[hibernate-issues] [Hibernate-JIRA] Commented: (HHH-1134) subclass tag with discriminator in one to many mapping

HG (JIRA) noreply at atlassian.com
Thu May 20 08:42:11 EDT 2010


    [ http://opensource.atlassian.com/projects/hibernate/browse/HHH-1134?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=37224#action_37224 ] 

HG commented on HHH-1134:
-------------------------

Thanks Gail, Its infact related to HH-4953

A better work around would be somthing like :

if (clazz.isInstance(result)) { return result; }
return null;

And not cathing the ClassCastException

In my opinion, It would be best to have cache per concrete class with discriminator value, and not a cache per class hierachy. This would help having CacheKeys characterized by their class names and not root class names, hence making this discriminator concept workable on second level cache.

This would ofcourse mean a lot more work while querying caches using a Super classes. But frankly, I dont know the real impact on performance it will cost.

> subclass tag with discriminator in one to many mapping
> ------------------------------------------------------
>
>                 Key: HHH-1134
>                 URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-1134
>             Project: Hibernate Core
>          Issue Type: Bug
>          Components: core
>         Environment: hibernate 3.0.5, Oracle
>            Reporter: Dilip Ranjith
>
> Consider the following hbm.xml file 
> <?xml version="1.0" encoding="UTF-8"?> 
> <!DOCTYPE hibernate-mapping PUBLIC 
>     "-//Hibernate/Hibernate Mapping DTD 3.0//EN" 
>     "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd"> 
> <hibernate-mapping 
> > 
>     <class 
>         name="DCDTO" 
>         table="ACCDC" 
>         dynamic-update="true" 
>     > 
>         <id 
>             name="ID" 
>             type="java.lang.String" 
>         > 
>                 <column 
>                     name="DCINFOID" 
>                 /> 
>             <generator class="sequence"> 
>                 <param name="sequence">DSEQ</param> 
>               <!-- 
>                   To add non XDoclet generator parameters, create a file named 
>                   hibernate-generator-params-DebtorCreditorDTO.xml 
>                   containing the additional parameters and place it in your merge dir. 
>               --> 
>             </generator> 
>         </id> 
>         <discriminator 
>             column="accountType" 
>             not-null="true" 
>             type="java.lang.String" 
>             force="true" 
>             insert="true" 
>         /> 
>         <property 
>             name="creditMax" 
>             type="java.lang.Double" 
>             update="true" 
>             insert="true" 
>             column="creditMax" 
>         /> 
>  <subclass 
>             name="CDTO" 
>             dynamic-update="true" 
>             dynamic-insert="true" 
>             discriminator-value="C" 
>         > 
> </.subclass> 
>  <subclass 
>             name="DDTO" 
>             dynamic-update="true" 
>             dynamic-insert="true" 
>             discriminator-value="D" 
>         > 
> </.subclass> 
> </class> 
> </hibernate-mapping> 
> DCDTO is the super class while DDTO and CDTO are its child classes 
> If in a mapped object say  TDTO   there are a set of CDTOs and a separate set of DDTOs
> when we get TDTO  the where clause "where  accountType='D'  " is not there when the query for set of DDTOs are generated. so instead of a set of DDTOs i am getting a set of both DDTO's and CDTO's

-- 
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