-->
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.  [ 1 post ] 
Author Message
 Post subject: Multiple level Foreign Key.
PostPosted: Sun Dec 01, 2013 10:49 am 
Newbie

Joined: Sun Dec 01, 2013 10:18 am
Posts: 1
Hi,

Can someone help me with a problem?

I have the following case:
Code:
@Entity
@Table
public class EntityA {
   @Id
   @Column(name = "ID")
   private Integer id;
   ...
}

@Entity
@Table
public class EntityB {
   @Id
   @ManyToOne(targetEntity = EntityA.class)
   @JoinColumn(name = "ID")
   private EntityA id;
   ...
}

@Entity
@Table
public class EntityC {
   @Id
   @ManyToOne(targetEntity = EntityB.class)
   @JoinColumn(name = "ID")
   private EntityB id;
   ...
}

I do not know what is happening. However when I try to run it, I got the follow error:
Code:
Caused by: A Foreign key refering EntityB from EntityC has the wrong number of column. should be 0
   at org.hibernate.cfg.annotations.TableBinder.bindFk(TableBinder.java:432)
   at org.hibernate.cfg.ToOneFkSecondPass.doSecondPass(ToOneFkSecondPass.java:117)
   at org.hibernate.cfg.Configuration.processEndOfQueue(Configuration.java:1514)
   at org.hibernate.cfg.Configuration.processFkSecondPassInOrder(Configuration.java:1437)
   at org.hibernate.cfg.Configuration.secondPassCompile(Configuration.java:1355)
   at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1724)
   at org.hibernate.ejb.EntityManagerFactoryImpl.<init>(EntityManagerFactoryImpl.java:84)
   at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:904)
   ... 10 more

What can I do to fix it?
However, I cannot change the current table relationships.

Thanks for the help.


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

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.