-->
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: Hibernate Criterias
PostPosted: Sat Jun 27, 2009 9:34 pm 
Newbie

Joined: Thu Jun 25, 2009 9:27 am
Posts: 2
Hi,

first of all congrats on fantastic Hibernate Project.
Next, I would like to ask few questions:

1) How to force logical or in expressions, I couldn't figure out.
I'm using something like this and I need ors instead of ands there:

Code:
                crit.add(Restrictions.like("prodName", "%" + s + "%"));
                crit.add(Restrictions.like("prodCode", "%" + s + "%"));
                crit.add(Restrictions.like("prodDescription", "%" + s + "%"));
                products.addAll(crit.list());

2) Is there any way in hib. ocnfig to enable showing actual values instead of question marks in generated sql stat. shown in console (turned on show sql in config)? Using MySQl+InnoDB, netbeans IDE, not using log4j by my own unless installed in IDE.
Code:
...from eshop_v1.Products this_ where this_.prod_name like ? and this_.prod_code like ? and this_.prod_description like ?


Thanks, regards

Marek


Top
 Profile  
 
 Post subject: Re: Hibernate Criterias
PostPosted: Sun Jun 28, 2009 8:09 am 
Newbie

Joined: Sun Jun 28, 2009 8:02 am
Posts: 1
Regarding 1)

Use
Code:
Restrictions.or
(some examples: http://docs.jboss.org/hibernate/stable/core/reference/en/html/querycriteria-narrowing.html)

or if it's easier for you case, even an sqlRestriction.


Top
 Profile  
 
 Post subject: Re: Hibernate Criterias
PostPosted: Sun Jun 28, 2009 8:23 am 
Newbie

Joined: Thu Jun 25, 2009 9:27 am
Posts: 2
Thanks,

Restrictions.disjunction() was exactly what I was looking for.


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.