From: <leg...@at...> - 2003-07-10 18:58:32
|
Message: A new issue has been created in JIRA. --------------------------------------------------------------------- View the issue: http://opensource.atlassian.com/projects/hibernate/secure/ViewIssue.jspa?key=HB-175 Here is an overview of the issue: --------------------------------------------------------------------- Key: HB-175 Summary: One-to-many association does not correctly discriminate when a subclass is specified Type: Bug Status: Unassigned Priority: Major Project: Hibernate2 Components: core Versions: 2.0.1 Assignee: Reporter: Peachawat Peachavanish Created: Thu, 10 Jul 2003 1:49 PM Updated: Thu, 10 Jul 2003 1:49 PM Environment: Gentoo Linux, Sun Java 1.4.1 Description: When using one-to-many association from 'Parent' to 'SubChild_1' and 'SubChild_2' where 'SubChild_1' and 'SubChild_2' are subclasses of 'Child', the generated SQL for hydrating a 'Parent' does not appropriate include 'where' clause to discriminate 'SubChild_1' or 'SubChild_2'. Class Declaration ================= 'Child.java' public abstract class Child{} 'SubChild_1.java' public class SubChild_1 extends Child {} 'SubChild_2.java' public class SubChild_2 extends Child {} 'Parent.java' public class Parent { private List subChilds_1 = new ArrayList(); private List subChilds_2 = new ArrayList(); } Mapping ======= 'Child.hbm.xml' <?xml version="1.0"?> <!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 2.0//EN" "http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd"> <hibernate-mapping> <class name="Child" discriminator-value="_"> <id name="id"> <generator class="native"/> </id> <discriminator column="CHILDTYPE"/> <property name="aProperty"/> <subclass name="SubChild_1" discriminator-value="1"/> <subclass name="SubChild_2" discriminator-value="2"/> </class> </hibernate-mapping> 'Parent.hmb.xml' <?xml version="1.0"?> <!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 2.0//EN" "http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd"> <hibernate-mapping> <class name="Parent"> <id name="id"> <generator class="native"/> </id> <property name="aProperty"/> <list name="subChilds_1" lazy="false" cascade="all"> <key column="parent_id"/> <index column="idx"/> <one-to-many class="SubChild_1"/> </list> <list name="subChilds_2" lazy="false" cascade="all"> <key column="parent_id"/> <index column="idx"/> <one-to-many class="SubChild_2"/> </list> </class> </hibernate-mapping> Generated SQL when perform session.find() ========================================= Hibernate: select child0_.id as id__, child0_.idx as idx__, child0_.id as id from Child child0_ where child0_.parent_id=? There is no 'where CHILDTYPE=?' discriminating clause. --------------------------------------------------------------------- JIRA INFORMATION: 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 If you want more information on JIRA, or have a bug to report see: http://www.atlassian.com/software/jira |