-->
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: Creating dynamic queries: how to?
PostPosted: Sat Jun 06, 2009 6:43 pm 
Beginner
Beginner

Joined: Mon Jun 01, 2009 5:39 am
Posts: 34
Hello,

The use case is as follows: the user can create a search profile (what fields to display for a particular object, what search conditions should be applied, and more later), and this profile is persisted to the database in an XML string (NOT an XML object). POJO mode is not used, I only use dynamic-map and dom4j modes.

Of course, when it is retrieved from the database, I need to turn that XML into something understandable by Hibernate. I have two choices: HQL and DetachedCriteria.

I quite like the DetachedCriteria idea, but there's a challenge: XML is text. If I have, say:

Code:
<eq field="somefield" value="somevalue"/>


I need to get the type of "somefield" (this I know how to do), but also to convert the "somevalue" from a String, which it will be, to the appropriate object type. The Type API, as far as I can see, has no method to take a String as an argument and turn it into the expected class. I'm also pretty sure that Hibernate has the means to do that, and I don't want to reinvent the wheel. Where does Hibernate do it, and how?

HQL is a valid alternative, of course, but I'd prefer if I could do this with the DetachedCriteria.


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.