Here is a naive question about a OneToMany relationship. This is
probably a basic question.
I have a lazily fetched List. It might be large and I don't want to
load it until it is accessed.
In a transaction - If I create and persist a new Entity that is a member
of the list, I think (is
Paul,
When you get a Master entity into your persistent context, because members
is LAZY field it should not be loaded.
Persisting a Member entity should not affect this LAZY field unless you
access the list by calling getMembers().
You must set the master field in newly created Member instance
Hi Catalina -
All of what you said confirms my understanding.
One question I have is will a new Persistent member that has not been
flushed in the same transaction be returned by getMembers()?
My other question is what happens if I create a Member after calling
getMembers()? Will that new
Does this sequence of calls satisfy my requirement? Is there a better way?
Member newMember = new Member(master);
entityManager.persist(newMember);
entityManager.flush();
entityManager.refresh(master); // reloads the list if List has already
been lazily loaded
Hopefully refresh() does not