nhibernate/nhibernate-core — pull request #105 by cremor (2012-05-14 12:00:12+00:00)
Title: NH-3072: OneToManyPersister improvements

All of the changes were ported from Hibernate from this changeset:
https://github.com/hibernate/hibernate-orm/commit/08d9fe2117a1afc60ad15cb1b6124b057b6eae32#hibernate-core/src/main/java/org/hibernate/persister/collection/OneToManyPersister.java

I ported these changes with the following points in mind:

* (Minor point): Hibernate still uses the code that resulted from the Hibernate changeset I linked, so it can't be that wrong.
* Removal of "if (st == null)" conditions: The AbstractBatcher already handles the reusing or recreation of the command. Additional checks in the OneToManyPersister are not needed and might even be wrong depending on the AbstractBatcher recreation logic (which might change at some time in the future, will anyone remember to change the OneToManyPersister then?).
* Removal of the "if (DeleteCallable)" condition: That code just doesn't make sense. Why should "expectation" and "useBatch" only be changed to values that depend on some logic if "DeleteCallable" is true? I can't see a reason why it shouldn't be possible to have a different expectation than "None" with a "DeleteCallable" value of false. Same for "useBatch": Why should we always use BatchCommands (default value of "useBatch" is true) when "DeleteCallable" is false? The change that was done in the Hibernate code makes sense: Seperate the expectation and batching behaviour from the callable value. That way all combinations are allowed. And it then also uses the same logical flow as the row insert section below.
* Removal of the "DeleteCallable" allthogether: Yes, Hibernate still uses this in calls to "getBatchStatement" and "prepareStatement", but it also does this in the row insert section below where NHibernate also doesn't use it. It seems like NHibernate doesn't need this information in the AbstractBatcher, so the usage of this property isn't needed any more (like "InsertCallable" isn't used in the row insert section).

Jira issue: https://nhibernate.jira.com/browse/NH-3072