[hibernate-issues] [Hibernate-JIRA] Created: (ANN-686) SubClass with EmbeddedId or IdClass containing @ManyToOne fail at startup

Marcos Sousa (JIRA) noreply at atlassian.com
Mon Dec 31 09:02:24 EST 2007


SubClass with EmbeddedId or IdClass containing @ManyToOne fail at startup
-------------------------------------------------------------------------

                 Key: ANN-686
                 URL: http://opensource.atlassian.com/projects/hibernate/browse/ANN-686
             Project: Hibernate Annotations
          Issue Type: Bug
    Affects Versions: 3.3.1.beta1, 3.3.0.ga
            Reporter: Marcos Sousa
            Priority: Minor


I subclass Customer that has a EmbeddedId using JOIN inheritance strategy. My embeddable class has @ManyToOne relationship. Look the classes:
Pesson class:
@Entity
@Table(name="person")
public class Person {
   @Id
   private Integer personId;
   private String name;
}   

Embeddable class ID.
@Embeddable
public class PersonPk implements Serializable {
   @ManyToOne(optional=false,
           cascade={CascadeType.PERSIST,
           CascadeType.REFRESH,
           CascadeType.REMOVE}, fetch=FetchType.EAGER)
   @JoinColumn(name="personId")
   private Person person;
   // ... getters and setters
} 

CustomerClass:
@Entity
@Table(name="Customer")
@Inheritance(strategy=InheritanceType.JOINED)
public class Customer {
   @Id
   private PersonPk pk = new PersonPk();
} 

Regional Custumer:
@Entity
@Table(name="AmericanCustomer")
@PrimaryKeyJoinColumn(name="personId")
@IdClass(PessoaPk.class)
public class AmericanCustomer extends Customer {
   // some american customer fields..
} 

This mapping throw this exception at hibernate startup:

Invocation of init method failed; nested exception is java.util.NoSuchElementException
Caused by: 
java.util.NoSuchElementException
	at java.util.AbstractList$Itr.next(Unknown Source)
	at org.hibernate.util.JoinedIterator.next(JoinedIterator.java:53)
	at org.hibernate.cfg.Ejb3JoinColumn.buildJoinColumn(Ejb3JoinColumn.java:210)
	at org.hibernate.cfg.AnnotationBinder.bindClass(AnnotationBinder.java:463)
	at org.hibernate.cfg.AnnotationConfiguration.processArtifactsOfType(AnnotationConfiguration.java:501)
	at org.hibernate.cfg.AnnotationConfiguration.secondPassCompile(AnnotationConfiguration.java:282)
	at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1286)
	at org.hibernate.cfg.AnnotationConfiguration.buildSessionFactory(AnnotationConfiguration.java:918)

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://opensource.atlassian.com/projects/hibernate/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        



More information about the hibernate-issues mailing list