-->
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: Problem searching an entity after Evict
PostPosted: Wed Oct 18, 2006 5:50 pm 
Newbie

Joined: Wed Oct 18, 2006 5:27 pm
Posts: 1
My entity has an one-to-many association between the User to e-mails
Code:
@Entity
public class User implements java.io.Serializable {
    private Set<String> emails = new HashSet<String>();
    private String login; //primary key
    ...
    @CollectionOfElements(fetch=FetchType.EAGER)
    @Cascade(value=CascadeType.ALL)
    public Set<String> getEmails() {
        return emails;
    }
    ...
}

When, in DAO, I search by "login" it return only one object (that´s OK). But after I evict this object and try to find another "login" it returns N results.
I don´t understand why !!! Can anyone help me ?

Search function in UserDAO extends GenericDAO:
Code:
public List<User> searchUserByLogin(String login) {
   try{
   return super.findByCriteria(new Criterion[]{Restrictions.eq("login",login)});
   }catch( Exception e ){
   throw new IllegalArgumentException("Parâmetro CAMPO inválido");
   }
}

Search function in GenericDAO:
Code:
protected List<T> findByCriteria(Criterion... criterion) {
   Criteria crit = getSession().createCriteria(getPersistentClass());
      for (Criterion c : criterion) {
         crit.add(c);
      }
      return crit.list();
   }


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.