[hibernate-issues] [Hibernate-JIRA] Commented: (HHH-6157) Column under a duplicate alias in union-subclass filtered from select statement
Diego del Río (JIRA)
noreply at atlassian.com
Mon Apr 25 12:24:59 EDT 2011
[ http://opensource.atlassian.com/projects/hibernate/browse/HHH-6157?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=42142#action_42142 ]
Diego del Río commented on HHH-6157:
------------------------------------
The test fails in all the 3.6 versions
> Column under a duplicate alias in union-subclass filtered from select statement
> -------------------------------------------------------------------------------
>
> Key: HHH-6157
> URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-6157
> Project: Hibernate Core
> Issue Type: Bug
> Components: core
> Affects Versions: 3.6.1
> Environment: Hibernate Core 3.6.1.Final
> Database ->
> name : HSQL Database Engine
> version : 1.8.0
> major : 1
> minor : 8
> Driver ->
> name : HSQL Database Engine Driver
> version : 1.8.0
> major : 1
> minor : 8
> Reporter: Diego del Río
> Attachments: test_case.zip
>
>
> I think there is a bug in the process of column alias generation.
> Given this mapping
> {code:xml}
> <?xml version="1.0" encoding="ISO-8859-1"?>
> <!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD//EN" "http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd">
> <hibernate-mapping package="org.headlesspigs.domainmodel">
> <class name="Invoice" abstract="true">
> <id name="id" column="ID" type="long" unsaved-value="0">
> <generator class="hilo" />
> </id>
> <property name="name" type="string" column="DS_NAME" />
> <union-subclass name="SpecificInvoice" table="TEST_SPECIFIC">
> <!-- "sameNameAsInvoice" is intentionally mapped to the same column as
> the inherited property "name" is -->
> <property name="sameNameAsInvoice" type="string" column="DS_NAME"
> insert="false" update="false" />
> <property name="number" column="DS_NUMBER" type="string" />
> <property name="code" column="DS_CODE" type="string" />
> </union-subclass>
> </class>
> </hibernate-mapping>
> {code}
> During the process of alias generation, the column {{DS_CODE}} gets the same alias as the column {{DS_NAME}} from {{SpecificInvoice}}. Later on, when the {{UnionSubclassEntityPersister}} builds the _select_ part of the SQL statement in the method {{propertySelectFragment()}}, {{DS_CODE}} is filtered out from the select string in the method {{SelectFragment.toFragmentString()}}.
> When the entity is being loaded, the entity loader uses the wrong alias for the {{DS_CODE}} column and instead obtains the value of the column {{DS_NAME}}, leading to an {{SpecificInvoice}} instance with the wrong value for the property _code_. If, instead, the property _code_ had a different type, e.g. {{many-to-one}}, that would potentially lead to an {{ObjectNotFoundException}}, because the identifier used to load the associated entity would be wrong.
> A test case (along with the mapping file and domain classes) is attached, that shows the entity {{SpecificInvoice}} being loaded with its property _code_ with the wrong value.
--
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