In my entities I have to use fetch = FetchType.EAGER because I have a mistake:
nested exception is org.hibernate.LazyInitializationException: failed to lazily initialize a collection of role: "field should haver FetchType.EAGER", could not initialize proxy - no Session
If I use this then my app goes correct, but the time execution is too, between page and page around 7 seconds (now bbdd has little data)
I have two problems.
- If I put FetchType.LAZY my app does not work
- If I put FetchType.EAGER my app has a lot of time of execution
PF.class (Entity)
@OneToMany(fetch = FetchType.EAGER, mappedBy = "pf", cascade = CascadeType.ALL)
private Set<HDSEntity> hardwareDeviceStocks = new HashSet<HDSEntity>();
@OneToMany(fetch = FetchType.EAGER, mappedBy = "pf", cascade = CascadeType.ALL)
private Set<BSEntity> bS = new HashSet<BSEntity>();
@OneToMany(cascade = CascadeType.ALL, mappedBy = "pf", fetch = FetchType.EAGER)
private Set<CEntity> cp = new HashSet<CEntity>();
HDS.class (Entity)
@ManyToOne(cascade = {CascadeType.ALL})
@JoinColumn(name = "fk_pf")
private PFEntity pf;
BS.class (Entity)
@ManyToOne(cascade = CascadeType.ALL)
@JoinColumn(name = "fk_pf")
private PFEntity pf;
Thanks. ;)