-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 
Author Message
 Post subject: mappedBy reference an unknown target entity property
PostPosted: Thu Aug 13, 2009 6:43 am 
Newbie

Joined: Sun Aug 09, 2009 12:14 pm
Posts: 16
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 ?


Top
 Profile  
 
 Post subject: Re: mappedBy reference an unknown target entity property
PostPosted: Fri Aug 14, 2009 8:00 am 
Beginner
Beginner

Joined: Fri Sep 08, 2006 7:29 am
Posts: 36
Take a look at this...it might help....

I am assuming you are trying to do something similar...

http://boris.kirzner.info/blog/archives ... osite-key/

_________________
Shardul
Please Rate.


Top
 Profile  
 
 Post subject: Re: mappedBy reference an unknown target entity property
PostPosted: Mon Aug 17, 2009 2:16 am 
Newbie

Joined: Sun Aug 09, 2009 12:14 pm
Posts: 16
I have tried to find a hint in the solution above but its not my case, my case is just the opposite actually.
I have found much easier solution to the mapping into PK when the last is the many on the relation ( https://forum.hibernate.org/viewtopic.php?f=1&t=998848 )

This time the OneToMany annotation is placed in the PK class.

I'm still stuck with this problem, anyone has a solution ????

It seems that this issue was discussed in the past but with no solution:
http://opensource.atlassian.com/project ... e/HHH-2872


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.