Is ther any way to have a Criteria search not use a property's formula in its generated SQL?
Hibernate version: 3.0
Mapping documents:
Code:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping>
<class name="Foo" table="FOO">
<cache usage="read-write"/>
<id name="identifier" column="ID" type="long" length="20">
<generator class="sequence">
<param name="sequence">SEQ_FOO</param>
</generator>
</id>
<property name="status" formula="( select STATUS( ID ) from FOO where FOO.ID = ID )" type="integer" />
<set name="bars" lazy="true" cascade="delete" inverse="true">
<key column="FOO_ID" not-null="true" />
<one-to-many class="Bar" />
</set>
</class>
</hibernate-mapping>
Code between sessionFactory.openSession() and session.close():Code:
Criteria criteria = session.createCriteria(Foo.class);
Criterion criterion = null;
criterion = Restrictions.eq( "status",STATUS_A);
criterion = Restrictions.or( criterion, Restrictions.eq( "status",STATUS_B) );
criterion = Restrictions.or( criterion, Restrictions.eq( "status",STATUS_C) );
criteria.add(criterion);
List results = criteria.list( );
Name and version of the database you are using: Oracle 9.2.0.3
The generated SQL (show_sql=true):Code:
Hibernate:
select
this_.ID as ID3_,
( select RECURRENCE_NUMERIC_STATUS( this_.ID ) from RECURRENCE where RECURRENCE.ID = this_.ID ) as formula0_3_
from
FOO this_
where
( ( select STATUS( this_.ID ) from FOO where FOO.ID = this_.ID )=? or
( select STATUS( this_.ID ) from FOO where FOO.ID = this_.ID )=? or
( select STATUS( this_.ID ) from FOO where FOO.ID = this_.ID )=?
)
My question is: is there a way to make this query look like the following instead of the above?
Code:
Hibernate:
select
this_.ID as ID3_,
( select RECURRENCE_NUMERIC_STATUS( this_.ID ) from RECURRENCE where RECURRENCE.ID = this_.ID ) as formula0_3_
from
FOO this_
where ( formula0_3_=? or formula0_3_=? or formula0_3_=? )
Thank-you,
Zac.