-->
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: is that possible with criteria ?
PostPosted: Sat Sep 27, 2008 4:46 pm 
Newbie

Joined: Fri Sep 26, 2008 4:45 am
Posts: 17
Hi I need to know if it's possible within criteria queries to create a query that meet the following needs

I've an entity affaire that have a communes relations and these commune have a relation to district

how to access to affaire.communes.district.libelleFr like '%Toto%'

I've tryed to first create a criteria within the affaire object then create a criteriera for the communes relation for the affaire object and then tryed to create a district citeria and expression for the communes criteria

any idea ?


Top
 Profile  
 
 Post subject:
PostPosted: Sun Sep 28, 2008 4:14 am 
Newbie

Joined: Fri Sep 26, 2008 4:45 am
Posts: 17
I do it like this way :

Code:
Criteria criteria = session.createCriteria(Affaire.class);
if (auteur.getNom() != null && auteur.getNom().length > 0) {
  Criteria manyToMany = criteria.createCriteria("auteurs");
   manyToMany.add(Expression.like("nom","%" +   
  auteur.getNom() " +"%")
}
......
if (distrcit.getLibelleFr() != null && distrcit.getLibelleFr().length > 0) {
  Criteria manyToMany = criteria.createCriteria("communes");
  Criteria distrcitCriteria = manyToMany.createCriteria("district")
  distrcitCriteria .add(Expression.like("libelleFr","%" +
  district.getLibelleFr() " +"%")
}

  }


but that's doesn't work for district ...

Does a sqlRestriction could help me to solve this case ?

thx in advance


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.