Thanks for the replies. I replaced my "saveOrUpdate()" with a "persist()" and every things seems ok now. I could get the id just after the persist(). Good news for me ;)
Some comments anyway:
Quote:
Generally speaking needing the ID in some cases is bad design in my opinion. Although in some cases it is needed.
I agree with that, but I really need that children ID for speeding up some external index process, and I need it before the "commit()" to be able to rollback if something goes wrong.
Quote:
probe with the inverse clause, add inverse in true in the bag declaration, and add in the child mapping the many-to-one clause
I already use a inverse relation, so this was not the reason of the cascade failure. (I did not post my mapping files sorry for that, but I wasn't sure they'll be usefull, since this is a very general problem).
Final note, the hibernate documentation is not so clear about that problem. I was not able to find a clear distinction between "saveOrUpdate()" and "persist()".
And I found some inconsistency between the documentation and the actual code behavior. The docuementation says:
Quote:
"If a parent is passed to save(), update() or saveOrUpdate(), all children are passed to saveOrUpdate()"
but according to the definition of saveOrUpdate() :
Quote:
saveOrUpdate() does the following:
[...]
* if the object has no identifier property, save() it
[...]