I need to do something very similar. I'm building a web service client and server for synchronization in a distributed database application, where nodes use Hibernate to access their backing stores, and records are held as POJOs in memory.
So far I've been working on using reflection to serialize and deserialize the object, but this breaks after it's sent via the web service, because CXF creates proxy objects which have new members that I don't want to see or touch (e.g. handler). Also the logic is very complex, inefficient and probably buggy.
I know that Hibernate is perfectly capable of flattening my objects, as it does it whenever I call save(), but I can't find any sample code to get the flattened data without going direct to the database with JDBC. Does anyone have any ideas? Do I just get the mapping (PersistentClass), iterate over its properties and disassemble() them? If I re-assemble() the serialized data into POJOs, what happens to associated objects? Is any of this documented or supported in any way, or am I messing with Hibernate internals here?
Cheers, Chris.
|