bdenny wrote:
gavin wrote:
HIbernate 2.1 offers the replicate() method for doing this stuff.
That looks like pretty much exactly what I want, but I'm having a problem with it.
I have a parent-child-type relationship mapped as a many-to-many using a List.
When I replicate() my top-level object, it puts rows for that object and all its children (recursively) into the database. So far, so good.
The problem is that it doesn't seem to be adding rows to the table which provides the many-to-many mapping.
It's clearly *finding* the reachable objects, since it's sticking them in the database. It just doesn't seem to be correctly replicating the association.
Is this intentional, or a bug, or do you think i'm doing something wrong?
-brian
I have a problem with hibernate3.1 wihich looks quite similar.
I have a server running a oracle 10 database and many mobile clients using derby database, both using hibernate3.1 and the same database scheme (the same hibernate mapping file).
The mobile clients request objects (which are object trees) from the server database which were serialized and sent to the clients over network.
To persist the object tree on the client side I use Session.save on the root object since these object are new (transient) to the clients database.
Code:
Catalog catalog=(Catalog) objectInputStream.readObject();
....
session.save(catalog);
All data is persisted to the db, except for the association tables of the many-to-many associations which are empty. On java side the association consists of a SortedSet implemented by TreeSet.
When I create a new TreeSet on the client using the TreeSet of the deserialized object everything works fiine for the many-to-many association between Catalog and Chapters:
Code:
Catalog catalog=(Catalog) objectInputStream.readObject();
SortedSet set=new TreeSet( catalog.getChapters() );
catalog.setChapters ( set );
....
session.save( catalog);
In order to preserve primary keys all keys were generated by the application (generator="assigned").
Is this a hibernate bug or is it me doing something wrong here?