Created
March 30, 2013 11:06
-
-
Save nemo83/5276330 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Entity | |
@Table(name ="product_item") | |
@AssociationOverrides({ | |
@AssociationOverride(name ="pk.item", joinColumns = @JoinColumn(name ="item_id")), | |
@AssociationOverride(name ="pk.product", joinColumns = @JoinColumn(name ="product_id")) | |
}) | |
public class ProductItem { | |
private ProductItemPk pk =new ProductItemPk(); | |
@EmbeddedId | |
private ProductItemPk getPk() { | |
return pk; | |
} | |
privatevoid setPk(ProductItemPk pk) { | |
this.pk = pk; | |
} | |
@Transient | |
public Item getItem() { | |
return getPk().getItem(); | |
} | |
publicvoid setItem(Item item) { | |
getPk().setItem(item); | |
} | |
@Transient | |
public Product getProduct() { | |
return getPk().getProduct(); | |
} | |
publicvoid setProduct(Product product) { | |
getPk().setProduct(product); | |
} | |
publicboolean equals(Object o) { | |
if (this== o) returntrue; | |
if (o ==null|| getClass() != o.getClass()) returnfalse; | |
ProductItem that = (ProductItem) o; | |
if (getPk() !=null?!getPk().equals(that.getPk()) : that.getPk() !=null) returnfalse; | |
returntrue; | |
} | |
publicint hashCode() { | |
return (getPk() !=null? getPk().hashCode() : 0); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment