EJB3 Entity and Lazy Problem
- by Stefano
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