-->
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.  [ 3 posts ] 
Author Message
 Post subject: newbie - dynamic queries
PostPosted: Sat Nov 13, 2004 6:23 am 
Newbie

Joined: Sat Nov 13, 2004 6:03 am
Posts: 3
Hi,

I'm currently evaluating hibernate for use on a number of projects. I've used ibatis before and notice a number of features are common. One feature I can't see in hibernate is dynamic where clauses.

Is it possible to modify the where clause of named queries based upon the properties of the object passed to the query.setProperties(fooBean) method?

Taking an example from an ibatis config...

Code:
<query name="............">
select appointment.id as id, appointment_reference_no,
..........
.........
............
<dynamic>
      <isNotEmpty prepend="AND" property="bookingNumber">
        booking_number like '%' || #bookingNumber# || '%'
      </isNotEmpty>
      <isNotEmpty prepend="AND" property="containerOperatorId">
        cont_operator_mapping.id=#containerOperatorId#
      </isNotEmpty>
</dynamic>
</query>


thanks
Nathan


Top
 Profile  
 
 Post subject:
PostPosted: Sat Nov 13, 2004 3:08 pm 
Hibernate Team
Hibernate Team

Joined: Thu Dec 18, 2003 9:55 am
Posts: 1977
Location: France
hibernate and ibatis are not really the same.

do you know the query api? named parameters should do the job

_________________
Anthony,
Get value thanks to your skills: http://www.redhat.com/certification


Top
 Profile  
 
 Post subject:
PostPosted: Sun Nov 14, 2004 7:57 pm 
Newbie

Joined: Sat Nov 13, 2004 6:03 am
Posts: 3
Hi Anthony,

yes I've seen the query api. Is your suggestion to define the query in a config file and then modify the where clause in java (using the api)? Or have I mis-understood you?

I'd prefer to have all of the sql (including dynamic where clauses) in one place i.e. a config file. Is this possible?

thanks
Nathan


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

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.