Skip to content

Instantly share code, notes, and snippets.

@nemo83
Created March 30, 2013 11:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nemo83/5276334 to your computer and use it in GitHub Desktop.
Save nemo83/5276334 to your computer and use it in GitHub Desktop.
@Embeddable
public class ProductItemPk implements Serializable {
private Item item;
private Product product;
@ManyToOne
public Item getItem() {
return item;
}
publicvoid setItem(Item item) {
this.item = item;
}
@ManyToOne
public Product getProduct() {
return product;
}
publicvoid setProduct(Product product) {
this.product = product;
}
publicboolean equals(Object o) {
if (this== o) returntrue;
if (o ==null|| getClass() != o.getClass()) returnfalse;
ProductItemPk that = (ProductItemPk) o;
if (item !=null?!item.equals(that.item) : that.item !=null) returnfalse;
if (product !=null?!product.equals(that.product) : that.product !=null)
returnfalse;
returntrue;
}
publicint hashCode() {
int result;
result = (item !=null? item.hashCode() : 0);
result =31* result + (product !=null? product.hashCode() : 0);
return result;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment