According the the hibernate docs, my @ManyToOne
relationships should have proxy objects by default. However, when I look at an expanded object in the Eclipse debugger ("Variables" view), it looks like the field variables are instances of the base type as defined in the entity class. Moreover, when I call session.get(type, id)
with hibernate.show_sql=true
I can see left outer join
s for all @ManyToOne
relationships defined on the object.
Is there something specific that needs done in order for Hibernate to create proxy classes/objects for these relationships? Perhaps bytecode enhancement?
Quote from hibernate docs:
Lazy fetching for collections is implemented using Hibernate's own implementation of persistent collections. However, a different mechanism is needed for lazy behavior in single-ended associations. The target entity of the association must be proxied. Hibernate implements lazy initializing proxies for persistent objects using runtime bytecode enhancement which is accessed via the bytecode provider.
At startup, Hibernate generates proxies by default for all persistent classes and uses them to enable lazy fetching of many-to-one and one-to-one associations.