-->
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: Is ther any way to have a Criteria search not use a property
PostPosted: Wed Jun 29, 2005 9:33 pm 
Newbie

Joined: Thu Jun 10, 2004 6:04 pm
Posts: 8
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.


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.