-->
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.  [ 2 posts ] 
Author Message
 Post subject: Dynamic HSQL citeria restriction needed.
PostPosted: Fri Oct 28, 2005 3:10 am 
Newbie

Joined: Sun Jan 30, 2005 9:43 pm
Posts: 16
Hibernate version: 3.05

I'd like to be able to add the following type of criteria restriction:

Code:
List cats = sess.createCriteria(Cat.class)
    .add ( /* .... other normal fixed restrictions */ )
    .add( Restrictions.hsql(hsqlFilter) )  // add dynamic HSQL restriction
    .list();


Unfortunately only SQL filters are supported via Restrictions.sqlRestriction().
I need support for HSQL filters via something like Restrictions.hsqlRestriction(hsqlFilter) .

I want to store a HSQL filter as a string and have Hibernate parse it at runtime and apply it as an additional criteria restriction in conjunctions with other fixed criteria. In particaluar I don't want to reference SQL field names, rather I want to use the Class field names understood by HSQL. I need these filters to understand class inheritance - just like normal HSQL does.


Top
 Profile  
 
 Post subject: workarounds
PostPosted: Fri Oct 28, 2005 5:11 pm 
Expert
Expert

Joined: Fri Jul 22, 2005 2:42 pm
Posts: 670
Location: Seattle, WA
I do not think it is possible with the Criteria API and I suggest you to create a simple HQL builder class that will be responsible for creating the desired HQL. In the essence – string manipulation class. I have used such approach in the past and it works well and looks like Criteria API.
As another alternative, you may try saving scriplets to call the criteria API. Jython/BeanShell would be good for the job.

_________________
--------------
Konstantin

SourceLabs - dependable OpenSource systems


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 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.