#822 - EbeanServer.getBeanId(entity) does not trigger jdbc batch flush - when bean inserted with jdbc batch mode

This commit is contained in:
Robin Bygrave
2016-09-22 21:25:22 +12:00
parent bd3e7c8035
commit a3143b1cf6
2 changed files with 35 additions and 1 deletions
@@ -0,0 +1,34 @@
package com.avaje.tests.batchinsert;
import com.avaje.ebean.BaseTestCase;
import com.avaje.ebean.Ebean;
import com.avaje.ebean.EbeanServer;
import com.avaje.ebean.annotation.Transactional;
import com.avaje.tests.model.basic.Customer;
import org.junit.Test;
import static org.junit.Assert.assertNotNull;
public class TestBatchSaveWithGetBeanId extends BaseTestCase {
/**
* Making this transaction with batchSize means that the insert
* below does not occur immediately ... and the getBeanId()
* should invoke the flush (and hence trigger the insert).
*/
@Transactional(batchSize = 10)
@Test
public void test() {
EbeanServer server = Ebean.getDefaultServer();
Customer model = new Customer();
model.setName("foo");
server.insert(model);
// should invoke a flush which then means the
// insert occurs and the bean has an Id value
Object beanId = server.getBeanId(model);
assertNotNull(beanId);
}
}