-->
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.  [ 2 posts ] 
Author Message
 Post subject: Problem with composite key and OneToOne relation
PostPosted: Wed Jun 06, 2007 9:44 am 
Newbie

Joined: Wed Jun 06, 2007 9:01 am
Posts: 2
Hibernate version:3.2.3.ga

I have 3 classes A,B and C. B and C have only id's. A has pk which is a composite key AId and it's made from id's of B and C, and there are OneToOne relations from A to B and from A to C

this is the code:

Code:
@Entity
public class A implements Serializable{

   @EmbeddedId
   AId aId;
}

@Embeddable
public class AId implements Serializable{

   @OneToOne
   @JoinColumn(name="id")
   B b;
   
   @OneToOne
   @JoinColumn(name="id")
   C c;
}

@Entity
public class B {

   @Id@GeneratedValue
   private Long id;
}

@Entity
public class C {

   @Id@GeneratedValue
   private Long id;
}


When i try to run this i got:
Code:
[java] Initial SessionFactory creation failed.java.lang.NullPointerException
     [java] Exception in thread "main" java.lang.ExceptionInInitializerError
     [java] at util.HibernateUtil.<clinit>(Unknown Source)
     [java] at one.Start.main(Unknown Source)
     [java] Caused by: java.lang.NullPointerException
     [java] at org.hibernate.cfg.AnnotationBinder.bindOneToOne(AnnotationBinder.java:1960)
     [java] at org.hibernate.cfg.AnnotationBinder.processElementAnnotations(AnnotationBinder.java:1346)
     [java] at org.hibernate.cfg.AnnotationBinder.fillComponent(AnnotationBinder.java:1731)
     [java] at org.hibernate.cfg.AnnotationBinder.bindId(AnnotationBinder.java:1768)
     [java] at org.hibernate.cfg.AnnotationBinder.processElementAnnotations(AnnotationBinder.java:1229)
     [java] at org.hibernate.cfg.AnnotationBinder.bindClass(AnnotationBinder.java:733)
     [java] at org.hibernate.cfg.AnnotationConfiguration.processArtifactsOfType(AnnotationConfiguration.java:498)
     [java] at org.hibernate.cfg.AnnotationConfiguration.secondPassCompile(AnnotationConfiguration.java:277)
     [java] at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1286)
     [java] at org.hibernate.cfg.AnnotationConfiguration.buildSessionFactory(AnnotationConfiguration.java:915)
     [java] ... 2 more


Where Start is the class which I run and it just get the session

I've searched for solution but i couldn't find anything helpful

the only solution i could think of is to do it without composite key and then it works, but it isn't exactly what i wanted

Can you tell me what am I doing wrong with this OneToOne relation using composite key?


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jun 06, 2007 12:31 pm 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
oups, can you give it a try with 3.3, and open a JIRA issue if it's still the case,I'll have to check it out

_________________
Emmanuel


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 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.