I've been using session replicate which seems to work wonderfully in most scenarios but I have an issue with it in one particular scenario.
If I have Class A and Class B that have many-to-one references to each other I can get a problem where integrity contrains are violated. If I were to insert these objects using more normal methods I would do something like:
Code:
session.save(a);
session.save(b);
b.refToA = a;
session.flush();
In otherwords I do the insert then the do an update.
Unfortunately in this case I need to use replicate. Replicate doesn't seem's to just want to do the full inserts (triggering the constraint). I'm wondering whether this is the intended behaviour? I'm basically after something that would detect this situation and automatically do the two stage insert then update.
The reason I'm using session.replicate() is because I'm using the ReverseXMLDatabinder code that's been posted to JIRA. This code works pretty well except for this one issue.