Using hibernate 2.0.3
I have a mapping with a one table per sublass strategy.
Code:
<hibernate-mapping>
<class
name="com.fnac.customer.mailfollowup.bean.AbstractMailParam"
table="COMMON_MAIL_PARAM"
dynamic-update="false"
dynamic-insert="false"
>
<id
name="id"
column="COMMON_MAIL_PARAM_ID"
type="java.lang.Long"
unsaved-value="null"
>
<generator class="sequence">
<param name="sequence">SEQ_DEFAULT</param>
</generator>
</id>
<version
name="versionNumber"
type="int"
column="VERSION_NUMBER"
/>
<many-to-one
name="thePartner"
class="com.fnac.customer.mailfollowup.bean.admin.Partner"
cascade="none"
outer-join="auto"
update="true"
insert="true"
column="PARTNER_ID"
/>
<joined-subclass
name="com.fnac.customer.mailfollowup.bean.MailParam"
table="MAIL_PARAM"
dynamic-update="false"
dynamic-insert="false"
>
<key
column="COMMON_MAIL_PARAM_ID"
/>
<many-to-one
name="mailProcess"
class="com.fnac.customer.mailfollowup.bean.MailProcess"
cascade="none"
outer-join="auto"
update="true"
insert="true"
column="PROCESS_ID"
/>
</joined-subclass>
</class>
<class
name="com.fnac.customer.mailfollowup.bean.AbstractProcess"
table="PROCESS"
dynamic-update="false"
dynamic-insert="false"
discriminator-value="null"
>
<id
name="id"
column="PROCESS_ID"
type="java.lang.Long"
unsaved-value="null"
>
<generator class="sequence">
<param name="sequence">SEQ_PROCESS</param>
</generator>
</id>
<discriminator
column="PROCESS_TYPE"
type="java.lang.Integer"
/>
<version
name="versionNumber"
type="int"
column="VERSION_NUMBER"
/>
</subclass>
<subclass
name="com.fnac.customer.mailfollowup.bean.MailProcess"
dynamic-update="false"
dynamic-insert="false"
discriminator-value="1"
>
<many-to-one
name="mailParam"
class="com.fnac.customer.mailfollowup.bean.MailParam"
cascade="none"
outer-join="auto"
update="true"
insert="true"
column="PARAM_ID"
/>
</subclass>
</class>
<class
name="com.fnac.customer.mailfollowup.bean.admin.Partner"
table="PARTNER"
dynamic-update="false"
dynamic-insert="false"
>
<id
name="id"
column="PARTNER_ID"
type="java.lang.Long"
unsaved-value="null"
>
<generator class="sequence">
<param name="sequence">SEQ_DEFAULT</param>
</generator>
</id>
<version
name="versionNumber"
type="int"
column="VERSION_NUMBER"
/>
<property
name="name"
type="java.lang.String"
update="true"
insert="true"
column="NAME"
/>
</class>
</hibernate-mapping>
Then I do a simple query trying:
Code:
session.find( "select process.mailParam.thePartner.name"
+ " from MailProcess as process ");
Then hibernate tries to get thePartner property from the subclass and not the parent class. As a consequence I get an SQL Exception.
How come it doesn't get the property from the parent class ?
Is ther any workaround for that ?
Thanks.
Code:
java.sql.SQLException: ORA-00904: "MAILPARA1__1"."PARTNER_ID" : identificateur non valide
at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:180)
at oracle.jdbc.ttc7.TTIoer.processError(TTIoer.java:208)
at oracle.jdbc.ttc7.Oall7.receive(Oall7.java:543)
at oracle.jdbc.ttc7.TTC7Protocol.doOall7(TTC7Protocol.java:1451)
at oracle.jdbc.ttc7.TTC7Protocol.parseExecuteDescribe(TTC7Protocol.java:651)
at oracle.jdbc.driver.OracleStatement.doExecuteQuery(OracleStatement.java:2117)
at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:2331)
at oracle.jdbc.driver.OraclePreparedStatement.executeUpdate(OraclePreparedStatement.java:422)
at oracle.jdbc.driver.OraclePreparedStatement.executeQuery(OraclePreparedStatement.java:366)
at net.sf.hibernate.impl.BatcherImpl.getResultSet(BatcherImpl.java:71)
at net.sf.hibernate.loader.Loader.getResultSet(Loader.java:551)
at net.sf.hibernate.loader.Loader.doFind(Loader.java:140)
at net.sf.hibernate.loader.Loader.find(Loader.java:620)
at net.sf.hibernate.hql.QueryTranslator.find(QueryTranslator.java:928)
at net.sf.hibernate.impl.SessionImpl.find(SessionImpl.java:1343)
... 29 more