Hello, good morning, friends,
Why are my entities marked as fetch lazy returning "null" even when they are invoked via a get?
What I learned in several courses is that when I make the first call to a get method, hibernate would load the database object, I updated hibernate to the latest version, but still bringing "null" from the database. data, I'm using the .find () method, I've also used .load ().
In testing, as a bad practice, I tried to open the transaction, and inside it load the object through a get and nothing happened!
EntityManager manager = HibernateUtil.fabrica.getEntityManager();
cliente = manager.find(Cliente.class, 3);
At this point address returns "null" and possibly will generate a nullPointerException in the future.
Endereco endereco = cliente.getEndereco();
manager.close();
Would anyone know what that would be? Am I setting it wrong? if not well after the first get? really tried everything and when I use lazy, it generates nullPointerException.
To make matters worse, if I use a lot of EAGUER starts to generate that "multiples" exception, could anyone help me?