I'm trying to use Spring Data Mongo's @DBRef(lazy = true)
feature for lazy loading of an association but it doesn't seem to work. Even though it loads the Mainobject
with an empty ReferencedObject
, inside the reference object there is a CGLIB$CALLBACK_0
proxy object that has the association already loaded. Doesn't this beat the concept of lazy loading? Also, when I return the object to the client it returns the association twice:
mainObject: {
field: value
reference: { //same object
refField: refValue
},
target: { //same object
refField: refValue
}
}
Isn't the goal for the lazy association to only fetch the object after some method call (like getRefObject()
for example)? Also I'm failing to see how I can access the fetched object from its proxy once it is loaded since it is a private property and it doesn't have accessors...