I have a very straight-forward webservice that returns an object retrieved from the database. I'm using a spring-data-jpa repository to get the entity, after which, I return the object without any modification.
I have several lazy-loaded relationships in the entity and would like to leave them "unfetched". However, when the webservice marshals the response object, it triggers the lazy fetches and makes additional calls to the database.
I will still need to lazily fetch the data under certain circumstances so I need to be able to dynamically detach/remove/unproxy the object from the control of Hibernate.
I have attempted to use the following method to unproxy the object, but without any luck (my entity is not a HibernateProxy object it seems).
What is the best approach to "un-ORMify" an entity so that I can freely manipulate/serialize the object without triggering data calls.