I have two Java classes, Measure and Trade, Trade joins Measure as a property:
class Measure{
@OneToOne(fetch = FetchType.LAZY)
Private Trade trade;
}
Then I have a stored proc which, after running and working with Hibernate, somehow mysteriously (meaning I failed to follow the code routes) creates a collection of Measure objects (trades are supposedly enriched when they tag along, as Measures' properties).
Now it comes to this point that I found that trade of Measure instance is a HiberateProxy. According to what I read online, when the Fetch type is LAZY, Hibernate create a proxy for trade, but I thought it'd somehow be replaced by the Trade objects later, it's obviously not happening, and they remained as HiberateProxy.
So my question is, why the Trade failed to transition it from a Hibernate Proxy to a real object? And, if I remove the (fetch = FetchType.LAZY) part from the annotation above, can it be a workaround? I am reluctant to do so, though, because the above code is actually in Measure's parent class, it might have ripple effect on other code. (I moved the Trade property to Measure for simpler illustration).