EJB3 Entity and Lazy Problem
Posted
by Stefano
on Stack Overflow
See other posts from Stack Overflow
or by Stefano
Published on 2010-05-12T13:07:39Z
Indexed on
2010/05/12
13:14 UTC
Read the original article
Hit count: 434
My Entity beAN have 2 list:
@Entity
@Table(name = "TABLE_INTERNAL")
public class Internal implements java.io.Serializable {
...SOME GETTERS AND SETTERS...
private List<Match> matchs;
private List<Regional> regionals;
}
mapped one FetchType.LAZY and one FetchType.EAGER :
@OneToMany(fetch = FetchType.LAZY,mappedBy = "internal")
public List<Match> getMatchs() {
return matchs;
}
public void setMatchs(List<Match> matchs) {
this.matchs = matchs;
}
@ManyToMany(targetEntity = Regional.class, mappedBy = "internals", fetch =FetchType.EAGER)
public List<Regional> getRegionals() {
return regionals;
}
public void setRegionals(List<Regional> regionals) {
this.regionals = regionals;
}
I need both lists full ! But I cant put two FetchType.EAGER beacuse it's an error. I try some test:
List<Internal> out;
out= em.createQuery("from Internal").getResultList();
out= em.createQuery("from Internal i JOIN FETCH i.regionals ").getResultList();
I'm not able to fill both lists...Help!!!
Stefano
© Stack Overflow or respective owner