Hello,
I have a problem with (understanding) serialization of collections.
Guess I have loaded a "Customer" object and want each of his opened trouble tickets. No problem. One-to-Many (one customer, many trouble tickets) The mapping is bidirectional. So every Customer has a List<TroubleTickets>, every TroubleTicket has a Customer (lazy) object.
I want to only return a List<TroubleTickets> from my method (parameter is a customer).
When it goes to serialization (graniteds) of the List<TroubleTickets>, there is a relatively huge problem:
Since Hibernate knows the lazy-fetched "Customer" of the Trouble-Tickets as initialized, the whole Customer object is serialized for each TroubleTicket. Since the CustomerObject is about 10 times larger than the Trouble-Ticket, there is more than 10 times unneccessary data than important data.
All trouble-tickets belong to the same customer... So we have 500 times the same customer serialized and transmitted...
Is there any chance to bring the "customer" object back to a lazy loaded, uninitialized reference just before the method ends and serialization starts?
So many thanks.... :)
Steffen
|