From the document referenced above:
Quote:
all entity insertions, in the same order the corresponding objects were saved using Session.save()
In the case that doesn't work you are using a native SQL query, not Session.save().
One might argue that FlushMode.AUTO should detect that an automatic flush is needed but the documentation about when an automatic flush happens is quite vague and only mentions Query.list(). In any case, the only way to make the 'b' object to be inserted is to flush the session if that is an automatic or manual flush doesn't matter. It should not cause any harm to issue a manual flush.