Sebastian, I use a custom converter that knows explictly where to prune the association tree, as there's no consistent way to know whether any given reference (i.e. foreign key) is internal to the aggregate or external. With a domain model with lots of cross-linking you can easily have external references at any level in the association graph, not just the top level. I can chase up some code tomorrow if you're interested.
Regards Jaime On Tue, Oct 16, 2012 at 9:09 PM, Sebastian Götz <[email protected]> wrote: > Hello Users,**** > > ** ** > > I am trying to use XSTREAM as serialization engine to backup my database. > We use hibernate as OR mapper. **** > > My intention is to serialize table by table (entity class by entity > class). And so I came across associations. **** > > If I serialized each table standalone at the end I will have any instance > serialized. The problem now is to enforce the foreign key. So I want to > only serialize the unique id for associated entities.**** > > So when restoring the database again I can easily recreate the > constraints. **** > > ** ** > > How can I achieve this? All may entities derive from a base class so I > have a good point to start at. But I do not know how to detect in a > converter whether the current object is a top level entity or an > association.**** > > ** ** > > ** ** > > Kind regards**** > > > Sebastian Götz**** > > ** ** >
