These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: using joined-subclass property in filter condition
PostPosted: Sat Aug 26, 2006 8:24 am 
Beginner
Beginner

Joined: Mon Aug 01, 2005 3:51 pm
Posts: 22
I'm trying to use a filter with a condition on a property in a joined-subclass. The dtd doesn't support filter in the joined-subclass and if I apply it on the class, the generated sql places the column on the parent table.

How do I use a filter on a joined-subclass?

Hibernate version:
3.1.3

Mapping documents:
<hibernate-mapping default-cascade="save-update">
<class name="com.rjlg.ehmdrc.core.domain.party.PartyImpl" table="PARTY" dynamic-insert="false" dynamic-update="false">
<id name="id" type="java.lang.Long" unsaved-value="null">
<column name="ID" sql-type="NUMERIC(19,0)"/>
<generator class="native">
</generator>
</id>

<many-to-one name="address" entity-name="com.rjlg.ehmdrc.core.domain.party.AddressImpl" foreign-key="PARTY_ADDRESS_FKC" lazy="proxy" fetch="select">
<column name="ADDRESS_FK" not-null="false" sql-type="NUMERIC(19,0)"/>
</many-to-one>

<joined-subclass entity-name="com.rjlg.ehmdrc.core.domain.party.PersonImpl" table="PERSON" dynamic-insert="false" dynamic-update="false" abstract="false">
<key foreign-key="PERSON_INHERITANCE_FKC">
<column name="ID" sql-type="NUMERIC(19,0)"/>
</key>
<property name="lastName" type="java.lang.String">
<column name="LAST_NAME" not-null="true" unique="false" sql-type="VARCHAR(50)"/>
</property>
<property name="firstName" type="java.lang.String">
<column name="FIRST_NAME" not-null="true" unique="false" sql-type="VARCHAR(50)"/>
</property>
<property name="email" type="java.lang.String">
<column name="EMAIL" not-null="true" unique="false" sql-type="VARCHAR(50)"/>
</property>
<property name="phoneNumber" type="java.lang.String">
<column name="PHONE_NUMBER" not-null="true" unique="false" sql-type="VARCHAR(50)"/>
</property>
</joined-subclass>

<filter name="byLastName"
condition="LAST_NAME = :lastName"/>

</class>

<query name="com.rjlg.ehmdrc.core.domain.party.PersonImpl.find">
<![CDATA[from com.rjlg.ehmdrc.core.domain.party.PersonImpl]]>
</query>

<filter-def name="byLastName">
<filter-param name="lastName" type="java.lang.String"/>
</filter-def>
</hibernate-mapping>

Code between sessionFactory.openSession() and session.close():
session.enableFilter("byLastName);
filter.setParameter("lastName", "Salvucci");

Full stack trace of any exception that occurs:
java.sql.SQLException: ORA-00904: "PERSONIMPL0_1_"."LAST_NAME": invalid identifier

at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:112)
at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:331)
at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:288)
at oracle.jdbc.driver.T4C8Oall.receive(T4C8Oall.java:743)
at oracle.jdbc.driver.T4CPreparedStatement.doOall8(T4CPreparedStatement.java:216)
at oracle.jdbc.driver.T4CPreparedStatement.executeForDescribe(T4CPreparedStatement.java:799)
at oracle.jdbc.driver.OracleStatement.executeMaybeDescribe(OracleStatement.java:1039)
at oracle.jdbc.driver.T4CPreparedStatement.executeMaybeDescribe(T4CPreparedStatement.java:839)
at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:1132)
at oracle.jdbc.driver.OraclePreparedStatement.executeInternal(OraclePreparedStatement.java:3285)
at oracle.jdbc.driver.OraclePreparedStatement.executeQuery(OraclePreparedStatement.java:3329)
at org.hibernate.jdbc.AbstractBatcher.getResultSet(AbstractBatcher.java:139)
at org.hibernate.loader.Loader.getResultSet(Loader.java:1669)
at org.hibernate.loader.Loader.doQuery(Loader.java:662)
at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:224)
at org.hibernate.loader.Loader.doList(Loader.java:2145)
at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2029)
at org.hibernate.loader.Loader.list(Loader.java:2024)
at org.hibernate.loader.hql.QueryLoader.list(QueryLoader.java:375)
at org.hibernate.hql.ast.QueryTranslatorImpl.list(QueryTranslatorImpl.java:308)
at org.hibernate.engine.query.HQLQueryPlan.performList(HQLQueryPlan.java:153)
at org.hibernate.impl.SessionImpl.list(SessionImpl.java:1106)
at org.hibernate.impl.QueryImpl.list(QueryImpl.java:79)
at org.springframework.orm.hibernate3.HibernateTemplate$34.doInHibernate(HibernateTemplate.java:920)
at org.springframework.orm.hibernate3.HibernateTemplate.execute(HibernateTemplate.java:366)
at org.springframework.orm.hibernate3.HibernateTemplate.findByNamedQuery(HibernateTemplate.java:911)
at org.springframework.orm.hibernate3.HibernateTemplate.findByNamedQuery(HibernateTemplate.java:903)
at com.rjlg.commons.persistence.PersistentEntityDaoBase$3.doInHibernate(PersistentEntityDaoBase.java:138)
at org.springframework.orm.hibernate3.HibernateTemplate.execute(HibernateTemplate.java:366)
at org.springframework.orm.hibernate3.HibernateTemplate.executeFind(HibernateTemplate.java:338)
at com.rjlg.commons.persistence.PersistentEntityDaoBase.find(PersistentEntityDaoBase.java:133)
at com.rjlg.commons.persistence.PersistentEntityDaoBase.findFiltered(PersistentEntityDaoBase.java:120)
at com.rjlg.commons.services.CrudServiceImpl.handleFind(CrudServiceImpl.java:33)
at com.rjlg.commons.services.CrudServiceBase.find(CrudServiceBase.java:69)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:287)
at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:181)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:148)
at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:96)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:170)
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:176)
at $Proxy1.find(Unknown Source)
at com.rjlg.ehmdrc.core.services.party.PersonServiceTest.testFindFilteredByLastName(PersonServiceTest.java:35)
Name and version of the database you are using:
Oracle 10g
The generated SQL (show_sql=true):
select personimpl0_.ID as ID4_, personimpl0_1_.ADDRESS_FK as ADDRESS2_4_, personimpl0_.LAST_NAME as LAST2_5_, personimpl0_.FIRST_NAME as FIRST3_5_, personimpl0_.EMAIL as EMAIL5_, personimpl0_.PHONE_NUMBER as PHONE5_5_ from PERSON personimpl0_, PARTY personimpl0_1_ where personimpl0_1_.LAST_NAME = ? and personimpl0_.ID=personimpl0_1_.ID


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.