mirror of
https://github.com/ebean-orm/ebean.git
synced 2024-04-21 10:51:47 +00:00
Add SAP HANA support (#1511)
This commit is contained in:
committed by
Rob Bygrave
parent
b1410cc660
commit
158ee9a081
@@ -18,7 +18,12 @@ public class TestErrorBindLog extends BaseTestCase {
|
||||
|
||||
} catch (PersistenceException e) {
|
||||
String msg = e.getMessage();
|
||||
Assert.assertTrue(msg.contains("Bind values:"));
|
||||
if (isHana()) {
|
||||
Assert.assertTrue(msg.contains("Error with property[1] dt[12]data[JUNK]"));
|
||||
}
|
||||
else {
|
||||
Assert.assertTrue(msg.contains("Bind values:"));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,7 +4,9 @@ import io.ebean.BaseTestCase;
|
||||
import io.ebean.Ebean;
|
||||
import io.ebean.EbeanServer;
|
||||
import io.ebean.Transaction;
|
||||
import io.ebean.annotation.IgnorePlatform;
|
||||
import io.ebean.annotation.PersistBatch;
|
||||
import io.ebean.annotation.Platform;
|
||||
import io.ebean.annotation.Transactional;
|
||||
import io.ebean.meta.BasicMetricVisitor;
|
||||
import io.ebean.meta.MetaTimedMetric;
|
||||
@@ -119,6 +121,7 @@ public class TestBatchInsertFlush extends BaseTestCase {
|
||||
|
||||
@Test
|
||||
@Transactional(batch = PersistBatch.ALL)
|
||||
@IgnorePlatform(Platform.HANA)
|
||||
public void transactional_flushOnGetId() {
|
||||
|
||||
EbeanServer server = Ebean.getDefaultServer();
|
||||
@@ -141,6 +144,7 @@ public class TestBatchInsertFlush extends BaseTestCase {
|
||||
}
|
||||
|
||||
@Test
|
||||
@IgnorePlatform(Platform.HANA)
|
||||
public void testFlushOnGetId() {
|
||||
|
||||
EbeanServer server = Ebean.getDefaultServer();
|
||||
|
||||
@@ -3,7 +3,9 @@ package org.tests.batchinsert;
|
||||
import io.ebean.BaseTestCase;
|
||||
import io.ebean.Ebean;
|
||||
import io.ebean.Transaction;
|
||||
import io.ebean.annotation.IgnorePlatform;
|
||||
import io.ebean.annotation.PersistBatch;
|
||||
import io.ebean.annotation.Platform;
|
||||
import io.ebean.annotation.Transactional;
|
||||
import org.junit.Test;
|
||||
import org.tests.model.basic.UTDetail;
|
||||
@@ -46,6 +48,7 @@ public class TestBatchInsertSimple extends BaseTestCase {
|
||||
}
|
||||
|
||||
@Test
|
||||
@IgnorePlatform(Platform.HANA)
|
||||
public void testTransactional() {
|
||||
|
||||
saveWithFullBatchMode();
|
||||
@@ -131,7 +134,7 @@ public class TestBatchInsertSimple extends BaseTestCase {
|
||||
Transaction transaction = Ebean.beginTransaction();
|
||||
try {
|
||||
transaction.setBatch(PersistBatch.NONE);
|
||||
transaction.setBatchOnCascade(PersistBatch.ALL);
|
||||
transaction.setBatchOnCascade(spiEbeanServer().getDatabasePlatform().getPersistBatchOnCascade());
|
||||
transaction.setBatchSize(20);
|
||||
|
||||
// escalate based on batchOnCascade value
|
||||
|
||||
@@ -3,7 +3,9 @@ package org.tests.batchinsert;
|
||||
import io.ebean.BaseTestCase;
|
||||
import io.ebean.EbeanServer;
|
||||
import io.ebean.Transaction;
|
||||
import io.ebean.annotation.IgnorePlatform;
|
||||
import io.ebean.annotation.PersistBatch;
|
||||
import io.ebean.annotation.Platform;
|
||||
import io.ebeaninternal.api.SpiTransaction;
|
||||
import io.ebeaninternal.server.persist.BatchControl;
|
||||
import org.tests.model.basic.EBasicWithUniqueCon;
|
||||
@@ -20,6 +22,7 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
public class TestBatchOnCascadeExceptionHandling extends BaseTestCase {
|
||||
|
||||
@IgnorePlatform(Platform.HANA)
|
||||
@Test
|
||||
public void testBatchScenarioWithSavepoint() throws SQLException {
|
||||
server().save(createEntityWithName("conflict", "before"));
|
||||
@@ -84,7 +87,7 @@ public class TestBatchOnCascadeExceptionHandling extends BaseTestCase {
|
||||
Transaction txn = server.beginTransaction();
|
||||
try {
|
||||
assertThat(txn.getBatch()).isSameAs(PersistBatch.NONE);
|
||||
assertThat(txn.getBatchOnCascade()).isSameAs(PersistBatch.ALL);
|
||||
assertThat(txn.getBatchOnCascade()).isSameAs(spiEbeanServer().getDatabasePlatform().getPersistBatchOnCascade());
|
||||
|
||||
failingOperation.run();
|
||||
Assertions.fail("PersistenceException expected");
|
||||
|
||||
@@ -3,6 +3,8 @@ package org.tests.batchinsert;
|
||||
import io.ebean.BaseTestCase;
|
||||
import io.ebean.Ebean;
|
||||
import io.ebean.EbeanServer;
|
||||
import io.ebean.annotation.IgnorePlatform;
|
||||
import io.ebean.annotation.Platform;
|
||||
import io.ebean.annotation.Transactional;
|
||||
import org.tests.model.basic.Customer;
|
||||
import org.junit.Test;
|
||||
@@ -18,6 +20,7 @@ public class TestBatchSaveWithGetBeanId extends BaseTestCase {
|
||||
*/
|
||||
@Transactional(batchSize = 10)
|
||||
@Test
|
||||
@IgnorePlatform(Platform.HANA) // HANA doesn't support insert batching
|
||||
public void test() {
|
||||
|
||||
EbeanServer server = Ebean.getDefaultServer();
|
||||
|
||||
@@ -6,10 +6,12 @@ import javax.persistence.JoinColumn;
|
||||
import javax.persistence.JoinColumns;
|
||||
import javax.persistence.ManyToOne;
|
||||
import javax.persistence.OneToMany;
|
||||
import javax.persistence.Table;
|
||||
import javax.persistence.Version;
|
||||
import java.util.List;
|
||||
|
||||
@Entity
|
||||
@Table(name="`type`") // needs to be quoted because it's a keyword on HANA
|
||||
public class Type {
|
||||
@Id
|
||||
private TypeKey key;
|
||||
|
||||
@@ -59,12 +59,23 @@ public class TestMergeBasic extends BaseTestCase {
|
||||
assertThat(sql.get(2)).contains("update uuone set name=?, description=?, version=? where id=? and version=?");
|
||||
|
||||
// persist children ...
|
||||
assertThat(sql.get(3)).contains("insert into uutwo (id, name, notes, version, master_id) values (?,?,?,?,?);");
|
||||
assertThat(sql.get(4)).contains("insert into uutwo (id, name, notes, version, master_id) values (?,?,?,?,?);");
|
||||
if (isPersistBatchOnCascade()) {
|
||||
assertThat(sql.get(3)).contains("insert into uutwo (id, name, notes, version, master_id) values (?,?,?,?,?);");
|
||||
assertThat(sql.get(4)).contains("insert into uutwo (id, name, notes, version, master_id) values (?,?,?,?,?);");
|
||||
|
||||
assertThat(sql.get(5)).contains("update uutwo set name=?, notes=?, version=?, master_id=? where id=? and version=?");
|
||||
assertThat(sql.get(6)).contains("update uutwo set name=?, notes=?, version=?, master_id=? where id=? and version=?");
|
||||
assertThat(sql.get(7)).contains("update uutwo set name=?, notes=?, version=?, master_id=? where id=? and version=?");
|
||||
assertThat(sql.get(5)).contains("update uutwo set name=?, notes=?, version=?, master_id=? where id=? and version=?");
|
||||
assertThat(sql.get(6)).contains("update uutwo set name=?, notes=?, version=?, master_id=? where id=? and version=?");
|
||||
assertThat(sql.get(7)).contains("update uutwo set name=?, notes=?, version=?, master_id=? where id=? and version=?");
|
||||
}
|
||||
else {
|
||||
assertThat(sql.get(3)).contains("insert into uutwo (id, name, notes, version, master_id) values (?,?,?,?,?);");
|
||||
|
||||
assertThat(sql.get(4)).contains("update uutwo set name=?, notes=?, version=?, master_id=? where id=? and version=?");
|
||||
assertThat(sql.get(5)).contains("update uutwo set name=?, notes=?, version=?, master_id=? where id=? and version=?");
|
||||
assertThat(sql.get(6)).contains("update uutwo set name=?, notes=?, version=?, master_id=? where id=? and version=?");
|
||||
|
||||
assertThat(sql.get(7)).contains("insert into uutwo (id, name, notes, version, master_id) values (?,?,?,?,?);");
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -97,12 +108,23 @@ public class TestMergeBasic extends BaseTestCase {
|
||||
assertThat(sql.get(2)).contains("update uuone set name=?, description=?, version=? where id=? and version=?");
|
||||
|
||||
// persist children ...
|
||||
assertThat(sql.get(3)).contains("insert into uutwo (id, name, notes, version, master_id) values (?,?,?,?,?);");
|
||||
assertThat(sql.get(4)).contains("insert into uutwo (id, name, notes, version, master_id) values (?,?,?,?,?);");
|
||||
if (isPersistBatchOnCascade()) {
|
||||
assertThat(sql.get(3)).contains("insert into uutwo (id, name, notes, version, master_id) values (?,?,?,?,?);");
|
||||
assertThat(sql.get(4)).contains("insert into uutwo (id, name, notes, version, master_id) values (?,?,?,?,?);");
|
||||
|
||||
assertThat(sql.get(5)).contains("update uutwo set name=?, notes=?, version=?, master_id=? where id=? and version=?");
|
||||
assertThat(sql.get(6)).contains("update uutwo set name=?, notes=?, version=?, master_id=? where id=? and version=?");
|
||||
assertThat(sql.get(7)).contains("update uutwo set name=?, notes=?, version=?, master_id=? where id=? and version=?");
|
||||
}
|
||||
else {
|
||||
assertThat(sql.get(3)).contains("insert into uutwo (id, name, notes, version, master_id) values (?,?,?,?,?);");
|
||||
|
||||
assertThat(sql.get(5)).contains("update uutwo set name=?, notes=?, version=?, master_id=? where id=? and version=?");
|
||||
assertThat(sql.get(6)).contains("update uutwo set name=?, notes=?, version=?, master_id=? where id=? and version=?");
|
||||
assertThat(sql.get(7)).contains("update uutwo set name=?, notes=?, version=?, master_id=? where id=? and version=?");
|
||||
assertThat(sql.get(4)).contains("update uutwo set name=?, notes=?, version=?, master_id=? where id=? and version=?");
|
||||
assertThat(sql.get(5)).contains("update uutwo set name=?, notes=?, version=?, master_id=? where id=? and version=?");
|
||||
assertThat(sql.get(6)).contains("update uutwo set name=?, notes=?, version=?, master_id=? where id=? and version=?");
|
||||
|
||||
assertThat(sql.get(7)).contains("insert into uutwo (id, name, notes, version, master_id) values (?,?,?,?,?);");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -277,10 +277,18 @@ public class TestMergeCustomer extends BaseTestCase {
|
||||
assertThat(sql.get(2)).contains("delete from mcontact where id=?");
|
||||
|
||||
assertThat(sql.get(5)).contains("update mcustomer set name=?, version=?, shipping_address_id=?, billing_address_id=? where id=? and version=?");
|
||||
assertThat(sql.get(6)).contains("insert into mcontact");
|
||||
assertThat(sql.get(7)).contains("insert into mcontact");
|
||||
assertThat(sql.get(8)).contains("update mcontact set email=?, first_name=?, last_name=?, version=?, customer_id=? where id=? and version=?");
|
||||
assertThat(sql.get(11)).contains("update mcontact set email=?, first_name=?, last_name=?, version=?, customer_id=? where id=? and version=?");
|
||||
if (isPersistBatchOnCascade()) {
|
||||
assertThat(sql.get(6)).contains("insert into mcontact");
|
||||
assertThat(sql.get(7)).contains("insert into mcontact");
|
||||
assertThat(sql.get(8)).contains("update mcontact set email=?, first_name=?, last_name=?, version=?, customer_id=? where id=? and version=?");
|
||||
assertThat(sql.get(11)).contains("update mcontact set email=?, first_name=?, last_name=?, version=?, customer_id=? where id=? and version=?");
|
||||
}
|
||||
else {
|
||||
assertThat(sql.get(6)).contains("update mcontact set email=?, first_name=?, last_name=?, version=?, customer_id=? where id=? and version=?");
|
||||
assertThat(sql.get(7)).contains("update mcontact set email=?, first_name=?, last_name=?, version=?, customer_id=? where id=? and version=?");
|
||||
assertThat(sql.get(10)).contains("insert into mcontact");
|
||||
assertThat(sql.get(11)).contains("insert into mcontact");
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -305,7 +313,7 @@ public class TestMergeCustomer extends BaseTestCase {
|
||||
|
||||
List<String> sql = LoggedSqlCollector.stop();
|
||||
assertThat(sql.get(0)).contains("select t0.id, t3.id, t1.id, t2.id from mcustomer t0 left join maddress t3 on t3.id = t0.shipping_address_id left join maddress t1 on t1.id = t0.billing_address_id left join mcontact t2 on t2.customer_id = t0.id where t0.id = ?");
|
||||
if (isH2()) {
|
||||
if (isH2() || isHana()) {
|
||||
// with nested OneToMany .. we need a second query to read the contact message ids
|
||||
assertThat(sql.get(1)).contains("select t0.contact_id, t0.id from mcontact_message t0 where (t0.contact_id) in (?, ?, ?, ?, ?, ?, ?, ?, ?, ? )");
|
||||
}
|
||||
@@ -317,10 +325,18 @@ public class TestMergeCustomer extends BaseTestCase {
|
||||
assertThat(sql.get(6)).contains("update maddress set street=?, city=?, version=? where id=? and version=?");
|
||||
assertThat(sql.get(7)).contains("update mcustomer set name=?, notes=?, version=?, shipping_address_id=?, billing_address_id=? where id=? and version=?");
|
||||
|
||||
assertThat(sql.get(8)).contains("insert into mcontact");
|
||||
assertThat(sql.get(9)).contains("update mcontact set email=?, first_name=?, last_name=?, version=?, customer_id=? where id=? and version=?");
|
||||
|
||||
assertThat(sql.get(13)).contains("update mcontact_message set title=?, subject=?, notes=?, version=?, contact_id=? where id=? and version=?");
|
||||
if (isPersistBatchOnCascade()) {
|
||||
assertThat(sql.get(8)).contains("insert into mcontact");
|
||||
assertThat(sql.get(9)).contains("update mcontact set email=?, first_name=?, last_name=?, version=?, customer_id=? where id=? and version=?");
|
||||
|
||||
assertThat(sql.get(13)).contains("update mcontact_message set title=?, subject=?, notes=?, version=?, contact_id=? where id=? and version=?");
|
||||
}
|
||||
else {
|
||||
assertThat(sql.get(8)).contains("update mcontact set email=?, first_name=?, last_name=?, version=?, customer_id=? where id=? and version=?");
|
||||
assertThat(sql.get(9)).contains("update mcontact_message set title=?, subject=?, notes=?, version=?, contact_id=? where id=? and version=?");
|
||||
|
||||
assertThat(sql.get(sql.size()-1)).contains("insert into mcontact");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -40,10 +40,20 @@ public class TestMergeM2M extends BaseTestCase {
|
||||
Ebean.merge(machine, options);
|
||||
|
||||
List<String> sql = LoggedSqlCollector.current();
|
||||
assertThat(sql).hasSize(3);
|
||||
assertThat(sql.get(0)).contains("select");
|
||||
assertThat(sql.get(1)).contains("insert into mmachine");
|
||||
assertThat(sql.get(2)).contains("insert into mmachine_mgroup");
|
||||
if (isPersistBatchOnCascade()) {
|
||||
assertThat(sql).hasSize(3);
|
||||
assertThat(sql.get(0)).contains("select");
|
||||
assertThat(sql.get(1)).contains("insert into mmachine");
|
||||
assertThat(sql.get(2)).contains("insert into mmachine_mgroup");
|
||||
}
|
||||
else {
|
||||
assertThat(sql).hasSize(5);
|
||||
assertThat(sql.get(0)).contains("select");
|
||||
assertThat(sql.get(1)).contains("insert into mmachine");
|
||||
assertThat(sql.get(2)).contains("insert into mmachine_mgroup");
|
||||
assertThat(sql.get(3)).contains("insert into mmachine_mgroup");
|
||||
assertThat(sql.get(4)).contains("insert into mmachine_mgroup");
|
||||
}
|
||||
|
||||
machine.setName("mac1-mod");
|
||||
machine.getGroups().remove(group2);
|
||||
|
||||
@@ -3,6 +3,9 @@ package org.tests.model.array;
|
||||
import io.ebean.BaseTestCase;
|
||||
import io.ebean.Ebean;
|
||||
import io.ebean.Query;
|
||||
import io.ebean.annotation.IgnorePlatform;
|
||||
import io.ebean.annotation.Platform;
|
||||
|
||||
import org.ebeantest.LoggedSqlCollector;
|
||||
import org.junit.Test;
|
||||
|
||||
@@ -22,6 +25,7 @@ public class TestDbArray_asSet extends BaseTestCase {
|
||||
private EArraySetBean found;
|
||||
|
||||
@Test
|
||||
@IgnorePlatform(Platform.HANA)
|
||||
public void insert() {
|
||||
|
||||
bean.setName("some stuff");
|
||||
@@ -122,6 +126,7 @@ public class TestDbArray_asSet extends BaseTestCase {
|
||||
}
|
||||
|
||||
@Test
|
||||
@IgnorePlatform(Platform.HANA)
|
||||
public void insertNulls() {
|
||||
|
||||
EArraySetBean bean = new EArraySetBean();
|
||||
@@ -135,6 +140,7 @@ public class TestDbArray_asSet extends BaseTestCase {
|
||||
}
|
||||
|
||||
@Test
|
||||
@IgnorePlatform(Platform.HANA)
|
||||
public void insertAll_when_hasNulls() {
|
||||
|
||||
EArraySetBean bean = new EArraySetBean();
|
||||
|
||||
@@ -17,6 +17,8 @@ import io.ebean.BaseTestCase;
|
||||
import io.ebean.Ebean;
|
||||
import io.ebean.Query;
|
||||
import io.ebean.SqlRow;
|
||||
import io.ebean.annotation.IgnorePlatform;
|
||||
import io.ebean.annotation.Platform;
|
||||
|
||||
public class TestDbArray_basic extends BaseTestCase {
|
||||
|
||||
@@ -25,6 +27,7 @@ public class TestDbArray_basic extends BaseTestCase {
|
||||
private EArrayBean found;
|
||||
|
||||
@Test
|
||||
@IgnorePlatform(Platform.HANA)
|
||||
public void insert() throws SQLException {
|
||||
|
||||
bean.setName("some stuff");
|
||||
@@ -159,6 +162,7 @@ public class TestDbArray_basic extends BaseTestCase {
|
||||
}
|
||||
|
||||
@Test
|
||||
@IgnorePlatform(Platform.HANA)
|
||||
public void insertNulls() {
|
||||
|
||||
EArrayBean bean = new EArrayBean();
|
||||
@@ -172,6 +176,7 @@ public class TestDbArray_basic extends BaseTestCase {
|
||||
}
|
||||
|
||||
@Test
|
||||
@IgnorePlatform(Platform.HANA)
|
||||
public void insertAll_when_hasNulls() {
|
||||
|
||||
EArrayBean bean = new EArrayBean();
|
||||
|
||||
@@ -280,6 +280,8 @@ public class TestCacheViaComplexNaturalKey3 extends BaseTestCase {
|
||||
assertThat(sql.get(0)).contains("from o_cached_natkey3 t0 where t0.store = ? and concat(t0.sku,'-',t0.code) in (?, ? ) order by t0.sku desc; --bind(def,Array[2]={2-1000,3-1000})");
|
||||
} else if (isPostgres()) {
|
||||
assertThat(sql.get(0)).contains("from o_cached_natkey3 t0 where t0.store = ? and (t0.sku||'-'||t0.code)");
|
||||
} else if (isHana()) {
|
||||
assertThat(sql.get(0)).contains("from o_cached_natkey3 t0 where t0.store = ? and concat(t0.sku, '-'||t0.code)");
|
||||
} else {
|
||||
assertThat(sql.get(0)).contains("from o_cached_natkey3 t0 where t0.store = ? and concat(t0.sku,'-',t0.code)");
|
||||
}
|
||||
@@ -319,6 +321,8 @@ public class TestCacheViaComplexNaturalKey3 extends BaseTestCase {
|
||||
assertThat(sql.get(0)).contains("from o_cached_natkey3 t0 where t0.store = ? and concat(t0.sku,':',t0.code,'-foo') in (?, ? ) order by t0.sku desc; --bind(def,Array[2]={2:1000-foo,3:1000-foo})");
|
||||
} else if (isPostgres()){
|
||||
assertThat(sql.get(0)).contains("from o_cached_natkey3 t0 where t0.store = ? and (t0.sku||':'||t0.code||'-foo')");
|
||||
} else if (isHana()){
|
||||
assertThat(sql.get(0)).contains("from o_cached_natkey3 t0 where t0.store = ? and concat(t0.sku, ':'||t0.code||'-foo')");
|
||||
} else {
|
||||
assertThat(sql.get(0)).contains("from o_cached_natkey3 t0 where t0.store = ? and concat(t0.sku,':',t0.code,'-foo')");
|
||||
}
|
||||
|
||||
@@ -3,7 +3,10 @@ package org.tests.model.basic.xtra;
|
||||
import io.ebean.BaseTestCase;
|
||||
import io.ebean.Ebean;
|
||||
import io.ebean.Transaction;
|
||||
import io.ebean.annotation.IgnorePlatform;
|
||||
import io.ebean.annotation.PersistBatch;
|
||||
import io.ebean.annotation.Platform;
|
||||
|
||||
import org.ebeantest.LoggedSqlCollector;
|
||||
import org.junit.Test;
|
||||
|
||||
@@ -16,6 +19,7 @@ import static org.junit.Assert.assertTrue;
|
||||
public class TestInsertBatchThenFlushThenUpdate extends BaseTestCase {
|
||||
|
||||
@Test
|
||||
@IgnorePlatform(Platform.HANA)
|
||||
public void test() {
|
||||
|
||||
LoggedSqlCollector.start();
|
||||
|
||||
@@ -3,7 +3,10 @@ package org.tests.model.basic.xtra;
|
||||
import io.ebean.BaseTestCase;
|
||||
import io.ebean.Ebean;
|
||||
import io.ebean.Transaction;
|
||||
import io.ebean.annotation.IgnorePlatform;
|
||||
import io.ebean.annotation.PersistBatch;
|
||||
import io.ebean.annotation.Platform;
|
||||
|
||||
import org.ebeantest.LoggedSqlCollector;
|
||||
import org.junit.Test;
|
||||
|
||||
@@ -16,6 +19,7 @@ import static org.junit.Assert.assertEquals;
|
||||
public class TestInsertBatchThenUpdate extends BaseTestCase {
|
||||
|
||||
@Test
|
||||
@IgnorePlatform(Platform.HANA)
|
||||
public void test() {
|
||||
|
||||
LoggedSqlCollector.start();
|
||||
@@ -60,6 +64,7 @@ public class TestInsertBatchThenUpdate extends BaseTestCase {
|
||||
|
||||
|
||||
@Test
|
||||
@IgnorePlatform(Platform.HANA)
|
||||
public void test_noFlushOn_getterOfNonGeneratedProperty() {
|
||||
|
||||
LoggedSqlCollector.start();
|
||||
|
||||
@@ -3,7 +3,10 @@ package org.tests.model.basic.xtra;
|
||||
import io.ebean.BaseTestCase;
|
||||
import io.ebean.Ebean;
|
||||
import io.ebean.Transaction;
|
||||
import io.ebean.annotation.IgnorePlatform;
|
||||
import io.ebean.annotation.PersistBatch;
|
||||
import io.ebean.annotation.Platform;
|
||||
|
||||
import org.ebeantest.LoggedSqlCollector;
|
||||
import org.junit.Test;
|
||||
|
||||
@@ -15,6 +18,7 @@ import static org.junit.Assert.assertEquals;
|
||||
public class TestInsertBatchWithDifferentRootTypes extends BaseTestCase {
|
||||
|
||||
@Test
|
||||
@IgnorePlatform(Platform.HANA)
|
||||
public void testDifferRootTypes() {
|
||||
|
||||
LoggedSqlCollector.start();
|
||||
|
||||
@@ -29,9 +29,17 @@ public class TestElementCollectionBasic extends BaseTestCase {
|
||||
assertThat(eventLog()).containsExactly("preInsert", "postInsert");
|
||||
|
||||
List<String> sql = LoggedSqlCollector.current();
|
||||
assertThat(sql).hasSize(2);
|
||||
assertThat(sql.get(0)).contains("insert into ec_person");
|
||||
assertThat(sql.get(1)).contains("insert into ec_person_phone");
|
||||
if (isPersistBatchOnCascade()) {
|
||||
assertThat(sql).hasSize(2);
|
||||
assertThat(sql.get(0)).contains("insert into ec_person");
|
||||
assertThat(sql.get(1)).contains("insert into ec_person_phone");
|
||||
}
|
||||
else {
|
||||
assertThat(sql).hasSize(3);
|
||||
assertThat(sql.get(0)).contains("insert into ec_person");
|
||||
assertThat(sql.get(1)).contains("insert into ec_person_phone");
|
||||
assertThat(sql.get(2)).contains("insert into ec_person_phone");
|
||||
}
|
||||
|
||||
EcPerson person1 = new EcPerson("Fiona09");
|
||||
person1.getPhoneNumbers().add("09 1234");
|
||||
@@ -121,10 +129,20 @@ public class TestElementCollectionBasic extends BaseTestCase {
|
||||
Ebean.save(bean);
|
||||
|
||||
List<String> sql = LoggedSqlCollector.current();
|
||||
assertThat(sql).hasSize(3);
|
||||
assertThat(sql.get(0)).contains("update ec_person set name=?, version=? where id=? and version=?");
|
||||
assertThat(sql.get(1)).contains("delete from ec_person_phone where owner_id=?");
|
||||
assertThat(sql.get(2)).contains("insert into ec_person_phone (owner_id,phone) values (?,?)");
|
||||
if (isPersistBatchOnCascade()) {
|
||||
assertThat(sql).hasSize(3);
|
||||
assertThat(sql.get(0)).contains("update ec_person set name=?, version=? where id=? and version=?");
|
||||
assertThat(sql.get(1)).contains("delete from ec_person_phone where owner_id=?");
|
||||
assertThat(sql.get(2)).contains("insert into ec_person_phone (owner_id,phone) values (?,?)");
|
||||
}
|
||||
else {
|
||||
assertThat(sql).hasSize(5);
|
||||
assertThat(sql.get(0)).contains("update ec_person set name=?, version=? where id=? and version=?");
|
||||
assertThat(sql.get(1)).contains("delete from ec_person_phone where owner_id=?");
|
||||
assertThat(sql.get(2)).contains("insert into ec_person_phone (owner_id,phone) values (?,?)");
|
||||
assertThat(sql.get(3)).contains("insert into ec_person_phone (owner_id,phone) values (?,?)");
|
||||
assertThat(sql.get(4)).contains("insert into ec_person_phone (owner_id,phone) values (?,?)");
|
||||
}
|
||||
|
||||
assertThat(eventLog()).containsExactly("preUpdate", "postUpdate");
|
||||
|
||||
@@ -189,9 +207,21 @@ public class TestElementCollectionBasic extends BaseTestCase {
|
||||
Ebean.save(bean);
|
||||
|
||||
List<String> sql = LoggedSqlCollector.current();
|
||||
assertThat(sql).hasSize(2);
|
||||
assertThat(sql.get(0)).contains("delete from ec_person_phone where owner_id=?");
|
||||
assertThat(sql.get(1)).contains("insert into ec_person_phone (owner_id,phone) values (?,?)");
|
||||
if (isPersistBatchOnCascade()) {
|
||||
assertThat(sql).hasSize(2);
|
||||
assertThat(sql.get(0)).contains("delete from ec_person_phone where owner_id=?");
|
||||
assertThat(sql.get(1)).contains("insert into ec_person_phone (owner_id,phone) values (?,?)");
|
||||
}
|
||||
else {
|
||||
assertThat(sql).hasSize(7);
|
||||
assertThat(sql.get(0)).contains("delete from ec_person_phone where owner_id=?");
|
||||
assertThat(sql.get(1)).contains("insert into ec_person_phone (owner_id,phone) values (?,?)");
|
||||
assertThat(sql.get(2)).contains("insert into ec_person_phone (owner_id,phone) values (?,?)");
|
||||
assertThat(sql.get(3)).contains("insert into ec_person_phone (owner_id,phone) values (?,?)");
|
||||
assertThat(sql.get(4)).contains("insert into ec_person_phone (owner_id,phone) values (?,?)");
|
||||
assertThat(sql.get(5)).contains("insert into ec_person_phone (owner_id,phone) values (?,?)");
|
||||
assertThat(sql.get(6)).contains("insert into ec_person_phone (owner_id,phone) values (?,?)");
|
||||
}
|
||||
|
||||
assertThat(eventLog()).containsExactly("preUpdate", "postUpdate");
|
||||
|
||||
|
||||
+19
-2
@@ -1,6 +1,9 @@
|
||||
package org.tests.model.elementcollection;
|
||||
|
||||
import io.ebean.Ebean;
|
||||
import io.ebean.annotation.PersistBatch;
|
||||
import io.ebeaninternal.api.SpiEbeanServer;
|
||||
|
||||
import org.ebeantest.LoggedSqlCollector;
|
||||
import org.junit.Test;
|
||||
|
||||
@@ -39,7 +42,12 @@ public class TestElementCollectionBasicCache {
|
||||
Ebean.save(two);
|
||||
|
||||
sql = LoggedSqlCollector.current();
|
||||
assertThat(sql).hasSize(3);
|
||||
if (isPersistBatchOnCascade()) {
|
||||
assertThat(sql).hasSize(3);
|
||||
}
|
||||
else {
|
||||
assertThat(sql).hasSize(5);
|
||||
}
|
||||
|
||||
Ebean.save(two);
|
||||
|
||||
@@ -60,7 +68,12 @@ public class TestElementCollectionBasicCache {
|
||||
Ebean.save(three);
|
||||
|
||||
sql = LoggedSqlCollector.current();
|
||||
assertThat(sql).hasSize(2); // cache hit
|
||||
if (isPersistBatchOnCascade()) {
|
||||
assertThat(sql).hasSize(2); // cache hit
|
||||
}
|
||||
else {
|
||||
assertThat(sql).hasSize(5); // cache hit
|
||||
}
|
||||
|
||||
EcPerson four = Ebean.find(EcPerson.class)
|
||||
.setId(person.getId())
|
||||
@@ -77,4 +90,8 @@ public class TestElementCollectionBasicCache {
|
||||
|
||||
LoggedSqlCollector.stop();
|
||||
}
|
||||
|
||||
public boolean isPersistBatchOnCascade() {
|
||||
return ((SpiEbeanServer) Ebean.getDefaultServer()).getDatabasePlatform().getPersistBatchOnCascade() != PersistBatch.NONE;
|
||||
}
|
||||
}
|
||||
|
||||
+40
-10
@@ -2,6 +2,8 @@ package org.tests.model.elementcollection;
|
||||
|
||||
import io.ebean.BaseTestCase;
|
||||
import io.ebean.Ebean;
|
||||
import io.ebean.annotation.PersistBatch;
|
||||
|
||||
import org.ebeantest.LoggedSqlCollector;
|
||||
import org.junit.Test;
|
||||
|
||||
@@ -24,9 +26,17 @@ public class TestElementCollectionBasicMap extends BaseTestCase {
|
||||
Ebean.save(person);
|
||||
|
||||
List<String> sql = LoggedSqlCollector.current();
|
||||
assertThat(sql).hasSize(2);
|
||||
assertThat(sql.get(0)).contains("insert into ecm_person");
|
||||
assertThat(sql.get(1)).contains("insert into ecm_person_phone");
|
||||
if (isPersistBatchOnCascade()) {
|
||||
assertThat(sql).hasSize(2);
|
||||
assertThat(sql.get(0)).contains("insert into ecm_person");
|
||||
assertThat(sql.get(1)).contains("insert into ecm_person_phone");
|
||||
}
|
||||
else {
|
||||
assertThat(sql).hasSize(3);
|
||||
assertThat(sql.get(0)).contains("insert into ecm_person");
|
||||
assertThat(sql.get(1)).contains("insert into ecm_person_phone");
|
||||
assertThat(sql.get(2)).contains("insert into ecm_person_phone");
|
||||
}
|
||||
|
||||
EcmPerson person1 = new EcmPerson("Fiona09");
|
||||
person1.getPhoneNumbers().put("home", "09 1234");
|
||||
@@ -96,10 +106,20 @@ public class TestElementCollectionBasicMap extends BaseTestCase {
|
||||
Ebean.save(bean);
|
||||
|
||||
List<String> sql = LoggedSqlCollector.current();
|
||||
assertThat(sql).hasSize(3);
|
||||
assertThat(sql.get(0)).contains("update ecm_person set name=?, version=? where id=? and version=?");
|
||||
assertThat(sql.get(1)).contains("delete from ecm_person_phone_numbers where ecm_person_id=?");
|
||||
assertThat(sql.get(2)).contains("insert into ecm_person_phone_numbers (ecm_person_id,type,number) values (?,?,?)");
|
||||
if (isPersistBatchOnCascade()) {
|
||||
assertThat(sql).hasSize(3);
|
||||
assertThat(sql.get(0)).contains("update ecm_person set name=?, version=? where id=? and version=?");
|
||||
assertThat(sql.get(1)).contains("delete from ecm_person_phone_numbers where ecm_person_id=?");
|
||||
assertThat(sql.get(2)).contains("insert into ecm_person_phone_numbers (ecm_person_id,type,number) values (?,?,?)");
|
||||
}
|
||||
else {
|
||||
assertThat(sql).hasSize(5);
|
||||
assertThat(sql.get(0)).contains("update ecm_person set name=?, version=? where id=? and version=?");
|
||||
assertThat(sql.get(1)).contains("delete from ecm_person_phone_numbers where ecm_person_id=?");
|
||||
assertThat(sql.get(2)).contains("insert into ecm_person_phone_numbers (ecm_person_id,type,number) values (?,?,?)");
|
||||
assertThat(sql.get(3)).contains("insert into ecm_person_phone_numbers (ecm_person_id,type,number) values (?,?,?)");
|
||||
assertThat(sql.get(4)).contains("insert into ecm_person_phone_numbers (ecm_person_id,type,number) values (?,?,?)");
|
||||
}
|
||||
|
||||
updateNothing(bean);
|
||||
}
|
||||
@@ -120,9 +140,19 @@ public class TestElementCollectionBasicMap extends BaseTestCase {
|
||||
Ebean.save(bean);
|
||||
|
||||
List<String> sql = LoggedSqlCollector.current();
|
||||
assertThat(sql).hasSize(2);
|
||||
assertThat(sql.get(0)).contains("delete from ecm_person_phone_numbers where ecm_person_id=?");
|
||||
assertThat(sql.get(1)).contains("insert into ecm_person_phone_numbers (ecm_person_id,type,number) values (?,?,?)");
|
||||
if (isPersistBatchOnCascade()) {
|
||||
assertThat(sql).hasSize(2);
|
||||
assertThat(sql.get(0)).contains("delete from ecm_person_phone_numbers where ecm_person_id=?");
|
||||
assertThat(sql.get(1)).contains("insert into ecm_person_phone_numbers (ecm_person_id,type,number) values (?,?,?)");
|
||||
}
|
||||
else {
|
||||
assertThat(sql).hasSize(5);
|
||||
assertThat(sql.get(0)).contains("delete from ecm_person_phone_numbers where ecm_person_id=?");
|
||||
assertThat(sql.get(1)).contains("insert into ecm_person_phone_numbers (ecm_person_id,type,number) values (?,?,?)");
|
||||
assertThat(sql.get(2)).contains("insert into ecm_person_phone_numbers (ecm_person_id,type,number) values (?,?,?)");
|
||||
assertThat(sql.get(3)).contains("insert into ecm_person_phone_numbers (ecm_person_id,type,number) values (?,?,?)");
|
||||
assertThat(sql.get(4)).contains("insert into ecm_person_phone_numbers (ecm_person_id,type,number) values (?,?,?)");
|
||||
}
|
||||
|
||||
delete(bean);
|
||||
}
|
||||
|
||||
+19
-2
@@ -1,6 +1,9 @@
|
||||
package org.tests.model.elementcollection;
|
||||
|
||||
import io.ebean.Ebean;
|
||||
import io.ebean.annotation.PersistBatch;
|
||||
import io.ebeaninternal.api.SpiEbeanServer;
|
||||
|
||||
import org.ebeantest.LoggedSqlCollector;
|
||||
import org.junit.Test;
|
||||
|
||||
@@ -41,7 +44,12 @@ public class TestElementCollectionBasicMapCache {
|
||||
Ebean.save(two);
|
||||
|
||||
sql = LoggedSqlCollector.current();
|
||||
assertThat(sql).hasSize(3);
|
||||
if (isPersistBatchOnCascade()) {
|
||||
assertThat(sql).hasSize(3);
|
||||
}
|
||||
else {
|
||||
assertThat(sql).hasSize(5);
|
||||
}
|
||||
|
||||
Ebean.save(two);
|
||||
|
||||
@@ -64,7 +72,12 @@ public class TestElementCollectionBasicMapCache {
|
||||
Ebean.save(three);
|
||||
|
||||
sql = LoggedSqlCollector.current();
|
||||
assertThat(sql).hasSize(2); // cache hit
|
||||
if (isPersistBatchOnCascade()) {
|
||||
assertThat(sql).hasSize(2); // cache hit
|
||||
}
|
||||
else {
|
||||
assertThat(sql).hasSize(3); // cache hit
|
||||
}
|
||||
|
||||
EcmPerson four = Ebean.find(EcmPerson.class)
|
||||
.setId(person.getId())
|
||||
@@ -82,4 +95,8 @@ public class TestElementCollectionBasicMapCache {
|
||||
|
||||
LoggedSqlCollector.stop();
|
||||
}
|
||||
|
||||
public boolean isPersistBatchOnCascade() {
|
||||
return ((SpiEbeanServer) Ebean.getDefaultServer()).getDatabasePlatform().getPersistBatchOnCascade() != PersistBatch.NONE;
|
||||
}
|
||||
}
|
||||
|
||||
+38
-10
@@ -23,9 +23,17 @@ public class TestElementCollectionBasicSet extends BaseTestCase {
|
||||
Ebean.save(person);
|
||||
|
||||
List<String> sql = LoggedSqlCollector.current();
|
||||
assertThat(sql).hasSize(2);
|
||||
assertThat(sql.get(0)).contains("insert into ecs_person");
|
||||
assertThat(sql.get(1)).contains("insert into ecs_person_phone");
|
||||
if (isPersistBatchOnCascade()) {
|
||||
assertThat(sql).hasSize(2);
|
||||
assertThat(sql.get(0)).contains("insert into ecs_person");
|
||||
assertThat(sql.get(1)).contains("insert into ecs_person_phone");
|
||||
}
|
||||
else {
|
||||
assertThat(sql).hasSize(3);
|
||||
assertThat(sql.get(0)).contains("insert into ecs_person");
|
||||
assertThat(sql.get(1)).contains("insert into ecs_person_phone");
|
||||
assertThat(sql.get(2)).contains("insert into ecs_person_phone");
|
||||
}
|
||||
|
||||
EcsPerson person1 = new EcsPerson("Fiona09");
|
||||
person1.getPhoneNumbers().add("09 1234");
|
||||
@@ -94,10 +102,20 @@ public class TestElementCollectionBasicSet extends BaseTestCase {
|
||||
Ebean.save(bean);
|
||||
|
||||
List<String> sql = LoggedSqlCollector.current();
|
||||
assertThat(sql).hasSize(3);
|
||||
assertThat(sql.get(0)).contains("update ecs_person set name=?, version=? where id=? and version=?");
|
||||
assertThat(sql.get(1)).contains("delete from ecs_person_phone where ecs_person_id=?");
|
||||
assertThat(sql.get(2)).contains("insert into ecs_person_phone (ecs_person_id,phone) values (?,?)");
|
||||
if (isPersistBatchOnCascade()) {
|
||||
assertThat(sql).hasSize(3);
|
||||
assertThat(sql.get(0)).contains("update ecs_person set name=?, version=? where id=? and version=?");
|
||||
assertThat(sql.get(1)).contains("delete from ecs_person_phone where ecs_person_id=?");
|
||||
assertThat(sql.get(2)).contains("insert into ecs_person_phone (ecs_person_id,phone) values (?,?)");
|
||||
}
|
||||
else {
|
||||
assertThat(sql).hasSize(5);
|
||||
assertThat(sql.get(0)).contains("update ecs_person set name=?, version=? where id=? and version=?");
|
||||
assertThat(sql.get(1)).contains("delete from ecs_person_phone where ecs_person_id=?");
|
||||
assertThat(sql.get(2)).contains("insert into ecs_person_phone (ecs_person_id,phone) values (?,?)");
|
||||
assertThat(sql.get(3)).contains("insert into ecs_person_phone (ecs_person_id,phone) values (?,?)");
|
||||
assertThat(sql.get(4)).contains("insert into ecs_person_phone (ecs_person_id,phone) values (?,?)");
|
||||
}
|
||||
|
||||
updateNothing(bean);
|
||||
}
|
||||
@@ -118,9 +136,19 @@ public class TestElementCollectionBasicSet extends BaseTestCase {
|
||||
Ebean.save(bean);
|
||||
|
||||
List<String> sql = LoggedSqlCollector.current();
|
||||
assertThat(sql).hasSize(2);
|
||||
assertThat(sql.get(0)).contains("delete from ecs_person_phone where ecs_person_id=?");
|
||||
assertThat(sql.get(1)).contains("insert into ecs_person_phone (ecs_person_id,phone) values (?,?)");
|
||||
if (isPersistBatchOnCascade()) {
|
||||
assertThat(sql).hasSize(2);
|
||||
assertThat(sql.get(0)).contains("delete from ecs_person_phone where ecs_person_id=?");
|
||||
assertThat(sql.get(1)).contains("insert into ecs_person_phone (ecs_person_id,phone) values (?,?)");
|
||||
}
|
||||
else {
|
||||
assertThat(sql).hasSize(5);
|
||||
assertThat(sql.get(0)).contains("delete from ecs_person_phone where ecs_person_id=?");
|
||||
assertThat(sql.get(1)).contains("insert into ecs_person_phone (ecs_person_id,phone) values (?,?)");
|
||||
assertThat(sql.get(2)).contains("insert into ecs_person_phone (ecs_person_id,phone) values (?,?)");
|
||||
assertThat(sql.get(3)).contains("insert into ecs_person_phone (ecs_person_id,phone) values (?,?)");
|
||||
assertThat(sql.get(4)).contains("insert into ecs_person_phone (ecs_person_id,phone) values (?,?)");
|
||||
}
|
||||
|
||||
delete(bean);
|
||||
}
|
||||
|
||||
+38
-10
@@ -22,9 +22,17 @@ public class TestElementCollectionEmbeddedList extends BaseTestCase {
|
||||
Ebean.save(person);
|
||||
|
||||
List<String> sql = LoggedSqlCollector.current();
|
||||
assertThat(sql).hasSize(2);
|
||||
assertThat(sql.get(0)).contains("insert into ecbl_person");
|
||||
assertThat(sql.get(1)).contains("insert into ecbl_person_phone_numbers");
|
||||
if (isPersistBatchOnCascade()) {
|
||||
assertThat(sql).hasSize(2);
|
||||
assertThat(sql.get(0)).contains("insert into ecbl_person");
|
||||
assertThat(sql.get(1)).contains("insert into ecbl_person_phone_numbers");
|
||||
}
|
||||
else {
|
||||
assertThat(sql).hasSize(3);
|
||||
assertThat(sql.get(0)).contains("insert into ecbl_person");
|
||||
assertThat(sql.get(1)).contains("insert into ecbl_person_phone_numbers");
|
||||
assertThat(sql.get(2)).contains("insert into ecbl_person_phone_numbers");
|
||||
}
|
||||
|
||||
EcblPerson person1 = new EcblPerson("Fiona6409");
|
||||
person1.getPhoneNumbers().add(new EcPhone("61","09","1234"));
|
||||
@@ -94,10 +102,20 @@ public class TestElementCollectionEmbeddedList extends BaseTestCase {
|
||||
Ebean.save(bean);
|
||||
|
||||
List<String> sql = LoggedSqlCollector.current();
|
||||
assertThat(sql).hasSize(3);
|
||||
assertThat(sql.get(0)).contains("update ecbl_person set name=?, version=? where id=? and version=?");
|
||||
assertThat(sql.get(1)).contains("delete from ecbl_person_phone_numbers where person_id=?");
|
||||
assertThat(sql.get(2)).contains("insert into ecbl_person_phone_numbers (person_id,country_code,area,number) values (?,?,?,?)");
|
||||
if (isPersistBatchOnCascade()) {
|
||||
assertThat(sql).hasSize(3);
|
||||
assertThat(sql.get(0)).contains("update ecbl_person set name=?, version=? where id=? and version=?");
|
||||
assertThat(sql.get(1)).contains("delete from ecbl_person_phone_numbers where person_id=?");
|
||||
assertThat(sql.get(2)).contains("insert into ecbl_person_phone_numbers (person_id,country_code,area,number) values (?,?,?,?)");
|
||||
}
|
||||
else {
|
||||
assertThat(sql).hasSize(5);
|
||||
assertThat(sql.get(0)).contains("update ecbl_person set name=?, version=? where id=? and version=?");
|
||||
assertThat(sql.get(1)).contains("delete from ecbl_person_phone_numbers where person_id=?");
|
||||
assertThat(sql.get(2)).contains("insert into ecbl_person_phone_numbers (person_id,country_code,area,number) values (?,?,?,?)");
|
||||
assertThat(sql.get(3)).contains("insert into ecbl_person_phone_numbers (person_id,country_code,area,number) values (?,?,?,?)");
|
||||
assertThat(sql.get(4)).contains("insert into ecbl_person_phone_numbers (person_id,country_code,area,number) values (?,?,?,?)");
|
||||
}
|
||||
|
||||
updateNothing(bean);
|
||||
}
|
||||
@@ -118,9 +136,19 @@ public class TestElementCollectionEmbeddedList extends BaseTestCase {
|
||||
Ebean.save(bean);
|
||||
|
||||
List<String> sql = LoggedSqlCollector.current();
|
||||
assertThat(sql).hasSize(2);
|
||||
assertThat(sql.get(0)).contains("delete from ecbl_person_phone_numbers where person_id=?");
|
||||
assertThat(sql.get(1)).contains("insert into ecbl_person_phone_numbers (person_id,country_code,area,number) values (?,?,?,?)");
|
||||
if (isPersistBatchOnCascade()) {
|
||||
assertThat(sql).hasSize(2);
|
||||
assertThat(sql.get(0)).contains("delete from ecbl_person_phone_numbers where person_id=?");
|
||||
assertThat(sql.get(1)).contains("insert into ecbl_person_phone_numbers (person_id,country_code,area,number) values (?,?,?,?)");
|
||||
}
|
||||
else {
|
||||
assertThat(sql).hasSize(5);
|
||||
assertThat(sql.get(0)).contains("delete from ecbl_person_phone_numbers where person_id=?");
|
||||
assertThat(sql.get(1)).contains("insert into ecbl_person_phone_numbers (person_id,country_code,area,number) values (?,?,?,?)");
|
||||
assertThat(sql.get(2)).contains("insert into ecbl_person_phone_numbers (person_id,country_code,area,number) values (?,?,?,?)");
|
||||
assertThat(sql.get(3)).contains("insert into ecbl_person_phone_numbers (person_id,country_code,area,number) values (?,?,?,?)");
|
||||
assertThat(sql.get(4)).contains("insert into ecbl_person_phone_numbers (person_id,country_code,area,number) values (?,?,?,?)");
|
||||
}
|
||||
|
||||
delete(bean);
|
||||
}
|
||||
|
||||
+13
-3
@@ -2,6 +2,8 @@ package org.tests.model.elementcollection;
|
||||
|
||||
import io.ebean.BaseTestCase;
|
||||
import io.ebean.Ebean;
|
||||
import io.ebean.annotation.PersistBatch;
|
||||
|
||||
import org.ebeantest.LoggedSqlCollector;
|
||||
import org.junit.Test;
|
||||
|
||||
@@ -47,9 +49,17 @@ public class TestElementCollectionEmbeddedListCache extends BaseTestCase {
|
||||
Ebean.save(two);
|
||||
|
||||
sql = LoggedSqlCollector.current();
|
||||
assertThat(sql).hasSize(2); // update of collection only
|
||||
assertThat(sql.get(0)).contains("delete from ecbl_person_phone_numbers where person_id=?");
|
||||
assertThat(sql.get(1)).contains("insert into ecbl_person_phone_numbers (person_id,country_code,area,number) values (?,?,?,?)");
|
||||
if (isPersistBatchOnCascade()) {
|
||||
assertThat(sql).hasSize(2); // update of collection only
|
||||
assertThat(sql.get(0)).contains("delete from ecbl_person_phone_numbers where person_id=?");
|
||||
assertThat(sql.get(1)).contains("insert into ecbl_person_phone_numbers (person_id,country_code,area,number) values (?,?,?,?)");
|
||||
}
|
||||
else {
|
||||
assertThat(sql).hasSize(3); // update of collection only
|
||||
assertThat(sql.get(0)).contains("delete from ecbl_person_phone_numbers where person_id=?");
|
||||
assertThat(sql.get(1)).contains("insert into ecbl_person_phone_numbers (person_id,country_code,area,number) values (?,?,?,?)");
|
||||
assertThat(sql.get(2)).contains("insert into ecbl_person_phone_numbers (person_id,country_code,area,number) values (?,?,?,?)");
|
||||
}
|
||||
|
||||
EcblPerson three = Ebean.find(EcblPerson.class)
|
||||
.setId(person.getId())
|
||||
|
||||
+38
-10
@@ -23,9 +23,17 @@ public class TestElementCollectionEmbeddedMap extends BaseTestCase {
|
||||
Ebean.save(person);
|
||||
|
||||
List<String> sql = LoggedSqlCollector.current();
|
||||
assertThat(sql).hasSize(2);
|
||||
assertThat(sql.get(0)).contains("insert into ecbm_person");
|
||||
assertThat(sql.get(1)).contains("insert into ecbm_person_phone_numbers");
|
||||
if (isPersistBatchOnCascade()) {
|
||||
assertThat(sql).hasSize(2);
|
||||
assertThat(sql.get(0)).contains("insert into ecbm_person");
|
||||
assertThat(sql.get(1)).contains("insert into ecbm_person_phone_numbers");
|
||||
}
|
||||
else {
|
||||
assertThat(sql).hasSize(3);
|
||||
assertThat(sql.get(0)).contains("insert into ecbm_person");
|
||||
assertThat(sql.get(1)).contains("insert into ecbm_person_phone_numbers");
|
||||
assertThat(sql.get(2)).contains("insert into ecbm_person_phone_numbers");
|
||||
}
|
||||
|
||||
EcbmPerson person1 = new EcbmPerson("Fiona6409");
|
||||
person1.getPhoneNumbers().put("home",new EcPhone("64","09","1234"));
|
||||
@@ -87,10 +95,20 @@ public class TestElementCollectionEmbeddedMap extends BaseTestCase {
|
||||
Ebean.save(bean);
|
||||
|
||||
List<String> sql = LoggedSqlCollector.current();
|
||||
assertThat(sql).hasSize(3);
|
||||
assertThat(sql.get(0)).contains("update ecbm_person set name=?, version=? where id=? and version=?");
|
||||
assertThat(sql.get(1)).contains("delete from ecbm_person_phone_numbers where person_id=?");
|
||||
assertThat(sql.get(2)).contains("insert into ecbm_person_phone_numbers (person_id,mkey,country_code,area,number)");
|
||||
if (isPersistBatchOnCascade()) {
|
||||
assertThat(sql).hasSize(3);
|
||||
assertThat(sql.get(0)).contains("update ecbm_person set name=?, version=? where id=? and version=?");
|
||||
assertThat(sql.get(1)).contains("delete from ecbm_person_phone_numbers where person_id=?");
|
||||
assertThat(sql.get(2)).contains("insert into ecbm_person_phone_numbers (person_id,mkey,country_code,area,number)");
|
||||
}
|
||||
else {
|
||||
assertThat(sql).hasSize(5);
|
||||
assertThat(sql.get(0)).contains("update ecbm_person set name=?, version=? where id=? and version=?");
|
||||
assertThat(sql.get(1)).contains("delete from ecbm_person_phone_numbers where person_id=?");
|
||||
assertThat(sql.get(2)).contains("insert into ecbm_person_phone_numbers (person_id,mkey,country_code,area,number)");
|
||||
assertThat(sql.get(3)).contains("insert into ecbm_person_phone_numbers (person_id,mkey,country_code,area,number)");
|
||||
assertThat(sql.get(4)).contains("insert into ecbm_person_phone_numbers (person_id,mkey,country_code,area,number)");
|
||||
}
|
||||
|
||||
updateNothing(bean);
|
||||
}
|
||||
@@ -111,9 +129,19 @@ public class TestElementCollectionEmbeddedMap extends BaseTestCase {
|
||||
Ebean.save(bean);
|
||||
|
||||
List<String> sql = LoggedSqlCollector.current();
|
||||
assertThat(sql).hasSize(2);
|
||||
assertThat(sql.get(0)).contains("delete from ecbm_person_phone_numbers where person_id=?");
|
||||
assertThat(sql.get(1)).contains("insert into ecbm_person_phone_numbers (person_id,mkey,country_code,area,number) values (?,?,?,?,?)");
|
||||
if (isPersistBatchOnCascade()) {
|
||||
assertThat(sql).hasSize(2);
|
||||
assertThat(sql.get(0)).contains("delete from ecbm_person_phone_numbers where person_id=?");
|
||||
assertThat(sql.get(1)).contains("insert into ecbm_person_phone_numbers (person_id,mkey,country_code,area,number) values (?,?,?,?,?)");
|
||||
}
|
||||
else {
|
||||
assertThat(sql).hasSize(5);
|
||||
assertThat(sql.get(0)).contains("delete from ecbm_person_phone_numbers where person_id=?");
|
||||
assertThat(sql.get(1)).contains("insert into ecbm_person_phone_numbers (person_id,mkey,country_code,area,number) values (?,?,?,?,?)");
|
||||
assertThat(sql.get(2)).contains("insert into ecbm_person_phone_numbers (person_id,mkey,country_code,area,number) values (?,?,?,?,?)");
|
||||
assertThat(sql.get(3)).contains("insert into ecbm_person_phone_numbers (person_id,mkey,country_code,area,number) values (?,?,?,?,?)");
|
||||
assertThat(sql.get(4)).contains("insert into ecbm_person_phone_numbers (person_id,mkey,country_code,area,number) values (?,?,?,?,?)");
|
||||
}
|
||||
|
||||
delete(bean);
|
||||
}
|
||||
|
||||
+11
-3
@@ -48,9 +48,17 @@ public class TestElementCollectionEmbeddedMapCache extends BaseTestCase {
|
||||
Ebean.save(two);
|
||||
|
||||
sql = LoggedSqlCollector.current();
|
||||
assertThat(sql).hasSize(2); // update of collection only
|
||||
assertThat(sql.get(0)).contains("delete from ecbm_person_phone_numbers where person_id=?");
|
||||
assertThat(sql.get(1)).contains("insert into ecbm_person_phone_numbers (person_id,mkey,country_code,area,number) values (?,?,?,?,?)");
|
||||
if (isPersistBatchOnCascade()) {
|
||||
assertThat(sql).hasSize(2); // update of collection only
|
||||
assertThat(sql.get(0)).contains("delete from ecbm_person_phone_numbers where person_id=?");
|
||||
assertThat(sql.get(1)).contains("insert into ecbm_person_phone_numbers (person_id,mkey,country_code,area,number) values (?,?,?,?,?)");
|
||||
}
|
||||
else {
|
||||
assertThat(sql).hasSize(3); // update of collection only
|
||||
assertThat(sql.get(0)).contains("delete from ecbm_person_phone_numbers where person_id=?");
|
||||
assertThat(sql.get(1)).contains("insert into ecbm_person_phone_numbers (person_id,mkey,country_code,area,number) values (?,?,?,?,?)");
|
||||
assertThat(sql.get(2)).contains("insert into ecbm_person_phone_numbers (person_id,mkey,country_code,area,number) values (?,?,?,?,?)");
|
||||
}
|
||||
|
||||
EcbmPerson three = Ebean.find(EcbmPerson.class)
|
||||
.setId(person.getId())
|
||||
|
||||
@@ -18,7 +18,7 @@ public class TestManyToOneAsOne extends BaseTestCase {
|
||||
|
||||
@Transactional(batchSize = 20)
|
||||
@Test
|
||||
@IgnorePlatform({Platform.SQLSERVER, Platform.ORACLE}) // probably due the use of sequences - Empl has already an ID and Addr refers to it.
|
||||
@IgnorePlatform({Platform.SQLSERVER, Platform.ORACLE, Platform.HANA}) // probably due the use of sequences - Empl has already an ID and Addr refers to it.
|
||||
public void test_when_jdbcBatch() {
|
||||
runInserts();
|
||||
}
|
||||
|
||||
@@ -216,7 +216,12 @@ public class DeleteById_SoftDelete_Tests extends BaseTestCase {
|
||||
|
||||
List<String> sql = LoggedSqlCollector.stop();
|
||||
assertThat(sql).hasSize(2);
|
||||
assertThat(sql.get(0)).contains("update cover set s3url=?, deleted=? where id=?");
|
||||
if (isPersistBatchOnCascade()) {
|
||||
assertThat(sql.get(0)).contains("update cover set s3url=?, deleted=? where id=?");
|
||||
}
|
||||
else {
|
||||
assertThat(sql.get(0)).contains("update cover set deleted=? where id=?");
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -232,7 +237,12 @@ public class DeleteById_SoftDelete_Tests extends BaseTestCase {
|
||||
|
||||
List<String> sql = LoggedSqlCollector.stop();
|
||||
assertThat(sql).hasSize(2);
|
||||
assertThat(sql.get(0)).contains("update cover set s3url=?, deleted=? where id=?");
|
||||
if (isPersistBatchOnCascade()) {
|
||||
assertThat(sql.get(0)).contains("update cover set s3url=?, deleted=? where id=?");
|
||||
}
|
||||
else {
|
||||
assertThat(sql.get(0)).contains("update cover set deleted=? where id=?");
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -254,7 +264,12 @@ public class DeleteById_SoftDelete_Tests extends BaseTestCase {
|
||||
|
||||
List<String> sql = LoggedSqlCollector.stop();
|
||||
assertThat(sql).hasSize(2);
|
||||
assertThat(sql.get(0)).contains("update cover set s3url=?, deleted=? where id=?");
|
||||
if (isPersistBatchOnCascade()) {
|
||||
assertThat(sql.get(0)).contains("update cover set s3url=?, deleted=? where id=?");
|
||||
}
|
||||
else {
|
||||
assertThat(sql.get(0)).contains("update cover set deleted=? where id=?");
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -2,10 +2,13 @@ package org.tests.o2m.jointable;
|
||||
|
||||
import io.ebean.BaseTestCase;
|
||||
import io.ebean.Ebean;
|
||||
import io.ebean.annotation.PersistBatch;
|
||||
|
||||
import org.ebeantest.LoggedSqlCollector;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
@@ -37,8 +40,15 @@ public class TestOneToManyJoinTable extends BaseTestCase {
|
||||
Ebean.save(troop);
|
||||
|
||||
List<String> sql = LoggedSqlCollector.current();
|
||||
assertThat(sql).hasSize(1);
|
||||
assertThat(sql.get(0)).contains("insert into troop_monkey (troop_pid, monkey_mid) values (?, ?)");
|
||||
if (isPersistBatchOnCascade()) {
|
||||
assertThat(sql).hasSize(1);
|
||||
assertThat(sql.get(0)).contains("insert into troop_monkey (troop_pid, monkey_mid) values (?, ?)");
|
||||
}
|
||||
else {
|
||||
assertThat(sql).hasSize(2);
|
||||
assertThat(sql.get(0)).contains("insert into troop_monkey (troop_pid, monkey_mid) values (?, ?)");
|
||||
assertThat(sql.get(1)).contains("insert into troop_monkey (troop_pid, monkey_mid) values (?, ?)");
|
||||
}
|
||||
|
||||
int intersectionRows = Ebean.createSqlQuery("select count(*) as total from troop_monkey where troop_pid = ?")
|
||||
.setParameter(1, troop.getPid())
|
||||
@@ -87,12 +97,23 @@ public class TestOneToManyJoinTable extends BaseTestCase {
|
||||
Ebean.save(trainer);
|
||||
|
||||
List<String> sql = LoggedSqlCollector.current();
|
||||
//Collections.sort(sql);
|
||||
|
||||
assertThat(sql).hasSize(6);
|
||||
assertThat(sql.get(0)).contains("insert into trainer ");
|
||||
assertThat(sql.get(1)).contains("insert into monkey ");
|
||||
assertThat(sql.get(4)).contains("update monkey set name=?, food_preference=?, version=? where mid=? and version=?");
|
||||
assertThat(sql.get(5)).contains("insert into trainer_monkey ");
|
||||
if (isPersistBatchOnCascade()) {
|
||||
assertThat(sql).hasSize(6);
|
||||
assertThat(sql.get(0)).contains("insert into trainer ");
|
||||
assertThat(sql.get(1)).contains("insert into monkey ");
|
||||
assertThat(sql.get(4)).contains("update monkey set name=?, food_preference=?, version=? where mid=? and version=?");
|
||||
assertThat(sql.get(5)).contains("insert into trainer_monkey ");
|
||||
}
|
||||
else {
|
||||
assertThat(sql).hasSize(10);
|
||||
assertThat(sql.get(0)).contains("insert into trainer ");
|
||||
assertThat(sql.get(1)).contains("update monkey set food_preference=?, version=? where mid=? and version=?");
|
||||
assertThat(sql.get(2)).contains("insert into monkey ");
|
||||
assertThat(sql.get(5)).contains("insert into trainer_monkey ");
|
||||
assertThat(sql.get(9)).contains("insert into trainer_monkey ");
|
||||
}
|
||||
|
||||
|
||||
int intersectionRows = Ebean.createSqlQuery("select count(*) as total from trainer_monkey where trainer_tid = ?")
|
||||
|
||||
@@ -37,8 +37,15 @@ public class TestOneToManyJoinTableNoTableName extends BaseTestCase {
|
||||
Ebean.save(troop);
|
||||
|
||||
List<String> sql = LoggedSqlCollector.current();
|
||||
assertThat(sql).hasSize(1);
|
||||
assertThat(sql.get(0)).contains("insert into mkeygroup_monkey (mkeygroup_pid, monkey_mid) values (?, ?)");
|
||||
if (isPersistBatchOnCascade()) {
|
||||
assertThat(sql).hasSize(1);
|
||||
assertThat(sql.get(0)).contains("insert into mkeygroup_monkey (mkeygroup_pid, monkey_mid) values (?, ?)");
|
||||
}
|
||||
else {
|
||||
assertThat(sql).hasSize(2);
|
||||
assertThat(sql.get(0)).contains("insert into mkeygroup_monkey (mkeygroup_pid, monkey_mid) values (?, ?)");
|
||||
assertThat(sql.get(1)).contains("insert into mkeygroup_monkey (mkeygroup_pid, monkey_mid) values (?, ?)");
|
||||
}
|
||||
|
||||
int intersectionRows = Ebean.createSqlQuery("select count(*) as total from mkeygroup_monkey where mkeygroup_pid = ?")
|
||||
.setParameter(1, troop.getPid())
|
||||
|
||||
@@ -1,8 +1,12 @@
|
||||
package org.tests.query.aggregation;
|
||||
|
||||
import io.ebean.BaseTestCase;
|
||||
import io.ebean.Ebean;
|
||||
import io.ebean.Query;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.assertj.core.api.StrictAssertions.assertThat;
|
||||
|
||||
import java.sql.Timestamp;
|
||||
import java.time.Instant;
|
||||
import java.util.List;
|
||||
|
||||
import org.ebeantest.LoggedSqlCollector;
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
@@ -13,11 +17,9 @@ import org.tests.model.basic.ResetBasicData;
|
||||
import org.tests.model.tevent.TEventMany;
|
||||
import org.tests.model.tevent.TEventOne;
|
||||
|
||||
import java.sql.Timestamp;
|
||||
import java.time.Instant;
|
||||
import java.util.List;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import io.ebean.BaseTestCase;
|
||||
import io.ebean.Ebean;
|
||||
import io.ebean.Query;
|
||||
|
||||
public class TestAggregationCount extends BaseTestCase {
|
||||
|
||||
@@ -383,7 +385,7 @@ public class TestAggregationCount extends BaseTestCase {
|
||||
List<String> names =
|
||||
|
||||
Ebean.find(Contact.class)
|
||||
.select("concat(lastName,', ',firstName)")
|
||||
.select(concat("lastName",", ","firstName"))
|
||||
.where().isNull("phone")
|
||||
.orderBy().asc("lastName")
|
||||
.findSingleAttributeList();
|
||||
@@ -391,7 +393,7 @@ public class TestAggregationCount extends BaseTestCase {
|
||||
assertThat(names).isNotEmpty();
|
||||
|
||||
List<String> sql = LoggedSqlCollector.stop();
|
||||
assertThat(trimSql(sql.get(0))).contains("select concat(t0.last_name,', ',t0.first_name) from contact t0 where t0.phone is null order by t0.last_name");
|
||||
assertThat(trimSql(sql.get(0))).contains("select " + concat("t0.last_name",", ","t0.first_name") + " from contact t0 where t0.phone is null order by t0.last_name");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -404,7 +406,7 @@ public class TestAggregationCount extends BaseTestCase {
|
||||
List<String> names =
|
||||
|
||||
Ebean.find(Contact.class)
|
||||
.select("concat(updtime,', ',firstName)")
|
||||
.select(concat("updtime",", ","firstName"))
|
||||
.where().isNull("phone")
|
||||
.orderBy().asc("lastName")
|
||||
.findSingleAttributeList();
|
||||
@@ -412,7 +414,7 @@ public class TestAggregationCount extends BaseTestCase {
|
||||
assertThat(names).isNotEmpty();
|
||||
|
||||
List<String> sql = LoggedSqlCollector.stop();
|
||||
assertThat(trimSql(sql.get(0))).contains("select concat(t0.updtime,', ',t0.first_name) from contact t0");
|
||||
assertThat(trimSql(sql.get(0))).contains("select " + concat("t0.updtime",", ","t0.first_name") + " from contact t0");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -446,7 +448,7 @@ public class TestAggregationCount extends BaseTestCase {
|
||||
List<Contact> contacts =
|
||||
|
||||
Ebean.find(Contact.class)
|
||||
.select("email, concat(lastName,', ',firstName) as lastName")
|
||||
.select("email, " + concat("lastName",", ","firstName") + " as lastName")
|
||||
.where().isNull("phone")
|
||||
.orderBy().asc("lastName")
|
||||
.findList();
|
||||
@@ -459,7 +461,7 @@ public class TestAggregationCount extends BaseTestCase {
|
||||
}
|
||||
|
||||
List<String> sql = LoggedSqlCollector.stop();
|
||||
assertThat(trimSql(sql.get(0))).contains("select t0.id, t0.email, concat(t0.last_name,', ',t0.first_name) lastName from contact t0 where t0.phone is null order by t0.last_name; --bind()");
|
||||
assertThat(trimSql(sql.get(0))).contains("select t0.id, t0.email, " + concat("t0.last_name",", ","t0.first_name") + " lastName from contact t0 where t0.phone is null order by t0.last_name; --bind()");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -4,7 +4,10 @@ import io.ebean.BaseTestCase;
|
||||
import io.ebean.Ebean;
|
||||
import io.ebean.EbeanServer;
|
||||
import io.ebean.Transaction;
|
||||
import io.ebean.annotation.IgnorePlatform;
|
||||
import io.ebean.annotation.PersistBatch;
|
||||
import io.ebean.annotation.Platform;
|
||||
|
||||
import org.tests.model.basic.UTDetail;
|
||||
import org.tests.model.basic.UTMaster;
|
||||
import org.ebeantest.LoggedSqlCollector;
|
||||
@@ -21,6 +24,7 @@ public class TestBatchPersistCascade extends BaseTestCase {
|
||||
Logger logger = LoggerFactory.getLogger(TestBatchPersistCascade.class);
|
||||
|
||||
@Test
|
||||
@IgnorePlatform(Platform.HANA)
|
||||
public void test() {
|
||||
|
||||
EbeanServer ebeanServer = Ebean.getServer(null);
|
||||
|
||||
@@ -20,7 +20,7 @@ public class TestNestedSubTransaction extends BaseTestCase {
|
||||
/**
|
||||
* MySql only supports named savepoints - review.
|
||||
*/
|
||||
@IgnorePlatform({Platform.MYSQL, Platform.SQLSERVER})
|
||||
@IgnorePlatform({Platform.MYSQL, Platform.SQLSERVER, Platform.HANA})
|
||||
@Test
|
||||
public void ebeanServer_commitTransaction_expect_sameAsTransactionCommit() {
|
||||
|
||||
@@ -65,7 +65,7 @@ public class TestNestedSubTransaction extends BaseTestCase {
|
||||
}
|
||||
|
||||
|
||||
@IgnorePlatform({Platform.SQLSERVER, Platform.MYSQL})
|
||||
@IgnorePlatform({Platform.SQLSERVER, Platform.MYSQL, Platform.HANA})
|
||||
@Test
|
||||
public void nestedUseSavepoint_doubleNested_rollbackCommit() {
|
||||
|
||||
@@ -102,7 +102,7 @@ public class TestNestedSubTransaction extends BaseTestCase {
|
||||
}
|
||||
}
|
||||
|
||||
@IgnorePlatform({Platform.SQLSERVER, Platform.MYSQL})
|
||||
@IgnorePlatform({Platform.SQLSERVER, Platform.MYSQL, Platform.HANA})
|
||||
@Test
|
||||
public void nestedUseSavepoint_doubleNested_commitRollback() {
|
||||
|
||||
@@ -139,7 +139,7 @@ public class TestNestedSubTransaction extends BaseTestCase {
|
||||
}
|
||||
}
|
||||
|
||||
@IgnorePlatform({Platform.SQLSERVER, Platform.MYSQL})
|
||||
@IgnorePlatform({Platform.SQLSERVER, Platform.MYSQL, Platform.HANA})
|
||||
@Test
|
||||
public void nestedUseSavepoint_nested_RequiresNew() {
|
||||
|
||||
@@ -175,7 +175,7 @@ public class TestNestedSubTransaction extends BaseTestCase {
|
||||
assertNull(after);
|
||||
}
|
||||
|
||||
@IgnorePlatform({Platform.SQLSERVER, Platform.MYSQL})
|
||||
@IgnorePlatform({Platform.SQLSERVER, Platform.MYSQL, Platform.HANA})
|
||||
@Test
|
||||
public void nestedUseSavepoint() {
|
||||
|
||||
|
||||
Reference in New Issue
Block a user