[
http://opensource.atlassian.com/projects/hibernate/browse/HHH-1134?page=c...
]
Bob Petry commented on HHH-1134:
--------------------------------
Your comment :[The reasoning is that you should not reuse the same FK column for 2
different relationships, which is what is done here.]
is a dificult for me to understand.
I am facing the same problem, where multiple one to many relationships from PojoA to
multiple different subclassed Pojos (PojoC, PojoD, PojoE, where C, D and E are subclasses
of PojoB) exist.
Can you explain to me why a single column (with a foreign key to the ID of PojoA) in the
PojoB table that stores my subclassed Pojos, should not be done.
I don't think this is an unreasonable situation.
It seems silly to have a separate column for each subclass type, where each reference the
id of PojoA.
This seems like a bug to me that would have a simple fix. It seems like simply
performing, an instanceof on each of the SubClass types (until the proper type is
identified) rather than casting to the first type that is loaded would solve the issue.
Am I correct or is this issue and the proper solution more convoluted?
subclass tag with discriminator in one to many mapping
------------------------------------------------------
Key: HHH-1134
URL:
http://opensource.atlassian.com/projects/hibernate/browse/HHH-1134
Project: Hibernate3
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....
-
For more information on JIRA, see:
http://www.atlassian.com/software/jira