From: Markus J. (JIRA) <no...@at...> - 2006-06-19 15:34:33
|
Polymorphic association to a MappedSuperclass throws exception -------------------------------------------------------------- Key: EJB-199 URL: http://opensource.atlassian.com/projects/hibernate/browse/EJB-199 Project: Hibernate Entity Manager Type: Bug Components: EntityManager Versions: 3.2.0.cr1 Environment: Annotations CR1, EntityManager CR1, and Hibernate 3.2 CR2 Reporter: Markus Junginger I think it should be possible to have polymorphic association to a class annotated as a MappedSuperclass. However, this combination throws an exception. The class Xyz is a super class for a couple of entity classes: @MappedSuperclass public abstract class Xyz{...} The following association to Xyz does not work (see exception below) @ManyToOne(fetch = FetchType.LAZY) @JoinColumns({...}) private Xyz test; If it matters, each entity (the sub classes of Xyz) is annotated with @Inheritance(strategy = InheritanceType.TABLE_PER_CLASS). Here's the execption: javax.persistence.PersistenceException: org.hibernate.AnnotationException: @OneToOne or @ManyToOne on play.abc.test references an unknown entity: play.Xyz at org.hibernate.ejb.Ejb3Configuration.createEntityManagerFactory(Ejb3Configuration.java:196) at org.hibernate.ejb.HibernatePersistence.createEntityManagerFactory(HibernatePersistence.java:114) at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:37) at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:27) ... Caused by: org.hibernate.AnnotationException: @OneToOne or @ManyToOne on play.abc.test references an unknown entity: play.Xyz at org.hibernate.cfg.FkSecondPass.doSecondPass(FkSecondPass.java:40) at org.hibernate.cfg.AnnotationConfiguration.secondPassCompile(AnnotationConfiguration.java:261) at org.hibernate.cfg.Configuration.buildMappings(Configuration.java:1034) at org.hibernate.ejb.Ejb3Configuration.buildMappings(Ejb3Configuration.java:868) at org.hibernate.ejb.EventListenerConfigurator.configure(EventListenerConfigurator.java:163) at org.hibernate.ejb.Ejb3Configuration.createEntityManagerFactory(Ejb3Configuration.java:641) at org.hibernate.ejb.Ejb3Configuration.createFactory(Ejb3Configuration.java:134) at org.hibernate.ejb.Ejb3Configuration.createEntityManagerFactory(Ejb3Configuration.java:188) ... 20 more -- 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 |
From: Emmanuel B. (JIRA) <no...@at...> - 2006-06-20 02:09:32
|
[ http://opensource.atlassian.com/projects/hibernate/browse/EJB-199?page=all ] Emmanuel Bernard resolved EJB-199: ---------------------------------- Resolution: Rejected Nope that's expected Only entities can be associated to each other an mapped superclass is not an entity > Polymorphic association to a MappedSuperclass throws exception > -------------------------------------------------------------- > > Key: EJB-199 > URL: http://opensource.atlassian.com/projects/hibernate/browse/EJB-199 > Project: Hibernate Entity Manager > Type: Bug > Components: EntityManager > Versions: 3.2.0.cr1 > Environment: Annotations CR1, EntityManager CR1, and Hibernate 3.2 CR2 > Reporter: Markus Junginger > > > I think it should be possible to have polymorphic association to a class annotated as a MappedSuperclass. However, this combination throws an exception. > The class Xyz is a super class for a couple of entity classes: > @MappedSuperclass > public abstract class Xyz{...} > The following association to Xyz does not work (see exception below) > @ManyToOne(fetch = FetchType.LAZY) > @JoinColumns({...}) > private Xyz test; > If it matters, each entity (the sub classes of Xyz) is annotated with > @Inheritance(strategy = InheritanceType.TABLE_PER_CLASS). > Here's the execption: > javax.persistence.PersistenceException: org.hibernate.AnnotationException: @OneToOne or @ManyToOne on play.abc.test references an unknown entity: play.Xyz > at org.hibernate.ejb.Ejb3Configuration.createEntityManagerFactory(Ejb3Configuration.java:196) > at org.hibernate.ejb.HibernatePersistence.createEntityManagerFactory(HibernatePersistence.java:114) > at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:37) > at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:27) > ... > Caused by: org.hibernate.AnnotationException: @OneToOne or @ManyToOne on play.abc.test references an unknown entity: play.Xyz > at org.hibernate.cfg.FkSecondPass.doSecondPass(FkSecondPass.java:40) > at org.hibernate.cfg.AnnotationConfiguration.secondPassCompile(AnnotationConfiguration.java:261) > at org.hibernate.cfg.Configuration.buildMappings(Configuration.java:1034) > at org.hibernate.ejb.Ejb3Configuration.buildMappings(Ejb3Configuration.java:868) > at org.hibernate.ejb.EventListenerConfigurator.configure(EventListenerConfigurator.java:163) > at org.hibernate.ejb.Ejb3Configuration.createEntityManagerFactory(Ejb3Configuration.java:641) > at org.hibernate.ejb.Ejb3Configuration.createFactory(Ejb3Configuration.java:134) > at org.hibernate.ejb.Ejb3Configuration.createEntityManagerFactory(Ejb3Configuration.java:188) > ... 20 more -- 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 |
From: Markus J. (JIRA) <no...@at...> - 2006-06-20 08:52:35
|
[ http://opensource.atlassian.com/projects/hibernate/browse/EJB-199?page=comments#action_23360 ] Markus Junginger commented on EJB-199: -------------------------------------- I agree with you in terms of JSR-220 (section 2.1.9.2 Mapped Superclasses: A class designated as MappedSuperclass has no separate table defined for it.) Nevertheless, I think this feature would make perfectly sense. We have several abstract classes that are NOT mapped to tables, but sub classes have their table counterparts. Background: I am working on a big migration project (including an homegrown ORM tool to be replaced) and without this feature we probably do not let Hibernate/EJB3.0 manage relationships. > Polymorphic association to a MappedSuperclass throws exception > -------------------------------------------------------------- > > Key: EJB-199 > URL: http://opensource.atlassian.com/projects/hibernate/browse/EJB-199 > Project: Hibernate Entity Manager > Type: Bug > Components: EntityManager > Versions: 3.2.0.cr1 > Environment: Annotations CR1, EntityManager CR1, and Hibernate 3.2 CR2 > Reporter: Markus Junginger > > > I think it should be possible to have polymorphic association to a class annotated as a MappedSuperclass. However, this combination throws an exception. > The class Xyz is a super class for a couple of entity classes: > @MappedSuperclass > public abstract class Xyz{...} > The following association to Xyz does not work (see exception below) > @ManyToOne(fetch = FetchType.LAZY) > @JoinColumns({...}) > private Xyz test; > If it matters, each entity (the sub classes of Xyz) is annotated with > @Inheritance(strategy = InheritanceType.TABLE_PER_CLASS). > Here's the execption: > javax.persistence.PersistenceException: org.hibernate.AnnotationException: @OneToOne or @ManyToOne on play.abc.test references an unknown entity: play.Xyz > at org.hibernate.ejb.Ejb3Configuration.createEntityManagerFactory(Ejb3Configuration.java:196) > at org.hibernate.ejb.HibernatePersistence.createEntityManagerFactory(HibernatePersistence.java:114) > at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:37) > at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:27) > ... > Caused by: org.hibernate.AnnotationException: @OneToOne or @ManyToOne on play.abc.test references an unknown entity: play.Xyz > at org.hibernate.cfg.FkSecondPass.doSecondPass(FkSecondPass.java:40) > at org.hibernate.cfg.AnnotationConfiguration.secondPassCompile(AnnotationConfiguration.java:261) > at org.hibernate.cfg.Configuration.buildMappings(Configuration.java:1034) > at org.hibernate.ejb.Ejb3Configuration.buildMappings(Ejb3Configuration.java:868) > at org.hibernate.ejb.EventListenerConfigurator.configure(EventListenerConfigurator.java:163) > at org.hibernate.ejb.Ejb3Configuration.createEntityManagerFactory(Ejb3Configuration.java:641) > at org.hibernate.ejb.Ejb3Configuration.createFactory(Ejb3Configuration.java:134) > at org.hibernate.ejb.Ejb3Configuration.createEntityManagerFactory(Ejb3Configuration.java:188) > ... 20 more -- 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 |
From: Christian B. (JIRA) <no...@at...> - 2006-06-20 08:59:32
|
[ http://opensource.atlassian.com/projects/hibernate/browse/EJB-199?page=comments#action_23361 ] Christian Bauer commented on EJB-199: ------------------------------------- So use TABLE_PER_CLASS for your abstract classes and you get what you want with the same schema. > Polymorphic association to a MappedSuperclass throws exception > -------------------------------------------------------------- > > Key: EJB-199 > URL: http://opensource.atlassian.com/projects/hibernate/browse/EJB-199 > Project: Hibernate Entity Manager > Type: Bug > Components: EntityManager > Versions: 3.2.0.cr1 > Environment: Annotations CR1, EntityManager CR1, and Hibernate 3.2 CR2 > Reporter: Markus Junginger > > > I think it should be possible to have polymorphic association to a class annotated as a MappedSuperclass. However, this combination throws an exception. > The class Xyz is a super class for a couple of entity classes: > @MappedSuperclass > public abstract class Xyz{...} > The following association to Xyz does not work (see exception below) > @ManyToOne(fetch = FetchType.LAZY) > @JoinColumns({...}) > private Xyz test; > If it matters, each entity (the sub classes of Xyz) is annotated with > @Inheritance(strategy = InheritanceType.TABLE_PER_CLASS). > Here's the execption: > javax.persistence.PersistenceException: org.hibernate.AnnotationException: @OneToOne or @ManyToOne on play.abc.test references an unknown entity: play.Xyz > at org.hibernate.ejb.Ejb3Configuration.createEntityManagerFactory(Ejb3Configuration.java:196) > at org.hibernate.ejb.HibernatePersistence.createEntityManagerFactory(HibernatePersistence.java:114) > at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:37) > at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:27) > ... > Caused by: org.hibernate.AnnotationException: @OneToOne or @ManyToOne on play.abc.test references an unknown entity: play.Xyz > at org.hibernate.cfg.FkSecondPass.doSecondPass(FkSecondPass.java:40) > at org.hibernate.cfg.AnnotationConfiguration.secondPassCompile(AnnotationConfiguration.java:261) > at org.hibernate.cfg.Configuration.buildMappings(Configuration.java:1034) > at org.hibernate.ejb.Ejb3Configuration.buildMappings(Ejb3Configuration.java:868) > at org.hibernate.ejb.EventListenerConfigurator.configure(EventListenerConfigurator.java:163) > at org.hibernate.ejb.Ejb3Configuration.createEntityManagerFactory(Ejb3Configuration.java:641) > at org.hibernate.ejb.Ejb3Configuration.createFactory(Ejb3Configuration.java:134) > at org.hibernate.ejb.Ejb3Configuration.createEntityManagerFactory(Ejb3Configuration.java:188) > ... 20 more -- 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 |
From: Emmanuel B. (JIRA) <no...@at...> - 2006-06-21 01:47:31
|
[ http://opensource.atlassian.com/projects/hibernate/browse/EJB-199?page=comments#action_23366 ] Emmanuel Bernard commented on EJB-199: -------------------------------------- christian is right, TABLE_PER_CLASS with the root class made abstract is the way to map your requirement. > Polymorphic association to a MappedSuperclass throws exception > -------------------------------------------------------------- > > Key: EJB-199 > URL: http://opensource.atlassian.com/projects/hibernate/browse/EJB-199 > Project: Hibernate Entity Manager > Type: Bug > Components: EntityManager > Versions: 3.2.0.cr1 > Environment: Annotations CR1, EntityManager CR1, and Hibernate 3.2 CR2 > Reporter: Markus Junginger > > > I think it should be possible to have polymorphic association to a class annotated as a MappedSuperclass. However, this combination throws an exception. > The class Xyz is a super class for a couple of entity classes: > @MappedSuperclass > public abstract class Xyz{...} > The following association to Xyz does not work (see exception below) > @ManyToOne(fetch = FetchType.LAZY) > @JoinColumns({...}) > private Xyz test; > If it matters, each entity (the sub classes of Xyz) is annotated with > @Inheritance(strategy = InheritanceType.TABLE_PER_CLASS). > Here's the execption: > javax.persistence.PersistenceException: org.hibernate.AnnotationException: @OneToOne or @ManyToOne on play.abc.test references an unknown entity: play.Xyz > at org.hibernate.ejb.Ejb3Configuration.createEntityManagerFactory(Ejb3Configuration.java:196) > at org.hibernate.ejb.HibernatePersistence.createEntityManagerFactory(HibernatePersistence.java:114) > at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:37) > at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:27) > ... > Caused by: org.hibernate.AnnotationException: @OneToOne or @ManyToOne on play.abc.test references an unknown entity: play.Xyz > at org.hibernate.cfg.FkSecondPass.doSecondPass(FkSecondPass.java:40) > at org.hibernate.cfg.AnnotationConfiguration.secondPassCompile(AnnotationConfiguration.java:261) > at org.hibernate.cfg.Configuration.buildMappings(Configuration.java:1034) > at org.hibernate.ejb.Ejb3Configuration.buildMappings(Ejb3Configuration.java:868) > at org.hibernate.ejb.EventListenerConfigurator.configure(EventListenerConfigurator.java:163) > at org.hibernate.ejb.Ejb3Configuration.createEntityManagerFactory(Ejb3Configuration.java:641) > at org.hibernate.ejb.Ejb3Configuration.createFactory(Ejb3Configuration.java:134) > at org.hibernate.ejb.Ejb3Configuration.createEntityManagerFactory(Ejb3Configuration.java:188) > ... 20 more -- 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 |