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: Criteria and manyTomany association
PostPosted: Mon May 25, 2009 4:27 am 
Beginner
Beginner

Joined: Tue Jun 06, 2006 3:37 am
Posts: 29
Hi,

I've an entity that contain the following relations

Code:
   @ManyToMany(fetch = FetchType.EAGER)
   @Cascade ((org.hibernate.annotations.CascadeType.SAVE_UPDATE))
   private Set<Localisation> parcelles;

        @ManyToMany(fetch = FetchType.EAGER)
   @Cascade ((org.hibernate.annotations.CascadeType.SAVE_UPDATE))
   private Set<Commune> communes;


If I do a search within the communes relation with that code :

Code:
   private Criteria createCriteriaForCommune(Criteria criteria, Commune commune, YaminaDistrict district) {
      Criteria manyToMany = criteria.createCriteria("communes");
      if (commune.getLibelleDe() != null && commune.getLibelleDe().length() > 0 && !commune.getLibelleDe().equals("null"))
         manyToMany.add(Expression.like("libelleDe", "%" +commune.getLibelleDe() + "%"));
         LOG.error("communes.libelleDe not null\n" + commune.getLibelleDe());

      if (commune.getLibelleFr() != null && commune.getLibelleFr().length() > 0 && !commune.getLibelleFr().equals("null")) {
         manyToMany.add(Expression.like("libelleFr", "%" +commune.getLibelleFr() +"%"));
         LOG.error("communes.libelleFr not null\n"+ commune.getLibelleFr());
      }
return criteria;


Everything work

But if I did :

Code:
   private Criteria createCriteriaForLocalisation(Criteria criteria, Localisation localisation) {
      LOG.debug("CREATE CRITERIA FOR TYPE AFFAIRE\n");
      Criteria oneToMany = criteria.createCriteria("parcelles");         
      oneToMany.add(Expression.eq("coordonneeX", localisation.getCoordonneeX()));
      oneToMany.add(Expression.eq("coordonneeY", localisation.getCoordonneeY()));
      return criteria;   
   }


The list of my element is not filled

Any idea ?

Thx !


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.