-->
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: detached criteria api
PostPosted: Thu Sep 06, 2007 9:59 am 
Newbie

Joined: Wed Sep 05, 2007 6:19 am
Posts: 11
is it possible to use criteria to build ejbql queries?

pattern of usage:

collection of property contraints
building of the criteria
generation of the ejbql query
retieval of the object via an entitymanager

objective:
indipendence between the query building layer and the orm layer, to use some lightweight alternative to hibernate


Top
 Profile  
 
 Post subject:
PostPosted: Thu Sep 06, 2007 6:41 pm 
Expert
Expert

Joined: Tue Nov 23, 2004 7:00 pm
Posts: 570
Location: mostly Frankfurt Germany
I am not sure, if criteria all already translated into HQL. I saw a discussion once but haven't checked since then.

I cannot see the advantage to separate things. You will need the mappings twice (Hibernate + other solution). I don't think that other solutions are more "lightweigh" copying resultsets into properties than Hibernate.

_________________
Best Regards
Sebastian
---
Training for Hibernate and Java Persistence
Tutorials for Hibernate, Spring, EJB, JSF...
eBook: Hibernate 3 - DeveloperGuide
Paper book: Hibernate 3 - Das Praxisbuch
http://www.laliluna.de


Top
 Profile  
 
 Post subject:
PostPosted: Mon Sep 10, 2007 4:37 am 
Newbie

Joined: Wed Sep 05, 2007 6:19 am
Posts: 11
no, you do not need the mappings to use the criteria.
well, you shouldn't need the mapping to use the criteria,
as the criteria works on properties and the properties could
be translatend in hql without worring about mapping:
you could build a criteria with something like cat.age = 'twenty', where is a numeric type, and the error shows during the qery execution, not during the translation of the criteria to the query. In other world, the criteria will build the hql neverthless, without checking the model.

with the query log you could see that the query is correctly built, and then the classcastexception raised during the execution

so you will need the mapping only once, in hibernate, or using custom solution, without losing the powerful criteria api.

In theory one could just build the query using the criterion, and pass the query to any ejb3 EntityManager

(the problem is that hibernate itself doesn't scale, and we're looking for alternative, but the criteria api is just too powerful to be left behind)


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.