[hibernate-issues] [Hibernate-JIRA] Resolved: (EJB-208) EntityManager.find() fails finding JOINED mapped Subclass by ID and Superclass in MySql

Emmanuel Bernard (JIRA) noreply at atlassian.com
Mon Aug 28 19:03:24 EDT 2006


     [ 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 at 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.jspa
-
For more information on JIRA, see:
   http://www.atlassian.com/software/jira




More information about the hibernate-issues mailing list