Item.class
Code:
@Entity
public class Item implements Serializable {
private static final long serialVersionUID = 8635086262992868784L;
@EmbeddedId
public ItemPK itemPK;
@Column(name = "ITM_ITEM_NAME")
private String itemName;
}
ItemPK.class
Code:
@Embeddable
public class ItemPK implements Serializable {
private static final long serialVersionUID = -5177491823551943094L;
@OneToMany(mappedBy="itemPK")
private Set<ItemCrossReference> itemCrossReferences;
@Column(name="ITM_COMP_ID", nullable=false)
private String companyId;
@Column(name="ITM_ITEM_CODE", nullable=false)
private String itemCode;
// setter/ getter ...
public void setItemCrossReferences(Set<ItemCrossReference> itemCrossReferences) {
this.itemCrossReferences = itemCrossReferences;
}
public Set<ItemCrossReference> getItemCrossReferences() {
return itemCrossReferences;
}
public boolean equals(Object other) {
if (other instanceof ItemPK) {
final ItemPK otherItemPK = (ItemPK) other;
return (otherItemPK.companyId.equals(companyId) && otherItemPK.itemCode.equals(itemCode));
}
return false;
}
public int hashCode() {
return super.hashCode();
}
}
ItemCrossReference.class
Code:
@Entity
public class ItemCrossReference {
@EmbeddedId
public ItemCrossReferencePK itemCrossReferencePK;
@ManyToOne
@JoinColumns( {
@JoinColumn(name = "REF_MANUF_CMP_CODE", referencedColumnName = "ITM_COMP_ID"),
@JoinColumn(name = "REF_MANUF_REF_CODE", referencedColumnName = "ITM_ITEM_CODE") })
protected Item manufItem;
@Embedded
protected CreationDetails creationDetails;
}
Stack
Code:
Caused by: org.hibernate.AnnotationException: mappedBy reference an unknown target entity property: model.ItemCrossReference.itemPK in model.Item.itemCrossReferences
at org.hibernate.cfg.annotations.CollectionBinder.bindStarToManySecondPass(CollectionBinder.java:578)
at org.hibernate.cfg.annotations.CollectionBinder$1.secondPass(CollectionBinder.java:543)
at org.hibernate.cfg.CollectionSecondPass.doSecondPass(CollectionSecondPass.java:43)
at org.hibernate.cfg.Configuration.secondPassCompile(Configuration.java:1130)
at org.hibernate.cfg.AnnotationConfiguration.secondPassCompile(AnnotationConfiguration.java:329)
at org.hibernate.cfg.Configuration.buildMappings(Configuration.java:1115)
at org.hibernate.ejb.Ejb3Configuration.buildMappings(Ejb3Configuration.java:1226)
at org.hibernate.ejb.EventListenerConfigurator.configure(EventListenerConfigurator.java:173)
at org.hibernate.ejb.Ejb3Configuration.configure(Ejb3Configuration.java:854)
at org.hibernate.ejb.Ejb3Configuration.configure(Ejb3Configuration.java:425)
at org.hibernate.ejb.HibernatePersistence.createContainerEntityManagerFactory(HibernatePersistence.java:131)
at org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean.createNativeEntityManagerFactory(LocalContainerEntityManagerFactoryBean.java:224)
at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.afterPropertiesSet(AbstractEntityManagerFactoryBean.java:291)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1369)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1335)
i believe its something with my mapping but what exactly wrong ?