Attempting to save an object that contains a member variable that is a reference to some other object that is not under the current persistence context will not be possible, when this happens, you need to extract the required object and set it in the original to respect the relationship and be allowed to save it.
When I need to do this, I usually use the EntityManager search method, but it will hit the database and select the entire object along with it, which may not be annotated for lazy loading. I was glad to learn about getReference, which, apparently, does not get into the database, but returns a proxy view where only the primary key is available, and thatβs really all that is needed for this type of situation.
Unfortunately, after some debugging, I found that I can see all the information about the getReference'd object, and not just the primary key, when I "check" it in Eclipse debugging mode.
Am I missing something? Is debugging mode fooling me? Can it get information similar to the getter method when using a proxy in a link?
Thank you in advance
source share