batch insertAll has no effect when tx commited
Hi , I'm using version 6.1.1 of ebean, and integration it with spring . when batch insertAll commited via spring's tx , it takes no effect , I found com.avaje.ebeaninternal.server.persist.BatchControl#flush(boolean) method did not called from spring's tx commit , anything wrong?
Maybe, the ebean spring project is a bit behind so yes there is a chance something got broken. Any chance of creating a test case and pull request against avaje-ebeanorm-spring?
On 27 July 2015 at 21:20, xxcode-monkey [email protected] wrote:
Hi , I'm using version 6.1.1 of ebean, and integration it with spring . when batch insertAll commited via spring's tx , it takes no effect , I found com.avaje.ebeaninternal.server.persist.BatchControl#flush(boolean) method did not called from spring's tx commit , anything wrong?
— Reply to this email directly or view it on GitHub https://github.com/ebean-orm/avaje-ebeanorm/issues/357.
ok , later
If you like ... create an issue on the avaje-ebeanorm-spring project and put in the issue some pseudo code & spring version and observed behaviour. In case I get to it before you get a test case pull request in.
Cheers, Rob.
On 27 July 2015 at 21:36, xxcode-monkey [email protected] wrote:
ok , later
— Reply to this email directly or view it on GitHub https://github.com/ebean-orm/avaje-ebeanorm/issues/357#issuecomment-125146318 .
Interesting enough this is a bug in core (not spring specific). The underlying issue is that the 'many' property is initialised in the constructor - for this associated test case we initialised with ArrayList() but the code in the ebeanorm-spring project initialised a HashSet().
The fix is to include a test for 'vanilla' collections (HashSet, ArrayList) so BeanCollection was correctly skipping the save call to the 'many' property but this was not being skipped for HashSet, ArrayList. As the skipping of the save call to the 'many' property was not being skipped the batch insert was effectively flushing after each insert (and that was what you saw in the logs).
Summary: Fix adds checks for empty vanilla collections in BeanPropertyAssocMany. isEmptyBeanCollection()