[
http://opensource.atlassian.com/projects/hibernate/browse/HHH-1901?page=c...
]
Nicolas commented on HHH-1901:
------------------------------
Using Hibernate 3.2.4ga
Database : Oracle 10gR2 or MySQL 5.0.27
I've got the same kind of problem with the following mapping :
<hibernate-mapping default-access="field">
<class name="org.escapek.core.domain.Node" table="NODES">
<id name="Id" column="NODE_ID">
<generator class="uuid"/>
</id>
<property name="instanceName" column="INSTANCE_NAME"/>
<property name="creationDate" column="CREATION_DATE"/>
<property name="lastModifiedDate"
column="LAST_MODIFIED_DATE"/>
<property name="deletedDate" column="DELETE_DATE"/>
<property name="status" column="STATUS"/>
<many-to-one name="owner" column="OWNER_FK"
lazy="false" />
<many-to-one name="creationUser" column="CREATION_USER_FK"
lazy="false" />
<many-to-one name="lastModifiedUser"
column="LAST_MODIFIED_USER_FK" lazy="false" />
<many-to-one name="deleteUser" column="DELETE_USER_FK"
lazy="false" />
<set name="notes" inverse="true">
<key column="COMMENTED_NODE_FK"/>
<one-to-many class="org.escapek.core.domain.Comment"/>
</set>
<joined-subclass
name="org.escapek.core.objectmanager.domain.MOFLibrary"
table="MOF_LIBRARY">
<key column="NODE_ID"/>
<property name="name" column="NAME"/>
<property name="description" column="DESCRIPTION"/>
<many-to-one name="parentLibrary"
column="PARENT_LIBRARY_FK" lazy="false" />
<map name="childrenLibs" inverse="true"
lazy="true">
<key column="PARENT_LIBRARY_FK"/>
<map-key column="name" type="string"/>
<one-to-many
class="org.escapek.core.objectmanager.domain.MOFLibrary"/>
<filter name="nodeStatus" condition=":nodeStatusParam =
STATUS"/>
</map>
<map name="childrenFiles" inverse="true"
lazy="true">
<key column="LIBRARY_FK"/>
<map-key column="name" type="string"/>
<one-to-many
class="org.escapek.core.objectmanager.domain.MOFFile"/>
<filter name="nodeStatus" condition=":nodeStatusParam =
STATUS"/>
</map>
</joined-subclass>
<joined-subclass name="org.escapek.core.objectmanager.domain.MOFFile"
table="MOF_FILE">
<key column="NODE_ID"/>
<property name="name" column="NAME"/>
<property name="description" column="DESCRIPTION"/>
<many-to-one name="library" column="LIBRARY_FK"
lazy="false" />
<property name="content" column="CONTENT"
type="text" length="100000"/>
</joined-subclass>
<filter name="nodeStatus" condition=":nodeStatusParam =
STATUS"/>
</class>
<filter-def name="nodeStatus">
<filter-param name="nodeStatusParam" type="string"/>
</filter-def>
</hibernate-mapping>
Whenever I access a node subclass is loaded or when the MOFLibrary collection are loaded,
I get the same kind of error saying that column status is undefined. I think this is the
same error as already reported by Juan. Here the SQL code generated:
select
childrenfi0_.LIBRARY_FK as LIBRARY4_1_,
childrenfi0_.NODE_ID as NODE1_1_,
childrenfi0_.name as name1_,
childrenfi0_.NODE_ID as NODE1_0_0_,
childrenfi0_1_.INSTANCE_NAME as INSTANCE2_0_0_,
childrenfi0_1_.CREATION_DATE as CREATION3_0_0_,
childrenfi0_1_.LAST_MODIFIED_DATE as LAST4_0_0_,
childrenfi0_1_.DELETE_DATE as DELETE5_0_0_,
childrenfi0_1_.STATUS as STATUS0_0_,
childrenfi0_1_.OWNER_FK as OWNER7_0_0_,
childrenfi0_1_.CREATION_USER_FK as CREATION8_0_0_,
childrenfi0_1_.LAST_MODIFIED_USER_FK as LAST9_0_0_,
childrenfi0_1_.DELETE_USER_FK as DELETE10_0_0_,
childrenfi0_.NAME as NAME17_0_,
childrenfi0_.DESCRIPTION as DESCRIPT3_17_0_,
childrenfi0_.LIBRARY_FK as LIBRARY4_17_0_,
childrenfi0_.CONTENT as CONTENT17_0_
from
MOF_FILE childrenfi0_ inner join NODES childrenfi0_1_ on
childrenfi0_.NODE_ID=childrenfi0_1_.NODE_ID
where
:nodeStatus.nodeStatusParam = childrenfi0_.STATUS
and
childrenfi0_.LIBRARY_FK=?
This clearly shows that status column is prefixed with the alias of joined-subclass table
instead of the master class.
Hope this will help.
Filtering on superclass property problem
----------------------------------------
Key: HHH-1901
URL:
http://opensource.atlassian.com/projects/hibernate/browse/HHH-1901
Project: Hibernate3
Issue Type: Bug
Affects Versions: 3.1.3
Environment: Hibernate 3.1.3 on Oracle 9i
Reporter: Juan Ignacio Cidre
Attachments: test.tar.gz
I have three classes Order, Advertisements and Creatives.
Advertisements is subclass of Creatives
Order has a one-to-many to Advertisements
That one-to-many has a filter. The condition has to do with a property of Creative, the
Advertisements superclass.
This is the Order to Advertisements mapping with a filter on deletionStatusId that is a
field of Creative.
<set name="ads" inverse="true" lazy="true">
<key column="orderId"/>
<one-to-many class="com.inceptor.domain.msn.Advertisement"/>
<filter name="deletionStatusFilter"
condition="deletionStatusId = 0"/>
</set>
This is the Creative mapping with the deletionStatusId, which is mapped as a component.
It is a Enum in Java.
<component name="deletionStatus"
class="com.inceptor.domain.core.DeletionStatusType">
<property name="number" column="deletionStatusId"
/>
</component>
I would expected an sql that appends a where condition like [superclass (Creative) table
alias].deletionStatusId instead I received [subclass (Advertisements) table
alias].deletionStatusId
This generates a DB error.
Follows the generated query
Note ads0_ instead of ads0_1_
select ads0_.orderId as orderId1_, ads0_.id as id1_, ads0_.id as ID324_0_,
ads0_1_.version as version324_0_, ads0_1_.searchEngineAccountId as searchEn3_324_0_,
ads0_1_.creationTime as creation4_324_0_, ads0_1_.creatorId as creatorId324_0_,
ads0_1_.modificationTime as modifica6_324_0_, ads0_1_.synchTime as synchTime324_0_,
ads0_1_.modifierId as modifierId324_0_, ads0_1_.deletionStatusId as deletion9_324_0_,
ads0_1_.deleterId as deleterId324_0_, ads0_1_.pushError as pushError324_0_, ads0_.seId as
seId418_0_, ads0_.title as title418_0_, ads0_.description as descript4_418_0_,
ads0_.displayURL as displayURL418_0_, ads0_.destinationURL as destinat6_418_0_,
ads0_.originalDestinationURL as original7_418_0_, ads0_.orderId as orderId418_0_ from
MSN_Advertisements ads0_ inner join GTK_Creatives ads0_1_ on ads0_.id=ads0_1_.ID where
ads0_.deletionStatusId = 0 and ads0_.orderId=?
--
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