Issue Details (XML | Word | Printable)

Key: XSTR-377
Type: New Feature New Feature
Status: Open Open
Assignee: Unassigned
Reporter: Konstantin Pribluda
Votes: 2
Watchers: 3
Operations

If you were logged in you would be able to see more operations.
XStream

Sanitizing hibernate proxied objects ( GetOutOfMyPojo)

Created: 11/Jan/07 08:23 AM   Updated: 12/Apr/08 12:11 PM
Component/s: None
Affects Version/s: None
Fix Version/s: None

File Attachments: 1. Java Source File HibernateUserManagerTest.java (26 kB)

Issue Links:
Duplicate
 


 Description  « Hide
This is a known problem that objects loaded via hibernate are
heavily proxied by CGLIB, and thus not really serializable.

Since hibernate is de-facto O/R mapping standard, this is pretty common
that such objects have to be sent to remote clients via SOAP or other
means, and somehow this is not working
( See for example: http://www.mojavelinux.com/blog/archives/2006/06/hibernate_get_out_of_my_pojo/ )

I played around with mappers / converters and it seems that I got it working.
Since my knowlege about xstream internals is pretty limited, I would like developers to review
( and maybe make it better ) my solution

Attached file is quick & dirty testcase, adapted from jtec-user
( http://www.sourceforge.net/projects/jtec/ ,
svn:https://jtec.svn.sourceforge.net/svnroot/jtec/jtec-user )



 All   Comments   Change History      Sort Order: Ascending order - Click to sort in descending order
Geoffrey De Smet added a comment - 09/Jan/08 01:49 AM
Do note that if you're sanitizing objects, you're also removing the PersistentBag (implements List) etc implementations.
AFAIK the PersistentBag implements remembers what objects have been deleted.
So when you cascade to a bag(=List), it's probably a performance gain (and even optimistic locking check too?) to come back with the modified detached PersistentBag's instead of a brand new ArrayList.

Nevertheless, sanitizing will probably work.


Geoffrey De Smet added a comment - 09/Jan/08 01:53 AM
PS: How do you deal with proxy's?

A proxy is just a "wrapper around the id" (which was a foreign key in the referencing object).

Say I have A -> B -> C -> D (all explicitly LAZY mapped) and I select A left join fetch B, but I don't eager fetch C.
Than A has a B and that B has a proxy of C.
Note that you'd have to LAZY map a ManyToOne association to test this (which is actually recommended by the hibernate guys).


Eric Raymond added a comment - 12/Apr/08 12:11 PM
Is this really a duplicate of http://jira.codehaus.org/browse/XSTR-226?

It seems like the former is dealing with the hibenrate collection classes.

This bug seems to be related to the fact that proxied objects in hibernate also use CGLIB and add their own callbacks.