2
I have a problem trying to load an object that is mapped as LAZY. I mapped my attribute this way:
@OneToOne(fetch = FetchType.LAZY)
private Obra obra;
And I load the data at the time of opening the sale like this:
public void carregaItensOs(Venda os) {
os.setItensVenda(em.createQuery("FROM ItemVenda AS iop WHERE iop.venda=" + os).getResultList());
os.setObra((Obra) em.createQuery("FROM Obra AS obra WHERE obra.id=" + os.getObra().getId()).getResultList().get(0));
}
In this case the itensVenda list loads right, the problem is when I have to load an object.
There’d be some way to fix it ?
The problem was the same, but I solved otherwise, saved the work ID in a separate column from the sale and loaded from it.
– Leandro Santos