3
Hello, good morning friends,
Why my entities marked as fetch Lazy are returning "null" even when they are invoked through a get?
What I learned in several courses is that when making the first call to a get method, Hibernate would load the object from the database, updated Hibernate to the latest version, even so it continues to bring "null" from the database, I’m using the method . find(), I’ve also used . load().
For testing purposes, 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 that time 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? if I’m setting it wrong? if it’s not quite so after the first get? really tried everything and when I use Lazy, generates nullPointerException.
To make matters worse, if I use too much EAGUER starts generating that "multiples bags" Exception, someone would know to help me?
You can post the code of the whole query method?
– Felipe
As soon as I get home, I’ll copy and paste the code here.
– Gabriel Martins
You are viewing this "null" by debug?
– Dherik