[Hibernate-JIRA] Resolved: (EJB-208) EntityManager.find() fails finding JOINED mapped Subclass by ID and Superclass in MySql
by Emmanuel Bernard (JIRA)
[ http://opensource.atlassian.com/projects/hibernate/browse/EJB-208?page=all ]
Emmanuel Bernard resolved EJB-208:
----------------------------------
Resolution: Cannot Reproduce
Works for me on MySQL 5
> EntityManager.find() fails finding JOINED mapped Subclass by ID and Superclass in MySql
> ----------------------------------------------------------------------------------------
>
> Key: EJB-208
> URL: http://opensource.atlassian.com/projects/hibernate/browse/EJB-208
> Project: Hibernate Entity Manager
> Type: Bug
> Components: EntityManager
> Versions: 3.2.0.cr1
> Environment: WinXP
> Reporter: B.Schmacka
> Attachments: hibernate_bug.zip
>
>
> There is a by finding an entity by ID from the EntityManager using its find() method. If does not work if you use MySql and try to find an abstract entity by id and its abstract super class:
> I used Hibernate to persist the object. I boiled it down to the following test lines:
> Test model classes:
> @Entity
> @Inheritance(strategy = InheritanceType.JOINED)
> public abstract class AbstractSuperclass{
> Long id;
> @Id @GeneratedValue
> public Long getId() { return id; }
> public void setId(Long id) { this.id = id; }
> }
> @Entity
> public class Subclass extends AbstractSuperclass {}
> Test Code:
>
> EntityManager firstSession = ...
> Subclass u = new Subclass();
> firstSession.getTransaction().begin();
> firstSession.persist(u);
> firstSession.getTransaction().commit();
> Long newId = u.getId();
> System.out.println("new ID is:" + newId);
> firstSession.close();
> EntityManager secondSession = ...
> secondSession.getTransaction().begin();
> // 1.
> Subclass result1 = secondSession.find(Subclass.class, newId);
> System.out.println("1. result is:" + result1);
> // 2.
> Subclass result2 = (Subclass) secondSession.find(AbstractSuperclass.class, newId);
> System.out.println("2. result is:" + result2);
> secondSession.getTransaction().commit();
> secondSession.close();
>
> Result is:
> new ID is:1
> 1. result is:null
> 2. result is:com.riacom.dms.model.Subclass@3afb99
> But it works (first result is != null) with SINGLE_TABLE. It also works with JOINED tables for postgres and hsqldb, but not for mysql.
> An small test case (eclipse project including all libs) is provided as attachment.
--
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....
-
For more information on JIRA, see:
http://www.atlassian.com/software/jira
18 years, 4 months
[Hibernate-JIRA] Moved: (ANN-427) throw "java.lang.IllegalStateException: Property parent has an unbound type and no explicit target entity." on generic type
by Emmanuel Bernard (JIRA)
[ http://opensource.atlassian.com/projects/hibernate/browse/ANN-427?page=all ]
Emmanuel Bernard moved EJB-213 to ANN-427:
------------------------------------------
Project: Hibernate Annotations (was: Hibernate Entity Manager)
Key: ANN-427 (was: EJB-213)
Component: binder
(was: EntityManager)
Version: 3.2.0.cr1
(was: 3.2.0.cr1)
> throw "java.lang.IllegalStateException: Property parent has an unbound type and no explicit target entity." on generic type
> ---------------------------------------------------------------------------------------------------------------------------
>
> Key: ANN-427
> URL: http://opensource.atlassian.com/projects/hibernate/browse/ANN-427
> Project: Hibernate Annotations
> Type: Bug
> Components: binder
> Versions: 3.2.0.cr1
> Environment: Hibernate version: 3.2.0.cr2<br>
> Mapping documents: Annotations 3.2.0.cr1
> Reporter: Zheng.Duan
> Attachments: jira.zip
>
> Original Estimate: 2 weeks
> Remaining: 2 weeks
>
> Classes and mapping code: <br>
> <code>
> @MappedSuperclass
> public abstract class Child<P extends Parent> {
> @Id Long id;
> @ManyToOne P parent;
> ...
> }
> @MappedSuperclass
> public abstract class Parent<C extends Child> {
> @Id @GeneratedValue Long id;
> @MapKey @OneToMany(mappedBy="parent") Map<Long,C> children = new HashMap<Long,C>();
> ...
> }
> @Entity
> public class ChildHierarchy1 extends Child<ParentHierarchy1> {
> ....
> }
> @Entity
> public class ParentHierarchy1 extends Parent<ChildHierarchy1> {
> ....
> }
> @MappedSuperclass
> public class ChildHierarchy2<P extends ParentHierarchy2> extends Child<P> {
> ....
> }
> @MappedSuperclass
> public class ParentHierarchy2<C extends ChildHierarchy2> extends Parent<C> {
> ....
> }
> @Entity
> public class ChildHierarchy22 extends ChildHierarchy2<ParentHierarchy22> {
> ....
> }
> @Entity
> public class ParentHierarchy22 extends ParentHierarchy2<ChildHierarchy22> {
> ....
> }
> </code>
> Full stack trace of exception:
> <code>
> Caused by: java.lang.IllegalStateException: Property parent has an unbound type and no explicit target entity.
> at org.hibernate.cfg.AnnotationBinder.addElementsOfAClass(AnnotationBinder.java:938)
> at org.hibernate.cfg.AnnotationBinder.getElementsToProcess(AnnotationBinder.java:788)
> at org.hibernate.cfg.AnnotationBinder.bindClass(AnnotationBinder.java:615)
> at org.hibernate.cfg.AnnotationConfiguration.processArtifactsOfType(AnnotationConfiguration.java:353)
> at org.hibernate.cfg.AnnotationConfiguration.secondPassCompile(AnnotationConfiguration.java:265)
> at org.hibernate.cfg.Configuration.buildMappings(Configuration.java:1034)
> at org.hibernate.ejb.Ejb3Configuration.buildMappings(Ejb3Configuration.java:1015)
> at org.hibernate.ejb.EventListenerConfigurator.configure(EventListenerConfigurator.java:154)
> at org.hibernate.ejb.Ejb3Configuration.createEntityManagerFactory(Ejb3Configuration.java:751)
> at org.hibernate.ejb.Ejb3Configuration.createFactory(Ejb3Configuration.java:151)
> at org.hibernate.ejb.Ejb3Configuration.createEntityManagerFactory(Ejb3Configuration.java:205)
> ... 4 more
> </code>
> if let <code>org.hibernate.cfg.AnnotationBinder.hasExplicitTargetEntity(XProperty p)</code> return <code>true</code>(it return <code>false</code> actually) then throw:<br>
> <code>
> Caused by: org.hibernate.AnnotationException: @OneToOne or @ManyToOne on zhengduan.entities.ChildHierarchy22.parent references an unknown entity: zhengduan.entities.ParentHierarchy2
> at org.hibernate.cfg.FkSecondPass.doSecondPass(FkSecondPass.java:40)
> at org.hibernate.cfg.AnnotationConfiguration.secondPassCompile(AnnotationConfiguration.java:288)
> at org.hibernate.cfg.Configuration.buildMappings(Configuration.java:1034)
> at org.hibernate.ejb.Ejb3Configuration.buildMappings(Ejb3Configuration.java:1015)
> at org.hibernate.ejb.EventListenerConfigurator.configure(EventListenerConfigurator.java:154)
> at org.hibernate.ejb.Ejb3Configuration.createEntityManagerFactory(Ejb3Configuration.java:751)
> at org.hibernate.ejb.Ejb3Configuration.createFactory(Ejb3Configuration.java:151)
> at org.hibernate.ejb.Ejb3Configuration.createEntityManagerFactory(Ejb3Configuration.java:205)
> ... 4 more
> </code>
> But it's wrong, <code>zhengduan.entities.ChildHierarchy22.parent</code> references <code>zhengduan.entities.ParentHierarchy22</code>, not <code>zhengduan.entities.ParentHierarchy2</code>!
--
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....
-
For more information on JIRA, see:
http://www.atlassian.com/software/jira
18 years, 4 months
[Hibernate-JIRA] Resolved: (ANN-390) Property pointed to by "mappedBy" not found if defined in superclass of class referenced by "targetType"
by Emmanuel Bernard (JIRA)
[ http://opensource.atlassian.com/projects/hibernate/browse/ANN-390?page=all ]
Emmanuel Bernard resolved ANN-390:
----------------------------------
Resolution: Won't Fix
I've enhanced the exception message to include "target entity"
> Property pointed to by "mappedBy" not found if defined in superclass of class referenced by "targetType"
> --------------------------------------------------------------------------------------------------------
>
> Key: ANN-390
> URL: http://opensource.atlassian.com/projects/hibernate/browse/ANN-390
> Project: Hibernate Annotations
> Type: Bug
> Environment: Windows XP SP2, Eclipse 3.2 final, WTP 1.5 final
> HibernateTools-3.2.0.200607060659-nightly.zip with relevant jars in org.hibernate.eclipse_3.2.0.200607060659-nightly plugin replaced with same date jars built from SVN. Removed WTP plugins from Hibernate Tools dist since I already had them loaded.
> I realize that this does not exactly match the build drivers for the nightly I'm using, but I don't think this is the issue here.
> Reporter: Adrian Sampaleanu
>
>
> When trying to open session factory in the Hibernate Console, I get:
> org.hibernate.AnnotationException: mappedBy reference an unknown property: com.tirawireless.jump.jdm.model.task.DeploymentTaskImpl.deploymentPlan in com.tirawireless.jump.jdm.model.plan.DeploymentPlanImpl.deploymentTasks
> at org.hibernate.cfg.annotations.CollectionBinder.bindStarToManySecondPass(CollectionBinder.java:503)
> .....
> The relevant property and annotation is as follows:
> @OneToMany(targetEntity = DeploymentTaskImpl.class, mappedBy = "deploymentPlan", fetch = FetchType.LAZY)
> @OrderBy(clause = "name ASC")
> @Cascade({CascadeType.SAVE_UPDATE})
> public Set<DeploymentTask> getDeploymentTasks()
> The "deploymentPlan" property is _not_ defined in DeploymentTaskImpl, but is defined in it's superclass. I would think that it should be visible when establishing the mapping above.
> Have not found this issue addressed in either the forums or JIRA.
--
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....
-
For more information on JIRA, see:
http://www.atlassian.com/software/jira
18 years, 4 months
[Hibernate-JIRA] Commented: (ANN-390) Property pointed to by "mappedBy" not found if defined in superclass of class referenced by "targetType"
by Adrian Sampaleanu (JIRA)
[ http://opensource.atlassian.com/projects/hibernate/browse/ANN-390?page=co... ]
Adrian Sampaleanu commented on ANN-390:
---------------------------------------
Our situation is 3, and I see your point - the bi-directional mapping we had was not correct from that point of view so Hibernate's message was accurate, although it might be worded a bit more clearly to indicate that it wasn't found in the targetEntity (in our case that was DeploymentTaskImpl).
Thanks
> Property pointed to by "mappedBy" not found if defined in superclass of class referenced by "targetType"
> --------------------------------------------------------------------------------------------------------
>
> Key: ANN-390
> URL: http://opensource.atlassian.com/projects/hibernate/browse/ANN-390
> Project: Hibernate Annotations
> Type: Bug
> Environment: Windows XP SP2, Eclipse 3.2 final, WTP 1.5 final
> HibernateTools-3.2.0.200607060659-nightly.zip with relevant jars in org.hibernate.eclipse_3.2.0.200607060659-nightly plugin replaced with same date jars built from SVN. Removed WTP plugins from Hibernate Tools dist since I already had them loaded.
> I realize that this does not exactly match the build drivers for the nightly I'm using, but I don't think this is the issue here.
> Reporter: Adrian Sampaleanu
>
>
> When trying to open session factory in the Hibernate Console, I get:
> org.hibernate.AnnotationException: mappedBy reference an unknown property: com.tirawireless.jump.jdm.model.task.DeploymentTaskImpl.deploymentPlan in com.tirawireless.jump.jdm.model.plan.DeploymentPlanImpl.deploymentTasks
> at org.hibernate.cfg.annotations.CollectionBinder.bindStarToManySecondPass(CollectionBinder.java:503)
> .....
> The relevant property and annotation is as follows:
> @OneToMany(targetEntity = DeploymentTaskImpl.class, mappedBy = "deploymentPlan", fetch = FetchType.LAZY)
> @OrderBy(clause = "name ASC")
> @Cascade({CascadeType.SAVE_UPDATE})
> public Set<DeploymentTask> getDeploymentTasks()
> The "deploymentPlan" property is _not_ defined in DeploymentTaskImpl, but is defined in it's superclass. I would think that it should be visible when establishing the mapping above.
> Have not found this issue addressed in either the forums or JIRA.
--
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....
-
For more information on JIRA, see:
http://www.atlassian.com/software/jira
18 years, 4 months