From 2c8cc793abf98a29529cd3c92d25d1cfd5bc1ac5 Mon Sep 17 00:00:00 2001 From: rob bygrave Date: Tue, 1 Dec 2020 14:29:37 +1300 Subject: [PATCH 001/447] No effective change - tidy test only, TestStatelessUpdate --- .../org/tests/update/TestStatelessUpdate.java | 165 +++++++++++------- 1 file changed, 103 insertions(+), 62 deletions(-) diff --git a/ebean-core/src/test/java/org/tests/update/TestStatelessUpdate.java b/ebean-core/src/test/java/org/tests/update/TestStatelessUpdate.java index 28addd519..931714dc2 100644 --- a/ebean-core/src/test/java/org/tests/update/TestStatelessUpdate.java +++ b/ebean-core/src/test/java/org/tests/update/TestStatelessUpdate.java @@ -1,9 +1,8 @@ package org.tests.update; -import io.ebean.Ebean; -import io.ebean.EbeanServer; +import io.ebean.DB; import io.ebean.TransactionalTestCase; -import org.junit.Assert; +import io.ebeantest.LoggedSql; import org.junit.Test; import org.tests.model.basic.Contact; import org.tests.model.basic.Customer; @@ -20,13 +19,12 @@ import java.util.Set; import static org.assertj.core.api.Assertions.assertThat; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertNull; import static org.junit.Assert.assertTrue; public class TestStatelessUpdate extends TransactionalTestCase { - private EbeanServer server = server(); - @Test public void test() { @@ -35,41 +33,50 @@ public class TestStatelessUpdate extends TransactionalTestCase { e.setStatus(Status.NEW); e.setDescription("wow"); - server.save(e); + DB.save(e); // confirm saved as expected - EBasic eBasic = server.find(EBasic.class, e.getId()); - assertEquals(e.getId(), eBasic.getId()); - assertEquals(e.getName(), eBasic.getName()); - assertEquals(e.getStatus(), eBasic.getStatus()); - assertEquals(e.getDescription(), eBasic.getDescription()); + EBasic original = DB.find(EBasic.class, e.getId()); + assertEquals(e.getId(), original.getId()); + assertEquals(e.getName(), original.getName()); + assertEquals(e.getStatus(), original.getStatus()); + assertEquals(e.getDescription(), original.getDescription()); // test updating just the name - EBasic updateAll = new EBasic(); - updateAll.setId(e.getId()); - updateAll.setName("updAllProps"); + EBasic updateNameOnly = new EBasic(); + updateNameOnly.setId(e.getId()); + updateNameOnly.setName("updateNameOnly"); - server.update(updateAll); + LoggedSql.start(); + DB.update(updateNameOnly); - eBasic = server.find(EBasic.class, e.getId()); - assertEquals(e.getStatus(), eBasic.getStatus()); - assertEquals(e.getDescription(), eBasic.getDescription()); - assertEquals(updateAll.getName(), eBasic.getName()); + List sql = LoggedSql.collect(); + original = DB.find(EBasic.class, e.getId()); + assertEquals(e.getStatus(), original.getStatus()); + assertEquals(e.getDescription(), original.getDescription()); + assertEquals(updateNameOnly.getName(), original.getName()); + assertThat(sql).hasSize(1); + assertThat(sql.get(0)).contains("update e_basic set name=? where id=?; -- bind(updateNameOnly"); + LoggedSql.collect(); // test setting null - EBasic updateDeflt = new EBasic(); - updateDeflt.setId(e.getId()); - updateDeflt.setName("updateDeflt"); - updateDeflt.setDescription(null); - server.update(updateDeflt); + EBasic updateWithNull = new EBasic(); + updateWithNull.setId(e.getId()); + updateWithNull.setName("updateWithNull"); + updateWithNull.setDescription(null); + DB.update(updateWithNull); + + sql = LoggedSql.stop(); // name and description changed (using null) - eBasic = server.find(EBasic.class, e.getId()); - assertEquals(e.getStatus(), eBasic.getStatus()); - assertEquals(updateDeflt.getName(), eBasic.getName()); - assertNull(eBasic.getDescription()); + original = DB.find(EBasic.class, e.getId()); + assertEquals(e.getStatus(), original.getStatus()); + assertEquals(updateWithNull.getName(), original.getName()); + assertNull(original.getDescription()); + assertThat(sql).hasSize(1); + assertThat(sql.get(0)).contains("update e_basic set name=?, description=? where id=?; -- bind(updateWithNull,null,"); } @Test(expected = EntityNotFoundException.class) @@ -80,7 +87,7 @@ public class TestStatelessUpdate extends TransactionalTestCase { basic.setName("something"); basic.setStatus(Status.ACTIVE); - Ebean.update(basic); + DB.update(basic); } @Test @@ -91,7 +98,7 @@ public class TestStatelessUpdate extends TransactionalTestCase { basic.setName("something"); basic.setStatus(Status.ACTIVE); - assertThat(Ebean.delete(basic)).isFalse(); + assertThat(DB.delete(basic)).isFalse(); } /** @@ -106,16 +113,17 @@ public class TestStatelessUpdate extends TransactionalTestCase { basic.setStatus(Status.NEW); basic.setDescription("wow"); - server.save(basic); + DB.save(basic); + LoggedSql.start(); // act EBasic basicWithoutChanges = new EBasic(); basicWithoutChanges.setId(basic.getId()); - server.update(basicWithoutChanges); + DB.update(basicWithoutChanges); - // assert - // Nothing to check, simply no exception should occur - // maybe ensure that no update has been executed + // assert no update executed + final List sql = LoggedSql.stop(); + assertThat(sql).isEmpty(); } /** @@ -135,17 +143,18 @@ public class TestStatelessUpdate extends TransactionalTestCase { Customer customer = new Customer(); customer.setName("something"); - server.save(customer); + DB.save(customer); + LoggedSql.start(); // act Customer customerWithoutChanges = new Customer(); customerWithoutChanges.setId(customer.getId()); - server.update(customerWithoutChanges); + DB.update(customerWithoutChanges); + final List sql = LoggedSql.stop(); - Customer result = Ebean.find(Customer.class, customer.getId()); - - // assert + Customer result = DB.find(Customer.class, customer.getId()); assertThat(result.getUpdtime()).isEqualToIgnoringMillis(customer.getUpdtime()); + assertThat(sql).isEmpty(); } /** @@ -163,7 +172,7 @@ public class TestStatelessUpdate extends TransactionalTestCase { customer.setContacts(new ArrayList<>()); customer.getContacts().add(contact); - server.save(customer); + DB.save(customer); // act Customer customerWithChange = new Customer(); @@ -172,13 +181,17 @@ public class TestStatelessUpdate extends TransactionalTestCase { // contacts is not loaded assertFalse(containsContacts(customerWithChange)); - server.update(customerWithChange); + LoggedSql.start(); + DB.update(customerWithChange); + final List sql = LoggedSql.stop(); - Customer result = Ebean.find(Customer.class, customer.getId()); + Customer result = DB.find(Customer.class, customer.getId()); // assert null list was ignored (missing children not deleted) - Assert.assertNotNull(result.getContacts()); + assertNotNull(result.getContacts()); assertFalse("the contacts mustn't be deleted", result.getContacts().isEmpty()); + assertThat(sql).hasSize(1); + assertThat(sql.get(0)).contains("update o_customer set name=?, updtime=? where id=?;"); } /** @@ -198,7 +211,7 @@ public class TestStatelessUpdate extends TransactionalTestCase { customer.setContacts(new ArrayList<>()); customer.getContacts().add(contact); - server.save(customer); + DB.save(customer); // act Customer customerWithChange = new Customer(); @@ -210,13 +223,17 @@ public class TestStatelessUpdate extends TransactionalTestCase { // contacts has been initialised to empty BeanList assertTrue(containsContacts(customerWithChange)); - server.update(customerWithChange); + LoggedSql.start(); + DB.update(customerWithChange); + final List sql = LoggedSql.stop(); - Customer result = Ebean.find(Customer.class, customer.getId()); + Customer result = DB.find(Customer.class, customer.getId()); // assert empty bean list was ignore (missing children not deleted) - Assert.assertNotNull(result.getContacts()); + assertNotNull(result.getContacts()); assertFalse("the contacts mustn't be deleted", result.getContacts().isEmpty()); + assertThat(sql).hasSize(1); + assertThat(sql.get(0)).contains("update o_customer set name=?, updtime=? where id=?;"); } @Test @@ -231,7 +248,7 @@ public class TestStatelessUpdate extends TransactionalTestCase { customer.setContacts(new ArrayList<>()); customer.getContacts().add(contact); - server.save(customer); + DB.save(customer); // act Customer customerWithChange = new Customer(); @@ -242,16 +259,20 @@ public class TestStatelessUpdate extends TransactionalTestCase { customerWithChange.setContacts(Collections.emptyList()); assertTrue(containsContacts(customerWithChange)); - server.update(customerWithChange); + LoggedSql.start(); + DB.update(customerWithChange); + final List sql = LoggedSql.stop(); - Customer result = Ebean.find(Customer.class, customer.getId()); + Customer result = DB.find(Customer.class, customer.getId()); // assert empty bean list was ignore (missing children not deleted) assertThat(result.getContacts()).hasSize(1); + assertThat(sql).hasSize(1); + assertThat(sql.get(0)).contains("update o_customer set name=?, updtime=? where id=?;"); } private boolean containsContacts(Customer cust) { - return server.getBeanState(cust).getLoadedProps().contains("contacts"); + return DB.getBeanState(cust).getLoadedProps().contains("contacts"); } /** @@ -273,7 +294,7 @@ public class TestStatelessUpdate extends TransactionalTestCase { customer.getContacts().add(contact1); customer.getContacts().add(contact2); - server.save(customer); + DB.save(customer); // act Contact updateContact1 = new Contact(); @@ -287,11 +308,13 @@ public class TestStatelessUpdate extends TransactionalTestCase { updateCustomer.getContacts().add(updateContact1); updateCustomer.getContacts().add(updateContact2); - server.update(updateCustomer); + LoggedSql.start(); + DB.update(updateCustomer); + final List sql = LoggedSql.stop(); // assert - // maybe check if update instead of insert has been executed, - // currently "Unique index or primary key violation" PersistenceException is throwing + assertThat(sql).hasSize(1); + assertThat(sql.get(0)).contains("update o_customer set updtime=? where id=?;"); } @Test @@ -308,7 +331,7 @@ public class TestStatelessUpdate extends TransactionalTestCase { customer.getContacts().add(contact1); customer.getContacts().add(contact2); - server.save(customer); + DB.save(customer); // act @@ -324,10 +347,19 @@ public class TestStatelessUpdate extends TransactionalTestCase { updateCustomer.getContacts().add(updateContact1); updateCustomer.getContacts().add(updateContact3); - server.update(updateCustomer); + LoggedSql.start(); + DB.update(updateCustomer); + final List sql = LoggedSql.stop(); + + assertThat(sql).hasSize(5); + assertThat(sql.get(0)).contains("update o_customer set updtime=? where id=?"); + assertThat(sql.get(1)).contains("insert into contact"); + assertThat(sql.get(2)).contains(" -- bind("); + assertThat(sql.get(3)).contains("update contact set last_name=?, customer_id=? where id=?"); + assertThat(sql.get(4)).contains(" -- bind("); // assert - Customer assCustomer = server.find(Customer.class, customer.getId()); + Customer assCustomer = DB.find(Customer.class, customer.getId()); List assContacts = assCustomer.getContacts(); assertThat(assContacts).hasSize(3); Set ids = new LinkedHashSet<>(); @@ -357,7 +389,7 @@ public class TestStatelessUpdate extends TransactionalTestCase { customer.getContacts().add(contact1); customer.getContacts().add(contact2); - server.save(customer); + DB.save(customer); // act @@ -375,10 +407,19 @@ public class TestStatelessUpdate extends TransactionalTestCase { updateCustomer.getContacts().add(updateContact3); // not adding contact2 but it won't be deleted in this case - server.update(updateCustomer); + LoggedSql.start(); + DB.update(updateCustomer); + final List sql = LoggedSql.stop(); + + assertThat(sql).hasSize(5); + assertThat(sql.get(0)).contains("update o_customer set updtime=? where id=?"); + assertThat(sql.get(1)).contains("insert into contact"); + assertThat(sql.get(2)).contains(" -- bind("); + assertThat(sql.get(3)).contains("update contact set last_name=?, customer_id=? where id=?"); + assertThat(sql.get(4)).contains(" -- bind("); // assert - Customer assCustomer = server.find(Customer.class, customer.getId()); + Customer assCustomer = DB.find(Customer.class, customer.getId()); List assContacts = assCustomer.getContacts(); // contact 2 was not deleted this time From f6c4024ae5e634f476e4b2421f0abb7738498f1e Mon Sep 17 00:00:00 2001 From: rob bygrave Date: Tue, 1 Dec 2020 21:17:19 +1300 Subject: [PATCH 002/447] No effective change - tidy test only, TestStatelessUpdate --- .../org/tests/update/TestStatelessUpdate.java | 18 ++++-------------- 1 file changed, 4 insertions(+), 14 deletions(-) diff --git a/ebean-core/src/test/java/org/tests/update/TestStatelessUpdate.java b/ebean-core/src/test/java/org/tests/update/TestStatelessUpdate.java index 931714dc2..d96de03e4 100644 --- a/ebean-core/src/test/java/org/tests/update/TestStatelessUpdate.java +++ b/ebean-core/src/test/java/org/tests/update/TestStatelessUpdate.java @@ -368,11 +368,8 @@ public class TestStatelessUpdate extends TransactionalTestCase { ids.add(contact.getId()); names.add(contact.getLastName()); } - assertTrue(ids.contains(contact1.getId())); - assertTrue(ids.contains(updateContact3.getId())); - assertTrue(ids.contains(contact2.getId())); - assertTrue(names.contains(updateContact1.getLastName())); - assertTrue(names.contains(updateContact3.getLastName())); + assertThat(ids).contains(contact1.getId(), updateContact3.getId(), contact2.getId()); + assertThat(names).contains(updateContact1.getLastName(), updateContact3.getLastName()); } @Test @@ -391,13 +388,11 @@ public class TestStatelessUpdate extends TransactionalTestCase { DB.save(customer); - // act Contact updateContact1 = new Contact(); updateContact1.setId(contact1.getId()); updateContact1.setLastName("contact1-changed"); - Contact updateContact3 = new Contact(); updateContact3.setLastName("contact3-added"); @@ -431,12 +426,7 @@ public class TestStatelessUpdate extends TransactionalTestCase { ids.add(contact.getId()); names.add(contact.getLastName()); } - assertTrue(ids.contains(contact1.getId())); - assertTrue(ids.contains(updateContact3.getId())); - assertTrue(ids.contains(contact2.getId())); - - assertTrue(names.contains(updateContact1.getLastName())); - assertTrue(names.contains(contact2.getLastName())); - assertTrue(names.contains(updateContact3.getLastName())); + assertThat(ids).contains(contact1.getId(), updateContact3.getId(), contact2.getId()); + assertThat(names).contains(updateContact1.getLastName(), contact2.getLastName(), updateContact3.getLastName()); } } From c66875449b93654a9723336f71f5d434c0e10955 Mon Sep 17 00:00:00 2001 From: Rob Bygrave Date: Tue, 1 Dec 2020 21:31:53 +1300 Subject: [PATCH 003/447] Add Query.withLock(LockType) and withLock(LockType, LockWait) (#2116) Add Query.withLock(LockType) and withLock(LockType, LockWait) --- .../main/java/io/ebean/ExpressionList.java | 28 +++++++++++++ ebean-api/src/main/java/io/ebean/Query.java | 42 ++++++++++++++++--- .../expression/DefaultExpressionList.java | 10 +++++ .../server/expression/JunctionExpression.java | 10 +++++ .../server/query/DefaultFetchGroupQuery.java | 10 +++++ .../server/querydefn/DefaultOrmQuery.java | 10 +++++ .../basic/TestQueryForUpdatePostgresLock.java | 2 +- .../java/io/ebean/typequery/TQRootBean.java | 34 +++++++++++++++ 8 files changed, 139 insertions(+), 7 deletions(-) diff --git a/ebean-api/src/main/java/io/ebean/ExpressionList.java b/ebean-api/src/main/java/io/ebean/ExpressionList.java index 5ac3d7de8..33cf9efcb 100644 --- a/ebean-api/src/main/java/io/ebean/ExpressionList.java +++ b/ebean-api/src/main/java/io/ebean/ExpressionList.java @@ -169,14 +169,38 @@ public interface ExpressionList { */ UpdateQuery asUpdate(); + /** + * Execute the query with the given lock type and WAIT. + *

+ * Note that forUpdate() is the same as + * withLock(LockType.UPDATE). + *

+ * Provides us with the ability to explicitly use Postgres + * SHARE, KEY SHARE, NO KEY UPDATE and UPDATE row locks. + */ + Query withLock(Query.LockType lockType); + + /** + * Execute the query with the given lock type and lock wait. + *

+ * Note that forUpdateNoWait() is the same as + * withLock(LockType.UPDATE, LockWait.NOWAIT). + *

+ * Provides us with the ability to explicitly use Postgres + * SHARE, KEY SHARE, NO KEY UPDATE and UPDATE row locks. + */ + Query withLock(Query.LockType lockType, Query.LockWait lockWait); + /** * Execute using "for update" clause which results in the DB locking the record. */ Query forUpdate(); /** + * Deprecated - migrate to withLock(). * Execute using "for update" with given lock type (currently Postgres only). */ + @Deprecated Query forUpdate(Query.LockType lockType); /** @@ -188,8 +212,10 @@ public interface ExpressionList { Query forUpdateNoWait(); /** + * Deprecated - migrate to withLock(). * Execute using "for update nowait" with given lock type (currently Postgres only). */ + @Deprecated Query forUpdateNoWait(Query.LockType lockType); /** @@ -201,8 +227,10 @@ public interface ExpressionList { Query forUpdateSkipLocked(); /** + * Deprecated - migrate to withLock(). * Execute using "for update skip locked" with given lock type (currently Postgres only). */ + @Deprecated Query forUpdateSkipLocked(Query.LockType lockType); /** diff --git a/ebean-api/src/main/java/io/ebean/Query.java b/ebean-api/src/main/java/io/ebean/Query.java index 200704cfd..ab1c97122 100644 --- a/ebean-api/src/main/java/io/ebean/Query.java +++ b/ebean-api/src/main/java/io/ebean/Query.java @@ -184,7 +184,8 @@ public interface Query { */ enum LockType { /** - * The default lock type - See PlatformConfig.forUpdateNoKey option. + * The default lock type being either UPDATE or NO_KEY_UPDATE based on + * PlatformConfig.forUpdateNoKey configuration (Postgres option). */ DEFAULT, @@ -194,17 +195,17 @@ public interface Query { UPDATE, /** - * FOR NO KEY UPDATE. + * FOR NO KEY UPDATE (Postgres only). */ NO_KEY_UPDATE, /** - * FOR SHARE UPDATE. + * FOR SHARE (Postgres only). */ SHARE, /** - * FOR KEY SHARE UPDATE. + * FOR KEY SHARE (Postgres only). */ KEY_SHARE } @@ -1643,40 +1644,69 @@ public interface Query { */ String getGeneratedSql(); + /** + * Execute the query with the given lock type and WAIT. + *

+ * Note that forUpdate() is the same as + * withLock(LockType.UPDATE). + *

+ * Provides us with the ability to explicitly use Postgres + * SHARE, KEY SHARE, NO KEY UPDATE and UPDATE row locks. + */ + Query withLock(LockType lockType); + + /** + * Execute the query with the given lock type and lock wait. + *

+ * Note that forUpdateNoWait() is the same as + * withLock(LockType.UPDATE, LockWait.NOWAIT). + *

+ * Provides us with the ability to explicitly use Postgres + * SHARE, KEY SHARE, NO KEY UPDATE and UPDATE row locks. + */ + Query withLock(LockType lockType, LockWait lockWait); + /** * Execute using "for update" clause which results in the DB locking the record. + *

+ * The same as withLock(LockType.UPDATE, LockWait.WAIT). */ Query forUpdate(); /** * Execute using "for update" with given lock type (currently Postgres only). */ + @Deprecated Query forUpdate(LockType lockType); /** * Execute using "for update" clause with "no wait" option. *

* This is typically a Postgres and Oracle only option at this stage. - *

+ *

+ * The same as withLock(LockType.UPDATE, LockWait.NOWAIT). */ Query forUpdateNoWait(); /** * Execute using "for update nowait" with given lock type (currently Postgres only). */ + @Deprecated Query forUpdateNoWait(LockType lockType); /** * Execute using "for update" clause with "skip locked" option. *

* This is typically a Postgres and Oracle only option at this stage. - *

+ *

+ * The same as withLock(LockType.UPDATE, LockWait.SKIPLOCKED). */ Query forUpdateSkipLocked(); /** * Execute using "for update skip locked" with given lock type (currently Postgres only). */ + @Deprecated Query forUpdateSkipLocked(LockType lockType); /** diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/expression/DefaultExpressionList.java b/ebean-core/src/main/java/io/ebeaninternal/server/expression/DefaultExpressionList.java index 2cb12ea2a..569fb0868 100644 --- a/ebean-core/src/main/java/io/ebeaninternal/server/expression/DefaultExpressionList.java +++ b/ebean-core/src/main/java/io/ebeaninternal/server/expression/DefaultExpressionList.java @@ -486,6 +486,16 @@ public class DefaultExpressionList implements SpiExpressionList { return query.filterMany(manyProperty).where(expressions, params); } + @Override + public Query withLock(Query.LockType lockType) { + return query.withLock(lockType); + } + + @Override + public Query withLock(Query.LockType lockType, Query.LockWait lockWait) { + return query.withLock(lockType, lockWait); + } + @Override public Query forUpdate() { return query.forUpdate(); diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/expression/JunctionExpression.java b/ebean-core/src/main/java/io/ebeaninternal/server/expression/JunctionExpression.java index 37dab58f9..81548b19a 100644 --- a/ebean-core/src/main/java/io/ebeaninternal/server/expression/JunctionExpression.java +++ b/ebean-core/src/main/java/io/ebeaninternal/server/expression/JunctionExpression.java @@ -491,6 +491,16 @@ class JunctionExpression implements SpiJunction, SpiExpression, Expression return exprList.findOneOrEmpty(); } + @Override + public Query withLock(Query.LockType lockType) { + return exprList.withLock(lockType); + } + + @Override + public Query withLock(Query.LockType lockType, Query.LockWait lockWait) { + return exprList.withLock(lockType, lockWait); + } + @Override public Query forUpdate() { return exprList.forUpdate(); diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/query/DefaultFetchGroupQuery.java b/ebean-core/src/main/java/io/ebeaninternal/server/query/DefaultFetchGroupQuery.java index f0fc5a923..063f2071c 100644 --- a/ebean-core/src/main/java/io/ebeaninternal/server/query/DefaultFetchGroupQuery.java +++ b/ebean-core/src/main/java/io/ebeaninternal/server/query/DefaultFetchGroupQuery.java @@ -544,6 +544,16 @@ class DefaultFetchGroupQuery implements SpiFetchGroupQuery { throw new RuntimeException("EB102: Only select() and fetch() clause is allowed on FetchGroup"); } + @Override + public Query withLock(LockType lockType) { + throw new RuntimeException("EB102: Only select() and fetch() clause is allowed on FetchGroup"); + } + + @Override + public Query withLock(LockType lockType, LockWait lockWait) { + throw new RuntimeException("EB102: Only select() and fetch() clause is allowed on FetchGroup"); + } + @Override public Query forUpdate() { throw new RuntimeException("EB102: Only select() and fetch() clause is allowed on FetchGroup"); diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/querydefn/DefaultOrmQuery.java b/ebean-core/src/main/java/io/ebeaninternal/server/querydefn/DefaultOrmQuery.java index a7cb9bd64..0bb1b3e45 100644 --- a/ebean-core/src/main/java/io/ebeaninternal/server/querydefn/DefaultOrmQuery.java +++ b/ebean-core/src/main/java/io/ebeaninternal/server/querydefn/DefaultOrmQuery.java @@ -963,6 +963,16 @@ public class DefaultOrmQuery implements SpiQuery { return this; } + @Override + public Query withLock(LockType lockType) { + return setForUpdateWithMode(LockWait.WAIT, lockType); + } + + @Override + public Query withLock(LockType lockType, LockWait lockWait) { + return setForUpdateWithMode(lockWait, lockType); + } + @Override public DefaultOrmQuery forUpdate() { return setForUpdateWithMode(LockWait.WAIT, LockType.DEFAULT); diff --git a/ebean-core/src/test/java/org/tests/basic/TestQueryForUpdatePostgresLock.java b/ebean-core/src/test/java/org/tests/basic/TestQueryForUpdatePostgresLock.java index 799850500..ecda6bee2 100644 --- a/ebean-core/src/test/java/org/tests/basic/TestQueryForUpdatePostgresLock.java +++ b/ebean-core/src/test/java/org/tests/basic/TestQueryForUpdatePostgresLock.java @@ -55,7 +55,7 @@ public class TestQueryForUpdatePostgresLock extends BaseTestCase { private void lockArticle(Integer id) { timePreLock = System.currentTimeMillis(); log.info("lock start"); - DB.find(Article.class).setId(id).forUpdate(NO_KEY_UPDATE).findOne(); + DB.find(Article.class).setId(id).withLock(NO_KEY_UPDATE).findOne(); sleep(1000); timePostLock = System.currentTimeMillis(); log.info("lock done"); diff --git a/ebean-querybean/src/main/java/io/ebean/typequery/TQRootBean.java b/ebean-querybean/src/main/java/io/ebean/typequery/TQRootBean.java index 5f0e20185..66858dc10 100644 --- a/ebean-querybean/src/main/java/io/ebean/typequery/TQRootBean.java +++ b/ebean-querybean/src/main/java/io/ebean/typequery/TQRootBean.java @@ -685,6 +685,34 @@ public abstract class TQRootBean { return root; } + /** + * Execute the query with the given lock type and WAIT. + *

+ * Note that forUpdate() is the same as + * withLock(LockType.UPDATE). + *

+ * Provides us with the ability to explicitly use Postgres + * SHARE, KEY SHARE, NO KEY UPDATE and UPDATE row locks. + */ + R withLock(Query.LockType lockType) { + query.withLock(lockType); + return root; + } + + /** + * Execute the query with the given lock type and lock wait. + *

+ * Note that forUpdateNoWait() is the same as + * withLock(LockType.UPDATE, LockWait.NOWAIT). + *

+ * Provides us with the ability to explicitly use Postgres + * SHARE, KEY SHARE, NO KEY UPDATE and UPDATE row locks. + */ + R withLock(Query.LockType lockType, Query.LockWait lockWait) { + query.withLock(lockType, lockWait); + return root; + } + /** * Execute using "for update" clause which results in the DB locking the record. */ @@ -694,8 +722,10 @@ public abstract class TQRootBean { } /** + * Deprecated - migrate to withLock(). * Execute using "for update" with given lock type (currently Postgres only). */ + @Deprecated public R forUpdate(Query.LockType lockType) { query.forUpdate(lockType); return root; @@ -712,8 +742,10 @@ public abstract class TQRootBean { } /** + * Deprecated - migrate to withLock(). * Execute using "for update nowait" with given lock type (currently Postgres only). */ + @Deprecated public R forUpdateNoWait(Query.LockType lockType) { query.forUpdateNoWait(lockType); return root; @@ -731,8 +763,10 @@ public abstract class TQRootBean { } /** + * Deprecated - migrate to withLock(). * Execute using "for update skip locked" with given lock type (currently Postgres only). */ + @Deprecated public R forUpdateSkipLocked(Query.LockType lockType) { query.forUpdateSkipLocked(lockType); return root; From aa1e3ea1bc128c38e710f706f32766d088cf73b6 Mon Sep 17 00:00:00 2001 From: rob bygrave Date: Tue, 1 Dec 2020 22:04:07 +1300 Subject: [PATCH 004/447] #2118 - Generated code for @DbForeignKey reading onDelete and Ignores onUpdate --- .../ddlgeneration/platform/PlatformDdl.java | 2 +- .../platform/PlatformDdl_AlterColumnTest.java | 33 ++++++++++++++++++- 2 files changed, 33 insertions(+), 2 deletions(-) diff --git a/ebean-ddl-generator/src/main/java/io/ebeaninternal/dbmigration/ddlgeneration/platform/PlatformDdl.java b/ebean-ddl-generator/src/main/java/io/ebeaninternal/dbmigration/ddlgeneration/platform/PlatformDdl.java index 340f549be..648cfac83 100644 --- a/ebean-ddl-generator/src/main/java/io/ebeaninternal/dbmigration/ddlgeneration/platform/PlatformDdl.java +++ b/ebean-ddl-generator/src/main/java/io/ebeaninternal/dbmigration/ddlgeneration/platform/PlatformDdl.java @@ -457,7 +457,7 @@ public class PlatformDdl { protected void appendForeignKeySuffix(WriteForeignKey request, StringBuilder buffer) { appendForeignKeyOnDelete(buffer, withDefault(request.onDelete())); - appendForeignKeyOnUpdate(buffer, withDefault(request.onDelete())); + appendForeignKeyOnUpdate(buffer, withDefault(request.onUpdate())); } protected ConstraintMode withDefault(ConstraintMode mode) { diff --git a/ebean-ddl-generator/src/test/java/io/ebeaninternal/dbmigration/ddlgeneration/platform/PlatformDdl_AlterColumnTest.java b/ebean-ddl-generator/src/test/java/io/ebeaninternal/dbmigration/ddlgeneration/platform/PlatformDdl_AlterColumnTest.java index 8546885d0..da85dcd28 100644 --- a/ebean-ddl-generator/src/test/java/io/ebeaninternal/dbmigration/ddlgeneration/platform/PlatformDdl_AlterColumnTest.java +++ b/ebean-ddl-generator/src/test/java/io/ebeaninternal/dbmigration/ddlgeneration/platform/PlatformDdl_AlterColumnTest.java @@ -9,8 +9,9 @@ import io.ebean.config.dbplatform.mysql.MySqlPlatform; import io.ebean.config.dbplatform.oracle.OraclePlatform; import io.ebean.config.dbplatform.postgres.PostgresPlatform; import io.ebean.config.dbplatform.sqlserver.SqlServer17Platform; -import io.ebeaninternal.dbmigration.migration.AlterColumn; import io.ebeaninternal.dbmigration.ddlgeneration.PlatformDdlBuilder; +import io.ebeaninternal.dbmigration.migration.AlterColumn; +import io.ebeaninternal.dbmigration.migration.AlterForeignKey; import org.junit.Test; import static org.assertj.core.api.Assertions.assertThat; @@ -285,4 +286,34 @@ public class PlatformDdl_AlterColumnTest { assertEquals(hanaDdl.useIdentityType(IdType.GENERATOR), IdType.GENERATOR); assertEquals(hanaDdl.useIdentityType(IdType.EXTERNAL), IdType.EXTERNAL); } + + @Test + public void appendForeignKeySuffix_when_defaults() { + assertThat(alterFkey(null, null)).isEqualTo(" on delete restrict on update restrict"); + } + + @Test + public void appendForeignKeySuffix_when_RestrictSetNull() { + assertThat(alterFkey("RESTRICT", "SET_NULL")).isEqualTo(" on delete restrict on update set null"); + } + + @Test + public void appendForeignKeySuffix_when_SetNullRestrict() { + assertThat(alterFkey("SET_NULL", "RESTRICT")).isEqualTo(" on delete set null on update restrict"); + } + + @Test + public void appendForeignKeySuffix_when_SetDefaultCascade() { + assertThat(alterFkey("SET_DEFAULT", "CASCADE")).isEqualTo(" on delete set null on update restrict"); + } + + private String alterFkey(String onDelete, String onUpdate) { + AlterForeignKey afk = new AlterForeignKey(); + afk.setOnDelete(onDelete); + afk.setOnUpdate(onUpdate); + StringBuilder buffer = new StringBuilder(); + h2Ddl.appendForeignKeySuffix(new WriteForeignKey(afk), buffer); + return buffer.toString(); + } + } From 9ab26cfb9d495dc65e0c4483f53c72156f556da3 Mon Sep 17 00:00:00 2001 From: rob bygrave Date: Thu, 3 Dec 2020 09:48:41 +1300 Subject: [PATCH 005/447] #2118 - Fix test only PlatformDdl_AlterColumnTest --- .../ddlgeneration/platform/PlatformDdl_AlterColumnTest.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/ebean-ddl-generator/src/test/java/io/ebeaninternal/dbmigration/ddlgeneration/platform/PlatformDdl_AlterColumnTest.java b/ebean-ddl-generator/src/test/java/io/ebeaninternal/dbmigration/ddlgeneration/platform/PlatformDdl_AlterColumnTest.java index da85dcd28..3a0a8d727 100644 --- a/ebean-ddl-generator/src/test/java/io/ebeaninternal/dbmigration/ddlgeneration/platform/PlatformDdl_AlterColumnTest.java +++ b/ebean-ddl-generator/src/test/java/io/ebeaninternal/dbmigration/ddlgeneration/platform/PlatformDdl_AlterColumnTest.java @@ -1,6 +1,6 @@ package io.ebeaninternal.dbmigration.ddlgeneration.platform; -import io.ebean.Ebean; +import io.ebean.DB; import io.ebean.config.DatabaseConfig; import io.ebean.config.dbplatform.IdType; import io.ebean.config.dbplatform.h2.H2Platform; @@ -29,7 +29,7 @@ public class PlatformDdl_AlterColumnTest { private final PlatformDdl hanaDdl = PlatformDdlBuilder.create(new HanaPlatform()); { - DatabaseConfig serverConfig = Ebean.getDefaultServer().getPluginApi().getServerConfig(); + DatabaseConfig serverConfig = DB.getDefault().getPluginApi().getServerConfig(); sqlServerDdl.configure(serverConfig); } @@ -304,7 +304,7 @@ public class PlatformDdl_AlterColumnTest { @Test public void appendForeignKeySuffix_when_SetDefaultCascade() { - assertThat(alterFkey("SET_DEFAULT", "CASCADE")).isEqualTo(" on delete set null on update restrict"); + assertThat(alterFkey("SET_DEFAULT", "CASCADE")).isEqualTo(" on delete set default on update cascade"); } private String alterFkey(String onDelete, String onUpdate) { From 786444a6b9007fd44d616a8804bb08ed19ebe5db Mon Sep 17 00:00:00 2001 From: Rob Bygrave Date: Thu, 3 Dec 2020 13:16:51 +1300 Subject: [PATCH 006/447] Refactor BackgroundExecutor add submit() methods returning Future (#2121) - Adds submit() methods that return Future - Refactor internals to use DaemonScheduleThreadPool - Delete the now unused DaemonExecutorService - Tidy internals using wrapMDC() methods --- .../java/io/ebean/BackgroundExecutor.java | 44 +++--- .../core/DefaultBackgroundExecutor.java | 129 +++++++++--------- .../server/core/DefaultServer.java | 6 +- .../server/core/bootup/BootupClasses.java | 7 +- .../server/lib/DaemonExecutorService.java | 78 ----------- .../server/lib/DaemonScheduleThreadPool.java | 18 +-- .../server/lib/DaemonThreadFactory.java | 19 +-- .../core/DefaultBackgroundExecutorTest.java | 94 ++++++++++++- .../lib/sql/TestDataSourceMaxWithEntity.java | 67 --------- .../sql/TestShutdownWithBackgroundTasks.java | 57 ++++++++ .../src/test/resources/logback-test.xml | 2 +- 11 files changed, 254 insertions(+), 267 deletions(-) delete mode 100644 ebean-core/src/main/java/io/ebeaninternal/server/lib/DaemonExecutorService.java delete mode 100644 ebean-core/src/test/java/io/ebeaninternal/server/lib/sql/TestDataSourceMaxWithEntity.java create mode 100644 ebean-core/src/test/java/io/ebeaninternal/server/lib/sql/TestShutdownWithBackgroundTasks.java diff --git a/ebean-api/src/main/java/io/ebean/BackgroundExecutor.java b/ebean-api/src/main/java/io/ebean/BackgroundExecutor.java index 9ffa4b62b..94900c249 100644 --- a/ebean-api/src/main/java/io/ebean/BackgroundExecutor.java +++ b/ebean-api/src/main/java/io/ebean/BackgroundExecutor.java @@ -1,31 +1,40 @@ package io.ebean; import java.util.concurrent.Callable; +import java.util.concurrent.Future; import java.util.concurrent.ScheduledExecutorService; import java.util.concurrent.ScheduledFuture; import java.util.concurrent.TimeUnit; /** - * Background thread pool service for executing of tasks asynchronously. + * Background executor service for executing of tasks asynchronously. *

- * This service is used internally by Ebean for executing background tasks such - * as the {@link Query#findFutureList()} and also for executing background tasks - * periodically. - *

+ * This service can be used to execute tasks in the background. *

- * This service has been made available so you can use it for your application - * code if you want. It can be useful for some server caching implementations - * (background population and trimming of the cache etc). - *

- * - * @author rbygrave + * This service is managed by Ebean and will perform a clean shutdown + * waiting for background tasks to complete with a default 30 second + * timeout. Shutdown occurs prior to DataSource shutdown. + *

+ * This also propagates MDC context from the current thread to the + * background task if defined. */ public interface BackgroundExecutor { /** - * Execute a task in the background. + * Execute a callable task in the background returning the Future. */ - void execute(Runnable r); + Future submit(Callable task); + + /** + * Execute a runnable task in the background returning the Future. + */ + Future submit(Runnable task); + + /** + * Execute a task in the background. Effectively the same as + * {@link BackgroundExecutor#submit(Runnable)} but returns void. + */ + void execute(Runnable task); /** * Execute a task periodically with a fixed delay between each execution. @@ -36,12 +45,12 @@ public interface BackgroundExecutor { * That is, this method has the same behaviour characteristics as * {@link ScheduledExecutorService#scheduleWithFixedDelay(Runnable, long, long, TimeUnit)} */ - void executePeriodically(Runnable r, long delay, TimeUnit unit); + void executePeriodically(Runnable task, long delay, TimeUnit unit); /** * Execute a task periodically additionally with an initial delay different from delay. */ - void executePeriodically(Runnable r, long initialDelay, long delay, TimeUnit unit); + void executePeriodically(Runnable task, long initialDelay, long delay, TimeUnit unit); /** * Schedules a Runnable for one-shot action that becomes enabled after the given delay. @@ -49,14 +58,13 @@ public interface BackgroundExecutor { * @return a ScheduledFuture representing pending completion of the task and * whose get() method will return null upon completion */ - ScheduledFuture schedule(Runnable r, long delay, TimeUnit unit); + ScheduledFuture schedule(Runnable task, long delay, TimeUnit unit); /** * Schedules a Callable for one-shot action that becomes enabled after the given delay. * * @return a ScheduledFuture that can be used to extract result or cancel */ - ScheduledFuture schedule(Callable c, long delay, TimeUnit unit); - + ScheduledFuture schedule(Callable task, long delay, TimeUnit unit); } diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/core/DefaultBackgroundExecutor.java b/ebean-core/src/main/java/io/ebeaninternal/server/core/DefaultBackgroundExecutor.java index 89f6aa333..238911959 100644 --- a/ebean-core/src/main/java/io/ebeaninternal/server/core/DefaultBackgroundExecutor.java +++ b/ebean-core/src/main/java/io/ebeaninternal/server/core/DefaultBackgroundExecutor.java @@ -1,12 +1,13 @@ package io.ebeaninternal.server.core; import io.ebeaninternal.api.SpiBackgroundExecutor; -import io.ebeaninternal.server.lib.DaemonExecutorService; import io.ebeaninternal.server.lib.DaemonScheduleThreadPool; import org.slf4j.MDC; import java.util.Map; import java.util.concurrent.Callable; +import java.util.concurrent.Future; +import java.util.concurrent.ScheduledExecutorService; import java.util.concurrent.ScheduledFuture; import java.util.concurrent.TimeUnit; @@ -15,98 +16,94 @@ import java.util.concurrent.TimeUnit; */ public class DefaultBackgroundExecutor implements SpiBackgroundExecutor { - private final DaemonScheduleThreadPool schedulePool; - - private final DaemonExecutorService pool; + private final ScheduledExecutorService executor; /** * Construct the default implementation of BackgroundExecutor. */ public DefaultBackgroundExecutor(int schedulePoolSize, int shutdownWaitSeconds, String namePrefix) { - this.pool = new DaemonExecutorService(shutdownWaitSeconds, namePrefix); - this.schedulePool = new DaemonScheduleThreadPool(schedulePoolSize, shutdownWaitSeconds, namePrefix + "-periodic-"); + this.executor = new DaemonScheduleThreadPool(schedulePoolSize, shutdownWaitSeconds, namePrefix); + } + + /** + * Wrap the task with MDC context if defined. + */ + Callable wrapMDC(Callable task) { + final Map map = MDC.getCopyOfContextMap(); + if (map == null) { + return task; + } else { + return () -> { + MDC.setContextMap(map); + try { + return task.call(); + } finally { + MDC.clear(); + } + }; + } + } + + /** + * Wrap the task with MDC context if defined. + */ + Runnable wrapMDC(Runnable task) { + final Map map = MDC.getCopyOfContextMap(); + if (map == null) { + return task; + } else { + return () -> { + MDC.setContextMap(map); + try { + task.run(); + } finally { + MDC.clear(); + } + }; + } + } + + @Override + public Future submit(Callable task) { + return executor.submit(wrapMDC(task)); } /** * Execute a Runnable using a background thread. */ @Override - public void execute(Runnable r) { - final Map map = MDC.getCopyOfContextMap(); - if (map == null) { - pool.execute(r); - } else { - pool.execute(() -> { - MDC.setContextMap(map); - try { - r.run(); - } finally { - MDC.clear(); - } - }); - } + public Future submit(Runnable task) { + return executor.submit(wrapMDC(task)); } @Override - public void executePeriodically(Runnable r, long delay, TimeUnit unit) { - executePeriodically(r, delay, delay, unit); + public void execute(Runnable task) { + submit(task); } @Override - public void executePeriodically(Runnable r, long initialDelay, long delay, TimeUnit unit) { - final Map map = MDC.getCopyOfContextMap(); - if (map == null) { - schedulePool.scheduleWithFixedDelay(r, initialDelay, delay, unit); - } else { - schedulePool.scheduleWithFixedDelay(() -> { - MDC.setContextMap(map); - try { - r.run(); - } finally { - MDC.clear(); - } - }, initialDelay, delay, unit); - } + public void executePeriodically(Runnable task, long delay, TimeUnit unit) { + executePeriodically(task, delay, delay, unit); } @Override - public ScheduledFuture schedule(Runnable r, long delay, TimeUnit unit) { - final Map map = MDC.getCopyOfContextMap(); - if (map == null) { - return schedulePool.schedule(r, delay, unit); - } else { - return schedulePool.schedule(() -> { - MDC.setContextMap(map); - try { - r.run(); - } finally { - MDC.clear(); - } - }, delay, unit); - } + public void executePeriodically(Runnable task, long initialDelay, long delay, TimeUnit unit) { + executor.scheduleWithFixedDelay(wrapMDC(task), initialDelay, delay, unit); } @Override - public ScheduledFuture schedule(Callable c, long delay, TimeUnit unit) { - final Map map = MDC.getCopyOfContextMap(); - if (map == null) { - return schedulePool.schedule(c, delay, unit); - } else { - return schedulePool.schedule(() -> { - MDC.setContextMap(map); - try { - return c.call(); - } finally { - MDC.clear(); - } - }, delay, unit); - } + public ScheduledFuture schedule(Runnable task, long delay, TimeUnit unit) { + return executor.schedule(wrapMDC(task), delay, unit); + } + + @Override + public ScheduledFuture schedule(Callable task, long delay, TimeUnit unit) { + return executor.schedule(wrapMDC(task), delay, unit); } @Override public void shutdown() { - pool.shutdown(); - schedulePool.shutdown(); + executor.shutdown(); } } diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/core/DefaultServer.java b/ebean-core/src/main/java/io/ebeaninternal/server/core/DefaultServer.java index ae6549457..1b3291d59 100644 --- a/ebean-core/src/main/java/io/ebeaninternal/server/core/DefaultServer.java +++ b/ebean-core/src/main/java/io/ebeaninternal/server/core/DefaultServer.java @@ -451,16 +451,20 @@ public final class DefaultServer implements SpiServer, SpiEbeanServer { backgroundExecutor.shutdown(); // shutdown DataSource (if its an Ebean one) transactionManager.shutdown(shutdownDataSource, deregisterDriver); + dumpMetrics(); shutdown = true; if (shutdownDataSource) { config.setDataSource(null); } } - private void shutdownPlugins() { + private void dumpMetrics() { if (config.isDumpMetricsOnShutdown()) { new DumpMetrics(this, config.getDumpMetricsOptions()).dump(); } + } + + private void shutdownPlugins() { for (Plugin plugin : serverPlugins) { try { plugin.shutdown(); diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/core/bootup/BootupClasses.java b/ebean-core/src/main/java/io/ebeaninternal/server/core/bootup/BootupClasses.java index 6e9326afe..f7c1a5fea 100644 --- a/ebean-core/src/main/java/io/ebeaninternal/server/core/bootup/BootupClasses.java +++ b/ebean-core/src/main/java/io/ebeaninternal/server/core/bootup/BootupClasses.java @@ -223,12 +223,9 @@ public class BootupClasses implements ClassFilter { */ private T create(Class cls, boolean logOnException) { try { - // instantiate via found class - Constructor constructor = cls.getConstructor(); - return constructor.newInstance(); - + return cls.getConstructor().newInstance(); } catch (NoSuchMethodException e) { - logger.debug("Ignore/expected - no default constructor", e); + logger.debug("Ignore/expected - no default constructor: " +e.getMessage()); return null; } catch (Exception e) { diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/lib/DaemonExecutorService.java b/ebean-core/src/main/java/io/ebeaninternal/server/lib/DaemonExecutorService.java deleted file mode 100644 index 48883f87f..000000000 --- a/ebean-core/src/main/java/io/ebeaninternal/server/lib/DaemonExecutorService.java +++ /dev/null @@ -1,78 +0,0 @@ -package io.ebeaninternal.server.lib; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import java.util.concurrent.ExecutorService; -import java.util.concurrent.Executors; -import java.util.concurrent.TimeUnit; -import java.util.concurrent.locks.ReentrantLock; - -/** - * A "CachedThreadPool" based on Daemon threads. - *

- * The Threads are created as needed and once idle live for 60 seconds. - */ -public final class DaemonExecutorService { - - private static final Logger logger = LoggerFactory.getLogger(DaemonExecutorService.class); - - private final ReentrantLock lock = new ReentrantLock(false); - - private final String namePrefix; - - private final int shutdownWaitSeconds; - - private final ExecutorService service; - - /** - * Construct the DaemonThreadPool. - * - * @param shutdownWaitSeconds the time in seconds allowed for the pool to shutdown nicely. After - * this the pool is forced to shutdown. - */ - public DaemonExecutorService(int shutdownWaitSeconds, String namePrefix) { - this.service = Executors.newCachedThreadPool(new DaemonThreadFactory(namePrefix)); - this.shutdownWaitSeconds = shutdownWaitSeconds; - this.namePrefix = namePrefix; - } - - /** - * Execute the Runnable. - */ - public void execute(Runnable runnable) { - service.execute(runnable); - } - - /** - * Shutdown this thread pool nicely if possible. - *

- * This will wait a maximum of 20 seconds before terminating any threads still - * working. - *

- */ - public void shutdown() { - lock.lock(); - try { - if (service.isShutdown()) { - logger.debug("DaemonExecutorService[{}] already shut down", namePrefix); - return; - } - try { - logger.debug("DaemonExecutorService[{}] shutting down...", namePrefix); - service.shutdown(); - if (!service.awaitTermination(shutdownWaitSeconds, TimeUnit.SECONDS)) { - logger.info("DaemonExecutorService[{}] shut down timeout exceeded. Terminating running threads.", namePrefix); - service.shutdownNow(); - } - - } catch (Exception e) { - logger.error("Error during shutdown of DaemonThreadPool[" + namePrefix + "]", e); - e.printStackTrace(); - } - } finally { - lock.unlock(); - } - } - -} diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/lib/DaemonScheduleThreadPool.java b/ebean-core/src/main/java/io/ebeaninternal/server/lib/DaemonScheduleThreadPool.java index f3ee018af..c6636794d 100644 --- a/ebean-core/src/main/java/io/ebeaninternal/server/lib/DaemonScheduleThreadPool.java +++ b/ebean-core/src/main/java/io/ebeaninternal/server/lib/DaemonScheduleThreadPool.java @@ -9,15 +9,12 @@ import java.util.concurrent.locks.ReentrantLock; /** * Daemon based ScheduleThreadPool. - *

- * Uses Daemon threads and hooks into shutdown event. - *

*/ public final class DaemonScheduleThreadPool extends ScheduledThreadPoolExecutor { private static final Logger logger = LoggerFactory.getLogger(DaemonScheduleThreadPool.class); - private final ReentrantLock lock = new ReentrantLock(false); + private final ReentrantLock lock = new ReentrantLock(); private final String namePrefix; @@ -35,26 +32,25 @@ public final class DaemonScheduleThreadPool extends ScheduledThreadPoolExecutor /** * Shutdown this thread pool nicely if possible. *

- * This will wait a maximum of 20 seconds before terminating any threads still - * working. - *

+ * This will wait a maximum of shutdownWaitSeconds seconds before + * terminating any threads still working. */ @Override public void shutdown() { lock.lock(); try { if (super.isShutdown()) { - logger.debug("DaemonScheduleThreadPool {} already shut down", namePrefix); + logger.debug("Already shutdown {}", namePrefix); return; } try { - logger.debug("DaemonScheduleThreadPool {} shutting down...", namePrefix); + logger.trace("Shutting down {} ...", namePrefix); super.shutdown(); if (!super.awaitTermination(shutdownWaitSeconds, TimeUnit.SECONDS)) { - logger.info("DaemonScheduleThreadPool shut down timeout exceeded. Terminating running threads."); + logger.info("Shutdown wait timeout exceeded. Terminating running threads for {}", namePrefix); super.shutdownNow(); } - + logger.debug("Shutdown complete for {}", namePrefix); } catch (Exception e) { logger.error("Error during shutdown of " + namePrefix, e); e.printStackTrace(); diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/lib/DaemonThreadFactory.java b/ebean-core/src/main/java/io/ebeaninternal/server/lib/DaemonThreadFactory.java index 6656c1fdd..4b1c87770 100644 --- a/ebean-core/src/main/java/io/ebeaninternal/server/lib/DaemonThreadFactory.java +++ b/ebean-core/src/main/java/io/ebeaninternal/server/lib/DaemonThreadFactory.java @@ -1,6 +1,5 @@ package io.ebeaninternal.server.lib; - import java.util.concurrent.ThreadFactory; import java.util.concurrent.atomic.AtomicInteger; @@ -9,42 +8,28 @@ import java.util.concurrent.atomic.AtomicInteger; *

* Daemon threads do not stop a JVM stopping. If an application only has Daemon * threads left it will shutdown. - *

*

* In using Daemon threads you need to either not care about being interrupted * on shutdown or register with the JVM shutdown hook to perform a nice shutdown * of the daemon threads etc. - *

- * - * @author rbygrave */ public class DaemonThreadFactory implements ThreadFactory { - private static final AtomicInteger poolNumber = new AtomicInteger(1); - - private final ThreadGroup group; - private final AtomicInteger threadNumber = new AtomicInteger(1); private final String namePrefix; public DaemonThreadFactory(String namePrefix) { - SecurityManager s = System.getSecurityManager(); - this.group = (s != null) ? s.getThreadGroup() : Thread.currentThread().getThreadGroup(); - this.namePrefix = namePrefix != null ? namePrefix : "pool-" + poolNumber.getAndIncrement() + "-thread-"; + this.namePrefix = namePrefix; } @Override public Thread newThread(Runnable r) { - - Thread t = new Thread(group, r, namePrefix + threadNumber.getAndIncrement(), 0); - + Thread t = new Thread(null, r, namePrefix + threadNumber.getAndIncrement(), 0); t.setDaemon(true); - if (t.getPriority() != Thread.NORM_PRIORITY) { t.setPriority(Thread.NORM_PRIORITY); } - return t; } } diff --git a/ebean-core/src/test/java/io/ebeaninternal/server/core/DefaultBackgroundExecutorTest.java b/ebean-core/src/test/java/io/ebeaninternal/server/core/DefaultBackgroundExecutorTest.java index 647d95613..aa8c56598 100644 --- a/ebean-core/src/test/java/io/ebeaninternal/server/core/DefaultBackgroundExecutorTest.java +++ b/ebean-core/src/test/java/io/ebeaninternal/server/core/DefaultBackgroundExecutorTest.java @@ -2,12 +2,64 @@ package io.ebeaninternal.server.core; import org.junit.Ignore; import org.junit.Test; +import org.slf4j.MDC; + +import java.util.concurrent.Future; +import java.util.concurrent.TimeUnit; + +import static org.assertj.core.api.Assertions.assertThat; public class DefaultBackgroundExecutorTest { + @Test + public void submit_callable() throws Exception { + + DefaultBackgroundExecutor es = new DefaultBackgroundExecutor(1, 2, "test"); + + final Future future0 = es.submit(() -> "Hello"); + final Future future1 = es.submit(() -> "There"); + final Future future2 = es.submit(() -> { + try { + Thread.sleep(100); + return "Slow"; + } catch (InterruptedException e) { + e.printStackTrace(); + return "Interrupted"; + } + }); + + es.shutdown(); + + assertThat(future0.get()).isEqualTo("Hello"); + assertThat(future1.get(1, TimeUnit.SECONDS)).isEqualTo("There"); + assertThat(future2.get()).isEqualTo("Slow"); + } + + @Test + public void shutdown_slowCallable_expect_interrupted() throws Exception { + + int shutdownWaitSecs = 1; + DefaultBackgroundExecutor es = new DefaultBackgroundExecutor(1, shutdownWaitSecs, "test"); + + final Future future2 = es.submit(() -> { + try { + Thread.sleep(1500); // longer than shutdown wait + return "Slow"; + } catch (InterruptedException e) { + // expected for this test + Thread.currentThread().interrupt(); + return "Interrupted"; + } + }); + + // shutdown waits max shutdownWaitSecs seconds for active tasks + es.shutdown(); + assertThat(future2.get()).isEqualTo("Interrupted"); + } + @Test @Ignore("test takes long time") - public void shutdown_when_running_expect_waitAndNiceShutdown() throws Exception { + public void shutdown_when_running_expect_waitAndNiceShutdown() { DefaultBackgroundExecutor es = new DefaultBackgroundExecutor(1, 20, "test"); @@ -20,7 +72,7 @@ public class DefaultBackgroundExecutorTest { @Test @Ignore("test takes long time") - public void shutdown_when_rougeRunnable_expect_InterruptedException() throws Exception { + public void shutdown_when_rougeRunnable_expect_InterruptedException() { DefaultBackgroundExecutor es = new DefaultBackgroundExecutor(1, 10, "test"); @@ -31,8 +83,44 @@ public class DefaultBackgroundExecutorTest { es.shutdown(); } + @Test + public void wrapWithNoMDC() { + DefaultBackgroundExecutor es = new DefaultBackgroundExecutor(1, 10, "test"); + assertThat(MDC.getCopyOfContextMap()).isNull(); + es.wrapMDC(() -> { + assertThat(MDC.getCopyOfContextMap()).isNull(); + }); + es.wrapMDC(() -> { + assertThat(MDC.getCopyOfContextMap()).isNull(); + return "Callable"; + }); + es.shutdown(); + } - class RunFor implements Runnable { + @Test + public void wrapWithMDC_expect_() { + DefaultBackgroundExecutor es = new DefaultBackgroundExecutor(1, 10, "test"); + MDC.clear(); + MDC.put("hello", "there"); + es.wrapMDC(() -> { + assertThat(MDC.get("hello")).isEqualTo("there"); + }); + es.wrapMDC(() -> { + assertThat(MDC.get("hello")).isEqualTo("there"); + return "Callable"; + }); + es.execute(() -> { + assertThat(MDC.get("hello")).isEqualTo("there"); + }); + es.submit(() -> { + assertThat(MDC.get("hello")).isEqualTo("there"); + return "Callable"; + }); + MDC.clear(); + es.shutdown(); + } + + private static class RunFor implements Runnable { final long wait; final String id; diff --git a/ebean-core/src/test/java/io/ebeaninternal/server/lib/sql/TestDataSourceMaxWithEntity.java b/ebean-core/src/test/java/io/ebeaninternal/server/lib/sql/TestDataSourceMaxWithEntity.java deleted file mode 100644 index 73d93c6fb..000000000 --- a/ebean-core/src/test/java/io/ebeaninternal/server/lib/sql/TestDataSourceMaxWithEntity.java +++ /dev/null @@ -1,67 +0,0 @@ -package io.ebeaninternal.server.lib.sql; - -import io.ebean.BaseTestCase; -import io.ebean.Ebean; -import io.ebean.EbeanServer; -import io.ebeaninternal.server.core.DefaultBackgroundExecutor; -import org.tests.model.basic.Customer; -import org.junit.Test; - -public class TestDataSourceMaxWithEntity extends BaseTestCase { - - @Test - public void test() { - - boolean skipThisTest = true; - - if (skipThisTest) { - return; - } - - EbeanServer server = Ebean.getServer(null); - - - DefaultBackgroundExecutor bg = new DefaultBackgroundExecutor(1, 30, "testDs"); - - try { - for (int i = 0; i < 12; i++) { - // Thread.sleep(10*i); - bg.execute(new ConnRunner(server, 4000, i)); - } - - Thread.sleep(30000); - - server.shutdown(true, false); - - } catch (Exception e) { - e.printStackTrace(); - } - - } - - private static class ConnRunner implements Runnable { - - final EbeanServer server; - final long sleepMillis; - final int position; - - ConnRunner(EbeanServer server, long sleepMillis, int position) { - this.server = server; - this.sleepMillis = sleepMillis; - this.position = position; - } - - @Override - public void run() { - - server.find(Customer.class).findCount(); - try { - System.out.println(position + " sleep " + sleepMillis); - Thread.sleep(sleepMillis); - System.out.println(position + " sleep done"); - } catch (InterruptedException e) { - e.printStackTrace(); - } - } - } -} diff --git a/ebean-core/src/test/java/io/ebeaninternal/server/lib/sql/TestShutdownWithBackgroundTasks.java b/ebean-core/src/test/java/io/ebeaninternal/server/lib/sql/TestShutdownWithBackgroundTasks.java new file mode 100644 index 000000000..f8846ac62 --- /dev/null +++ b/ebean-core/src/test/java/io/ebeaninternal/server/lib/sql/TestShutdownWithBackgroundTasks.java @@ -0,0 +1,57 @@ +package io.ebeaninternal.server.lib.sql; + +import io.ebean.BackgroundExecutor; +import io.ebean.BaseTestCase; +import io.ebean.DB; +import io.ebean.Database; +import org.junit.Ignore; +import org.junit.Test; +import org.tests.model.basic.Customer; + +public class TestShutdownWithBackgroundTasks extends BaseTestCase { + + @Test + @Ignore + public void test() { + + Database server = DB.getDefault(); + final BackgroundExecutor bg = server.getBackgroundExecutor(); + try { + for (int i = 0; i < 12; i++) { + bg.execute(new Job(server, 500, i)); + } + + Thread.sleep(1000); + server.shutdown(); + + } catch (Exception e) { + e.printStackTrace(); + } + } + + private static class Job implements Runnable { + + final Database server; + final long sleepMillis; + final int position; + + Job(Database server, long sleepMillis, int position) { + this.server = server; + this.sleepMillis = sleepMillis; + this.position = position; + } + + @Override + public void run() { + try { + System.out.println(position + " sleep " + sleepMillis); + Thread.sleep(sleepMillis); + server.find(Customer.class).findCount(); + System.out.println(position + " sleep done"); + } catch (InterruptedException e) { + Thread.currentThread().interrupt(); + e.printStackTrace(); + } + } + } +} diff --git a/ebean-core/src/test/resources/logback-test.xml b/ebean-core/src/test/resources/logback-test.xml index 97cbf1ec9..1b8a60a9b 100644 --- a/ebean-core/src/test/resources/logback-test.xml +++ b/ebean-core/src/test/resources/logback-test.xml @@ -92,7 +92,7 @@ - + From 046033627a7cd67abdf244de4a2d774287116333 Mon Sep 17 00:00:00 2001 From: rob bygrave Date: Thu, 3 Dec 2020 13:22:13 +1300 Subject: [PATCH 007/447] Update tests - generated sql for add constraint foreign key --- .../resources/dbmigration/migrationtest/h2/1.0__initial.sql | 4 ++-- .../src/test/resources/dbmigration/migrationtest/h2/1.3.sql | 4 ++-- .../resources/dbmigration/migrationtest/hana/1.0__initial.sql | 4 ++-- .../src/test/resources/dbmigration/migrationtest/hana/1.3.sql | 4 ++-- .../dbmigration/migrationtest/hsqldb/1.0__initial.sql | 4 ++-- .../test/resources/dbmigration/migrationtest/hsqldb/1.3.sql | 4 ++-- .../dbmigration/migrationtest/mysql/1.0__initial.sql | 4 ++-- .../test/resources/dbmigration/migrationtest/mysql/1.3.sql | 4 ++-- .../dbmigration/migrationtest/mysql55/1.0__initial.sql | 4 ++-- .../test/resources/dbmigration/migrationtest/mysql55/1.3.sql | 4 ++-- .../dbmigration/migrationtest/postgres/1.0__initial.sql | 4 ++-- .../test/resources/dbmigration/migrationtest/postgres/1.3.sql | 4 ++-- .../dbmigration/migrationtest/sqlite/1.0__initial.sql | 4 ++-- .../dbmigration/migrationtest/sqlserver17/1.0__initial.sql | 4 ++-- .../resources/dbmigration/migrationtest/sqlserver17/1.3.sql | 4 ++-- 15 files changed, 30 insertions(+), 30 deletions(-) diff --git a/ebean-ddl-generator/src/test/resources/dbmigration/migrationtest/h2/1.0__initial.sql b/ebean-ddl-generator/src/test/resources/dbmigration/migrationtest/h2/1.0__initial.sql index 37db6d4b2..1e2a4095f 100644 --- a/ebean-ddl-generator/src/test/resources/dbmigration/migrationtest/h2/1.0__initial.sql +++ b/ebean-ddl-generator/src/test/resources/dbmigration/migrationtest/h2/1.0__initial.sql @@ -164,10 +164,10 @@ create table migtest_oto_master ( create index ix_migtest_e_basic_indextest1 on migtest_e_basic (indextest1); create index ix_migtest_e_basic_indextest5 on migtest_e_basic (indextest5); create index ix_migtest_fk_cascade_one_id on migtest_fk_cascade (one_id); -alter table migtest_fk_cascade add constraint fk_migtest_fk_cascade_one_id foreign key (one_id) references migtest_fk_cascade_one (id) on delete cascade on update cascade; +alter table migtest_fk_cascade add constraint fk_migtest_fk_cascade_one_id foreign key (one_id) references migtest_fk_cascade_one (id) on delete cascade on update restrict; create index ix_migtest_fk_set_null_one_id on migtest_fk_set_null (one_id); -alter table migtest_fk_set_null add constraint fk_migtest_fk_set_null_one_id foreign key (one_id) references migtest_fk_one (id) on delete set null on update set null; +alter table migtest_fk_set_null add constraint fk_migtest_fk_set_null_one_id foreign key (one_id) references migtest_fk_one (id) on delete set null on update restrict; create index ix_migtest_e_basic_eref_id on migtest_e_basic (eref_id); alter table migtest_e_basic add constraint fk_migtest_e_basic_eref_id foreign key (eref_id) references migtest_e_ref (id) on delete restrict on update restrict; diff --git a/ebean-ddl-generator/src/test/resources/dbmigration/migrationtest/h2/1.3.sql b/ebean-ddl-generator/src/test/resources/dbmigration/migrationtest/h2/1.3.sql index 79645fc49..a1d6ccad1 100644 --- a/ebean-ddl-generator/src/test/resources/dbmigration/migrationtest/h2/1.3.sql +++ b/ebean-ddl-generator/src/test/resources/dbmigration/migrationtest/h2/1.3.sql @@ -14,11 +14,11 @@ create table migtest_e_ref ( alter table migtest_ckey_detail drop constraint if exists fk_migtest_ckey_detail_parent; alter table migtest_fk_cascade drop constraint if exists fk_migtest_fk_cascade_one_id; -alter table migtest_fk_cascade add constraint fk_migtest_fk_cascade_one_id foreign key (one_id) references migtest_fk_cascade_one (id) on delete cascade on update cascade; +alter table migtest_fk_cascade add constraint fk_migtest_fk_cascade_one_id foreign key (one_id) references migtest_fk_cascade_one (id) on delete cascade on update restrict; alter table migtest_fk_none drop constraint if exists fk_migtest_fk_none_one_id; alter table migtest_fk_none_via_join drop constraint if exists fk_migtest_fk_none_via_join_one_id; alter table migtest_fk_set_null drop constraint if exists fk_migtest_fk_set_null_one_id; -alter table migtest_fk_set_null add constraint fk_migtest_fk_set_null_one_id foreign key (one_id) references migtest_fk_one (id) on delete set null on update set null; +alter table migtest_fk_set_null add constraint fk_migtest_fk_set_null_one_id foreign key (one_id) references migtest_fk_one (id) on delete set null on update restrict; alter table migtest_e_basic drop constraint if exists ck_migtest_e_basic_status; alter table migtest_e_basic alter column status drop default; alter table migtest_e_basic alter column status set null; diff --git a/ebean-ddl-generator/src/test/resources/dbmigration/migrationtest/hana/1.0__initial.sql b/ebean-ddl-generator/src/test/resources/dbmigration/migrationtest/hana/1.0__initial.sql index 17e451bad..837424e6d 100644 --- a/ebean-ddl-generator/src/test/resources/dbmigration/migrationtest/hana/1.0__initial.sql +++ b/ebean-ddl-generator/src/test/resources/dbmigration/migrationtest/hana/1.0__initial.sql @@ -164,10 +164,10 @@ create column table migtest_oto_master ( -- explicit index "ix_migtest_e_basic_indextest1" for single column "indextest1" of table "migtest_e_basic" is not necessary; -- explicit index "ix_migtest_e_basic_indextest5" for single column "indextest5" of table "migtest_e_basic" is not necessary; -- explicit index "ix_migtest_fk_cascade_one_id" for single column "one_id" of table "migtest_fk_cascade" is not necessary; -alter table migtest_fk_cascade add constraint fk_migtest_fk_cascade_one_id foreign key (one_id) references migtest_fk_cascade_one (id) on delete cascade on update cascade; +alter table migtest_fk_cascade add constraint fk_migtest_fk_cascade_one_id foreign key (one_id) references migtest_fk_cascade_one (id) on delete cascade on update restrict; -- explicit index "ix_migtest_fk_set_null_one_id" for single column "one_id" of table "migtest_fk_set_null" is not necessary; -alter table migtest_fk_set_null add constraint fk_migtest_fk_set_null_one_id foreign key (one_id) references migtest_fk_one (id) on delete set null on update set null; +alter table migtest_fk_set_null add constraint fk_migtest_fk_set_null_one_id foreign key (one_id) references migtest_fk_one (id) on delete set null on update restrict; -- explicit index "ix_migtest_e_basic_eref_id" for single column "eref_id" of table "migtest_e_basic" is not necessary; alter table migtest_e_basic add constraint fk_migtest_e_basic_eref_id foreign key (eref_id) references migtest_e_ref (id) on delete restrict on update restrict; diff --git a/ebean-ddl-generator/src/test/resources/dbmigration/migrationtest/hana/1.3.sql b/ebean-ddl-generator/src/test/resources/dbmigration/migrationtest/hana/1.3.sql index 8c8aa59fc..9e3ba6f9f 100644 --- a/ebean-ddl-generator/src/test/resources/dbmigration/migrationtest/hana/1.3.sql +++ b/ebean-ddl-generator/src/test/resources/dbmigration/migrationtest/hana/1.3.sql @@ -9,11 +9,11 @@ create column table migtest_e_ref ( alter table migtest_ckey_detail drop constraint fk_migtest_ckey_detail_parent; alter table migtest_fk_cascade drop constraint fk_migtest_fk_cascade_one_id; -alter table migtest_fk_cascade add constraint fk_migtest_fk_cascade_one_id foreign key (one_id) references migtest_fk_cascade_one (id) on delete cascade on update cascade; +alter table migtest_fk_cascade add constraint fk_migtest_fk_cascade_one_id foreign key (one_id) references migtest_fk_cascade_one (id) on delete cascade on update restrict; alter table migtest_fk_none drop constraint fk_migtest_fk_none_one_id; alter table migtest_fk_none_via_join drop constraint fk_migtest_fk_none_via_join_one_id; alter table migtest_fk_set_null drop constraint fk_migtest_fk_set_null_one_id; -alter table migtest_fk_set_null add constraint fk_migtest_fk_set_null_one_id foreign key (one_id) references migtest_fk_one (id) on delete set null on update set null; +alter table migtest_fk_set_null add constraint fk_migtest_fk_set_null_one_id foreign key (one_id) references migtest_fk_one (id) on delete set null on update restrict; delimiter $$ do begin diff --git a/ebean-ddl-generator/src/test/resources/dbmigration/migrationtest/hsqldb/1.0__initial.sql b/ebean-ddl-generator/src/test/resources/dbmigration/migrationtest/hsqldb/1.0__initial.sql index b4d627c18..40616be0a 100644 --- a/ebean-ddl-generator/src/test/resources/dbmigration/migrationtest/hsqldb/1.0__initial.sql +++ b/ebean-ddl-generator/src/test/resources/dbmigration/migrationtest/hsqldb/1.0__initial.sql @@ -164,10 +164,10 @@ create table migtest_oto_master ( create index ix_migtest_e_basic_indextest1 on migtest_e_basic (indextest1); create index ix_migtest_e_basic_indextest5 on migtest_e_basic (indextest5); create index ix_migtest_fk_cascade_one_id on migtest_fk_cascade (one_id); -alter table migtest_fk_cascade add constraint fk_migtest_fk_cascade_one_id foreign key (one_id) references migtest_fk_cascade_one (id) on delete cascade on update cascade; +alter table migtest_fk_cascade add constraint fk_migtest_fk_cascade_one_id foreign key (one_id) references migtest_fk_cascade_one (id) on delete cascade on update restrict; create index ix_migtest_fk_set_null_one_id on migtest_fk_set_null (one_id); -alter table migtest_fk_set_null add constraint fk_migtest_fk_set_null_one_id foreign key (one_id) references migtest_fk_one (id) on delete set null on update set null; +alter table migtest_fk_set_null add constraint fk_migtest_fk_set_null_one_id foreign key (one_id) references migtest_fk_one (id) on delete set null on update restrict; create index ix_migtest_e_basic_eref_id on migtest_e_basic (eref_id); alter table migtest_e_basic add constraint fk_migtest_e_basic_eref_id foreign key (eref_id) references migtest_e_ref (id) on delete restrict on update restrict; diff --git a/ebean-ddl-generator/src/test/resources/dbmigration/migrationtest/hsqldb/1.3.sql b/ebean-ddl-generator/src/test/resources/dbmigration/migrationtest/hsqldb/1.3.sql index ed3b50536..f7f307719 100644 --- a/ebean-ddl-generator/src/test/resources/dbmigration/migrationtest/hsqldb/1.3.sql +++ b/ebean-ddl-generator/src/test/resources/dbmigration/migrationtest/hsqldb/1.3.sql @@ -9,11 +9,11 @@ create table migtest_e_ref ( alter table migtest_ckey_detail drop constraint if exists fk_migtest_ckey_detail_parent; alter table migtest_fk_cascade drop constraint if exists fk_migtest_fk_cascade_one_id; -alter table migtest_fk_cascade add constraint fk_migtest_fk_cascade_one_id foreign key (one_id) references migtest_fk_cascade_one (id) on delete cascade on update cascade; +alter table migtest_fk_cascade add constraint fk_migtest_fk_cascade_one_id foreign key (one_id) references migtest_fk_cascade_one (id) on delete cascade on update restrict; alter table migtest_fk_none drop constraint if exists fk_migtest_fk_none_one_id; alter table migtest_fk_none_via_join drop constraint if exists fk_migtest_fk_none_via_join_one_id; alter table migtest_fk_set_null drop constraint if exists fk_migtest_fk_set_null_one_id; -alter table migtest_fk_set_null add constraint fk_migtest_fk_set_null_one_id foreign key (one_id) references migtest_fk_one (id) on delete set null on update set null; +alter table migtest_fk_set_null add constraint fk_migtest_fk_set_null_one_id foreign key (one_id) references migtest_fk_one (id) on delete set null on update restrict; alter table migtest_e_basic drop constraint if exists ck_migtest_e_basic_status; alter table migtest_e_basic alter column status drop default; alter table migtest_e_basic alter column status set null; diff --git a/ebean-ddl-generator/src/test/resources/dbmigration/migrationtest/mysql/1.0__initial.sql b/ebean-ddl-generator/src/test/resources/dbmigration/migrationtest/mysql/1.0__initial.sql index 0267c1545..ce464c473 100644 --- a/ebean-ddl-generator/src/test/resources/dbmigration/migrationtest/mysql/1.0__initial.sql +++ b/ebean-ddl-generator/src/test/resources/dbmigration/migrationtest/mysql/1.0__initial.sql @@ -161,10 +161,10 @@ create table migtest_oto_master ( create index ix_migtest_e_basic_indextest1 on migtest_e_basic (indextest1); create index ix_migtest_e_basic_indextest5 on migtest_e_basic (indextest5); create index ix_migtest_fk_cascade_one_id on migtest_fk_cascade (one_id); -alter table migtest_fk_cascade add constraint fk_migtest_fk_cascade_one_id foreign key (one_id) references migtest_fk_cascade_one (id) on delete cascade on update cascade; +alter table migtest_fk_cascade add constraint fk_migtest_fk_cascade_one_id foreign key (one_id) references migtest_fk_cascade_one (id) on delete cascade on update restrict; create index ix_migtest_fk_set_null_one_id on migtest_fk_set_null (one_id); -alter table migtest_fk_set_null add constraint fk_migtest_fk_set_null_one_id foreign key (one_id) references migtest_fk_one (id) on delete set null on update set null; +alter table migtest_fk_set_null add constraint fk_migtest_fk_set_null_one_id foreign key (one_id) references migtest_fk_one (id) on delete set null on update restrict; create index ix_migtest_e_basic_eref_id on migtest_e_basic (eref_id); alter table migtest_e_basic add constraint fk_migtest_e_basic_eref_id foreign key (eref_id) references migtest_e_ref (id) on delete restrict on update restrict; diff --git a/ebean-ddl-generator/src/test/resources/dbmigration/migrationtest/mysql/1.3.sql b/ebean-ddl-generator/src/test/resources/dbmigration/migrationtest/mysql/1.3.sql index 593f0f3c0..6953c06f5 100644 --- a/ebean-ddl-generator/src/test/resources/dbmigration/migrationtest/mysql/1.3.sql +++ b/ebean-ddl-generator/src/test/resources/dbmigration/migrationtest/mysql/1.3.sql @@ -14,11 +14,11 @@ create table migtest_e_ref ( alter table migtest_ckey_detail drop foreign key fk_migtest_ckey_detail_parent; alter table migtest_fk_cascade drop foreign key fk_migtest_fk_cascade_one_id; -alter table migtest_fk_cascade add constraint fk_migtest_fk_cascade_one_id foreign key (one_id) references migtest_fk_cascade_one (id) on delete cascade on update cascade; +alter table migtest_fk_cascade add constraint fk_migtest_fk_cascade_one_id foreign key (one_id) references migtest_fk_cascade_one (id) on delete cascade on update restrict; alter table migtest_fk_none drop foreign key fk_migtest_fk_none_one_id; alter table migtest_fk_none_via_join drop foreign key fk_migtest_fk_none_via_join_one_id; alter table migtest_fk_set_null drop foreign key fk_migtest_fk_set_null_one_id; -alter table migtest_fk_set_null add constraint fk_migtest_fk_set_null_one_id foreign key (one_id) references migtest_fk_one (id) on delete set null on update set null; +alter table migtest_fk_set_null add constraint fk_migtest_fk_set_null_one_id foreign key (one_id) references migtest_fk_one (id) on delete set null on update restrict; alter table migtest_e_basic alter status drop default; alter table migtest_e_basic modify status varchar(1); diff --git a/ebean-ddl-generator/src/test/resources/dbmigration/migrationtest/mysql55/1.0__initial.sql b/ebean-ddl-generator/src/test/resources/dbmigration/migrationtest/mysql55/1.0__initial.sql index aba5c29eb..0a76ab174 100644 --- a/ebean-ddl-generator/src/test/resources/dbmigration/migrationtest/mysql55/1.0__initial.sql +++ b/ebean-ddl-generator/src/test/resources/dbmigration/migrationtest/mysql55/1.0__initial.sql @@ -161,10 +161,10 @@ create table migtest_oto_master ( create index ix_migtest_e_basic_indextest1 on migtest_e_basic (indextest1); create index ix_migtest_e_basic_indextest5 on migtest_e_basic (indextest5); create index ix_migtest_fk_cascade_one_id on migtest_fk_cascade (one_id); -alter table migtest_fk_cascade add constraint fk_migtest_fk_cascade_one_id foreign key (one_id) references migtest_fk_cascade_one (id) on delete cascade on update cascade; +alter table migtest_fk_cascade add constraint fk_migtest_fk_cascade_one_id foreign key (one_id) references migtest_fk_cascade_one (id) on delete cascade on update restrict; create index ix_migtest_fk_set_null_one_id on migtest_fk_set_null (one_id); -alter table migtest_fk_set_null add constraint fk_migtest_fk_set_null_one_id foreign key (one_id) references migtest_fk_one (id) on delete set null on update set null; +alter table migtest_fk_set_null add constraint fk_migtest_fk_set_null_one_id foreign key (one_id) references migtest_fk_one (id) on delete set null on update restrict; create index ix_migtest_e_basic_eref_id on migtest_e_basic (eref_id); alter table migtest_e_basic add constraint fk_migtest_e_basic_eref_id foreign key (eref_id) references migtest_e_ref (id) on delete restrict on update restrict; diff --git a/ebean-ddl-generator/src/test/resources/dbmigration/migrationtest/mysql55/1.3.sql b/ebean-ddl-generator/src/test/resources/dbmigration/migrationtest/mysql55/1.3.sql index 593f0f3c0..6953c06f5 100644 --- a/ebean-ddl-generator/src/test/resources/dbmigration/migrationtest/mysql55/1.3.sql +++ b/ebean-ddl-generator/src/test/resources/dbmigration/migrationtest/mysql55/1.3.sql @@ -14,11 +14,11 @@ create table migtest_e_ref ( alter table migtest_ckey_detail drop foreign key fk_migtest_ckey_detail_parent; alter table migtest_fk_cascade drop foreign key fk_migtest_fk_cascade_one_id; -alter table migtest_fk_cascade add constraint fk_migtest_fk_cascade_one_id foreign key (one_id) references migtest_fk_cascade_one (id) on delete cascade on update cascade; +alter table migtest_fk_cascade add constraint fk_migtest_fk_cascade_one_id foreign key (one_id) references migtest_fk_cascade_one (id) on delete cascade on update restrict; alter table migtest_fk_none drop foreign key fk_migtest_fk_none_one_id; alter table migtest_fk_none_via_join drop foreign key fk_migtest_fk_none_via_join_one_id; alter table migtest_fk_set_null drop foreign key fk_migtest_fk_set_null_one_id; -alter table migtest_fk_set_null add constraint fk_migtest_fk_set_null_one_id foreign key (one_id) references migtest_fk_one (id) on delete set null on update set null; +alter table migtest_fk_set_null add constraint fk_migtest_fk_set_null_one_id foreign key (one_id) references migtest_fk_one (id) on delete set null on update restrict; alter table migtest_e_basic alter status drop default; alter table migtest_e_basic modify status varchar(1); diff --git a/ebean-ddl-generator/src/test/resources/dbmigration/migrationtest/postgres/1.0__initial.sql b/ebean-ddl-generator/src/test/resources/dbmigration/migrationtest/postgres/1.0__initial.sql index bc920ec22..5229ed032 100644 --- a/ebean-ddl-generator/src/test/resources/dbmigration/migrationtest/postgres/1.0__initial.sql +++ b/ebean-ddl-generator/src/test/resources/dbmigration/migrationtest/postgres/1.0__initial.sql @@ -167,10 +167,10 @@ create index idxd_migtest_0 on migtest_oto_child using hash (upper(name)) where create index concurrently ix_migtest_oto_child_lowername_id on migtest_oto_child (lower(name),id); create index ix_migtest_oto_child_lowername on migtest_oto_child (lower(name)); create index ix_migtest_fk_cascade_one_id on migtest_fk_cascade (one_id); -alter table migtest_fk_cascade add constraint fk_migtest_fk_cascade_one_id foreign key (one_id) references migtest_fk_cascade_one (id) on delete cascade on update cascade; +alter table migtest_fk_cascade add constraint fk_migtest_fk_cascade_one_id foreign key (one_id) references migtest_fk_cascade_one (id) on delete cascade on update restrict; create index ix_migtest_fk_set_null_one_id on migtest_fk_set_null (one_id); -alter table migtest_fk_set_null add constraint fk_migtest_fk_set_null_one_id foreign key (one_id) references migtest_fk_one (id) on delete set null on update set null; +alter table migtest_fk_set_null add constraint fk_migtest_fk_set_null_one_id foreign key (one_id) references migtest_fk_one (id) on delete set null on update restrict; create index ix_migtest_e_basic_eref_id on migtest_e_basic (eref_id); alter table migtest_e_basic add constraint fk_migtest_e_basic_eref_id foreign key (eref_id) references migtest_e_ref (id) on delete restrict on update restrict; diff --git a/ebean-ddl-generator/src/test/resources/dbmigration/migrationtest/postgres/1.3.sql b/ebean-ddl-generator/src/test/resources/dbmigration/migrationtest/postgres/1.3.sql index 1be77e36d..a57b95ae2 100644 --- a/ebean-ddl-generator/src/test/resources/dbmigration/migrationtest/postgres/1.3.sql +++ b/ebean-ddl-generator/src/test/resources/dbmigration/migrationtest/postgres/1.3.sql @@ -14,11 +14,11 @@ create table migtest_e_ref ( alter table if exists migtest_ckey_detail drop constraint if exists fk_migtest_ckey_detail_parent; alter table if exists migtest_fk_cascade drop constraint if exists fk_migtest_fk_cascade_one_id; -alter table migtest_fk_cascade add constraint fk_migtest_fk_cascade_one_id foreign key (one_id) references migtest_fk_cascade_one (id) on delete cascade on update cascade; +alter table migtest_fk_cascade add constraint fk_migtest_fk_cascade_one_id foreign key (one_id) references migtest_fk_cascade_one (id) on delete cascade on update restrict; alter table if exists migtest_fk_none drop constraint if exists fk_migtest_fk_none_one_id; alter table if exists migtest_fk_none_via_join drop constraint if exists fk_migtest_fk_none_via_join_one_id; alter table if exists migtest_fk_set_null drop constraint if exists fk_migtest_fk_set_null_one_id; -alter table migtest_fk_set_null add constraint fk_migtest_fk_set_null_one_id foreign key (one_id) references migtest_fk_one (id) on delete set null on update set null; +alter table migtest_fk_set_null add constraint fk_migtest_fk_set_null_one_id foreign key (one_id) references migtest_fk_one (id) on delete set null on update restrict; alter table migtest_e_basic drop constraint if exists ck_migtest_e_basic_status; alter table migtest_e_basic alter column status drop default; alter table migtest_e_basic alter column status drop not null; diff --git a/ebean-ddl-generator/src/test/resources/dbmigration/migrationtest/sqlite/1.0__initial.sql b/ebean-ddl-generator/src/test/resources/dbmigration/migrationtest/sqlite/1.0__initial.sql index 565b49c14..1a4944f30 100644 --- a/ebean-ddl-generator/src/test/resources/dbmigration/migrationtest/sqlite/1.0__initial.sql +++ b/ebean-ddl-generator/src/test/resources/dbmigration/migrationtest/sqlite/1.0__initial.sql @@ -24,7 +24,7 @@ create table migtest_fk_cascade ( id integer not null, one_id integer, constraint pk_migtest_fk_cascade primary key (id), - foreign key (one_id) references migtest_fk_cascade_one (id) on delete cascade on update cascade + foreign key (one_id) references migtest_fk_cascade_one (id) on delete cascade on update restrict ); create table migtest_fk_cascade_one ( @@ -53,7 +53,7 @@ create table migtest_fk_set_null ( id integer not null, one_id integer, constraint pk_migtest_fk_set_null primary key (id), - foreign key (one_id) references migtest_fk_one (id) on delete set null on update set null + foreign key (one_id) references migtest_fk_one (id) on delete set null on update restrict ); create table migtest_e_basic ( diff --git a/ebean-ddl-generator/src/test/resources/dbmigration/migrationtest/sqlserver17/1.0__initial.sql b/ebean-ddl-generator/src/test/resources/dbmigration/migrationtest/sqlserver17/1.0__initial.sql index af322b975..13b5da203 100644 --- a/ebean-ddl-generator/src/test/resources/dbmigration/migrationtest/sqlserver17/1.0__initial.sql +++ b/ebean-ddl-generator/src/test/resources/dbmigration/migrationtest/sqlserver17/1.0__initial.sql @@ -186,10 +186,10 @@ create sequence migtest_oto_master_seq as bigint start with 1; create index ix_migtest_e_basic_indextest1 on migtest_e_basic (indextest1); create index ix_migtest_e_basic_indextest5 on migtest_e_basic (indextest5); create index ix_migtest_fk_cascade_one_id on migtest_fk_cascade (one_id); -alter table migtest_fk_cascade add constraint fk_migtest_fk_cascade_one_id foreign key (one_id) references migtest_fk_cascade_one (id) on delete cascade on update cascade; +alter table migtest_fk_cascade add constraint fk_migtest_fk_cascade_one_id foreign key (one_id) references migtest_fk_cascade_one (id) on delete cascade; create index ix_migtest_fk_set_null_one_id on migtest_fk_set_null (one_id); -alter table migtest_fk_set_null add constraint fk_migtest_fk_set_null_one_id foreign key (one_id) references migtest_fk_one (id) on delete set null on update set null; +alter table migtest_fk_set_null add constraint fk_migtest_fk_set_null_one_id foreign key (one_id) references migtest_fk_one (id) on delete set null; create index ix_migtest_e_basic_eref_id on migtest_e_basic (eref_id); alter table migtest_e_basic add constraint fk_migtest_e_basic_eref_id foreign key (eref_id) references migtest_e_ref (id); diff --git a/ebean-ddl-generator/src/test/resources/dbmigration/migrationtest/sqlserver17/1.3.sql b/ebean-ddl-generator/src/test/resources/dbmigration/migrationtest/sqlserver17/1.3.sql index 645d0879d..76564b73c 100644 --- a/ebean-ddl-generator/src/test/resources/dbmigration/migrationtest/sqlserver17/1.3.sql +++ b/ebean-ddl-generator/src/test/resources/dbmigration/migrationtest/sqlserver17/1.3.sql @@ -10,11 +10,11 @@ create sequence migtest_e_ref_seq as bigint start with 1; IF OBJECT_ID('fk_migtest_ckey_detail_parent', 'F') IS NOT NULL alter table migtest_ckey_detail drop constraint fk_migtest_ckey_detail_parent; IF OBJECT_ID('fk_migtest_fk_cascade_one_id', 'F') IS NOT NULL alter table migtest_fk_cascade drop constraint fk_migtest_fk_cascade_one_id; -alter table migtest_fk_cascade add constraint fk_migtest_fk_cascade_one_id foreign key (one_id) references migtest_fk_cascade_one (id) on delete cascade on update cascade; +alter table migtest_fk_cascade add constraint fk_migtest_fk_cascade_one_id foreign key (one_id) references migtest_fk_cascade_one (id) on delete cascade; IF OBJECT_ID('fk_migtest_fk_none_one_id', 'F') IS NOT NULL alter table migtest_fk_none drop constraint fk_migtest_fk_none_one_id; IF OBJECT_ID('fk_migtest_fk_none_via_join_one_id', 'F') IS NOT NULL alter table migtest_fk_none_via_join drop constraint fk_migtest_fk_none_via_join_one_id; IF OBJECT_ID('fk_migtest_fk_set_null_one_id', 'F') IS NOT NULL alter table migtest_fk_set_null drop constraint fk_migtest_fk_set_null_one_id; -alter table migtest_fk_set_null add constraint fk_migtest_fk_set_null_one_id foreign key (one_id) references migtest_fk_one (id) on delete set null on update set null; +alter table migtest_fk_set_null add constraint fk_migtest_fk_set_null_one_id foreign key (one_id) references migtest_fk_one (id) on delete set null; IF (OBJECT_ID('ck_migtest_e_basic_status', 'C') IS NOT NULL) alter table migtest_e_basic drop constraint ck_migtest_e_basic_status; EXEC usp_ebean_drop_default_constraint migtest_e_basic, status; alter table migtest_e_basic alter column status nvarchar(1); From ed2455f460128ec785ff38b17f380472f2502236 Mon Sep 17 00:00:00 2001 From: rob bygrave Date: Thu, 3 Dec 2020 15:47:14 +1300 Subject: [PATCH 008/447] #2121 - Refactor internals move DefaultBackgroundExecutor etc --- .../java/io/ebeaninternal/server/core/DefaultContainer.java | 5 +++-- .../server/{lib => executor}/DaemonScheduleThreadPool.java | 2 +- .../server/{lib => executor}/DaemonThreadFactory.java | 2 +- .../server/{core => executor}/DefaultBackgroundExecutor.java | 3 +-- .../{core => executor}/DefaultBackgroundExecutorTest.java | 3 ++- .../sql => executor}/TestShutdownWithBackgroundTasks.java | 2 +- 6 files changed, 9 insertions(+), 8 deletions(-) rename ebean-core/src/main/java/io/ebeaninternal/server/{lib => executor}/DaemonScheduleThreadPool.java (97%) rename ebean-core/src/main/java/io/ebeaninternal/server/{lib => executor}/DaemonThreadFactory.java (95%) rename ebean-core/src/main/java/io/ebeaninternal/server/{core => executor}/DefaultBackgroundExecutor.java (96%) rename ebean-core/src/test/java/io/ebeaninternal/server/{core => executor}/DefaultBackgroundExecutorTest.java (97%) rename ebean-core/src/test/java/io/ebeaninternal/server/{lib/sql => executor}/TestShutdownWithBackgroundTasks.java (96%) diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/core/DefaultContainer.java b/ebean-core/src/main/java/io/ebeaninternal/server/core/DefaultContainer.java index 46f9124c0..a352a5b6d 100644 --- a/ebean-core/src/main/java/io/ebeaninternal/server/core/DefaultContainer.java +++ b/ebean-core/src/main/java/io/ebeaninternal/server/core/DefaultContainer.java @@ -10,14 +10,15 @@ import io.ebean.config.TenantMode; import io.ebean.config.UnderscoreNamingConvention; import io.ebean.config.dbplatform.DatabasePlatform; import io.ebean.config.dbplatform.h2.H2Platform; +import io.ebean.event.ShutdownManager; import io.ebean.service.SpiContainer; +import io.ebeaninternal.api.DbOffline; import io.ebeaninternal.api.SpiBackgroundExecutor; import io.ebeaninternal.api.SpiEbeanServer; -import io.ebeaninternal.api.DbOffline; import io.ebeaninternal.server.cluster.ClusterManager; import io.ebeaninternal.server.core.bootup.BootupClassPathSearch; import io.ebeaninternal.server.core.bootup.BootupClasses; -import io.ebean.event.ShutdownManager; +import io.ebeaninternal.server.executor.DefaultBackgroundExecutor; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/lib/DaemonScheduleThreadPool.java b/ebean-core/src/main/java/io/ebeaninternal/server/executor/DaemonScheduleThreadPool.java similarity index 97% rename from ebean-core/src/main/java/io/ebeaninternal/server/lib/DaemonScheduleThreadPool.java rename to ebean-core/src/main/java/io/ebeaninternal/server/executor/DaemonScheduleThreadPool.java index c6636794d..3bdf15777 100644 --- a/ebean-core/src/main/java/io/ebeaninternal/server/lib/DaemonScheduleThreadPool.java +++ b/ebean-core/src/main/java/io/ebeaninternal/server/executor/DaemonScheduleThreadPool.java @@ -1,4 +1,4 @@ -package io.ebeaninternal.server.lib; +package io.ebeaninternal.server.executor; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/lib/DaemonThreadFactory.java b/ebean-core/src/main/java/io/ebeaninternal/server/executor/DaemonThreadFactory.java similarity index 95% rename from ebean-core/src/main/java/io/ebeaninternal/server/lib/DaemonThreadFactory.java rename to ebean-core/src/main/java/io/ebeaninternal/server/executor/DaemonThreadFactory.java index 4b1c87770..d1bbf3ee1 100644 --- a/ebean-core/src/main/java/io/ebeaninternal/server/lib/DaemonThreadFactory.java +++ b/ebean-core/src/main/java/io/ebeaninternal/server/executor/DaemonThreadFactory.java @@ -1,4 +1,4 @@ -package io.ebeaninternal.server.lib; +package io.ebeaninternal.server.executor; import java.util.concurrent.ThreadFactory; import java.util.concurrent.atomic.AtomicInteger; diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/core/DefaultBackgroundExecutor.java b/ebean-core/src/main/java/io/ebeaninternal/server/executor/DefaultBackgroundExecutor.java similarity index 96% rename from ebean-core/src/main/java/io/ebeaninternal/server/core/DefaultBackgroundExecutor.java rename to ebean-core/src/main/java/io/ebeaninternal/server/executor/DefaultBackgroundExecutor.java index 238911959..c93cbfac7 100644 --- a/ebean-core/src/main/java/io/ebeaninternal/server/core/DefaultBackgroundExecutor.java +++ b/ebean-core/src/main/java/io/ebeaninternal/server/executor/DefaultBackgroundExecutor.java @@ -1,7 +1,6 @@ -package io.ebeaninternal.server.core; +package io.ebeaninternal.server.executor; import io.ebeaninternal.api.SpiBackgroundExecutor; -import io.ebeaninternal.server.lib.DaemonScheduleThreadPool; import org.slf4j.MDC; import java.util.Map; diff --git a/ebean-core/src/test/java/io/ebeaninternal/server/core/DefaultBackgroundExecutorTest.java b/ebean-core/src/test/java/io/ebeaninternal/server/executor/DefaultBackgroundExecutorTest.java similarity index 97% rename from ebean-core/src/test/java/io/ebeaninternal/server/core/DefaultBackgroundExecutorTest.java rename to ebean-core/src/test/java/io/ebeaninternal/server/executor/DefaultBackgroundExecutorTest.java index aa8c56598..264edac57 100644 --- a/ebean-core/src/test/java/io/ebeaninternal/server/core/DefaultBackgroundExecutorTest.java +++ b/ebean-core/src/test/java/io/ebeaninternal/server/executor/DefaultBackgroundExecutorTest.java @@ -1,5 +1,6 @@ -package io.ebeaninternal.server.core; +package io.ebeaninternal.server.executor; +import io.ebeaninternal.server.executor.DefaultBackgroundExecutor; import org.junit.Ignore; import org.junit.Test; import org.slf4j.MDC; diff --git a/ebean-core/src/test/java/io/ebeaninternal/server/lib/sql/TestShutdownWithBackgroundTasks.java b/ebean-core/src/test/java/io/ebeaninternal/server/executor/TestShutdownWithBackgroundTasks.java similarity index 96% rename from ebean-core/src/test/java/io/ebeaninternal/server/lib/sql/TestShutdownWithBackgroundTasks.java rename to ebean-core/src/test/java/io/ebeaninternal/server/executor/TestShutdownWithBackgroundTasks.java index f8846ac62..a0a98c38a 100644 --- a/ebean-core/src/test/java/io/ebeaninternal/server/lib/sql/TestShutdownWithBackgroundTasks.java +++ b/ebean-core/src/test/java/io/ebeaninternal/server/executor/TestShutdownWithBackgroundTasks.java @@ -1,4 +1,4 @@ -package io.ebeaninternal.server.lib.sql; +package io.ebeaninternal.server.executor; import io.ebean.BackgroundExecutor; import io.ebean.BaseTestCase; From 365b7c46000874b128c0ff466147b87586a8df66 Mon Sep 17 00:00:00 2001 From: rob bygrave Date: Fri, 4 Dec 2020 20:41:40 +1300 Subject: [PATCH 009/447] #2122 - Metrics for ElementCollection query not included in reporting (via MetaInfoManager) --- .../server/deploy/BeanDescriptor.java | 7 +++++++ .../server/deploy/BeanDescriptorElement.java | 19 ++++++++++++++++++ .../server/deploy/BeanDescriptorManager.java | 9 +++++++++ .../server/deploy/BeanPropertyAssocMany.java | 7 +++++++ .../server/query/CQueryPlan.java | 20 ++++++++++++------- .../TestElementCollectionBasic.java | 6 +++++- 6 files changed, 60 insertions(+), 8 deletions(-) diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/deploy/BeanDescriptor.java b/ebean-core/src/main/java/io/ebeaninternal/server/deploy/BeanDescriptor.java index e5b8c10f2..bfb32c8fe 100644 --- a/ebean-core/src/main/java/io/ebeaninternal/server/deploy/BeanDescriptor.java +++ b/ebean-core/src/main/java/io/ebeaninternal/server/deploy/BeanDescriptor.java @@ -2087,6 +2087,13 @@ public class BeanDescriptor implements BeanType, STreeType { return name; } + /** + * Return the simple name of the entity bean. + */ + public String getSimpleName() { + return beanType.getSimpleName(); + } + /** * Summary description. */ diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/deploy/BeanDescriptorElement.java b/ebean-core/src/main/java/io/ebeaninternal/server/deploy/BeanDescriptorElement.java index 6553a28d2..1d541377d 100644 --- a/ebean-core/src/main/java/io/ebeaninternal/server/deploy/BeanDescriptorElement.java +++ b/ebean-core/src/main/java/io/ebeaninternal/server/deploy/BeanDescriptorElement.java @@ -14,13 +14,32 @@ import java.util.Arrays; */ abstract class BeanDescriptorElement extends BeanDescriptor { + private final String simpleName; + final ElementHelp elementHelp; BeanDescriptorElement(BeanDescriptorMap owner, DeployBeanDescriptor deploy, ElementHelp elementHelp) { super(owner, deploy); + this.simpleName = shortName(deploy.getName()); this.elementHelp = elementHelp; } + private String shortName(String name) { + int pos = name.lastIndexOf('.'); + if (pos > 1) { + pos = name.lastIndexOf('.', pos - 1); + if (pos > 1) { + return name.substring(pos + 1); + } + } + return name; + } + + @Override + public String getSimpleName() { + return simpleName; + } + @Override public boolean isJsonReadCollection() { return true; diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/deploy/BeanDescriptorManager.java b/ebean-core/src/main/java/io/ebeaninternal/server/deploy/BeanDescriptorManager.java index 15d2bcdc4..9a8c7a233 100644 --- a/ebean-core/src/main/java/io/ebeaninternal/server/deploy/BeanDescriptorManager.java +++ b/ebean-core/src/main/java/io/ebeaninternal/server/deploy/BeanDescriptorManager.java @@ -117,6 +117,7 @@ public class BeanDescriptorManager implements BeanDescriptorMap { private final TypeManager typeManager; private final BootupClasses bootupClasses; private final String serverName; + private final List elementDescriptors = new ArrayList<>(); private final Map, BeanTable> beanTableMap = new HashMap<>(); private final Map> descMap = new HashMap<>(); private final Map> descQueueMap = new HashMap<>(); @@ -644,6 +645,11 @@ public class BeanDescriptorManager implements BeanDescriptorMap { if (desc.isDocStoreMapped()) { descQueueMap.put(desc.getDocStoreQueueId(), desc); } + for (BeanPropertyAssocMany many : desc.propertiesMany()) { + if (many.isElementCollection()) { + elementDescriptors.add(many.getElementDescriptor()); + } + } } /** @@ -1619,6 +1625,9 @@ public class BeanDescriptorManager implements BeanDescriptorMap { for (BeanDescriptor desc : immutableDescriptorList) { desc.visitMetrics(visitor); } + for (BeanDescriptor desc : elementDescriptors) { + desc.visitMetrics(visitor); + } } public List queryPlanInit(QueryPlanInit request) { diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/deploy/BeanPropertyAssocMany.java b/ebean-core/src/main/java/io/ebeaninternal/server/deploy/BeanPropertyAssocMany.java index 8b98e1679..8e1ac1a14 100644 --- a/ebean-core/src/main/java/io/ebeaninternal/server/deploy/BeanPropertyAssocMany.java +++ b/ebean-core/src/main/java/io/ebeaninternal/server/deploy/BeanPropertyAssocMany.java @@ -569,6 +569,13 @@ public class BeanPropertyAssocMany extends BeanPropertyAssoc implements ST return elementCollection; } + /** + * Return the element bean descriptor (for an element collection only). + */ + public BeanDescriptor getElementDescriptor() { + return elementDescriptor; + } + /** * ManyToMany only, join from local table to intersection table. */ diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/query/CQueryPlan.java b/ebean-core/src/main/java/io/ebeaninternal/server/query/CQueryPlan.java index af4ad9c48..86e8d209d 100644 --- a/ebean-core/src/main/java/io/ebeaninternal/server/query/CQueryPlan.java +++ b/ebean-core/src/main/java/io/ebeaninternal/server/query/CQueryPlan.java @@ -13,6 +13,7 @@ import io.ebeaninternal.api.SpiQueryBindCapture; import io.ebeaninternal.api.SpiQueryPlan; import io.ebeaninternal.server.core.OrmQueryRequest; import io.ebeaninternal.server.core.timezone.DataTimeZone; +import io.ebeaninternal.server.lib.Str; import io.ebeaninternal.server.query.CQueryPlanStats.Snapshot; import io.ebeaninternal.server.type.DataBind; import io.ebeaninternal.server.type.DataBindCapture; @@ -106,7 +107,7 @@ public class CQueryPlan implements SpiQueryPlan { SpiQuery query = request.getQuery(); this.profileLocation = query.getProfileLocation(); this.label = query.getPlanLabel(); - this.name = deriveName(label, query.getType()); + this.name = deriveName(label, query.getType(), request.getBeanDescriptor().getSimpleName()); this.location = location(); this.asOfTableCount = query.getAsOfTableCount(); this.sql = sqlRes.getSql(); @@ -130,7 +131,7 @@ public class CQueryPlan implements SpiQueryPlan { SpiQuery query = request.getQuery(); this.profileLocation = query.getProfileLocation(); this.label = query.getPlanLabel(); - this.name = deriveName(label, query.getType()); + this.name = deriveName(label, query.getType(), request.getBeanDescriptor().getSimpleName()); this.location = location(); this.planKey = buildPlanKey(sql, logWhereSql); this.asOfTableCount = 0; @@ -145,14 +146,19 @@ public class CQueryPlan implements SpiQueryPlan { this.hash = md5Hash(); } - private String deriveName(String label, SpiQuery.Type type) { + private String deriveName(String label, SpiQuery.Type type, String simpleName) { if (label == null) { - return "orm." + beanType.getSimpleName() + "." + type.label(); + return Str.add("orm.", simpleName, ".", type.label()); } - if (label.startsWith(beanType.getSimpleName())) { - return "orm." + label; + int pos = simpleName.indexOf('.'); + if (pos > 1) { + // element collection and label + return Str.add("orm.", simpleName.substring(0, pos), "_", label); } - return "orm." + beanType.getSimpleName() + "_" + label; + if (label.startsWith(simpleName)) { + return Str.add("orm.", label); + } + return Str.add("orm.", simpleName, "_", label); } private SpiQueryBindCapture initBindCapture(SpiQuery query) { diff --git a/ebean-core/src/test/java/org/tests/model/elementcollection/TestElementCollectionBasic.java b/ebean-core/src/test/java/org/tests/model/elementcollection/TestElementCollectionBasic.java index 9b304bafc..78562fb6d 100644 --- a/ebean-core/src/test/java/org/tests/model/elementcollection/TestElementCollectionBasic.java +++ b/ebean-core/src/test/java/org/tests/model/elementcollection/TestElementCollectionBasic.java @@ -30,7 +30,11 @@ public class TestElementCollectionBasic extends BaseTestCase { assertThat(eventLog()).containsOnly("preInsert", "postInsert"); assertThat(sql).hasSize(4); - final EcPerson found = Ebean.find(EcPerson.class, person.getId()); + final EcPerson found = Ebean.find(EcPerson.class) + .setId(person.getId()) + //.setLabel("findById") + .findOne(); + found.getPhoneNumbers().size(); sql = LoggedSqlCollector.current(); From a23a179bbff059f027788ce23cb07c78e6f86e70 Mon Sep 17 00:00:00 2001 From: rob bygrave Date: Fri, 4 Dec 2020 20:45:38 +1300 Subject: [PATCH 010/447] Fix test bump kotlin-querybean-generator 12.6.2-SNAPSHOT --- kotlin-querybean-generator/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kotlin-querybean-generator/pom.xml b/kotlin-querybean-generator/pom.xml index 8a6753c04..a5c53e5fa 100644 --- a/kotlin-querybean-generator/pom.xml +++ b/kotlin-querybean-generator/pom.xml @@ -106,7 +106,7 @@ io.ebean kotlin-querybean-generator - 12.6.1-SNAPSHOT + 12.6.2-SNAPSHOT From 9c6dd0989a7ebbb8596bc47e45166f083d901fff Mon Sep 17 00:00:00 2001 From: rob bygrave Date: Fri, 4 Dec 2020 21:03:08 +1300 Subject: [PATCH 011/447] Refactor tidy BeanDescriptorManager whitespace and raw types --- .../server/deploy/BeanDescriptorManager.java | 118 ++---------------- 1 file changed, 9 insertions(+), 109 deletions(-) diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/deploy/BeanDescriptorManager.java b/ebean-core/src/main/java/io/ebeaninternal/server/deploy/BeanDescriptorManager.java index 9a8c7a233..77b3c6c04 100644 --- a/ebean-core/src/main/java/io/ebeaninternal/server/deploy/BeanDescriptorManager.java +++ b/ebean-core/src/main/java/io/ebeaninternal/server/deploy/BeanDescriptorManager.java @@ -117,7 +117,7 @@ public class BeanDescriptorManager implements BeanDescriptorMap { private final TypeManager typeManager; private final BootupClasses bootupClasses; private final String serverName; - private final List elementDescriptors = new ArrayList<>(); + private final List> elementDescriptors = new ArrayList<>(); private final Map, BeanTable> beanTableMap = new HashMap<>(); private final Map> descMap = new HashMap<>(); private final Map> descQueueMap = new HashMap<>(); @@ -238,7 +238,6 @@ public class BeanDescriptorManager implements BeanDescriptorMap { * Return the versions between timestamp suffix based on the DbHistorySupport. */ private String getVersionsBetweenSuffix(DatabasePlatform databasePlatform, DatabaseConfig serverConfig) { - DbHistorySupport historySupport = databasePlatform.getHistorySupport(); // with historySupport returns a simple view suffix or the sql2011 versions between timestamp suffix return (historySupport == null) ? serverConfig.getAsOfViewSuffix() : historySupport.getVersionsBetweenSuffix(serverConfig.getAsOfViewSuffix()); @@ -362,7 +361,6 @@ public class BeanDescriptorManager implements BeanDescriptorMap { } private void readEntityMapping(ClassLoader classLoader, XmapEntity entityDeploy) { - String entityClassName = entityDeploy.getClazz(); Class entityClass; try { @@ -412,7 +410,6 @@ public class BeanDescriptorManager implements BeanDescriptorMap { * For SQL based modifications we need to invalidate appropriate parts of the cache. */ public void cacheNotify(TransactionEventTable.TableIUD tableIUD, CacheChangeSet changeSet) { - String tableName = tableIUD.getTableName().toLowerCase(); List> normalBeanTypes = tableToDescMap.get(tableName); if (normalBeanTypes != null) { @@ -448,7 +445,6 @@ public class BeanDescriptorManager implements BeanDescriptorMap { * Invalidate entity beans based on views via their dependent tables. */ public void processViewInvalidation(Set viewInvalidation) { - for (String depTable : viewInvalidation) { List> list = tableToViewDescMap.get(depTable.toLowerCase()); if (list != null) { @@ -461,12 +457,8 @@ public class BeanDescriptorManager implements BeanDescriptorMap { /** * Build a map of table names to BeanDescriptors. - *

- * This is generally used to maintain caches from table names. - *

*/ private void readTableToDescriptor() { - for (BeanDescriptor desc : descMap.values()) { String baseTable = desc.getBaseTable(); if (baseTable != null) { @@ -490,7 +482,6 @@ public class BeanDescriptorManager implements BeanDescriptorMap { } private void readForeignKeys() { - for (BeanDescriptor d : descMap.values()) { d.initialiseFkeys(); } @@ -501,18 +492,14 @@ public class BeanDescriptorManager implements BeanDescriptorMap { *

* This occurs after all the BeanDescriptors have been created. This resolves * circular relationships between BeanDescriptors. - *

*

* Also responsible for creating all the BeanManagers which contain the * persister, listener etc. - *

*/ private void initialiseAll() { - // now that all the BeanDescriptors are in their map // we can initialise them which sorts out circular // dependencies for OneToMany and ManyToOne etc - BeanDescriptorInitContext initContext = new BeanDescriptorInitContext(asOfTableMap, draftTableMap, asOfViewSuffix); // PASS 1: @@ -570,7 +557,6 @@ public class BeanDescriptorManager implements BeanDescriptorMap { } private void checkMissingHashCodeOrEquals(Exception source, Class idType, Class beanType) { - String msg = "SERIOUS ERROR: The hashCode() and equals() methods *MUST* be implemented "; msg += "on Embedded bean " + idType + " as it is used as an Id for " + beanType; throw new PersistenceException(msg, source); @@ -604,7 +590,6 @@ public class BeanDescriptorManager implements BeanDescriptorMap { @SuppressWarnings("unchecked") public BeanManager getBeanManager(Class entityType) { - return (BeanManager) getBeanManager(entityType.getName()); } @@ -616,14 +601,12 @@ public class BeanDescriptorManager implements BeanDescriptorMap { * Create the BeanControllers, BeanFinders and BeanListeners. */ private void createListeners() { - int qa = beanQueryAdapterManager.getRegisterCount(); int cc = persistControllerManager.getRegisterCount(); int pl = postLoadManager.getRegisterCount(); int pc = postConstructManager.getRegisterCount(); int lc = persistListenerManager.getRegisterCount(); int fc = beanFinderManager.getRegisterCount(); - logger.debug("BeanPersistControllers[{}] BeanFinders[{}] BeanPersistListeners[{}] BeanQueryAdapters[{}] BeanPostLoaders[{}] BeanPostConstructors[{}]", cc, fc, lc, qa, pl, pc); } @@ -640,12 +623,12 @@ public class BeanDescriptorManager implements BeanDescriptorMap { } private void registerBeanDescriptor(DeployBeanInfo info) { - BeanDescriptor desc = new BeanDescriptor<>(this, info.getDescriptor()); + BeanDescriptor desc = new BeanDescriptor<>(this, info.getDescriptor()); descMap.put(desc.getBeanType().getName(), desc); if (desc.isDocStoreMapped()) { descQueueMap.put(desc.getDocStoreQueueId(), desc); } - for (BeanPropertyAssocMany many : desc.propertiesMany()) { + for (BeanPropertyAssocMany many : desc.propertiesMany()) { if (many.isElementCollection()) { elementDescriptors.add(many.getElementDescriptor()); } @@ -657,10 +640,8 @@ public class BeanDescriptorManager implements BeanDescriptorMap { *

* This stops short of reading relationship meta data until after the * BeanTables have all been created. - *

*/ private void readEntityDeploymentInitial() { - for (Class entityClass : bootupClasses.getEntities()) { DeployBeanInfo info = createDeployBeanInfo(entityClass); deployInfoMap.put(entityClass, info); @@ -693,15 +674,12 @@ public class BeanDescriptorManager implements BeanDescriptorMap { * Create the BeanTable information which has the base table and id. *

* This is determined prior to resolving relationship information. - *

*/ private void readEntityBeanTable() { - for (DeployBeanInfo info : deployInfoMap.values()) { BeanTable beanTable = createBeanTable(info); beanTableMap.put(beanTable.getBeanType(), beanTable); } - // register non-id embedded beans (after bean tables are created) for (DeployBeanInfo info : embeddedBeans) { registerEmbeddedBean(info); @@ -712,17 +690,14 @@ public class BeanDescriptorManager implements BeanDescriptorMap { * Create the BeanTable information which has the base table and id. *

* This is determined prior to resolving relationship information. - *

*/ private void readEntityDeploymentAssociations() { - for (DeployBeanInfo info : deployInfoMap.values()) { readDeployAssociations(info); } } private void readInheritedIdGenerators() { - for (DeployBeanInfo info : deployInfoMap.values()) { DeployBeanDescriptor descriptor = info.getDescriptor(); InheritInfo inheritInfo = descriptor.getInheritInfo(); @@ -740,17 +715,14 @@ public class BeanDescriptorManager implements BeanDescriptorMap { * Create the BeanTable from the deployment information gathered so far. */ private BeanTable createBeanTable(DeployBeanInfo info) { - DeployBeanDescriptor deployDescriptor = info.getDescriptor(); DeployBeanTable beanTable = deployDescriptor.createDeployBeanTable(); return new BeanTable(beanTable, this); } private void readEntityRelationships() { - // We only perform 'circular' checks etc after we have // all the DeployBeanDescriptors created and in the map. - List> primaryKeyJoinCheck = new ArrayList<>(); for (DeployBeanInfo info : deployInfoMap.values()) { checkMappedBy(info, primaryKeyJoinCheck); @@ -758,15 +730,12 @@ public class BeanDescriptorManager implements BeanDescriptorMap { for (DeployBeanPropertyAssocOne prop : primaryKeyJoinCheck) { checkUniDirectionalPrimaryKeyJoin(prop); } - for (DeployBeanInfo info : deployInfoMap.values()) { secondaryPropsJoins(info); } - for (DeployBeanInfo info : deployInfoMap.values()) { setInheritanceInfo(info); } - for (DeployBeanInfo info : deployInfoMap.values()) { if (!info.isEmbedded()) { registerBeanDescriptor(info); @@ -775,12 +744,9 @@ public class BeanDescriptorManager implements BeanDescriptorMap { } /** - * Sets the inheritance info. ~EMG fix for join problem - * - * @param info the new inheritance info + * Sets the inheritance info. */ private void setInheritanceInfo(DeployBeanInfo info) { - for (DeployBeanPropertyAssocOne oneProp : info.getDescriptor().propertiesAssocOne()) { if (!oneProp.isTransient()) { DeployBeanInfo assoc = deployInfoMap.get(oneProp.getTargetType()); @@ -789,7 +755,6 @@ public class BeanDescriptorManager implements BeanDescriptorMap { } } } - for (DeployBeanPropertyAssocMany manyProp : info.getDescriptor().propertiesAssocMany()) { if (!manyProp.isTransient()) { DeployBeanInfo assoc = deployInfoMap.get(manyProp.getTargetType()); @@ -801,7 +766,6 @@ public class BeanDescriptorManager implements BeanDescriptorMap { } private void secondaryPropsJoins(DeployBeanInfo info) { - DeployBeanDescriptor descriptor = info.getDescriptor(); for (DeployBeanProperty prop : descriptor.propertiesBase()) { if (prop.isSecondaryTable()) { @@ -825,10 +789,8 @@ public class BeanDescriptorManager implements BeanDescriptorMap { * This will read join information defined on the 'owning/other' side of the * relationship. It also does some extra work for unidirectional * relationships. - *

*/ private void checkMappedBy(DeployBeanInfo info, List> primaryKeyJoinCheck) { - for (DeployBeanPropertyAssocOne oneProp : info.getDescriptor().propertiesAssocOne()) { if (!oneProp.isTransient()) { if (oneProp.getMappedBy() != null) { @@ -851,14 +813,12 @@ public class BeanDescriptorManager implements BeanDescriptorMap { } private DeployBeanDescriptor getTargetDescriptor(DeployBeanPropertyAssoc prop) { - Class targetType = prop.getTargetType(); DeployBeanInfo info = deployInfoMap.get(targetType); if (info == null) { String msg = "Can not find descriptor [" + targetType + "] for " + prop.getFullBeanName(); throw new PersistenceException(msg); } - return info.getDescriptor(); } @@ -867,10 +827,8 @@ public class BeanDescriptorManager implements BeanDescriptorMap { * mark it as unidirectional. */ private boolean findMappedBy(DeployBeanPropertyAssocMany prop) { - // this is the entity bean type - that owns this property Class owningType = prop.getOwningType(); - Set matchSet = new HashSet<>(); // get the bean descriptor that holds the mappedBy property @@ -924,7 +882,6 @@ public class BeanDescriptorManager implements BeanDescriptorMap { return true; } } - } } // multiple options so should specify mappedBy property @@ -936,12 +893,9 @@ public class BeanDescriptorManager implements BeanDescriptorMap { } private void makeOrderColumn(DeployBeanPropertyAssocMany oneToMany) { - DeployBeanDescriptor targetDesc = getTargetDescriptor(oneToMany); - DeployOrderColumn orderColumn = oneToMany.getOrderColumn(); DeployBeanProperty orderProperty = new DeployBeanProperty(targetDesc, Integer.class, ScalarTypeInteger.INSTANCE, null); - orderProperty.setName(DeployOrderColumn.LOGICAL_NAME); orderProperty.setDbColumn(orderColumn.getName()); orderProperty.setNullable(orderColumn.isNullable()); @@ -949,7 +903,6 @@ public class BeanDescriptorManager implements BeanDescriptorMap { orderProperty.setDbUpdateable(orderColumn.isUpdatable()); orderProperty.setDbRead(true); orderProperty.setOwningType(targetDesc.getBeanType()); - final InheritInfo targetInheritInfo = targetDesc.getInheritInfo(); if (targetInheritInfo != null) { for (InheritInfo child : targetInheritInfo.getChildren()) { @@ -957,7 +910,6 @@ public class BeanDescriptorManager implements BeanDescriptorMap { childDescriptor.setOrderColumn(orderProperty); } } - targetDesc.setOrderColumn(orderProperty); } @@ -966,19 +918,14 @@ public class BeanDescriptorManager implements BeanDescriptorMap { * unidirectional. *

* This means that inserts MUST cascade for this property. - *

*

* Create a "Shadow"/Unidirectional property on the target. It is used with * inserts to set the foreign key value (e.g. inserts the foreign key value * into the order_id column on the order_lines table). - *

*/ private void makeUnidirectional(DeployBeanPropertyAssocMany oneToMany) { - DeployBeanDescriptor targetDesc = getTargetDescriptor(oneToMany); - Class owningType = oneToMany.getOwningType(); - if (!oneToMany.getCascadeInfo().isSave()) { // The property MUST have persist cascading so that inserts work. @@ -1026,11 +973,9 @@ public class BeanDescriptorManager implements BeanDescriptorMap { } private void checkMappedByOneToOne(DeployBeanPropertyAssocOne prop) { - // check that the mappedBy property is valid and read // its associated join information if it is available String mappedBy = prop.getMappedBy(); - // get the mappedBy property DeployBeanDescriptor targetDesc = getTargetDescriptor(prop); DeployBeanProperty mappedProp = targetDesc.getBeanProperty(mappedBy); @@ -1083,10 +1028,8 @@ public class BeanDescriptorManager implements BeanDescriptorMap { *

* We can use the join information from the mappedBy property and reverse it * for using in the OneToMany direction. - *

*/ private void checkMappedByOneToMany(DeployBeanInfo info, DeployBeanPropertyAssocMany prop) { - if (prop.isElementCollection()) { // skip mapping check return; @@ -1167,7 +1110,6 @@ public class BeanDescriptorManager implements BeanDescriptorMap { * For mappedBy copy the joins from the other side. */ private void checkMappedByManyToMany(DeployBeanPropertyAssocMany prop) { - // get the bean descriptor that holds the mappedBy property String mappedBy = prop.getMappedBy(); if (mappedBy == null) { @@ -1228,50 +1170,40 @@ public class BeanDescriptorManager implements BeanDescriptorMap { } private void setBeanControllerFinderListener(DeployBeanDescriptor descriptor) { - persistControllerManager.addPersistControllers(descriptor); postLoadManager.addPostLoad(descriptor); postConstructManager.addPostConstructListeners(descriptor); persistListenerManager.addPersistListeners(descriptor); beanQueryAdapterManager.addQueryAdapter(descriptor); beanFinderManager.addFindControllers(descriptor); - if (changeLogRegister != null) { ChangeLogFilter changeFilter = changeLogRegister.getChangeFilter(descriptor.getBeanType()); if (changeFilter != null) { descriptor.setChangeLogFilter(changeFilter); } } - } /** * Read the initial deployment information for a given bean type. */ private DeployBeanInfo createDeployBeanInfo(Class beanClass) { - DeployBeanDescriptor desc = new DeployBeanDescriptor<>(this, beanClass, config); beanLifecycleAdapterFactory.addLifecycleMethods(desc); - // set bean controller, finder and listener setBeanControllerFinderListener(desc); deplyInherit.process(desc); desc.checkInheritanceMapping(); createProperties.createProperties(desc); - DeployBeanInfo info = new DeployBeanInfo<>(deployUtil, desc); - readAnnotations.readInitial(info); return info; } private void readDeployAssociations(DeployBeanInfo info) { - DeployBeanDescriptor desc = info.getDescriptor(); - readAnnotations.readAssociations(info, this); - if (EntityType.SQL == desc.getEntityType()) { desc.setBaseTable(null, null, null); } @@ -1279,15 +1211,12 @@ public class BeanDescriptorManager implements BeanDescriptorMap { // mark transient properties transientProperties.process(desc); setScalarType(desc); - if (!desc.isEmbedded()) { // Set IdGenerator or use DB Identity setIdGeneration(desc); - // find the appropriate default concurrency mode setConcurrencyMode(desc); } - // generate the byte code createByteCode(desc); } @@ -1296,7 +1225,6 @@ public class BeanDescriptorManager implements BeanDescriptorMap { * Set the Identity generation mechanism. */ private void setIdGeneration(DeployBeanDescriptor desc) { - if (desc.getIdGenerator() != null) { // already assigned (So custom or UUID) return; @@ -1304,7 +1232,6 @@ public class BeanDescriptorManager implements BeanDescriptorMap { if (desc.idProperty() == null) { return; } - final DeployIdentityMode identityMode = desc.getIdentityMode(); if (identityMode.isSequence() && !dbIdentity.isSupportsSequence()) { // explicit sequence but not supported by the DatabasePlatform @@ -1361,11 +1288,9 @@ public class BeanDescriptorManager implements BeanDescriptorMap { } private void createByteCode(DeployBeanDescriptor deploy) { - // check to see if the bean supports EntityBean interface // generate a subclass if required setEntityBeanClass(deploy); - // use Code generation or Standard reflection to support // getter and setter methods setBeanReflect(deploy); @@ -1379,10 +1304,8 @@ public class BeanDescriptorManager implements BeanDescriptorMap { *

* Enums are treated a bit differently in that they always have a ScalarType * as one is built for them. - *

*/ private void setScalarType(DeployBeanDescriptor deployDesc) { - for (DeployBeanProperty prop : deployDesc.propertiesAll()) { if (!(prop instanceof DeployBeanPropertyAssoc)) { deployUtil.setScalarType(prop); @@ -1396,17 +1319,13 @@ public class BeanDescriptorManager implements BeanDescriptorMap { * This sets the implementation of constructing entity beans and the setting * and getting of properties. It is generally faster to use code generation * rather than reflection to do this. - *

*/ private void setBeanReflect(DeployBeanDescriptor desc) { - // Set the BeanReflectGetter and BeanReflectSetter that typically // use generated code. NB: Due to Bug 166 so now doing this for // abstract classes as well. - BeanPropertiesReader reflectProps = new BeanPropertiesReader(desc.getBeanType()); desc.setProperties(reflectProps.getProperties()); - for (DeployBeanProperty prop : desc.propertiesAll()) { String propName = prop.getName(); Integer pos = reflectProps.getPropertyIndex(propName); @@ -1416,7 +1335,6 @@ public class BeanDescriptorManager implements BeanDescriptorMap { "If you are running in an IDE with enhancement plugin try a Build -> Rebuild Project to recompile and enhance all entity beans. " + "Error - property " + propName + " not found in " + reflectProps + " for type " + desc.getBeanType()); } - } else { final int propertyIndex = pos; prop.setPropertyIndex(propertyIndex); @@ -1433,7 +1351,6 @@ public class BeanDescriptorManager implements BeanDescriptorMap { * Return true if this is a persistent field (not transient or static). */ private boolean isPersistentField(DeployBeanProperty prop) { - Field field = prop.getField(); if (field == null) { return false; @@ -1448,12 +1365,10 @@ public class BeanDescriptorManager implements BeanDescriptorMap { * which contain version properties. */ private void setConcurrencyMode(DeployBeanDescriptor desc) { - if (desc.getConcurrencyMode() != null) { // concurrency mode explicitly set during deployment return; } - if (checkForVersionProperties(desc)) { desc.setConcurrencyMode(ConcurrencyMode.VERSION); } else { @@ -1465,23 +1380,16 @@ public class BeanDescriptorManager implements BeanDescriptorMap { * Search for version properties also including embedded beans. */ private boolean checkForVersionProperties(DeployBeanDescriptor desc) { - - boolean hasVersionProperty = false; - - List props = desc.propertiesBase(); - for (DeployBeanProperty prop : props) { + for (DeployBeanProperty prop : desc.propertiesBase()) { if (prop.isVersionColumn()) { - hasVersionProperty = true; + return true; } } - - return hasVersionProperty; + return false; } private boolean hasEntityBeanInterface(Class beanClass) { - - Class[] interfaces = beanClass.getInterfaces(); - for (Class anInterface : interfaces) { + for (Class anInterface : beanClass.getInterfaces()) { if (anInterface.equals(EntityBean.class)) { return true; } @@ -1493,18 +1401,14 @@ public class BeanDescriptorManager implements BeanDescriptorMap { * Test the bean type to see if it implements EntityBean interface already. */ private void setEntityBeanClass(DeployBeanDescriptor desc) { - Class beanClass = desc.getBeanType(); - if (!hasEntityBeanInterface(beanClass)) { String msg = "Bean " + beanClass + " is not enhanced? Check packages specified in ebean.mf. If you are running in IDEA or " + "Eclipse check that the enhancement plugin is installed. See https://ebean.io/docs/trouble-shooting#not-enhanced"; throw new BeanNotEnhancedException(msg); } - // the bean already implements EntityBean checkInheritedClasses(beanClass); - entityBeanCount++; } @@ -1513,7 +1417,6 @@ public class BeanDescriptorManager implements BeanDescriptorMap { * enhanced or all dynamically subclassed). */ private void checkInheritedClasses(Class beanClass) { - Class superclass = beanClass.getSuperclass(); if (Object.class.equals(superclass)) { // we got to the top of the inheritance @@ -1572,10 +1475,8 @@ public class BeanDescriptorManager implements BeanDescriptorMap { } private void addPrimaryKeyJoin(DeployBeanPropertyAssocOne prop) { - String baseTable = prop.getDesc().getBaseTable(); DeployTableJoin inverse = prop.getTableJoin().createInverse(baseTable); - TableJoin inverseJoin = new TableJoin(inverse, prop.getForeignKey()); DeployBeanInfo target = deployInfoMap.get(prop.getTargetType()); target.setPrimaryKeyJoin(inverseJoin); @@ -1592,7 +1493,6 @@ public class BeanDescriptorManager implements BeanDescriptorMap { * Create a BeanDescriptor for an ElementCollection target. */ public BeanDescriptor createElementDescriptor(DeployBeanDescriptor elementDescriptor, ManyType manyType, boolean scalar) { - ElementHelp elementHelp = elementHelper(manyType); if (manyType.isMap()) { if (scalar) { @@ -1625,7 +1525,7 @@ public class BeanDescriptorManager implements BeanDescriptorMap { for (BeanDescriptor desc : immutableDescriptorList) { desc.visitMetrics(visitor); } - for (BeanDescriptor desc : elementDescriptors) { + for (BeanDescriptor desc : elementDescriptors) { desc.visitMetrics(visitor); } } From cb0100f02a37f63dd5835f9272c001b8fdbab9d3 Mon Sep 17 00:00:00 2001 From: rob bygrave Date: Fri, 4 Dec 2020 21:11:02 +1300 Subject: [PATCH 012/447] Refactor tidy BeanDescriptor, no effective change --- .../server/deploy/BeanDescriptor.java | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/deploy/BeanDescriptor.java b/ebean-core/src/main/java/io/ebeaninternal/server/deploy/BeanDescriptor.java index bfb32c8fe..bc2c87e66 100644 --- a/ebean-core/src/main/java/io/ebeaninternal/server/deploy/BeanDescriptor.java +++ b/ebean-core/src/main/java/io/ebeaninternal/server/deploy/BeanDescriptor.java @@ -522,7 +522,7 @@ public class BeanDescriptor implements BeanType, STreeType { return null; } try { - return (EntityBean) beanType.newInstance(); + return (EntityBean) beanType.getDeclaredConstructor().newInstance(); } catch (Exception e) { throw new IllegalStateException("Error trying to create the prototypeEntityBean for " + beanType, e); } @@ -814,7 +814,6 @@ public class BeanDescriptor implements BeanType, STreeType { int propertyLength = toEbi.getPropertyLength(); String[] names = getProperties(); for (int i = 0; i < propertyLength; i++) { - if (fromEbi.isLoadedProperty(i)) { BeanProperty property = getBeanProperty(names[i]); if (!toEbi.isLoadedProperty(i)) { @@ -1865,17 +1864,12 @@ public class BeanDescriptor implements BeanType, STreeType { } /** - * We actually need to do a query because we don't know the type without the discriminator - * value, just select the id property and discriminator column (auto added) + * We actually need to do a query because we don't know the type without the discriminator value. */ private T findReferenceBean(Object id, PersistenceContext pc) { DefaultOrmQuery query = new DefaultOrmQuery<>(this, ebeanServer, ebeanServer.getExpressionFactory()); query.setPersistenceContext(pc); - return query - // .select(getIdProperty().getName()) - // we do not select the id because we - // probably have to load the entire bean - .setId(id).findOne(); + return query.setId(id).findOne(); } /** @@ -2278,8 +2272,7 @@ public class BeanDescriptor implements BeanType, STreeType { */ public void lazyLoadRegister(String prefix, EntityBeanIntercept ebi, EntityBean bean, LoadContext loadContext) { // load the List/Set/Map proxy objects (deferred fetching of lists) - BeanPropertyAssocMany[] manys = propertiesMany(); - for (BeanPropertyAssocMany many : manys) { + for (BeanPropertyAssocMany many : propertiesMany()) { if (!ebi.isLoadedProperty(many.getPropertyIndex())) { BeanCollection ref = many.createReferenceIfNull(bean); if (ref != null && !ref.isRegisteredWithLoadContext()) { From 9d706056c614bcc60255c5730f7ed70fb0ab69bb Mon Sep 17 00:00:00 2001 From: rob bygrave Date: Fri, 4 Dec 2020 21:18:55 +1300 Subject: [PATCH 013/447] No functional change, replace new ReentrantLock(false) with new ReentrantLock() --- ebean-api/src/main/java/io/ebean/DatabaseFactory.java | 2 +- ebean-api/src/main/java/io/ebean/DbContext.java | 2 +- ebean-api/src/main/java/io/ebean/DbPrimary.java | 2 +- .../src/main/java/io/ebean/bean/EntityBeanIntercept.java | 2 +- ebean-api/src/main/java/io/ebean/bean/SingleBeanLoader.java | 2 +- .../src/main/java/io/ebean/common/AbstractBeanCollection.java | 2 +- .../src/main/java/io/ebean/common/CopyOnFirstWriteList.java | 2 +- .../java/io/ebean/config/dbplatform/SequenceIdGenerator.java | 4 +--- ebean-api/src/main/java/io/ebean/event/ShutdownManager.java | 2 +- .../server/autotune/service/DefaultAutoTuneService.java | 2 +- .../ebeaninternal/server/autotune/service/ProfileManager.java | 2 +- .../ebeaninternal/server/autotune/service/ProfileOrigin.java | 2 +- .../server/autotune/service/ProfileOriginNodeUsage.java | 2 +- .../io/ebeaninternal/server/cache/DefaultCacheHolder.java | 2 +- .../java/io/ebeaninternal/server/cluster/ClusterManager.java | 2 +- .../java/io/ebeaninternal/server/core/DefaultContainer.java | 2 +- .../main/java/io/ebeaninternal/server/core/DefaultServer.java | 2 +- .../main/java/io/ebeaninternal/server/core/InternString.java | 2 +- .../io/ebeaninternal/server/idgen/UuidV1RndIdGenerator.java | 2 +- .../io/ebeaninternal/server/loadcontext/DLoadBaseContext.java | 2 +- .../io/ebeaninternal/server/loadcontext/DLoadBeanContext.java | 2 +- .../io/ebeaninternal/server/loadcontext/DLoadManyContext.java | 2 +- .../src/main/java/io/ebeaninternal/server/query/CQuery.java | 2 +- .../java/io/ebeaninternal/server/query/CQueryBindCapture.java | 2 +- .../io/ebeaninternal/server/query/LimitOffsetPagedList.java | 2 +- .../io/ebeaninternal/server/querydefn/DefaultOrmQuery.java | 2 +- .../server/transaction/DefaultPersistenceContext.java | 2 +- .../server/transaction/DefaultProfileHandler.java | 2 +- .../io/ebeaninternal/server/type/ScalarTypeArrayList.java | 2 +- .../io/ebeaninternal/server/type/ScalarTypeArrayListH2.java | 2 +- .../java/io/ebeaninternal/server/type/ScalarTypeArraySet.java | 2 +- .../io/ebeaninternal/server/type/ScalarTypeArraySetH2.java | 2 +- .../src/main/java/io/ebean/test/config/RunOnceMarker.java | 2 +- 33 files changed, 33 insertions(+), 35 deletions(-) diff --git a/ebean-api/src/main/java/io/ebean/DatabaseFactory.java b/ebean-api/src/main/java/io/ebean/DatabaseFactory.java index 13a0c4125..11cdf9068 100644 --- a/ebean-api/src/main/java/io/ebean/DatabaseFactory.java +++ b/ebean-api/src/main/java/io/ebean/DatabaseFactory.java @@ -31,7 +31,7 @@ import java.util.concurrent.locks.ReentrantLock; */ public class DatabaseFactory { - private static final ReentrantLock lock = new ReentrantLock(false); + private static final ReentrantLock lock = new ReentrantLock(); private static SpiContainer container; static { diff --git a/ebean-api/src/main/java/io/ebean/DbContext.java b/ebean-api/src/main/java/io/ebean/DbContext.java index cf09dc7fb..18df2169e 100644 --- a/ebean-api/src/main/java/io/ebean/DbContext.java +++ b/ebean-api/src/main/java/io/ebean/DbContext.java @@ -27,7 +27,7 @@ final class DbContext { private final HashMap syncMap = new HashMap<>(); - private final ReentrantLock lock = new ReentrantLock(false); + private final ReentrantLock lock = new ReentrantLock(); /** * The 'default' Database. diff --git a/ebean-api/src/main/java/io/ebean/DbPrimary.java b/ebean-api/src/main/java/io/ebean/DbPrimary.java index 9cbdc2eba..ffec8b114 100644 --- a/ebean-api/src/main/java/io/ebean/DbPrimary.java +++ b/ebean-api/src/main/java/io/ebean/DbPrimary.java @@ -12,7 +12,7 @@ import java.util.concurrent.locks.ReentrantLock; */ class DbPrimary { - private static final ReentrantLock lock = new ReentrantLock(false); + private static final ReentrantLock lock = new ReentrantLock(); private static String defaultServerName; private static boolean skip; diff --git a/ebean-api/src/main/java/io/ebean/bean/EntityBeanIntercept.java b/ebean-api/src/main/java/io/ebean/bean/EntityBeanIntercept.java index 4bb520a32..b49c6f8ae 100644 --- a/ebean-api/src/main/java/io/ebean/bean/EntityBeanIntercept.java +++ b/ebean-api/src/main/java/io/ebean/bean/EntityBeanIntercept.java @@ -32,7 +32,7 @@ public final class EntityBeanIntercept implements Serializable { private static final int STATE_REFERENCE = 1; private static final int STATE_LOADED = 2; - private transient final ReentrantLock lock = new ReentrantLock(false); + private transient final ReentrantLock lock = new ReentrantLock(); private transient NodeUsageCollector nodeUsageCollector; diff --git a/ebean-api/src/main/java/io/ebean/bean/SingleBeanLoader.java b/ebean-api/src/main/java/io/ebean/bean/SingleBeanLoader.java index 4d84ada39..ad4a30b95 100644 --- a/ebean-api/src/main/java/io/ebean/bean/SingleBeanLoader.java +++ b/ebean-api/src/main/java/io/ebean/bean/SingleBeanLoader.java @@ -10,7 +10,7 @@ import java.util.concurrent.locks.ReentrantLock; */ public abstract class SingleBeanLoader implements BeanLoader { - private final ReentrantLock lock = new ReentrantLock(false); + private final ReentrantLock lock = new ReentrantLock(); protected final Database database; diff --git a/ebean-api/src/main/java/io/ebean/common/AbstractBeanCollection.java b/ebean-api/src/main/java/io/ebean/common/AbstractBeanCollection.java index 297c6fb9d..f1a608361 100644 --- a/ebean-api/src/main/java/io/ebean/common/AbstractBeanCollection.java +++ b/ebean-api/src/main/java/io/ebean/common/AbstractBeanCollection.java @@ -16,7 +16,7 @@ abstract class AbstractBeanCollection implements BeanCollection { private static final long serialVersionUID = 3365725236140187588L; - protected final ReentrantLock lock = new ReentrantLock(false); + protected final ReentrantLock lock = new ReentrantLock(); protected boolean readOnly; diff --git a/ebean-api/src/main/java/io/ebean/common/CopyOnFirstWriteList.java b/ebean-api/src/main/java/io/ebean/common/CopyOnFirstWriteList.java index c4acf4f34..0ef9e3fe4 100644 --- a/ebean-api/src/main/java/io/ebean/common/CopyOnFirstWriteList.java +++ b/ebean-api/src/main/java/io/ebean/common/CopyOnFirstWriteList.java @@ -20,7 +20,7 @@ public final class CopyOnFirstWriteList extends AbstractList implements Li private static final long serialVersionUID = 1L; - private final ReentrantLock lock = new ReentrantLock(false); + private final ReentrantLock lock = new ReentrantLock(); /** * The underlying List implementation. diff --git a/ebean-api/src/main/java/io/ebean/config/dbplatform/SequenceIdGenerator.java b/ebean-api/src/main/java/io/ebean/config/dbplatform/SequenceIdGenerator.java index 351d1e8b8..7ddcef6f3 100644 --- a/ebean-api/src/main/java/io/ebean/config/dbplatform/SequenceIdGenerator.java +++ b/ebean-api/src/main/java/io/ebean/config/dbplatform/SequenceIdGenerator.java @@ -26,9 +26,7 @@ public abstract class SequenceIdGenerator implements PlatformIdGenerator { protected static final Logger logger = LoggerFactory.getLogger("io.ebean.SEQ"); - private final ReentrantLock lock = new ReentrantLock(false); - - private final ReentrantLock loadLock = new ReentrantLock(false); + private final ReentrantLock lock = new ReentrantLock(); /** * The actual sequence name. diff --git a/ebean-api/src/main/java/io/ebean/event/ShutdownManager.java b/ebean-api/src/main/java/io/ebean/event/ShutdownManager.java index f01a22b83..f762b0084 100644 --- a/ebean-api/src/main/java/io/ebean/event/ShutdownManager.java +++ b/ebean-api/src/main/java/io/ebean/event/ShutdownManager.java @@ -23,7 +23,7 @@ public final class ShutdownManager { private static final Logger logger = LoggerFactory.getLogger(ShutdownManager.class); - private static final ReentrantLock lock = new ReentrantLock(false); + private static final ReentrantLock lock = new ReentrantLock(); private static final List databases = new ArrayList<>(); diff --git a/ebean-autotune/src/main/java/io/ebeaninternal/server/autotune/service/DefaultAutoTuneService.java b/ebean-autotune/src/main/java/io/ebeaninternal/server/autotune/service/DefaultAutoTuneService.java index 11182ec19..9856e59da 100644 --- a/ebean-autotune/src/main/java/io/ebeaninternal/server/autotune/service/DefaultAutoTuneService.java +++ b/ebean-autotune/src/main/java/io/ebeaninternal/server/autotune/service/DefaultAutoTuneService.java @@ -23,7 +23,7 @@ public class DefaultAutoTuneService implements AutoTuneService { private static final Logger logger = LoggerFactory.getLogger(DefaultAutoTuneService.class); - private final ReentrantLock lock = new ReentrantLock(false); + private final ReentrantLock lock = new ReentrantLock(); private final SpiEbeanServer server; diff --git a/ebean-autotune/src/main/java/io/ebeaninternal/server/autotune/service/ProfileManager.java b/ebean-autotune/src/main/java/io/ebeaninternal/server/autotune/service/ProfileManager.java index dfbdc5800..f334208f9 100644 --- a/ebean-autotune/src/main/java/io/ebeaninternal/server/autotune/service/ProfileManager.java +++ b/ebean-autotune/src/main/java/io/ebeaninternal/server/autotune/service/ProfileManager.java @@ -18,7 +18,7 @@ import java.util.concurrent.locks.ReentrantLock; */ public class ProfileManager implements ProfilingListener { - private final ReentrantLock lock = new ReentrantLock(false); + private final ReentrantLock lock = new ReentrantLock(); private final boolean queryTuningAddVersion; diff --git a/ebean-autotune/src/main/java/io/ebeaninternal/server/autotune/service/ProfileOrigin.java b/ebean-autotune/src/main/java/io/ebeaninternal/server/autotune/service/ProfileOrigin.java index 62feec130..b9935f558 100644 --- a/ebean-autotune/src/main/java/io/ebeaninternal/server/autotune/service/ProfileOrigin.java +++ b/ebean-autotune/src/main/java/io/ebeaninternal/server/autotune/service/ProfileOrigin.java @@ -16,7 +16,7 @@ import java.util.concurrent.locks.ReentrantLock; public class ProfileOrigin { - private final ReentrantLock lock = new ReentrantLock(false); + private final ReentrantLock lock = new ReentrantLock(); private static final long RESET_COUNT = -1000000000L; diff --git a/ebean-autotune/src/main/java/io/ebeaninternal/server/autotune/service/ProfileOriginNodeUsage.java b/ebean-autotune/src/main/java/io/ebeaninternal/server/autotune/service/ProfileOriginNodeUsage.java index dc632e2cd..3ba6afa20 100644 --- a/ebean-autotune/src/main/java/io/ebeaninternal/server/autotune/service/ProfileOriginNodeUsage.java +++ b/ebean-autotune/src/main/java/io/ebeaninternal/server/autotune/service/ProfileOriginNodeUsage.java @@ -21,7 +21,7 @@ public class ProfileOriginNodeUsage { private static final Logger logger = LoggerFactory.getLogger(ProfileOriginNodeUsage.class); - private final ReentrantLock lock = new ReentrantLock(false); + private final ReentrantLock lock = new ReentrantLock(); private final String path; diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/cache/DefaultCacheHolder.java b/ebean-core/src/main/java/io/ebeaninternal/server/cache/DefaultCacheHolder.java index d2d38e7cf..cf15c51fe 100644 --- a/ebean-core/src/main/java/io/ebeaninternal/server/cache/DefaultCacheHolder.java +++ b/ebean-core/src/main/java/io/ebeaninternal/server/cache/DefaultCacheHolder.java @@ -27,7 +27,7 @@ class DefaultCacheHolder { private static final Logger log = LoggerFactory.getLogger("io.ebean.cache.ALL"); - private final ReentrantLock lock = new ReentrantLock(false); + private final ReentrantLock lock = new ReentrantLock(); private final ConcurrentHashMap allCaches = new ConcurrentHashMap<>(); private final ConcurrentHashMap> collectIdCaches = new ConcurrentHashMap<>(); diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/cluster/ClusterManager.java b/ebean-core/src/main/java/io/ebeaninternal/server/cluster/ClusterManager.java index face12592..d2bdaeda7 100644 --- a/ebean-core/src/main/java/io/ebeaninternal/server/cluster/ClusterManager.java +++ b/ebean-core/src/main/java/io/ebeaninternal/server/cluster/ClusterManager.java @@ -18,7 +18,7 @@ public class ClusterManager implements ServerLookup { private static final Logger clusterLogger = LoggerFactory.getLogger("io.ebean.Cluster"); - private final ReentrantLock lock = new ReentrantLock(false); + private final ReentrantLock lock = new ReentrantLock(); private final ConcurrentHashMap serverMap = new ConcurrentHashMap<>(); diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/core/DefaultContainer.java b/ebean-core/src/main/java/io/ebeaninternal/server/core/DefaultContainer.java index a352a5b6d..300acdb2d 100644 --- a/ebean-core/src/main/java/io/ebeaninternal/server/core/DefaultContainer.java +++ b/ebean-core/src/main/java/io/ebeaninternal/server/core/DefaultContainer.java @@ -36,7 +36,7 @@ public class DefaultContainer implements SpiContainer { private static final Logger logger = LoggerFactory.getLogger("io.ebean.internal.DefaultContainer"); - private final ReentrantLock lock = new ReentrantLock(false); + private final ReentrantLock lock = new ReentrantLock(); private final ClusterManager clusterManager; public DefaultContainer(ContainerConfig containerConfig) { diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/core/DefaultServer.java b/ebean-core/src/main/java/io/ebeaninternal/server/core/DefaultServer.java index 1b3291d59..c6665a757 100644 --- a/ebean-core/src/main/java/io/ebeaninternal/server/core/DefaultServer.java +++ b/ebean-core/src/main/java/io/ebeaninternal/server/core/DefaultServer.java @@ -161,7 +161,7 @@ public final class DefaultServer implements SpiServer, SpiEbeanServer { private static final Logger logger = LoggerFactory.getLogger(DefaultServer.class); - private final ReentrantLock lock = new ReentrantLock(false); + private final ReentrantLock lock = new ReentrantLock(); private final DatabaseConfig config; private final String serverName; private final DatabasePlatform databasePlatform; diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/core/InternString.java b/ebean-core/src/main/java/io/ebeaninternal/server/core/InternString.java index c952f8f2d..8a06fc4d4 100644 --- a/ebean-core/src/main/java/io/ebeaninternal/server/core/InternString.java +++ b/ebean-core/src/main/java/io/ebeaninternal/server/core/InternString.java @@ -13,7 +13,7 @@ public final class InternString { private static final HashMap map = new HashMap<>(); - private static final ReentrantLock lock = new ReentrantLock(false); + private static final ReentrantLock lock = new ReentrantLock(); /** * Return the shared instance of this string. diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/idgen/UuidV1RndIdGenerator.java b/ebean-core/src/main/java/io/ebeaninternal/server/idgen/UuidV1RndIdGenerator.java index d9928c422..3d0a39a8a 100644 --- a/ebean-core/src/main/java/io/ebeaninternal/server/idgen/UuidV1RndIdGenerator.java +++ b/ebean-core/src/main/java/io/ebeaninternal/server/idgen/UuidV1RndIdGenerator.java @@ -45,7 +45,7 @@ public class UuidV1RndIdGenerator implements PlatformIdGenerator { private AtomicLong nanoToMilliOffset = new AtomicLong(currentUuidTime()); - private final ReentrantLock lock = new ReentrantLock(false); + private final ReentrantLock lock = new ReentrantLock(); /** diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/loadcontext/DLoadBaseContext.java b/ebean-core/src/main/java/io/ebeaninternal/server/loadcontext/DLoadBaseContext.java index fc2213db5..3040ebcaf 100644 --- a/ebean-core/src/main/java/io/ebeaninternal/server/loadcontext/DLoadBaseContext.java +++ b/ebean-core/src/main/java/io/ebeaninternal/server/loadcontext/DLoadBaseContext.java @@ -14,7 +14,7 @@ import java.util.concurrent.locks.ReentrantLock; */ abstract class DLoadBaseContext { - protected final ReentrantLock lock = new ReentrantLock(false); + protected final ReentrantLock lock = new ReentrantLock(); protected final DLoadContext parent; diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/loadcontext/DLoadBeanContext.java b/ebean-core/src/main/java/io/ebeaninternal/server/loadcontext/DLoadBeanContext.java index f33d597e8..6c796501f 100644 --- a/ebean-core/src/main/java/io/ebeaninternal/server/loadcontext/DLoadBeanContext.java +++ b/ebean-core/src/main/java/io/ebeaninternal/server/loadcontext/DLoadBeanContext.java @@ -120,7 +120,7 @@ class DLoadBeanContext extends DLoadBaseContext implements LoadBeanContext { */ static class LoadBuffer implements BeanLoader, LoadBeanBuffer { - private final ReentrantLock bufferLock = new ReentrantLock(false); + private final ReentrantLock bufferLock = new ReentrantLock(); private final DLoadBeanContext context; private final int batchSize; private final List list; diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/loadcontext/DLoadManyContext.java b/ebean-core/src/main/java/io/ebeaninternal/server/loadcontext/DLoadManyContext.java index 1f1685485..ac846e359 100644 --- a/ebean-core/src/main/java/io/ebeaninternal/server/loadcontext/DLoadManyContext.java +++ b/ebean-core/src/main/java/io/ebeaninternal/server/loadcontext/DLoadManyContext.java @@ -130,7 +130,7 @@ class DLoadManyContext extends DLoadBaseContext implements LoadManyContext { */ static class LoadBuffer implements BeanCollectionLoader, LoadManyBuffer { - private final ReentrantLock lock = new ReentrantLock(false); + private final ReentrantLock lock = new ReentrantLock(); private final PersistenceContext persistenceContext; private final DLoadManyContext context; private final int batchSize; diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/query/CQuery.java b/ebean-core/src/main/java/io/ebeaninternal/server/query/CQuery.java index d1d1e1640..f92960419 100644 --- a/ebean-core/src/main/java/io/ebeaninternal/server/query/CQuery.java +++ b/ebean-core/src/main/java/io/ebeaninternal/server/query/CQuery.java @@ -59,7 +59,7 @@ public class CQuery implements DbReadContext, CancelableQuery, SpiProfileTran private static final CQueryCollectionAddNoop NOOP_ADD = new CQueryCollectionAddNoop(); - private final ReentrantLock lock = new ReentrantLock(false); + private final ReentrantLock lock = new ReentrantLock(); /** * The resultSet rows read. diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/query/CQueryBindCapture.java b/ebean-core/src/main/java/io/ebeaninternal/server/query/CQueryBindCapture.java index c4e7ab5bc..713169640 100644 --- a/ebean-core/src/main/java/io/ebeaninternal/server/query/CQueryBindCapture.java +++ b/ebean-core/src/main/java/io/ebeaninternal/server/query/CQueryBindCapture.java @@ -11,7 +11,7 @@ class CQueryBindCapture implements SpiQueryBindCapture { private static final double multiplier = 1.3d; - private final ReentrantLock lock = new ReentrantLock(false); + private final ReentrantLock lock = new ReentrantLock(); private final CQueryPlanManager manager; private final SpiQueryPlan queryPlan; diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/query/LimitOffsetPagedList.java b/ebean-core/src/main/java/io/ebeaninternal/server/query/LimitOffsetPagedList.java index 6aa3ac38b..a6f506ef6 100644 --- a/ebean-core/src/main/java/io/ebeaninternal/server/query/LimitOffsetPagedList.java +++ b/ebean-core/src/main/java/io/ebeaninternal/server/query/LimitOffsetPagedList.java @@ -16,7 +16,7 @@ public class LimitOffsetPagedList implements PagedList { private final transient SpiEbeanServer server; - private final transient ReentrantLock lock = new ReentrantLock(false); + private final transient ReentrantLock lock = new ReentrantLock(); private final SpiQuery query; diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/querydefn/DefaultOrmQuery.java b/ebean-core/src/main/java/io/ebeaninternal/server/querydefn/DefaultOrmQuery.java index 0bb1b3e45..39d7b350d 100644 --- a/ebean-core/src/main/java/io/ebeaninternal/server/querydefn/DefaultOrmQuery.java +++ b/ebean-core/src/main/java/io/ebeaninternal/server/querydefn/DefaultOrmQuery.java @@ -89,7 +89,7 @@ public class DefaultOrmQuery implements SpiQuery { private static final FetchConfig FETCH_LAZY = new FetchConfig().lazy(); - private final ReentrantLock lock = new ReentrantLock(false); + private final ReentrantLock lock = new ReentrantLock(); private final Class beanType; diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/transaction/DefaultPersistenceContext.java b/ebean-core/src/main/java/io/ebeaninternal/server/transaction/DefaultPersistenceContext.java index 85733cd5b..df92246fa 100644 --- a/ebean-core/src/main/java/io/ebeaninternal/server/transaction/DefaultPersistenceContext.java +++ b/ebean-core/src/main/java/io/ebeaninternal/server/transaction/DefaultPersistenceContext.java @@ -32,7 +32,7 @@ public final class DefaultPersistenceContext implements PersistenceContext { */ private final HashMap, ClassContext> typeCache = new HashMap<>(); - private final ReentrantLock lock = new ReentrantLock(false); + private final ReentrantLock lock = new ReentrantLock(); private int putCount; diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/transaction/DefaultProfileHandler.java b/ebean-core/src/main/java/io/ebeaninternal/server/transaction/DefaultProfileHandler.java index 6d6dbb42e..38f5446d2 100644 --- a/ebean-core/src/main/java/io/ebeaninternal/server/transaction/DefaultProfileHandler.java +++ b/ebean-core/src/main/java/io/ebeaninternal/server/transaction/DefaultProfileHandler.java @@ -66,7 +66,7 @@ public class DefaultProfileHandler implements SpiProfileHandler, Plugin { private final ExecutorService executor; - private final ReentrantLock lock = new ReentrantLock(false); + private final ReentrantLock lock = new ReentrantLock(); private final File dir; diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/type/ScalarTypeArrayList.java b/ebean-core/src/main/java/io/ebeaninternal/server/type/ScalarTypeArrayList.java index 3f540b3e3..736cd94eb 100644 --- a/ebean-core/src/main/java/io/ebeaninternal/server/type/ScalarTypeArrayList.java +++ b/ebean-core/src/main/java/io/ebeaninternal/server/type/ScalarTypeArrayList.java @@ -36,7 +36,7 @@ public class ScalarTypeArrayList extends ScalarTypeArrayBase implements Sc static class Factory implements PlatformArrayTypeFactory { - private final ReentrantLock lock = new ReentrantLock(false); + private final ReentrantLock lock = new ReentrantLock(); private final Map cache = new HashMap<>(); /** diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/type/ScalarTypeArrayListH2.java b/ebean-core/src/main/java/io/ebeaninternal/server/type/ScalarTypeArrayListH2.java index ebad83024..f8b30a7a0 100644 --- a/ebean-core/src/main/java/io/ebeaninternal/server/type/ScalarTypeArrayListH2.java +++ b/ebean-core/src/main/java/io/ebeaninternal/server/type/ScalarTypeArrayListH2.java @@ -27,7 +27,7 @@ class ScalarTypeArrayListH2 extends ScalarTypeArrayList { static class Factory implements PlatformArrayTypeFactory { - private final ReentrantLock lock = new ReentrantLock(false); + private final ReentrantLock lock = new ReentrantLock(); private final Map cache = new HashMap<>(); /** diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/type/ScalarTypeArraySet.java b/ebean-core/src/main/java/io/ebeaninternal/server/type/ScalarTypeArraySet.java index d07f2f795..fd0b7dd41 100644 --- a/ebean-core/src/main/java/io/ebeaninternal/server/type/ScalarTypeArraySet.java +++ b/ebean-core/src/main/java/io/ebeaninternal/server/type/ScalarTypeArraySet.java @@ -36,7 +36,7 @@ public class ScalarTypeArraySet extends ScalarTypeArrayBase implements Scal static class Factory implements PlatformArrayTypeFactory { - private final ReentrantLock lock = new ReentrantLock(false); + private final ReentrantLock lock = new ReentrantLock(); private final Map cache = new HashMap<>(); /** diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/type/ScalarTypeArraySetH2.java b/ebean-core/src/main/java/io/ebeaninternal/server/type/ScalarTypeArraySetH2.java index e67b5e434..cd7f7cf98 100644 --- a/ebean-core/src/main/java/io/ebeaninternal/server/type/ScalarTypeArraySetH2.java +++ b/ebean-core/src/main/java/io/ebeaninternal/server/type/ScalarTypeArraySetH2.java @@ -27,7 +27,7 @@ class ScalarTypeArraySetH2 extends ScalarTypeArraySet { static class Factory implements PlatformArrayTypeFactory { - private final ReentrantLock lock = new ReentrantLock(false); + private final ReentrantLock lock = new ReentrantLock(); private final Map cache = new HashMap<>(); /** diff --git a/ebean-test/src/main/java/io/ebean/test/config/RunOnceMarker.java b/ebean-test/src/main/java/io/ebean/test/config/RunOnceMarker.java index 31f534c24..a812139f4 100644 --- a/ebean-test/src/main/java/io/ebean/test/config/RunOnceMarker.java +++ b/ebean-test/src/main/java/io/ebean/test/config/RunOnceMarker.java @@ -6,7 +6,7 @@ import java.util.concurrent.locks.ReentrantLock; class RunOnceMarker { - private static final ReentrantLock lock = new ReentrantLock(false); + private static final ReentrantLock lock = new ReentrantLock(); private static boolean hasRun; static boolean isRun() { From c3cdecaa60e3600bb33ebaedb7d81065242cfbe2 Mon Sep 17 00:00:00 2001 From: rob bygrave Date: Mon, 7 Dec 2020 10:06:15 +1300 Subject: [PATCH 014/447] Fix test TestSqlUpdateBatch with correct bind type for Postgres --- .../src/test/java/org/tests/update/TestSqlUpdateBatch.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ebean-core/src/test/java/org/tests/update/TestSqlUpdateBatch.java b/ebean-core/src/test/java/org/tests/update/TestSqlUpdateBatch.java index ff440ea96..1cc735fa0 100644 --- a/ebean-core/src/test/java/org/tests/update/TestSqlUpdateBatch.java +++ b/ebean-core/src/test/java/org/tests/update/TestSqlUpdateBatch.java @@ -34,7 +34,7 @@ public class TestSqlUpdateBatch extends BaseTestCase { .setParameter(1, String.valueOf(i)) .addBatch(); delete - .setParameter(1, String.valueOf(i)) + .setParameter(1, i) .addBatch(); } From 1a4377da2917fce5431a40b0d11f56754bf91961 Mon Sep 17 00:00:00 2001 From: rob bygrave Date: Mon, 7 Dec 2020 13:29:47 +1300 Subject: [PATCH 015/447] Improve tests TestQueryForUpdate and TestSoftDeleteBasic --- .../org/tests/basic/TestQueryForUpdate.java | 12 +++++--- .../tests/softdelete/TestSoftDeleteBasic.java | 28 ++++++++++++------- 2 files changed, 26 insertions(+), 14 deletions(-) diff --git a/ebean-core/src/test/java/org/tests/basic/TestQueryForUpdate.java b/ebean-core/src/test/java/org/tests/basic/TestQueryForUpdate.java index ef8469f35..ee224ccd5 100644 --- a/ebean-core/src/test/java/org/tests/basic/TestQueryForUpdate.java +++ b/ebean-core/src/test/java/org/tests/basic/TestQueryForUpdate.java @@ -27,11 +27,15 @@ public class TestQueryForUpdate extends BaseTestCase { ResetBasicData.reset(); - Query query = DB.find(Customer.class) - .forUpdate() - .order().desc("id"); + Query query; + try (final Transaction transaction = DB.beginTransaction()) { + query = DB.find(Customer.class) + .forUpdate() + .order().desc("id"); + + query.findList(); + } - query.findList(); if (isSqlServer()) { assertThat(sqlOf(query)).contains("with (updlock)"); } else if (isPostgres()) { diff --git a/ebean-core/src/test/java/org/tests/softdelete/TestSoftDeleteBasic.java b/ebean-core/src/test/java/org/tests/softdelete/TestSoftDeleteBasic.java index 738366b6f..590585404 100644 --- a/ebean-core/src/test/java/org/tests/softdelete/TestSoftDeleteBasic.java +++ b/ebean-core/src/test/java/org/tests/softdelete/TestSoftDeleteBasic.java @@ -12,6 +12,7 @@ import org.tests.model.softdelete.EBasicNoSDChild; import org.tests.model.softdelete.EBasicSDChild; import org.tests.model.softdelete.EBasicSoftDelete; +import java.util.Arrays; import java.util.List; import static java.util.Collections.singletonList; @@ -173,13 +174,17 @@ public class TestSoftDeleteBasic extends BaseTestCase { .query(); List list = query.findList(); - assertSql(query).contains("t0.deleted = false"); - // Make sure that query includes that the child mustn't've been deleted - assertSql(query).contains("u1.deleted = false"); + if (isMySql() || isMariaDB()) { + assertSql(query).contains("t0.deleted = 0"); + assertSql(query).contains("u1.deleted = 0"); + } else { + assertSql(query).contains("t0.deleted = false"); + // Make sure that query includes that the child mustn't've been deleted + assertSql(query).contains("u1.deleted = false"); + } assertThat(list).hasSize(0); // Cleanup created entity - query.delete(); DB.deleteAllPermanent(singletonList(child)); DB.deleteAllPermanent(singletonList(bean)); } @@ -205,13 +210,17 @@ public class TestSoftDeleteBasic extends BaseTestCase { List list = query.findList(); // Make sure that query includes that the child mustn't've been deleted - assertSql(query).contains("u1.deleted = false"); - assertSql(query).contains("u2.deleted = false"); + if (isMySql() || isMariaDB()) { + assertSql(query).contains("u1.deleted = 0"); + assertSql(query).contains("u2.deleted = 0"); + } else { + assertSql(query).contains("u1.deleted = false"); + assertSql(query).contains("u2.deleted = false"); + } assertThat(list).hasSize(0); // Cleanup created entity - query.delete(); - DB.deleteAllPermanent(singletonList(child)); + DB.deleteAllPermanent(Arrays.asList(child, secondChild)); DB.deleteAllPermanent(singletonList(bean)); } @@ -242,8 +251,7 @@ public class TestSoftDeleteBasic extends BaseTestCase { assertThat(list).hasSize(1); // Cleanup created entity - query.delete(); - DB.deleteAllPermanent(singletonList(child)); + DB.deleteAllPermanent(Arrays.asList(child, secondChild)); DB.deleteAllPermanent(singletonList(bean)); } From dbe273bb5674a882f10d60d28905ec7a89926964 Mon Sep 17 00:00:00 2001 From: rob bygrave Date: Mon, 7 Dec 2020 17:14:03 +1300 Subject: [PATCH 016/447] #2123 - Modify BackgroundExecutor API - add scheduleWithFixedDelay() and mark executePeriodically() as deprecated --- .../java/io/ebean/BackgroundExecutor.java | 41 ++++++++++++++++++- .../service/DefaultAutoTuneService.java | 2 +- .../server/cache/DefaultServerCache.java | 2 +- .../server/deploy/BeanDescriptorManager.java | 2 +- .../executor/DefaultBackgroundExecutor.java | 12 +++++- 5 files changed, 54 insertions(+), 5 deletions(-) diff --git a/ebean-api/src/main/java/io/ebean/BackgroundExecutor.java b/ebean-api/src/main/java/io/ebean/BackgroundExecutor.java index 94900c249..537fb7f36 100644 --- a/ebean-api/src/main/java/io/ebean/BackgroundExecutor.java +++ b/ebean-api/src/main/java/io/ebean/BackgroundExecutor.java @@ -37,6 +37,7 @@ public interface BackgroundExecutor { void execute(Runnable task); /** + * Deprecated - migrate to scheduleWithFixedDelay(). * Execute a task periodically with a fixed delay between each execution. *

* For example, execute a runnable every minute. @@ -45,18 +46,56 @@ public interface BackgroundExecutor { * That is, this method has the same behaviour characteristics as * {@link ScheduledExecutorService#scheduleWithFixedDelay(Runnable, long, long, TimeUnit)} */ + @Deprecated void executePeriodically(Runnable task, long delay, TimeUnit unit); /** + * Deprecated - migrate to scheduleWithFixedDelay(). * Execute a task periodically additionally with an initial delay different from delay. */ + @Deprecated void executePeriodically(Runnable task, long initialDelay, long delay, TimeUnit unit); + /** + * Execute a task periodically with a given delay. + * + * @param task the task to execute + * @param initialDelay the time to delay first execution + * @param delay the delay between the termination of one + * execution and the commencement of the next + * @param unit the time unit of the initialDelay and delay parameters + * @return a ScheduledFuture representing pending completion of + * the series of repeated tasks. The future's {@link + * Future#get() get()} method will never return normally, + * and will throw an exception upon task cancellation or + * abnormal termination of a task execution. + */ + ScheduledFuture scheduleWithFixedDelay(Runnable task, long initialDelay, long delay, TimeUnit unit); + + /** + * Execute a task periodically with a given period. + * + *

If any execution of this task takes longer than its period, then + * subsequent executions may start late, but will not concurrently + * execute. + * + * @param task the task to execute + * @param initialDelay the time to delay first execution + * @param period the period between successive executions + * @param unit the time unit of the initialDelay and period parameters + * @return a ScheduledFuture representing pending completion of + * the series of repeated tasks. The future's {@link + * Future#get() get()} method will never return normally, + * and will throw an exception upon task cancellation or + * abnormal termination of a task execution. + */ + ScheduledFuture scheduleAtFixedRate(Runnable task, long initialDelay, long period, TimeUnit unit); + /** * Schedules a Runnable for one-shot action that becomes enabled after the given delay. * * @return a ScheduledFuture representing pending completion of the task and - * whose get() method will return null upon completion + * whose get() method will return null upon completion */ ScheduledFuture schedule(Runnable task, long delay, TimeUnit unit); diff --git a/ebean-autotune/src/main/java/io/ebeaninternal/server/autotune/service/DefaultAutoTuneService.java b/ebean-autotune/src/main/java/io/ebeaninternal/server/autotune/service/DefaultAutoTuneService.java index 9856e59da..be2033695 100644 --- a/ebean-autotune/src/main/java/io/ebeaninternal/server/autotune/service/DefaultAutoTuneService.java +++ b/ebean-autotune/src/main/java/io/ebeaninternal/server/autotune/service/DefaultAutoTuneService.java @@ -77,7 +77,7 @@ public class DefaultAutoTuneService implements AutoTuneService { loadTuningFile(); if (isRuntimeTuningUpdates()) { // periodically gather and update query tuning - server.getBackgroundExecutor().executePeriodically(new ProfilingUpdate(), profilingUpdateFrequency, TimeUnit.SECONDS); + server.getBackgroundExecutor().scheduleWithFixedDelay(new ProfilingUpdate(), profilingUpdateFrequency, profilingUpdateFrequency, TimeUnit.SECONDS); } } } diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/cache/DefaultServerCache.java b/ebean-core/src/main/java/io/ebeaninternal/server/cache/DefaultServerCache.java index d0c44de1e..41ec3e2c9 100644 --- a/ebean-core/src/main/java/io/ebeaninternal/server/cache/DefaultServerCache.java +++ b/ebean-core/src/main/java/io/ebeaninternal/server/cache/DefaultServerCache.java @@ -86,7 +86,7 @@ public class DefaultServerCache implements ServerCache { // default to trimming the cache every 60 seconds long trimFreqSecs = (trimFrequency == 0) ? 60 : trimFrequency; - executor.executePeriodically(trim, trimFreqSecs, TimeUnit.SECONDS); + executor.scheduleWithFixedDelay(trim, trimFreqSecs, trimFreqSecs, TimeUnit.SECONDS); } @Override diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/deploy/BeanDescriptorManager.java b/ebean-core/src/main/java/io/ebeaninternal/server/deploy/BeanDescriptorManager.java index 77b3c6c04..0cb5deeaa 100644 --- a/ebean-core/src/main/java/io/ebeaninternal/server/deploy/BeanDescriptorManager.java +++ b/ebean-core/src/main/java/io/ebeaninternal/server/deploy/BeanDescriptorManager.java @@ -203,7 +203,7 @@ public class BeanDescriptorManager implements BeanDescriptorMap { * Run periodic trim of query plans. */ public void scheduleBackgroundTrim() { - backgroundExecutor.executePeriodically(this::trimQueryPlans, 117L, 60L, TimeUnit.SECONDS); + backgroundExecutor.scheduleWithFixedDelay(this::trimQueryPlans, 117L, 60L, TimeUnit.SECONDS); } private void trimQueryPlans() { diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/executor/DefaultBackgroundExecutor.java b/ebean-core/src/main/java/io/ebeaninternal/server/executor/DefaultBackgroundExecutor.java index c93cbfac7..28bb50765 100644 --- a/ebean-core/src/main/java/io/ebeaninternal/server/executor/DefaultBackgroundExecutor.java +++ b/ebean-core/src/main/java/io/ebeaninternal/server/executor/DefaultBackgroundExecutor.java @@ -82,7 +82,7 @@ public class DefaultBackgroundExecutor implements SpiBackgroundExecutor { @Override public void executePeriodically(Runnable task, long delay, TimeUnit unit) { - executePeriodically(task, delay, delay, unit); + executor.scheduleWithFixedDelay(wrapMDC(task), delay, delay, unit); } @Override @@ -90,6 +90,16 @@ public class DefaultBackgroundExecutor implements SpiBackgroundExecutor { executor.scheduleWithFixedDelay(wrapMDC(task), initialDelay, delay, unit); } + @Override + public ScheduledFuture scheduleWithFixedDelay(Runnable task, long initialDelay, long delay, TimeUnit unit) { + return executor.scheduleWithFixedDelay(wrapMDC(task), initialDelay, delay, unit); + } + + @Override + public ScheduledFuture scheduleAtFixedRate(Runnable task, long initialDelay, long delay, TimeUnit unit) { + return executor.scheduleAtFixedRate(wrapMDC(task), initialDelay, delay, unit); + } + @Override public ScheduledFuture schedule(Runnable task, long delay, TimeUnit unit) { return executor.schedule(wrapMDC(task), delay, unit); From d68f477e8eed5f6d9986dc9b9805f446ae6f4377 Mon Sep 17 00:00:00 2001 From: rob bygrave Date: Mon, 7 Dec 2020 21:53:03 +1300 Subject: [PATCH 017/447] #2120 - DbEnumValue without database constraint --- ebean-api/pom.xml | 2 +- .../server/type/DefaultTypeManager.java | 76 ++----------------- .../type/ScalarTypeEnumWithMapping.java | 15 +++- .../server/type/DefaultTypeManagerTest.java | 43 +++++++---- .../org/tests/model/array/VarcharEnum.java | 2 +- 5 files changed, 49 insertions(+), 89 deletions(-) diff --git a/ebean-api/pom.xml b/ebean-api/pom.xml index 472d240f9..22e0fd394 100644 --- a/ebean-api/pom.xml +++ b/ebean-api/pom.xml @@ -55,7 +55,7 @@ io.ebean ebean-annotation - 6.13 + 6.14-SNAPSHOT diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/type/DefaultTypeManager.java b/ebean-core/src/main/java/io/ebeaninternal/server/type/DefaultTypeManager.java index c41d1121d..7a2d82baa 100644 --- a/ebean-core/src/main/java/io/ebeaninternal/server/type/DefaultTypeManager.java +++ b/ebean-core/src/main/java/io/ebeaninternal/server/type/DefaultTypeManager.java @@ -256,7 +256,6 @@ public final class DefaultTypeManager implements TypeManager { * Load custom scalar types registered via ExtraTypeFactory and ServiceLoader. */ private void loadTypesFromProviders(DatabaseConfig config, Object objectMapper) { - ServiceLoader factories = ServiceLoader.load(ExtraTypeFactory.class); Iterator iterator = factories.iterator(); if (iterator.hasNext()) { @@ -291,7 +290,6 @@ public final class DefaultTypeManager implements TypeManager { @SuppressWarnings({"rawtypes", "unchecked"}) @Override public void addEnumType(ScalarType scalarType, Class enumClass) { - Set> mappedClasses = new HashSet<>(); mappedClasses.add(enumClass); for (Object value : EnumSet.allOf(enumClass).toArray()) { @@ -360,20 +358,16 @@ public final class DefaultTypeManager implements TypeManager { @Override public ScalarType getArrayScalarType(Class type, DbArray dbArray, Type genericType, boolean nullable) { - Type valueType = getValueType(genericType); if (type.equals(List.class)) { return getArrayScalarTypeList(valueType, nullable); - } else if (type.equals(Set.class)) { return getArrayScalarTypeSet(valueType, nullable); - } else { throw new IllegalStateException("Type [" + type + "] not supported for @DbArray"); } } - @SuppressWarnings("rawtypes") private ScalarType getArrayScalarTypeSet(Type valueType, boolean nullable) { if (arrayTypeSetFactory != null) { if (isEnumType(valueType)) { @@ -385,7 +379,6 @@ public final class DefaultTypeManager implements TypeManager { return new ScalarTypeJsonSet.Varchar(getDocType(valueType), nullable); } - @SuppressWarnings("rawtypes") private ScalarType getArrayScalarTypeList(Type valueType, boolean nullable) { if (arrayTypeListFactory != null) { if (isEnumType(valueType)) { @@ -407,10 +400,8 @@ public final class DefaultTypeManager implements TypeManager { @Override public ScalarType getJsonScalarType(DeployBeanProperty prop, int dbType, int dbLength) { - Class type = prop.getPropertyType(); Type genericType = prop.getGenericType(); - boolean hasJacksonAnnotations = objectMapperPresent && checkJacksonAnnotations(prop); if (type.equals(List.class)) { @@ -421,7 +412,6 @@ public final class DefaultTypeManager implements TypeManager { return createJsonObjectMapperType(prop, dbType, docType); } } - if (type.equals(Set.class)) { DocPropertyType docType = getDocType(genericType); if (!hasJacksonAnnotations && isValueTypeSimple(genericType)) { @@ -430,7 +420,6 @@ public final class DefaultTypeManager implements TypeManager { return createJsonObjectMapperType(prop, dbType, docType); } } - if (type.equals(Map.class)) { if (!hasJacksonAnnotations && isMapValueTypeObject(genericType)) { return ScalarTypeJsonMap.typeFor(postgres, dbType); @@ -438,7 +427,6 @@ public final class DefaultTypeManager implements TypeManager { return createJsonObjectMapperType(prop, dbType, DocPropertyType.OBJECT); } } - if (objectMapperPresent) { if (type.equals(JsonNode.class)) { switch (dbType) { @@ -455,7 +443,6 @@ public final class DefaultTypeManager implements TypeManager { } } } - return createJsonObjectMapperType(prop, dbType, DocPropertyType.OBJECT); } @@ -510,11 +497,9 @@ public final class DefaultTypeManager implements TypeManager { *

* Used for java.util.Date and java.util.Calendar which can be mapped to * different jdbcTypes in a single system. - *

*/ @Override public ScalarType getScalarType(Class type, int jdbcType) { - // File is a special Lob so check for that first if (File.class.equals(type)) { return fileType; @@ -554,10 +539,8 @@ public final class DefaultTypeManager implements TypeManager { * Kind of special case because these map multiple jdbc types to single Java * types - like String - Varchar, LongVarchar, Clob. For this reason I check * for the specific Lob types first before looking for a matching type. - *

*/ private ScalarType getLobTypes(int jdbcType) { - return getScalarType(jdbcType); } @@ -601,14 +584,10 @@ public final class DefaultTypeManager implements TypeManager { * Create the Mapping of Enum fields to DB values using EnumValue annotations. *

* Return null if the EnumValue annotations are not present/used. - *

*/ private ScalarTypeEnum createEnumScalarType2(Class enumType) { - boolean integerType = true; - Map nameValueMap = new LinkedHashMap<>(); - Field[] fields = enumType.getDeclaredFields(); for (Field field : fields) { EnumValue enumValue = AnnotationUtil.get(field, EnumValue.class); @@ -624,8 +603,7 @@ public final class DefaultTypeManager implements TypeManager { // Not using EnumValue here return null; } - - return createEnumScalarType(enumType, nameValueMap, integerType, 0); + return createEnumScalarType(enumType, nameValueMap, integerType, 0, true); } /** @@ -635,17 +613,14 @@ public final class DefaultTypeManager implements TypeManager { * such as A,I,N rather than the ACTIVE, INACTIVE, NEW. So there really needs * to be a mapping from the nicely named enumeration values to the typically * much shorter codes used in the DB. - *

*/ @Override public ScalarType createEnumScalarType(Class> enumType, EnumType type) { - ScalarType scalarType = getScalarType(enumType); if (scalarType instanceof ScalarTypeWrapper) { // no override or further mapping required return scalarType; } - ScalarTypeEnum scalarEnum = (ScalarTypeEnum)scalarType; if (scalarEnum != null && !scalarEnum.isOverrideBy(type)) { if (type != null && !scalarEnum.isCompatible(type)) { @@ -653,7 +628,6 @@ public final class DefaultTypeManager implements TypeManager { } return scalarEnum; } - scalarEnum = createEnumScalarTypePerExtentions(enumType); if (scalarEnum == null) { // use JPA normal Enum type (without mapping) @@ -665,33 +639,27 @@ public final class DefaultTypeManager implements TypeManager { private ScalarTypeEnum createEnumScalarTypePerSpec(Class enumType, EnumType type) { if (type == null) { - - if(defaultEnumType == EnumType.ORDINAL) { + if (defaultEnumType == EnumType.ORDINAL) { return new ScalarTypeEnumStandard.OrdinalEnum(enumType); - } else { return new ScalarTypeEnumStandard.StringEnum(enumType); } - } else if (type == EnumType.ORDINAL) { return new ScalarTypeEnumStandard.OrdinalEnum(enumType); - } else { return new ScalarTypeEnumStandard.StringEnum(enumType); } } private ScalarTypeEnum createEnumScalarTypePerExtentions(Class> enumType) { - Method[] methods = enumType.getMethods(); for (Method method : methods) { DbEnumValue dbValue = AnnotationUtil.get(method, DbEnumValue.class); if (dbValue != null) { boolean integerValues = DbEnumType.INTEGER == dbValue.storage(); - return createEnumScalarTypeDbValue(enumType, method, integerValues, dbValue.length()); + return createEnumScalarTypeDbValue(enumType, method, integerValues, dbValue.length(), dbValue.withConstraint()); } } - // look for EnumValue annotations instead return createEnumScalarType2(enumType); } @@ -702,10 +670,8 @@ public final class DefaultTypeManager implements TypeManager { * Return null if the EnumValue annotations are not present/used. *

*/ - private ScalarTypeEnum createEnumScalarTypeDbValue(Class> enumType, Method method, boolean integerType, int length) { - + private ScalarTypeEnum createEnumScalarTypeDbValue(Class> enumType, Method method, boolean integerType, int length, boolean withConstraint) { Map nameValueMap = new LinkedHashMap<>(); - Enum[] enumConstants = enumType.getEnumConstants(); for (Enum enumConstant : enumConstants) { try { @@ -719,8 +685,7 @@ public final class DefaultTypeManager implements TypeManager { // Not using EnumValue here return null; } - - return createEnumScalarType(enumType, nameValueMap, integerType, length); + return createEnumScalarType(enumType, nameValueMap, integerType, length, withConstraint); } /** @@ -728,27 +693,20 @@ public final class DefaultTypeManager implements TypeManager { * length create the ScalarType for the Enum. */ @SuppressWarnings({"unchecked", "rawtypes"}) - private ScalarTypeEnum createEnumScalarType(Class enumType, Map nameValueMap, boolean integerType, int dbColumnLength) { - + private ScalarTypeEnum createEnumScalarType(Class enumType, Map nameValueMap, boolean integerType, int dbColumnLength, boolean withConstraint) { EnumToDbValueMap beanDbMap = EnumToDbValueMap.create(integerType); - int maxValueLen = 0; - for (Map.Entry entry : nameValueMap.entrySet()) { String name = entry.getKey(); String value = entry.getValue(); - maxValueLen = Math.max(maxValueLen, value.length()); - Object enumValue = Enum.valueOf(enumType, name.trim()); beanDbMap.add(enumValue, value, name.trim()); } - if (dbColumnLength == 0 && !integerType) { dbColumnLength = maxValueLen; } - - return new ScalarTypeEnumWithMapping(beanDbMap, enumType, dbColumnLength); + return new ScalarTypeEnumWithMapping(beanDbMap, enumType, dbColumnLength, withConstraint); } /** @@ -760,10 +718,8 @@ public final class DefaultTypeManager implements TypeManager { *

*/ private void initialiseCustomScalarTypes(BootupClasses bootupClasses) { - for (Class> cls : bootupClasses.getScalarTypes()) { try { - ScalarType scalarType; if (objectMapper == null) { scalarType = cls.newInstance(); @@ -776,9 +732,7 @@ public final class DefaultTypeManager implements TypeManager { scalarType = cls.newInstance(); } } - addCustomType(scalarType); - } catch (Exception e) { String msg = "Error loading ScalarType [" + cls.getName() + "]"; logger.error(msg, e); @@ -801,30 +755,23 @@ public final class DefaultTypeManager implements TypeManager { @SuppressWarnings({"unchecked", "rawtypes"}) private void initialiseScalarConverters(BootupClasses bootupClasses) { - List>> foundTypes = bootupClasses.getScalarConverters(); - for (Class> foundType : foundTypes) { try { - Class[] paramTypes = TypeReflectHelper.getParams(foundType, ScalarTypeConverter.class); if (paramTypes.length != 2) { throw new IllegalStateException("Expected 2 generics paramtypes but got: " + Arrays.toString(paramTypes)); } - Class logicalType = paramTypes[0]; Class persistType = paramTypes[1]; - ScalarType wrappedType = getScalarType(persistType); if (wrappedType == null) { throw new IllegalStateException("Could not find ScalarType for: " + paramTypes[1]); } - ScalarTypeConverter converter = foundType.newInstance(); ScalarTypeWrapper stw = new ScalarTypeWrapper(logicalType, wrappedType, converter); logger.debug("Register ScalarTypeWrapper from {} -> {} using:{}", logicalType, persistType, foundType); add(stw); - } catch (Exception e) { logger.error("Error registering ScalarTypeConverter [" + foundType.getName() + "]", e); } @@ -833,30 +780,23 @@ public final class DefaultTypeManager implements TypeManager { @SuppressWarnings({"unchecked", "rawtypes"}) private void initialiseAttributeConverters(BootupClasses bootupClasses) { - List>> foundTypes = bootupClasses.getAttributeConverters(); - for (Class> foundType : foundTypes) { try { - Class[] paramTypes = TypeReflectHelper.getParams(foundType, AttributeConverter.class); if (paramTypes.length != 2) { throw new IllegalStateException("Expected 2 generics paramtypes but got: " + Arrays.toString(paramTypes)); } - Class logicalType = paramTypes[0]; Class persistType = paramTypes[1]; - ScalarType wrappedType = getScalarType(persistType); if (wrappedType == null) { throw new IllegalStateException("Could not find ScalarType for: " + paramTypes[1]); } - AttributeConverter converter = foundType.newInstance(); ScalarTypeWrapper stw = new ScalarTypeWrapper(logicalType, wrappedType, new AttributeConverterAdapter(converter)); logger.debug("Register ScalarTypeWrapper from {} -> {} using:{}", logicalType, persistType, foundType); add(stw); - } catch (Exception e) { logger.error("Error registering AttributeConverter [" + foundType.getName() + "]", e); } @@ -875,12 +815,10 @@ public final class DefaultTypeManager implements TypeManager { jsonNodeVarchar = new ScalarTypeJsonNode.Varchar(mapper); jsonNodeJson = jsonNodeClob; // Default for non-Postgres databases jsonNodeJsonb = jsonNodeClob; // Default for non-Postgres databases - if (isPostgres(config.getDatabasePlatform())) { jsonNodeJson = new ScalarTypeJsonNodePostgres.JSON(mapper); jsonNodeJsonb = new ScalarTypeJsonNodePostgres.JSONB(mapper); } - // add as default mapping for JsonNode (when not annotated with @DbJson etc) typeMap.put(JsonNode.class, jsonNodeJson); } diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/type/ScalarTypeEnumWithMapping.java b/ebean-core/src/main/java/io/ebeaninternal/server/type/ScalarTypeEnumWithMapping.java index d8ab07e72..598889f49 100644 --- a/ebean-core/src/main/java/io/ebeaninternal/server/type/ScalarTypeEnumWithMapping.java +++ b/ebean-core/src/main/java/io/ebeaninternal/server/type/ScalarTypeEnumWithMapping.java @@ -20,13 +20,20 @@ public class ScalarTypeEnumWithMapping extends ScalarTypeEnumStandard.EnumBase i private final int length; + private final boolean withConstraint; + /** * Create with an explicit mapping of bean to database values. */ - public ScalarTypeEnumWithMapping(EnumToDbValueMap beanDbMap, Class enumType, int length) { + public ScalarTypeEnumWithMapping(EnumToDbValueMap beanDbMap, Class enumType, int length, boolean withConstraint) { super(enumType, false, beanDbMap.getDbType()); this.beanDbMap = beanDbMap; this.length = length; + this.withConstraint = withConstraint; + } + + public ScalarTypeEnumWithMapping(EnumToDbValueMap beanDbMap, Class enumType, int length) { + this(beanDbMap, enumType, length, true); } @Override @@ -49,6 +56,9 @@ public class ScalarTypeEnumWithMapping extends ScalarTypeEnumStandard.EnumBase i */ @Override public Set getDbCheckConstraintValues() { + if (!withConstraint) { + return null; + } LinkedHashSet values = new LinkedHashSet(); Iterator it = beanDbMap.dbValues(); while (it.hasNext()) { @@ -64,9 +74,6 @@ public class ScalarTypeEnumWithMapping extends ScalarTypeEnumStandard.EnumBase i /** * Return the DB column length for storing the enum value. - *

- * This is for enum's mapped to strings. - *

*/ @Override public int getLength() { diff --git a/ebean-core/src/test/java/io/ebeaninternal/server/type/DefaultTypeManagerTest.java b/ebean-core/src/test/java/io/ebeaninternal/server/type/DefaultTypeManagerTest.java index e64bc2b7a..950a805fd 100644 --- a/ebean-core/src/test/java/io/ebeaninternal/server/type/DefaultTypeManagerTest.java +++ b/ebean-core/src/test/java/io/ebeaninternal/server/type/DefaultTypeManagerTest.java @@ -1,10 +1,13 @@ package io.ebeaninternal.server.type; -import io.ebean.config.ServerConfig; +import io.ebean.config.DatabaseConfig; import io.ebean.config.dbplatform.postgres.PostgresPlatform; import io.ebean.core.type.ScalarType; import io.ebeaninternal.server.core.bootup.BootupClasses; import org.junit.Test; +import org.tests.model.array.IntEnum; +import org.tests.model.array.VarcharEnum; +import org.tests.model.basic.Car; import javax.persistence.EnumType; import java.time.DayOfWeek; @@ -17,7 +20,7 @@ import static org.junit.Assert.assertTrue; public class DefaultTypeManagerTest { private DefaultTypeManager create() { - ServerConfig serverConfig = new ServerConfig(); + DatabaseConfig serverConfig = new DatabaseConfig(); serverConfig.setDatabasePlatform(new PostgresPlatform()); BootupClasses bootupClasses = new BootupClasses(); return new DefaultTypeManager(serverConfig, bootupClasses); @@ -25,7 +28,6 @@ public class DefaultTypeManagerTest { @Test public void isIntegerType() { - DefaultTypeManager typeManager = create(); assertTrue(typeManager.isIntegerType("1")); @@ -42,7 +44,6 @@ public class DefaultTypeManagerTest { @Test public void enumDayMonth_builtIn_overrideAsString() { - DefaultTypeManager typeManager = create(); ScalarType type = typeManager.createEnumScalarType(Month.class, null); @@ -51,7 +52,6 @@ public class DefaultTypeManagerTest { // mapped explicitly as JPA EnumType.STRING type = typeManager.createEnumScalarType(Month.class, EnumType.STRING); assertThat(type).isInstanceOf(ScalarTypeEnumStandard.StringEnum.class).as("override built in type"); - try { typeManager.createEnumScalarType(Month.class, EnumType.ORDINAL); assertThat(true).isFalse().as("never get here"); @@ -63,17 +63,14 @@ public class DefaultTypeManagerTest { @Test public void enumMonth_builtIn_overrideAsOrdinal() { - DefaultTypeManager typeManager = create(); // mapped explicitly as JPA EnumType.STRING ScalarType type = typeManager.createEnumScalarType(Month.class, EnumType.ORDINAL); assertThat(type).isInstanceOf(ScalarTypeEnumStandard.OrdinalEnum.class).as("override built in type"); - try { typeManager.createEnumScalarType(Month.class, EnumType.STRING); assertThat(true).isFalse().as("never get here"); - } catch (IllegalStateException e) { assertThat(e.getMessage()).contains("It is mapped using 2 different modes when only one is supported"); } @@ -81,7 +78,6 @@ public class DefaultTypeManagerTest { @Test public void enumDayOfWeek_builtIn_overrideAsString() { - DefaultTypeManager typeManager = create(); ScalarType type = typeManager.createEnumScalarType(DayOfWeek.class, null); @@ -90,11 +86,9 @@ public class DefaultTypeManagerTest { // mapped explicitly as JPA EnumType.STRING type = typeManager.createEnumScalarType(DayOfWeek.class, EnumType.STRING); assertThat(type).isInstanceOf(ScalarTypeEnumStandard.StringEnum.class).as("override built in type"); - try { typeManager.createEnumScalarType(DayOfWeek.class, EnumType.ORDINAL); assertThat(true).isFalse().as("never get here"); - } catch (IllegalStateException e) { assertThat(e.getMessage()).contains("It is mapped using 2 different modes when only one is supported"); } @@ -102,19 +96,40 @@ public class DefaultTypeManagerTest { @Test public void enumDayOfWeek_builtIn_overrideAsOrdinal() { - DefaultTypeManager typeManager = create(); // mapped explicitly as JPA EnumType.STRING ScalarType type = typeManager.createEnumScalarType(DayOfWeek.class, EnumType.ORDINAL); assertThat(type).isInstanceOf(ScalarTypeEnumStandard.OrdinalEnum.class).as("override built in type"); - try { typeManager.createEnumScalarType(DayOfWeek.class, EnumType.STRING); assertThat(true).isFalse().as("never get here"); - } catch (IllegalStateException e) { assertThat(e.getMessage()).contains("It is mapped using 2 different modes when only one is supported"); } } + + @Test + public void createEnumScalarTypePerExtentions() { + DefaultTypeManager typeManager = create(); + + ScalarType type = typeManager.createEnumScalarType(VarcharEnum.class, EnumType.ORDINAL); + assertThat(type).isInstanceOf(ScalarTypeEnumWithMapping.class); + // withConstraint false + assertThat(((ScalarTypeEnumWithMapping) type).getDbCheckConstraintValues()).isNull(); + + type = typeManager.createEnumScalarType(IntEnum.class, EnumType.ORDINAL); + assertThat(type).isInstanceOf(ScalarTypeEnumWithMapping.class); + ScalarTypeEnumWithMapping enumWithMapping = (ScalarTypeEnumWithMapping) type; + // withConstraint true + assertThat(enumWithMapping.getDbCheckConstraintValues()).hasSize(3); + assertThat(enumWithMapping.getDbCheckConstraintValues()).contains("100", "101", "102"); + + type = typeManager.createEnumScalarType(Car.Size.class, EnumType.ORDINAL); + assertThat(type).isInstanceOf(ScalarTypeEnumWithMapping.class); + enumWithMapping = (ScalarTypeEnumWithMapping) type; + // withConstraint true + assertThat(enumWithMapping.getDbCheckConstraintValues()).hasSize(2); + assertThat(enumWithMapping.getDbCheckConstraintValues()).contains("'L'", "'S'"); + } } diff --git a/ebean-core/src/test/java/org/tests/model/array/VarcharEnum.java b/ebean-core/src/test/java/org/tests/model/array/VarcharEnum.java index 2bbc64daf..f5698d009 100644 --- a/ebean-core/src/test/java/org/tests/model/array/VarcharEnum.java +++ b/ebean-core/src/test/java/org/tests/model/array/VarcharEnum.java @@ -6,7 +6,7 @@ import io.ebean.annotation.DbEnumValue; public enum VarcharEnum { ZERO, ONE, TWO; - @DbEnumValue(storage = DbEnumType.VARCHAR) + @DbEnumValue(storage = DbEnumType.VARCHAR, withConstraint = false) public String dbValue() { return "xXx" + name(); } From 7389a8b344db290fe3108ea52918cd517db85d9a Mon Sep 17 00:00:00 2001 From: rob bygrave Date: Mon, 7 Dec 2020 22:46:04 +1300 Subject: [PATCH 018/447] #2124 - ENH: Add name() attribute to @DbArray, @DbJson, @DbJsonB, @DbMap --- ebean-api/pom.xml | 2 +- .../server/deploy/parse/AnnotationFields.java | 4 ++++ .../server/deploy/parse/AnnotationParser.java | 12 +++++++----- .../java/org/tests/json/TestDbJson_Jackson3.java | 2 +- .../test/java/org/tests/json/TestDbJson_List.java | 2 +- .../java/org/tests/model/json/EBasicJsonList.java | 2 +- 6 files changed, 15 insertions(+), 9 deletions(-) diff --git a/ebean-api/pom.xml b/ebean-api/pom.xml index 22e0fd394..945d263f0 100644 --- a/ebean-api/pom.xml +++ b/ebean-api/pom.xml @@ -55,7 +55,7 @@ io.ebean ebean-annotation - 6.14-SNAPSHOT + 6.15 diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/deploy/parse/AnnotationFields.java b/ebean-core/src/main/java/io/ebeaninternal/server/deploy/parse/AnnotationFields.java index 0a1bc1ff4..aafbfa182 100644 --- a/ebean-core/src/main/java/io/ebeaninternal/server/deploy/parse/AnnotationFields.java +++ b/ebean-core/src/main/java/io/ebeaninternal/server/deploy/parse/AnnotationFields.java @@ -311,19 +311,23 @@ public class AnnotationFields extends AnnotationParser { DbMap dbMap = get(prop, DbMap.class); if (dbMap != null) { util.setDbMap(prop, dbMap); + setColumnName(prop, dbMap.name()); } DbJson dbJson = get(prop, DbJson.class); if (dbJson != null) { util.setDbJsonType(prop, dbJson); + setColumnName(prop, dbJson.name()); } else { DbJsonB dbJsonB = get(prop, DbJsonB.class); if (dbJsonB != null) { util.setDbJsonBType(prop, dbJsonB); + setColumnName(prop, dbJsonB.name()); } } DbArray dbArray = get(prop, DbArray.class); if (dbArray != null) { util.setDbArray(prop, dbArray); + setColumnName(prop, dbArray.name()); } } diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/deploy/parse/AnnotationParser.java b/ebean-core/src/main/java/io/ebeaninternal/server/deploy/parse/AnnotationParser.java index 8646aa62b..64851135d 100644 --- a/ebean-core/src/main/java/io/ebeaninternal/server/deploy/parse/AnnotationParser.java +++ b/ebean-core/src/main/java/io/ebeaninternal/server/deploy/parse/AnnotationParser.java @@ -99,11 +99,7 @@ public abstract class AnnotationParser extends AnnotationBase { } void readColumn(Column columnAnn, DeployBeanProperty prop) { - - if (!isEmpty(columnAnn.name())) { - prop.setDbColumn(databasePlatform.convertQuotedIdentifiers(columnAnn.name())); - } - + setColumnName(prop, columnAnn.name()); prop.setDbInsertable(columnAnn.insertable()); prop.setDbUpdateable(columnAnn.updatable()); prop.setNullable(columnAnn.nullable()); @@ -125,6 +121,12 @@ public abstract class AnnotationParser extends AnnotationBase { } } + protected void setColumnName(DeployBeanProperty prop, String name) { + if (!isEmpty(name)) { + prop.setDbColumn(databasePlatform.convertQuotedIdentifiers(name)); + } + } + /** * Return true if the validation groups are {@link Default} (respectively empty) * can be applied to DDL generation. diff --git a/ebean-core/src/test/java/org/tests/json/TestDbJson_Jackson3.java b/ebean-core/src/test/java/org/tests/json/TestDbJson_Jackson3.java index 336946ab2..74f004bca 100644 --- a/ebean-core/src/test/java/org/tests/json/TestDbJson_Jackson3.java +++ b/ebean-core/src/test/java/org/tests/json/TestDbJson_Jackson3.java @@ -71,6 +71,6 @@ public class TestDbJson_Jackson3 extends BaseTestCase { final List sql = LoggedSql.stop(); assertThat(sql).hasSize(1); - assertThat(sql.get(0)).contains("update ebasic_json_list set name=?, bean_set=?, bean_list=?, plain_bean=?, version=? where id=?"); + assertThat(sql.get(0)).contains("update ebasic_json_list set name=?, beans=?, bean_list=?, plain_bean=?, version=? where id=?"); } } diff --git a/ebean-core/src/test/java/org/tests/json/TestDbJson_List.java b/ebean-core/src/test/java/org/tests/json/TestDbJson_List.java index 3686e8f16..0582818db 100644 --- a/ebean-core/src/test/java/org/tests/json/TestDbJson_List.java +++ b/ebean-core/src/test/java/org/tests/json/TestDbJson_List.java @@ -154,7 +154,7 @@ public class TestDbJson_List extends BaseTestCase { List sql = LoggedSqlCollector.stop(); // we don't update the phone numbers (as they are not dirty) - assertSql(sql.get(0)).contains("update ebasic_json_list set bean_set=?, bean_list=?, bean_map=?, plain_bean=?, version=? where id=? and version=?"); + assertSql(sql.get(0)).contains("update ebasic_json_list set beans=?, bean_list=?, bean_map=?, plain_bean=?, version=? where id=? and version=?"); } @Test diff --git a/ebean-core/src/test/java/org/tests/model/json/EBasicJsonList.java b/ebean-core/src/test/java/org/tests/model/json/EBasicJsonList.java index cf34d5826..22b32e3e1 100644 --- a/ebean-core/src/test/java/org/tests/model/json/EBasicJsonList.java +++ b/ebean-core/src/test/java/org/tests/model/json/EBasicJsonList.java @@ -22,7 +22,7 @@ public class EBasicJsonList { String name; - @DbJson(length = 700) + @DbJson(length = 700, name = "beans") Set beanSet; @DbJsonB From b623e19daebf57677fed3aa1ce7d1059af2f48aa Mon Sep 17 00:00:00 2001 From: rob bygrave Date: Mon, 7 Dec 2020 22:47:43 +1300 Subject: [PATCH 019/447] update git ignore --- .gitignore | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/.gitignore b/.gitignore index 1b88dd830..861a33064 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,4 @@ *.autofetch -*create-all.sql -*drop-all.sql *.orig .classpath .project @@ -12,7 +10,6 @@ ebean-autotune.xml ebean-profiling*.xml /db /mydb.db -!src/test/ddl-review/*.sql profiling/ # Intellij project files @@ -20,4 +17,4 @@ profiling/ *.ipr *.iws .idea/ -*uuid.state \ No newline at end of file +*uuid.state From 0b24d635adf65c7295ee9c9a0c20582f40ae8fcd Mon Sep 17 00:00:00 2001 From: rob bygrave Date: Mon, 7 Dec 2020 22:48:32 +1300 Subject: [PATCH 020/447] Tests only - update ddl review --- .../src/test/ddl-review/h2-create-all.sql | 5188 ++++++++++++++++ .../src/test/ddl-review/h2-drop-all.sql | 1959 ++++++ .../test/ddl-review/mariadb-create-all.sql | 4909 +++++++++++++++ .../src/test/ddl-review/mariadb-drop-all.sql | 1868 ++++++ .../src/test/ddl-review/mysql-create-all.sql | 5008 ++++++++++++++++ .../src/test/ddl-review/mysql-drop-all.sql | 1867 ++++++ .../src/test/ddl-review/oracle-create-all.sql | 4826 +++++++++++++++ .../src/test/ddl-review/oracle-drop-all.sql | 1821 ++++++ .../src/test/ddl-review/pg-create-all.sql | 5236 ++++++++++++++++ .../src/test/ddl-review/pg-drop-all.sql | 1957 ++++++ .../test/ddl-review/sqlserver-create-all.sql | 5308 +++++++++++++++++ .../test/ddl-review/sqlserver-drop-all.sql | 2234 +++++++ 12 files changed, 42181 insertions(+) create mode 100644 ebean-core/src/test/ddl-review/h2-create-all.sql create mode 100644 ebean-core/src/test/ddl-review/h2-drop-all.sql create mode 100644 ebean-core/src/test/ddl-review/mariadb-create-all.sql create mode 100644 ebean-core/src/test/ddl-review/mariadb-drop-all.sql create mode 100644 ebean-core/src/test/ddl-review/mysql-create-all.sql create mode 100644 ebean-core/src/test/ddl-review/mysql-drop-all.sql create mode 100644 ebean-core/src/test/ddl-review/oracle-create-all.sql create mode 100644 ebean-core/src/test/ddl-review/oracle-drop-all.sql create mode 100644 ebean-core/src/test/ddl-review/pg-create-all.sql create mode 100644 ebean-core/src/test/ddl-review/pg-drop-all.sql create mode 100644 ebean-core/src/test/ddl-review/sqlserver-create-all.sql create mode 100644 ebean-core/src/test/ddl-review/sqlserver-drop-all.sql diff --git a/ebean-core/src/test/ddl-review/h2-create-all.sql b/ebean-core/src/test/ddl-review/h2-create-all.sql new file mode 100644 index 000000000..dc5f4879f --- /dev/null +++ b/ebean-core/src/test/ddl-review/h2-create-all.sql @@ -0,0 +1,5188 @@ +-- Generated by ebean unknown at 2020-12-07T09:40:50.461215Z +create table asimple_bean ( + id bigint generated by default as identity not null, + name varchar(255), + constraint pk_asimple_bean primary key (id) +); + +create table bar ( + bar_type varchar(31) not null, + bar_id integer generated by default as identity not null, + foo_id integer not null, + version integer not null, + constraint pk_bar primary key (bar_id) +); + +create table block ( + case_type integer(31) not null, + id bigint generated by default as identity not null, + name varchar(255), + version bigint not null, + notes varchar(255), + constraint pk_block primary key (id) +); + +create table oto_account ( + id bigint generated by default as identity not null, + name varchar(255), + version bigint not null, + when_created timestamp not null, + when_modified timestamp not null, + constraint pk_oto_account primary key (id) +); + +create table acl ( + id bigint generated by default as identity not null, + name varchar(255), + constraint pk_acl primary key (id) +); + +create table acl_container_relation ( + id bigint generated by default as identity not null, + container_id bigint not null, + acl_entry_id bigint not null, + constraint pk_acl_container_relation primary key (id) +); + +create table addr ( + id bigint generated by default as identity not null, + employee_id bigint, + name varchar(255), + address_line1 varchar(255), + address_line2 varchar(255), + city varchar(255), + version bigint not null, + constraint pk_addr primary key (id) +); + +create table address ( + oid bigint generated by default as identity not null, + street varchar(255), + version integer not null, + constraint pk_address primary key (oid) +); + +create table o_address ( + id integer generated by default as identity not null, + line_1 varchar(100), + line_2 varchar(100), + city varchar(100), + cretime timestamp, + country_code varchar(2), + updtime timestamp not null, + constraint pk_o_address primary key (id) +); + +create table album ( + id bigint generated by default as identity not null, + name varchar(255), + cover_id bigint, + deleted boolean default false not null, + created_at timestamp not null, + last_update timestamp not null, + constraint uq_album_cover_id unique (cover_id), + constraint pk_album primary key (id) +); + +create table animal ( + species varchar(255) not null, + id bigint generated by default as identity not null, + shelter_id bigint, + version bigint not null, + name varchar(255), + registration_number varchar(255), + date_of_birth date, + dog_size varchar(255), + constraint pk_animal primary key (id) +); + +create table animal_shelter ( + id bigint generated by default as identity not null, + name varchar(255), + version bigint not null, + constraint pk_animal_shelter primary key (id) +); + +create table article ( + id integer generated by default as identity not null, + name varchar(255), + author varchar(255), + cretime timestamp not null, + updtime timestamp not null, + version bigint not null, + constraint pk_article primary key (id) +); + +create table attribute ( + option_type integer(31) not null, + id integer generated by default as identity not null, + attribute_holder_id integer, + cretime timestamp not null, + updtime timestamp not null, + version bigint not null, + constraint pk_attribute primary key (id) +); + +create table attribute_holder ( + id integer generated by default as identity not null, + cretime timestamp not null, + updtime timestamp not null, + version bigint not null, + constraint pk_attribute_holder primary key (id) +); + +create table audit_log ( + id bigint generated by default as identity (start with 1000 cache 100) not null, + description varchar(255), + modified_description varchar(255), + constraint pk_audit_log primary key (id) +); + +create table bbookmark ( + id integer generated by default as identity not null, + bookmark_reference varchar(255), + user_id integer, + constraint pk_bbookmark primary key (id) +); + +create table bbookmark_org ( + id integer generated by default as identity not null, + name varchar(255), + constraint pk_bbookmark_org primary key (id) +); + +create table bbookmark_user ( + id integer generated by default as identity not null, + name varchar(255), + password varchar(255), + email_address varchar(255), + country varchar(255), + org_id integer, + constraint pk_bbookmark_user primary key (id) +); + +create table bsimple_with_gen ( + id integer generated by default as identity not null, + name varchar(255), + constraint pk_bsimple_with_gen primary key (id) +); + +create table bsite ( + id uuid not null, + name varchar(255), + constraint pk_bsite primary key (id) +); + +create table bsite_user_a ( + site_id uuid not null, + user_id uuid not null, + access_level integer, + version bigint not null, + constraint ck_bsite_user_a_access_level check ( access_level in (0,1,2)), + constraint pk_bsite_user_a primary key (site_id,user_id) +); + +create table bsite_user_b ( + site uuid not null, + usr uuid not null, + access_level integer, + constraint ck_bsite_user_b_access_level check ( access_level in (0,1,2)), + constraint pk_bsite_user_b primary key (site,usr) +); + +create table bsite_user_c ( + site_uid uuid not null, + user_uid uuid not null, + access_level integer, + constraint ck_bsite_user_c_access_level check ( access_level in (0,1,2)), + constraint pk_bsite_user_c primary key (site_uid,user_uid) +); + +create table bsite_user_d ( + site_id uuid not null, + user_id uuid not null, + access_level integer, + version bigint not null, + constraint ck_bsite_user_d_access_level check ( access_level in (0,1,2)) +); + +create table bsite_user_e ( + site_id uuid not null, + user_id uuid not null, + access_level integer, + constraint ck_bsite_user_e_access_level check ( access_level in (0,1,2)) +); + +create table buser ( + id uuid not null, + name varchar(255), + constraint pk_buser primary key (id) +); + +create table bwith_qident ( + id integer generated by default as identity not null, + "Name" varchar(191), + "CODE" varchar(255), + last_updated timestamp not null, + constraint uq_bwith_qident_name unique ("Name"), + constraint pk_bwith_qident primary key (id) +); + +create table basic_draftable_bean ( + id bigint generated by default as identity not null, + name varchar(255), + version bigint not null, + when_created timestamp not null, + when_modified timestamp not null, + constraint pk_basic_draftable_bean primary key (id) +); + +create table basic_draftable_bean_draft ( + id bigint generated by default as identity not null, + name varchar(255), + version bigint not null, + when_created timestamp not null, + when_modified timestamp not null, + constraint pk_basic_draftable_bean_draft primary key (id) +); + +create table basic_joda_entity ( + id bigint generated by default as identity not null, + name varchar(255), + period varchar(50), + local_date date, + created timestamp not null, + updated timestamp not null, + version timestamp not null, + constraint pk_basic_joda_entity primary key (id) +); + +create table bean_with_time_zone ( + id bigint generated by default as identity not null, + name varchar(255), + timezone varchar(20), + constraint pk_bean_with_time_zone primary key (id) +); + +create table drel_booking ( + id bigint not null, + booking_uid bigint, + agent_invoice bigint, + client_invoice bigint, + version integer not null, + constraint uq_drel_booking_booking_uid unique (booking_uid), + constraint uq_drel_booking_agent_invoice unique (agent_invoice), + constraint uq_drel_booking_client_invoice unique (client_invoice), + constraint pk_drel_booking primary key (id) +); +create sequence drel_booking_seq increment by 1; + +create table bw_bean ( + id bigint generated by default as identity not null, + name varchar(255), + flags integer not null, + version bigint not null, + constraint pk_bw_bean primary key (id) +); + +create table cepcategory ( + id bigint generated by default as identity not null, + name varchar(255), + version bigint not null, + constraint pk_cepcategory primary key (id) +); + +create table cepproduct ( + id bigint generated by default as identity not null, + name varchar(255), + version bigint not null, + constraint pk_cepproduct primary key (id) +); + +create table cepproduct_category ( + customer_id bigint not null, + address_id bigint not null, + category_id bigint not null, + product_id bigint not null, + priority integer +); + +create table ciaddress ( + id bigint generated by default as identity not null, + street_id bigint, + constraint pk_ciaddress primary key (id) +); + +create table cicustomer_parent ( + dtype integer(31) not null, + id bigint generated by default as identity not null, + address_id bigint, + notes varchar(255), + constraint pk_cicustomer_parent primary key (id) +); + +create table cistreet_parent ( + dtype integer(31) not null, + id bigint generated by default as identity not null, + name varchar(255), + num varchar(255), + constraint pk_cistreet_parent primary key (id) +); + +create table cinh_ref ( + id integer generated by default as identity not null, + ref_id integer, + cretime timestamp not null, + updtime timestamp not null, + version bigint not null, + constraint pk_cinh_ref primary key (id) +); + +create table cinh_root ( + dtype varchar(3) not null, + id integer generated by default as identity not null, + license_number varchar(255), + cretime timestamp not null, + updtime timestamp not null, + version bigint not null, + driver varchar(255), + notes varchar(255), + action varchar(255), + constraint pk_cinh_root primary key (id) +); + +create table ckey_assoc ( + id integer generated by default as identity not null, + assoc_one varchar(255), + constraint pk_ckey_assoc primary key (id) +); + +create table ckey_detail ( + id integer generated by default as identity not null, + something varchar(255), + one_key integer, + two_key varchar(127), + constraint pk_ckey_detail primary key (id) +); + +create table ckey_parent ( + one_key integer not null, + two_key varchar(127) not null, + name varchar(255), + assoc_id integer, + version integer not null, + constraint pk_ckey_parent primary key (one_key,two_key) +); + +create table coone ( + id bigint generated by default as identity not null, + name varchar(255), + constraint pk_coone primary key (id) +); + +create table coone_many ( + id bigint generated by default as identity not null, + coone_id bigint not null, + name varchar(255), + deleted boolean default false not null, + constraint pk_coone_many primary key (id) +); + +create table coroot ( + id bigint generated by default as identity not null, + name varchar(255), + one_id bigint, + constraint uq_coroot_one_id unique (one_id), + constraint pk_coroot primary key (id) +); + +create table calculation_result ( + id integer generated by default as identity not null, + charge double not null, + product_configuration_id integer, + group_configuration_id integer, + constraint pk_calculation_result primary key (id) +); + +create table cao_bean ( + x_cust_id integer not null, + x_type_id integer not null, + description varchar(255), + version bigint not null, + constraint pk_cao_bean primary key (x_cust_id,x_type_id) +); + +create table sp_car_car ( + id bigint not null, + name varchar(255), + version integer not null, + constraint pk_sp_car_car primary key (id) +); +create sequence sp_car_car_seq increment by 1; + +create table sp_car_car_wheels ( + car bigint not null, + wheel bigint not null, + constraint pk_sp_car_car_wheels primary key (car,wheel) +); + +create table sp_car_car_doors ( + car bigint not null, + door bigint not null, + constraint pk_sp_car_car_doors primary key (car,door) +); + +create table sa_car ( + id bigint not null, + brand varchar(255), + sold integer not null, + version integer not null, + constraint pk_sa_car primary key (id) +); +create sequence sa_car_seq increment by 1; + +create table car_accessory ( + id integer generated by default as identity not null, + name varchar(255), + fuse_id bigint not null, + car_id integer, + cretime timestamp not null, + updtime timestamp not null, + version bigint not null, + constraint pk_car_accessory primary key (id) +); + +create table car_fuse ( + id bigint generated by default as identity not null, + location_code varchar(255), + constraint pk_car_fuse primary key (id) +); + +create table category ( + id bigint generated by default as identity not null, + name varchar(255), + surveyobjectid bigint, + sequence_number integer not null, + constraint pk_category primary key (id) +); + +create table e_save_test_d ( + id bigint generated by default as identity not null, + parent_id bigint, + test_property boolean default false not null, + version bigint not null, + constraint uq_e_save_test_d_parent_id unique (parent_id), + constraint pk_e_save_test_d primary key (id) +); + +create table child_person ( + identifier integer generated by default as identity not null, + name varchar(255), + age integer, + some_bean_id integer, + parent_identifier integer, + family_name varchar(255), + address varchar(255), + constraint pk_child_person primary key (identifier) +); + +create table cke_client ( + cod_cpny integer not null, + cod_client varchar(100) not null, + username varchar(100) not null, + notes varchar(255), + constraint pk_cke_client primary key (cod_cpny,cod_client) +); + +create table cke_user ( + username varchar(100) not null, + cod_cpny integer not null, + name varchar(255), + constraint pk_cke_user primary key (username,cod_cpny) +); + +create table class_super ( + dtype varchar(31) not null, + sid bigint generated by default as identity not null, + constraint pk_class_super primary key (sid) +); + +create table class_super_monkey ( + class_super_sid bigint not null, + monkey_mid bigint not null, + constraint uq_class_super_monkey_mid unique (monkey_mid), + constraint pk_class_super_monkey primary key (class_super_sid,monkey_mid) +); + +create table configuration ( + type varchar(21) not null, + id integer generated by default as identity not null, + name varchar(255), + configurations_id integer, + group_name varchar(255), + product_name varchar(255), + constraint pk_configuration primary key (id) +); + +create table configurations ( + id integer generated by default as identity not null, + name varchar(255), + constraint pk_configurations primary key (id) +); + +create table contact ( + id integer generated by default as identity not null, + first_name varchar(127), + last_name varchar(127), + phone varchar(255), + mobile varchar(255), + email varchar(255), + is_member boolean default false not null, + customer_id integer not null, + group_id integer, + cretime timestamp not null, + updtime timestamp not null, + constraint pk_contact primary key (id) +); + +create table contact_group ( + id integer generated by default as identity not null, + name varchar(255), + cretime timestamp not null, + updtime timestamp not null, + version bigint not null, + constraint pk_contact_group primary key (id) +); + +create table contact_note ( + id integer generated by default as identity not null, + contact_id integer, + title varchar(255), + note clob, + cretime timestamp not null, + updtime timestamp not null, + version bigint not null, + constraint pk_contact_note primary key (id) +); + +create table contract ( + id bigint generated by default as identity not null, + name varchar(255), + constraint pk_contract primary key (id) +); + +create table contract_costs ( + id bigint generated by default as identity not null, + status varchar(255), + position_id bigint not null, + constraint pk_contract_costs primary key (id) +); + +create table c_conversation ( + id bigint generated by default as identity not null, + title varchar(255), + isopen boolean default false not null, + group_id bigint, + version bigint not null, + when_created timestamp not null, + when_modified timestamp not null, + constraint pk_c_conversation primary key (id) +); + +create table o_country ( + code varchar(2) not null, + name varchar(60), + constraint pk_o_country primary key (code) +); + +create table cover ( + id bigint generated by default as identity not null, + s3_url varchar(255), + deleted boolean default false not null, + constraint pk_cover primary key (id) +); + +create table o_customer ( + id integer generated by default as identity not null, + status varchar(1), + name varchar(40) not null, + smallnote varchar(100), + anniversary date, + billing_address_id integer, + shipping_address_id integer, + cretime timestamp not null, + updtime timestamp not null, + version bigint not null, + constraint ck_o_customer_status check ( status in ('N','A','I')), + constraint pk_o_customer primary key (id) +); +comment on table o_customer is 'Holds external customers'; +comment on column o_customer.status is 'status of the customer'; +comment on column o_customer.smallnote is 'Short notes regarding the customer'; +comment on column o_customer.anniversary is 'Join date of the customer'; + +create table dcredit ( + id bigint generated by default as identity not null, + credit varchar(255), + constraint pk_dcredit primary key (id) +); + +create table dcredit_drol ( + dcredit_id bigint not null, + drol_id bigint not null, + constraint pk_dcredit_drol primary key (dcredit_id,drol_id) +); + +create table dexh_entity ( + oid bigint generated by default as identity not null, + exhange varchar(255), + an_enum_type varchar(255), + last_updated timestamp not null, + constraint pk_dexh_entity primary key (oid) +); + +create table dint_parent ( + type integer(31) not null, + id bigint generated by default as identity not null, + val integer, + more varchar(255), + constraint pk_dint_parent primary key (id) +); + +create table dmachine ( + id bigint generated by default as identity not null, + name varchar(255), + organisation_id bigint, + version bigint not null, + constraint pk_dmachine primary key (id) +); + +create table d_machine_aux_use ( + id bigint generated by default as identity not null, + machine_id bigint not null, + name varchar(255), + edate date, + use_secs bigint not null, + fuel decimal(16,3), + version bigint not null, + constraint pk_d_machine_aux_use primary key (id) +); + +create table d_machine_stats ( + id bigint generated by default as identity not null, + machine_id bigint not null, + edate date, + total_kms bigint not null, + hours bigint not null, + rate decimal(16,3), + cost decimal(16,3), + version bigint not null, + constraint pk_d_machine_stats primary key (id) +); + +create table d_machine_use ( + id bigint generated by default as identity not null, + machine_id bigint not null, + edate date, + distance_kms bigint not null, + time_secs bigint not null, + fuel decimal(9,3), + version bigint not null, + constraint pk_d_machine_use primary key (id) +); + +create table dorg ( + id bigint generated by default as identity not null, + name varchar(255), + version bigint not null, + constraint pk_dorg primary key (id) +); + +create table dperson ( + id bigint generated by default as identity not null, + first_name varchar(255), + last_name varchar(255), + salary decimal(16,3), + constraint pk_dperson primary key (id) +); + +create table drol ( + id bigint generated by default as identity not null, + name varchar(255), + constraint pk_drol primary key (id) +); + +create table drot ( + id bigint generated by default as identity not null, + name varchar(255), + constraint pk_drot primary key (id) +); + +create table drot_drol ( + drot_id bigint not null, + drol_id bigint not null, + constraint pk_drot_drol primary key (drot_id,drol_id) +); + +create table rawinherit_data ( + id bigint generated by default as identity not null, + val integer, + constraint pk_rawinherit_data primary key (id) +); + +create table data_container ( + id uuid not null, + content varchar(255), + constraint pk_data_container primary key (id) +); + +create table dc_detail ( + id bigint generated by default as identity not null, + master_id bigint, + description varchar(255), + version bigint not null, + constraint pk_dc_detail primary key (id) +); + +create table dc_master ( + id bigint generated by default as identity not null, + name varchar(255), + version bigint not null, + constraint pk_dc_master primary key (id) +); + +create table defaults_model ( + id integer generated by default as identity not null, + constraint pk_defaults_model primary key (id) +); + +create table defaults_model_draft ( + id integer generated by default as identity not null, + constraint pk_defaults_model_draft primary key (id) +); + +create table dfk_cascade ( + id bigint generated by default as identity not null, + name varchar(255), + one_id bigint, + constraint pk_dfk_cascade primary key (id) +); + +create table dfk_cascade_one ( + id bigint generated by default as identity not null, + name varchar(255), + constraint pk_dfk_cascade_one primary key (id) +); + +create table dfk_none ( + id bigint generated by default as identity not null, + name varchar(255), + one_id bigint, + constraint pk_dfk_none primary key (id) +); + +create table dfk_none_via_join ( + id bigint generated by default as identity not null, + name varchar(255), + one_id bigint, + constraint pk_dfk_none_via_join primary key (id) +); + +create table dfk_none_via_mto_m ( + id bigint generated by default as identity not null, + name varchar(255), + constraint pk_dfk_none_via_mto_m primary key (id) +); + +create table dfk_none_via_mto_m_dfk_one ( + dfk_none_via_mto_m_id bigint not null, + dfk_one_id bigint not null, + constraint pk_dfk_none_via_mto_m_dfk_one primary key (dfk_none_via_mto_m_id,dfk_one_id) +); + +create table dfk_one ( + id bigint generated by default as identity not null, + name varchar(255), + constraint pk_dfk_one primary key (id) +); + +create table dfk_set_null ( + id bigint generated by default as identity not null, + name varchar(255), + one_id bigint, + constraint pk_dfk_set_null primary key (id) +); + +create table doc ( + id bigint generated by default as identity not null, + name varchar(255), + version bigint not null, + when_created timestamp not null, + when_modified timestamp not null, + constraint pk_doc primary key (id) +); + +create table doc_link ( + doc_id bigint not null, + link_id bigint not null, + constraint pk_doc_link primary key (doc_id,link_id) +); + +create table doc_link_draft ( + doc_id bigint not null, + link_id bigint not null, + constraint pk_doc_link_draft primary key (doc_id,link_id) +); + +create table doc_draft ( + id bigint generated by default as identity not null, + name varchar(255), + version bigint not null, + when_created timestamp not null, + when_modified timestamp not null, + constraint pk_doc_draft primary key (id) +); + +create table document ( + id bigint generated by default as identity not null, + title varchar(127), + body varchar(255), + organisation_id bigint, + version bigint not null, + when_created timestamp not null, + when_modified timestamp not null, + constraint uq_document_title unique (title), + constraint pk_document primary key (id) +); + +create table document_draft ( + id bigint generated by default as identity not null, + title varchar(127), + body varchar(255), + when_publish timestamp, + organisation_id bigint, + version bigint not null, + when_created timestamp not null, + when_modified timestamp not null, + constraint uq_document_draft_title unique (title), + constraint pk_document_draft primary key (id) +); + +create table document_media ( + id bigint generated by default as identity not null, + document_id bigint, + name varchar(255), + description varchar(255), + version bigint not null, + when_created timestamp not null, + when_modified timestamp not null, + constraint pk_document_media primary key (id) +); + +create table document_media_draft ( + id bigint generated by default as identity not null, + document_id bigint, + name varchar(255), + description varchar(255), + version bigint not null, + when_created timestamp not null, + when_modified timestamp not null, + constraint pk_document_media_draft primary key (id) +); + +create table sp_car_door ( + id bigint not null, + name varchar(255), + version integer not null, + constraint pk_sp_car_door primary key (id) +); +create sequence sp_car_door_seq increment by 1; + +create table earray_bean ( + id bigint generated by default as identity not null, + foo integer, + name varchar(255), + phone_numbers array, + uids array not null, + other_ids array, + doubs array, + statuses array, + vc_enums array, + int_enums array, + status2 array, + version bigint not null, + constraint ck_earray_bean_foo check ( foo in (100,101,102)), + constraint pk_earray_bean primary key (id) +); + +create table earray_set_bean ( + id bigint generated by default as identity not null, + name varchar(255), + phone_numbers array, + uids array, + other_ids array, + doubs array, + version bigint not null, + constraint pk_earray_set_bean primary key (id) +); + +create table e_basic ( + id integer generated by default as identity not null, + status varchar(1), + name varchar(127), + description varchar(255), + some_date timestamp, + constraint ck_e_basic_status check ( status in ('N','A','I')), + constraint pk_e_basic primary key (id) +); + +create table ebasic_change_log ( + id bigint generated by default as identity not null, + name varchar(20), + short_description varchar(50), + long_description varchar(100), + who_created varchar(255) not null, + who_modified varchar(255) not null, + when_created timestamp not null, + when_modified timestamp not null, + version bigint not null, + constraint pk_ebasic_change_log primary key (id) +); + +create table ebasic_clob ( + id bigint generated by default as identity not null, + name varchar(255), + title varchar(255), + description clob, + last_update timestamp not null, + constraint pk_ebasic_clob primary key (id) +); + +create table ebasic_clob_fetch_eager ( + id bigint generated by default as identity not null, + name varchar(255), + title varchar(255), + description clob, + last_update timestamp not null, + constraint pk_ebasic_clob_fetch_eager primary key (id) +); + +create table ebasic_clob_no_ver ( + id bigint generated by default as identity not null, + name varchar(255), + description clob, + constraint pk_ebasic_clob_no_ver primary key (id) +); + +create table e_basicenc ( + id integer generated by default as identity not null, + name varchar(255), + description varbinary(80), + dob varbinary(20), + status varbinary(20), + last_update timestamp, + constraint pk_e_basicenc primary key (id) +); + +create table e_basicenc_bin ( + id integer generated by default as identity not null, + name varchar(255), + description varchar(255), + data blob, + some_time varbinary(255), + last_update timestamp not null, + constraint pk_e_basicenc_bin primary key (id) +); + +create table e_basicenc_client ( + id bigint generated by default as identity not null, + name varchar(255), + description varbinary(80), + dob varbinary(20), + status varbinary(20), + version bigint not null, + constraint pk_e_basicenc_client primary key (id) +); + +create table e_basicenc_relate ( + id bigint generated by default as identity not null, + name varchar(255), + other_id integer, + constraint pk_e_basicenc_relate primary key (id) +); + +create table e_basic_enum_id ( + status varchar(1) not null, + name varchar(255), + description varchar(255), + constraint ck_e_basic_enum_id_status check ( status in ('N','A','I')), + constraint pk_e_basic_enum_id primary key (status) +); + +create table e_basic_eni ( + id integer generated by default as identity not null, + status integer, + name varchar(255), + description varchar(255), + some_date timestamp, + constraint ck_e_basic_eni_status check ( status in (1,2,3)), + constraint pk_e_basic_eni primary key (id) +); + +create table ebasic_hstore ( + id bigint generated by default as identity not null, + name varchar(255), + map varchar(800), + version bigint not null, + constraint pk_ebasic_hstore primary key (id) +); + +create table ebasic_json_jackson ( + id bigint generated by default as identity not null, + name varchar(255), + value_set varchar(700), + value_list clob, + value_map varchar(700), + plain_value varchar(500), + version bigint not null, + constraint pk_ebasic_json_jackson primary key (id) +); + +create table ebasic_json_jackson2 ( + id bigint generated by default as identity not null, + name varchar(255), + value_set varchar(700), + value_list clob, + value_map varchar(700), + plain_value varchar(500), + version bigint not null, + constraint pk_ebasic_json_jackson2 primary key (id) +); + +create table ebasic_json_jackson3 ( + id bigint generated by default as identity not null, + name varchar(255), + plain_value varchar(500), + version bigint not null, + constraint pk_ebasic_json_jackson3 primary key (id) +); + +create table ebasic_json_list ( + id bigint generated by default as identity not null, + name varchar(255), + beans varchar(700), + bean_list clob, + bean_map varchar(700), + plain_bean varchar(500), + flags varchar(50), + tags varchar(100), + version bigint not null, + constraint pk_ebasic_json_list primary key (id) +); + +create table ebasic_json_map ( + id bigint generated by default as identity not null, + name varchar(255), + content clob, + version bigint not null, + constraint pk_ebasic_json_map primary key (id) +); + +create table ebasic_json_map_blob ( + id bigint generated by default as identity not null, + name varchar(255), + content blob, + version bigint not null, + constraint pk_ebasic_json_map_blob primary key (id) +); + +create table ebasic_json_map_clob ( + id bigint generated by default as identity not null, + name varchar(255), + content clob, + version bigint not null, + constraint pk_ebasic_json_map_clob primary key (id) +); + +create table ebasic_json_map_detail ( + id bigint generated by default as identity not null, + owner_id bigint, + name varchar(255), + content clob, + version bigint not null, + constraint pk_ebasic_json_map_detail primary key (id) +); + +create table ebasic_json_map_json_b ( + id bigint generated by default as identity not null, + name varchar(255), + content clob, + version bigint not null, + constraint pk_ebasic_json_map_json_b primary key (id) +); + +create table ebasic_json_map_varchar ( + id bigint generated by default as identity not null, + name varchar(255), + content varchar(3000), + version bigint not null, + constraint pk_ebasic_json_map_varchar primary key (id) +); + +create table ebasic_json_node ( + id bigint generated by default as identity not null, + name varchar(255), + content clob, + version bigint not null, + constraint pk_ebasic_json_node primary key (id) +); + +create table ebasic_json_node_blob ( + id bigint generated by default as identity not null, + name varchar(255), + content blob, + version bigint not null, + constraint pk_ebasic_json_node_blob primary key (id) +); + +create table ebasic_json_node_json_b ( + id bigint generated by default as identity not null, + name varchar(255), + content clob, + version bigint not null, + constraint pk_ebasic_json_node_json_b primary key (id) +); + +create table ebasic_json_node_varchar ( + id bigint generated by default as identity not null, + name varchar(255), + content varchar(1000), + version bigint not null, + constraint pk_ebasic_json_node_varchar primary key (id) +); + +create table ebasic_json_unmapped ( + id bigint generated by default as identity not null, + name varchar(255), + version bigint not null, + constraint pk_ebasic_json_unmapped primary key (id) +); + +create table e_basic_ndc ( + id integer generated by default as identity not null, + name varchar(255), + constraint pk_e_basic_ndc primary key (id) +); + +create table ebasic_no_sdchild ( + id bigint generated by default as identity not null, + owner_id bigint not null, + child_name varchar(255), + amount bigint not null, + version bigint not null, + constraint pk_ebasic_no_sdchild primary key (id) +); + +create table ebasic_sdchild ( + id bigint generated by default as identity not null, + owner_id bigint not null, + child_name varchar(255), + amount bigint not null, + version bigint not null, + deleted boolean default false not null, + constraint pk_ebasic_sdchild primary key (id) +); + +create table ebasic_soft_delete ( + id bigint generated by default as identity not null, + name varchar(255), + description varchar(255), + version bigint not null, + deleted boolean default false not null, + constraint pk_ebasic_soft_delete primary key (id) +); + +create table e_basicver ( + id integer generated by default as identity not null, + name varchar(255), + description varchar(255), + other varchar(255), + last_update timestamp not null, + constraint pk_e_basicver primary key (id) +); + +create table e_basic_withlife ( + id bigint generated by default as identity not null, + name varchar(255), + other varchar(255), + deleted boolean default false not null, + version bigint not null, + constraint pk_e_basic_withlife primary key (id) +); + +create table e_basic_with_ex ( + id bigint generated by default as identity not null, + deleted boolean default false not null, + version bigint not null, + constraint pk_e_basic_with_ex primary key (id) +); + +create table e_basicverucon ( + id integer generated by default as identity not null, + name varchar(127), + other varchar(127), + other_one varchar(127), + description varchar(255), + last_update timestamp not null, + constraint uq_e_basicverucon_name unique (name), + constraint uq_e_basicverucon_other_other_one unique (other,other_one), + constraint pk_e_basicverucon primary key (id) +); + +create table ecache_child ( + id uuid not null, + name varchar(100), + root_id uuid not null, + constraint pk_ecache_child primary key (id) +); + +create table ecache_root ( + id uuid not null, + name varchar(100), + constraint pk_ecache_root primary key (id) +); + +create table e_col_ab ( + id bigint generated by default as identity not null, + column_a varchar(255), + column_b varchar(255), + constraint pk_e_col_ab primary key (id) +); + +create table ecustom_id ( + id varchar(127) not null, + name varchar(255), + constraint pk_ecustom_id primary key (id) +); + +create table edefault_prop ( + id integer generated by default as identity not null, + e_simple_usertypeid integer, + name varchar(255), + constraint uq_edefault_prop_e_simple_usertypeid unique (e_simple_usertypeid), + constraint pk_edefault_prop primary key (id) +); + +create table eemb_inner ( + id integer generated by default as identity not null, + nome_inner varchar(255), + outer_id integer, + update_count integer not null, + constraint pk_eemb_inner primary key (id) +); + +create table eemb_outer ( + id integer generated by default as identity not null, + nome_outer varchar(255), + date1 timestamp, + date2 timestamp, + update_count integer not null, + constraint pk_eemb_outer primary key (id) +); + +create table efile2_no_fk ( + file_name varchar(64) not null, + owner_id integer not null, + constraint pk_efile2_no_fk primary key (file_name) +); + +create table efile_no_fk ( + file_name varchar(64) not null, + owner_user_id integer, + owner_soft_del_user_id integer, + constraint pk_efile_no_fk primary key (file_name) +); + +create table efile_no_fk_euser_no_fk ( + efile_no_fk_file_name varchar(64) not null, + euser_no_fk_user_id integer not null, + constraint pk_efile_no_fk_euser_no_fk primary key (efile_no_fk_file_name,euser_no_fk_user_id) +); + +create table efile_no_fk_euser_no_fk_soft_del ( + efile_no_fk_file_name varchar(64) not null, + euser_no_fk_soft_del_user_id integer not null, + constraint pk_efile_no_fk_euser_no_fk_soft_del primary key (efile_no_fk_file_name,euser_no_fk_soft_del_user_id) +); + +create table egen_props ( + id bigint generated by default as identity not null, + name varchar(255), + version bigint not null, + when_created timestamp not null, + when_modified timestamp not null, + ts_created timestamp not null, + ts_updated timestamp not null, + ldt_created timestamp not null, + ldt_updated timestamp not null, + odt_created timestamp not null, + odt_updated timestamp not null, + zdt_created timestamp not null, + zdt_updated timestamp not null, + instant_created timestamp not null, + instant_updated timestamp not null, + long_created bigint not null, + long_updated bigint not null, + constraint pk_egen_props primary key (id) +); + +create table eid_uid_bean ( + id bigint generated by default as identity not null, + uuid uuid not null, + name varchar(255), + constraint uq_eid_uid_bean_uuid unique (uuid), + constraint pk_eid_uid_bean primary key (id) +); + +create table einvoice ( + id bigint generated by default as identity not null, + invoice_date timestamp, + state integer, + person_id bigint, + ship_street varchar(255) not null, + ship_suburb varchar(255), + ship_city varchar(255), + ship_status varchar(3), + bill_street varchar(255) not null, + bill_suburb varchar(255), + bill_city varchar(255), + bill_status varchar(3), + version bigint not null, + constraint ck_einvoice_state check ( state in (0,1,2)), + constraint ck_einvoice_ship_status check ( ship_status in ('ONE','TWO')), + constraint ck_einvoice_bill_status check ( bill_status in ('ONE','TWO')), + constraint pk_einvoice primary key (id) +); + +create table e_main ( + id integer generated by default as identity not null, + name varchar(255), + description varchar(255), + version bigint not null, + constraint pk_e_main primary key (id) +); + +create table enull_collection ( + id integer generated by default as identity not null, + name varchar(255), + constraint pk_enull_collection primary key (id) +); + +create table enull_collection_detail ( + id integer generated by default as identity not null, + enull_collection_id integer not null, + something varchar(255), + constraint pk_enull_collection_detail primary key (id) +); + +create table eopt_one_a ( + id integer generated by default as identity not null, + name_for_a varchar(255), + b_id integer, + cretime timestamp not null, + updtime timestamp not null, + version bigint not null, + constraint pk_eopt_one_a primary key (id) +); + +create table eopt_one_b ( + id integer generated by default as identity not null, + name_for_b varchar(255), + c_id integer not null, + cretime timestamp not null, + updtime timestamp not null, + version bigint not null, + constraint pk_eopt_one_b primary key (id) +); + +create table eopt_one_c ( + id integer generated by default as identity not null, + name_for_c varchar(255), + cretime timestamp not null, + updtime timestamp not null, + version bigint not null, + constraint pk_eopt_one_c primary key (id) +); + +create table eper_addr ( + id bigint generated by default as identity not null, + name varchar(255), + ma_street varchar(255), + ma_suburb varchar(255), + ma_city varchar(255), + ma_country_code varchar(2), + version bigint not null, + constraint pk_eper_addr primary key (id) +); + +create table eperson ( + id bigint generated by default as identity not null, + name varchar(255), + notes varchar(255), + street varchar(255) not null, + suburb varchar(255), + addr_city varchar(255), + addr_status varchar(3), + version bigint not null, + constraint ck_eperson_addr_status check ( addr_status in ('ONE','TWO')), + constraint pk_eperson primary key (id) +); + +create table eperson2 ( + id bigint generated by default as identity not null, + name varchar(255), + notes varchar(255), + street varchar(10), + suburb varchar(100), + city varchar(255) not null, + status varchar(3) not null, + version bigint not null, + constraint ck_eperson2_status check ( status in ('ONE','TWO')), + constraint pk_eperson2 primary key (id) +); + +create table eperson3 ( + id bigint generated by default as identity not null, + name varchar(255), + street varchar(255), + suburb varchar(255), + city varchar(255), + status varchar(3), + version bigint not null, + constraint ck_eperson3_status check ( status in ('ONE','TWO')), + constraint pk_eperson3 primary key (id) +); + +create table e_person_online ( + id bigint generated by default as identity not null, + email varchar(127), + online_status boolean default false not null, + when_updated timestamp not null, + constraint uq_e_person_online_email unique (email), + constraint pk_e_person_online primary key (id) +); + +create table esimple ( + usertypeid integer generated by default as identity not null, + name varchar(255), + constraint pk_esimple primary key (usertypeid) +); + +create table esoft_del_book ( + id bigint generated by default as identity not null, + book_title varchar(255), + lend_by_id bigint, + version bigint not null, + deleted boolean default false not null, + constraint pk_esoft_del_book primary key (id) +); + +create table esoft_del_book_esoft_del_user ( + esoft_del_book_id bigint not null, + esoft_del_user_id bigint not null, + constraint pk_esoft_del_book_esoft_del_user primary key (esoft_del_book_id,esoft_del_user_id) +); + +create table esoft_del_down ( + id bigint generated by default as identity not null, + esoft_del_mid_id bigint not null, + down varchar(255), + version bigint not null, + deleted boolean default false not null, + constraint pk_esoft_del_down primary key (id) +); + +create table esoft_del_mid ( + id bigint generated by default as identity not null, + top_id bigint, + mid varchar(255), + up_id bigint, + version bigint not null, + deleted boolean default false not null, + constraint pk_esoft_del_mid primary key (id) +); + +create table esoft_del_one_a ( + id bigint generated by default as identity not null, + name varchar(255), + oneb_id bigint, + deleted boolean default false not null, + version bigint not null, + constraint uq_esoft_del_one_a_oneb_id unique (oneb_id), + constraint pk_esoft_del_one_a primary key (id) +); + +create table esoft_del_one_b ( + id bigint generated by default as identity not null, + name varchar(255), + version bigint not null, + constraint pk_esoft_del_one_b primary key (id) +); + +create table esoft_del_role ( + id bigint generated by default as identity not null, + role_name varchar(255), + version bigint not null, + deleted boolean default false not null, + constraint pk_esoft_del_role primary key (id) +); + +create table esoft_del_role_esoft_del_user ( + esoft_del_role_id bigint not null, + esoft_del_user_id bigint not null, + constraint pk_esoft_del_role_esoft_del_user primary key (esoft_del_role_id,esoft_del_user_id) +); + +create table esoft_del_top ( + id bigint generated by default as identity not null, + name varchar(255), + version bigint not null, + deleted boolean default false not null, + constraint pk_esoft_del_top primary key (id) +); + +create table esoft_del_up ( + id bigint generated by default as identity not null, + up varchar(255), + version bigint not null, + deleted boolean default false not null, + constraint pk_esoft_del_up primary key (id) +); + +create table esoft_del_user ( + id bigint generated by default as identity not null, + user_name varchar(255), + version bigint not null, + deleted boolean default false not null, + constraint pk_esoft_del_user primary key (id) +); + +create table esoft_del_user_esoft_del_role ( + esoft_del_user_id bigint not null, + esoft_del_role_id bigint not null, + constraint pk_esoft_del_user_esoft_del_role primary key (esoft_del_user_id,esoft_del_role_id) +); + +create table esome_convert_type ( + id bigint generated by default as identity not null, + name varchar(255), + money decimal(16,3), + constraint pk_esome_convert_type primary key (id) +); + +create table esome_type ( + id integer generated by default as identity not null, + currency varchar(3), + locale varchar(20), + time_zone varchar(20), + constraint pk_esome_type primary key (id) +); + +create table etrans_many ( + id integer generated by default as identity not null, + name varchar(255), + constraint pk_etrans_many primary key (id) +); + +create table rawinherit_uncle ( + id integer generated by default as identity not null, + name varchar(255), + parent_id bigint not null, + version bigint not null, + constraint pk_rawinherit_uncle primary key (id) +); + +create table euser_no_fk ( + user_id integer generated by default as identity not null, + user_name varchar(255), + constraint pk_euser_no_fk primary key (user_id) +); + +create table euser_no_fk_soft_del ( + user_id integer generated by default as identity not null, + user_name varchar(255), + constraint pk_euser_no_fk_soft_del primary key (user_id) +); + +create table evanilla_collection ( + id integer generated by default as identity not null, + name varchar(255), + constraint pk_evanilla_collection primary key (id) +); + +create table evanilla_collection_detail ( + id integer generated by default as identity not null, + evanilla_collection_id integer not null, + something varchar(255), + constraint pk_evanilla_collection_detail primary key (id) +); + +create table ewho_props ( + id bigint generated by default as identity not null, + name varchar(255), + version bigint not null, + when_created timestamp not null, + when_modified timestamp not null, + who_created varchar(255) not null, + who_modified varchar(255) not null, + constraint pk_ewho_props primary key (id) +); + +create table e_withinet ( + id bigint generated by default as identity not null, + name varchar(255), + inet_address varchar(50), + inet2 varchar(255), + cidr varchar(50), + version bigint not null, + constraint pk_e_withinet primary key (id) +); + +create table ec_enum_person ( + id bigint generated by default as identity not null, + name varchar(255), + version bigint not null, + constraint pk_ec_enum_person primary key (id) +); + +create table ec_enum_person_tags ( + ec_enum_person_id bigint not null, + value varchar(5) not null, + constraint ck_ec_enum_person_tags_value check ( value in ('RED','BLUE','GREEN')) +); + +create table ec_person ( + id bigint generated by default as identity not null, + name varchar(255), + version bigint not null, + constraint pk_ec_person primary key (id) +); + +create table ec_person_phone ( + owner_id bigint not null, + phone varchar(255) not null +); + +create table ec_top ( + id bigint generated by default as identity not null, + name varchar(255), + person_id bigint, + version bigint not null, + constraint pk_ec_top primary key (id) +); + +create table ec_top_ecs_person ( + ec_top_id bigint not null, + ecs_person_id bigint not null, + constraint pk_ec_top_ecs_person primary key (ec_top_id,ecs_person_id) +); + +create table ecbl_person ( + id bigint generated by default as identity not null, + name varchar(255), + version bigint not null, + constraint pk_ecbl_person primary key (id) +); + +create table ecbl_person_phone_numbers ( + person_id bigint not null, + country_code varchar(2), + area varchar(6), + phnum varchar(20) +); + +create table ecbm_person ( + id bigint generated by default as identity not null, + name varchar(255), + version bigint not null, + constraint pk_ecbm_person primary key (id) +); + +create table ecbm_person_phone_numbers ( + person_id bigint not null, + mkey varchar(255) not null, + country_code varchar(2), + area varchar(6), + phnum varchar(20) +); + +create table ecm_person ( + id bigint generated by default as identity not null, + name varchar(255), + version bigint not null, + constraint pk_ecm_person primary key (id) +); + +create table ecm_person_phone_numbers ( + ecm_person_id bigint not null, + type varchar(4) not null, + phnum varchar(10) not null +); + +create table ecmc_person ( + id bigint generated by default as identity not null, + name varchar(255), + version bigint not null, + constraint pk_ecmc_person primary key (id) +); + +create table ecmc_person_phone_numbers ( + ecmc_person_id bigint not null, + type varchar(4) not null, + value clob not null +); + +create table ecs_person ( + id bigint generated by default as identity not null, + name varchar(255), + version bigint not null, + constraint pk_ecs_person primary key (id) +); + +create table ecs_person_phone ( + ecs_person_id bigint not null, + phone varchar(255) not null +); + +create table ecsm_child ( + one_id uuid not null, + ecsm_parent_id bigint not null, + name varchar(255), + version bigint not null, + constraint pk_ecsm_child primary key (one_id) +); + +create table ecsm_values ( + host_id uuid not null, + value varchar(255) not null +); + +create table ecsm_one ( + one_id uuid not null, + name varchar(255), + version bigint not null, + constraint pk_ecsm_one primary key (one_id) +); + +create table ecsm_parent ( + id bigint generated by default as identity not null, + name varchar(255), + version bigint not null, + constraint pk_ecsm_parent primary key (id) +); + +create table ecsm_two ( + id uuid not null, + name varchar(255), + version bigint not null, + constraint pk_ecsm_two primary key (id) +); + +create table td_child ( + child_id integer generated by default as identity not null, + child_name varchar(255), + parent_id integer not null, + constraint pk_td_child primary key (child_id) +); + +create table td_parent ( + parent_type varchar(31) not null, + parent_id integer generated by default as identity not null, + parent_name varchar(255), + extended_name varchar(255), + constraint pk_td_parent primary key (parent_id) +); + +create table element_bean ( + id bigint generated by default as identity not null, + complex_bean_id uuid not null, + value varchar(255) not null, + constraint pk_element_bean primary key (id) +); + +create table empl ( + id bigint generated by default as identity not null, + name varchar(255), + age integer, + default_address_id bigint, + constraint pk_empl primary key (id) +); + +create table esd_detail ( + id bigint generated by default as identity not null, + name varchar(255), + master_id bigint not null, + version bigint not null, + deleted boolean default false not null, + constraint pk_esd_detail primary key (id) +); + +create table esd_master ( + id bigint generated by default as identity not null, + name varchar(255), + version bigint not null, + deleted boolean default false not null, + constraint pk_esd_master primary key (id) +); + +create table feature_desc ( + id integer generated by default as identity not null, + name varchar(255), + description varchar(255), + constraint pk_feature_desc primary key (id) +); + +create table f_first ( + id bigint generated by default as identity not null, + name varchar(255), + constraint pk_f_first primary key (id) +); + +create table foo ( + foo_id integer generated by default as identity not null, + important_text varchar(255), + version integer not null, + constraint pk_foo primary key (foo_id) +); + +create table gen_key_identity ( + id bigint generated by default as identity not null, + description varchar(255), + constraint pk_gen_key_identity primary key (id) +); + +create table gen_key_sequence ( + id bigint not null, + description varchar(255), + constraint pk_gen_key_sequence primary key (id) +); +create sequence SEQ_NAME increment by 1; + +create table grand_parent_person ( + identifier integer generated by default as identity not null, + name varchar(255), + age integer, + some_bean_id integer, + family_name varchar(255), + address varchar(255), + constraint pk_grand_parent_person primary key (identifier) +); + +create table survey_group ( + id bigint generated by default as identity not null, + name varchar(255), + categoryobjectid bigint, + sequence_number integer not null, + constraint pk_survey_group primary key (id) +); + +create table c_group ( + id bigint generated by default as identity not null, + inactive boolean default false not null, + name varchar(255), + version bigint not null, + when_created timestamp not null, + when_modified timestamp not null, + constraint pk_c_group primary key (id) +); + +create table hembi_bean ( + part bigint not null, + brand varchar(20) not null, + name varchar(255), + description varchar(255), + version bigint not null, + constraint pk_hembi_bean primary key (part,brand) +); + +create table he_doc ( + id bigint generated by default as identity not null, + name varchar(255), + version bigint not null, + when_created timestamp not null, + when_modified timestamp not null, + constraint pk_he_doc primary key (id) +); + +create table hx_link ( + id bigint generated by default as identity not null, + name varchar(255), + location varchar(255), + comments varchar(255), + version bigint not null, + when_created timestamp not null, + when_modified timestamp not null, + deleted boolean default false not null, + constraint pk_hx_link primary key (id) +); + +create table hx_link_doc ( + hx_link_id bigint not null, + he_doc_id bigint not null, + constraint pk_hx_link_doc primary key (hx_link_id,he_doc_id) +); + +create table hi_doc ( + id bigint generated by default as identity not null, + name varchar(255), + version bigint not null, + when_created timestamp not null, + when_modified timestamp not null, + constraint pk_hi_doc primary key (id) +); + +create table hi_link ( + id bigint generated by default as identity not null, + name varchar(255), + location varchar(255), + comments varchar(255), + version bigint not null, + when_created timestamp not null, + when_modified timestamp not null, + constraint pk_hi_link primary key (id) +); + +create table hi_link_doc ( + hi_link_id bigint not null, + hi_doc_id bigint not null, + constraint pk_hi_link_doc primary key (hi_link_id,hi_doc_id) +); + +create table hi_tone ( + id bigint generated by default as identity not null, + name varchar(255), + comments varchar(255), + version bigint not null, + when_created timestamp not null, + when_modified timestamp not null, + constraint pk_hi_tone primary key (id) +); + +create table hi_tthree ( + id bigint generated by default as identity not null, + hi_ttwo_id bigint not null, + three varchar(255), + version bigint not null, + when_created timestamp not null, + when_modified timestamp not null, + constraint pk_hi_tthree primary key (id) +); + +create table hi_ttwo ( + id bigint generated by default as identity not null, + hi_tone_id bigint not null, + two varchar(255), + version bigint not null, + when_created timestamp not null, + when_modified timestamp not null, + constraint pk_hi_ttwo primary key (id) +); + +create table hsd_setting ( + id bigint generated by default as identity not null, + code varchar(255), + content varchar(255), + user_id bigint, + version bigint not null, + when_created timestamp not null, + when_modified timestamp not null, + deleted boolean default false not null, + constraint uq_hsd_setting_user_id unique (user_id), + constraint pk_hsd_setting primary key (id) +); + +create table hsd_user ( + id bigint generated by default as identity not null, + name varchar(255), + version bigint not null, + when_created timestamp not null, + when_modified timestamp not null, + deleted boolean default false not null, + constraint pk_hsd_user primary key (id) +); + +create table iaf_segment ( + ptype varchar(31) not null, + id bigint generated by default as identity not null, + segment_id_zat bigint not null, + status_id bigint not null, + constraint pk_iaf_segment primary key (id) +); + +create table iaf_segment_status ( + id bigint generated by default as identity not null, + name varchar(255), + constraint pk_iaf_segment_status primary key (id) +); + +create table imrelated ( + id bigint generated by default as identity not null, + name varchar(255), + owner_id bigint not null, + constraint pk_imrelated primary key (id) +); + +create table imroot ( + dtype varchar(31) not null, + id bigint generated by default as identity not null, + name varchar(255), + title varchar(255), + when_title timestamp, + constraint pk_imroot primary key (id) +); + +create table ixresource ( + dtype varchar(255), + id uuid not null, + name varchar(255), + constraint pk_ixresource primary key (id) +); + +create table info_company ( + id bigint generated by default as identity not null, + name varchar(255), + version bigint not null, + constraint pk_info_company primary key (id) +); + +create table info_contact ( + id bigint generated by default as identity not null, + name varchar(255), + company_id bigint not null, + version bigint not null, + constraint pk_info_contact primary key (id) +); + +create table info_customer ( + id bigint generated by default as identity not null, + name varchar(255), + company_id bigint, + version bigint not null, + constraint uq_info_customer_company_id unique (company_id), + constraint pk_info_customer primary key (id) +); + +create table inner_report ( + id bigint generated by default as identity not null, + name varchar(255), + forecast_id bigint, + constraint uq_inner_report_forecast_id unique (forecast_id), + constraint pk_inner_report primary key (id) +); + +create table drel_invoice ( + id bigint not null, + booking bigint, + version integer not null, + constraint pk_drel_invoice primary key (id) +); +create sequence drel_invoice_seq increment by 1; + +create table item ( + customer integer not null, + itemnumber varchar(127) not null, + description varchar(255), + units varchar(255), + type integer not null, + region integer not null, + date_modified timestamp, + date_created timestamp, + modified_by varchar(255), + created_by varchar(255), + version bigint not null, + constraint pk_item primary key (customer,itemnumber) +); + +create table monkey ( + mid bigint generated by default as identity not null, + name varchar(255), + food_preference varchar(255), + version bigint not null, + constraint pk_monkey primary key (mid) +); + +create table mkeygroup ( + pid bigint generated by default as identity not null, + name varchar(255), + version bigint not null, + constraint pk_mkeygroup primary key (pid) +); + +create table mkeygroup_monkey ( + mkeygroup_pid bigint not null, + monkey_mid bigint not null, + constraint uq_mkeygroup_monkey_mid unique (monkey_mid), + constraint pk_mkeygroup_monkey primary key (mkeygroup_pid,monkey_mid) +); + +create table trainer ( + tid bigint generated by default as identity not null, + name varchar(255), + version bigint not null, + constraint pk_trainer primary key (tid) +); + +create table trainer_monkey ( + trainer_tid bigint not null, + monkey_mid bigint not null, + constraint uq_trainer_monkey_mid unique (monkey_mid), + constraint pk_trainer_monkey primary key (trainer_tid,monkey_mid) +); + +create table troop ( + pid bigint generated by default as identity not null, + name varchar(255), + version bigint not null, + constraint pk_troop primary key (pid) +); + +create table troop_monkey ( + troop_pid bigint not null, + monkey_mid bigint not null, + constraint uq_troop_monkey_mid unique (monkey_mid), + constraint pk_troop_monkey primary key (troop_pid,monkey_mid) +); + +create table l2_cldf_reset_bean ( + id bigint generated by default as identity not null, + name varchar(255), + constraint pk_l2_cldf_reset_bean primary key (id) +); + +create table l2_cldf_reset_bean_child ( + id bigint generated by default as identity not null, + parent_id bigint, + constraint pk_l2_cldf_reset_bean_child primary key (id) +); + +create table level1 ( + id bigint generated by default as identity not null, + name varchar(255), + constraint pk_level1 primary key (id) +); + +create table level1_level4 ( + level1_id bigint not null, + level4_id bigint not null, + constraint pk_level1_level4 primary key (level1_id,level4_id) +); + +create table level1_level2 ( + level1_id bigint not null, + level2_id bigint not null, + constraint pk_level1_level2 primary key (level1_id,level2_id) +); + +create table level2 ( + id bigint generated by default as identity not null, + name varchar(255), + constraint pk_level2 primary key (id) +); + +create table level2_level3 ( + level2_id bigint not null, + level3_id bigint not null, + constraint pk_level2_level3 primary key (level2_id,level3_id) +); + +create table level3 ( + id bigint generated by default as identity not null, + name varchar(255), + constraint pk_level3 primary key (id) +); + +create table level4 ( + id bigint generated by default as identity not null, + name varchar(255), + constraint pk_level4 primary key (id) +); + +create table link ( + id bigint generated by default as identity not null, + name varchar(255), + location varchar(255), + when_publish timestamp, + link_comment varchar(255), + version bigint not null, + when_created timestamp not null, + when_modified timestamp not null, + deleted boolean default false not null, + constraint pk_link primary key (id) +); + +create table link_draft ( + id bigint generated by default as identity not null, + name varchar(255), + location varchar(255), + when_publish timestamp, + link_comment varchar(255), + dirty boolean default false not null, + version bigint not null, + when_created timestamp not null, + when_modified timestamp not null, + deleted boolean default false not null, + constraint pk_link_draft primary key (id) +); + +create table la_attr_value ( + id integer generated by default as identity not null, + name varchar(255), + cretime timestamp not null, + updtime timestamp not null, + version bigint not null, + constraint pk_la_attr_value primary key (id) +); + +create table la_attr_value_attribute ( + la_attr_value_id integer not null, + attribute_id integer not null, + constraint pk_la_attr_value_attribute primary key (la_attr_value_id,attribute_id) +); + +create table looney ( + id bigint generated by default as identity not null, + tune_id bigint, + name varchar(255), + constraint pk_looney primary key (id) +); + +create table maddress ( + id uuid not null, + street varchar(255), + city varchar(255), + version bigint not null, + constraint pk_maddress primary key (id) +); + +create table mcontact ( + id uuid not null, + email varchar(255), + first_name varchar(255), + last_name varchar(255), + customer_id uuid, + version bigint not null, + constraint pk_mcontact primary key (id) +); + +create table mcontact_message ( + id uuid not null, + title varchar(255), + subject varchar(255), + notes varchar(255), + contact_id uuid not null, + version bigint not null, + constraint pk_mcontact_message primary key (id) +); + +create table mcustomer ( + id uuid not null, + name varchar(255), + notes varchar(255), + shipping_address_id uuid, + billing_address_id uuid, + version bigint not null, + constraint pk_mcustomer primary key (id) +); + +create table mgroup ( + id bigint generated by default as identity not null, + name varchar(255), + constraint pk_mgroup primary key (id) +); + +create table mmachine ( + id bigint generated by default as identity not null, + name varchar(255), + version bigint not null, + constraint pk_mmachine primary key (id) +); + +create table mmachine_mgroup ( + mmachine_id bigint not null, + mgroup_id bigint not null, + constraint pk_mmachine_mgroup primary key (mmachine_id,mgroup_id) +); + +create table mmedia ( + type varchar(31) not null, + id bigint generated by default as identity not null, + url varchar(255), + note varchar(255), + constraint pk_mmedia primary key (id) +); + +create table non_updateprop ( + id integer generated by default as identity not null, + non_enum varchar(5), + name varchar(255), + note varchar(255), + constraint ck_non_updateprop_non_enum check ( non_enum in ('BEGIN','END')), + constraint pk_non_updateprop primary key (id) +); + +create table mprinter ( + id bigint generated by default as identity not null, + name varchar(255), + flags bigint not null, + current_state_id bigint, + last_swap_cyan_id bigint, + last_swap_magenta_id bigint, + last_swap_yellow_id bigint, + last_swap_black_id bigint, + version bigint not null, + constraint uq_mprinter_last_swap_cyan_id unique (last_swap_cyan_id), + constraint uq_mprinter_last_swap_magenta_id unique (last_swap_magenta_id), + constraint uq_mprinter_last_swap_yellow_id unique (last_swap_yellow_id), + constraint uq_mprinter_last_swap_black_id unique (last_swap_black_id), + constraint pk_mprinter primary key (id) +); + +create table mprinter_state ( + id bigint generated by default as identity not null, + flags bigint not null, + printer_id bigint, + version bigint not null, + constraint pk_mprinter_state primary key (id) +); + +create table mprofile ( + id bigint generated by default as identity not null, + picture_id bigint, + name varchar(255), + constraint pk_mprofile primary key (id) +); + +create table mprotected_construct_bean ( + id bigint generated by default as identity not null, + name varchar(255), + constraint pk_mprotected_construct_bean primary key (id) +); + +create table mrole ( + roleid integer generated by default as identity not null, + role_name varchar(255), + constraint pk_mrole primary key (roleid) +); + +create table mrole_muser ( + mrole_roleid integer not null, + muser_userid integer not null, + constraint pk_mrole_muser primary key (mrole_roleid,muser_userid) +); + +create table msome_other ( + id bigint generated by default as identity not null, + name varchar(255), + constraint pk_msome_other primary key (id) +); + +create table muser ( + userid integer generated by default as identity not null, + user_name varchar(255), + user_type_id integer, + constraint pk_muser primary key (userid) +); + +create table muser_type ( + id integer generated by default as identity not null, + name varchar(255), + constraint pk_muser_type primary key (id) +); + +create table mail_box ( + id bigint generated by default as identity not null, + name varchar(255), + version bigint not null, + constraint pk_mail_box primary key (id) +); + +create table mail_user ( + id bigint generated by default as identity not null, + name varchar(255), + version bigint not null, + constraint pk_mail_user primary key (id) +); + +create table mail_user_inbox ( + mail_user_id bigint not null, + mail_box_id bigint not null, + constraint pk_mail_user_inbox primary key (mail_user_id,mail_box_id) +); + +create table mail_user_outbox ( + mail_user_id bigint not null, + mail_box_id bigint not null, + constraint pk_mail_user_outbox primary key (mail_user_id,mail_box_id) +); + +create table main_entity ( + id varchar(255) not null, + attr1 varchar(255), + attr2 varchar(255), + constraint pk_main_entity primary key (id) +); + +create table main_entity_relation ( + id uuid not null, + id1 varchar(255), + id2 varchar(255), + attr1 varchar(255), + constraint pk_main_entity_relation primary key (id) +); + +create table map_super_actual ( + id bigint generated by default as identity not null, + name varchar(255), + when_created timestamp not null, + when_updated timestamp not null, + constraint pk_map_super_actual primary key (id) +); + +create table c_message ( + id bigint generated by default as identity not null, + title varchar(255), + body varchar(255), + conversation_id bigint, + user_id bigint, + version bigint not null, + when_created timestamp not null, + when_modified timestamp not null, + constraint pk_c_message primary key (id) +); + +create table meter_address_data ( + id uuid not null, + street varchar(255) not null, + constraint pk_meter_address_data primary key (id) +); + +create table meter_contract_data ( + id uuid not null, + special_needs_client_id uuid not null, + constraint uq_meter_contract_data_special_needs_client_id unique (special_needs_client_id), + constraint pk_meter_contract_data primary key (id) +); + +create table meter_special_needs_client ( + id uuid not null, + name varchar(255), + primary_id uuid, + constraint uq_meter_special_needs_client_primary_id unique (primary_id), + constraint pk_meter_special_needs_client primary key (id) +); + +create table meter_special_needs_contact ( + id uuid not null, + name varchar(255), + constraint pk_meter_special_needs_contact primary key (id) +); + +create table meter_version ( + id uuid not null, + address_data_id uuid, + contract_data_id uuid not null, + constraint uq_meter_version_address_data_id unique (address_data_id), + constraint uq_meter_version_contract_data_id unique (contract_data_id), + constraint pk_meter_version primary key (id) +); + +create table mnoc_role ( + role_id integer generated by default as identity not null, + role_name varchar(255), + version integer not null, + constraint pk_mnoc_role primary key (role_id) +); + +create table mnoc_user ( + user_id integer generated by default as identity not null, + user_name varchar(255), + version integer not null, + constraint pk_mnoc_user primary key (user_id) +); + +create table mnoc_user_mnoc_role ( + mnoc_user_user_id integer not null, + mnoc_role_role_id integer not null, + constraint pk_mnoc_user_mnoc_role primary key (mnoc_user_user_id,mnoc_role_role_id) +); + +create table mny_a ( + id bigint generated by default as identity not null, + name varchar(255), + version bigint not null, + when_created timestamp not null, + when_modified timestamp not null, + constraint pk_mny_a primary key (id) +); + +create table mny_b ( + id bigint generated by default as identity not null, + name varchar(255), + a_id bigint, + version bigint not null, + when_created timestamp not null, + when_modified timestamp not null, + constraint pk_mny_b primary key (id) +); + +create table mny_b_mny_c ( + mny_b_id bigint not null, + mny_c_id bigint not null, + constraint pk_mny_b_mny_c primary key (mny_b_id,mny_c_id) +); + +create table mny_c ( + id bigint generated by default as identity not null, + name varchar(255), + version bigint not null, + when_created timestamp not null, + when_modified timestamp not null, + constraint pk_mny_c primary key (id) +); + +create table mny_topic ( + id bigint generated by default as identity not null, + name varchar(255), + version bigint not null, + constraint pk_mny_topic primary key (id) +); + +create table subtopics ( + topic bigint not null, + subtopic bigint not null, + constraint pk_subtopics primary key (topic,subtopic) +); + +create table mp_role ( + id bigint generated by default as identity not null, + mp_user_id bigint not null, + code varchar(255), + organization_id bigint, + constraint pk_mp_role primary key (id) +); + +create table mp_user ( + id bigint generated by default as identity not null, + name varchar(255), + constraint pk_mp_user primary key (id) +); + +create table ms_many_a ( + aid bigint generated by default as identity not null, + name varchar(255), + ms_many_a_many_b boolean default false not null, + ms_many_b boolean default false not null, + deleted boolean default false not null, + constraint pk_ms_many_a primary key (aid) +); + +create table ms_many_a_many_b ( + ms_many_a_aid bigint not null, + ms_many_b_bid bigint not null, + constraint pk_ms_many_a_many_b primary key (ms_many_a_aid,ms_many_b_bid) +); + +create table ms_many_b ( + bid bigint generated by default as identity not null, + name varchar(255), + deleted boolean default false not null, + constraint pk_ms_many_b primary key (bid) +); + +create table ms_many_b_many_a ( + ms_many_b_bid bigint not null, + ms_many_a_aid bigint not null, + constraint pk_ms_many_b_many_a primary key (ms_many_b_bid,ms_many_a_aid) +); + +create table my_lob_size ( + id integer generated by default as identity not null, + name varchar(255), + my_count integer not null, + my_lob clob, + constraint pk_my_lob_size primary key (id) +); + +create table my_lob_size_join_many ( + id integer generated by default as identity not null, + something varchar(255), + other varchar(255), + parent_id integer, + constraint pk_my_lob_size_join_many primary key (id) +); + +create table noidbean ( + name varchar(255), + subject varchar(255), + when_created timestamp not null +); + +create table o_bean_child ( + id bigint generated by default as identity not null, + cached_bean_id bigint, + constraint pk_o_bean_child primary key (id) +); + +create table ocached_app ( + id bigint generated by default as identity not null, + app_name varchar(255), + version bigint not null, + constraint uq_ocached_app_app_name unique (app_name), + constraint pk_ocached_app primary key (id) +); + +create table ocached_app_detail ( + id bigint generated by default as identity not null, + app_id bigint not null, + detail varchar(255), + version bigint not null, + constraint uq_ocached_app_detail_app_id_detail unique (app_id,detail), + constraint pk_ocached_app_detail primary key (id) +); + +create table o_cached_bean ( + id bigint generated by default as identity not null, + name varchar(255), + constraint pk_o_cached_bean primary key (id) +); + +create table o_cached_bean_country ( + o_cached_bean_id bigint not null, + o_country_code varchar(2) not null, + constraint pk_o_cached_bean_country primary key (o_cached_bean_id,o_country_code) +); + +create table o_cached_bean_child ( + id bigint generated by default as identity not null, + cached_bean_id bigint, + constraint pk_o_cached_bean_child primary key (id) +); + +create table o_cached_inherit ( + dtype varchar(31) not null, + id bigint generated by default as identity not null, + name varchar(255), + child_adata varchar(255), + child_bdata varchar(255), + constraint pk_o_cached_inherit primary key (id) +); + +create table o_cached_natkey ( + id bigint generated by default as identity not null, + store varchar(255), + sku varchar(255), + description varchar(255), + constraint pk_o_cached_natkey primary key (id) +); + +create table o_cached_natkey3 ( + id bigint generated by default as identity not null, + store varchar(255), + code integer not null, + sku varchar(255), + description varchar(255), + constraint pk_o_cached_natkey3 primary key (id) +); + +create table ocached_nkey_uid ( + id bigint generated by default as identity not null, + cid uuid, + other varchar(255), + version bigint not null, + constraint pk_ocached_nkey_uid primary key (id) +); + +create table ocar ( + id integer generated by default as identity not null, + vin varchar(255), + name varchar(255), + cretime timestamp not null, + updtime timestamp not null, + version bigint not null, + constraint pk_ocar primary key (id) +); + +create table ocompany ( + id integer generated by default as identity not null, + corp_id varchar(50), + cretime timestamp not null, + updtime timestamp not null, + version bigint not null, + constraint uq_ocompany_corp_id unique (corp_id), + constraint pk_ocompany primary key (id) +); + +create table oengine ( + engine_id uuid not null, + short_desc varchar(255), + car_id integer, + version integer not null, + constraint uq_oengine_car_id unique (car_id), + constraint pk_oengine primary key (engine_id) +); + +create table ogear_box ( + id uuid not null, + box_desc varchar(255), + box_size integer, + car_id integer, + version integer not null, + constraint uq_ogear_box_car_id unique (car_id), + constraint pk_ogear_box primary key (id) +); + +create table omvertex ( + id uuid not null, + constraint pk_omvertex primary key (id) +); + +create table omvertex_other ( + id uuid not null, + omvertex_id uuid not null, + name varchar(255), + constraint pk_omvertex_other primary key (id) +); + +create table oroad_show_msg ( + id integer generated by default as identity not null, + company_id integer not null, + cretime timestamp not null, + updtime timestamp not null, + version bigint not null, + constraint uq_oroad_show_msg_company_id unique (company_id), + constraint pk_oroad_show_msg primary key (id) +); + +create table om_account_child_dbo ( + id bigint generated by default as identity not null, + description varchar(255), + banana_rama_id bigint, + constraint pk_om_account_child_dbo primary key (id) +); + +create table om_account_dbo ( + id bigint generated by default as identity not null, + name varchar(255), + constraint pk_om_account_dbo primary key (id) +); + +create table om_basic_child ( + id bigint generated by default as identity not null, + name varchar(255), + parent_id bigint, + version bigint not null, + constraint pk_om_basic_child primary key (id) +); + +create table om_basic_parent ( + id bigint generated by default as identity not null, + name varchar(255), + version bigint not null, + constraint pk_om_basic_parent primary key (id) +); + +create table om_ordered_detail ( + id bigint generated by default as identity not null, + name varchar(255), + master_id bigint, + version bigint not null, + sort_order integer, + constraint pk_om_ordered_detail primary key (id) +); + +create table om_ordered_master ( + id bigint generated by default as identity not null, + name varchar(255), + version bigint not null, + constraint pk_om_ordered_master primary key (id) +); + +create table oml_bar ( + id bigint generated by default as identity not null, + constraint pk_oml_bar primary key (id) +); + +create table oml_baz ( + id bigint generated by default as identity not null, + foo_id bigint not null, + constraint pk_oml_baz primary key (id) +); + +create table oml_foo ( + id bigint generated by default as identity not null, + bar_id bigint not null, + constraint pk_oml_foo primary key (id) +); + +create table only_id_entity ( + id bigint generated by default as identity not null, + constraint pk_only_id_entity primary key (id) +); + +create table o_order ( + id integer generated by default as identity not null, + status integer, + order_date date, + ship_date date, + kcustomer_id integer not null, + cretime timestamp not null, + updtime timestamp not null, + constraint ck_o_order_status check ( status in (0,1,2,3)), + constraint pk_o_order primary key (id) +); + +create table o_order_detail ( + id integer generated by default as identity not null, + order_id integer not null, + order_qty integer, + ship_qty integer, + unit_price double, + product_id integer, + cretime timestamp, + updtime timestamp not null, + constraint pk_o_order_detail primary key (id) +); + +create table s_orders ( + uuid varchar(40) not null, + constraint pk_s_orders primary key (uuid) +); + +create table s_order_items ( + uuid varchar(40) not null, + product_variant_uuid varchar(255), + order_uuid varchar(40), + quantity integer not null, + amount decimal(16,3), + constraint pk_s_order_items primary key (uuid) +); + +create table order_master ( + id bigint generated by default as identity not null, + constraint pk_order_master primary key (id) +); + +create table order_master_inheritance ( + id integer generated by default as identity not null, + constraint pk_order_master_inheritance primary key (id) +); + +create table order_referenced_parent ( + type varchar(31) not null, + id bigint generated by default as identity not null, + name varchar(255), + child_name varchar(255), + master_id bigint, + sort_order integer, + constraint pk_order_referenced_parent primary key (id) +); + +create table or_order_ship ( + id integer generated by default as identity not null, + order_id integer, + ship_time timestamp, + cretime timestamp not null, + updtime timestamp not null, + version bigint not null, + constraint pk_or_order_ship primary key (id) +); + +create table order_toy ( + id integer generated by default as identity not null, + title varchar(255), + child_id bigint, + sort_order integer, + constraint pk_order_toy primary key (id) +); + +create table ordered_parent ( + dtype varchar(31) not null, + id integer generated by default as identity not null, + order_master_inheritance_id integer not null, + common_name varchar(255), + sort_order integer, + ordered_aname varchar(255), + ordered_bname varchar(255), + constraint pk_ordered_parent primary key (id) +); + +create table organisation ( + id bigint generated by default as identity not null, + name varchar(255), + version bigint not null, + when_created timestamp not null, + when_modified timestamp not null, + constraint pk_organisation primary key (id) +); + +create table organization_node ( + kind varchar(31) not null, + id bigint generated by default as identity not null, + parent_tree_node_id bigint not null, + title varchar(255), + constraint uq_organization_node_parent_tree_node_id unique (parent_tree_node_id), + constraint pk_organization_node primary key (id) +); + +create table organization_tree_node ( + id bigint generated by default as identity not null, + name varchar(255), + constraint pk_organization_tree_node primary key (id) +); + +create table orp_detail ( + id varchar(100) not null, + detail varchar(255), + master_id varchar(100), + version bigint not null, + constraint pk_orp_detail primary key (id) +); + +create table orp_detail2 ( + id varchar(100) not null, + orp_master2_id varchar(100) not null, + detail varchar(255), + master_id varchar(255), + version bigint not null, + constraint pk_orp_detail2 primary key (id) +); + +create table orp_master ( + id varchar(100) not null, + name varchar(255), + version bigint not null, + constraint pk_orp_master primary key (id) +); + +create table orp_master2 ( + id varchar(100) not null, + name varchar(255), + version bigint not null, + constraint pk_orp_master2 primary key (id) +); + +create table oto_aone ( + id varchar(100) not null, + description varchar(255), + constraint pk_oto_aone primary key (id) +); + +create table oto_atwo ( + id varchar(100) not null, + description varchar(255), + aone_id varchar(100), + constraint uq_oto_atwo_aone_id unique (aone_id), + constraint pk_oto_atwo primary key (id) +); + +create table oto_bchild ( + master_id bigint generated by default as identity not null, + child varchar(255), + constraint pk_oto_bchild primary key (master_id) +); + +create table oto_bmaster ( + id bigint generated by default as identity not null, + name varchar(255), + constraint pk_oto_bmaster primary key (id) +); + +create table oto_child ( + id integer generated by default as identity not null, + name varchar(255), + master_id bigint, + constraint uq_oto_child_master_id unique (master_id), + constraint pk_oto_child primary key (id) +); + +create table oto_cust ( + cid bigint generated by default as identity not null, + name varchar(255), + version bigint not null, + constraint pk_oto_cust primary key (cid) +); + +create table oto_cust_address ( + aid bigint generated by default as identity not null, + line1 varchar(255), + line2 varchar(255), + line3 varchar(255), + customer_cid bigint, + version bigint not null, + constraint uq_oto_cust_address_customer_cid unique (customer_cid), + constraint pk_oto_cust_address primary key (aid) +); + +create table oto_level_a ( + id bigint generated by default as identity not null, + name varchar(255), + b_id bigint, + constraint uq_oto_level_a_b_id unique (b_id), + constraint pk_oto_level_a primary key (id) +); + +create table oto_level_b ( + id bigint generated by default as identity not null, + name varchar(255), + c_id bigint, + constraint uq_oto_level_b_c_id unique (c_id), + constraint pk_oto_level_b primary key (id) +); + +create table oto_level_c ( + id bigint generated by default as identity not null, + name varchar(255), + constraint pk_oto_level_c primary key (id) +); + +create table oto_master ( + id bigint generated by default as identity not null, + name varchar(255), + constraint pk_oto_master primary key (id) +); + +create table oto_prime ( + pid bigint generated by default as identity not null, + name varchar(255), + version bigint not null, + constraint pk_oto_prime primary key (pid) +); + +create table oto_prime_extra ( + eid bigint generated by default as identity not null, + extra varchar(255), + version bigint not null, + constraint pk_oto_prime_extra primary key (eid) +); + +create table oto_sd_child ( + id bigint generated by default as identity not null, + child varchar(255), + master_id bigint, + deleted boolean default false not null, + version bigint not null, + constraint uq_oto_sd_child_master_id unique (master_id), + constraint pk_oto_sd_child primary key (id) +); + +create table oto_sd_master ( + id bigint generated by default as identity not null, + name varchar(255), + version bigint not null, + constraint pk_oto_sd_master primary key (id) +); + +create table oto_th_many ( + id bigint generated by default as identity not null, + oto_th_top_id bigint not null, + many varchar(255), + version bigint not null, + when_created timestamp not null, + when_modified timestamp not null, + constraint pk_oto_th_many primary key (id) +); + +create table oto_th_one ( + id bigint generated by default as identity not null, + one boolean default false not null, + many_id bigint, + version bigint not null, + when_created timestamp not null, + when_modified timestamp not null, + constraint uq_oto_th_one_many_id unique (many_id), + constraint pk_oto_th_one primary key (id) +); + +create table oto_th_top ( + id bigint generated by default as identity not null, + topp varchar(255), + version bigint not null, + when_created timestamp not null, + when_modified timestamp not null, + constraint pk_oto_th_top primary key (id) +); + +create table oto_ubprime ( + pid uuid not null, + name varchar(255), + version bigint not null, + constraint pk_oto_ubprime primary key (pid) +); + +create table oto_ubprime_extra ( + eid uuid not null, + extra varchar(255), + version bigint not null, + constraint pk_oto_ubprime_extra primary key (eid) +); + +create table oto_uprime ( + pid uuid not null, + name varchar(255), + version bigint not null, + constraint pk_oto_uprime primary key (pid) +); + +create table oto_uprime_extra ( + eid uuid not null, + extra varchar(255), + version bigint not null, + constraint pk_oto_uprime_extra primary key (eid) +); + +create table oto_user_model ( + id bigint generated by default as identity not null, + name varchar(255), + user_optional_id bigint, + version bigint not null, + when_created timestamp not null, + when_modified timestamp not null, + constraint uq_oto_user_model_user_optional_id unique (user_optional_id), + constraint pk_oto_user_model primary key (id) +); + +create table oto_user_model_optional ( + id bigint generated by default as identity not null, + optional varchar(255), + version bigint not null, + when_created timestamp not null, + when_modified timestamp not null, + constraint pk_oto_user_model_optional primary key (id) +); + +create table pfile ( + id integer generated by default as identity not null, + name varchar(255), + file_content_id integer, + file_content2_id integer, + cretime timestamp not null, + updtime timestamp not null, + version bigint not null, + constraint uq_pfile_file_content_id unique (file_content_id), + constraint uq_pfile_file_content2_id unique (file_content2_id), + constraint pk_pfile primary key (id) +); + +create table pfile_content ( + id integer generated by default as identity not null, + content blob, + cretime timestamp not null, + updtime timestamp not null, + version bigint not null, + constraint pk_pfile_content primary key (id) +); + +create table paggview ( + pview_id uuid, + amount integer not null, + constraint uq_paggview_pview_id unique (pview_id) +); + +create table pallet_location ( + type varchar(31) not null, + id integer generated by default as identity not null, + zone_sid integer not null, + attribute varchar(255), + constraint pk_pallet_location primary key (id) +); + +create table parcel ( + parcelid bigint generated by default as identity not null, + description varchar(255), + constraint pk_parcel primary key (parcelid) +); + +create table parcel_location ( + parcellocid bigint generated by default as identity not null, + location varchar(255), + parcelid bigint, + constraint uq_parcel_location_parcelid unique (parcelid), + constraint pk_parcel_location primary key (parcellocid) +); + +create table rawinherit_parent ( + type varchar(31) not null, + id bigint generated by default as identity not null, + val integer, + more varchar(255), + constraint pk_rawinherit_parent primary key (id) +); + +create table rawinherit_parent_rawinherit_data ( + rawinherit_parent_id bigint not null, + rawinherit_data_id bigint not null, + constraint pk_rawinherit_parent_rawinherit_data primary key (rawinherit_parent_id,rawinherit_data_id) +); + +create table e_save_test_c ( + id bigint generated by default as identity not null, + version bigint not null, + constraint pk_e_save_test_c primary key (id) +); + +create table parent_person ( + identifier integer generated by default as identity not null, + name varchar(255), + age integer, + some_bean_id integer, + parent_identifier integer, + family_name varchar(255), + address varchar(255), + constraint pk_parent_person primary key (identifier) +); + +create table c_participation ( + id bigint generated by default as identity not null, + rating integer, + type integer, + conversation_id bigint not null, + user_id bigint not null, + version bigint not null, + when_created timestamp not null, + when_modified timestamp not null, + constraint ck_c_participation_type check ( type in (0,1)), + constraint pk_c_participation primary key (id) +); + +create table password_store_model ( + id bigint generated by default as identity not null, + enc1 varchar(30), + enc2 varchar(40), + enc3 clob, + enc4 varbinary(30), + enc5 varbinary(40), + enc6 blob, + version bigint not null, + when_created timestamp not null, + when_modified timestamp not null, + constraint pk_password_store_model primary key (id) +); + +create table pcf_calendar ( + id bigint generated by default as identity not null, + pcf_person_id bigint not null, + version bigint not null, + constraint pk_pcf_calendar primary key (id) +); + +create table pcf_city ( + id bigint generated by default as identity not null, + pcf_country_id bigint not null, + name varchar(255), + mayor_id bigint not null, + vice_mayor_id bigint not null, + version bigint not null, + constraint uq_pcf_city_mayor_id unique (mayor_id), + constraint uq_pcf_city_vice_mayor_id unique (vice_mayor_id), + constraint pk_pcf_city primary key (id) +); + +create table pcf_country ( + id bigint generated by default as identity not null, + version bigint not null, + constraint pk_pcf_country primary key (id) +); + +create table pcf_event ( + id bigint generated by default as identity not null, + pcf_calendar_id bigint not null, + name varchar(255), + version bigint not null, + constraint pk_pcf_event primary key (id) +); + +create table pcf_person ( + id bigint generated by default as identity not null, + name varchar(255), + version bigint not null, + constraint pk_pcf_person primary key (id) +); + +create table mt_permission ( + id uuid not null, + name varchar(255), + constraint pk_mt_permission primary key (id) +); + +create table persistent_file ( + id integer generated by default as identity not null, + name varchar(255), + cretime timestamp not null, + updtime timestamp not null, + version bigint not null, + constraint pk_persistent_file primary key (id) +); + +create table persistent_file_content ( + id integer generated by default as identity not null, + persistent_file_id integer, + content blob, + cretime timestamp not null, + updtime timestamp not null, + version bigint not null, + constraint uq_persistent_file_content_persistent_file_id unique (persistent_file_id), + constraint pk_persistent_file_content primary key (id) +); + +create table person ( + oid bigint generated by default as identity not null, + default_address_oid bigint, + version integer not null, + constraint pk_person primary key (oid) +); + +create table persons ( + id bigint generated by default as identity (start with 1000 increment by 40) not null, + surname varchar(64) not null, + name varchar(64) not null, + constraint pk_persons primary key (id) +); + +create table person_cache_email ( + id varchar(128) not null, + person_info_person_id varchar(128), + email varchar(255), + constraint pk_person_cache_email primary key (id) +); + +create table person_cache_info ( + person_id varchar(128) not null, + name varchar(255), + constraint pk_person_cache_info primary key (person_id) +); + +create table phones ( + id bigint generated by default as identity not null, + phone_number varchar(7) not null, + person_id bigint not null, + constraint uq_phones_phone_number unique (phone_number), + constraint pk_phones primary key (id) +); + +create table e_position ( + id bigint generated by default as identity not null, + name varchar(255), + contract_id bigint not null, + constraint pk_e_position primary key (id) +); + +create table primary_revision ( + id bigint not null, + revision integer not null, + name varchar(255), + version bigint not null, + constraint pk_primary_revision primary key (id,revision) +); + +create table o_product ( + id integer generated by default as identity not null, + sku varchar(20), + name varchar(255), + cretime timestamp not null, + updtime timestamp not null, + constraint pk_o_product primary key (id) +); + +create table pp ( + id uuid not null, + name varchar(255), + value varchar(100) not null, + constraint pk_pp primary key (id) +); + +create table pp_to_ww ( + pp_id uuid not null, + ww_id uuid not null, + constraint pk_pp_to_ww primary key (pp_id,ww_id) +); + +create table question ( + id bigint generated by default as identity not null, + name varchar(255), + groupobjectid bigint, + sequence_number integer not null, + constraint pk_question primary key (id) +); + +create table rcustomer ( + company varchar(127) not null, + name varchar(127) not null, + description varchar(255), + constraint pk_rcustomer primary key (company,name) +); + +create table r_orders ( + company varchar(127) not null, + order_number integer not null, + customername varchar(127), + item varchar(255), + constraint pk_r_orders primary key (company,order_number) +); + +create table referenced_defaults_model ( + id integer generated by default as identity not null, + defaults_model_id integer not null, + name varchar(255), + constraint pk_referenced_defaults_model primary key (id) +); + +create table referenced_defaults_model_draft ( + id integer generated by default as identity not null, + defaults_model_id integer not null, + name varchar(255), + constraint pk_referenced_defaults_model_draft primary key (id) +); + +create table referencing_bean ( + id uuid not null, + constraint pk_referencing_bean primary key (id) +); + +create table region ( + customer integer not null, + type integer not null, + description varchar(255), + version bigint not null, + constraint pk_region primary key (customer,type) +); + +create table rel_detail ( + id bigint generated by default as identity not null, + name varchar(255), + version integer not null, + constraint pk_rel_detail primary key (id) +); + +create table rel_master ( + id bigint generated by default as identity not null, + name varchar(255), + detail_id bigint, + version integer not null, + constraint pk_rel_master primary key (id) +); + +create table resourcefile ( + id varchar(64) not null, + parentresourcefileid varchar(64), + name varchar(128) not null, + constraint pk_resourcefile primary key (id) +); + +create table mt_role ( + id uuid not null, + name varchar(50), + tenant_id uuid, + version bigint not null, + constraint pk_mt_role primary key (id) +); + +create table mt_role_permission ( + mt_role_id uuid not null, + mt_permission_id uuid not null, + constraint pk_mt_role_permission primary key (mt_role_id,mt_permission_id) +); + +create table em_role ( + id bigint generated by default as identity not null, + name varchar(255), + constraint pk_em_role primary key (id) +); + +create table root_bean ( + dtype varchar(31) not null, + id uuid not null, + referencing_bean_id uuid not null, + value varchar(255), + constraint pk_root_bean primary key (id) +); + +create table f_second ( + id bigint generated by default as identity not null, + mod_name varchar(255), + first bigint, + title varchar(255), + constraint uq_f_second_first unique (first), + constraint pk_f_second primary key (id) +); + +create table section ( + id integer generated by default as identity not null, + article_id integer, + type integer, + content clob, + cretime timestamp not null, + updtime timestamp not null, + version bigint not null, + constraint ck_section_type check ( type in (0,1)), + constraint pk_section primary key (id) +); + +create table self_parent ( + id bigint generated by default as identity not null, + name varchar(255), + parent_id bigint, + version bigint not null, + constraint pk_self_parent primary key (id) +); + +create table self_ref_customer ( + id bigint generated by default as identity not null, + name varchar(255), + referred_by_id bigint, + constraint pk_self_ref_customer primary key (id) +); + +create table self_ref_example ( + id bigint generated by default as identity not null, + name varchar(255) not null, + parent_id bigint, + constraint pk_self_ref_example primary key (id) +); + +create table e_save_test_a ( + id bigint generated by default as identity not null, + version bigint not null, + constraint pk_e_save_test_a primary key (id) +); + +create table e_save_test_b ( + id bigint generated by default as identity not null, + sibling_a_id bigint, + test_property boolean default false not null, + version bigint not null, + constraint uq_e_save_test_b_sibling_a_id unique (sibling_a_id), + constraint pk_e_save_test_b primary key (id) +); + +create table site ( + id uuid not null, + name varchar(255), + parent_id uuid, + data_container_id uuid, + site_address_id uuid, + constraint uq_site_data_container_id unique (data_container_id), + constraint uq_site_site_address_id unique (site_address_id), + constraint pk_site primary key (id) +); + +create table site_address ( + id uuid not null, + street varchar(255), + city varchar(255), + zip_code varchar(255), + constraint pk_site_address primary key (id) +); + +create table some_enum_bean ( + id bigint generated by default as identity not null, + some_enum integer, + name varchar(255), + constraint ck_some_enum_bean_some_enum check ( some_enum in (0,1)), + constraint pk_some_enum_bean primary key (id) +); + +create table some_file_bean ( + id bigint generated by default as identity not null, + name varchar(255), + content blob, + version bigint not null, + constraint pk_some_file_bean primary key (id) +); + +create table some_new_types_bean ( + id bigint generated by default as identity not null, + dow integer(1), + mth integer(1), + yr integer, + yr_mth date, + month_day date, + sql_date date, + sql_time time, + local_date date, + local_date_time timestamp, + offset_date_time timestamp, + zoned_date_time timestamp, + local_time time, + instant timestamp, + zone_id varchar(60), + zone_offset varchar(60), + path varchar(255), + period varchar(20), + duration bigint, + version bigint not null, + constraint ck_some_new_types_bean_dow check ( dow in (1,2,3,4,5,6,7)), + constraint ck_some_new_types_bean_mth check ( mth in (1,2,3,4,5,6,7,8,9,10,11,12)), + constraint pk_some_new_types_bean primary key (id) +); + +create table some_period_bean ( + id bigint generated by default as identity not null, + anniversary date, + version bigint not null, + constraint pk_some_period_bean primary key (id) +); + +create table source_base ( + dtype varchar(31) not null, + id uuid not null, + name varchar(255), + pos integer not null, + target_id uuid, + constraint pk_source_base primary key (id) +); + +create table stockforecast ( + type varchar(31) not null, + id bigint generated by default as identity not null, + inner_report_id bigint, + constraint pk_stockforecast primary key (id) +); + +create table sub_section ( + id integer generated by default as identity not null, + section_id integer, + title varchar(255), + cretime timestamp not null, + updtime timestamp not null, + version bigint not null, + constraint pk_sub_section primary key (id) +); + +create table sub_type ( + sub_type_id integer generated by default as identity not null, + description varchar(255), + version bigint not null, + constraint pk_sub_type primary key (sub_type_id) +); + +create table survey ( + id bigint generated by default as identity not null, + name varchar(255), + constraint pk_survey primary key (id) +); + +create table tbytes_only ( + id integer generated by default as identity not null, + content blob, + constraint pk_tbytes_only primary key (id) +); + +create table tcar ( + type varchar(31) not null, + plate_no varchar(32) not null, + deleted boolean default false not null, + truckload bigint, + constraint pk_tcar primary key (plate_no) +); + +create table tevent ( + id bigint generated by default as identity not null, + name varchar(255), + version bigint not null, + constraint pk_tevent primary key (id) +); + +create table tevent_many ( + id bigint generated by default as identity not null, + description varchar(255), + event_id bigint, + units integer not null, + amount double not null, + version bigint not null, + constraint pk_tevent_many primary key (id) +); + +create table tevent_one ( + id bigint generated by default as identity not null, + name varchar(255), + status integer, + event_id bigint, + version bigint not null, + constraint ck_tevent_one_status check ( status in (0,1)), + constraint uq_tevent_one_event_id unique (event_id), + constraint pk_tevent_one primary key (id) +); + +create table tint_root ( + my_type integer(3) not null, + id integer generated by default as identity not null, + name varchar(255), + child_property varchar(255), + constraint pk_tint_root primary key (id) +); + +create table tjoda_entity ( + id integer generated by default as identity not null, + local_time time, + constraint pk_tjoda_entity primary key (id) +); + +create table t_mapsuper1 ( + id integer generated by default as identity not null, + something varchar(255), + name varchar(255), + version integer not null, + constraint pk_t_mapsuper1 primary key (id) +); + +create table t_oneb ( + id integer generated by default as identity not null, + name varchar(255), + description varchar(255), + active boolean default false not null, + constraint pk_t_oneb primary key (id) +); + +create table t_detail_with_other_namexxxyy ( + id integer not null, + name varchar(255), + description varchar(255), + some_unique_value varchar(127), + active boolean default false not null, + master_id integer, + constraint uq_t_detail_with_other_namexxxyy_some_unique_value unique (some_unique_value), + constraint pk_t_detail_with_other_namexxxyy primary key (id) +); +create sequence t_atable_detail_seq increment by 1; + +create table t_atable_thatisrelatively ( + id integer not null, + name varchar(255), + description varchar(255), + active boolean default false not null, + constraint pk_t_atable_thatisrelatively primary key (id) +); +create sequence t_atable_master_seq increment by 1; + +create table ttruck_holder ( + id bigint generated by default as identity not null, + name varchar(255), + truck_plate_no varchar(32) not null, + basic_id integer, + version bigint not null, + constraint pk_ttruck_holder primary key (id) +); + +create table ttruck_holder_item ( + id bigint generated by default as identity not null, + some_uid uuid, + foo varchar(255), + owner_id bigint not null, + constraint pk_ttruck_holder_item primary key (id) +); + +create table tuuid_entity ( + id uuid not null, + name varchar(255), + constraint pk_tuuid_entity primary key (id) +); + +create table twheel ( + id bigint generated by default as identity not null, + owner_plate_no varchar(32) not null, + constraint pk_twheel primary key (id) +); + +create table twith_pre_insert ( + id integer generated by default as identity not null, + name varchar(255) not null, + title varchar(255), + constraint pk_twith_pre_insert primary key (id) +); + +create table target_base ( + dtype varchar(31) not null, + id uuid not null, + name varchar(255), + constraint pk_target_base primary key (id) +); + +create table mt_tenant ( + id uuid not null, + name varchar(255), + version bigint not null, + constraint pk_mt_tenant primary key (id) +); + +create table test_annotation_base_entity ( + direct varchar(255), + meta varchar(255), + mixed varchar(255), + constraint_annotation varchar(40), + null1 varchar(255) not null, + null2 varchar(255), + null3 varchar(255) +); + +create table tire ( + id bigint not null, + wheel bigint, + version integer not null, + constraint uq_tire_wheel unique (wheel), + constraint pk_tire primary key (id) +); +create sequence tire_seq increment by 1; + +create table sa_tire ( + id bigint not null, + version integer not null, + constraint pk_sa_tire primary key (id) +); +create sequence sa_tire_seq increment by 1; + +create table tree_entity ( + id integer generated by default as identity not null, + text varchar(255), + parent_id integer, + constraint pk_tree_entity primary key (id) +); + +create table trip ( + id integer generated by default as identity not null, + vehicle_driver_id integer, + destination varchar(255), + address_id integer, + star_date timestamp, + cretime timestamp not null, + updtime timestamp not null, + version bigint not null, + constraint pk_trip primary key (id) +); + +create table truck_ref ( + id integer generated by default as identity not null, + something varchar(255), + constraint pk_truck_ref primary key (id) +); + +create table tune ( + id bigint generated by default as identity not null, + name varchar(255), + constraint pk_tune primary key (id) +); + +create table "type" ( + customer integer not null, + type integer not null, + description varchar(255), + sub_type_id integer, + version bigint not null, + constraint pk_type primary key (customer,type) +); + +create table tz_bean ( + id bigint generated by default as identity not null, + moda varchar(255), + ts timestamp, + tstz timestamp, + constraint pk_tz_bean primary key (id) +); + +create table usib_child ( + id uuid not null, + parent_id bigint, + deleted boolean default false not null, + constraint pk_usib_child primary key (id) +); + +create table usib_child_sibling ( + id bigint generated by default as identity not null, + child_id uuid, + deleted boolean default false not null, + constraint uq_usib_child_sibling_child_id unique (child_id), + constraint pk_usib_child_sibling primary key (id) +); + +create table usib_parent ( + id bigint generated by default as identity not null, + deleted boolean default false not null, + constraint pk_usib_parent primary key (id) +); + +create table ut_detail ( + id integer generated by default as identity not null, + utmaster_id integer not null, + name varchar(255), + qty integer, + amount double, + version integer not null, + constraint pk_ut_detail primary key (id) +); + +create table ut_master ( + id integer generated by default as identity not null, + name varchar(255), + description varchar(255), + event_date date, + version integer not null, + constraint pk_ut_master primary key (id) +); + +create table uuone ( + id uuid not null, + name varchar(255), + description varchar(255), + version bigint not null, + constraint pk_uuone primary key (id) +); + +create table uutwo ( + id uuid not null, + name varchar(255), + notes varchar(255), + master_id uuid, + version bigint not null, + constraint pk_uutwo primary key (id) +); + +create table oto_user ( + id bigint generated by default as identity not null, + name varchar(255), + account_id bigint not null, + version bigint not null, + when_created timestamp not null, + when_modified timestamp not null, + constraint uq_oto_user_account_id unique (account_id), + constraint pk_oto_user primary key (id) +); + +create table c_user ( + id bigint generated by default as identity not null, + inactive boolean default false not null, + name varchar(255), + email varchar(255), + password_hash varchar(255), + group_id bigint, + version bigint not null, + when_created timestamp not null, + when_modified timestamp not null, + constraint pk_c_user primary key (id) +); + +create table tx_user ( + id bigint generated by default as identity not null, + name varchar(255), + constraint pk_tx_user primary key (id) +); + +create table g_user ( + id bigint generated by default as identity not null, + username varchar(255), + version bigint not null, + constraint pk_g_user primary key (id) +); + +create table em_user ( + id bigint generated by default as identity not null, + name varchar(255), + constraint pk_em_user primary key (id) +); + +create table user_interest_live ( + user_id bigint not null, + live_id bigint not null, + created_at timestamp not null, + constraint pk_user_interest_live primary key (user_id,live_id) +); + +create table em_user_role ( + user_id bigint not null, + role_id bigint not null, + constraint pk_em_user_role primary key (user_id,role_id) +); + +create table vehicle ( + dtype varchar(3) not null, + id integer generated by default as identity not null, + license_number varchar(255), + registration_date timestamp, + lease_id bigint, + cretime timestamp not null, + updtime timestamp not null, + version bigint not null, + siz varchar(3), + driver varchar(255), + car_ref_id integer, + notes varchar(255), + truck_ref_id integer, + capacity double, + constraint ck_vehicle_siz check ( siz in ('S','M','L','H')), + constraint pk_vehicle primary key (id) +); + +create table vehicle_driver ( + id integer generated by default as identity not null, + name varchar(255), + vehicle_id integer, + address_id integer, + license_issued_on timestamp, + cretime timestamp not null, + updtime timestamp not null, + version bigint not null, + constraint pk_vehicle_driver primary key (id) +); + +create table vehicle_lease ( + dtype varchar(31) not null, + id bigint generated by default as identity not null, + name varchar(255), + active_start date, + active_end date, + version bigint not null, + bond decimal(16,3), + min_duration integer not null, + day_rate decimal(16,3), + max_days integer, + constraint pk_vehicle_lease primary key (id) +); + +create table version_child ( + id integer generated by default as identity not null, + name varchar(255), + parent_id integer, + version integer not null, + position integer, + constraint pk_version_child primary key (id) +); + +create table version_parent ( + id integer generated by default as identity not null, + name varchar(255), + version integer not null, + constraint pk_version_parent primary key (id) +); + +create table version_toy ( + id integer generated by default as identity not null, + name varchar(255), + child_id integer, + version integer not null, + position integer, + constraint pk_version_toy primary key (id) +); + +create table warehouses ( + id integer generated by default as identity not null, + officezoneid integer, + constraint pk_warehouses primary key (id) +); + +create table warehousesshippingzones ( + warehouseid integer not null, + shippingzoneid integer not null, + constraint pk_warehousesshippingzones primary key (warehouseid,shippingzoneid) +); + +create table wheel ( + id bigint not null, + version integer not null, + constraint pk_wheel primary key (id) +); +create sequence wheel_seq increment by 1; + +create table sa_wheel ( + id bigint not null, + tire bigint, + car bigint, + version integer not null, + constraint pk_sa_wheel primary key (id) +); +create sequence sa_wheel_seq increment by 1; + +create table sp_car_wheel ( + id bigint not null, + name varchar(255), + version integer not null, + constraint pk_sp_car_wheel primary key (id) +); +create sequence sp_car_wheel_seq increment by 1; + +create table g_who_props_otm ( + id bigint generated by default as identity not null, + name varchar(255), + version bigint not null, + when_created timestamp not null, + when_modified timestamp not null, + who_created_id bigint, + who_modified_id bigint, + constraint pk_g_who_props_otm primary key (id) +); + +create table with_zero ( + id bigint generated by default as identity not null, + name varchar(255), + parent_id integer, + lang varchar(2) default 'en' not null, + version bigint not null, + constraint pk_with_zero primary key (id) +); + +create table parent ( + id integer generated by default as identity not null, + name varchar(255), + constraint pk_parent primary key (id) +); + +create table wview ( + id uuid not null, + name varchar(127) not null, + constraint uq_wview_name unique (name), + constraint pk_wview primary key (id) +); + +create table zones ( + type varchar(31) not null, + id integer generated by default as identity not null, + attribute varchar(255), + constraint pk_zones primary key (id) +); + +create index ix_contact_last_name_first_name on contact (last_name,first_name); +create index ix_e_basic_name on e_basic (name); +create index ix_efile2_no_fk_owner_id on efile2_no_fk (owner_id); +create index ix_ecsm_values_host_id on ecsm_values (host_id); +create index ix_order_referenced_parent_type on order_referenced_parent (type); +create index ix_organization_node_kind on organization_node (kind); +create index ano_3 on test_annotation_base_entity (direct); +create index ano_1 on test_annotation_base_entity (direct); +create index ano_2 on test_annotation_base_entity (direct); +create index ix_bar_foo_id on bar (foo_id); +alter table bar add constraint fk_bar_foo_id foreign key (foo_id) references foo (foo_id) on delete restrict on update restrict; + +create index ix_acl_container_relation_container_id on acl_container_relation (container_id); +alter table acl_container_relation add constraint fk_acl_container_relation_container_id foreign key (container_id) references contract (id) on delete restrict on update restrict; + +create index ix_acl_container_relation_acl_entry_id on acl_container_relation (acl_entry_id); +alter table acl_container_relation add constraint fk_acl_container_relation_acl_entry_id foreign key (acl_entry_id) references acl (id) on delete restrict on update restrict; + +create index ix_addr_employee_id on addr (employee_id); +alter table addr add constraint fk_addr_employee_id foreign key (employee_id) references empl (id) on delete restrict on update restrict; + +create index ix_o_address_country_code on o_address (country_code); +alter table o_address add constraint fk_o_address_country_code foreign key (country_code) references o_country (code) on delete restrict on update restrict; + +alter table album add constraint fk_album_cover_id foreign key (cover_id) references cover (id) on delete restrict on update restrict; + +create index ix_animal_shelter_id on animal (shelter_id); +alter table animal add constraint fk_animal_shelter_id foreign key (shelter_id) references animal_shelter (id) on delete restrict on update restrict; + +create index ix_attribute_attribute_holder_id on attribute (attribute_holder_id); +alter table attribute add constraint fk_attribute_attribute_holder_id foreign key (attribute_holder_id) references attribute_holder (id) on delete restrict on update restrict; + +create index ix_bbookmark_user_id on bbookmark (user_id); +alter table bbookmark add constraint fk_bbookmark_user_id foreign key (user_id) references bbookmark_user (id) on delete restrict on update restrict; + +create index ix_bbookmark_user_org_id on bbookmark_user (org_id); +alter table bbookmark_user add constraint fk_bbookmark_user_org_id foreign key (org_id) references bbookmark_org (id) on delete restrict on update restrict; + +create index ix_bsite_user_a_site_id on bsite_user_a (site_id); +alter table bsite_user_a add constraint fk_bsite_user_a_site_id foreign key (site_id) references bsite (id) on delete restrict on update restrict; + +create index ix_bsite_user_a_user_id on bsite_user_a (user_id); +alter table bsite_user_a add constraint fk_bsite_user_a_user_id foreign key (user_id) references buser (id) on delete restrict on update restrict; + +create index ix_bsite_user_b_site on bsite_user_b (site); +alter table bsite_user_b add constraint fk_bsite_user_b_site foreign key (site) references bsite (id) on delete restrict on update restrict; + +create index ix_bsite_user_b_usr on bsite_user_b (usr); +alter table bsite_user_b add constraint fk_bsite_user_b_usr foreign key (usr) references buser (id) on delete restrict on update restrict; + +create index ix_bsite_user_c_site_uid on bsite_user_c (site_uid); +alter table bsite_user_c add constraint fk_bsite_user_c_site_uid foreign key (site_uid) references bsite (id) on delete restrict on update restrict; + +create index ix_bsite_user_c_user_uid on bsite_user_c (user_uid); +alter table bsite_user_c add constraint fk_bsite_user_c_user_uid foreign key (user_uid) references buser (id) on delete restrict on update restrict; + +create index ix_bsite_user_e_site_id on bsite_user_e (site_id); +alter table bsite_user_e add constraint fk_bsite_user_e_site_id foreign key (site_id) references bsite (id) on delete restrict on update restrict; + +create index ix_bsite_user_e_user_id on bsite_user_e (user_id); +alter table bsite_user_e add constraint fk_bsite_user_e_user_id foreign key (user_id) references buser (id) on delete restrict on update restrict; + +alter table basic_draftable_bean add constraint fk_basic_draftable_bean_id foreign key (id) references basic_draftable_bean_draft (id) on delete restrict on update restrict; + +alter table drel_booking add constraint fk_drel_booking_agent_invoice foreign key (agent_invoice) references drel_invoice (id) on delete restrict on update restrict; + +alter table drel_booking add constraint fk_drel_booking_client_invoice foreign key (client_invoice) references drel_invoice (id) on delete restrict on update restrict; + +create index ix_cepproduct_category_category_id on cepproduct_category (category_id); +alter table cepproduct_category add constraint fk_cepproduct_category_category_id foreign key (category_id) references cepcategory (id) on delete restrict on update restrict; + +create index ix_cepproduct_category_product_id on cepproduct_category (product_id); +alter table cepproduct_category add constraint fk_cepproduct_category_product_id foreign key (product_id) references cepproduct (id) on delete restrict on update restrict; + +create index ix_ciaddress_street_id on ciaddress (street_id); +alter table ciaddress add constraint fk_ciaddress_street_id foreign key (street_id) references cistreet_parent (id) on delete restrict on update restrict; + +create index ix_cicustomer_parent_address_id on cicustomer_parent (address_id); +alter table cicustomer_parent add constraint fk_cicustomer_parent_address_id foreign key (address_id) references ciaddress (id) on delete restrict on update restrict; + +create index ix_cinh_ref_ref_id on cinh_ref (ref_id); +alter table cinh_ref add constraint fk_cinh_ref_ref_id foreign key (ref_id) references cinh_root (id) on delete restrict on update restrict; + +create index ix_ckey_detail_parent on ckey_detail (one_key,two_key); +alter table ckey_detail add constraint fk_ckey_detail_parent foreign key (one_key,two_key) references ckey_parent (one_key,two_key) on delete restrict on update restrict; + +create index ix_ckey_parent_assoc_id on ckey_parent (assoc_id); +alter table ckey_parent add constraint fk_ckey_parent_assoc_id foreign key (assoc_id) references ckey_assoc (id) on delete restrict on update restrict; + +create index ix_coone_many_coone_id on coone_many (coone_id); +alter table coone_many add constraint fk_coone_many_coone_id foreign key (coone_id) references coone (id) on delete restrict on update restrict; + +alter table coroot add constraint fk_coroot_one_id foreign key (one_id) references coone (id) on delete restrict on update restrict; + +create index ix_calculation_result_product_configuration_id on calculation_result (product_configuration_id); +alter table calculation_result add constraint fk_calculation_result_product_configuration_id foreign key (product_configuration_id) references configuration (id) on delete restrict on update restrict; + +create index ix_calculation_result_group_configuration_id on calculation_result (group_configuration_id); +alter table calculation_result add constraint fk_calculation_result_group_configuration_id foreign key (group_configuration_id) references configuration (id) on delete restrict on update restrict; + +create index ix_sp_car_car_wheels_sp_car_car on sp_car_car_wheels (car); +alter table sp_car_car_wheels add constraint fk_sp_car_car_wheels_sp_car_car foreign key (car) references sp_car_car (id) on delete restrict on update restrict; + +create index ix_sp_car_car_wheels_sp_car_wheel on sp_car_car_wheels (wheel); +alter table sp_car_car_wheels add constraint fk_sp_car_car_wheels_sp_car_wheel foreign key (wheel) references sp_car_wheel (id) on delete restrict on update restrict; + +create index ix_sp_car_car_doors_sp_car_car on sp_car_car_doors (car); +alter table sp_car_car_doors add constraint fk_sp_car_car_doors_sp_car_car foreign key (car) references sp_car_car (id) on delete restrict on update restrict; + +create index ix_sp_car_car_doors_sp_car_door on sp_car_car_doors (door); +alter table sp_car_car_doors add constraint fk_sp_car_car_doors_sp_car_door foreign key (door) references sp_car_door (id) on delete restrict on update restrict; + +create index ix_car_accessory_fuse_id on car_accessory (fuse_id); +alter table car_accessory add constraint fk_car_accessory_fuse_id foreign key (fuse_id) references car_fuse (id) on delete restrict on update restrict; + +create index ix_car_accessory_car_id on car_accessory (car_id); +alter table car_accessory add constraint fk_car_accessory_car_id foreign key (car_id) references vehicle (id) on delete restrict on update restrict; + +create index ix_category_surveyobjectid on category (surveyobjectid); +alter table category add constraint fk_category_surveyobjectid foreign key (surveyobjectid) references survey (id) on delete restrict on update restrict; + +alter table e_save_test_d add constraint fk_e_save_test_d_parent_id foreign key (parent_id) references e_save_test_c (id) on delete restrict on update restrict; + +create index ix_child_person_some_bean_id on child_person (some_bean_id); +alter table child_person add constraint fk_child_person_some_bean_id foreign key (some_bean_id) references e_basic (id) on delete restrict on update restrict; + +create index ix_child_person_parent_identifier on child_person (parent_identifier); +alter table child_person add constraint fk_child_person_parent_identifier foreign key (parent_identifier) references parent_person (identifier) on delete restrict on update restrict; + +create index ix_cke_client_user on cke_client (username,cod_cpny); +alter table cke_client add constraint fk_cke_client_user foreign key (username,cod_cpny) references cke_user (username,cod_cpny) on delete restrict on update restrict; + +alter table class_super_monkey add constraint fk_class_super_monkey_class_super foreign key (class_super_sid) references class_super (sid) on delete restrict on update restrict; + +alter table class_super_monkey add constraint fk_class_super_monkey_monkey foreign key (monkey_mid) references monkey (mid) on delete restrict on update restrict; + +create index ix_configuration_configurations_id on configuration (configurations_id); +alter table configuration add constraint fk_configuration_configurations_id foreign key (configurations_id) references configurations (id) on delete restrict on update restrict; + +create index ix_contact_customer_id on contact (customer_id); +alter table contact add constraint fk_contact_customer_id foreign key (customer_id) references o_customer (id) on delete restrict on update restrict; + +create index ix_contact_group_id on contact (group_id); +alter table contact add constraint fk_contact_group_id foreign key (group_id) references contact_group (id) on delete restrict on update restrict; + +create index ix_contact_note_contact_id on contact_note (contact_id); +alter table contact_note add constraint fk_contact_note_contact_id foreign key (contact_id) references contact (id) on delete restrict on update restrict; + +create index ix_contract_costs_position_id on contract_costs (position_id); +alter table contract_costs add constraint fk_contract_costs_position_id foreign key (position_id) references e_position (id) on delete restrict on update restrict; + +create index ix_c_conversation_group_id on c_conversation (group_id); +alter table c_conversation add constraint fk_c_conversation_group_id foreign key (group_id) references c_group (id) on delete restrict on update restrict; + +create index ix_o_customer_billing_address_id on o_customer (billing_address_id); +alter table o_customer add constraint fk_o_customer_billing_address_id foreign key (billing_address_id) references o_address (id) on delete restrict on update restrict; + +create index ix_o_customer_shipping_address_id on o_customer (shipping_address_id); +alter table o_customer add constraint fk_o_customer_shipping_address_id foreign key (shipping_address_id) references o_address (id) on delete restrict on update restrict; + +create index ix_dcredit_drol_dcredit on dcredit_drol (dcredit_id); +alter table dcredit_drol add constraint fk_dcredit_drol_dcredit foreign key (dcredit_id) references dcredit (id) on delete restrict on update restrict; + +create index ix_dcredit_drol_drol on dcredit_drol (drol_id); +alter table dcredit_drol add constraint fk_dcredit_drol_drol foreign key (drol_id) references drol (id) on delete restrict on update restrict; + +create index ix_dmachine_organisation_id on dmachine (organisation_id); +alter table dmachine add constraint fk_dmachine_organisation_id foreign key (organisation_id) references dorg (id) on delete restrict on update restrict; + +create index ix_d_machine_aux_use_machine_id on d_machine_aux_use (machine_id); +alter table d_machine_aux_use add constraint fk_d_machine_aux_use_machine_id foreign key (machine_id) references dmachine (id) on delete restrict on update restrict; + +create index ix_d_machine_stats_machine_id on d_machine_stats (machine_id); +alter table d_machine_stats add constraint fk_d_machine_stats_machine_id foreign key (machine_id) references dmachine (id) on delete restrict on update restrict; + +create index ix_d_machine_use_machine_id on d_machine_use (machine_id); +alter table d_machine_use add constraint fk_d_machine_use_machine_id foreign key (machine_id) references dmachine (id) on delete restrict on update restrict; + +create index ix_drot_drol_drot on drot_drol (drot_id); +alter table drot_drol add constraint fk_drot_drol_drot foreign key (drot_id) references drot (id) on delete restrict on update restrict; + +create index ix_drot_drol_drol on drot_drol (drol_id); +alter table drot_drol add constraint fk_drot_drol_drol foreign key (drol_id) references drol (id) on delete restrict on update restrict; + +create index ix_dc_detail_master_id on dc_detail (master_id); +alter table dc_detail add constraint fk_dc_detail_master_id foreign key (master_id) references dc_master (id) on delete restrict on update restrict; + +alter table defaults_model add constraint fk_defaults_model_id foreign key (id) references defaults_model_draft (id) on delete restrict on update restrict; + +create index ix_dfk_cascade_one_id on dfk_cascade (one_id); +alter table dfk_cascade add constraint fk_dfk_cascade_one_id foreign key (one_id) references dfk_cascade_one (id) on delete cascade on update cascade; + +create index ix_dfk_set_null_one_id on dfk_set_null (one_id); +alter table dfk_set_null add constraint fk_dfk_set_null_one_id foreign key (one_id) references dfk_one (id) on delete set null on update set null; + +alter table doc add constraint fk_doc_id foreign key (id) references doc_draft (id) on delete restrict on update restrict; + +create index ix_doc_link_doc on doc_link (doc_id); +alter table doc_link add constraint fk_doc_link_doc foreign key (doc_id) references doc (id) on delete restrict on update restrict; + +create index ix_doc_link_link on doc_link (link_id); +alter table doc_link add constraint fk_doc_link_link foreign key (link_id) references link (id) on delete restrict on update restrict; + +alter table document add constraint fk_document_id foreign key (id) references document_draft (id) on delete restrict on update restrict; + +create index ix_document_organisation_id on document (organisation_id); +alter table document add constraint fk_document_organisation_id foreign key (organisation_id) references organisation (id) on delete restrict on update restrict; + +create index ix_document_draft_organisation_id on document_draft (organisation_id); +alter table document_draft add constraint fk_document_draft_organisation_id foreign key (organisation_id) references organisation (id) on delete restrict on update restrict; + +create index ix_document_media_document_id on document_media (document_id); +alter table document_media add constraint fk_document_media_document_id foreign key (document_id) references document (id) on delete restrict on update restrict; + +create index ix_document_media_draft_document_id on document_media_draft (document_id); +alter table document_media_draft add constraint fk_document_media_draft_document_id foreign key (document_id) references document_draft (id) on delete restrict on update restrict; + +create index ix_e_basicenc_relate_other_id on e_basicenc_relate (other_id); +alter table e_basicenc_relate add constraint fk_e_basicenc_relate_other_id foreign key (other_id) references e_basicenc (id) on delete restrict on update restrict; + +create index ix_ebasic_json_map_detail_owner_id on ebasic_json_map_detail (owner_id); +alter table ebasic_json_map_detail add constraint fk_ebasic_json_map_detail_owner_id foreign key (owner_id) references ebasic_json_map (id) on delete restrict on update restrict; + +create index ix_ebasic_no_sdchild_owner_id on ebasic_no_sdchild (owner_id); +alter table ebasic_no_sdchild add constraint fk_ebasic_no_sdchild_owner_id foreign key (owner_id) references ebasic_soft_delete (id) on delete restrict on update restrict; + +create index ix_ebasic_sdchild_owner_id on ebasic_sdchild (owner_id); +alter table ebasic_sdchild add constraint fk_ebasic_sdchild_owner_id foreign key (owner_id) references ebasic_soft_delete (id) on delete restrict on update restrict; + +create index ix_ecache_child_root_id on ecache_child (root_id); +alter table ecache_child add constraint fk_ecache_child_root_id foreign key (root_id) references ecache_root (id) on delete restrict on update restrict; + +alter table edefault_prop add constraint fk_edefault_prop_e_simple_usertypeid foreign key (e_simple_usertypeid) references esimple (usertypeid) on delete restrict on update restrict; + +create index ix_eemb_inner_outer_id on eemb_inner (outer_id); +alter table eemb_inner add constraint fk_eemb_inner_outer_id foreign key (outer_id) references eemb_outer (id) on delete restrict on update restrict; + +create index ix_einvoice_person_id on einvoice (person_id); +alter table einvoice add constraint fk_einvoice_person_id foreign key (person_id) references eperson (id) on delete restrict on update restrict; + +create index ix_enull_collection_detail_enull_collection_id on enull_collection_detail (enull_collection_id); +alter table enull_collection_detail add constraint fk_enull_collection_detail_enull_collection_id foreign key (enull_collection_id) references enull_collection (id) on delete restrict on update restrict; + +create index ix_eopt_one_a_b_id on eopt_one_a (b_id); +alter table eopt_one_a add constraint fk_eopt_one_a_b_id foreign key (b_id) references eopt_one_b (id) on delete restrict on update restrict; + +create index ix_eopt_one_b_c_id on eopt_one_b (c_id); +alter table eopt_one_b add constraint fk_eopt_one_b_c_id foreign key (c_id) references eopt_one_c (id) on delete restrict on update restrict; + +create index ix_eper_addr_ma_country_code on eper_addr (ma_country_code); +alter table eper_addr add constraint fk_eper_addr_ma_country_code foreign key (ma_country_code) references o_country (code) on delete restrict on update restrict; + +create index ix_esoft_del_book_lend_by_id on esoft_del_book (lend_by_id); +alter table esoft_del_book add constraint fk_esoft_del_book_lend_by_id foreign key (lend_by_id) references esoft_del_user (id) on delete restrict on update restrict; + +create index ix_esoft_del_book_esoft_del_user_esoft_del_book on esoft_del_book_esoft_del_user (esoft_del_book_id); +alter table esoft_del_book_esoft_del_user add constraint fk_esoft_del_book_esoft_del_user_esoft_del_book foreign key (esoft_del_book_id) references esoft_del_book (id) on delete restrict on update restrict; + +create index ix_esoft_del_book_esoft_del_user_esoft_del_user on esoft_del_book_esoft_del_user (esoft_del_user_id); +alter table esoft_del_book_esoft_del_user add constraint fk_esoft_del_book_esoft_del_user_esoft_del_user foreign key (esoft_del_user_id) references esoft_del_user (id) on delete restrict on update restrict; + +create index ix_esoft_del_down_esoft_del_mid_id on esoft_del_down (esoft_del_mid_id); +alter table esoft_del_down add constraint fk_esoft_del_down_esoft_del_mid_id foreign key (esoft_del_mid_id) references esoft_del_mid (id) on delete restrict on update restrict; + +create index ix_esoft_del_mid_top_id on esoft_del_mid (top_id); +alter table esoft_del_mid add constraint fk_esoft_del_mid_top_id foreign key (top_id) references esoft_del_top (id) on delete restrict on update restrict; + +create index ix_esoft_del_mid_up_id on esoft_del_mid (up_id); +alter table esoft_del_mid add constraint fk_esoft_del_mid_up_id foreign key (up_id) references esoft_del_up (id) on delete restrict on update restrict; + +alter table esoft_del_one_a add constraint fk_esoft_del_one_a_oneb_id foreign key (oneb_id) references esoft_del_one_b (id) on delete restrict on update restrict; + +create index ix_esoft_del_role_esoft_del_user_esoft_del_role on esoft_del_role_esoft_del_user (esoft_del_role_id); +alter table esoft_del_role_esoft_del_user add constraint fk_esoft_del_role_esoft_del_user_esoft_del_role foreign key (esoft_del_role_id) references esoft_del_role (id) on delete restrict on update restrict; + +create index ix_esoft_del_role_esoft_del_user_esoft_del_user on esoft_del_role_esoft_del_user (esoft_del_user_id); +alter table esoft_del_role_esoft_del_user add constraint fk_esoft_del_role_esoft_del_user_esoft_del_user foreign key (esoft_del_user_id) references esoft_del_user (id) on delete restrict on update restrict; + +create index ix_esoft_del_user_esoft_del_role_esoft_del_user on esoft_del_user_esoft_del_role (esoft_del_user_id); +alter table esoft_del_user_esoft_del_role add constraint fk_esoft_del_user_esoft_del_role_esoft_del_user foreign key (esoft_del_user_id) references esoft_del_user (id) on delete restrict on update restrict; + +create index ix_esoft_del_user_esoft_del_role_esoft_del_role on esoft_del_user_esoft_del_role (esoft_del_role_id); +alter table esoft_del_user_esoft_del_role add constraint fk_esoft_del_user_esoft_del_role_esoft_del_role foreign key (esoft_del_role_id) references esoft_del_role (id) on delete restrict on update restrict; + +create index ix_rawinherit_uncle_parent_id on rawinherit_uncle (parent_id); +alter table rawinherit_uncle add constraint fk_rawinherit_uncle_parent_id foreign key (parent_id) references rawinherit_parent (id) on delete restrict on update restrict; + +create index ix_evanilla_collection_detail_evanilla_collection_id on evanilla_collection_detail (evanilla_collection_id); +alter table evanilla_collection_detail add constraint fk_evanilla_collection_detail_evanilla_collection_id foreign key (evanilla_collection_id) references evanilla_collection (id) on delete restrict on update restrict; + +create index ix_ec_enum_person_tags_ec_enum_person_id on ec_enum_person_tags (ec_enum_person_id); +alter table ec_enum_person_tags add constraint fk_ec_enum_person_tags_ec_enum_person_id foreign key (ec_enum_person_id) references ec_enum_person (id) on delete restrict on update restrict; + +create index ix_ec_person_phone_owner_id on ec_person_phone (owner_id); +alter table ec_person_phone add constraint fk_ec_person_phone_owner_id foreign key (owner_id) references ec_person (id) on delete restrict on update restrict; + +create index ix_ec_top_person_id on ec_top (person_id); +alter table ec_top add constraint fk_ec_top_person_id foreign key (person_id) references ecs_person (id) on delete restrict on update restrict; + +create index ix_ec_top_ecs_person_ec_top on ec_top_ecs_person (ec_top_id); +alter table ec_top_ecs_person add constraint fk_ec_top_ecs_person_ec_top foreign key (ec_top_id) references ec_top (id) on delete restrict on update restrict; + +create index ix_ec_top_ecs_person_ecs_person on ec_top_ecs_person (ecs_person_id); +alter table ec_top_ecs_person add constraint fk_ec_top_ecs_person_ecs_person foreign key (ecs_person_id) references ecs_person (id) on delete restrict on update restrict; + +create index ix_ecbl_person_phone_numbers_person_id on ecbl_person_phone_numbers (person_id); +alter table ecbl_person_phone_numbers add constraint fk_ecbl_person_phone_numbers_person_id foreign key (person_id) references ecbl_person (id) on delete restrict on update restrict; + +create index ix_ecbm_person_phone_numbers_person_id on ecbm_person_phone_numbers (person_id); +alter table ecbm_person_phone_numbers add constraint fk_ecbm_person_phone_numbers_person_id foreign key (person_id) references ecbm_person (id) on delete restrict on update restrict; + +create index ix_ecm_person_phone_numbers_ecm_person_id on ecm_person_phone_numbers (ecm_person_id); +alter table ecm_person_phone_numbers add constraint fk_ecm_person_phone_numbers_ecm_person_id foreign key (ecm_person_id) references ecm_person (id) on delete restrict on update restrict; + +create index ix_ecmc_person_phone_numbers_ecmc_person_id on ecmc_person_phone_numbers (ecmc_person_id); +alter table ecmc_person_phone_numbers add constraint fk_ecmc_person_phone_numbers_ecmc_person_id foreign key (ecmc_person_id) references ecmc_person (id) on delete restrict on update restrict; + +create index ix_ecs_person_phone_ecs_person_id on ecs_person_phone (ecs_person_id); +alter table ecs_person_phone add constraint fk_ecs_person_phone_ecs_person_id foreign key (ecs_person_id) references ecs_person (id) on delete restrict on update restrict; + +create index ix_ecsm_child_ecsm_parent_id on ecsm_child (ecsm_parent_id); +alter table ecsm_child add constraint fk_ecsm_child_ecsm_parent_id foreign key (ecsm_parent_id) references ecsm_parent (id) on delete restrict on update restrict; + +create index ix_td_child_parent_id on td_child (parent_id); +alter table td_child add constraint fk_td_child_parent_id foreign key (parent_id) references td_parent (parent_id) on delete restrict on update restrict; + +create index ix_element_bean_complex_bean_id on element_bean (complex_bean_id); +alter table element_bean add constraint fk_element_bean_complex_bean_id foreign key (complex_bean_id) references root_bean (id) on delete restrict on update restrict; + +create index ix_empl_default_address_id on empl (default_address_id); +alter table empl add constraint fk_empl_default_address_id foreign key (default_address_id) references addr (id) on delete restrict on update restrict; + +create index ix_esd_detail_master_id on esd_detail (master_id); +alter table esd_detail add constraint fk_esd_detail_master_id foreign key (master_id) references esd_master (id) on delete restrict on update restrict; + +create index ix_grand_parent_person_some_bean_id on grand_parent_person (some_bean_id); +alter table grand_parent_person add constraint fk_grand_parent_person_some_bean_id foreign key (some_bean_id) references e_basic (id) on delete restrict on update restrict; + +create index ix_survey_group_categoryobjectid on survey_group (categoryobjectid); +alter table survey_group add constraint fk_survey_group_categoryobjectid foreign key (categoryobjectid) references category (id) on delete restrict on update restrict; + +create index ix_hx_link_doc_hx_link on hx_link_doc (hx_link_id); +alter table hx_link_doc add constraint fk_hx_link_doc_hx_link foreign key (hx_link_id) references hx_link (id) on delete restrict on update restrict; + +create index ix_hx_link_doc_he_doc on hx_link_doc (he_doc_id); +alter table hx_link_doc add constraint fk_hx_link_doc_he_doc foreign key (he_doc_id) references he_doc (id) on delete restrict on update restrict; + +create index ix_hi_link_doc_hi_link on hi_link_doc (hi_link_id); +alter table hi_link_doc add constraint fk_hi_link_doc_hi_link foreign key (hi_link_id) references hi_link (id) on delete restrict on update restrict; + +create index ix_hi_link_doc_hi_doc on hi_link_doc (hi_doc_id); +alter table hi_link_doc add constraint fk_hi_link_doc_hi_doc foreign key (hi_doc_id) references hi_doc (id) on delete restrict on update restrict; + +create index ix_hi_tthree_hi_ttwo_id on hi_tthree (hi_ttwo_id); +alter table hi_tthree add constraint fk_hi_tthree_hi_ttwo_id foreign key (hi_ttwo_id) references hi_ttwo (id) on delete restrict on update restrict; + +create index ix_hi_ttwo_hi_tone_id on hi_ttwo (hi_tone_id); +alter table hi_ttwo add constraint fk_hi_ttwo_hi_tone_id foreign key (hi_tone_id) references hi_tone (id) on delete restrict on update restrict; + +alter table hsd_setting add constraint fk_hsd_setting_user_id foreign key (user_id) references hsd_user (id) on delete restrict on update restrict; + +create index ix_iaf_segment_status_id on iaf_segment (status_id); +alter table iaf_segment add constraint fk_iaf_segment_status_id foreign key (status_id) references iaf_segment_status (id) on delete restrict on update restrict; + +create index ix_imrelated_owner_id on imrelated (owner_id); +alter table imrelated add constraint fk_imrelated_owner_id foreign key (owner_id) references imroot (id) on delete restrict on update restrict; + +create index ix_info_contact_company_id on info_contact (company_id); +alter table info_contact add constraint fk_info_contact_company_id foreign key (company_id) references info_company (id) on delete restrict on update restrict; + +alter table info_customer add constraint fk_info_customer_company_id foreign key (company_id) references info_company (id) on delete restrict on update restrict; + +alter table inner_report add constraint fk_inner_report_forecast_id foreign key (forecast_id) references stockforecast (id) on delete restrict on update restrict; + +create index ix_drel_invoice_booking on drel_invoice (booking); +alter table drel_invoice add constraint fk_drel_invoice_booking foreign key (booking) references drel_booking (id) on delete restrict on update restrict; + +create index ix_item_etype on item (customer,type); +alter table item add constraint fk_item_etype foreign key (customer,type) references "type" (customer,type) on delete restrict on update restrict; + +create index ix_item_eregion on item (customer,region); +alter table item add constraint fk_item_eregion foreign key (customer,region) references region (customer,type) on delete restrict on update restrict; + +alter table mkeygroup_monkey add constraint fk_mkeygroup_monkey_mkeygroup foreign key (mkeygroup_pid) references mkeygroup (pid) on delete restrict on update restrict; + +alter table mkeygroup_monkey add constraint fk_mkeygroup_monkey_monkey foreign key (monkey_mid) references monkey (mid) on delete restrict on update restrict; + +alter table trainer_monkey add constraint fk_trainer_monkey_trainer foreign key (trainer_tid) references trainer (tid) on delete restrict on update restrict; + +alter table trainer_monkey add constraint fk_trainer_monkey_monkey foreign key (monkey_mid) references monkey (mid) on delete restrict on update restrict; + +alter table troop_monkey add constraint fk_troop_monkey_troop foreign key (troop_pid) references troop (pid) on delete restrict on update restrict; + +alter table troop_monkey add constraint fk_troop_monkey_monkey foreign key (monkey_mid) references monkey (mid) on delete restrict on update restrict; + +create index ix_l2_cldf_reset_bean_child_parent_id on l2_cldf_reset_bean_child (parent_id); +alter table l2_cldf_reset_bean_child add constraint fk_l2_cldf_reset_bean_child_parent_id foreign key (parent_id) references l2_cldf_reset_bean (id) on delete restrict on update restrict; + +create index ix_level1_level4_level1 on level1_level4 (level1_id); +alter table level1_level4 add constraint fk_level1_level4_level1 foreign key (level1_id) references level1 (id) on delete restrict on update restrict; + +create index ix_level1_level4_level4 on level1_level4 (level4_id); +alter table level1_level4 add constraint fk_level1_level4_level4 foreign key (level4_id) references level4 (id) on delete restrict on update restrict; + +create index ix_level1_level2_level1 on level1_level2 (level1_id); +alter table level1_level2 add constraint fk_level1_level2_level1 foreign key (level1_id) references level1 (id) on delete restrict on update restrict; + +create index ix_level1_level2_level2 on level1_level2 (level2_id); +alter table level1_level2 add constraint fk_level1_level2_level2 foreign key (level2_id) references level2 (id) on delete restrict on update restrict; + +create index ix_level2_level3_level2 on level2_level3 (level2_id); +alter table level2_level3 add constraint fk_level2_level3_level2 foreign key (level2_id) references level2 (id) on delete restrict on update restrict; + +create index ix_level2_level3_level3 on level2_level3 (level3_id); +alter table level2_level3 add constraint fk_level2_level3_level3 foreign key (level3_id) references level3 (id) on delete restrict on update restrict; + +alter table link add constraint fk_link_id foreign key (id) references link_draft (id) on delete restrict on update restrict; + +create index ix_la_attr_value_attribute_la_attr_value on la_attr_value_attribute (la_attr_value_id); +alter table la_attr_value_attribute add constraint fk_la_attr_value_attribute_la_attr_value foreign key (la_attr_value_id) references la_attr_value (id) on delete restrict on update restrict; + +create index ix_la_attr_value_attribute_attribute on la_attr_value_attribute (attribute_id); +alter table la_attr_value_attribute add constraint fk_la_attr_value_attribute_attribute foreign key (attribute_id) references attribute (id) on delete restrict on update restrict; + +create index ix_looney_tune_id on looney (tune_id); +alter table looney add constraint fk_looney_tune_id foreign key (tune_id) references tune (id) on delete restrict on update restrict; + +create index ix_mcontact_customer_id on mcontact (customer_id); +alter table mcontact add constraint fk_mcontact_customer_id foreign key (customer_id) references mcustomer (id) on delete restrict on update restrict; + +create index ix_mcontact_message_contact_id on mcontact_message (contact_id); +alter table mcontact_message add constraint fk_mcontact_message_contact_id foreign key (contact_id) references mcontact (id) on delete restrict on update restrict; + +create index ix_mcustomer_shipping_address_id on mcustomer (shipping_address_id); +alter table mcustomer add constraint fk_mcustomer_shipping_address_id foreign key (shipping_address_id) references maddress (id) on delete restrict on update restrict; + +create index ix_mcustomer_billing_address_id on mcustomer (billing_address_id); +alter table mcustomer add constraint fk_mcustomer_billing_address_id foreign key (billing_address_id) references maddress (id) on delete restrict on update restrict; + +create index ix_mmachine_mgroup_mmachine on mmachine_mgroup (mmachine_id); +alter table mmachine_mgroup add constraint fk_mmachine_mgroup_mmachine foreign key (mmachine_id) references mmachine (id) on delete restrict on update restrict; + +create index ix_mmachine_mgroup_mgroup on mmachine_mgroup (mgroup_id); +alter table mmachine_mgroup add constraint fk_mmachine_mgroup_mgroup foreign key (mgroup_id) references mgroup (id) on delete restrict on update restrict; + +create index ix_mprinter_current_state_id on mprinter (current_state_id); +alter table mprinter add constraint fk_mprinter_current_state_id foreign key (current_state_id) references mprinter_state (id) on delete restrict on update restrict; + +alter table mprinter add constraint fk_mprinter_last_swap_cyan_id foreign key (last_swap_cyan_id) references mprinter_state (id) on delete restrict on update restrict; + +alter table mprinter add constraint fk_mprinter_last_swap_magenta_id foreign key (last_swap_magenta_id) references mprinter_state (id) on delete restrict on update restrict; + +alter table mprinter add constraint fk_mprinter_last_swap_yellow_id foreign key (last_swap_yellow_id) references mprinter_state (id) on delete restrict on update restrict; + +alter table mprinter add constraint fk_mprinter_last_swap_black_id foreign key (last_swap_black_id) references mprinter_state (id) on delete restrict on update restrict; + +create index ix_mprinter_state_printer_id on mprinter_state (printer_id); +alter table mprinter_state add constraint fk_mprinter_state_printer_id foreign key (printer_id) references mprinter (id) on delete restrict on update restrict; + +create index ix_mprofile_picture_id on mprofile (picture_id); +alter table mprofile add constraint fk_mprofile_picture_id foreign key (picture_id) references mmedia (id) on delete restrict on update restrict; + +create index ix_mrole_muser_mrole on mrole_muser (mrole_roleid); +alter table mrole_muser add constraint fk_mrole_muser_mrole foreign key (mrole_roleid) references mrole (roleid) on delete restrict on update restrict; + +create index ix_mrole_muser_muser on mrole_muser (muser_userid); +alter table mrole_muser add constraint fk_mrole_muser_muser foreign key (muser_userid) references muser (userid) on delete restrict on update restrict; + +create index ix_muser_user_type_id on muser (user_type_id); +alter table muser add constraint fk_muser_user_type_id foreign key (user_type_id) references muser_type (id) on delete restrict on update restrict; + +create index ix_mail_user_inbox_mail_user on mail_user_inbox (mail_user_id); +alter table mail_user_inbox add constraint fk_mail_user_inbox_mail_user foreign key (mail_user_id) references mail_user (id) on delete restrict on update restrict; + +create index ix_mail_user_inbox_mail_box on mail_user_inbox (mail_box_id); +alter table mail_user_inbox add constraint fk_mail_user_inbox_mail_box foreign key (mail_box_id) references mail_box (id) on delete restrict on update restrict; + +create index ix_mail_user_outbox_mail_user on mail_user_outbox (mail_user_id); +alter table mail_user_outbox add constraint fk_mail_user_outbox_mail_user foreign key (mail_user_id) references mail_user (id) on delete restrict on update restrict; + +create index ix_mail_user_outbox_mail_box on mail_user_outbox (mail_box_id); +alter table mail_user_outbox add constraint fk_mail_user_outbox_mail_box foreign key (mail_box_id) references mail_box (id) on delete restrict on update restrict; + +create index ix_c_message_conversation_id on c_message (conversation_id); +alter table c_message add constraint fk_c_message_conversation_id foreign key (conversation_id) references c_conversation (id) on delete restrict on update restrict; + +create index ix_c_message_user_id on c_message (user_id); +alter table c_message add constraint fk_c_message_user_id foreign key (user_id) references c_user (id) on delete restrict on update restrict; + +alter table meter_contract_data add constraint fk_meter_contract_data_special_needs_client_id foreign key (special_needs_client_id) references meter_special_needs_client (id) on delete restrict on update restrict; + +alter table meter_special_needs_client add constraint fk_meter_special_needs_client_primary_id foreign key (primary_id) references meter_special_needs_contact (id) on delete restrict on update restrict; + +alter table meter_version add constraint fk_meter_version_address_data_id foreign key (address_data_id) references meter_address_data (id) on delete restrict on update restrict; + +alter table meter_version add constraint fk_meter_version_contract_data_id foreign key (contract_data_id) references meter_contract_data (id) on delete restrict on update restrict; + +create index ix_mnoc_user_mnoc_role_mnoc_user on mnoc_user_mnoc_role (mnoc_user_user_id); +alter table mnoc_user_mnoc_role add constraint fk_mnoc_user_mnoc_role_mnoc_user foreign key (mnoc_user_user_id) references mnoc_user (user_id) on delete restrict on update restrict; + +create index ix_mnoc_user_mnoc_role_mnoc_role on mnoc_user_mnoc_role (mnoc_role_role_id); +alter table mnoc_user_mnoc_role add constraint fk_mnoc_user_mnoc_role_mnoc_role foreign key (mnoc_role_role_id) references mnoc_role (role_id) on delete restrict on update restrict; + +create index ix_mny_b_a_id on mny_b (a_id); +alter table mny_b add constraint fk_mny_b_a_id foreign key (a_id) references mny_a (id) on delete restrict on update restrict; + +create index ix_mny_b_mny_c_mny_b on mny_b_mny_c (mny_b_id); +alter table mny_b_mny_c add constraint fk_mny_b_mny_c_mny_b foreign key (mny_b_id) references mny_b (id) on delete restrict on update restrict; + +create index ix_mny_b_mny_c_mny_c on mny_b_mny_c (mny_c_id); +alter table mny_b_mny_c add constraint fk_mny_b_mny_c_mny_c foreign key (mny_c_id) references mny_c (id) on delete restrict on update restrict; + +create index ix_subtopics_mny_topic_1 on subtopics (topic); +alter table subtopics add constraint fk_subtopics_mny_topic_1 foreign key (topic) references mny_topic (id) on delete restrict on update restrict; + +create index ix_subtopics_mny_topic_2 on subtopics (subtopic); +alter table subtopics add constraint fk_subtopics_mny_topic_2 foreign key (subtopic) references mny_topic (id) on delete restrict on update restrict; + +create index ix_mp_role_mp_user_id on mp_role (mp_user_id); +alter table mp_role add constraint fk_mp_role_mp_user_id foreign key (mp_user_id) references mp_user (id) on delete restrict on update restrict; + +create index ix_ms_many_a_many_b_ms_many_a on ms_many_a_many_b (ms_many_a_aid); +alter table ms_many_a_many_b add constraint fk_ms_many_a_many_b_ms_many_a foreign key (ms_many_a_aid) references ms_many_a (aid) on delete restrict on update restrict; + +create index ix_ms_many_a_many_b_ms_many_b on ms_many_a_many_b (ms_many_b_bid); +alter table ms_many_a_many_b add constraint fk_ms_many_a_many_b_ms_many_b foreign key (ms_many_b_bid) references ms_many_b (bid) on delete restrict on update restrict; + +create index ix_ms_many_b_many_a_ms_many_b on ms_many_b_many_a (ms_many_b_bid); +alter table ms_many_b_many_a add constraint fk_ms_many_b_many_a_ms_many_b foreign key (ms_many_b_bid) references ms_many_b (bid) on delete restrict on update restrict; + +create index ix_ms_many_b_many_a_ms_many_a on ms_many_b_many_a (ms_many_a_aid); +alter table ms_many_b_many_a add constraint fk_ms_many_b_many_a_ms_many_a foreign key (ms_many_a_aid) references ms_many_a (aid) on delete restrict on update restrict; + +create index ix_my_lob_size_join_many_parent_id on my_lob_size_join_many (parent_id); +alter table my_lob_size_join_many add constraint fk_my_lob_size_join_many_parent_id foreign key (parent_id) references my_lob_size (id) on delete restrict on update restrict; + +create index ix_o_bean_child_cached_bean_id on o_bean_child (cached_bean_id); +alter table o_bean_child add constraint fk_o_bean_child_cached_bean_id foreign key (cached_bean_id) references o_cached_bean (id) on delete restrict on update restrict; + +create index ix_ocached_app_detail_app_id on ocached_app_detail (app_id); +alter table ocached_app_detail add constraint fk_ocached_app_detail_app_id foreign key (app_id) references ocached_app (id) on delete restrict on update restrict; + +create index ix_o_cached_bean_country_o_cached_bean on o_cached_bean_country (o_cached_bean_id); +alter table o_cached_bean_country add constraint fk_o_cached_bean_country_o_cached_bean foreign key (o_cached_bean_id) references o_cached_bean (id) on delete restrict on update restrict; + +create index ix_o_cached_bean_country_o_country on o_cached_bean_country (o_country_code); +alter table o_cached_bean_country add constraint fk_o_cached_bean_country_o_country foreign key (o_country_code) references o_country (code) on delete restrict on update restrict; + +create index ix_o_cached_bean_child_cached_bean_id on o_cached_bean_child (cached_bean_id); +alter table o_cached_bean_child add constraint fk_o_cached_bean_child_cached_bean_id foreign key (cached_bean_id) references o_cached_bean (id) on delete restrict on update restrict; + +alter table oengine add constraint fk_oengine_car_id foreign key (car_id) references ocar (id) on delete restrict on update restrict; + +alter table ogear_box add constraint fk_ogear_box_car_id foreign key (car_id) references ocar (id) on delete restrict on update restrict; + +create index ix_omvertex_other_omvertex_id on omvertex_other (omvertex_id); +alter table omvertex_other add constraint fk_omvertex_other_omvertex_id foreign key (omvertex_id) references omvertex (id) on delete restrict on update restrict; + +alter table oroad_show_msg add constraint fk_oroad_show_msg_company_id foreign key (company_id) references ocompany (id) on delete restrict on update restrict; + +create index ix_om_account_child_dbo_banana_rama_id on om_account_child_dbo (banana_rama_id); +alter table om_account_child_dbo add constraint fk_om_account_child_dbo_banana_rama_id foreign key (banana_rama_id) references om_account_dbo (id) on delete restrict on update restrict; + +create index ix_om_basic_child_parent_id on om_basic_child (parent_id); +alter table om_basic_child add constraint fk_om_basic_child_parent_id foreign key (parent_id) references om_basic_parent (id) on delete restrict on update restrict; + +create index ix_om_ordered_detail_master_id on om_ordered_detail (master_id); +alter table om_ordered_detail add constraint fk_om_ordered_detail_master_id foreign key (master_id) references om_ordered_master (id) on delete restrict on update restrict; + +create index ix_oml_baz_foo_id on oml_baz (foo_id); +alter table oml_baz add constraint fk_oml_baz_foo_id foreign key (foo_id) references oml_foo (id) on delete restrict on update restrict; + +create index ix_oml_foo_bar_id on oml_foo (bar_id); +alter table oml_foo add constraint fk_oml_foo_bar_id foreign key (bar_id) references oml_bar (id) on delete restrict on update restrict; + +create index ix_o_order_kcustomer_id on o_order (kcustomer_id); +alter table o_order add constraint fk_o_order_kcustomer_id foreign key (kcustomer_id) references o_customer (id) on delete restrict on update restrict; + +create index ix_o_order_detail_order_id on o_order_detail (order_id); +alter table o_order_detail add constraint fk_o_order_detail_order_id foreign key (order_id) references o_order (id) on delete restrict on update restrict; + +create index ix_o_order_detail_product_id on o_order_detail (product_id); +alter table o_order_detail add constraint fk_o_order_detail_product_id foreign key (product_id) references o_product (id) on delete restrict on update restrict; + +create index ix_s_order_items_order_uuid on s_order_items (order_uuid); +alter table s_order_items add constraint fk_s_order_items_order_uuid foreign key (order_uuid) references s_orders (uuid) on delete restrict on update restrict; + +create index ix_order_referenced_parent_master_id on order_referenced_parent (master_id); +alter table order_referenced_parent add constraint fk_order_referenced_parent_master_id foreign key (master_id) references order_master (id) on delete restrict on update restrict; + +create index ix_or_order_ship_order_id on or_order_ship (order_id); +alter table or_order_ship add constraint fk_or_order_ship_order_id foreign key (order_id) references o_order (id) on delete restrict on update restrict; + +create index ix_order_toy_child_id on order_toy (child_id); +alter table order_toy add constraint fk_order_toy_child_id foreign key (child_id) references order_referenced_parent (id) on delete restrict on update restrict; + +create index ix_ordered_parent_order_master_inheritance_id on ordered_parent (order_master_inheritance_id); +alter table ordered_parent add constraint fk_ordered_parent_order_master_inheritance_id foreign key (order_master_inheritance_id) references order_master_inheritance (id) on delete restrict on update restrict; + +alter table organization_node add constraint fk_organization_node_parent_tree_node_id foreign key (parent_tree_node_id) references organization_tree_node (id) on delete restrict on update restrict; + +create index ix_orp_detail_master_id on orp_detail (master_id); +alter table orp_detail add constraint fk_orp_detail_master_id foreign key (master_id) references orp_master (id) on delete restrict on update restrict; + +create index ix_orp_detail2_orp_master2_id on orp_detail2 (orp_master2_id); +alter table orp_detail2 add constraint fk_orp_detail2_orp_master2_id foreign key (orp_master2_id) references orp_master2 (id) on delete restrict on update restrict; + +alter table oto_atwo add constraint fk_oto_atwo_aone_id foreign key (aone_id) references oto_aone (id) on delete restrict on update restrict; + +alter table oto_bchild add constraint fk_oto_bchild_master_id foreign key (master_id) references oto_bmaster (id) on delete restrict on update restrict; + +alter table oto_child add constraint fk_oto_child_master_id foreign key (master_id) references oto_master (id) on delete restrict on update restrict; + +alter table oto_cust_address add constraint fk_oto_cust_address_customer_cid foreign key (customer_cid) references oto_cust (cid) on delete restrict on update restrict; + +alter table oto_level_a add constraint fk_oto_level_a_b_id foreign key (b_id) references oto_level_b (id) on delete restrict on update restrict; + +alter table oto_level_b add constraint fk_oto_level_b_c_id foreign key (c_id) references oto_level_c (id) on delete restrict on update restrict; + +alter table oto_prime_extra add constraint fk_oto_prime_extra_eid foreign key (eid) references oto_prime (pid) on delete restrict on update restrict; + +alter table oto_sd_child add constraint fk_oto_sd_child_master_id foreign key (master_id) references oto_sd_master (id) on delete restrict on update restrict; + +create index ix_oto_th_many_oto_th_top_id on oto_th_many (oto_th_top_id); +alter table oto_th_many add constraint fk_oto_th_many_oto_th_top_id foreign key (oto_th_top_id) references oto_th_top (id) on delete restrict on update restrict; + +alter table oto_th_one add constraint fk_oto_th_one_many_id foreign key (many_id) references oto_th_many (id) on delete restrict on update restrict; + +alter table oto_ubprime_extra add constraint fk_oto_ubprime_extra_eid foreign key (eid) references oto_ubprime (pid) on delete restrict on update restrict; + +alter table oto_user_model add constraint fk_oto_user_model_user_optional_id foreign key (user_optional_id) references oto_user_model_optional (id) on delete restrict on update restrict; + +alter table pfile add constraint fk_pfile_file_content_id foreign key (file_content_id) references pfile_content (id) on delete restrict on update restrict; + +alter table pfile add constraint fk_pfile_file_content2_id foreign key (file_content2_id) references pfile_content (id) on delete restrict on update restrict; + +alter table paggview add constraint fk_paggview_pview_id foreign key (pview_id) references pp (id) on delete restrict on update restrict; + +create index ix_pallet_location_zone_sid on pallet_location (zone_sid); +alter table pallet_location add constraint fk_pallet_location_zone_sid foreign key (zone_sid) references zones (id) on delete restrict on update restrict; + +alter table parcel_location add constraint fk_parcel_location_parcelid foreign key (parcelid) references parcel (parcelid) on delete restrict on update restrict; + +create index ix_rawinherit_parent_rawinherit_data_rawinherit_parent on rawinherit_parent_rawinherit_data (rawinherit_parent_id); +alter table rawinherit_parent_rawinherit_data add constraint fk_rawinherit_parent_rawinherit_data_rawinherit_parent foreign key (rawinherit_parent_id) references rawinherit_parent (id) on delete restrict on update restrict; + +create index ix_rawinherit_parent_rawinherit_data_rawinherit_data on rawinherit_parent_rawinherit_data (rawinherit_data_id); +alter table rawinherit_parent_rawinherit_data add constraint fk_rawinherit_parent_rawinherit_data_rawinherit_data foreign key (rawinherit_data_id) references rawinherit_data (id) on delete restrict on update restrict; + +create index ix_parent_person_some_bean_id on parent_person (some_bean_id); +alter table parent_person add constraint fk_parent_person_some_bean_id foreign key (some_bean_id) references e_basic (id) on delete restrict on update restrict; + +create index ix_parent_person_parent_identifier on parent_person (parent_identifier); +alter table parent_person add constraint fk_parent_person_parent_identifier foreign key (parent_identifier) references grand_parent_person (identifier) on delete restrict on update restrict; + +create index ix_c_participation_conversation_id on c_participation (conversation_id); +alter table c_participation add constraint fk_c_participation_conversation_id foreign key (conversation_id) references c_conversation (id) on delete restrict on update restrict; + +create index ix_c_participation_user_id on c_participation (user_id); +alter table c_participation add constraint fk_c_participation_user_id foreign key (user_id) references c_user (id) on delete restrict on update restrict; + +create index ix_pcf_calendar_pcf_person_id on pcf_calendar (pcf_person_id); +alter table pcf_calendar add constraint fk_pcf_calendar_pcf_person_id foreign key (pcf_person_id) references pcf_person (id) on delete restrict on update restrict; + +create index ix_pcf_city_pcf_country_id on pcf_city (pcf_country_id); +alter table pcf_city add constraint fk_pcf_city_pcf_country_id foreign key (pcf_country_id) references pcf_country (id) on delete restrict on update restrict; + +alter table pcf_city add constraint fk_pcf_city_mayor_id foreign key (mayor_id) references pcf_person (id) on delete restrict on update restrict; + +alter table pcf_city add constraint fk_pcf_city_vice_mayor_id foreign key (vice_mayor_id) references pcf_person (id) on delete restrict on update restrict; + +create index ix_pcf_event_pcf_calendar_id on pcf_event (pcf_calendar_id); +alter table pcf_event add constraint fk_pcf_event_pcf_calendar_id foreign key (pcf_calendar_id) references pcf_calendar (id) on delete restrict on update restrict; + +alter table persistent_file_content add constraint fk_persistent_file_content_persistent_file_id foreign key (persistent_file_id) references persistent_file (id) on delete restrict on update restrict; + +create index ix_person_default_address_oid on person (default_address_oid); +alter table person add constraint fk_person_default_address_oid foreign key (default_address_oid) references address (oid) on delete restrict on update restrict; + +create index ix_person_cache_email_person_info_person_id on person_cache_email (person_info_person_id); +alter table person_cache_email add constraint fk_person_cache_email_person_info_person_id foreign key (person_info_person_id) references person_cache_info (person_id) on delete restrict on update restrict; + +create index ix_phones_person_id on phones (person_id); +alter table phones add constraint fk_phones_person_id foreign key (person_id) references persons (id) on delete restrict on update restrict; + +create index ix_e_position_contract_id on e_position (contract_id); +alter table e_position add constraint fk_e_position_contract_id foreign key (contract_id) references contract (id) on delete restrict on update restrict; + +create index ix_pp_to_ww_pp on pp_to_ww (pp_id); +alter table pp_to_ww add constraint fk_pp_to_ww_pp foreign key (pp_id) references pp (id) on delete restrict on update restrict; + +create index ix_pp_to_ww_wview on pp_to_ww (ww_id); +alter table pp_to_ww add constraint fk_pp_to_ww_wview foreign key (ww_id) references wview (id) on delete restrict on update restrict; + +create index ix_question_groupobjectid on question (groupobjectid); +alter table question add constraint fk_question_groupobjectid foreign key (groupobjectid) references survey_group (id) on delete restrict on update restrict; + +create index ix_r_orders_customer on r_orders (company,customername); +alter table r_orders add constraint fk_r_orders_customer foreign key (company,customername) references rcustomer (company,name) on delete restrict on update restrict; + +alter table referenced_defaults_model add constraint fk_referenced_defaults_model_id foreign key (id) references referenced_defaults_model_draft (id) on delete restrict on update restrict; + +create index ix_referenced_defaults_model_defaults_model_id on referenced_defaults_model (defaults_model_id); +alter table referenced_defaults_model add constraint fk_referenced_defaults_model_defaults_model_id foreign key (defaults_model_id) references defaults_model (id) on delete restrict on update restrict; + +create index ix_referenced_defaults_model_draft_defaults_model_id on referenced_defaults_model_draft (defaults_model_id); +alter table referenced_defaults_model_draft add constraint fk_referenced_defaults_model_draft_defaults_model_id foreign key (defaults_model_id) references defaults_model_draft (id) on delete restrict on update restrict; + +create index ix_rel_master_detail_id on rel_master (detail_id); +alter table rel_master add constraint fk_rel_master_detail_id foreign key (detail_id) references rel_detail (id) on delete restrict on update restrict; + +create index ix_resourcefile_parentresourcefileid on resourcefile (parentresourcefileid); +alter table resourcefile add constraint fk_resourcefile_parentresourcefileid foreign key (parentresourcefileid) references resourcefile (id) on delete restrict on update restrict; + +create index ix_mt_role_tenant_id on mt_role (tenant_id); +alter table mt_role add constraint fk_mt_role_tenant_id foreign key (tenant_id) references mt_tenant (id) on delete restrict on update restrict; + +create index ix_mt_role_permission_mt_role on mt_role_permission (mt_role_id); +alter table mt_role_permission add constraint fk_mt_role_permission_mt_role foreign key (mt_role_id) references mt_role (id) on delete restrict on update restrict; + +create index ix_mt_role_permission_mt_permission on mt_role_permission (mt_permission_id); +alter table mt_role_permission add constraint fk_mt_role_permission_mt_permission foreign key (mt_permission_id) references mt_permission (id) on delete restrict on update restrict; + +create index ix_root_bean_referencing_bean_id on root_bean (referencing_bean_id); +alter table root_bean add constraint fk_root_bean_referencing_bean_id foreign key (referencing_bean_id) references referencing_bean (id) on delete restrict on update restrict; + +alter table f_second add constraint fk_f_second_first foreign key (first) references f_first (id) on delete restrict on update restrict; + +create index ix_section_article_id on section (article_id); +alter table section add constraint fk_section_article_id foreign key (article_id) references article (id) on delete restrict on update restrict; + +create index ix_self_parent_parent_id on self_parent (parent_id); +alter table self_parent add constraint fk_self_parent_parent_id foreign key (parent_id) references self_parent (id) on delete restrict on update restrict; + +create index ix_self_ref_customer_referred_by_id on self_ref_customer (referred_by_id); +alter table self_ref_customer add constraint fk_self_ref_customer_referred_by_id foreign key (referred_by_id) references self_ref_customer (id) on delete restrict on update restrict; + +create index ix_self_ref_example_parent_id on self_ref_example (parent_id); +alter table self_ref_example add constraint fk_self_ref_example_parent_id foreign key (parent_id) references self_ref_example (id) on delete restrict on update restrict; + +alter table e_save_test_b add constraint fk_e_save_test_b_sibling_a_id foreign key (sibling_a_id) references e_save_test_a (id) on delete restrict on update restrict; + +create index ix_site_parent_id on site (parent_id); +alter table site add constraint fk_site_parent_id foreign key (parent_id) references site (id) on delete restrict on update restrict; + +alter table site add constraint fk_site_data_container_id foreign key (data_container_id) references data_container (id) on delete restrict on update restrict; + +alter table site add constraint fk_site_site_address_id foreign key (site_address_id) references site_address (id) on delete restrict on update restrict; + +create index ix_source_base_target_id on source_base (target_id); +alter table source_base add constraint fk_source_base_target_id foreign key (target_id) references target_base (id) on delete restrict on update restrict; + +create index ix_stockforecast_inner_report_id on stockforecast (inner_report_id); +alter table stockforecast add constraint fk_stockforecast_inner_report_id foreign key (inner_report_id) references inner_report (id) on delete restrict on update restrict; + +create index ix_sub_section_section_id on sub_section (section_id); +alter table sub_section add constraint fk_sub_section_section_id foreign key (section_id) references section (id) on delete restrict on update restrict; + +create index ix_tevent_many_event_id on tevent_many (event_id); +alter table tevent_many add constraint fk_tevent_many_event_id foreign key (event_id) references tevent_one (id) on delete restrict on update restrict; + +alter table tevent_one add constraint fk_tevent_one_event_id foreign key (event_id) references tevent (id) on delete restrict on update restrict; + +create index ix_t_detail_with_other_namexxxyy_master_id on t_detail_with_other_namexxxyy (master_id); +alter table t_detail_with_other_namexxxyy add constraint fk_t_detail_with_other_namexxxyy_master_id foreign key (master_id) references t_atable_thatisrelatively (id) on delete restrict on update restrict; + +create index ix_ttruck_holder_truck_plate_no on ttruck_holder (truck_plate_no); +alter table ttruck_holder add constraint fk_ttruck_holder_truck_plate_no foreign key (truck_plate_no) references tcar (plate_no) on delete restrict on update restrict; + +create index ix_ttruck_holder_basic_id on ttruck_holder (basic_id); +alter table ttruck_holder add constraint fk_ttruck_holder_basic_id foreign key (basic_id) references e_basic (id) on delete restrict on update restrict; + +create index ix_ttruck_holder_item_owner_id on ttruck_holder_item (owner_id); +alter table ttruck_holder_item add constraint fk_ttruck_holder_item_owner_id foreign key (owner_id) references ttruck_holder (id) on delete restrict on update restrict; + +create index ix_twheel_owner_plate_no on twheel (owner_plate_no); +alter table twheel add constraint fk_twheel_owner_plate_no foreign key (owner_plate_no) references tcar (plate_no) on delete restrict on update restrict; + +alter table tire add constraint fk_tire_wheel foreign key (wheel) references wheel (id) on delete restrict on update restrict; + +create index ix_tree_entity_parent_id on tree_entity (parent_id); +alter table tree_entity add constraint fk_tree_entity_parent_id foreign key (parent_id) references tree_entity (id) on delete restrict on update restrict; + +create index ix_trip_vehicle_driver_id on trip (vehicle_driver_id); +alter table trip add constraint fk_trip_vehicle_driver_id foreign key (vehicle_driver_id) references vehicle_driver (id) on delete restrict on update restrict; + +create index ix_trip_address_id on trip (address_id); +alter table trip add constraint fk_trip_address_id foreign key (address_id) references o_address (id) on delete restrict on update restrict; + +create index ix_type_sub_type_id on "type" (sub_type_id); +alter table "type" add constraint fk_type_sub_type_id foreign key (sub_type_id) references sub_type (sub_type_id) on delete restrict on update restrict; + +create index ix_usib_child_parent_id on usib_child (parent_id); +alter table usib_child add constraint fk_usib_child_parent_id foreign key (parent_id) references usib_parent (id) on delete restrict on update restrict; + +alter table usib_child_sibling add constraint fk_usib_child_sibling_child_id foreign key (child_id) references usib_child (id) on delete restrict on update restrict; + +create index ix_ut_detail_utmaster_id on ut_detail (utmaster_id); +alter table ut_detail add constraint fk_ut_detail_utmaster_id foreign key (utmaster_id) references ut_master (id) on delete restrict on update restrict; + +create index ix_uutwo_master_id on uutwo (master_id); +alter table uutwo add constraint fk_uutwo_master_id foreign key (master_id) references uuone (id) on delete restrict on update restrict; + +alter table oto_user add constraint fk_oto_user_account_id foreign key (account_id) references oto_account (id) on delete restrict on update restrict; + +create index ix_c_user_group_id on c_user (group_id); +alter table c_user add constraint fk_c_user_group_id foreign key (group_id) references c_group (id) on delete restrict on update restrict; + +create index ix_em_user_role_user_id on em_user_role (user_id); +alter table em_user_role add constraint fk_em_user_role_user_id foreign key (user_id) references em_user (id) on delete restrict on update restrict; + +create index ix_em_user_role_role_id on em_user_role (role_id); +alter table em_user_role add constraint fk_em_user_role_role_id foreign key (role_id) references em_role (id) on delete restrict on update restrict; + +create index ix_vehicle_lease_id on vehicle (lease_id); +alter table vehicle add constraint fk_vehicle_lease_id foreign key (lease_id) references vehicle_lease (id) on delete restrict on update restrict; + +create index ix_vehicle_car_ref_id on vehicle (car_ref_id); +alter table vehicle add constraint fk_vehicle_car_ref_id foreign key (car_ref_id) references truck_ref (id) on delete restrict on update restrict; + +create index ix_vehicle_truck_ref_id on vehicle (truck_ref_id); +alter table vehicle add constraint fk_vehicle_truck_ref_id foreign key (truck_ref_id) references truck_ref (id) on delete restrict on update restrict; + +create index ix_vehicle_driver_vehicle_id on vehicle_driver (vehicle_id); +alter table vehicle_driver add constraint fk_vehicle_driver_vehicle_id foreign key (vehicle_id) references vehicle (id) on delete restrict on update restrict; + +create index ix_vehicle_driver_address_id on vehicle_driver (address_id); +alter table vehicle_driver add constraint fk_vehicle_driver_address_id foreign key (address_id) references o_address (id) on delete restrict on update restrict; + +create index ix_version_child_parent_id on version_child (parent_id); +alter table version_child add constraint fk_version_child_parent_id foreign key (parent_id) references version_parent (id) on delete restrict on update restrict; + +create index ix_version_toy_child_id on version_toy (child_id); +alter table version_toy add constraint fk_version_toy_child_id foreign key (child_id) references version_child (id) on delete restrict on update restrict; + +create index ix_warehouses_officezoneid on warehouses (officezoneid); +alter table warehouses add constraint fk_warehouses_officezoneid foreign key (officezoneid) references zones (id) on delete restrict on update restrict; + +create index ix_warehousesshippingzones_warehouses on warehousesshippingzones (warehouseid); +alter table warehousesshippingzones add constraint fk_warehousesshippingzones_warehouses foreign key (warehouseid) references warehouses (id) on delete restrict on update restrict; + +create index ix_warehousesshippingzones_zones on warehousesshippingzones (shippingzoneid); +alter table warehousesshippingzones add constraint fk_warehousesshippingzones_zones foreign key (shippingzoneid) references zones (id) on delete restrict on update restrict; + +create index ix_sa_wheel_tire on sa_wheel (tire); +alter table sa_wheel add constraint fk_sa_wheel_tire foreign key (tire) references sa_tire (id) on delete restrict on update restrict; + +create index ix_sa_wheel_car on sa_wheel (car); +alter table sa_wheel add constraint fk_sa_wheel_car foreign key (car) references sa_car (id) on delete restrict on update restrict; + +create index ix_g_who_props_otm_who_created_id on g_who_props_otm (who_created_id); +alter table g_who_props_otm add constraint fk_g_who_props_otm_who_created_id foreign key (who_created_id) references g_user (id) on delete restrict on update restrict; + +create index ix_g_who_props_otm_who_modified_id on g_who_props_otm (who_modified_id); +alter table g_who_props_otm add constraint fk_g_who_props_otm_who_modified_id foreign key (who_modified_id) references g_user (id) on delete restrict on update restrict; + +create index ix_with_zero_parent_id on with_zero (parent_id); +alter table with_zero add constraint fk_with_zero_parent_id foreign key (parent_id) references parent (id) on delete restrict on update restrict; + +alter table hembi_bean add column sys_period_start timestamp default now(); +alter table hembi_bean add column sys_period_end timestamp; +create table hembi_bean_history( + part bigint, + brand varchar(20), + name varchar(255), + description varchar(255), + version bigint, + sys_period_start timestamp, + sys_period_end timestamp +); +create view hembi_bean_with_history as select * from hembi_bean union all select * from hembi_bean_history; + +alter table hx_link add column sys_period_start timestamp default now(); +alter table hx_link add column sys_period_end timestamp; +update hx_link set sys_period_start = when_created; +create table hx_link_history( + id bigint, + name varchar(255), + location varchar(255), + comments varchar(255), + version bigint, + when_created timestamp, + when_modified timestamp, + deleted boolean, + sys_period_start timestamp, + sys_period_end timestamp +); +create view hx_link_with_history as select * from hx_link union all select * from hx_link_history; + +alter table hi_link add column sys_period_start timestamp default now(); +alter table hi_link add column sys_period_end timestamp; +update hi_link set sys_period_start = when_created; +create table hi_link_history( + id bigint, + name varchar(255), + location varchar(255), + comments varchar(255), + version bigint, + when_created timestamp, + when_modified timestamp, + sys_period_start timestamp, + sys_period_end timestamp +); +create view hi_link_with_history as select * from hi_link union all select * from hi_link_history; + +alter table hi_link_doc add column sys_period_start timestamp default now(); +alter table hi_link_doc add column sys_period_end timestamp; +create table hi_link_doc_history( + hi_link_id bigint, + hi_doc_id bigint, + sys_period_start timestamp, + sys_period_end timestamp +); +create view hi_link_doc_with_history as select * from hi_link_doc union all select * from hi_link_doc_history; + +alter table hi_tone add column sys_period_start timestamp default now(); +alter table hi_tone add column sys_period_end timestamp; +update hi_tone set sys_period_start = when_created; +create table hi_tone_history( + id bigint, + name varchar(255), + comments varchar(255), + version bigint, + when_created timestamp, + when_modified timestamp, + sys_period_start timestamp, + sys_period_end timestamp +); +create view hi_tone_with_history as select * from hi_tone union all select * from hi_tone_history; + +alter table hi_tthree add column sys_period_start timestamp default now(); +alter table hi_tthree add column sys_period_end timestamp; +update hi_tthree set sys_period_start = when_created; +create table hi_tthree_history( + id bigint, + hi_ttwo_id bigint, + three varchar(255), + version bigint, + when_created timestamp, + when_modified timestamp, + sys_period_start timestamp, + sys_period_end timestamp +); +create view hi_tthree_with_history as select * from hi_tthree union all select * from hi_tthree_history; + +alter table hi_ttwo add column sys_period_start timestamp default now(); +alter table hi_ttwo add column sys_period_end timestamp; +update hi_ttwo set sys_period_start = when_created; +create table hi_ttwo_history( + id bigint, + hi_tone_id bigint, + two varchar(255), + version bigint, + when_created timestamp, + when_modified timestamp, + sys_period_start timestamp, + sys_period_end timestamp +); +create view hi_ttwo_with_history as select * from hi_ttwo union all select * from hi_ttwo_history; + +alter table hsd_setting add column sys_period_start timestamp default now(); +alter table hsd_setting add column sys_period_end timestamp; +update hsd_setting set sys_period_start = when_created; +create table hsd_setting_history( + id bigint, + code varchar(255), + content varchar(255), + user_id bigint, + version bigint, + when_created timestamp, + when_modified timestamp, + deleted boolean, + sys_period_start timestamp, + sys_period_end timestamp +); +create view hsd_setting_with_history as select * from hsd_setting union all select * from hsd_setting_history; + +alter table hsd_user add column sys_period_start timestamp default now(); +alter table hsd_user add column sys_period_end timestamp; +update hsd_user set sys_period_start = when_created; +create table hsd_user_history( + id bigint, + name varchar(255), + version bigint, + when_created timestamp, + when_modified timestamp, + deleted boolean, + sys_period_start timestamp, + sys_period_end timestamp +); +create view hsd_user_with_history as select * from hsd_user union all select * from hsd_user_history; + +alter table link add column sys_period_start timestamp default now(); +alter table link add column sys_period_end timestamp; +update link set sys_period_start = when_created; +create table link_history( + id bigint, + name varchar(255), + location varchar(255), + when_publish timestamp, + link_comment varchar(255), + version bigint, + when_created timestamp, + when_modified timestamp, + deleted boolean, + sys_period_start timestamp, + sys_period_end timestamp +); +create view link_with_history as select * from link union all select * from link_history; + +alter table c_user add column sys_period_start timestamp default now(); +alter table c_user add column sys_period_end timestamp; +update c_user set sys_period_start = when_created; +create table c_user_history( + id bigint, + inactive boolean, + name varchar(255), + email varchar(255), + password_hash varchar(255), + group_id bigint, + version bigint, + when_created timestamp, + when_modified timestamp, + sys_period_start timestamp, + sys_period_end timestamp +); +create view c_user_with_history as select * from c_user union all select * from c_user_history; + +create trigger hembi_bean_history_upd before update,delete on hembi_bean for each row call "io.ebean.config.dbplatform.h2.H2HistoryTrigger"; +create trigger hx_link_history_upd before update,delete on hx_link for each row call "io.ebean.config.dbplatform.h2.H2HistoryTrigger"; +create trigger hi_link_history_upd before update,delete on hi_link for each row call "io.ebean.config.dbplatform.h2.H2HistoryTrigger"; +create trigger hi_link_doc_history_upd before update,delete on hi_link_doc for each row call "io.ebean.config.dbplatform.h2.H2HistoryTrigger"; +create trigger hi_tone_history_upd before update,delete on hi_tone for each row call "io.ebean.config.dbplatform.h2.H2HistoryTrigger"; +create trigger hi_tthree_history_upd before update,delete on hi_tthree for each row call "io.ebean.config.dbplatform.h2.H2HistoryTrigger"; +create trigger hi_ttwo_history_upd before update,delete on hi_ttwo for each row call "io.ebean.config.dbplatform.h2.H2HistoryTrigger"; +create trigger hsd_setting_history_upd before update,delete on hsd_setting for each row call "io.ebean.config.dbplatform.h2.H2HistoryTrigger"; +create trigger hsd_user_history_upd before update,delete on hsd_user for each row call "io.ebean.config.dbplatform.h2.H2HistoryTrigger"; +create trigger link_history_upd before update,delete on link for each row call "io.ebean.config.dbplatform.h2.H2HistoryTrigger"; +create trigger c_user_history_upd before update,delete on c_user for each row call "io.ebean.config.dbplatform.h2.H2HistoryTrigger"; diff --git a/ebean-core/src/test/ddl-review/h2-drop-all.sql b/ebean-core/src/test/ddl-review/h2-drop-all.sql new file mode 100644 index 000000000..16a4f3c7a --- /dev/null +++ b/ebean-core/src/test/ddl-review/h2-drop-all.sql @@ -0,0 +1,1959 @@ +-- Generated by ebean unknown at 2020-12-07T09:40:50.461215Z +alter table bar drop constraint if exists fk_bar_foo_id; +drop index if exists ix_bar_foo_id; + +alter table acl_container_relation drop constraint if exists fk_acl_container_relation_container_id; +drop index if exists ix_acl_container_relation_container_id; + +alter table acl_container_relation drop constraint if exists fk_acl_container_relation_acl_entry_id; +drop index if exists ix_acl_container_relation_acl_entry_id; + +alter table addr drop constraint if exists fk_addr_employee_id; +drop index if exists ix_addr_employee_id; + +alter table o_address drop constraint if exists fk_o_address_country_code; +drop index if exists ix_o_address_country_code; + +alter table album drop constraint if exists fk_album_cover_id; + +alter table animal drop constraint if exists fk_animal_shelter_id; +drop index if exists ix_animal_shelter_id; + +alter table attribute drop constraint if exists fk_attribute_attribute_holder_id; +drop index if exists ix_attribute_attribute_holder_id; + +alter table bbookmark drop constraint if exists fk_bbookmark_user_id; +drop index if exists ix_bbookmark_user_id; + +alter table bbookmark_user drop constraint if exists fk_bbookmark_user_org_id; +drop index if exists ix_bbookmark_user_org_id; + +alter table bsite_user_a drop constraint if exists fk_bsite_user_a_site_id; +drop index if exists ix_bsite_user_a_site_id; + +alter table bsite_user_a drop constraint if exists fk_bsite_user_a_user_id; +drop index if exists ix_bsite_user_a_user_id; + +alter table bsite_user_b drop constraint if exists fk_bsite_user_b_site; +drop index if exists ix_bsite_user_b_site; + +alter table bsite_user_b drop constraint if exists fk_bsite_user_b_usr; +drop index if exists ix_bsite_user_b_usr; + +alter table bsite_user_c drop constraint if exists fk_bsite_user_c_site_uid; +drop index if exists ix_bsite_user_c_site_uid; + +alter table bsite_user_c drop constraint if exists fk_bsite_user_c_user_uid; +drop index if exists ix_bsite_user_c_user_uid; + +alter table bsite_user_e drop constraint if exists fk_bsite_user_e_site_id; +drop index if exists ix_bsite_user_e_site_id; + +alter table bsite_user_e drop constraint if exists fk_bsite_user_e_user_id; +drop index if exists ix_bsite_user_e_user_id; + +alter table basic_draftable_bean drop constraint if exists fk_basic_draftable_bean_id; + +alter table drel_booking drop constraint if exists fk_drel_booking_agent_invoice; + +alter table drel_booking drop constraint if exists fk_drel_booking_client_invoice; + +alter table cepproduct_category drop constraint if exists fk_cepproduct_category_category_id; +drop index if exists ix_cepproduct_category_category_id; + +alter table cepproduct_category drop constraint if exists fk_cepproduct_category_product_id; +drop index if exists ix_cepproduct_category_product_id; + +alter table ciaddress drop constraint if exists fk_ciaddress_street_id; +drop index if exists ix_ciaddress_street_id; + +alter table cicustomer_parent drop constraint if exists fk_cicustomer_parent_address_id; +drop index if exists ix_cicustomer_parent_address_id; + +alter table cinh_ref drop constraint if exists fk_cinh_ref_ref_id; +drop index if exists ix_cinh_ref_ref_id; + +alter table ckey_detail drop constraint if exists fk_ckey_detail_parent; +drop index if exists ix_ckey_detail_parent; + +alter table ckey_parent drop constraint if exists fk_ckey_parent_assoc_id; +drop index if exists ix_ckey_parent_assoc_id; + +alter table coone_many drop constraint if exists fk_coone_many_coone_id; +drop index if exists ix_coone_many_coone_id; + +alter table coroot drop constraint if exists fk_coroot_one_id; + +alter table calculation_result drop constraint if exists fk_calculation_result_product_configuration_id; +drop index if exists ix_calculation_result_product_configuration_id; + +alter table calculation_result drop constraint if exists fk_calculation_result_group_configuration_id; +drop index if exists ix_calculation_result_group_configuration_id; + +alter table sp_car_car_wheels drop constraint if exists fk_sp_car_car_wheels_sp_car_car; +drop index if exists ix_sp_car_car_wheels_sp_car_car; + +alter table sp_car_car_wheels drop constraint if exists fk_sp_car_car_wheels_sp_car_wheel; +drop index if exists ix_sp_car_car_wheels_sp_car_wheel; + +alter table sp_car_car_doors drop constraint if exists fk_sp_car_car_doors_sp_car_car; +drop index if exists ix_sp_car_car_doors_sp_car_car; + +alter table sp_car_car_doors drop constraint if exists fk_sp_car_car_doors_sp_car_door; +drop index if exists ix_sp_car_car_doors_sp_car_door; + +alter table car_accessory drop constraint if exists fk_car_accessory_fuse_id; +drop index if exists ix_car_accessory_fuse_id; + +alter table car_accessory drop constraint if exists fk_car_accessory_car_id; +drop index if exists ix_car_accessory_car_id; + +alter table category drop constraint if exists fk_category_surveyobjectid; +drop index if exists ix_category_surveyobjectid; + +alter table e_save_test_d drop constraint if exists fk_e_save_test_d_parent_id; + +alter table child_person drop constraint if exists fk_child_person_some_bean_id; +drop index if exists ix_child_person_some_bean_id; + +alter table child_person drop constraint if exists fk_child_person_parent_identifier; +drop index if exists ix_child_person_parent_identifier; + +alter table cke_client drop constraint if exists fk_cke_client_user; +drop index if exists ix_cke_client_user; + +alter table class_super_monkey drop constraint if exists fk_class_super_monkey_class_super; + +alter table class_super_monkey drop constraint if exists fk_class_super_monkey_monkey; + +alter table configuration drop constraint if exists fk_configuration_configurations_id; +drop index if exists ix_configuration_configurations_id; + +alter table contact drop constraint if exists fk_contact_customer_id; +drop index if exists ix_contact_customer_id; + +alter table contact drop constraint if exists fk_contact_group_id; +drop index if exists ix_contact_group_id; + +alter table contact_note drop constraint if exists fk_contact_note_contact_id; +drop index if exists ix_contact_note_contact_id; + +alter table contract_costs drop constraint if exists fk_contract_costs_position_id; +drop index if exists ix_contract_costs_position_id; + +alter table c_conversation drop constraint if exists fk_c_conversation_group_id; +drop index if exists ix_c_conversation_group_id; + +alter table o_customer drop constraint if exists fk_o_customer_billing_address_id; +drop index if exists ix_o_customer_billing_address_id; + +alter table o_customer drop constraint if exists fk_o_customer_shipping_address_id; +drop index if exists ix_o_customer_shipping_address_id; + +alter table dcredit_drol drop constraint if exists fk_dcredit_drol_dcredit; +drop index if exists ix_dcredit_drol_dcredit; + +alter table dcredit_drol drop constraint if exists fk_dcredit_drol_drol; +drop index if exists ix_dcredit_drol_drol; + +alter table dmachine drop constraint if exists fk_dmachine_organisation_id; +drop index if exists ix_dmachine_organisation_id; + +alter table d_machine_aux_use drop constraint if exists fk_d_machine_aux_use_machine_id; +drop index if exists ix_d_machine_aux_use_machine_id; + +alter table d_machine_stats drop constraint if exists fk_d_machine_stats_machine_id; +drop index if exists ix_d_machine_stats_machine_id; + +alter table d_machine_use drop constraint if exists fk_d_machine_use_machine_id; +drop index if exists ix_d_machine_use_machine_id; + +alter table drot_drol drop constraint if exists fk_drot_drol_drot; +drop index if exists ix_drot_drol_drot; + +alter table drot_drol drop constraint if exists fk_drot_drol_drol; +drop index if exists ix_drot_drol_drol; + +alter table dc_detail drop constraint if exists fk_dc_detail_master_id; +drop index if exists ix_dc_detail_master_id; + +alter table defaults_model drop constraint if exists fk_defaults_model_id; + +alter table dfk_cascade drop constraint if exists fk_dfk_cascade_one_id; +drop index if exists ix_dfk_cascade_one_id; + +alter table dfk_set_null drop constraint if exists fk_dfk_set_null_one_id; +drop index if exists ix_dfk_set_null_one_id; + +alter table doc drop constraint if exists fk_doc_id; + +alter table doc_link drop constraint if exists fk_doc_link_doc; +drop index if exists ix_doc_link_doc; + +alter table doc_link drop constraint if exists fk_doc_link_link; +drop index if exists ix_doc_link_link; + +alter table document drop constraint if exists fk_document_id; + +alter table document drop constraint if exists fk_document_organisation_id; +drop index if exists ix_document_organisation_id; + +alter table document_draft drop constraint if exists fk_document_draft_organisation_id; +drop index if exists ix_document_draft_organisation_id; + +alter table document_media drop constraint if exists fk_document_media_document_id; +drop index if exists ix_document_media_document_id; + +alter table document_media_draft drop constraint if exists fk_document_media_draft_document_id; +drop index if exists ix_document_media_draft_document_id; + +alter table e_basicenc_relate drop constraint if exists fk_e_basicenc_relate_other_id; +drop index if exists ix_e_basicenc_relate_other_id; + +alter table ebasic_json_map_detail drop constraint if exists fk_ebasic_json_map_detail_owner_id; +drop index if exists ix_ebasic_json_map_detail_owner_id; + +alter table ebasic_no_sdchild drop constraint if exists fk_ebasic_no_sdchild_owner_id; +drop index if exists ix_ebasic_no_sdchild_owner_id; + +alter table ebasic_sdchild drop constraint if exists fk_ebasic_sdchild_owner_id; +drop index if exists ix_ebasic_sdchild_owner_id; + +alter table ecache_child drop constraint if exists fk_ecache_child_root_id; +drop index if exists ix_ecache_child_root_id; + +alter table edefault_prop drop constraint if exists fk_edefault_prop_e_simple_usertypeid; + +alter table eemb_inner drop constraint if exists fk_eemb_inner_outer_id; +drop index if exists ix_eemb_inner_outer_id; + +alter table einvoice drop constraint if exists fk_einvoice_person_id; +drop index if exists ix_einvoice_person_id; + +alter table enull_collection_detail drop constraint if exists fk_enull_collection_detail_enull_collection_id; +drop index if exists ix_enull_collection_detail_enull_collection_id; + +alter table eopt_one_a drop constraint if exists fk_eopt_one_a_b_id; +drop index if exists ix_eopt_one_a_b_id; + +alter table eopt_one_b drop constraint if exists fk_eopt_one_b_c_id; +drop index if exists ix_eopt_one_b_c_id; + +alter table eper_addr drop constraint if exists fk_eper_addr_ma_country_code; +drop index if exists ix_eper_addr_ma_country_code; + +alter table esoft_del_book drop constraint if exists fk_esoft_del_book_lend_by_id; +drop index if exists ix_esoft_del_book_lend_by_id; + +alter table esoft_del_book_esoft_del_user drop constraint if exists fk_esoft_del_book_esoft_del_user_esoft_del_book; +drop index if exists ix_esoft_del_book_esoft_del_user_esoft_del_book; + +alter table esoft_del_book_esoft_del_user drop constraint if exists fk_esoft_del_book_esoft_del_user_esoft_del_user; +drop index if exists ix_esoft_del_book_esoft_del_user_esoft_del_user; + +alter table esoft_del_down drop constraint if exists fk_esoft_del_down_esoft_del_mid_id; +drop index if exists ix_esoft_del_down_esoft_del_mid_id; + +alter table esoft_del_mid drop constraint if exists fk_esoft_del_mid_top_id; +drop index if exists ix_esoft_del_mid_top_id; + +alter table esoft_del_mid drop constraint if exists fk_esoft_del_mid_up_id; +drop index if exists ix_esoft_del_mid_up_id; + +alter table esoft_del_one_a drop constraint if exists fk_esoft_del_one_a_oneb_id; + +alter table esoft_del_role_esoft_del_user drop constraint if exists fk_esoft_del_role_esoft_del_user_esoft_del_role; +drop index if exists ix_esoft_del_role_esoft_del_user_esoft_del_role; + +alter table esoft_del_role_esoft_del_user drop constraint if exists fk_esoft_del_role_esoft_del_user_esoft_del_user; +drop index if exists ix_esoft_del_role_esoft_del_user_esoft_del_user; + +alter table esoft_del_user_esoft_del_role drop constraint if exists fk_esoft_del_user_esoft_del_role_esoft_del_user; +drop index if exists ix_esoft_del_user_esoft_del_role_esoft_del_user; + +alter table esoft_del_user_esoft_del_role drop constraint if exists fk_esoft_del_user_esoft_del_role_esoft_del_role; +drop index if exists ix_esoft_del_user_esoft_del_role_esoft_del_role; + +alter table rawinherit_uncle drop constraint if exists fk_rawinherit_uncle_parent_id; +drop index if exists ix_rawinherit_uncle_parent_id; + +alter table evanilla_collection_detail drop constraint if exists fk_evanilla_collection_detail_evanilla_collection_id; +drop index if exists ix_evanilla_collection_detail_evanilla_collection_id; + +alter table ec_enum_person_tags drop constraint if exists fk_ec_enum_person_tags_ec_enum_person_id; +drop index if exists ix_ec_enum_person_tags_ec_enum_person_id; + +alter table ec_person_phone drop constraint if exists fk_ec_person_phone_owner_id; +drop index if exists ix_ec_person_phone_owner_id; + +alter table ec_top drop constraint if exists fk_ec_top_person_id; +drop index if exists ix_ec_top_person_id; + +alter table ec_top_ecs_person drop constraint if exists fk_ec_top_ecs_person_ec_top; +drop index if exists ix_ec_top_ecs_person_ec_top; + +alter table ec_top_ecs_person drop constraint if exists fk_ec_top_ecs_person_ecs_person; +drop index if exists ix_ec_top_ecs_person_ecs_person; + +alter table ecbl_person_phone_numbers drop constraint if exists fk_ecbl_person_phone_numbers_person_id; +drop index if exists ix_ecbl_person_phone_numbers_person_id; + +alter table ecbm_person_phone_numbers drop constraint if exists fk_ecbm_person_phone_numbers_person_id; +drop index if exists ix_ecbm_person_phone_numbers_person_id; + +alter table ecm_person_phone_numbers drop constraint if exists fk_ecm_person_phone_numbers_ecm_person_id; +drop index if exists ix_ecm_person_phone_numbers_ecm_person_id; + +alter table ecmc_person_phone_numbers drop constraint if exists fk_ecmc_person_phone_numbers_ecmc_person_id; +drop index if exists ix_ecmc_person_phone_numbers_ecmc_person_id; + +alter table ecs_person_phone drop constraint if exists fk_ecs_person_phone_ecs_person_id; +drop index if exists ix_ecs_person_phone_ecs_person_id; + +alter table ecsm_child drop constraint if exists fk_ecsm_child_ecsm_parent_id; +drop index if exists ix_ecsm_child_ecsm_parent_id; + +alter table td_child drop constraint if exists fk_td_child_parent_id; +drop index if exists ix_td_child_parent_id; + +alter table element_bean drop constraint if exists fk_element_bean_complex_bean_id; +drop index if exists ix_element_bean_complex_bean_id; + +alter table empl drop constraint if exists fk_empl_default_address_id; +drop index if exists ix_empl_default_address_id; + +alter table esd_detail drop constraint if exists fk_esd_detail_master_id; +drop index if exists ix_esd_detail_master_id; + +alter table grand_parent_person drop constraint if exists fk_grand_parent_person_some_bean_id; +drop index if exists ix_grand_parent_person_some_bean_id; + +alter table survey_group drop constraint if exists fk_survey_group_categoryobjectid; +drop index if exists ix_survey_group_categoryobjectid; + +alter table hx_link_doc drop constraint if exists fk_hx_link_doc_hx_link; +drop index if exists ix_hx_link_doc_hx_link; + +alter table hx_link_doc drop constraint if exists fk_hx_link_doc_he_doc; +drop index if exists ix_hx_link_doc_he_doc; + +alter table hi_link_doc drop constraint if exists fk_hi_link_doc_hi_link; +drop index if exists ix_hi_link_doc_hi_link; + +alter table hi_link_doc drop constraint if exists fk_hi_link_doc_hi_doc; +drop index if exists ix_hi_link_doc_hi_doc; + +alter table hi_tthree drop constraint if exists fk_hi_tthree_hi_ttwo_id; +drop index if exists ix_hi_tthree_hi_ttwo_id; + +alter table hi_ttwo drop constraint if exists fk_hi_ttwo_hi_tone_id; +drop index if exists ix_hi_ttwo_hi_tone_id; + +alter table hsd_setting drop constraint if exists fk_hsd_setting_user_id; + +alter table iaf_segment drop constraint if exists fk_iaf_segment_status_id; +drop index if exists ix_iaf_segment_status_id; + +alter table imrelated drop constraint if exists fk_imrelated_owner_id; +drop index if exists ix_imrelated_owner_id; + +alter table info_contact drop constraint if exists fk_info_contact_company_id; +drop index if exists ix_info_contact_company_id; + +alter table info_customer drop constraint if exists fk_info_customer_company_id; + +alter table inner_report drop constraint if exists fk_inner_report_forecast_id; + +alter table drel_invoice drop constraint if exists fk_drel_invoice_booking; +drop index if exists ix_drel_invoice_booking; + +alter table item drop constraint if exists fk_item_etype; +drop index if exists ix_item_etype; + +alter table item drop constraint if exists fk_item_eregion; +drop index if exists ix_item_eregion; + +alter table mkeygroup_monkey drop constraint if exists fk_mkeygroup_monkey_mkeygroup; + +alter table mkeygroup_monkey drop constraint if exists fk_mkeygroup_monkey_monkey; + +alter table trainer_monkey drop constraint if exists fk_trainer_monkey_trainer; + +alter table trainer_monkey drop constraint if exists fk_trainer_monkey_monkey; + +alter table troop_monkey drop constraint if exists fk_troop_monkey_troop; + +alter table troop_monkey drop constraint if exists fk_troop_monkey_monkey; + +alter table l2_cldf_reset_bean_child drop constraint if exists fk_l2_cldf_reset_bean_child_parent_id; +drop index if exists ix_l2_cldf_reset_bean_child_parent_id; + +alter table level1_level4 drop constraint if exists fk_level1_level4_level1; +drop index if exists ix_level1_level4_level1; + +alter table level1_level4 drop constraint if exists fk_level1_level4_level4; +drop index if exists ix_level1_level4_level4; + +alter table level1_level2 drop constraint if exists fk_level1_level2_level1; +drop index if exists ix_level1_level2_level1; + +alter table level1_level2 drop constraint if exists fk_level1_level2_level2; +drop index if exists ix_level1_level2_level2; + +alter table level2_level3 drop constraint if exists fk_level2_level3_level2; +drop index if exists ix_level2_level3_level2; + +alter table level2_level3 drop constraint if exists fk_level2_level3_level3; +drop index if exists ix_level2_level3_level3; + +alter table link drop constraint if exists fk_link_id; + +alter table la_attr_value_attribute drop constraint if exists fk_la_attr_value_attribute_la_attr_value; +drop index if exists ix_la_attr_value_attribute_la_attr_value; + +alter table la_attr_value_attribute drop constraint if exists fk_la_attr_value_attribute_attribute; +drop index if exists ix_la_attr_value_attribute_attribute; + +alter table looney drop constraint if exists fk_looney_tune_id; +drop index if exists ix_looney_tune_id; + +alter table mcontact drop constraint if exists fk_mcontact_customer_id; +drop index if exists ix_mcontact_customer_id; + +alter table mcontact_message drop constraint if exists fk_mcontact_message_contact_id; +drop index if exists ix_mcontact_message_contact_id; + +alter table mcustomer drop constraint if exists fk_mcustomer_shipping_address_id; +drop index if exists ix_mcustomer_shipping_address_id; + +alter table mcustomer drop constraint if exists fk_mcustomer_billing_address_id; +drop index if exists ix_mcustomer_billing_address_id; + +alter table mmachine_mgroup drop constraint if exists fk_mmachine_mgroup_mmachine; +drop index if exists ix_mmachine_mgroup_mmachine; + +alter table mmachine_mgroup drop constraint if exists fk_mmachine_mgroup_mgroup; +drop index if exists ix_mmachine_mgroup_mgroup; + +alter table mprinter drop constraint if exists fk_mprinter_current_state_id; +drop index if exists ix_mprinter_current_state_id; + +alter table mprinter drop constraint if exists fk_mprinter_last_swap_cyan_id; + +alter table mprinter drop constraint if exists fk_mprinter_last_swap_magenta_id; + +alter table mprinter drop constraint if exists fk_mprinter_last_swap_yellow_id; + +alter table mprinter drop constraint if exists fk_mprinter_last_swap_black_id; + +alter table mprinter_state drop constraint if exists fk_mprinter_state_printer_id; +drop index if exists ix_mprinter_state_printer_id; + +alter table mprofile drop constraint if exists fk_mprofile_picture_id; +drop index if exists ix_mprofile_picture_id; + +alter table mrole_muser drop constraint if exists fk_mrole_muser_mrole; +drop index if exists ix_mrole_muser_mrole; + +alter table mrole_muser drop constraint if exists fk_mrole_muser_muser; +drop index if exists ix_mrole_muser_muser; + +alter table muser drop constraint if exists fk_muser_user_type_id; +drop index if exists ix_muser_user_type_id; + +alter table mail_user_inbox drop constraint if exists fk_mail_user_inbox_mail_user; +drop index if exists ix_mail_user_inbox_mail_user; + +alter table mail_user_inbox drop constraint if exists fk_mail_user_inbox_mail_box; +drop index if exists ix_mail_user_inbox_mail_box; + +alter table mail_user_outbox drop constraint if exists fk_mail_user_outbox_mail_user; +drop index if exists ix_mail_user_outbox_mail_user; + +alter table mail_user_outbox drop constraint if exists fk_mail_user_outbox_mail_box; +drop index if exists ix_mail_user_outbox_mail_box; + +alter table c_message drop constraint if exists fk_c_message_conversation_id; +drop index if exists ix_c_message_conversation_id; + +alter table c_message drop constraint if exists fk_c_message_user_id; +drop index if exists ix_c_message_user_id; + +alter table meter_contract_data drop constraint if exists fk_meter_contract_data_special_needs_client_id; + +alter table meter_special_needs_client drop constraint if exists fk_meter_special_needs_client_primary_id; + +alter table meter_version drop constraint if exists fk_meter_version_address_data_id; + +alter table meter_version drop constraint if exists fk_meter_version_contract_data_id; + +alter table mnoc_user_mnoc_role drop constraint if exists fk_mnoc_user_mnoc_role_mnoc_user; +drop index if exists ix_mnoc_user_mnoc_role_mnoc_user; + +alter table mnoc_user_mnoc_role drop constraint if exists fk_mnoc_user_mnoc_role_mnoc_role; +drop index if exists ix_mnoc_user_mnoc_role_mnoc_role; + +alter table mny_b drop constraint if exists fk_mny_b_a_id; +drop index if exists ix_mny_b_a_id; + +alter table mny_b_mny_c drop constraint if exists fk_mny_b_mny_c_mny_b; +drop index if exists ix_mny_b_mny_c_mny_b; + +alter table mny_b_mny_c drop constraint if exists fk_mny_b_mny_c_mny_c; +drop index if exists ix_mny_b_mny_c_mny_c; + +alter table subtopics drop constraint if exists fk_subtopics_mny_topic_1; +drop index if exists ix_subtopics_mny_topic_1; + +alter table subtopics drop constraint if exists fk_subtopics_mny_topic_2; +drop index if exists ix_subtopics_mny_topic_2; + +alter table mp_role drop constraint if exists fk_mp_role_mp_user_id; +drop index if exists ix_mp_role_mp_user_id; + +alter table ms_many_a_many_b drop constraint if exists fk_ms_many_a_many_b_ms_many_a; +drop index if exists ix_ms_many_a_many_b_ms_many_a; + +alter table ms_many_a_many_b drop constraint if exists fk_ms_many_a_many_b_ms_many_b; +drop index if exists ix_ms_many_a_many_b_ms_many_b; + +alter table ms_many_b_many_a drop constraint if exists fk_ms_many_b_many_a_ms_many_b; +drop index if exists ix_ms_many_b_many_a_ms_many_b; + +alter table ms_many_b_many_a drop constraint if exists fk_ms_many_b_many_a_ms_many_a; +drop index if exists ix_ms_many_b_many_a_ms_many_a; + +alter table my_lob_size_join_many drop constraint if exists fk_my_lob_size_join_many_parent_id; +drop index if exists ix_my_lob_size_join_many_parent_id; + +alter table o_bean_child drop constraint if exists fk_o_bean_child_cached_bean_id; +drop index if exists ix_o_bean_child_cached_bean_id; + +alter table ocached_app_detail drop constraint if exists fk_ocached_app_detail_app_id; +drop index if exists ix_ocached_app_detail_app_id; + +alter table o_cached_bean_country drop constraint if exists fk_o_cached_bean_country_o_cached_bean; +drop index if exists ix_o_cached_bean_country_o_cached_bean; + +alter table o_cached_bean_country drop constraint if exists fk_o_cached_bean_country_o_country; +drop index if exists ix_o_cached_bean_country_o_country; + +alter table o_cached_bean_child drop constraint if exists fk_o_cached_bean_child_cached_bean_id; +drop index if exists ix_o_cached_bean_child_cached_bean_id; + +alter table oengine drop constraint if exists fk_oengine_car_id; + +alter table ogear_box drop constraint if exists fk_ogear_box_car_id; + +alter table omvertex_other drop constraint if exists fk_omvertex_other_omvertex_id; +drop index if exists ix_omvertex_other_omvertex_id; + +alter table oroad_show_msg drop constraint if exists fk_oroad_show_msg_company_id; + +alter table om_account_child_dbo drop constraint if exists fk_om_account_child_dbo_banana_rama_id; +drop index if exists ix_om_account_child_dbo_banana_rama_id; + +alter table om_basic_child drop constraint if exists fk_om_basic_child_parent_id; +drop index if exists ix_om_basic_child_parent_id; + +alter table om_ordered_detail drop constraint if exists fk_om_ordered_detail_master_id; +drop index if exists ix_om_ordered_detail_master_id; + +alter table oml_baz drop constraint if exists fk_oml_baz_foo_id; +drop index if exists ix_oml_baz_foo_id; + +alter table oml_foo drop constraint if exists fk_oml_foo_bar_id; +drop index if exists ix_oml_foo_bar_id; + +alter table o_order drop constraint if exists fk_o_order_kcustomer_id; +drop index if exists ix_o_order_kcustomer_id; + +alter table o_order_detail drop constraint if exists fk_o_order_detail_order_id; +drop index if exists ix_o_order_detail_order_id; + +alter table o_order_detail drop constraint if exists fk_o_order_detail_product_id; +drop index if exists ix_o_order_detail_product_id; + +alter table s_order_items drop constraint if exists fk_s_order_items_order_uuid; +drop index if exists ix_s_order_items_order_uuid; + +alter table order_referenced_parent drop constraint if exists fk_order_referenced_parent_master_id; +drop index if exists ix_order_referenced_parent_master_id; + +alter table or_order_ship drop constraint if exists fk_or_order_ship_order_id; +drop index if exists ix_or_order_ship_order_id; + +alter table order_toy drop constraint if exists fk_order_toy_child_id; +drop index if exists ix_order_toy_child_id; + +alter table ordered_parent drop constraint if exists fk_ordered_parent_order_master_inheritance_id; +drop index if exists ix_ordered_parent_order_master_inheritance_id; + +alter table organization_node drop constraint if exists fk_organization_node_parent_tree_node_id; + +alter table orp_detail drop constraint if exists fk_orp_detail_master_id; +drop index if exists ix_orp_detail_master_id; + +alter table orp_detail2 drop constraint if exists fk_orp_detail2_orp_master2_id; +drop index if exists ix_orp_detail2_orp_master2_id; + +alter table oto_atwo drop constraint if exists fk_oto_atwo_aone_id; + +alter table oto_bchild drop constraint if exists fk_oto_bchild_master_id; + +alter table oto_child drop constraint if exists fk_oto_child_master_id; + +alter table oto_cust_address drop constraint if exists fk_oto_cust_address_customer_cid; + +alter table oto_level_a drop constraint if exists fk_oto_level_a_b_id; + +alter table oto_level_b drop constraint if exists fk_oto_level_b_c_id; + +alter table oto_prime_extra drop constraint if exists fk_oto_prime_extra_eid; + +alter table oto_sd_child drop constraint if exists fk_oto_sd_child_master_id; + +alter table oto_th_many drop constraint if exists fk_oto_th_many_oto_th_top_id; +drop index if exists ix_oto_th_many_oto_th_top_id; + +alter table oto_th_one drop constraint if exists fk_oto_th_one_many_id; + +alter table oto_ubprime_extra drop constraint if exists fk_oto_ubprime_extra_eid; + +alter table oto_user_model drop constraint if exists fk_oto_user_model_user_optional_id; + +alter table pfile drop constraint if exists fk_pfile_file_content_id; + +alter table pfile drop constraint if exists fk_pfile_file_content2_id; + +alter table paggview drop constraint if exists fk_paggview_pview_id; + +alter table pallet_location drop constraint if exists fk_pallet_location_zone_sid; +drop index if exists ix_pallet_location_zone_sid; + +alter table parcel_location drop constraint if exists fk_parcel_location_parcelid; + +alter table rawinherit_parent_rawinherit_data drop constraint if exists fk_rawinherit_parent_rawinherit_data_rawinherit_parent; +drop index if exists ix_rawinherit_parent_rawinherit_data_rawinherit_parent; + +alter table rawinherit_parent_rawinherit_data drop constraint if exists fk_rawinherit_parent_rawinherit_data_rawinherit_data; +drop index if exists ix_rawinherit_parent_rawinherit_data_rawinherit_data; + +alter table parent_person drop constraint if exists fk_parent_person_some_bean_id; +drop index if exists ix_parent_person_some_bean_id; + +alter table parent_person drop constraint if exists fk_parent_person_parent_identifier; +drop index if exists ix_parent_person_parent_identifier; + +alter table c_participation drop constraint if exists fk_c_participation_conversation_id; +drop index if exists ix_c_participation_conversation_id; + +alter table c_participation drop constraint if exists fk_c_participation_user_id; +drop index if exists ix_c_participation_user_id; + +alter table pcf_calendar drop constraint if exists fk_pcf_calendar_pcf_person_id; +drop index if exists ix_pcf_calendar_pcf_person_id; + +alter table pcf_city drop constraint if exists fk_pcf_city_pcf_country_id; +drop index if exists ix_pcf_city_pcf_country_id; + +alter table pcf_city drop constraint if exists fk_pcf_city_mayor_id; + +alter table pcf_city drop constraint if exists fk_pcf_city_vice_mayor_id; + +alter table pcf_event drop constraint if exists fk_pcf_event_pcf_calendar_id; +drop index if exists ix_pcf_event_pcf_calendar_id; + +alter table persistent_file_content drop constraint if exists fk_persistent_file_content_persistent_file_id; + +alter table person drop constraint if exists fk_person_default_address_oid; +drop index if exists ix_person_default_address_oid; + +alter table person_cache_email drop constraint if exists fk_person_cache_email_person_info_person_id; +drop index if exists ix_person_cache_email_person_info_person_id; + +alter table phones drop constraint if exists fk_phones_person_id; +drop index if exists ix_phones_person_id; + +alter table e_position drop constraint if exists fk_e_position_contract_id; +drop index if exists ix_e_position_contract_id; + +alter table pp_to_ww drop constraint if exists fk_pp_to_ww_pp; +drop index if exists ix_pp_to_ww_pp; + +alter table pp_to_ww drop constraint if exists fk_pp_to_ww_wview; +drop index if exists ix_pp_to_ww_wview; + +alter table question drop constraint if exists fk_question_groupobjectid; +drop index if exists ix_question_groupobjectid; + +alter table r_orders drop constraint if exists fk_r_orders_customer; +drop index if exists ix_r_orders_customer; + +alter table referenced_defaults_model drop constraint if exists fk_referenced_defaults_model_id; + +alter table referenced_defaults_model drop constraint if exists fk_referenced_defaults_model_defaults_model_id; +drop index if exists ix_referenced_defaults_model_defaults_model_id; + +alter table referenced_defaults_model_draft drop constraint if exists fk_referenced_defaults_model_draft_defaults_model_id; +drop index if exists ix_referenced_defaults_model_draft_defaults_model_id; + +alter table rel_master drop constraint if exists fk_rel_master_detail_id; +drop index if exists ix_rel_master_detail_id; + +alter table resourcefile drop constraint if exists fk_resourcefile_parentresourcefileid; +drop index if exists ix_resourcefile_parentresourcefileid; + +alter table mt_role drop constraint if exists fk_mt_role_tenant_id; +drop index if exists ix_mt_role_tenant_id; + +alter table mt_role_permission drop constraint if exists fk_mt_role_permission_mt_role; +drop index if exists ix_mt_role_permission_mt_role; + +alter table mt_role_permission drop constraint if exists fk_mt_role_permission_mt_permission; +drop index if exists ix_mt_role_permission_mt_permission; + +alter table root_bean drop constraint if exists fk_root_bean_referencing_bean_id; +drop index if exists ix_root_bean_referencing_bean_id; + +alter table f_second drop constraint if exists fk_f_second_first; + +alter table section drop constraint if exists fk_section_article_id; +drop index if exists ix_section_article_id; + +alter table self_parent drop constraint if exists fk_self_parent_parent_id; +drop index if exists ix_self_parent_parent_id; + +alter table self_ref_customer drop constraint if exists fk_self_ref_customer_referred_by_id; +drop index if exists ix_self_ref_customer_referred_by_id; + +alter table self_ref_example drop constraint if exists fk_self_ref_example_parent_id; +drop index if exists ix_self_ref_example_parent_id; + +alter table e_save_test_b drop constraint if exists fk_e_save_test_b_sibling_a_id; + +alter table site drop constraint if exists fk_site_parent_id; +drop index if exists ix_site_parent_id; + +alter table site drop constraint if exists fk_site_data_container_id; + +alter table site drop constraint if exists fk_site_site_address_id; + +alter table source_base drop constraint if exists fk_source_base_target_id; +drop index if exists ix_source_base_target_id; + +alter table stockforecast drop constraint if exists fk_stockforecast_inner_report_id; +drop index if exists ix_stockforecast_inner_report_id; + +alter table sub_section drop constraint if exists fk_sub_section_section_id; +drop index if exists ix_sub_section_section_id; + +alter table tevent_many drop constraint if exists fk_tevent_many_event_id; +drop index if exists ix_tevent_many_event_id; + +alter table tevent_one drop constraint if exists fk_tevent_one_event_id; + +alter table t_detail_with_other_namexxxyy drop constraint if exists fk_t_detail_with_other_namexxxyy_master_id; +drop index if exists ix_t_detail_with_other_namexxxyy_master_id; + +alter table ttruck_holder drop constraint if exists fk_ttruck_holder_truck_plate_no; +drop index if exists ix_ttruck_holder_truck_plate_no; + +alter table ttruck_holder drop constraint if exists fk_ttruck_holder_basic_id; +drop index if exists ix_ttruck_holder_basic_id; + +alter table ttruck_holder_item drop constraint if exists fk_ttruck_holder_item_owner_id; +drop index if exists ix_ttruck_holder_item_owner_id; + +alter table twheel drop constraint if exists fk_twheel_owner_plate_no; +drop index if exists ix_twheel_owner_plate_no; + +alter table tire drop constraint if exists fk_tire_wheel; + +alter table tree_entity drop constraint if exists fk_tree_entity_parent_id; +drop index if exists ix_tree_entity_parent_id; + +alter table trip drop constraint if exists fk_trip_vehicle_driver_id; +drop index if exists ix_trip_vehicle_driver_id; + +alter table trip drop constraint if exists fk_trip_address_id; +drop index if exists ix_trip_address_id; + +alter table "type" drop constraint if exists fk_type_sub_type_id; +drop index if exists ix_type_sub_type_id; + +alter table usib_child drop constraint if exists fk_usib_child_parent_id; +drop index if exists ix_usib_child_parent_id; + +alter table usib_child_sibling drop constraint if exists fk_usib_child_sibling_child_id; + +alter table ut_detail drop constraint if exists fk_ut_detail_utmaster_id; +drop index if exists ix_ut_detail_utmaster_id; + +alter table uutwo drop constraint if exists fk_uutwo_master_id; +drop index if exists ix_uutwo_master_id; + +alter table oto_user drop constraint if exists fk_oto_user_account_id; + +alter table c_user drop constraint if exists fk_c_user_group_id; +drop index if exists ix_c_user_group_id; + +alter table em_user_role drop constraint if exists fk_em_user_role_user_id; +drop index if exists ix_em_user_role_user_id; + +alter table em_user_role drop constraint if exists fk_em_user_role_role_id; +drop index if exists ix_em_user_role_role_id; + +alter table vehicle drop constraint if exists fk_vehicle_lease_id; +drop index if exists ix_vehicle_lease_id; + +alter table vehicle drop constraint if exists fk_vehicle_car_ref_id; +drop index if exists ix_vehicle_car_ref_id; + +alter table vehicle drop constraint if exists fk_vehicle_truck_ref_id; +drop index if exists ix_vehicle_truck_ref_id; + +alter table vehicle_driver drop constraint if exists fk_vehicle_driver_vehicle_id; +drop index if exists ix_vehicle_driver_vehicle_id; + +alter table vehicle_driver drop constraint if exists fk_vehicle_driver_address_id; +drop index if exists ix_vehicle_driver_address_id; + +alter table version_child drop constraint if exists fk_version_child_parent_id; +drop index if exists ix_version_child_parent_id; + +alter table version_toy drop constraint if exists fk_version_toy_child_id; +drop index if exists ix_version_toy_child_id; + +alter table warehouses drop constraint if exists fk_warehouses_officezoneid; +drop index if exists ix_warehouses_officezoneid; + +alter table warehousesshippingzones drop constraint if exists fk_warehousesshippingzones_warehouses; +drop index if exists ix_warehousesshippingzones_warehouses; + +alter table warehousesshippingzones drop constraint if exists fk_warehousesshippingzones_zones; +drop index if exists ix_warehousesshippingzones_zones; + +alter table sa_wheel drop constraint if exists fk_sa_wheel_tire; +drop index if exists ix_sa_wheel_tire; + +alter table sa_wheel drop constraint if exists fk_sa_wheel_car; +drop index if exists ix_sa_wheel_car; + +alter table g_who_props_otm drop constraint if exists fk_g_who_props_otm_who_created_id; +drop index if exists ix_g_who_props_otm_who_created_id; + +alter table g_who_props_otm drop constraint if exists fk_g_who_props_otm_who_modified_id; +drop index if exists ix_g_who_props_otm_who_modified_id; + +alter table with_zero drop constraint if exists fk_with_zero_parent_id; +drop index if exists ix_with_zero_parent_id; + +drop table if exists asimple_bean; + +drop table if exists bar; + +drop table if exists block; + +drop table if exists oto_account; + +drop table if exists acl; + +drop table if exists acl_container_relation; + +drop table if exists addr; + +drop table if exists address; + +drop table if exists o_address; + +drop table if exists album; + +drop table if exists animal; + +drop table if exists animal_shelter; + +drop table if exists article; + +drop table if exists attribute; + +drop table if exists attribute_holder; + +drop table if exists audit_log; + +drop table if exists bbookmark; + +drop table if exists bbookmark_org; + +drop table if exists bbookmark_user; + +drop table if exists bsimple_with_gen; + +drop table if exists bsite; + +drop table if exists bsite_user_a; + +drop table if exists bsite_user_b; + +drop table if exists bsite_user_c; + +drop table if exists bsite_user_d; + +drop table if exists bsite_user_e; + +drop table if exists buser; + +drop table if exists bwith_qident; + +drop table if exists basic_draftable_bean; + +drop table if exists basic_draftable_bean_draft; + +drop table if exists basic_joda_entity; + +drop table if exists bean_with_time_zone; + +drop table if exists drel_booking; +drop sequence if exists drel_booking_seq; + +drop table if exists bw_bean; + +drop table if exists cepcategory; + +drop table if exists cepproduct; + +drop table if exists cepproduct_category; + +drop table if exists ciaddress; + +drop table if exists cicustomer_parent; + +drop table if exists cistreet_parent; + +drop table if exists cinh_ref; + +drop table if exists cinh_root; + +drop table if exists ckey_assoc; + +drop table if exists ckey_detail; + +drop table if exists ckey_parent; + +drop table if exists coone; + +drop table if exists coone_many; + +drop table if exists coroot; + +drop table if exists calculation_result; + +drop table if exists cao_bean; + +drop table if exists sp_car_car; +drop sequence if exists sp_car_car_seq; + +drop table if exists sp_car_car_wheels; + +drop table if exists sp_car_car_doors; + +drop table if exists sa_car; +drop sequence if exists sa_car_seq; + +drop table if exists car_accessory; + +drop table if exists car_fuse; + +drop table if exists category; + +drop table if exists e_save_test_d; + +drop table if exists child_person; + +drop table if exists cke_client; + +drop table if exists cke_user; + +drop table if exists class_super; + +drop table if exists class_super_monkey; + +drop table if exists configuration; + +drop table if exists configurations; + +drop table if exists contact; + +drop table if exists contact_group; + +drop table if exists contact_note; + +drop table if exists contract; + +drop table if exists contract_costs; + +drop table if exists c_conversation; + +drop table if exists o_country; + +drop table if exists cover; + +drop table if exists o_customer; + +drop table if exists dcredit; + +drop table if exists dcredit_drol; + +drop table if exists dexh_entity; + +drop table if exists dint_parent; + +drop table if exists dmachine; + +drop table if exists d_machine_aux_use; + +drop table if exists d_machine_stats; + +drop table if exists d_machine_use; + +drop table if exists dorg; + +drop table if exists dperson; + +drop table if exists drol; + +drop table if exists drot; + +drop table if exists drot_drol; + +drop table if exists rawinherit_data; + +drop table if exists data_container; + +drop table if exists dc_detail; + +drop table if exists dc_master; + +drop table if exists defaults_model; + +drop table if exists defaults_model_draft; + +drop table if exists dfk_cascade; + +drop table if exists dfk_cascade_one; + +drop table if exists dfk_none; + +drop table if exists dfk_none_via_join; + +drop table if exists dfk_none_via_mto_m; + +drop table if exists dfk_none_via_mto_m_dfk_one; + +drop table if exists dfk_one; + +drop table if exists dfk_set_null; + +drop table if exists doc; + +drop table if exists doc_link; + +drop table if exists doc_link_draft; + +drop table if exists doc_draft; + +drop table if exists document; + +drop table if exists document_draft; + +drop table if exists document_media; + +drop table if exists document_media_draft; + +drop table if exists sp_car_door; +drop sequence if exists sp_car_door_seq; + +drop table if exists earray_bean; + +drop table if exists earray_set_bean; + +drop table if exists e_basic; + +drop table if exists ebasic_change_log; + +drop table if exists ebasic_clob; + +drop table if exists ebasic_clob_fetch_eager; + +drop table if exists ebasic_clob_no_ver; + +drop table if exists e_basicenc; + +drop table if exists e_basicenc_bin; + +drop table if exists e_basicenc_client; + +drop table if exists e_basicenc_relate; + +drop table if exists e_basic_enum_id; + +drop table if exists e_basic_eni; + +drop table if exists ebasic_hstore; + +drop table if exists ebasic_json_jackson; + +drop table if exists ebasic_json_jackson2; + +drop table if exists ebasic_json_jackson3; + +drop table if exists ebasic_json_list; + +drop table if exists ebasic_json_map; + +drop table if exists ebasic_json_map_blob; + +drop table if exists ebasic_json_map_clob; + +drop table if exists ebasic_json_map_detail; + +drop table if exists ebasic_json_map_json_b; + +drop table if exists ebasic_json_map_varchar; + +drop table if exists ebasic_json_node; + +drop table if exists ebasic_json_node_blob; + +drop table if exists ebasic_json_node_json_b; + +drop table if exists ebasic_json_node_varchar; + +drop table if exists ebasic_json_unmapped; + +drop table if exists e_basic_ndc; + +drop table if exists ebasic_no_sdchild; + +drop table if exists ebasic_sdchild; + +drop table if exists ebasic_soft_delete; + +drop table if exists e_basicver; + +drop table if exists e_basic_withlife; + +drop table if exists e_basic_with_ex; + +drop table if exists e_basicverucon; + +drop table if exists ecache_child; + +drop table if exists ecache_root; + +drop table if exists e_col_ab; + +drop table if exists ecustom_id; + +drop table if exists edefault_prop; + +drop table if exists eemb_inner; + +drop table if exists eemb_outer; + +drop table if exists efile2_no_fk; + +drop table if exists efile_no_fk; + +drop table if exists efile_no_fk_euser_no_fk; + +drop table if exists efile_no_fk_euser_no_fk_soft_del; + +drop table if exists egen_props; + +drop table if exists eid_uid_bean; + +drop table if exists einvoice; + +drop table if exists e_main; + +drop table if exists enull_collection; + +drop table if exists enull_collection_detail; + +drop table if exists eopt_one_a; + +drop table if exists eopt_one_b; + +drop table if exists eopt_one_c; + +drop table if exists eper_addr; + +drop table if exists eperson; + +drop table if exists eperson2; + +drop table if exists eperson3; + +drop table if exists e_person_online; + +drop table if exists esimple; + +drop table if exists esoft_del_book; + +drop table if exists esoft_del_book_esoft_del_user; + +drop table if exists esoft_del_down; + +drop table if exists esoft_del_mid; + +drop table if exists esoft_del_one_a; + +drop table if exists esoft_del_one_b; + +drop table if exists esoft_del_role; + +drop table if exists esoft_del_role_esoft_del_user; + +drop table if exists esoft_del_top; + +drop table if exists esoft_del_up; + +drop table if exists esoft_del_user; + +drop table if exists esoft_del_user_esoft_del_role; + +drop table if exists esome_convert_type; + +drop table if exists esome_type; + +drop table if exists etrans_many; + +drop table if exists rawinherit_uncle; + +drop table if exists euser_no_fk; + +drop table if exists euser_no_fk_soft_del; + +drop table if exists evanilla_collection; + +drop table if exists evanilla_collection_detail; + +drop table if exists ewho_props; + +drop table if exists e_withinet; + +drop table if exists ec_enum_person; + +drop table if exists ec_enum_person_tags; + +drop table if exists ec_person; + +drop table if exists ec_person_phone; + +drop table if exists ec_top; + +drop table if exists ec_top_ecs_person; + +drop table if exists ecbl_person; + +drop table if exists ecbl_person_phone_numbers; + +drop table if exists ecbm_person; + +drop table if exists ecbm_person_phone_numbers; + +drop table if exists ecm_person; + +drop table if exists ecm_person_phone_numbers; + +drop table if exists ecmc_person; + +drop table if exists ecmc_person_phone_numbers; + +drop table if exists ecs_person; + +drop table if exists ecs_person_phone; + +drop table if exists ecsm_child; + +drop table if exists ecsm_values; + +drop table if exists ecsm_one; + +drop table if exists ecsm_parent; + +drop table if exists ecsm_two; + +drop table if exists td_child; + +drop table if exists td_parent; + +drop table if exists element_bean; + +drop table if exists empl; + +drop table if exists esd_detail; + +drop table if exists esd_master; + +drop table if exists feature_desc; + +drop table if exists f_first; + +drop table if exists foo; + +drop table if exists gen_key_identity; + +drop table if exists gen_key_sequence; +drop sequence if exists SEQ_NAME; + +drop table if exists grand_parent_person; + +drop table if exists survey_group; + +drop table if exists c_group; + +drop trigger hembi_bean_history_upd; +drop view hembi_bean_with_history; +alter table hembi_bean drop column sys_period_start; +alter table hembi_bean drop column sys_period_end; +drop table hembi_bean_history; + +drop table if exists hembi_bean; + +drop table if exists he_doc; + +drop trigger hx_link_history_upd; +drop view hx_link_with_history; +alter table hx_link drop column sys_period_start; +alter table hx_link drop column sys_period_end; +drop table hx_link_history; + +drop table if exists hx_link; + +drop table if exists hx_link_doc; + +drop table if exists hi_doc; + +drop trigger hi_link_history_upd; +drop view hi_link_with_history; +alter table hi_link drop column sys_period_start; +alter table hi_link drop column sys_period_end; +drop table hi_link_history; + +drop table if exists hi_link; + +drop trigger hi_link_doc_history_upd; +drop view hi_link_doc_with_history; +alter table hi_link_doc drop column sys_period_start; +alter table hi_link_doc drop column sys_period_end; +drop table hi_link_doc_history; + +drop table if exists hi_link_doc; + +drop trigger hi_tone_history_upd; +drop view hi_tone_with_history; +alter table hi_tone drop column sys_period_start; +alter table hi_tone drop column sys_period_end; +drop table hi_tone_history; + +drop table if exists hi_tone; + +drop trigger hi_tthree_history_upd; +drop view hi_tthree_with_history; +alter table hi_tthree drop column sys_period_start; +alter table hi_tthree drop column sys_period_end; +drop table hi_tthree_history; + +drop table if exists hi_tthree; + +drop trigger hi_ttwo_history_upd; +drop view hi_ttwo_with_history; +alter table hi_ttwo drop column sys_period_start; +alter table hi_ttwo drop column sys_period_end; +drop table hi_ttwo_history; + +drop table if exists hi_ttwo; + +drop trigger hsd_setting_history_upd; +drop view hsd_setting_with_history; +alter table hsd_setting drop column sys_period_start; +alter table hsd_setting drop column sys_period_end; +drop table hsd_setting_history; + +drop table if exists hsd_setting; + +drop trigger hsd_user_history_upd; +drop view hsd_user_with_history; +alter table hsd_user drop column sys_period_start; +alter table hsd_user drop column sys_period_end; +drop table hsd_user_history; + +drop table if exists hsd_user; + +drop table if exists iaf_segment; + +drop table if exists iaf_segment_status; + +drop table if exists imrelated; + +drop table if exists imroot; + +drop table if exists ixresource; + +drop table if exists info_company; + +drop table if exists info_contact; + +drop table if exists info_customer; + +drop table if exists inner_report; + +drop table if exists drel_invoice; +drop sequence if exists drel_invoice_seq; + +drop table if exists item; + +drop table if exists monkey; + +drop table if exists mkeygroup; + +drop table if exists mkeygroup_monkey; + +drop table if exists trainer; + +drop table if exists trainer_monkey; + +drop table if exists troop; + +drop table if exists troop_monkey; + +drop table if exists l2_cldf_reset_bean; + +drop table if exists l2_cldf_reset_bean_child; + +drop table if exists level1; + +drop table if exists level1_level4; + +drop table if exists level1_level2; + +drop table if exists level2; + +drop table if exists level2_level3; + +drop table if exists level3; + +drop table if exists level4; + +drop trigger link_history_upd; +drop view link_with_history; +alter table link drop column sys_period_start; +alter table link drop column sys_period_end; +drop table link_history; + +drop table if exists link; + +drop table if exists link_draft; + +drop table if exists la_attr_value; + +drop table if exists la_attr_value_attribute; + +drop table if exists looney; + +drop table if exists maddress; + +drop table if exists mcontact; + +drop table if exists mcontact_message; + +drop table if exists mcustomer; + +drop table if exists mgroup; + +drop table if exists mmachine; + +drop table if exists mmachine_mgroup; + +drop table if exists mmedia; + +drop table if exists non_updateprop; + +drop table if exists mprinter; + +drop table if exists mprinter_state; + +drop table if exists mprofile; + +drop table if exists mprotected_construct_bean; + +drop table if exists mrole; + +drop table if exists mrole_muser; + +drop table if exists msome_other; + +drop table if exists muser; + +drop table if exists muser_type; + +drop table if exists mail_box; + +drop table if exists mail_user; + +drop table if exists mail_user_inbox; + +drop table if exists mail_user_outbox; + +drop table if exists main_entity; + +drop table if exists main_entity_relation; + +drop table if exists map_super_actual; + +drop table if exists c_message; + +drop table if exists meter_address_data; + +drop table if exists meter_contract_data; + +drop table if exists meter_special_needs_client; + +drop table if exists meter_special_needs_contact; + +drop table if exists meter_version; + +drop table if exists mnoc_role; + +drop table if exists mnoc_user; + +drop table if exists mnoc_user_mnoc_role; + +drop table if exists mny_a; + +drop table if exists mny_b; + +drop table if exists mny_b_mny_c; + +drop table if exists mny_c; + +drop table if exists mny_topic; + +drop table if exists subtopics; + +drop table if exists mp_role; + +drop table if exists mp_user; + +drop table if exists ms_many_a; + +drop table if exists ms_many_a_many_b; + +drop table if exists ms_many_b; + +drop table if exists ms_many_b_many_a; + +drop table if exists my_lob_size; + +drop table if exists my_lob_size_join_many; + +drop table if exists noidbean; + +drop table if exists o_bean_child; + +drop table if exists ocached_app; + +drop table if exists ocached_app_detail; + +drop table if exists o_cached_bean; + +drop table if exists o_cached_bean_country; + +drop table if exists o_cached_bean_child; + +drop table if exists o_cached_inherit; + +drop table if exists o_cached_natkey; + +drop table if exists o_cached_natkey3; + +drop table if exists ocached_nkey_uid; + +drop table if exists ocar; + +drop table if exists ocompany; + +drop table if exists oengine; + +drop table if exists ogear_box; + +drop table if exists omvertex; + +drop table if exists omvertex_other; + +drop table if exists oroad_show_msg; + +drop table if exists om_account_child_dbo; + +drop table if exists om_account_dbo; + +drop table if exists om_basic_child; + +drop table if exists om_basic_parent; + +drop table if exists om_ordered_detail; + +drop table if exists om_ordered_master; + +drop table if exists oml_bar; + +drop table if exists oml_baz; + +drop table if exists oml_foo; + +drop table if exists only_id_entity; + +drop table if exists o_order; + +drop table if exists o_order_detail; + +drop table if exists s_orders; + +drop table if exists s_order_items; + +drop table if exists order_master; + +drop table if exists order_master_inheritance; + +drop table if exists order_referenced_parent; + +drop table if exists or_order_ship; + +drop table if exists order_toy; + +drop table if exists ordered_parent; + +drop table if exists organisation; + +drop table if exists organization_node; + +drop table if exists organization_tree_node; + +drop table if exists orp_detail; + +drop table if exists orp_detail2; + +drop table if exists orp_master; + +drop table if exists orp_master2; + +drop table if exists oto_aone; + +drop table if exists oto_atwo; + +drop table if exists oto_bchild; + +drop table if exists oto_bmaster; + +drop table if exists oto_child; + +drop table if exists oto_cust; + +drop table if exists oto_cust_address; + +drop table if exists oto_level_a; + +drop table if exists oto_level_b; + +drop table if exists oto_level_c; + +drop table if exists oto_master; + +drop table if exists oto_prime; + +drop table if exists oto_prime_extra; + +drop table if exists oto_sd_child; + +drop table if exists oto_sd_master; + +drop table if exists oto_th_many; + +drop table if exists oto_th_one; + +drop table if exists oto_th_top; + +drop table if exists oto_ubprime; + +drop table if exists oto_ubprime_extra; + +drop table if exists oto_uprime; + +drop table if exists oto_uprime_extra; + +drop table if exists oto_user_model; + +drop table if exists oto_user_model_optional; + +drop table if exists pfile; + +drop table if exists pfile_content; + +drop table if exists paggview; + +drop table if exists pallet_location; + +drop table if exists parcel; + +drop table if exists parcel_location; + +drop table if exists rawinherit_parent; + +drop table if exists rawinherit_parent_rawinherit_data; + +drop table if exists e_save_test_c; + +drop table if exists parent_person; + +drop table if exists c_participation; + +drop table if exists password_store_model; + +drop table if exists pcf_calendar; + +drop table if exists pcf_city; + +drop table if exists pcf_country; + +drop table if exists pcf_event; + +drop table if exists pcf_person; + +drop table if exists mt_permission; + +drop table if exists persistent_file; + +drop table if exists persistent_file_content; + +drop table if exists person; + +drop table if exists persons; + +drop table if exists person_cache_email; + +drop table if exists person_cache_info; + +drop table if exists phones; + +drop table if exists e_position; + +drop table if exists primary_revision; + +drop table if exists o_product; + +drop table if exists pp; + +drop table if exists pp_to_ww; + +drop table if exists question; + +drop table if exists rcustomer; + +drop table if exists r_orders; + +drop table if exists referenced_defaults_model; + +drop table if exists referenced_defaults_model_draft; + +drop table if exists referencing_bean; + +drop table if exists region; + +drop table if exists rel_detail; + +drop table if exists rel_master; + +drop table if exists resourcefile; + +drop table if exists mt_role; + +drop table if exists mt_role_permission; + +drop table if exists em_role; + +drop table if exists root_bean; + +drop table if exists f_second; + +drop table if exists section; + +drop table if exists self_parent; + +drop table if exists self_ref_customer; + +drop table if exists self_ref_example; + +drop table if exists e_save_test_a; + +drop table if exists e_save_test_b; + +drop table if exists site; + +drop table if exists site_address; + +drop table if exists some_enum_bean; + +drop table if exists some_file_bean; + +drop table if exists some_new_types_bean; + +drop table if exists some_period_bean; + +drop table if exists source_base; + +drop table if exists stockforecast; + +drop table if exists sub_section; + +drop table if exists sub_type; + +drop table if exists survey; + +drop table if exists tbytes_only; + +drop table if exists tcar; + +drop table if exists tevent; + +drop table if exists tevent_many; + +drop table if exists tevent_one; + +drop table if exists tint_root; + +drop table if exists tjoda_entity; + +drop table if exists t_mapsuper1; + +drop table if exists t_oneb; + +drop table if exists t_detail_with_other_namexxxyy; +drop sequence if exists t_atable_detail_seq; + +drop table if exists t_atable_thatisrelatively; +drop sequence if exists t_atable_master_seq; + +drop table if exists ttruck_holder; + +drop table if exists ttruck_holder_item; + +drop table if exists tuuid_entity; + +drop table if exists twheel; + +drop table if exists twith_pre_insert; + +drop table if exists target_base; + +drop table if exists mt_tenant; + +drop table if exists test_annotation_base_entity; + +drop table if exists tire; +drop sequence if exists tire_seq; + +drop table if exists sa_tire; +drop sequence if exists sa_tire_seq; + +drop table if exists tree_entity; + +drop table if exists trip; + +drop table if exists truck_ref; + +drop table if exists tune; + +drop table if exists "type"; + +drop table if exists tz_bean; + +drop table if exists usib_child; + +drop table if exists usib_child_sibling; + +drop table if exists usib_parent; + +drop table if exists ut_detail; + +drop table if exists ut_master; + +drop table if exists uuone; + +drop table if exists uutwo; + +drop table if exists oto_user; + +drop trigger c_user_history_upd; +drop view c_user_with_history; +alter table c_user drop column sys_period_start; +alter table c_user drop column sys_period_end; +drop table c_user_history; + +drop table if exists c_user; + +drop table if exists tx_user; + +drop table if exists g_user; + +drop table if exists em_user; + +drop table if exists user_interest_live; + +drop table if exists em_user_role; + +drop table if exists vehicle; + +drop table if exists vehicle_driver; + +drop table if exists vehicle_lease; + +drop table if exists version_child; + +drop table if exists version_parent; + +drop table if exists version_toy; + +drop table if exists warehouses; + +drop table if exists warehousesshippingzones; + +drop table if exists wheel; +drop sequence if exists wheel_seq; + +drop table if exists sa_wheel; +drop sequence if exists sa_wheel_seq; + +drop table if exists sp_car_wheel; +drop sequence if exists sp_car_wheel_seq; + +drop table if exists g_who_props_otm; + +drop table if exists with_zero; + +drop table if exists parent; + +drop table if exists wview; + +drop table if exists zones; + +drop index if exists ix_contact_last_name_first_name; +drop index if exists ix_e_basic_name; +drop index if exists ix_efile2_no_fk_owner_id; +drop index if exists ix_ecsm_values_host_id; +drop index if exists ix_order_referenced_parent_type; +drop index if exists ix_organization_node_kind; +drop index if exists ano_3; +drop index if exists ano_1; +drop index if exists ano_2; diff --git a/ebean-core/src/test/ddl-review/mariadb-create-all.sql b/ebean-core/src/test/ddl-review/mariadb-create-all.sql new file mode 100644 index 000000000..521bb29c1 --- /dev/null +++ b/ebean-core/src/test/ddl-review/mariadb-create-all.sql @@ -0,0 +1,4909 @@ +-- Generated by ebean unknown at 2020-06-29T03:48:37.908711Z +create table asimple_bean ( + id bigint auto_increment not null, + name varchar(255), + constraint pk_asimple_bean primary key (id) +); + +create table bar ( + bar_type varchar(31) not null, + bar_id integer auto_increment not null, + foo_id integer not null, + version integer not null, + constraint pk_bar primary key (bar_id) +); + +create table block ( + case_type integer(31) not null, + id bigint auto_increment not null, + name varchar(255), + version bigint not null, + notes varchar(255), + constraint pk_block primary key (id) +); + +create table oto_account ( + id bigint auto_increment not null, + name varchar(255), + version bigint not null, + when_created datetime(6) not null, + when_modified datetime(6) not null, + constraint pk_oto_account primary key (id) +); + +create table acl ( + id bigint auto_increment not null, + name varchar(255), + constraint pk_acl primary key (id) +); + +create table acl_container_relation ( + id bigint auto_increment not null, + container_id bigint not null, + acl_entry_id bigint not null, + constraint pk_acl_container_relation primary key (id) +); + +create table addr ( + id bigint auto_increment not null, + employee_id bigint, + name varchar(255), + address_line1 varchar(255), + address_line2 varchar(255), + city varchar(255), + version bigint not null, + constraint pk_addr primary key (id) +); + +create table address ( + oid bigint auto_increment not null, + street varchar(255), + version integer not null, + constraint pk_address primary key (oid) +); + +create table o_address ( + id integer auto_increment not null, + line_1 varchar(100), + line_2 varchar(100), + city varchar(100), + cretime datetime(6), + country_code varchar(2), + updtime datetime(6) not null, + constraint pk_o_address primary key (id) +); + +create table album ( + id bigint auto_increment not null, + name varchar(255), + cover_id bigint, + deleted tinyint(1) default 0 not null, + created_at datetime(6) not null, + last_update datetime(6) not null, + constraint uq_album_cover_id unique (cover_id), + constraint pk_album primary key (id) +); + +create table animal ( + species varchar(255) not null, + id bigint auto_increment not null, + shelter_id bigint, + version bigint not null, + name varchar(255), + registration_number varchar(255), + date_of_birth date, + dog_size varchar(255), + constraint pk_animal primary key (id) +); + +create table animal_shelter ( + id bigint auto_increment not null, + name varchar(255), + version bigint not null, + constraint pk_animal_shelter primary key (id) +); + +create table article ( + id integer auto_increment not null, + name varchar(255), + author varchar(255), + cretime datetime(6) not null, + updtime datetime(6) not null, + version bigint not null, + constraint pk_article primary key (id) +); + +create table attribute ( + option_type integer(31) not null, + id integer auto_increment not null, + attribute_holder_id integer, + cretime datetime(6) not null, + updtime datetime(6) not null, + version bigint not null, + constraint pk_attribute primary key (id) +); + +create table attribute_holder ( + id integer auto_increment not null, + cretime datetime(6) not null, + updtime datetime(6) not null, + version bigint not null, + constraint pk_attribute_holder primary key (id) +); + +create table audit_log ( + id bigint auto_increment not null, + description varchar(255), + modified_description varchar(255), + constraint pk_audit_log primary key (id) +); + +create table bbookmark ( + id integer auto_increment not null, + bookmark_reference varchar(255), + user_id integer, + constraint pk_bbookmark primary key (id) +); + +create table bbookmark_org ( + id integer auto_increment not null, + name varchar(255), + constraint pk_bbookmark_org primary key (id) +); + +create table bbookmark_user ( + id integer auto_increment not null, + name varchar(255), + password varchar(255), + email_address varchar(255), + country varchar(255), + org_id integer, + constraint pk_bbookmark_user primary key (id) +); + +create table bsimple_with_gen ( + id integer auto_increment not null, + name varchar(255), + constraint pk_bsimple_with_gen primary key (id) +); + +create table bsite ( + id varchar(40) not null, + name varchar(255), + constraint pk_bsite primary key (id) +); + +create table bsite_user_a ( + site_id varchar(40) not null, + user_id varchar(40) not null, + access_level integer, + version bigint not null, + constraint pk_bsite_user_a primary key (site_id,user_id) +); + +create table bsite_user_b ( + site varchar(40) not null, + usr varchar(40) not null, + access_level integer, + constraint pk_bsite_user_b primary key (site,usr) +); + +create table bsite_user_c ( + site_uid varchar(40) not null, + user_uid varchar(40) not null, + access_level integer, + constraint pk_bsite_user_c primary key (site_uid,user_uid) +); + +create table bsite_user_d ( + site_id varchar(40) not null, + user_id varchar(40) not null, + access_level integer, + version bigint not null +); + +create table bsite_user_e ( + site_id varchar(40) not null, + user_id varchar(40) not null, + access_level integer +); + +create table buser ( + id varchar(40) not null, + name varchar(255), + constraint pk_buser primary key (id) +); + +create table bwith_qident ( + id integer auto_increment not null, + `Name` varchar(191), + `CODE` varchar(255), + last_updated datetime(6) not null, + constraint uq_bwith_qident_name unique (`Name`), + constraint pk_bwith_qident primary key (id) +); + +create table basic_draftable_bean ( + id bigint auto_increment not null, + name varchar(255), + version bigint not null, + when_created datetime(6) not null, + when_modified datetime(6) not null, + constraint pk_basic_draftable_bean primary key (id) +); + +create table basic_draftable_bean_draft ( + id bigint auto_increment not null, + name varchar(255), + version bigint not null, + when_created datetime(6) not null, + when_modified datetime(6) not null, + constraint pk_basic_draftable_bean_draft primary key (id) +); + +create table basic_joda_entity ( + id bigint auto_increment not null, + name varchar(255), + period varchar(50), + local_date date, + created datetime(6) not null, + updated datetime(6) not null, + version datetime(6) not null, + constraint pk_basic_joda_entity primary key (id) +); + +create table bean_with_time_zone ( + id bigint auto_increment not null, + name varchar(255), + timezone varchar(20), + constraint pk_bean_with_time_zone primary key (id) +); + +create table drel_booking ( + id bigint auto_increment not null, + booking_uid bigint, + agent_invoice bigint, + client_invoice bigint, + version integer not null, + constraint uq_drel_booking_booking_uid unique (booking_uid), + constraint uq_drel_booking_agent_invoice unique (agent_invoice), + constraint uq_drel_booking_client_invoice unique (client_invoice), + constraint pk_drel_booking primary key (id) +); + +create table bw_bean ( + id bigint auto_increment not null, + name varchar(255), + flags integer not null, + version bigint not null, + constraint pk_bw_bean primary key (id) +); + +create table cepcategory ( + id bigint auto_increment not null, + name varchar(255), + version bigint not null, + constraint pk_cepcategory primary key (id) +); + +create table cepproduct ( + id bigint auto_increment not null, + name varchar(255), + version bigint not null, + constraint pk_cepproduct primary key (id) +); + +create table cepproduct_category ( + customer_id bigint not null, + address_id bigint not null, + category_id bigint not null, + product_id bigint not null, + priority integer +); + +create table ciaddress ( + id bigint auto_increment not null, + street_id bigint, + constraint pk_ciaddress primary key (id) +); + +create table cicustomer_parent ( + dtype integer(31) not null, + id bigint auto_increment not null, + address_id bigint, + notes varchar(255), + constraint pk_cicustomer_parent primary key (id) +); + +create table cistreet_parent ( + dtype integer(31) not null, + id bigint auto_increment not null, + name varchar(255), + num varchar(255), + constraint pk_cistreet_parent primary key (id) +); + +create table cinh_ref ( + id integer auto_increment not null, + ref_id integer, + cretime datetime(6) not null, + updtime datetime(6) not null, + version bigint not null, + constraint pk_cinh_ref primary key (id) +); + +create table cinh_root ( + dtype varchar(3) not null, + id integer auto_increment not null, + license_number varchar(255), + cretime datetime(6) not null, + updtime datetime(6) not null, + version bigint not null, + driver varchar(255), + notes varchar(255), + action varchar(255), + constraint pk_cinh_root primary key (id) +); + +create table ckey_assoc ( + id integer auto_increment not null, + assoc_one varchar(255), + constraint pk_ckey_assoc primary key (id) +); + +create table ckey_detail ( + id integer auto_increment not null, + something varchar(255), + one_key integer, + two_key varchar(127), + constraint pk_ckey_detail primary key (id) +); + +create table ckey_parent ( + one_key integer not null, + two_key varchar(127) not null, + name varchar(255), + assoc_id integer, + version integer not null, + constraint pk_ckey_parent primary key (one_key,two_key) +); + +create table coone ( + id bigint auto_increment not null, + name varchar(255), + constraint pk_coone primary key (id) +); + +create table coone_many ( + id bigint auto_increment not null, + coone_id bigint not null, + name varchar(255), + deleted tinyint(1) default 0 not null, + constraint pk_coone_many primary key (id) +); + +create table coroot ( + id bigint auto_increment not null, + name varchar(255), + one_id bigint, + constraint uq_coroot_one_id unique (one_id), + constraint pk_coroot primary key (id) +); + +create table calculation_result ( + id integer auto_increment not null, + charge double not null, + product_configuration_id integer, + group_configuration_id integer, + constraint pk_calculation_result primary key (id) +); + +create table cao_bean ( + x_cust_id integer not null, + x_type_id integer not null, + description varchar(255), + version bigint not null, + constraint pk_cao_bean primary key (x_cust_id,x_type_id) +); + +create table sp_car_car ( + id bigint auto_increment not null, + name varchar(255), + version integer not null, + constraint pk_sp_car_car primary key (id) +); + +create table sp_car_car_wheels ( + car bigint not null, + wheel bigint not null, + constraint pk_sp_car_car_wheels primary key (car,wheel) +); + +create table sp_car_car_doors ( + car bigint not null, + door bigint not null, + constraint pk_sp_car_car_doors primary key (car,door) +); + +create table sa_car ( + id bigint auto_increment not null, + brand varchar(255), + sold integer not null, + version integer not null, + constraint pk_sa_car primary key (id) +); + +create table car_accessory ( + id integer auto_increment not null, + name varchar(255), + fuse_id bigint not null, + car_id integer, + cretime datetime(6) not null, + updtime datetime(6) not null, + version bigint not null, + constraint pk_car_accessory primary key (id) +); + +create table car_fuse ( + id bigint auto_increment not null, + location_code varchar(255), + constraint pk_car_fuse primary key (id) +); + +create table category ( + id bigint auto_increment not null, + name varchar(255), + surveyobjectid bigint, + sequence_number integer not null, + constraint pk_category primary key (id) +); + +create table e_save_test_d ( + id bigint auto_increment not null, + parent_id bigint, + test_property tinyint(1) default 0 not null, + version bigint not null, + constraint uq_e_save_test_d_parent_id unique (parent_id), + constraint pk_e_save_test_d primary key (id) +); + +create table child_person ( + identifier integer auto_increment not null, + name varchar(255), + age integer, + some_bean_id integer, + parent_identifier integer, + family_name varchar(255), + address varchar(255), + constraint pk_child_person primary key (identifier) +); + +create table cke_client ( + cod_cpny integer not null, + cod_client varchar(100) not null, + username varchar(100) not null, + notes varchar(255), + constraint pk_cke_client primary key (cod_cpny,cod_client) +); + +create table cke_user ( + username varchar(100) not null, + cod_cpny integer not null, + name varchar(255), + constraint pk_cke_user primary key (username,cod_cpny) +); + +create table class_super ( + dtype varchar(31) not null, + sid bigint auto_increment not null, + constraint pk_class_super primary key (sid) +); + +create table class_super_monkey ( + class_super_sid bigint not null, + monkey_mid bigint not null, + constraint uq_class_super_monkey_mid unique (monkey_mid), + constraint pk_class_super_monkey primary key (class_super_sid,monkey_mid) +); + +create table configuration ( + type varchar(21) not null, + id integer auto_increment not null, + name varchar(255), + configurations_id integer, + group_name varchar(255), + product_name varchar(255), + constraint pk_configuration primary key (id) +); + +create table configurations ( + id integer auto_increment not null, + name varchar(255), + constraint pk_configurations primary key (id) +); + +create table contact ( + id integer auto_increment not null, + first_name varchar(127), + last_name varchar(127), + phone varchar(255), + mobile varchar(255), + email varchar(255), + is_member tinyint(1) default 0 not null, + customer_id integer not null, + group_id integer, + cretime datetime(6) not null, + updtime datetime(6) not null, + constraint pk_contact primary key (id) +); + +create table contact_group ( + id integer auto_increment not null, + name varchar(255), + cretime datetime(6) not null, + updtime datetime(6) not null, + version bigint not null, + constraint pk_contact_group primary key (id) +); + +create table contact_note ( + id integer auto_increment not null, + contact_id integer, + title varchar(255), + note longtext, + cretime datetime(6) not null, + updtime datetime(6) not null, + version bigint not null, + constraint pk_contact_note primary key (id) +); + +create table contract ( + id bigint auto_increment not null, + name varchar(255), + constraint pk_contract primary key (id) +); + +create table contract_costs ( + id bigint auto_increment not null, + status varchar(255), + position_id bigint not null, + constraint pk_contract_costs primary key (id) +); + +create table c_conversation ( + id bigint auto_increment not null, + title varchar(255), + isopen tinyint(1) default 0 not null, + group_id bigint, + version bigint not null, + when_created datetime(6) not null, + when_modified datetime(6) not null, + constraint pk_c_conversation primary key (id) +); + +create table o_country ( + code varchar(2) not null, + name varchar(60), + constraint pk_o_country primary key (code) +); + +create table cover ( + id bigint auto_increment not null, + s3_url varchar(255), + deleted tinyint(1) default 0 not null, + constraint pk_cover primary key (id) +); + +create table o_customer ( + id integer auto_increment not null, + status varchar(1) comment 'status of the customer', + name varchar(40) not null, + smallnote varchar(100) comment 'Short notes regarding the customer', + anniversary date comment 'Join date of the customer', + billing_address_id integer, + shipping_address_id integer, + cretime datetime(6) not null, + updtime datetime(6) not null, + version bigint not null, + constraint pk_o_customer primary key (id) +) comment='Holds external customers'; + +create table dcredit ( + id bigint auto_increment not null, + credit varchar(255), + constraint pk_dcredit primary key (id) +); + +create table dcredit_drol ( + dcredit_id bigint not null, + drol_id bigint not null, + constraint pk_dcredit_drol primary key (dcredit_id,drol_id) +); + +create table dexh_entity ( + oid bigint auto_increment not null, + exhange varchar(255), + an_enum_type varchar(255), + last_updated datetime(6) not null, + constraint pk_dexh_entity primary key (oid) +); + +create table dint_parent ( + type integer(31) not null, + id bigint auto_increment not null, + val integer, + more varchar(255), + constraint pk_dint_parent primary key (id) +); + +create table dmachine ( + id bigint auto_increment not null, + name varchar(255), + organisation_id bigint, + version bigint not null, + constraint pk_dmachine primary key (id) +); + +create table d_machine_aux_use ( + id bigint auto_increment not null, + machine_id bigint not null, + name varchar(255), + edate date, + use_secs bigint not null, + fuel decimal(16,3), + version bigint not null, + constraint pk_d_machine_aux_use primary key (id) +); + +create table d_machine_stats ( + id bigint auto_increment not null, + machine_id bigint not null, + edate date, + total_kms bigint not null, + hours bigint not null, + rate decimal(16,3), + cost decimal(16,3), + version bigint not null, + constraint pk_d_machine_stats primary key (id) +); + +create table d_machine_use ( + id bigint auto_increment not null, + machine_id bigint not null, + edate date, + distance_kms bigint not null, + time_secs bigint not null, + fuel decimal(9,3), + version bigint not null, + constraint pk_d_machine_use primary key (id) +); + +create table dorg ( + id bigint auto_increment not null, + name varchar(255), + version bigint not null, + constraint pk_dorg primary key (id) +); + +create table dperson ( + id bigint auto_increment not null, + first_name varchar(255), + last_name varchar(255), + salary decimal(16,3), + constraint pk_dperson primary key (id) +); + +create table drol ( + id bigint auto_increment not null, + name varchar(255), + constraint pk_drol primary key (id) +); + +create table drot ( + id bigint auto_increment not null, + name varchar(255), + constraint pk_drot primary key (id) +); + +create table drot_drol ( + drot_id bigint not null, + drol_id bigint not null, + constraint pk_drot_drol primary key (drot_id,drol_id) +); + +create table rawinherit_data ( + id bigint auto_increment not null, + val integer, + constraint pk_rawinherit_data primary key (id) +); + +create table data_container ( + id varchar(40) not null, + content varchar(255), + constraint pk_data_container primary key (id) +); + +create table dc_detail ( + id bigint auto_increment not null, + master_id bigint, + description varchar(255), + version bigint not null, + constraint pk_dc_detail primary key (id) +); + +create table dc_master ( + id bigint auto_increment not null, + name varchar(255), + version bigint not null, + constraint pk_dc_master primary key (id) +); + +create table defaults_model ( + id integer auto_increment not null, + constraint pk_defaults_model primary key (id) +); + +create table defaults_model_draft ( + id integer auto_increment not null, + constraint pk_defaults_model_draft primary key (id) +); + +create table dfk_cascade ( + id bigint auto_increment not null, + name varchar(255), + one_id bigint, + constraint pk_dfk_cascade primary key (id) +); + +create table dfk_cascade_one ( + id bigint auto_increment not null, + name varchar(255), + constraint pk_dfk_cascade_one primary key (id) +); + +create table dfk_none ( + id bigint auto_increment not null, + name varchar(255), + one_id bigint, + constraint pk_dfk_none primary key (id) +); + +create table dfk_none_via_join ( + id bigint auto_increment not null, + name varchar(255), + one_id bigint, + constraint pk_dfk_none_via_join primary key (id) +); + +create table dfk_none_via_mto_m ( + id bigint auto_increment not null, + name varchar(255), + constraint pk_dfk_none_via_mto_m primary key (id) +); + +create table dfk_none_via_mto_m_dfk_one ( + dfk_none_via_mto_m_id bigint not null, + dfk_one_id bigint not null, + constraint pk_dfk_none_via_mto_m_dfk_one primary key (dfk_none_via_mto_m_id,dfk_one_id) +); + +create table dfk_one ( + id bigint auto_increment not null, + name varchar(255), + constraint pk_dfk_one primary key (id) +); + +create table dfk_set_null ( + id bigint auto_increment not null, + name varchar(255), + one_id bigint, + constraint pk_dfk_set_null primary key (id) +); + +create table doc ( + id bigint auto_increment not null, + name varchar(255), + version bigint not null, + when_created datetime(6) not null, + when_modified datetime(6) not null, + constraint pk_doc primary key (id) +); + +create table doc_link ( + doc_id bigint not null, + link_id bigint not null, + constraint pk_doc_link primary key (doc_id,link_id) +); + +create table doc_link_draft ( + doc_id bigint not null, + link_id bigint not null, + constraint pk_doc_link_draft primary key (doc_id,link_id) +); + +create table doc_draft ( + id bigint auto_increment not null, + name varchar(255), + version bigint not null, + when_created datetime(6) not null, + when_modified datetime(6) not null, + constraint pk_doc_draft primary key (id) +); + +create table document ( + id bigint auto_increment not null, + title varchar(127), + body varchar(255), + organisation_id bigint, + version bigint not null, + when_created datetime(6) not null, + when_modified datetime(6) not null, + constraint uq_document_title unique (title), + constraint pk_document primary key (id) +); + +create table document_draft ( + id bigint auto_increment not null, + title varchar(127), + body varchar(255), + when_publish datetime(6), + organisation_id bigint, + version bigint not null, + when_created datetime(6) not null, + when_modified datetime(6) not null, + constraint uq_document_draft_title unique (title), + constraint pk_document_draft primary key (id) +); + +create table document_media ( + id bigint auto_increment not null, + document_id bigint, + name varchar(255), + description varchar(255), + version bigint not null, + when_created datetime(6) not null, + when_modified datetime(6) not null, + constraint pk_document_media primary key (id) +); + +create table document_media_draft ( + id bigint auto_increment not null, + document_id bigint, + name varchar(255), + description varchar(255), + version bigint not null, + when_created datetime(6) not null, + when_modified datetime(6) not null, + constraint pk_document_media_draft primary key (id) +); + +create table sp_car_door ( + id bigint auto_increment not null, + name varchar(255), + version integer not null, + constraint pk_sp_car_door primary key (id) +); + +create table earray_bean ( + id bigint auto_increment not null, + foo integer, + name varchar(255), + phone_numbers varchar(300), + uids varchar(1000) not null, + other_ids varchar(1000), + doubs varchar(1000), + statuses varchar(1000), + vc_enums varchar(1000), + int_enums varchar(1000), + status2 varchar(1000), + version bigint not null, + constraint pk_earray_bean primary key (id) +); + +create table earray_set_bean ( + id bigint auto_increment not null, + name varchar(255), + phone_numbers varchar(300), + uids varchar(1000), + other_ids varchar(1000), + doubs varchar(1000), + version bigint not null, + constraint pk_earray_set_bean primary key (id) +); + +create table e_basic ( + id integer auto_increment not null, + status varchar(1), + name varchar(127), + description varchar(255), + some_date datetime(6), + constraint pk_e_basic primary key (id) +); + +create table ebasic_change_log ( + id bigint auto_increment not null, + name varchar(20), + short_description varchar(50), + long_description varchar(100), + who_created varchar(255) not null, + who_modified varchar(255) not null, + when_created datetime(6) not null, + when_modified datetime(6) not null, + version bigint not null, + constraint pk_ebasic_change_log primary key (id) +); + +create table ebasic_clob ( + id bigint auto_increment not null, + name varchar(255), + title varchar(255), + description longtext, + last_update datetime(6) not null, + constraint pk_ebasic_clob primary key (id) +); + +create table ebasic_clob_fetch_eager ( + id bigint auto_increment not null, + name varchar(255), + title varchar(255), + description longtext, + last_update datetime(6) not null, + constraint pk_ebasic_clob_fetch_eager primary key (id) +); + +create table ebasic_clob_no_ver ( + id bigint auto_increment not null, + name varchar(255), + description longtext, + constraint pk_ebasic_clob_no_ver primary key (id) +); + +create table e_basicenc ( + id integer auto_increment not null, + name varchar(255), + description varbinary(80), + dob varbinary(20), + status varbinary(20), + last_update datetime(6), + constraint pk_e_basicenc primary key (id) +); + +create table e_basicenc_bin ( + id integer auto_increment not null, + name varchar(255), + description varchar(255), + data longblob, + some_time varbinary(255), + last_update datetime(6) not null, + constraint pk_e_basicenc_bin primary key (id) +); + +create table e_basicenc_client ( + id bigint auto_increment not null, + name varchar(255), + description varbinary(80), + dob varbinary(20), + status varbinary(20), + version bigint not null, + constraint pk_e_basicenc_client primary key (id) +); + +create table e_basicenc_relate ( + id bigint auto_increment not null, + name varchar(255), + other_id integer, + constraint pk_e_basicenc_relate primary key (id) +); + +create table e_basic_enum_id ( + status varchar(1) not null, + name varchar(255), + description varchar(255), + constraint pk_e_basic_enum_id primary key (status) +); + +create table e_basic_eni ( + id integer auto_increment not null, + status integer, + name varchar(255), + description varchar(255), + some_date datetime(6), + constraint pk_e_basic_eni primary key (id) +); + +create table ebasic_hstore ( + id bigint auto_increment not null, + name varchar(255), + map varchar(800), + version bigint not null, + constraint pk_ebasic_hstore primary key (id) +); + +create table ebasic_json_jackson ( + id bigint auto_increment not null, + name varchar(255), + value_set json, + value_list json, + value_map json, + plain_value json, + version bigint not null, + constraint pk_ebasic_json_jackson primary key (id) +); + +create table ebasic_json_jackson2 ( + id bigint auto_increment not null, + name varchar(255), + value_set json, + value_list json, + value_map json, + plain_value json, + version bigint not null, + constraint pk_ebasic_json_jackson2 primary key (id) +); + +create table ebasic_json_list ( + id bigint auto_increment not null, + name varchar(255), + bean_set json, + bean_list json, + bean_map json, + plain_bean json, + flags json, + tags varchar(100), + version bigint not null, + constraint pk_ebasic_json_list primary key (id) +); + +create table ebasic_json_map ( + id bigint auto_increment not null, + name varchar(255), + content json, + version bigint not null, + constraint pk_ebasic_json_map primary key (id) +); + +create table ebasic_json_map_blob ( + id bigint auto_increment not null, + name varchar(255), + content longblob, + version bigint not null, + constraint pk_ebasic_json_map_blob primary key (id) +); + +create table ebasic_json_map_clob ( + id bigint auto_increment not null, + name varchar(255), + content longtext, + version bigint not null, + constraint pk_ebasic_json_map_clob primary key (id) +); + +create table ebasic_json_map_detail ( + id bigint auto_increment not null, + owner_id bigint, + name varchar(255), + content json, + version bigint not null, + constraint pk_ebasic_json_map_detail primary key (id) +); + +create table ebasic_json_map_json_b ( + id bigint auto_increment not null, + name varchar(255), + content json, + version bigint not null, + constraint pk_ebasic_json_map_json_b primary key (id) +); + +create table ebasic_json_map_varchar ( + id bigint auto_increment not null, + name varchar(255), + content varchar(3000), + version bigint not null, + constraint pk_ebasic_json_map_varchar primary key (id) +); + +create table ebasic_json_node ( + id bigint auto_increment not null, + name varchar(255), + content json, + version bigint not null, + constraint pk_ebasic_json_node primary key (id) +); + +create table ebasic_json_node_blob ( + id bigint auto_increment not null, + name varchar(255), + content longblob, + version bigint not null, + constraint pk_ebasic_json_node_blob primary key (id) +); + +create table ebasic_json_node_json_b ( + id bigint auto_increment not null, + name varchar(255), + content json, + version bigint not null, + constraint pk_ebasic_json_node_json_b primary key (id) +); + +create table ebasic_json_node_varchar ( + id bigint auto_increment not null, + name varchar(255), + content varchar(1000), + version bigint not null, + constraint pk_ebasic_json_node_varchar primary key (id) +); + +create table ebasic_json_unmapped ( + id bigint auto_increment not null, + name varchar(255), + version bigint not null, + constraint pk_ebasic_json_unmapped primary key (id) +); + +create table e_basic_ndc ( + id integer auto_increment not null, + name varchar(255), + constraint pk_e_basic_ndc primary key (id) +); + +create table ebasic_no_sdchild ( + id bigint auto_increment not null, + owner_id bigint not null, + child_name varchar(255), + amount bigint not null, + version bigint not null, + constraint pk_ebasic_no_sdchild primary key (id) +); + +create table ebasic_sdchild ( + id bigint auto_increment not null, + owner_id bigint not null, + child_name varchar(255), + amount bigint not null, + version bigint not null, + deleted tinyint(1) default 0 not null, + constraint pk_ebasic_sdchild primary key (id) +); + +create table ebasic_soft_delete ( + id bigint auto_increment not null, + name varchar(255), + description varchar(255), + version bigint not null, + deleted tinyint(1) default 0 not null, + constraint pk_ebasic_soft_delete primary key (id) +); + +create table e_basicver ( + id integer auto_increment not null, + name varchar(255), + description varchar(255), + other varchar(255), + last_update datetime(6) not null, + constraint pk_e_basicver primary key (id) +); + +create table e_basic_withlife ( + id bigint auto_increment not null, + name varchar(255), + other varchar(255), + deleted tinyint(1) default 0 not null, + version bigint not null, + constraint pk_e_basic_withlife primary key (id) +); + +create table e_basic_with_ex ( + id bigint auto_increment not null, + deleted tinyint(1) default 0 not null, + version bigint not null, + constraint pk_e_basic_with_ex primary key (id) +); + +create table e_basicverucon ( + id integer auto_increment not null, + name varchar(127), + other varchar(127), + other_one varchar(127), + description varchar(255), + last_update datetime(6) not null, + constraint uq_e_basicverucon_name unique (name), + constraint uq_e_basicverucon_other_other_one unique (other,other_one), + constraint pk_e_basicverucon primary key (id) +); + +create table ecache_child ( + id varchar(40) not null, + name varchar(100), + root_id varchar(40) not null, + constraint pk_ecache_child primary key (id) +); + +create table ecache_root ( + id varchar(40) not null, + name varchar(100), + constraint pk_ecache_root primary key (id) +); + +create table e_col_ab ( + id bigint auto_increment not null, + column_a varchar(255), + column_b varchar(255), + constraint pk_e_col_ab primary key (id) +); + +create table ecustom_id ( + id varchar(127) not null, + name varchar(255), + constraint pk_ecustom_id primary key (id) +); + +create table edefault_prop ( + id integer auto_increment not null, + e_simple_usertypeid integer, + name varchar(255), + constraint uq_edefault_prop_e_simple_usertypeid unique (e_simple_usertypeid), + constraint pk_edefault_prop primary key (id) +); + +create table eemb_inner ( + id integer auto_increment not null, + nome_inner varchar(255), + outer_id integer, + update_count integer not null, + constraint pk_eemb_inner primary key (id) +); + +create table eemb_outer ( + id integer auto_increment not null, + nome_outer varchar(255), + date1 datetime(6), + date2 datetime(6), + update_count integer not null, + constraint pk_eemb_outer primary key (id) +); + +create table efile2_no_fk ( + file_name varchar(64) not null, + owner_id integer not null, + constraint pk_efile2_no_fk primary key (file_name) +); + +create table efile_no_fk ( + file_name varchar(64) not null, + owner_user_id integer, + owner_soft_del_user_id integer, + constraint pk_efile_no_fk primary key (file_name) +); + +create table efile_no_fk_euser_no_fk ( + efile_no_fk_file_name varchar(64) not null, + euser_no_fk_user_id integer not null, + constraint pk_efile_no_fk_euser_no_fk primary key (efile_no_fk_file_name,euser_no_fk_user_id) +); + +create table efile_no_fk_euser_no_fk_soft_del ( + efile_no_fk_file_name varchar(64) not null, + euser_no_fk_soft_del_user_id integer not null, + constraint pk_efile_no_fk_euser_no_fk_soft_del primary key (efile_no_fk_file_name,euser_no_fk_soft_del_user_id) +); + +create table egen_props ( + id bigint auto_increment not null, + name varchar(255), + version bigint not null, + when_created datetime(6) not null, + when_modified datetime(6) not null, + ts_created datetime(6) not null, + ts_updated datetime(6) not null, + ldt_created datetime(6) not null, + ldt_updated datetime(6) not null, + odt_created datetime(6) not null, + odt_updated datetime(6) not null, + zdt_created datetime(6) not null, + zdt_updated datetime(6) not null, + instant_created datetime(6) not null, + instant_updated datetime(6) not null, + long_created bigint not null, + long_updated bigint not null, + constraint pk_egen_props primary key (id) +); + +create table eid_uid_bean ( + id bigint auto_increment not null, + uuid varchar(40) not null, + name varchar(255), + constraint uq_eid_uid_bean_uuid unique (uuid), + constraint pk_eid_uid_bean primary key (id) +); + +create table einvoice ( + id bigint auto_increment not null, + invoice_date datetime(6), + state integer, + person_id bigint, + ship_street varchar(255), + ship_suburb varchar(255), + ship_city varchar(255), + ship_status varchar(3), + bill_street varchar(255), + bill_suburb varchar(255), + bill_city varchar(255), + bill_status varchar(3), + version bigint not null, + constraint pk_einvoice primary key (id) +); + +create table e_main ( + id integer auto_increment not null, + name varchar(255), + description varchar(255), + version bigint not null, + constraint pk_e_main primary key (id) +); + +create table enull_collection ( + id integer auto_increment not null, + name varchar(255), + constraint pk_enull_collection primary key (id) +); + +create table enull_collection_detail ( + id integer auto_increment not null, + enull_collection_id integer not null, + something varchar(255), + constraint pk_enull_collection_detail primary key (id) +); + +create table eopt_one_a ( + id integer auto_increment not null, + name_for_a varchar(255), + b_id integer, + cretime datetime(6) not null, + updtime datetime(6) not null, + version bigint not null, + constraint pk_eopt_one_a primary key (id) +); + +create table eopt_one_b ( + id integer auto_increment not null, + name_for_b varchar(255), + c_id integer not null, + cretime datetime(6) not null, + updtime datetime(6) not null, + version bigint not null, + constraint pk_eopt_one_b primary key (id) +); + +create table eopt_one_c ( + id integer auto_increment not null, + name_for_c varchar(255), + cretime datetime(6) not null, + updtime datetime(6) not null, + version bigint not null, + constraint pk_eopt_one_c primary key (id) +); + +create table eper_addr ( + id bigint auto_increment not null, + name varchar(255), + ma_street varchar(255), + ma_suburb varchar(255), + ma_city varchar(255), + ma_country_code varchar(2), + version bigint not null, + constraint pk_eper_addr primary key (id) +); + +create table eperson ( + id bigint auto_increment not null, + name varchar(255), + notes varchar(255), + street varchar(255), + suburb varchar(255), + addr_city varchar(255), + addr_status varchar(3), + version bigint not null, + constraint pk_eperson primary key (id) +); + +create table e_person_online ( + id bigint auto_increment not null, + email varchar(127), + online_status tinyint(1) default 0 not null, + when_updated datetime(6) not null, + constraint uq_e_person_online_email unique (email), + constraint pk_e_person_online primary key (id) +); + +create table esimple ( + usertypeid integer auto_increment not null, + name varchar(255), + constraint pk_esimple primary key (usertypeid) +); + +create table esoft_del_book ( + id bigint auto_increment not null, + book_title varchar(255), + lend_by_id bigint, + version bigint not null, + deleted tinyint(1) default 0 not null, + constraint pk_esoft_del_book primary key (id) +); + +create table esoft_del_book_esoft_del_user ( + esoft_del_book_id bigint not null, + esoft_del_user_id bigint not null, + constraint pk_esoft_del_book_esoft_del_user primary key (esoft_del_book_id,esoft_del_user_id) +); + +create table esoft_del_down ( + id bigint auto_increment not null, + esoft_del_mid_id bigint not null, + down varchar(255), + version bigint not null, + deleted tinyint(1) default 0 not null, + constraint pk_esoft_del_down primary key (id) +); + +create table esoft_del_mid ( + id bigint auto_increment not null, + top_id bigint, + mid varchar(255), + up_id bigint, + version bigint not null, + deleted tinyint(1) default 0 not null, + constraint pk_esoft_del_mid primary key (id) +); + +create table esoft_del_one_a ( + id bigint auto_increment not null, + name varchar(255), + oneb_id bigint, + deleted tinyint(1) default 0 not null, + version bigint not null, + constraint uq_esoft_del_one_a_oneb_id unique (oneb_id), + constraint pk_esoft_del_one_a primary key (id) +); + +create table esoft_del_one_b ( + id bigint auto_increment not null, + name varchar(255), + version bigint not null, + constraint pk_esoft_del_one_b primary key (id) +); + +create table esoft_del_role ( + id bigint auto_increment not null, + role_name varchar(255), + version bigint not null, + deleted tinyint(1) default 0 not null, + constraint pk_esoft_del_role primary key (id) +); + +create table esoft_del_role_esoft_del_user ( + esoft_del_role_id bigint not null, + esoft_del_user_id bigint not null, + constraint pk_esoft_del_role_esoft_del_user primary key (esoft_del_role_id,esoft_del_user_id) +); + +create table esoft_del_top ( + id bigint auto_increment not null, + name varchar(255), + version bigint not null, + deleted tinyint(1) default 0 not null, + constraint pk_esoft_del_top primary key (id) +); + +create table esoft_del_up ( + id bigint auto_increment not null, + up varchar(255), + version bigint not null, + deleted tinyint(1) default 0 not null, + constraint pk_esoft_del_up primary key (id) +); + +create table esoft_del_user ( + id bigint auto_increment not null, + user_name varchar(255), + version bigint not null, + deleted tinyint(1) default 0 not null, + constraint pk_esoft_del_user primary key (id) +); + +create table esoft_del_user_esoft_del_role ( + esoft_del_user_id bigint not null, + esoft_del_role_id bigint not null, + constraint pk_esoft_del_user_esoft_del_role primary key (esoft_del_user_id,esoft_del_role_id) +); + +create table esome_convert_type ( + id bigint auto_increment not null, + name varchar(255), + money decimal(16,3), + constraint pk_esome_convert_type primary key (id) +); + +create table esome_type ( + id integer auto_increment not null, + currency varchar(3), + locale varchar(20), + time_zone varchar(20), + constraint pk_esome_type primary key (id) +); + +create table etrans_many ( + id integer auto_increment not null, + name varchar(255), + constraint pk_etrans_many primary key (id) +); + +create table rawinherit_uncle ( + id integer auto_increment not null, + name varchar(255), + parent_id bigint not null, + version bigint not null, + constraint pk_rawinherit_uncle primary key (id) +); + +create table euser_no_fk ( + user_id integer auto_increment not null, + user_name varchar(255), + constraint pk_euser_no_fk primary key (user_id) +); + +create table euser_no_fk_soft_del ( + user_id integer auto_increment not null, + user_name varchar(255), + constraint pk_euser_no_fk_soft_del primary key (user_id) +); + +create table evanilla_collection ( + id integer auto_increment not null, + name varchar(255), + constraint pk_evanilla_collection primary key (id) +); + +create table evanilla_collection_detail ( + id integer auto_increment not null, + evanilla_collection_id integer not null, + something varchar(255), + constraint pk_evanilla_collection_detail primary key (id) +); + +create table ewho_props ( + id bigint auto_increment not null, + name varchar(255), + version bigint not null, + when_created datetime(6) not null, + when_modified datetime(6) not null, + who_created varchar(255) not null, + who_modified varchar(255) not null, + constraint pk_ewho_props primary key (id) +); + +create table e_withinet ( + id bigint auto_increment not null, + name varchar(255), + inet_address varchar(50), + inet2 varchar(255), + cidr varchar(50), + version bigint not null, + constraint pk_e_withinet primary key (id) +); + +create table ec_enum_person ( + id bigint auto_increment not null, + name varchar(255), + version bigint not null, + constraint pk_ec_enum_person primary key (id) +); + +create table ec_enum_person_tags ( + ec_enum_person_id bigint not null, + value varchar(5) not null +); + +create table ec_person ( + id bigint auto_increment not null, + name varchar(255), + version bigint not null, + constraint pk_ec_person primary key (id) +); + +create table ec_person_phone ( + owner_id bigint not null, + phone varchar(255) not null +); + +create table ec_top ( + id bigint auto_increment not null, + name varchar(255), + person_id bigint, + version bigint not null, + constraint pk_ec_top primary key (id) +); + +create table ec_top_ecs_person ( + ec_top_id bigint not null, + ecs_person_id bigint not null, + constraint pk_ec_top_ecs_person primary key (ec_top_id,ecs_person_id) +); + +create table ecbl_person ( + id bigint auto_increment not null, + name varchar(255), + version bigint not null, + constraint pk_ecbl_person primary key (id) +); + +create table ecbl_person_phone_numbers ( + person_id bigint not null, + country_code varchar(2), + area varchar(6), + phnum varchar(20) +); + +create table ecbm_person ( + id bigint auto_increment not null, + name varchar(255), + version bigint not null, + constraint pk_ecbm_person primary key (id) +); + +create table ecbm_person_phone_numbers ( + person_id bigint not null, + mkey varchar(255) not null, + country_code varchar(2), + area varchar(6), + phnum varchar(20) +); + +create table ecm_person ( + id bigint auto_increment not null, + name varchar(255), + version bigint not null, + constraint pk_ecm_person primary key (id) +); + +create table ecm_person_phone_numbers ( + ecm_person_id bigint not null, + type varchar(4) not null, + phnum varchar(10) not null +); + +create table ecmc_person ( + id bigint auto_increment not null, + name varchar(255), + version bigint not null, + constraint pk_ecmc_person primary key (id) +); + +create table ecmc_person_phone_numbers ( + ecmc_person_id bigint not null, + type varchar(4) not null, + value longtext not null +); + +create table ecs_person ( + id bigint auto_increment not null, + name varchar(255), + version bigint not null, + constraint pk_ecs_person primary key (id) +); + +create table ecs_person_phone ( + ecs_person_id bigint not null, + phone varchar(255) not null +); + +create table ecsm_child ( + one_id varchar(40) not null, + ecsm_parent_id bigint not null, + name varchar(255), + version bigint not null, + constraint pk_ecsm_child primary key (one_id) +); + +create table ecsm_values ( + host_id varchar(40) not null, + value varchar(255) not null +); + +create table ecsm_one ( + one_id varchar(40) not null, + name varchar(255), + version bigint not null, + constraint pk_ecsm_one primary key (one_id) +); + +create table ecsm_parent ( + id bigint auto_increment not null, + name varchar(255), + version bigint not null, + constraint pk_ecsm_parent primary key (id) +); + +create table ecsm_two ( + id varchar(40) not null, + name varchar(255), + version bigint not null, + constraint pk_ecsm_two primary key (id) +); + +create table td_child ( + child_id integer auto_increment not null, + child_name varchar(255), + parent_id integer not null, + constraint pk_td_child primary key (child_id) +); + +create table td_parent ( + parent_type varchar(31) not null, + parent_id integer auto_increment not null, + parent_name varchar(255), + extended_name varchar(255), + constraint pk_td_parent primary key (parent_id) +); + +create table element_bean ( + id bigint auto_increment not null, + complex_bean_id varchar(40) not null, + value varchar(255) not null, + constraint pk_element_bean primary key (id) +); + +create table empl ( + id bigint auto_increment not null, + name varchar(255), + age integer, + default_address_id bigint, + constraint pk_empl primary key (id) +); + +create table esd_detail ( + id bigint auto_increment not null, + name varchar(255), + master_id bigint not null, + version bigint not null, + deleted tinyint(1) default 0 not null, + constraint pk_esd_detail primary key (id) +); + +create table esd_master ( + id bigint auto_increment not null, + name varchar(255), + version bigint not null, + deleted tinyint(1) default 0 not null, + constraint pk_esd_master primary key (id) +); + +create table feature_desc ( + id integer auto_increment not null, + name varchar(255), + description varchar(255), + constraint pk_feature_desc primary key (id) +); + +create table f_first ( + id bigint auto_increment not null, + name varchar(255), + constraint pk_f_first primary key (id) +); + +create table foo ( + foo_id integer auto_increment not null, + important_text varchar(255), + version integer not null, + constraint pk_foo primary key (foo_id) +); + +create table gen_key_identity ( + id bigint auto_increment not null, + description varchar(255), + constraint pk_gen_key_identity primary key (id) +); + +create table gen_key_sequence ( + id bigint auto_increment not null, + description varchar(255), + constraint pk_gen_key_sequence primary key (id) +); + +create table grand_parent_person ( + identifier integer auto_increment not null, + name varchar(255), + age integer, + some_bean_id integer, + family_name varchar(255), + address varchar(255), + constraint pk_grand_parent_person primary key (identifier) +); + +create table survey_group ( + id bigint auto_increment not null, + name varchar(255), + categoryobjectid bigint, + sequence_number integer not null, + constraint pk_survey_group primary key (id) +); + +create table c_group ( + id bigint auto_increment not null, + inactive tinyint(1) default 0 not null, + name varchar(255), + version bigint not null, + when_created datetime(6) not null, + when_modified datetime(6) not null, + constraint pk_c_group primary key (id) +); + +create table he_doc ( + id bigint auto_increment not null, + name varchar(255), + version bigint not null, + when_created datetime(6) not null, + when_modified datetime(6) not null, + constraint pk_he_doc primary key (id) +); + +create table hx_link ( + id bigint auto_increment not null, + name varchar(255), + location varchar(255), + comments varchar(255), + version bigint not null, + when_created datetime(6) not null, + when_modified datetime(6) not null, + deleted tinyint(1) default 0 not null, + constraint pk_hx_link primary key (id) +); + +create table hx_link_doc ( + hx_link_id bigint not null, + he_doc_id bigint not null, + constraint pk_hx_link_doc primary key (hx_link_id,he_doc_id) +); + +create table hi_doc ( + id bigint auto_increment not null, + name varchar(255), + version bigint not null, + when_created datetime(6) not null, + when_modified datetime(6) not null, + constraint pk_hi_doc primary key (id) +); + +create table hi_link ( + id bigint auto_increment not null, + name varchar(255), + location varchar(255), + comments varchar(255), + version bigint not null, + when_created datetime(6) not null, + when_modified datetime(6) not null, + constraint pk_hi_link primary key (id) +); + +create table hi_link_doc ( + hi_link_id bigint not null, + hi_doc_id bigint not null, + constraint pk_hi_link_doc primary key (hi_link_id,hi_doc_id) +); + +create table hi_tone ( + id bigint auto_increment not null, + name varchar(255), + comments varchar(255), + version bigint not null, + when_created datetime(6) not null, + when_modified datetime(6) not null, + constraint pk_hi_tone primary key (id) +); + +create table hi_tthree ( + id bigint auto_increment not null, + hi_ttwo_id bigint not null, + three varchar(255), + version bigint not null, + when_created datetime(6) not null, + when_modified datetime(6) not null, + constraint pk_hi_tthree primary key (id) +); + +create table hi_ttwo ( + id bigint auto_increment not null, + hi_tone_id bigint not null, + two varchar(255), + version bigint not null, + when_created datetime(6) not null, + when_modified datetime(6) not null, + constraint pk_hi_ttwo primary key (id) +); + +create table hsd_setting ( + id bigint auto_increment not null, + code varchar(255), + content varchar(255), + user_id bigint, + version bigint not null, + when_created datetime(6) not null, + when_modified datetime(6) not null, + deleted tinyint(1) default 0 not null, + constraint uq_hsd_setting_user_id unique (user_id), + constraint pk_hsd_setting primary key (id) +); + +create table hsd_user ( + id bigint auto_increment not null, + name varchar(255), + version bigint not null, + when_created datetime(6) not null, + when_modified datetime(6) not null, + deleted tinyint(1) default 0 not null, + constraint pk_hsd_user primary key (id) +); + +create table iaf_segment ( + ptype varchar(31) not null, + id bigint auto_increment not null, + segment_id_zat bigint not null, + status_id bigint not null, + constraint pk_iaf_segment primary key (id) +); + +create table iaf_segment_status ( + id bigint auto_increment not null, + name varchar(255), + constraint pk_iaf_segment_status primary key (id) +); + +create table imrelated ( + id bigint auto_increment not null, + name varchar(255), + owner_id bigint not null, + constraint pk_imrelated primary key (id) +); + +create table imroot ( + dtype varchar(31) not null, + id bigint auto_increment not null, + name varchar(255), + title varchar(255), + when_title datetime(6), + constraint pk_imroot primary key (id) +); + +create table ixresource ( + dtype varchar(255), + id varchar(40) not null, + name varchar(255), + constraint pk_ixresource primary key (id) +); + +create table info_company ( + id bigint auto_increment not null, + name varchar(255), + version bigint not null, + constraint pk_info_company primary key (id) +); + +create table info_contact ( + id bigint auto_increment not null, + name varchar(255), + company_id bigint not null, + version bigint not null, + constraint pk_info_contact primary key (id) +); + +create table info_customer ( + id bigint auto_increment not null, + name varchar(255), + company_id bigint, + version bigint not null, + constraint uq_info_customer_company_id unique (company_id), + constraint pk_info_customer primary key (id) +); + +create table inner_report ( + id bigint auto_increment not null, + name varchar(255), + forecast_id bigint, + constraint uq_inner_report_forecast_id unique (forecast_id), + constraint pk_inner_report primary key (id) +); + +create table drel_invoice ( + id bigint auto_increment not null, + booking bigint, + version integer not null, + constraint pk_drel_invoice primary key (id) +); + +create table item ( + customer integer not null, + itemnumber varchar(127) not null, + description varchar(255), + units varchar(255), + type integer not null, + region integer not null, + date_modified datetime(6), + date_created datetime(6), + modified_by varchar(255), + created_by varchar(255), + version bigint not null, + constraint pk_item primary key (customer,itemnumber) +); + +create table monkey ( + mid bigint auto_increment not null, + name varchar(255), + food_preference varchar(255), + version bigint not null, + constraint pk_monkey primary key (mid) +); + +create table mkeygroup ( + pid bigint auto_increment not null, + name varchar(255), + version bigint not null, + constraint pk_mkeygroup primary key (pid) +); + +create table mkeygroup_monkey ( + mkeygroup_pid bigint not null, + monkey_mid bigint not null, + constraint uq_mkeygroup_monkey_mid unique (monkey_mid), + constraint pk_mkeygroup_monkey primary key (mkeygroup_pid,monkey_mid) +); + +create table trainer ( + tid bigint auto_increment not null, + name varchar(255), + version bigint not null, + constraint pk_trainer primary key (tid) +); + +create table trainer_monkey ( + trainer_tid bigint not null, + monkey_mid bigint not null, + constraint uq_trainer_monkey_mid unique (monkey_mid), + constraint pk_trainer_monkey primary key (trainer_tid,monkey_mid) +); + +create table troop ( + pid bigint auto_increment not null, + name varchar(255), + version bigint not null, + constraint pk_troop primary key (pid) +); + +create table troop_monkey ( + troop_pid bigint not null, + monkey_mid bigint not null, + constraint uq_troop_monkey_mid unique (monkey_mid), + constraint pk_troop_monkey primary key (troop_pid,monkey_mid) +); + +create table l2_cldf_reset_bean ( + id bigint auto_increment not null, + name varchar(255), + constraint pk_l2_cldf_reset_bean primary key (id) +); + +create table l2_cldf_reset_bean_child ( + id bigint auto_increment not null, + parent_id bigint, + constraint pk_l2_cldf_reset_bean_child primary key (id) +); + +create table level1 ( + id bigint auto_increment not null, + name varchar(255), + constraint pk_level1 primary key (id) +); + +create table level1_level4 ( + level1_id bigint not null, + level4_id bigint not null, + constraint pk_level1_level4 primary key (level1_id,level4_id) +); + +create table level1_level2 ( + level1_id bigint not null, + level2_id bigint not null, + constraint pk_level1_level2 primary key (level1_id,level2_id) +); + +create table level2 ( + id bigint auto_increment not null, + name varchar(255), + constraint pk_level2 primary key (id) +); + +create table level2_level3 ( + level2_id bigint not null, + level3_id bigint not null, + constraint pk_level2_level3 primary key (level2_id,level3_id) +); + +create table level3 ( + id bigint auto_increment not null, + name varchar(255), + constraint pk_level3 primary key (id) +); + +create table level4 ( + id bigint auto_increment not null, + name varchar(255), + constraint pk_level4 primary key (id) +); + +create table link ( + id bigint auto_increment not null, + name varchar(255), + location varchar(255), + when_publish datetime(6), + link_comment varchar(255), + version bigint not null, + when_created datetime(6) not null, + when_modified datetime(6) not null, + deleted tinyint(1) default 0 not null, + constraint pk_link primary key (id) +); + +create table link_draft ( + id bigint auto_increment not null, + name varchar(255), + location varchar(255), + when_publish datetime(6), + link_comment varchar(255), + dirty tinyint(1) default 0 not null, + version bigint not null, + when_created datetime(6) not null, + when_modified datetime(6) not null, + deleted tinyint(1) default 0 not null, + constraint pk_link_draft primary key (id) +); + +create table la_attr_value ( + id integer auto_increment not null, + name varchar(255), + cretime datetime(6) not null, + updtime datetime(6) not null, + version bigint not null, + constraint pk_la_attr_value primary key (id) +); + +create table la_attr_value_attribute ( + la_attr_value_id integer not null, + attribute_id integer not null, + constraint pk_la_attr_value_attribute primary key (la_attr_value_id,attribute_id) +); + +create table looney ( + id bigint auto_increment not null, + tune_id bigint, + name varchar(255), + constraint pk_looney primary key (id) +); + +create table maddress ( + id varchar(40) not null, + street varchar(255), + city varchar(255), + version bigint not null, + constraint pk_maddress primary key (id) +); + +create table mcontact ( + id varchar(40) not null, + email varchar(255), + first_name varchar(255), + last_name varchar(255), + customer_id varchar(40), + version bigint not null, + constraint pk_mcontact primary key (id) +); + +create table mcontact_message ( + id varchar(40) not null, + title varchar(255), + subject varchar(255), + notes varchar(255), + contact_id varchar(40) not null, + version bigint not null, + constraint pk_mcontact_message primary key (id) +); + +create table mcustomer ( + id varchar(40) not null, + name varchar(255), + notes varchar(255), + shipping_address_id varchar(40), + billing_address_id varchar(40), + version bigint not null, + constraint pk_mcustomer primary key (id) +); + +create table mgroup ( + id bigint auto_increment not null, + name varchar(255), + constraint pk_mgroup primary key (id) +); + +create table mmachine ( + id bigint auto_increment not null, + name varchar(255), + version bigint not null, + constraint pk_mmachine primary key (id) +); + +create table mmachine_mgroup ( + mmachine_id bigint not null, + mgroup_id bigint not null, + constraint pk_mmachine_mgroup primary key (mmachine_id,mgroup_id) +); + +create table mmedia ( + type varchar(31) not null, + id bigint auto_increment not null, + url varchar(255), + note varchar(255), + constraint pk_mmedia primary key (id) +); + +create table non_updateprop ( + id integer auto_increment not null, + non_enum varchar(5), + name varchar(255), + note varchar(255), + constraint pk_non_updateprop primary key (id) +); + +create table mprinter ( + id bigint auto_increment not null, + name varchar(255), + flags bigint not null, + current_state_id bigint, + last_swap_cyan_id bigint, + last_swap_magenta_id bigint, + last_swap_yellow_id bigint, + last_swap_black_id bigint, + version bigint not null, + constraint uq_mprinter_last_swap_cyan_id unique (last_swap_cyan_id), + constraint uq_mprinter_last_swap_magenta_id unique (last_swap_magenta_id), + constraint uq_mprinter_last_swap_yellow_id unique (last_swap_yellow_id), + constraint uq_mprinter_last_swap_black_id unique (last_swap_black_id), + constraint pk_mprinter primary key (id) +); + +create table mprinter_state ( + id bigint auto_increment not null, + flags bigint not null, + printer_id bigint, + version bigint not null, + constraint pk_mprinter_state primary key (id) +); + +create table mprofile ( + id bigint auto_increment not null, + picture_id bigint, + name varchar(255), + constraint pk_mprofile primary key (id) +); + +create table mprotected_construct_bean ( + id bigint auto_increment not null, + name varchar(255), + constraint pk_mprotected_construct_bean primary key (id) +); + +create table mrole ( + roleid integer auto_increment not null, + role_name varchar(255), + constraint pk_mrole primary key (roleid) +); + +create table mrole_muser ( + mrole_roleid integer not null, + muser_userid integer not null, + constraint pk_mrole_muser primary key (mrole_roleid,muser_userid) +); + +create table msome_other ( + id bigint auto_increment not null, + name varchar(255), + constraint pk_msome_other primary key (id) +); + +create table muser ( + userid integer auto_increment not null, + user_name varchar(255), + user_type_id integer, + constraint pk_muser primary key (userid) +); + +create table muser_type ( + id integer auto_increment not null, + name varchar(255), + constraint pk_muser_type primary key (id) +); + +create table mail_box ( + id bigint auto_increment not null, + name varchar(255), + version bigint not null, + constraint pk_mail_box primary key (id) +); + +create table mail_user ( + id bigint auto_increment not null, + name varchar(255), + version bigint not null, + constraint pk_mail_user primary key (id) +); + +create table mail_user_inbox ( + mail_user_id bigint not null, + mail_box_id bigint not null, + constraint pk_mail_user_inbox primary key (mail_user_id,mail_box_id) +); + +create table mail_user_outbox ( + mail_user_id bigint not null, + mail_box_id bigint not null, + constraint pk_mail_user_outbox primary key (mail_user_id,mail_box_id) +); + +create table main_entity ( + id varchar(255) not null, + attr1 varchar(255), + attr2 varchar(255), + constraint pk_main_entity primary key (id) +); + +create table main_entity_relation ( + id varchar(40) not null, + id1 varchar(255), + id2 varchar(255), + attr1 varchar(255), + constraint pk_main_entity_relation primary key (id) +); + +create table map_super_actual ( + id bigint auto_increment not null, + name varchar(255), + when_created datetime(6) not null, + when_updated datetime(6) not null, + constraint pk_map_super_actual primary key (id) +); + +create table c_message ( + id bigint auto_increment not null, + title varchar(255), + body varchar(255), + conversation_id bigint, + user_id bigint, + version bigint not null, + when_created datetime(6) not null, + when_modified datetime(6) not null, + constraint pk_c_message primary key (id) +); + +create table meter_address_data ( + id varchar(40) not null, + street varchar(255) not null, + constraint pk_meter_address_data primary key (id) +); + +create table meter_contract_data ( + id varchar(40) not null, + special_needs_client_id varchar(40) not null, + constraint uq_meter_contract_data_special_needs_client_id unique (special_needs_client_id), + constraint pk_meter_contract_data primary key (id) +); + +create table meter_special_needs_client ( + id varchar(40) not null, + name varchar(255), + primary_id varchar(40), + constraint uq_meter_special_needs_client_primary_id unique (primary_id), + constraint pk_meter_special_needs_client primary key (id) +); + +create table meter_special_needs_contact ( + id varchar(40) not null, + name varchar(255), + constraint pk_meter_special_needs_contact primary key (id) +); + +create table meter_version ( + id varchar(40) not null, + address_data_id varchar(40), + contract_data_id varchar(40) not null, + constraint uq_meter_version_address_data_id unique (address_data_id), + constraint uq_meter_version_contract_data_id unique (contract_data_id), + constraint pk_meter_version primary key (id) +); + +create table mnoc_role ( + role_id integer auto_increment not null, + role_name varchar(255), + version integer not null, + constraint pk_mnoc_role primary key (role_id) +); + +create table mnoc_user ( + user_id integer auto_increment not null, + user_name varchar(255), + version integer not null, + constraint pk_mnoc_user primary key (user_id) +); + +create table mnoc_user_mnoc_role ( + mnoc_user_user_id integer not null, + mnoc_role_role_id integer not null, + constraint pk_mnoc_user_mnoc_role primary key (mnoc_user_user_id,mnoc_role_role_id) +); + +create table mny_a ( + id bigint auto_increment not null, + name varchar(255), + version bigint not null, + when_created datetime(6) not null, + when_modified datetime(6) not null, + constraint pk_mny_a primary key (id) +); + +create table mny_b ( + id bigint auto_increment not null, + name varchar(255), + a_id bigint, + version bigint not null, + when_created datetime(6) not null, + when_modified datetime(6) not null, + constraint pk_mny_b primary key (id) +); + +create table mny_b_mny_c ( + mny_b_id bigint not null, + mny_c_id bigint not null, + constraint pk_mny_b_mny_c primary key (mny_b_id,mny_c_id) +); + +create table mny_c ( + id bigint auto_increment not null, + name varchar(255), + version bigint not null, + when_created datetime(6) not null, + when_modified datetime(6) not null, + constraint pk_mny_c primary key (id) +); + +create table mny_topic ( + id bigint auto_increment not null, + name varchar(255), + version bigint not null, + constraint pk_mny_topic primary key (id) +); + +create table subtopics ( + topic bigint not null, + subtopic bigint not null, + constraint pk_subtopics primary key (topic,subtopic) +); + +create table mp_role ( + id bigint auto_increment not null, + mp_user_id bigint not null, + code varchar(255), + organization_id bigint, + constraint pk_mp_role primary key (id) +); + +create table mp_user ( + id bigint auto_increment not null, + name varchar(255), + constraint pk_mp_user primary key (id) +); + +create table ms_many_a ( + aid bigint auto_increment not null, + name varchar(255), + ms_many_a_many_b tinyint(1) default 0 not null, + ms_many_b tinyint(1) default 0 not null, + deleted tinyint(1) default 0 not null, + constraint pk_ms_many_a primary key (aid) +); + +create table ms_many_a_many_b ( + ms_many_a_aid bigint not null, + ms_many_b_bid bigint not null, + constraint pk_ms_many_a_many_b primary key (ms_many_a_aid,ms_many_b_bid) +); + +create table ms_many_b ( + bid bigint auto_increment not null, + name varchar(255), + deleted tinyint(1) default 0 not null, + constraint pk_ms_many_b primary key (bid) +); + +create table ms_many_b_many_a ( + ms_many_b_bid bigint not null, + ms_many_a_aid bigint not null, + constraint pk_ms_many_b_many_a primary key (ms_many_b_bid,ms_many_a_aid) +); + +create table my_lob_size ( + id integer auto_increment not null, + name varchar(255), + my_count integer not null, + my_lob longtext, + constraint pk_my_lob_size primary key (id) +); + +create table my_lob_size_join_many ( + id integer auto_increment not null, + something varchar(255), + other varchar(255), + parent_id integer, + constraint pk_my_lob_size_join_many primary key (id) +); + +create table noidbean ( + name varchar(255), + subject varchar(255), + when_created datetime(6) not null +); + +create table o_bean_child ( + id bigint auto_increment not null, + cached_bean_id bigint, + constraint pk_o_bean_child primary key (id) +); + +create table ocached_app ( + id bigint auto_increment not null, + app_name varchar(255), + version bigint not null, + constraint uq_ocached_app_app_name unique (app_name), + constraint pk_ocached_app primary key (id) +); + +create table ocached_app_detail ( + id bigint auto_increment not null, + app_id bigint not null, + detail varchar(255), + version bigint not null, + constraint uq_ocached_app_detail_app_id_detail unique (app_id,detail), + constraint pk_ocached_app_detail primary key (id) +); + +create table o_cached_bean ( + id bigint auto_increment not null, + name varchar(255), + constraint pk_o_cached_bean primary key (id) +); + +create table o_cached_bean_country ( + o_cached_bean_id bigint not null, + o_country_code varchar(2) not null, + constraint pk_o_cached_bean_country primary key (o_cached_bean_id,o_country_code) +); + +create table o_cached_bean_child ( + id bigint auto_increment not null, + cached_bean_id bigint, + constraint pk_o_cached_bean_child primary key (id) +); + +create table o_cached_inherit ( + dtype varchar(31) not null, + id bigint auto_increment not null, + name varchar(255), + child_adata varchar(255), + child_bdata varchar(255), + constraint pk_o_cached_inherit primary key (id) +); + +create table o_cached_natkey ( + id bigint auto_increment not null, + store varchar(255), + sku varchar(255), + description varchar(255), + constraint pk_o_cached_natkey primary key (id) +); + +create table o_cached_natkey3 ( + id bigint auto_increment not null, + store varchar(255), + code integer not null, + sku varchar(255), + description varchar(255), + constraint pk_o_cached_natkey3 primary key (id) +); + +create table ocached_nkey_uid ( + id bigint auto_increment not null, + cid varchar(40), + other varchar(255), + version bigint not null, + constraint pk_ocached_nkey_uid primary key (id) +); + +create table ocar ( + id integer auto_increment not null, + vin varchar(255), + name varchar(255), + cretime datetime(6) not null, + updtime datetime(6) not null, + version bigint not null, + constraint pk_ocar primary key (id) +); + +create table ocompany ( + id integer auto_increment not null, + corp_id varchar(50), + cretime datetime(6) not null, + updtime datetime(6) not null, + version bigint not null, + constraint uq_ocompany_corp_id unique (corp_id), + constraint pk_ocompany primary key (id) +); + +create table oengine ( + engine_id varchar(40) not null, + short_desc varchar(255), + car_id integer, + version integer not null, + constraint uq_oengine_car_id unique (car_id), + constraint pk_oengine primary key (engine_id) +); + +create table ogear_box ( + id varchar(40) not null, + box_desc varchar(255), + box_size integer, + car_id integer, + version integer not null, + constraint uq_ogear_box_car_id unique (car_id), + constraint pk_ogear_box primary key (id) +); + +create table omvertex ( + id varchar(40) not null, + constraint pk_omvertex primary key (id) +); + +create table omvertex_other ( + id varchar(40) not null, + omvertex_id varchar(40) not null, + name varchar(255), + constraint pk_omvertex_other primary key (id) +); + +create table oroad_show_msg ( + id integer auto_increment not null, + company_id integer not null, + cretime datetime(6) not null, + updtime datetime(6) not null, + version bigint not null, + constraint uq_oroad_show_msg_company_id unique (company_id), + constraint pk_oroad_show_msg primary key (id) +); + +create table om_account_child_dbo ( + id bigint auto_increment not null, + description varchar(255), + banana_rama_id bigint, + constraint pk_om_account_child_dbo primary key (id) +); + +create table om_account_dbo ( + id bigint auto_increment not null, + name varchar(255), + constraint pk_om_account_dbo primary key (id) +); + +create table om_basic_child ( + id bigint auto_increment not null, + name varchar(255), + parent_id bigint, + version bigint not null, + constraint pk_om_basic_child primary key (id) +); + +create table om_basic_parent ( + id bigint auto_increment not null, + name varchar(255), + version bigint not null, + constraint pk_om_basic_parent primary key (id) +); + +create table om_ordered_detail ( + id bigint auto_increment not null, + name varchar(255), + master_id bigint, + version bigint not null, + sort_order integer, + constraint pk_om_ordered_detail primary key (id) +); + +create table om_ordered_master ( + id bigint auto_increment not null, + name varchar(255), + version bigint not null, + constraint pk_om_ordered_master primary key (id) +); + +create table only_id_entity ( + id bigint auto_increment not null, + constraint pk_only_id_entity primary key (id) +); + +create table o_order ( + id integer auto_increment not null, + status integer, + order_date date, + ship_date date, + kcustomer_id integer not null, + cretime datetime(6) not null, + updtime datetime(6) not null, + constraint pk_o_order primary key (id) +); + +create table o_order_detail ( + id integer auto_increment not null, + order_id integer not null, + order_qty integer, + ship_qty integer, + unit_price double, + product_id integer, + cretime datetime(6), + updtime datetime(6) not null, + constraint pk_o_order_detail primary key (id) +); + +create table s_orders ( + uuid varchar(40) not null, + constraint pk_s_orders primary key (uuid) +); + +create table s_order_items ( + uuid varchar(40) not null, + product_variant_uuid varchar(255), + order_uuid varchar(40), + quantity integer not null, + amount decimal(16,3), + constraint pk_s_order_items primary key (uuid) +); + +create table order_master ( + id bigint auto_increment not null, + constraint pk_order_master primary key (id) +); + +create table order_master_inheritance ( + id integer auto_increment not null, + constraint pk_order_master_inheritance primary key (id) +); + +create table order_referenced_parent ( + type varchar(31) not null, + id bigint auto_increment not null, + name varchar(255), + child_name varchar(255), + master_id bigint, + sort_order integer, + constraint pk_order_referenced_parent primary key (id) +); + +create table or_order_ship ( + id integer auto_increment not null, + order_id integer, + ship_time datetime(6), + cretime datetime(6) not null, + updtime datetime(6) not null, + version bigint not null, + constraint pk_or_order_ship primary key (id) +); + +create table order_toy ( + id integer auto_increment not null, + title varchar(255), + child_id bigint, + sort_order integer, + constraint pk_order_toy primary key (id) +); + +create table ordered_parent ( + dtype varchar(31) not null, + id integer auto_increment not null, + order_master_inheritance_id integer not null, + common_name varchar(255), + sort_order integer, + ordered_aname varchar(255), + ordered_bname varchar(255), + constraint pk_ordered_parent primary key (id) +); + +create table organisation ( + id bigint auto_increment not null, + name varchar(255), + version bigint not null, + when_created datetime(6) not null, + when_modified datetime(6) not null, + constraint pk_organisation primary key (id) +); + +create table organization_node ( + kind varchar(31) not null, + id bigint auto_increment not null, + parent_tree_node_id bigint not null, + title varchar(255), + constraint uq_organization_node_parent_tree_node_id unique (parent_tree_node_id), + constraint pk_organization_node primary key (id) +); + +create table organization_tree_node ( + id bigint auto_increment not null, + name varchar(255), + constraint pk_organization_tree_node primary key (id) +); + +create table orp_detail ( + id varchar(100) not null, + detail varchar(255), + master_id varchar(100), + version bigint not null, + constraint pk_orp_detail primary key (id) +); + +create table orp_detail2 ( + id varchar(100) not null, + orp_master2_id varchar(100) not null, + detail varchar(255), + master_id varchar(255), + version bigint not null, + constraint pk_orp_detail2 primary key (id) +); + +create table orp_master ( + id varchar(100) not null, + name varchar(255), + version bigint not null, + constraint pk_orp_master primary key (id) +); + +create table orp_master2 ( + id varchar(100) not null, + name varchar(255), + version bigint not null, + constraint pk_orp_master2 primary key (id) +); + +create table oto_aone ( + id varchar(100) not null, + description varchar(255), + constraint pk_oto_aone primary key (id) +); + +create table oto_atwo ( + id varchar(100) not null, + description varchar(255), + aone_id varchar(100), + constraint uq_oto_atwo_aone_id unique (aone_id), + constraint pk_oto_atwo primary key (id) +); + +create table oto_bchild ( + master_id bigint auto_increment not null, + child varchar(255), + constraint pk_oto_bchild primary key (master_id) +); + +create table oto_bmaster ( + id bigint auto_increment not null, + name varchar(255), + constraint pk_oto_bmaster primary key (id) +); + +create table oto_child ( + id integer auto_increment not null, + name varchar(255), + master_id bigint, + constraint uq_oto_child_master_id unique (master_id), + constraint pk_oto_child primary key (id) +); + +create table oto_cust ( + cid bigint auto_increment not null, + name varchar(255), + version bigint not null, + constraint pk_oto_cust primary key (cid) +); + +create table oto_cust_address ( + aid bigint auto_increment not null, + line1 varchar(255), + line2 varchar(255), + line3 varchar(255), + customer_cid bigint, + version bigint not null, + constraint uq_oto_cust_address_customer_cid unique (customer_cid), + constraint pk_oto_cust_address primary key (aid) +); + +create table oto_level_a ( + id bigint auto_increment not null, + name varchar(255), + b_id bigint, + constraint uq_oto_level_a_b_id unique (b_id), + constraint pk_oto_level_a primary key (id) +); + +create table oto_level_b ( + id bigint auto_increment not null, + name varchar(255), + c_id bigint, + constraint uq_oto_level_b_c_id unique (c_id), + constraint pk_oto_level_b primary key (id) +); + +create table oto_level_c ( + id bigint auto_increment not null, + name varchar(255), + constraint pk_oto_level_c primary key (id) +); + +create table oto_master ( + id bigint auto_increment not null, + name varchar(255), + constraint pk_oto_master primary key (id) +); + +create table oto_prime ( + pid bigint auto_increment not null, + name varchar(255), + version bigint not null, + constraint pk_oto_prime primary key (pid) +); + +create table oto_prime_extra ( + eid bigint auto_increment not null, + extra varchar(255), + version bigint not null, + constraint pk_oto_prime_extra primary key (eid) +); + +create table oto_sd_child ( + id bigint auto_increment not null, + child varchar(255), + master_id bigint, + deleted tinyint(1) default 0 not null, + version bigint not null, + constraint uq_oto_sd_child_master_id unique (master_id), + constraint pk_oto_sd_child primary key (id) +); + +create table oto_sd_master ( + id bigint auto_increment not null, + name varchar(255), + version bigint not null, + constraint pk_oto_sd_master primary key (id) +); + +create table oto_th_many ( + id bigint auto_increment not null, + oto_th_top_id bigint not null, + many varchar(255), + version bigint not null, + when_created datetime(6) not null, + when_modified datetime(6) not null, + constraint pk_oto_th_many primary key (id) +); + +create table oto_th_one ( + id bigint auto_increment not null, + one tinyint(1) default 0 not null, + many_id bigint, + version bigint not null, + when_created datetime(6) not null, + when_modified datetime(6) not null, + constraint uq_oto_th_one_many_id unique (many_id), + constraint pk_oto_th_one primary key (id) +); + +create table oto_th_top ( + id bigint auto_increment not null, + topp varchar(255), + version bigint not null, + when_created datetime(6) not null, + when_modified datetime(6) not null, + constraint pk_oto_th_top primary key (id) +); + +create table oto_ubprime ( + pid varchar(40) not null, + name varchar(255), + version bigint not null, + constraint pk_oto_ubprime primary key (pid) +); + +create table oto_ubprime_extra ( + eid varchar(40) not null, + extra varchar(255), + version bigint not null, + constraint pk_oto_ubprime_extra primary key (eid) +); + +create table oto_uprime ( + pid varchar(40) not null, + name varchar(255), + version bigint not null, + constraint pk_oto_uprime primary key (pid) +); + +create table oto_uprime_extra ( + eid varchar(40) not null, + extra varchar(255), + version bigint not null, + constraint pk_oto_uprime_extra primary key (eid) +); + +create table oto_user_model ( + id bigint auto_increment not null, + name varchar(255), + user_optional_id bigint, + version bigint not null, + when_created datetime(6) not null, + when_modified datetime(6) not null, + constraint uq_oto_user_model_user_optional_id unique (user_optional_id), + constraint pk_oto_user_model primary key (id) +); + +create table oto_user_model_optional ( + id bigint auto_increment not null, + optional varchar(255), + version bigint not null, + when_created datetime(6) not null, + when_modified datetime(6) not null, + constraint pk_oto_user_model_optional primary key (id) +); + +create table pfile ( + id integer auto_increment not null, + name varchar(255), + file_content_id integer, + file_content2_id integer, + cretime datetime(6) not null, + updtime datetime(6) not null, + version bigint not null, + constraint uq_pfile_file_content_id unique (file_content_id), + constraint uq_pfile_file_content2_id unique (file_content2_id), + constraint pk_pfile primary key (id) +); + +create table pfile_content ( + id integer auto_increment not null, + content longblob, + cretime datetime(6) not null, + updtime datetime(6) not null, + version bigint not null, + constraint pk_pfile_content primary key (id) +); + +create table paggview ( + pview_id varchar(40), + amount integer not null, + constraint uq_paggview_pview_id unique (pview_id) +); + +create table pallet_location ( + type varchar(31) not null, + id integer auto_increment not null, + zone_sid integer not null, + attribute varchar(255), + constraint pk_pallet_location primary key (id) +); + +create table parcel ( + parcelid bigint auto_increment not null, + description varchar(255), + constraint pk_parcel primary key (parcelid) +); + +create table parcel_location ( + parcellocid bigint auto_increment not null, + location varchar(255), + parcelid bigint, + constraint uq_parcel_location_parcelid unique (parcelid), + constraint pk_parcel_location primary key (parcellocid) +); + +create table rawinherit_parent ( + type varchar(31) not null, + id bigint auto_increment not null, + val integer, + more varchar(255), + constraint pk_rawinherit_parent primary key (id) +); + +create table rawinherit_parent_rawinherit_data ( + rawinherit_parent_id bigint not null, + rawinherit_data_id bigint not null, + constraint pk_rawinherit_parent_rawinherit_data primary key (rawinherit_parent_id,rawinherit_data_id) +); + +create table e_save_test_c ( + id bigint auto_increment not null, + version bigint not null, + constraint pk_e_save_test_c primary key (id) +); + +create table parent_person ( + identifier integer auto_increment not null, + name varchar(255), + age integer, + some_bean_id integer, + parent_identifier integer, + family_name varchar(255), + address varchar(255), + constraint pk_parent_person primary key (identifier) +); + +create table c_participation ( + id bigint auto_increment not null, + rating integer, + type integer, + conversation_id bigint not null, + user_id bigint not null, + version bigint not null, + when_created datetime(6) not null, + when_modified datetime(6) not null, + constraint pk_c_participation primary key (id) +); + +create table password_store_model ( + id bigint auto_increment not null, + enc1 varchar(30), + enc2 varchar(40), + enc3 longtext, + enc4 varbinary(30), + enc5 varbinary(40), + enc6 longblob, + version bigint not null, + when_created datetime(6) not null, + when_modified datetime(6) not null, + constraint pk_password_store_model primary key (id) +); + +create table pcf_calendar ( + id bigint auto_increment not null, + pcf_person_id bigint not null, + version bigint not null, + constraint pk_pcf_calendar primary key (id) +); + +create table pcf_city ( + id bigint auto_increment not null, + pcf_country_id bigint not null, + name varchar(255), + mayor_id bigint not null, + vice_mayor_id bigint not null, + version bigint not null, + constraint uq_pcf_city_mayor_id unique (mayor_id), + constraint uq_pcf_city_vice_mayor_id unique (vice_mayor_id), + constraint pk_pcf_city primary key (id) +); + +create table pcf_country ( + id bigint auto_increment not null, + version bigint not null, + constraint pk_pcf_country primary key (id) +); + +create table pcf_event ( + id bigint auto_increment not null, + pcf_calendar_id bigint not null, + name varchar(255), + version bigint not null, + constraint pk_pcf_event primary key (id) +); + +create table pcf_person ( + id bigint auto_increment not null, + name varchar(255), + version bigint not null, + constraint pk_pcf_person primary key (id) +); + +create table mt_permission ( + id varchar(40) not null, + name varchar(255), + constraint pk_mt_permission primary key (id) +); + +create table persistent_file ( + id integer auto_increment not null, + name varchar(255), + cretime datetime(6) not null, + updtime datetime(6) not null, + version bigint not null, + constraint pk_persistent_file primary key (id) +); + +create table persistent_file_content ( + id integer auto_increment not null, + persistent_file_id integer, + content longblob, + cretime datetime(6) not null, + updtime datetime(6) not null, + version bigint not null, + constraint uq_persistent_file_content_persistent_file_id unique (persistent_file_id), + constraint pk_persistent_file_content primary key (id) +); + +create table person ( + oid bigint auto_increment not null, + default_address_oid bigint, + version integer not null, + constraint pk_person primary key (oid) +); + +create table persons ( + id bigint auto_increment not null, + surname varchar(64) not null, + name varchar(64) not null, + constraint pk_persons primary key (id) +); + +create table person_cache_email ( + id varchar(128) not null, + person_info_person_id varchar(128), + email varchar(255), + constraint pk_person_cache_email primary key (id) +); + +create table person_cache_info ( + person_id varchar(128) not null, + name varchar(255), + constraint pk_person_cache_info primary key (person_id) +); + +create table phones ( + id bigint auto_increment not null, + phone_number varchar(7) not null, + person_id bigint not null, + constraint uq_phones_phone_number unique (phone_number), + constraint pk_phones primary key (id) +); + +create table e_position ( + id bigint auto_increment not null, + name varchar(255), + contract_id bigint not null, + constraint pk_e_position primary key (id) +); + +create table primary_revision ( + id bigint not null, + revision integer not null, + name varchar(255), + version bigint not null, + constraint pk_primary_revision primary key (id,revision) +); + +create table o_product ( + id integer auto_increment not null, + sku varchar(20), + name varchar(255), + cretime datetime(6) not null, + updtime datetime(6) not null, + constraint pk_o_product primary key (id) +); + +create table pp ( + id varchar(40) not null, + name varchar(255), + value varchar(100) not null, + constraint pk_pp primary key (id) +); + +create table pp_to_ww ( + pp_id varchar(40) not null, + ww_id varchar(40) not null, + constraint pk_pp_to_ww primary key (pp_id,ww_id) +); + +create table question ( + id bigint auto_increment not null, + name varchar(255), + groupobjectid bigint, + sequence_number integer not null, + constraint pk_question primary key (id) +); + +create table rcustomer ( + company varchar(127) not null, + name varchar(127) not null, + description varchar(255), + constraint pk_rcustomer primary key (company,name) +); + +create table r_orders ( + company varchar(127) not null, + order_number integer not null, + customername varchar(127), + item varchar(255), + constraint pk_r_orders primary key (company,order_number) +); + +create table referenced_defaults_model ( + id integer auto_increment not null, + defaults_model_id integer not null, + name varchar(255), + constraint pk_referenced_defaults_model primary key (id) +); + +create table referenced_defaults_model_draft ( + id integer auto_increment not null, + defaults_model_id integer not null, + name varchar(255), + constraint pk_referenced_defaults_model_draft primary key (id) +); + +create table referencing_bean ( + id varchar(40) not null, + constraint pk_referencing_bean primary key (id) +); + +create table region ( + customer integer not null, + type integer not null, + description varchar(255), + version bigint not null, + constraint pk_region primary key (customer,type) +); + +create table rel_detail ( + id bigint auto_increment not null, + name varchar(255), + version integer not null, + constraint pk_rel_detail primary key (id) +); + +create table rel_master ( + id bigint auto_increment not null, + name varchar(255), + detail_id bigint, + version integer not null, + constraint pk_rel_master primary key (id) +); + +create table resourcefile ( + id varchar(64) not null, + parentresourcefileid varchar(64), + name varchar(128) not null, + constraint pk_resourcefile primary key (id) +); + +create table mt_role ( + id varchar(40) not null, + name varchar(50), + tenant_id varchar(40), + version bigint not null, + constraint pk_mt_role primary key (id) +); + +create table mt_role_permission ( + mt_role_id varchar(40) not null, + mt_permission_id varchar(40) not null, + constraint pk_mt_role_permission primary key (mt_role_id,mt_permission_id) +); + +create table em_role ( + id bigint auto_increment not null, + name varchar(255), + constraint pk_em_role primary key (id) +); + +create table root_bean ( + dtype varchar(31) not null, + id varchar(40) not null, + referencing_bean_id varchar(40) not null, + value varchar(255), + constraint pk_root_bean primary key (id) +); + +create table f_second ( + id bigint auto_increment not null, + mod_name varchar(255), + first bigint, + title varchar(255), + constraint uq_f_second_first unique (first), + constraint pk_f_second primary key (id) +); + +create table section ( + id integer auto_increment not null, + article_id integer, + type integer, + content longtext, + cretime datetime(6) not null, + updtime datetime(6) not null, + version bigint not null, + constraint pk_section primary key (id) +); + +create table self_parent ( + id bigint auto_increment not null, + name varchar(255), + parent_id bigint, + version bigint not null, + constraint pk_self_parent primary key (id) +); + +create table self_ref_customer ( + id bigint auto_increment not null, + name varchar(255), + referred_by_id bigint, + constraint pk_self_ref_customer primary key (id) +); + +create table self_ref_example ( + id bigint auto_increment not null, + name varchar(255) not null, + parent_id bigint, + constraint pk_self_ref_example primary key (id) +); + +create table e_save_test_a ( + id bigint auto_increment not null, + version bigint not null, + constraint pk_e_save_test_a primary key (id) +); + +create table e_save_test_b ( + id bigint auto_increment not null, + sibling_a_id bigint, + test_property tinyint(1) default 0 not null, + version bigint not null, + constraint uq_e_save_test_b_sibling_a_id unique (sibling_a_id), + constraint pk_e_save_test_b primary key (id) +); + +create table site ( + id varchar(40) not null, + name varchar(255), + parent_id varchar(40), + data_container_id varchar(40), + site_address_id varchar(40), + constraint uq_site_data_container_id unique (data_container_id), + constraint uq_site_site_address_id unique (site_address_id), + constraint pk_site primary key (id) +); + +create table site_address ( + id varchar(40) not null, + street varchar(255), + city varchar(255), + zip_code varchar(255), + constraint pk_site_address primary key (id) +); + +create table some_enum_bean ( + id bigint auto_increment not null, + some_enum integer, + name varchar(255), + constraint pk_some_enum_bean primary key (id) +); + +create table some_file_bean ( + id bigint auto_increment not null, + name varchar(255), + content longblob, + version bigint not null, + constraint pk_some_file_bean primary key (id) +); + +create table some_new_types_bean ( + id bigint auto_increment not null, + dow integer(1), + mth integer(1), + yr integer, + yr_mth date, + month_day date, + sql_date date, + sql_time time, + local_date date, + local_date_time datetime(6), + offset_date_time datetime(6), + zoned_date_time datetime(6), + local_time time, + instant datetime(6), + zone_id varchar(60), + zone_offset varchar(60), + path varchar(255), + period varchar(20), + duration bigint, + version bigint not null, + constraint pk_some_new_types_bean primary key (id) +); + +create table some_period_bean ( + id bigint auto_increment not null, + anniversary date, + version bigint not null, + constraint pk_some_period_bean primary key (id) +); + +create table source_base ( + dtype varchar(31) not null, + id varchar(40) not null, + name varchar(255), + pos integer not null, + target_id varchar(40), + constraint pk_source_base primary key (id) +); + +create table stockforecast ( + type varchar(31) not null, + id bigint auto_increment not null, + inner_report_id bigint, + constraint pk_stockforecast primary key (id) +); + +create table sub_section ( + id integer auto_increment not null, + section_id integer, + title varchar(255), + cretime datetime(6) not null, + updtime datetime(6) not null, + version bigint not null, + constraint pk_sub_section primary key (id) +); + +create table sub_type ( + sub_type_id integer auto_increment not null, + description varchar(255), + version bigint not null, + constraint pk_sub_type primary key (sub_type_id) +); + +create table survey ( + id bigint auto_increment not null, + name varchar(255), + constraint pk_survey primary key (id) +); + +create table tbytes_only ( + id integer auto_increment not null, + content longblob, + constraint pk_tbytes_only primary key (id) +); + +create table tcar ( + type varchar(31) not null, + plate_no varchar(32) not null, + truckload bigint, + constraint pk_tcar primary key (plate_no) +); + +create table tevent ( + id bigint auto_increment not null, + name varchar(255), + version bigint not null, + constraint pk_tevent primary key (id) +); + +create table tevent_many ( + id bigint auto_increment not null, + description varchar(255), + event_id bigint, + units integer not null, + amount double not null, + version bigint not null, + constraint pk_tevent_many primary key (id) +); + +create table tevent_one ( + id bigint auto_increment not null, + name varchar(255), + status integer, + event_id bigint, + version bigint not null, + constraint uq_tevent_one_event_id unique (event_id), + constraint pk_tevent_one primary key (id) +); + +create table tint_root ( + my_type integer(3) not null, + id integer auto_increment not null, + name varchar(255), + child_property varchar(255), + constraint pk_tint_root primary key (id) +); + +create table tjoda_entity ( + id integer auto_increment not null, + local_time time, + constraint pk_tjoda_entity primary key (id) +); + +create table t_mapsuper1 ( + id integer auto_increment not null, + something varchar(255), + name varchar(255), + version integer not null, + constraint pk_t_mapsuper1 primary key (id) +); + +create table t_oneb ( + id integer auto_increment not null, + name varchar(255), + description varchar(255), + active tinyint(1) default 0 not null, + constraint pk_t_oneb primary key (id) +); + +create table t_detail_with_other_namexxxyy ( + id integer auto_increment not null, + name varchar(255), + description varchar(255), + some_unique_value varchar(127), + active tinyint(1) default 0 not null, + master_id integer, + constraint uq_t_detail_with_other_namexxxyy_some_unique_value unique (some_unique_value), + constraint pk_t_detail_with_other_namexxxyy primary key (id) +); + +create table t_atable_thatisrelatively ( + id integer auto_increment not null, + name varchar(255), + description varchar(255), + active tinyint(1) default 0 not null, + constraint pk_t_atable_thatisrelatively primary key (id) +); + +create table ttruck_holder ( + id bigint auto_increment not null, + name varchar(255), + truck_plate_no varchar(32) not null, + basic_id integer, + version bigint not null, + constraint pk_ttruck_holder primary key (id) +); + +create table ttruck_holder_item ( + id bigint auto_increment not null, + some_uid varchar(40), + foo varchar(255), + owner_id bigint not null, + constraint pk_ttruck_holder_item primary key (id) +); + +create table tuuid_entity ( + id varchar(40) not null, + name varchar(255), + constraint pk_tuuid_entity primary key (id) +); + +create table twheel ( + id bigint auto_increment not null, + owner_plate_no varchar(32) not null, + constraint pk_twheel primary key (id) +); + +create table twith_pre_insert ( + id integer auto_increment not null, + name varchar(255) not null, + title varchar(255), + constraint pk_twith_pre_insert primary key (id) +); + +create table target_base ( + dtype varchar(31) not null, + id varchar(40) not null, + name varchar(255), + constraint pk_target_base primary key (id) +); + +create table mt_tenant ( + id varchar(40) not null, + name varchar(255), + version bigint not null, + constraint pk_mt_tenant primary key (id) +); + +create table test_annotation_base_entity ( + direct varchar(255), + meta varchar(255), + mixed varchar(255), + constraint_annotation varchar(40), + null1 varchar(255) not null, + null2 varchar(255), + null3 varchar(255) +); + +create table tire ( + id bigint auto_increment not null, + wheel bigint, + version integer not null, + constraint uq_tire_wheel unique (wheel), + constraint pk_tire primary key (id) +); + +create table sa_tire ( + id bigint auto_increment not null, + version integer not null, + constraint pk_sa_tire primary key (id) +); + +create table tree_entity ( + id integer auto_increment not null, + text varchar(255), + parent_id integer, + constraint pk_tree_entity primary key (id) +); + +create table trip ( + id integer auto_increment not null, + vehicle_driver_id integer, + destination varchar(255), + address_id integer, + star_date datetime(6), + cretime datetime(6) not null, + updtime datetime(6) not null, + version bigint not null, + constraint pk_trip primary key (id) +); + +create table truck_ref ( + id integer auto_increment not null, + something varchar(255), + constraint pk_truck_ref primary key (id) +); + +create table tune ( + id bigint auto_increment not null, + name varchar(255), + constraint pk_tune primary key (id) +); + +create table `type` ( + customer integer not null, + type integer not null, + description varchar(255), + sub_type_id integer, + version bigint not null, + constraint pk_type primary key (customer,type) +); + +create table tz_bean ( + id bigint auto_increment not null, + moda varchar(255), + ts datetime(6), + tstz datetime(6), + constraint pk_tz_bean primary key (id) +); + +create table usib_child ( + id varchar(40) not null, + parent_id bigint, + deleted tinyint(1) default 0 not null, + constraint pk_usib_child primary key (id) +); + +create table usib_child_sibling ( + id bigint auto_increment not null, + child_id varchar(40), + deleted tinyint(1) default 0 not null, + constraint uq_usib_child_sibling_child_id unique (child_id), + constraint pk_usib_child_sibling primary key (id) +); + +create table usib_parent ( + id bigint auto_increment not null, + deleted tinyint(1) default 0 not null, + constraint pk_usib_parent primary key (id) +); + +create table ut_detail ( + id integer auto_increment not null, + utmaster_id integer not null, + name varchar(255), + qty integer, + amount double, + version integer not null, + constraint pk_ut_detail primary key (id) +); + +create table ut_master ( + id integer auto_increment not null, + name varchar(255), + description varchar(255), + event_date date, + version integer not null, + constraint pk_ut_master primary key (id) +); + +create table uuone ( + id varchar(40) not null, + name varchar(255), + description varchar(255), + version bigint not null, + constraint pk_uuone primary key (id) +); + +create table uutwo ( + id varchar(40) not null, + name varchar(255), + notes varchar(255), + master_id varchar(40), + version bigint not null, + constraint pk_uutwo primary key (id) +); + +create table oto_user ( + id bigint auto_increment not null, + name varchar(255), + account_id bigint not null, + version bigint not null, + when_created datetime(6) not null, + when_modified datetime(6) not null, + constraint uq_oto_user_account_id unique (account_id), + constraint pk_oto_user primary key (id) +); + +create table c_user ( + id bigint auto_increment not null, + inactive tinyint(1) default 0 not null, + name varchar(255), + email varchar(255), + password_hash varchar(255), + group_id bigint, + version bigint not null, + when_created datetime(6) not null, + when_modified datetime(6) not null, + constraint pk_c_user primary key (id) +); + +create table tx_user ( + id bigint auto_increment not null, + name varchar(255), + constraint pk_tx_user primary key (id) +); + +create table g_user ( + id bigint auto_increment not null, + username varchar(255), + version bigint not null, + constraint pk_g_user primary key (id) +); + +create table em_user ( + id bigint auto_increment not null, + name varchar(255), + constraint pk_em_user primary key (id) +); + +create table user_interest_live ( + user_id bigint not null, + live_id bigint not null, + created_at datetime(6) not null, + constraint pk_user_interest_live primary key (user_id,live_id) +); + +create table em_user_role ( + user_id bigint not null, + role_id bigint not null, + constraint pk_em_user_role primary key (user_id,role_id) +); + +create table vehicle ( + dtype varchar(3) not null, + id integer auto_increment not null, + license_number varchar(255), + registration_date datetime(6), + lease_id bigint, + cretime datetime(6) not null, + updtime datetime(6) not null, + version bigint not null, + siz varchar(3), + driver varchar(255), + car_ref_id integer, + notes varchar(255), + truck_ref_id integer, + capacity double, + constraint pk_vehicle primary key (id) +); + +create table vehicle_driver ( + id integer auto_increment not null, + name varchar(255), + vehicle_id integer, + address_id integer, + license_issued_on datetime(6), + cretime datetime(6) not null, + updtime datetime(6) not null, + version bigint not null, + constraint pk_vehicle_driver primary key (id) +); + +create table vehicle_lease ( + dtype varchar(31) not null, + id bigint auto_increment not null, + name varchar(255), + active_start date, + active_end date, + version bigint not null, + bond decimal(16,3), + min_duration integer not null, + day_rate decimal(16,3), + max_days integer, + constraint pk_vehicle_lease primary key (id) +); + +create table version_child ( + id integer auto_increment not null, + name varchar(255), + parent_id integer, + version integer not null, + position integer, + constraint pk_version_child primary key (id) +); + +create table version_parent ( + id integer auto_increment not null, + name varchar(255), + version integer not null, + constraint pk_version_parent primary key (id) +); + +create table version_toy ( + id integer auto_increment not null, + name varchar(255), + child_id integer, + version integer not null, + position integer, + constraint pk_version_toy primary key (id) +); + +create table warehouses ( + id integer auto_increment not null, + officezoneid integer, + constraint pk_warehouses primary key (id) +); + +create table warehousesshippingzones ( + warehouseid integer not null, + shippingzoneid integer not null, + constraint pk_warehousesshippingzones primary key (warehouseid,shippingzoneid) +); + +create table wheel ( + id bigint auto_increment not null, + version integer not null, + constraint pk_wheel primary key (id) +); + +create table sa_wheel ( + id bigint auto_increment not null, + tire bigint, + car bigint, + version integer not null, + constraint pk_sa_wheel primary key (id) +); + +create table sp_car_wheel ( + id bigint auto_increment not null, + name varchar(255), + version integer not null, + constraint pk_sp_car_wheel primary key (id) +); + +create table g_who_props_otm ( + id bigint auto_increment not null, + name varchar(255), + version bigint not null, + when_created datetime(6) not null, + when_modified datetime(6) not null, + who_created_id bigint, + who_modified_id bigint, + constraint pk_g_who_props_otm primary key (id) +); + +create table with_zero ( + id bigint auto_increment not null, + name varchar(255), + parent_id integer, + lang varchar(2) default 'en' not null, + version bigint not null, + constraint pk_with_zero primary key (id) +); + +create table parent ( + id integer auto_increment not null, + name varchar(255), + constraint pk_parent primary key (id) +); + +create table wview ( + id varchar(40) not null, + name varchar(127) not null, + constraint uq_wview_name unique (name), + constraint pk_wview primary key (id) +); + +create table zones ( + type varchar(31) not null, + id integer auto_increment not null, + attribute varchar(255), + constraint pk_zones primary key (id) +); + +create index ix_contact_last_name_first_name on contact (last_name,first_name); +create index ix_e_basic_name on e_basic (name); +create index ix_efile2_no_fk_owner_id on efile2_no_fk (owner_id); +create index ix_ecsm_values_host_id on ecsm_values (host_id); +create index ix_order_referenced_parent_type on order_referenced_parent (type); +create index ix_organization_node_kind on organization_node (kind); +create index ano_3 on test_annotation_base_entity (direct); +create index ix_bar_foo_id on bar (foo_id); +alter table bar add constraint fk_bar_foo_id foreign key (foo_id) references foo (foo_id) on delete restrict on update restrict; + +create index ix_acl_container_relation_container_id on acl_container_relation (container_id); +alter table acl_container_relation add constraint fk_acl_container_relation_container_id foreign key (container_id) references contract (id) on delete restrict on update restrict; + +create index ix_acl_container_relation_acl_entry_id on acl_container_relation (acl_entry_id); +alter table acl_container_relation add constraint fk_acl_container_relation_acl_entry_id foreign key (acl_entry_id) references acl (id) on delete restrict on update restrict; + +create index ix_addr_employee_id on addr (employee_id); +alter table addr add constraint fk_addr_employee_id foreign key (employee_id) references empl (id) on delete restrict on update restrict; + +create index ix_o_address_country_code on o_address (country_code); +alter table o_address add constraint fk_o_address_country_code foreign key (country_code) references o_country (code) on delete restrict on update restrict; + +alter table album add constraint fk_album_cover_id foreign key (cover_id) references cover (id) on delete restrict on update restrict; + +create index ix_animal_shelter_id on animal (shelter_id); +alter table animal add constraint fk_animal_shelter_id foreign key (shelter_id) references animal_shelter (id) on delete restrict on update restrict; + +create index ix_attribute_attribute_holder_id on attribute (attribute_holder_id); +alter table attribute add constraint fk_attribute_attribute_holder_id foreign key (attribute_holder_id) references attribute_holder (id) on delete restrict on update restrict; + +create index ix_bbookmark_user_id on bbookmark (user_id); +alter table bbookmark add constraint fk_bbookmark_user_id foreign key (user_id) references bbookmark_user (id) on delete restrict on update restrict; + +create index ix_bbookmark_user_org_id on bbookmark_user (org_id); +alter table bbookmark_user add constraint fk_bbookmark_user_org_id foreign key (org_id) references bbookmark_org (id) on delete restrict on update restrict; + +create index ix_bsite_user_a_site_id on bsite_user_a (site_id); +alter table bsite_user_a add constraint fk_bsite_user_a_site_id foreign key (site_id) references bsite (id) on delete restrict on update restrict; + +create index ix_bsite_user_a_user_id on bsite_user_a (user_id); +alter table bsite_user_a add constraint fk_bsite_user_a_user_id foreign key (user_id) references buser (id) on delete restrict on update restrict; + +create index ix_bsite_user_b_site on bsite_user_b (site); +alter table bsite_user_b add constraint fk_bsite_user_b_site foreign key (site) references bsite (id) on delete restrict on update restrict; + +create index ix_bsite_user_b_usr on bsite_user_b (usr); +alter table bsite_user_b add constraint fk_bsite_user_b_usr foreign key (usr) references buser (id) on delete restrict on update restrict; + +create index ix_bsite_user_c_site_uid on bsite_user_c (site_uid); +alter table bsite_user_c add constraint fk_bsite_user_c_site_uid foreign key (site_uid) references bsite (id) on delete restrict on update restrict; + +create index ix_bsite_user_c_user_uid on bsite_user_c (user_uid); +alter table bsite_user_c add constraint fk_bsite_user_c_user_uid foreign key (user_uid) references buser (id) on delete restrict on update restrict; + +create index ix_bsite_user_e_site_id on bsite_user_e (site_id); +alter table bsite_user_e add constraint fk_bsite_user_e_site_id foreign key (site_id) references bsite (id) on delete restrict on update restrict; + +create index ix_bsite_user_e_user_id on bsite_user_e (user_id); +alter table bsite_user_e add constraint fk_bsite_user_e_user_id foreign key (user_id) references buser (id) on delete restrict on update restrict; + +alter table basic_draftable_bean add constraint fk_basic_draftable_bean_id foreign key (id) references basic_draftable_bean_draft (id) on delete restrict on update restrict; + +alter table drel_booking add constraint fk_drel_booking_agent_invoice foreign key (agent_invoice) references drel_invoice (id) on delete restrict on update restrict; + +alter table drel_booking add constraint fk_drel_booking_client_invoice foreign key (client_invoice) references drel_invoice (id) on delete restrict on update restrict; + +create index ix_cepproduct_category_category_id on cepproduct_category (category_id); +alter table cepproduct_category add constraint fk_cepproduct_category_category_id foreign key (category_id) references cepcategory (id) on delete restrict on update restrict; + +create index ix_cepproduct_category_product_id on cepproduct_category (product_id); +alter table cepproduct_category add constraint fk_cepproduct_category_product_id foreign key (product_id) references cepproduct (id) on delete restrict on update restrict; + +create index ix_ciaddress_street_id on ciaddress (street_id); +alter table ciaddress add constraint fk_ciaddress_street_id foreign key (street_id) references cistreet_parent (id) on delete restrict on update restrict; + +create index ix_cicustomer_parent_address_id on cicustomer_parent (address_id); +alter table cicustomer_parent add constraint fk_cicustomer_parent_address_id foreign key (address_id) references ciaddress (id) on delete restrict on update restrict; + +create index ix_cinh_ref_ref_id on cinh_ref (ref_id); +alter table cinh_ref add constraint fk_cinh_ref_ref_id foreign key (ref_id) references cinh_root (id) on delete restrict on update restrict; + +create index ix_ckey_detail_parent on ckey_detail (one_key,two_key); +alter table ckey_detail add constraint fk_ckey_detail_parent foreign key (one_key,two_key) references ckey_parent (one_key,two_key) on delete restrict on update restrict; + +create index ix_ckey_parent_assoc_id on ckey_parent (assoc_id); +alter table ckey_parent add constraint fk_ckey_parent_assoc_id foreign key (assoc_id) references ckey_assoc (id) on delete restrict on update restrict; + +create index ix_coone_many_coone_id on coone_many (coone_id); +alter table coone_many add constraint fk_coone_many_coone_id foreign key (coone_id) references coone (id) on delete restrict on update restrict; + +alter table coroot add constraint fk_coroot_one_id foreign key (one_id) references coone (id) on delete restrict on update restrict; + +create index ix_calculation_result_product_configuration_id on calculation_result (product_configuration_id); +alter table calculation_result add constraint fk_calculation_result_product_configuration_id foreign key (product_configuration_id) references configuration (id) on delete restrict on update restrict; + +create index ix_calculation_result_group_configuration_id on calculation_result (group_configuration_id); +alter table calculation_result add constraint fk_calculation_result_group_configuration_id foreign key (group_configuration_id) references configuration (id) on delete restrict on update restrict; + +create index ix_sp_car_car_wheels_sp_car_car on sp_car_car_wheels (car); +alter table sp_car_car_wheels add constraint fk_sp_car_car_wheels_sp_car_car foreign key (car) references sp_car_car (id) on delete restrict on update restrict; + +create index ix_sp_car_car_wheels_sp_car_wheel on sp_car_car_wheels (wheel); +alter table sp_car_car_wheels add constraint fk_sp_car_car_wheels_sp_car_wheel foreign key (wheel) references sp_car_wheel (id) on delete restrict on update restrict; + +create index ix_sp_car_car_doors_sp_car_car on sp_car_car_doors (car); +alter table sp_car_car_doors add constraint fk_sp_car_car_doors_sp_car_car foreign key (car) references sp_car_car (id) on delete restrict on update restrict; + +create index ix_sp_car_car_doors_sp_car_door on sp_car_car_doors (door); +alter table sp_car_car_doors add constraint fk_sp_car_car_doors_sp_car_door foreign key (door) references sp_car_door (id) on delete restrict on update restrict; + +create index ix_car_accessory_fuse_id on car_accessory (fuse_id); +alter table car_accessory add constraint fk_car_accessory_fuse_id foreign key (fuse_id) references car_fuse (id) on delete restrict on update restrict; + +create index ix_car_accessory_car_id on car_accessory (car_id); +alter table car_accessory add constraint fk_car_accessory_car_id foreign key (car_id) references vehicle (id) on delete restrict on update restrict; + +create index ix_category_surveyobjectid on category (surveyobjectid); +alter table category add constraint fk_category_surveyobjectid foreign key (surveyobjectid) references survey (id) on delete restrict on update restrict; + +alter table e_save_test_d add constraint fk_e_save_test_d_parent_id foreign key (parent_id) references e_save_test_c (id) on delete restrict on update restrict; + +create index ix_child_person_some_bean_id on child_person (some_bean_id); +alter table child_person add constraint fk_child_person_some_bean_id foreign key (some_bean_id) references e_basic (id) on delete restrict on update restrict; + +create index ix_child_person_parent_identifier on child_person (parent_identifier); +alter table child_person add constraint fk_child_person_parent_identifier foreign key (parent_identifier) references parent_person (identifier) on delete restrict on update restrict; + +create index ix_cke_client_user on cke_client (username,cod_cpny); +alter table cke_client add constraint fk_cke_client_user foreign key (username,cod_cpny) references cke_user (username,cod_cpny) on delete restrict on update restrict; + +alter table class_super_monkey add constraint fk_class_super_monkey_class_super foreign key (class_super_sid) references class_super (sid) on delete restrict on update restrict; + +alter table class_super_monkey add constraint fk_class_super_monkey_monkey foreign key (monkey_mid) references monkey (mid) on delete restrict on update restrict; + +create index ix_configuration_configurations_id on configuration (configurations_id); +alter table configuration add constraint fk_configuration_configurations_id foreign key (configurations_id) references configurations (id) on delete restrict on update restrict; + +create index ix_contact_customer_id on contact (customer_id); +alter table contact add constraint fk_contact_customer_id foreign key (customer_id) references o_customer (id) on delete restrict on update restrict; + +create index ix_contact_group_id on contact (group_id); +alter table contact add constraint fk_contact_group_id foreign key (group_id) references contact_group (id) on delete restrict on update restrict; + +create index ix_contact_note_contact_id on contact_note (contact_id); +alter table contact_note add constraint fk_contact_note_contact_id foreign key (contact_id) references contact (id) on delete restrict on update restrict; + +create index ix_contract_costs_position_id on contract_costs (position_id); +alter table contract_costs add constraint fk_contract_costs_position_id foreign key (position_id) references e_position (id) on delete restrict on update restrict; + +create index ix_c_conversation_group_id on c_conversation (group_id); +alter table c_conversation add constraint fk_c_conversation_group_id foreign key (group_id) references c_group (id) on delete restrict on update restrict; + +create index ix_o_customer_billing_address_id on o_customer (billing_address_id); +alter table o_customer add constraint fk_o_customer_billing_address_id foreign key (billing_address_id) references o_address (id) on delete restrict on update restrict; + +create index ix_o_customer_shipping_address_id on o_customer (shipping_address_id); +alter table o_customer add constraint fk_o_customer_shipping_address_id foreign key (shipping_address_id) references o_address (id) on delete restrict on update restrict; + +create index ix_dcredit_drol_dcredit on dcredit_drol (dcredit_id); +alter table dcredit_drol add constraint fk_dcredit_drol_dcredit foreign key (dcredit_id) references dcredit (id) on delete restrict on update restrict; + +create index ix_dcredit_drol_drol on dcredit_drol (drol_id); +alter table dcredit_drol add constraint fk_dcredit_drol_drol foreign key (drol_id) references drol (id) on delete restrict on update restrict; + +create index ix_dmachine_organisation_id on dmachine (organisation_id); +alter table dmachine add constraint fk_dmachine_organisation_id foreign key (organisation_id) references dorg (id) on delete restrict on update restrict; + +create index ix_d_machine_aux_use_machine_id on d_machine_aux_use (machine_id); +alter table d_machine_aux_use add constraint fk_d_machine_aux_use_machine_id foreign key (machine_id) references dmachine (id) on delete restrict on update restrict; + +create index ix_d_machine_stats_machine_id on d_machine_stats (machine_id); +alter table d_machine_stats add constraint fk_d_machine_stats_machine_id foreign key (machine_id) references dmachine (id) on delete restrict on update restrict; + +create index ix_d_machine_use_machine_id on d_machine_use (machine_id); +alter table d_machine_use add constraint fk_d_machine_use_machine_id foreign key (machine_id) references dmachine (id) on delete restrict on update restrict; + +create index ix_drot_drol_drot on drot_drol (drot_id); +alter table drot_drol add constraint fk_drot_drol_drot foreign key (drot_id) references drot (id) on delete restrict on update restrict; + +create index ix_drot_drol_drol on drot_drol (drol_id); +alter table drot_drol add constraint fk_drot_drol_drol foreign key (drol_id) references drol (id) on delete restrict on update restrict; + +create index ix_dc_detail_master_id on dc_detail (master_id); +alter table dc_detail add constraint fk_dc_detail_master_id foreign key (master_id) references dc_master (id) on delete restrict on update restrict; + +alter table defaults_model add constraint fk_defaults_model_id foreign key (id) references defaults_model_draft (id) on delete restrict on update restrict; + +create index ix_dfk_cascade_one_id on dfk_cascade (one_id); +alter table dfk_cascade add constraint fk_dfk_cascade_one_id foreign key (one_id) references dfk_cascade_one (id) on delete cascade on update cascade; + +create index ix_dfk_set_null_one_id on dfk_set_null (one_id); +alter table dfk_set_null add constraint fk_dfk_set_null_one_id foreign key (one_id) references dfk_one (id) on delete set null on update set null; + +alter table doc add constraint fk_doc_id foreign key (id) references doc_draft (id) on delete restrict on update restrict; + +create index ix_doc_link_doc on doc_link (doc_id); +alter table doc_link add constraint fk_doc_link_doc foreign key (doc_id) references doc (id) on delete restrict on update restrict; + +create index ix_doc_link_link on doc_link (link_id); +alter table doc_link add constraint fk_doc_link_link foreign key (link_id) references link (id) on delete restrict on update restrict; + +alter table document add constraint fk_document_id foreign key (id) references document_draft (id) on delete restrict on update restrict; + +create index ix_document_organisation_id on document (organisation_id); +alter table document add constraint fk_document_organisation_id foreign key (organisation_id) references organisation (id) on delete restrict on update restrict; + +create index ix_document_draft_organisation_id on document_draft (organisation_id); +alter table document_draft add constraint fk_document_draft_organisation_id foreign key (organisation_id) references organisation (id) on delete restrict on update restrict; + +create index ix_document_media_document_id on document_media (document_id); +alter table document_media add constraint fk_document_media_document_id foreign key (document_id) references document (id) on delete restrict on update restrict; + +create index ix_document_media_draft_document_id on document_media_draft (document_id); +alter table document_media_draft add constraint fk_document_media_draft_document_id foreign key (document_id) references document_draft (id) on delete restrict on update restrict; + +create index ix_e_basicenc_relate_other_id on e_basicenc_relate (other_id); +alter table e_basicenc_relate add constraint fk_e_basicenc_relate_other_id foreign key (other_id) references e_basicenc (id) on delete restrict on update restrict; + +create index ix_ebasic_json_map_detail_owner_id on ebasic_json_map_detail (owner_id); +alter table ebasic_json_map_detail add constraint fk_ebasic_json_map_detail_owner_id foreign key (owner_id) references ebasic_json_map (id) on delete restrict on update restrict; + +create index ix_ebasic_no_sdchild_owner_id on ebasic_no_sdchild (owner_id); +alter table ebasic_no_sdchild add constraint fk_ebasic_no_sdchild_owner_id foreign key (owner_id) references ebasic_soft_delete (id) on delete restrict on update restrict; + +create index ix_ebasic_sdchild_owner_id on ebasic_sdchild (owner_id); +alter table ebasic_sdchild add constraint fk_ebasic_sdchild_owner_id foreign key (owner_id) references ebasic_soft_delete (id) on delete restrict on update restrict; + +create index ix_ecache_child_root_id on ecache_child (root_id); +alter table ecache_child add constraint fk_ecache_child_root_id foreign key (root_id) references ecache_root (id) on delete restrict on update restrict; + +alter table edefault_prop add constraint fk_edefault_prop_e_simple_usertypeid foreign key (e_simple_usertypeid) references esimple (usertypeid) on delete restrict on update restrict; + +create index ix_eemb_inner_outer_id on eemb_inner (outer_id); +alter table eemb_inner add constraint fk_eemb_inner_outer_id foreign key (outer_id) references eemb_outer (id) on delete restrict on update restrict; + +create index ix_einvoice_person_id on einvoice (person_id); +alter table einvoice add constraint fk_einvoice_person_id foreign key (person_id) references eperson (id) on delete restrict on update restrict; + +create index ix_enull_collection_detail_enull_collection_id on enull_collection_detail (enull_collection_id); +alter table enull_collection_detail add constraint fk_enull_collection_detail_enull_collection_id foreign key (enull_collection_id) references enull_collection (id) on delete restrict on update restrict; + +create index ix_eopt_one_a_b_id on eopt_one_a (b_id); +alter table eopt_one_a add constraint fk_eopt_one_a_b_id foreign key (b_id) references eopt_one_b (id) on delete restrict on update restrict; + +create index ix_eopt_one_b_c_id on eopt_one_b (c_id); +alter table eopt_one_b add constraint fk_eopt_one_b_c_id foreign key (c_id) references eopt_one_c (id) on delete restrict on update restrict; + +create index ix_eper_addr_ma_country_code on eper_addr (ma_country_code); +alter table eper_addr add constraint fk_eper_addr_ma_country_code foreign key (ma_country_code) references o_country (code) on delete restrict on update restrict; + +create index ix_esoft_del_book_lend_by_id on esoft_del_book (lend_by_id); +alter table esoft_del_book add constraint fk_esoft_del_book_lend_by_id foreign key (lend_by_id) references esoft_del_user (id) on delete restrict on update restrict; + +create index ix_esoft_del_book_esoft_del_user_esoft_del_book on esoft_del_book_esoft_del_user (esoft_del_book_id); +alter table esoft_del_book_esoft_del_user add constraint fk_esoft_del_book_esoft_del_user_esoft_del_book foreign key (esoft_del_book_id) references esoft_del_book (id) on delete restrict on update restrict; + +create index ix_esoft_del_book_esoft_del_user_esoft_del_user on esoft_del_book_esoft_del_user (esoft_del_user_id); +alter table esoft_del_book_esoft_del_user add constraint fk_esoft_del_book_esoft_del_user_esoft_del_user foreign key (esoft_del_user_id) references esoft_del_user (id) on delete restrict on update restrict; + +create index ix_esoft_del_down_esoft_del_mid_id on esoft_del_down (esoft_del_mid_id); +alter table esoft_del_down add constraint fk_esoft_del_down_esoft_del_mid_id foreign key (esoft_del_mid_id) references esoft_del_mid (id) on delete restrict on update restrict; + +create index ix_esoft_del_mid_top_id on esoft_del_mid (top_id); +alter table esoft_del_mid add constraint fk_esoft_del_mid_top_id foreign key (top_id) references esoft_del_top (id) on delete restrict on update restrict; + +create index ix_esoft_del_mid_up_id on esoft_del_mid (up_id); +alter table esoft_del_mid add constraint fk_esoft_del_mid_up_id foreign key (up_id) references esoft_del_up (id) on delete restrict on update restrict; + +alter table esoft_del_one_a add constraint fk_esoft_del_one_a_oneb_id foreign key (oneb_id) references esoft_del_one_b (id) on delete restrict on update restrict; + +create index ix_esoft_del_role_esoft_del_user_esoft_del_role on esoft_del_role_esoft_del_user (esoft_del_role_id); +alter table esoft_del_role_esoft_del_user add constraint fk_esoft_del_role_esoft_del_user_esoft_del_role foreign key (esoft_del_role_id) references esoft_del_role (id) on delete restrict on update restrict; + +create index ix_esoft_del_role_esoft_del_user_esoft_del_user on esoft_del_role_esoft_del_user (esoft_del_user_id); +alter table esoft_del_role_esoft_del_user add constraint fk_esoft_del_role_esoft_del_user_esoft_del_user foreign key (esoft_del_user_id) references esoft_del_user (id) on delete restrict on update restrict; + +create index ix_esoft_del_user_esoft_del_role_esoft_del_user on esoft_del_user_esoft_del_role (esoft_del_user_id); +alter table esoft_del_user_esoft_del_role add constraint fk_esoft_del_user_esoft_del_role_esoft_del_user foreign key (esoft_del_user_id) references esoft_del_user (id) on delete restrict on update restrict; + +create index ix_esoft_del_user_esoft_del_role_esoft_del_role on esoft_del_user_esoft_del_role (esoft_del_role_id); +alter table esoft_del_user_esoft_del_role add constraint fk_esoft_del_user_esoft_del_role_esoft_del_role foreign key (esoft_del_role_id) references esoft_del_role (id) on delete restrict on update restrict; + +create index ix_rawinherit_uncle_parent_id on rawinherit_uncle (parent_id); +alter table rawinherit_uncle add constraint fk_rawinherit_uncle_parent_id foreign key (parent_id) references rawinherit_parent (id) on delete restrict on update restrict; + +create index ix_evanilla_collection_detail_evanilla_collection_id on evanilla_collection_detail (evanilla_collection_id); +alter table evanilla_collection_detail add constraint fk_evanilla_collection_detail_evanilla_collection_id foreign key (evanilla_collection_id) references evanilla_collection (id) on delete restrict on update restrict; + +create index ix_ec_enum_person_tags_ec_enum_person_id on ec_enum_person_tags (ec_enum_person_id); +alter table ec_enum_person_tags add constraint fk_ec_enum_person_tags_ec_enum_person_id foreign key (ec_enum_person_id) references ec_enum_person (id) on delete restrict on update restrict; + +create index ix_ec_person_phone_owner_id on ec_person_phone (owner_id); +alter table ec_person_phone add constraint fk_ec_person_phone_owner_id foreign key (owner_id) references ec_person (id) on delete restrict on update restrict; + +create index ix_ec_top_person_id on ec_top (person_id); +alter table ec_top add constraint fk_ec_top_person_id foreign key (person_id) references ecs_person (id) on delete restrict on update restrict; + +create index ix_ec_top_ecs_person_ec_top on ec_top_ecs_person (ec_top_id); +alter table ec_top_ecs_person add constraint fk_ec_top_ecs_person_ec_top foreign key (ec_top_id) references ec_top (id) on delete restrict on update restrict; + +create index ix_ec_top_ecs_person_ecs_person on ec_top_ecs_person (ecs_person_id); +alter table ec_top_ecs_person add constraint fk_ec_top_ecs_person_ecs_person foreign key (ecs_person_id) references ecs_person (id) on delete restrict on update restrict; + +create index ix_ecbl_person_phone_numbers_person_id on ecbl_person_phone_numbers (person_id); +alter table ecbl_person_phone_numbers add constraint fk_ecbl_person_phone_numbers_person_id foreign key (person_id) references ecbl_person (id) on delete restrict on update restrict; + +create index ix_ecbm_person_phone_numbers_person_id on ecbm_person_phone_numbers (person_id); +alter table ecbm_person_phone_numbers add constraint fk_ecbm_person_phone_numbers_person_id foreign key (person_id) references ecbm_person (id) on delete restrict on update restrict; + +create index ix_ecm_person_phone_numbers_ecm_person_id on ecm_person_phone_numbers (ecm_person_id); +alter table ecm_person_phone_numbers add constraint fk_ecm_person_phone_numbers_ecm_person_id foreign key (ecm_person_id) references ecm_person (id) on delete restrict on update restrict; + +create index ix_ecmc_person_phone_numbers_ecmc_person_id on ecmc_person_phone_numbers (ecmc_person_id); +alter table ecmc_person_phone_numbers add constraint fk_ecmc_person_phone_numbers_ecmc_person_id foreign key (ecmc_person_id) references ecmc_person (id) on delete restrict on update restrict; + +create index ix_ecs_person_phone_ecs_person_id on ecs_person_phone (ecs_person_id); +alter table ecs_person_phone add constraint fk_ecs_person_phone_ecs_person_id foreign key (ecs_person_id) references ecs_person (id) on delete restrict on update restrict; + +create index ix_ecsm_child_ecsm_parent_id on ecsm_child (ecsm_parent_id); +alter table ecsm_child add constraint fk_ecsm_child_ecsm_parent_id foreign key (ecsm_parent_id) references ecsm_parent (id) on delete restrict on update restrict; + +create index ix_td_child_parent_id on td_child (parent_id); +alter table td_child add constraint fk_td_child_parent_id foreign key (parent_id) references td_parent (parent_id) on delete restrict on update restrict; + +create index ix_element_bean_complex_bean_id on element_bean (complex_bean_id); +alter table element_bean add constraint fk_element_bean_complex_bean_id foreign key (complex_bean_id) references root_bean (id) on delete restrict on update restrict; + +create index ix_empl_default_address_id on empl (default_address_id); +alter table empl add constraint fk_empl_default_address_id foreign key (default_address_id) references addr (id) on delete restrict on update restrict; + +create index ix_esd_detail_master_id on esd_detail (master_id); +alter table esd_detail add constraint fk_esd_detail_master_id foreign key (master_id) references esd_master (id) on delete restrict on update restrict; + +create index ix_grand_parent_person_some_bean_id on grand_parent_person (some_bean_id); +alter table grand_parent_person add constraint fk_grand_parent_person_some_bean_id foreign key (some_bean_id) references e_basic (id) on delete restrict on update restrict; + +create index ix_survey_group_categoryobjectid on survey_group (categoryobjectid); +alter table survey_group add constraint fk_survey_group_categoryobjectid foreign key (categoryobjectid) references category (id) on delete restrict on update restrict; + +create index ix_hx_link_doc_hx_link on hx_link_doc (hx_link_id); +alter table hx_link_doc add constraint fk_hx_link_doc_hx_link foreign key (hx_link_id) references hx_link (id) on delete restrict on update restrict; + +create index ix_hx_link_doc_he_doc on hx_link_doc (he_doc_id); +alter table hx_link_doc add constraint fk_hx_link_doc_he_doc foreign key (he_doc_id) references he_doc (id) on delete restrict on update restrict; + +create index ix_hi_link_doc_hi_link on hi_link_doc (hi_link_id); +alter table hi_link_doc add constraint fk_hi_link_doc_hi_link foreign key (hi_link_id) references hi_link (id) on delete restrict on update restrict; + +create index ix_hi_link_doc_hi_doc on hi_link_doc (hi_doc_id); +alter table hi_link_doc add constraint fk_hi_link_doc_hi_doc foreign key (hi_doc_id) references hi_doc (id) on delete restrict on update restrict; + +create index ix_hi_tthree_hi_ttwo_id on hi_tthree (hi_ttwo_id); +alter table hi_tthree add constraint fk_hi_tthree_hi_ttwo_id foreign key (hi_ttwo_id) references hi_ttwo (id) on delete restrict on update restrict; + +create index ix_hi_ttwo_hi_tone_id on hi_ttwo (hi_tone_id); +alter table hi_ttwo add constraint fk_hi_ttwo_hi_tone_id foreign key (hi_tone_id) references hi_tone (id) on delete restrict on update restrict; + +alter table hsd_setting add constraint fk_hsd_setting_user_id foreign key (user_id) references hsd_user (id) on delete restrict on update restrict; + +create index ix_iaf_segment_status_id on iaf_segment (status_id); +alter table iaf_segment add constraint fk_iaf_segment_status_id foreign key (status_id) references iaf_segment_status (id) on delete restrict on update restrict; + +create index ix_imrelated_owner_id on imrelated (owner_id); +alter table imrelated add constraint fk_imrelated_owner_id foreign key (owner_id) references imroot (id) on delete restrict on update restrict; + +create index ix_info_contact_company_id on info_contact (company_id); +alter table info_contact add constraint fk_info_contact_company_id foreign key (company_id) references info_company (id) on delete restrict on update restrict; + +alter table info_customer add constraint fk_info_customer_company_id foreign key (company_id) references info_company (id) on delete restrict on update restrict; + +alter table inner_report add constraint fk_inner_report_forecast_id foreign key (forecast_id) references stockforecast (id) on delete restrict on update restrict; + +create index ix_drel_invoice_booking on drel_invoice (booking); +alter table drel_invoice add constraint fk_drel_invoice_booking foreign key (booking) references drel_booking (id) on delete restrict on update restrict; + +create index ix_item_etype on item (customer,type); +alter table item add constraint fk_item_etype foreign key (customer,type) references `type` (customer,type) on delete restrict on update restrict; + +create index ix_item_eregion on item (customer,region); +alter table item add constraint fk_item_eregion foreign key (customer,region) references region (customer,type) on delete restrict on update restrict; + +alter table mkeygroup_monkey add constraint fk_mkeygroup_monkey_mkeygroup foreign key (mkeygroup_pid) references mkeygroup (pid) on delete restrict on update restrict; + +alter table mkeygroup_monkey add constraint fk_mkeygroup_monkey_monkey foreign key (monkey_mid) references monkey (mid) on delete restrict on update restrict; + +alter table trainer_monkey add constraint fk_trainer_monkey_trainer foreign key (trainer_tid) references trainer (tid) on delete restrict on update restrict; + +alter table trainer_monkey add constraint fk_trainer_monkey_monkey foreign key (monkey_mid) references monkey (mid) on delete restrict on update restrict; + +alter table troop_monkey add constraint fk_troop_monkey_troop foreign key (troop_pid) references troop (pid) on delete restrict on update restrict; + +alter table troop_monkey add constraint fk_troop_monkey_monkey foreign key (monkey_mid) references monkey (mid) on delete restrict on update restrict; + +create index ix_l2_cldf_reset_bean_child_parent_id on l2_cldf_reset_bean_child (parent_id); +alter table l2_cldf_reset_bean_child add constraint fk_l2_cldf_reset_bean_child_parent_id foreign key (parent_id) references l2_cldf_reset_bean (id) on delete restrict on update restrict; + +create index ix_level1_level4_level1 on level1_level4 (level1_id); +alter table level1_level4 add constraint fk_level1_level4_level1 foreign key (level1_id) references level1 (id) on delete restrict on update restrict; + +create index ix_level1_level4_level4 on level1_level4 (level4_id); +alter table level1_level4 add constraint fk_level1_level4_level4 foreign key (level4_id) references level4 (id) on delete restrict on update restrict; + +create index ix_level1_level2_level1 on level1_level2 (level1_id); +alter table level1_level2 add constraint fk_level1_level2_level1 foreign key (level1_id) references level1 (id) on delete restrict on update restrict; + +create index ix_level1_level2_level2 on level1_level2 (level2_id); +alter table level1_level2 add constraint fk_level1_level2_level2 foreign key (level2_id) references level2 (id) on delete restrict on update restrict; + +create index ix_level2_level3_level2 on level2_level3 (level2_id); +alter table level2_level3 add constraint fk_level2_level3_level2 foreign key (level2_id) references level2 (id) on delete restrict on update restrict; + +create index ix_level2_level3_level3 on level2_level3 (level3_id); +alter table level2_level3 add constraint fk_level2_level3_level3 foreign key (level3_id) references level3 (id) on delete restrict on update restrict; + +alter table link add constraint fk_link_id foreign key (id) references link_draft (id) on delete restrict on update restrict; + +create index ix_la_attr_value_attribute_la_attr_value on la_attr_value_attribute (la_attr_value_id); +alter table la_attr_value_attribute add constraint fk_la_attr_value_attribute_la_attr_value foreign key (la_attr_value_id) references la_attr_value (id) on delete restrict on update restrict; + +create index ix_la_attr_value_attribute_attribute on la_attr_value_attribute (attribute_id); +alter table la_attr_value_attribute add constraint fk_la_attr_value_attribute_attribute foreign key (attribute_id) references attribute (id) on delete restrict on update restrict; + +create index ix_looney_tune_id on looney (tune_id); +alter table looney add constraint fk_looney_tune_id foreign key (tune_id) references tune (id) on delete restrict on update restrict; + +create index ix_mcontact_customer_id on mcontact (customer_id); +alter table mcontact add constraint fk_mcontact_customer_id foreign key (customer_id) references mcustomer (id) on delete restrict on update restrict; + +create index ix_mcontact_message_contact_id on mcontact_message (contact_id); +alter table mcontact_message add constraint fk_mcontact_message_contact_id foreign key (contact_id) references mcontact (id) on delete restrict on update restrict; + +create index ix_mcustomer_shipping_address_id on mcustomer (shipping_address_id); +alter table mcustomer add constraint fk_mcustomer_shipping_address_id foreign key (shipping_address_id) references maddress (id) on delete restrict on update restrict; + +create index ix_mcustomer_billing_address_id on mcustomer (billing_address_id); +alter table mcustomer add constraint fk_mcustomer_billing_address_id foreign key (billing_address_id) references maddress (id) on delete restrict on update restrict; + +create index ix_mmachine_mgroup_mmachine on mmachine_mgroup (mmachine_id); +alter table mmachine_mgroup add constraint fk_mmachine_mgroup_mmachine foreign key (mmachine_id) references mmachine (id) on delete restrict on update restrict; + +create index ix_mmachine_mgroup_mgroup on mmachine_mgroup (mgroup_id); +alter table mmachine_mgroup add constraint fk_mmachine_mgroup_mgroup foreign key (mgroup_id) references mgroup (id) on delete restrict on update restrict; + +create index ix_mprinter_current_state_id on mprinter (current_state_id); +alter table mprinter add constraint fk_mprinter_current_state_id foreign key (current_state_id) references mprinter_state (id) on delete restrict on update restrict; + +alter table mprinter add constraint fk_mprinter_last_swap_cyan_id foreign key (last_swap_cyan_id) references mprinter_state (id) on delete restrict on update restrict; + +alter table mprinter add constraint fk_mprinter_last_swap_magenta_id foreign key (last_swap_magenta_id) references mprinter_state (id) on delete restrict on update restrict; + +alter table mprinter add constraint fk_mprinter_last_swap_yellow_id foreign key (last_swap_yellow_id) references mprinter_state (id) on delete restrict on update restrict; + +alter table mprinter add constraint fk_mprinter_last_swap_black_id foreign key (last_swap_black_id) references mprinter_state (id) on delete restrict on update restrict; + +create index ix_mprinter_state_printer_id on mprinter_state (printer_id); +alter table mprinter_state add constraint fk_mprinter_state_printer_id foreign key (printer_id) references mprinter (id) on delete restrict on update restrict; + +create index ix_mprofile_picture_id on mprofile (picture_id); +alter table mprofile add constraint fk_mprofile_picture_id foreign key (picture_id) references mmedia (id) on delete restrict on update restrict; + +create index ix_mrole_muser_mrole on mrole_muser (mrole_roleid); +alter table mrole_muser add constraint fk_mrole_muser_mrole foreign key (mrole_roleid) references mrole (roleid) on delete restrict on update restrict; + +create index ix_mrole_muser_muser on mrole_muser (muser_userid); +alter table mrole_muser add constraint fk_mrole_muser_muser foreign key (muser_userid) references muser (userid) on delete restrict on update restrict; + +create index ix_muser_user_type_id on muser (user_type_id); +alter table muser add constraint fk_muser_user_type_id foreign key (user_type_id) references muser_type (id) on delete restrict on update restrict; + +create index ix_mail_user_inbox_mail_user on mail_user_inbox (mail_user_id); +alter table mail_user_inbox add constraint fk_mail_user_inbox_mail_user foreign key (mail_user_id) references mail_user (id) on delete restrict on update restrict; + +create index ix_mail_user_inbox_mail_box on mail_user_inbox (mail_box_id); +alter table mail_user_inbox add constraint fk_mail_user_inbox_mail_box foreign key (mail_box_id) references mail_box (id) on delete restrict on update restrict; + +create index ix_mail_user_outbox_mail_user on mail_user_outbox (mail_user_id); +alter table mail_user_outbox add constraint fk_mail_user_outbox_mail_user foreign key (mail_user_id) references mail_user (id) on delete restrict on update restrict; + +create index ix_mail_user_outbox_mail_box on mail_user_outbox (mail_box_id); +alter table mail_user_outbox add constraint fk_mail_user_outbox_mail_box foreign key (mail_box_id) references mail_box (id) on delete restrict on update restrict; + +create index ix_c_message_conversation_id on c_message (conversation_id); +alter table c_message add constraint fk_c_message_conversation_id foreign key (conversation_id) references c_conversation (id) on delete restrict on update restrict; + +create index ix_c_message_user_id on c_message (user_id); +alter table c_message add constraint fk_c_message_user_id foreign key (user_id) references c_user (id) on delete restrict on update restrict; + +alter table meter_contract_data add constraint fk_meter_contract_data_special_needs_client_id foreign key (special_needs_client_id) references meter_special_needs_client (id) on delete restrict on update restrict; + +alter table meter_special_needs_client add constraint fk_meter_special_needs_client_primary_id foreign key (primary_id) references meter_special_needs_contact (id) on delete restrict on update restrict; + +alter table meter_version add constraint fk_meter_version_address_data_id foreign key (address_data_id) references meter_address_data (id) on delete restrict on update restrict; + +alter table meter_version add constraint fk_meter_version_contract_data_id foreign key (contract_data_id) references meter_contract_data (id) on delete restrict on update restrict; + +create index ix_mnoc_user_mnoc_role_mnoc_user on mnoc_user_mnoc_role (mnoc_user_user_id); +alter table mnoc_user_mnoc_role add constraint fk_mnoc_user_mnoc_role_mnoc_user foreign key (mnoc_user_user_id) references mnoc_user (user_id) on delete restrict on update restrict; + +create index ix_mnoc_user_mnoc_role_mnoc_role on mnoc_user_mnoc_role (mnoc_role_role_id); +alter table mnoc_user_mnoc_role add constraint fk_mnoc_user_mnoc_role_mnoc_role foreign key (mnoc_role_role_id) references mnoc_role (role_id) on delete restrict on update restrict; + +create index ix_mny_b_a_id on mny_b (a_id); +alter table mny_b add constraint fk_mny_b_a_id foreign key (a_id) references mny_a (id) on delete restrict on update restrict; + +create index ix_mny_b_mny_c_mny_b on mny_b_mny_c (mny_b_id); +alter table mny_b_mny_c add constraint fk_mny_b_mny_c_mny_b foreign key (mny_b_id) references mny_b (id) on delete restrict on update restrict; + +create index ix_mny_b_mny_c_mny_c on mny_b_mny_c (mny_c_id); +alter table mny_b_mny_c add constraint fk_mny_b_mny_c_mny_c foreign key (mny_c_id) references mny_c (id) on delete restrict on update restrict; + +create index ix_subtopics_mny_topic_1 on subtopics (topic); +alter table subtopics add constraint fk_subtopics_mny_topic_1 foreign key (topic) references mny_topic (id) on delete restrict on update restrict; + +create index ix_subtopics_mny_topic_2 on subtopics (subtopic); +alter table subtopics add constraint fk_subtopics_mny_topic_2 foreign key (subtopic) references mny_topic (id) on delete restrict on update restrict; + +create index ix_mp_role_mp_user_id on mp_role (mp_user_id); +alter table mp_role add constraint fk_mp_role_mp_user_id foreign key (mp_user_id) references mp_user (id) on delete restrict on update restrict; + +create index ix_ms_many_a_many_b_ms_many_a on ms_many_a_many_b (ms_many_a_aid); +alter table ms_many_a_many_b add constraint fk_ms_many_a_many_b_ms_many_a foreign key (ms_many_a_aid) references ms_many_a (aid) on delete restrict on update restrict; + +create index ix_ms_many_a_many_b_ms_many_b on ms_many_a_many_b (ms_many_b_bid); +alter table ms_many_a_many_b add constraint fk_ms_many_a_many_b_ms_many_b foreign key (ms_many_b_bid) references ms_many_b (bid) on delete restrict on update restrict; + +create index ix_ms_many_b_many_a_ms_many_b on ms_many_b_many_a (ms_many_b_bid); +alter table ms_many_b_many_a add constraint fk_ms_many_b_many_a_ms_many_b foreign key (ms_many_b_bid) references ms_many_b (bid) on delete restrict on update restrict; + +create index ix_ms_many_b_many_a_ms_many_a on ms_many_b_many_a (ms_many_a_aid); +alter table ms_many_b_many_a add constraint fk_ms_many_b_many_a_ms_many_a foreign key (ms_many_a_aid) references ms_many_a (aid) on delete restrict on update restrict; + +create index ix_my_lob_size_join_many_parent_id on my_lob_size_join_many (parent_id); +alter table my_lob_size_join_many add constraint fk_my_lob_size_join_many_parent_id foreign key (parent_id) references my_lob_size (id) on delete restrict on update restrict; + +create index ix_o_bean_child_cached_bean_id on o_bean_child (cached_bean_id); +alter table o_bean_child add constraint fk_o_bean_child_cached_bean_id foreign key (cached_bean_id) references o_cached_bean (id) on delete restrict on update restrict; + +create index ix_ocached_app_detail_app_id on ocached_app_detail (app_id); +alter table ocached_app_detail add constraint fk_ocached_app_detail_app_id foreign key (app_id) references ocached_app (id) on delete restrict on update restrict; + +create index ix_o_cached_bean_country_o_cached_bean on o_cached_bean_country (o_cached_bean_id); +alter table o_cached_bean_country add constraint fk_o_cached_bean_country_o_cached_bean foreign key (o_cached_bean_id) references o_cached_bean (id) on delete restrict on update restrict; + +create index ix_o_cached_bean_country_o_country on o_cached_bean_country (o_country_code); +alter table o_cached_bean_country add constraint fk_o_cached_bean_country_o_country foreign key (o_country_code) references o_country (code) on delete restrict on update restrict; + +create index ix_o_cached_bean_child_cached_bean_id on o_cached_bean_child (cached_bean_id); +alter table o_cached_bean_child add constraint fk_o_cached_bean_child_cached_bean_id foreign key (cached_bean_id) references o_cached_bean (id) on delete restrict on update restrict; + +alter table oengine add constraint fk_oengine_car_id foreign key (car_id) references ocar (id) on delete restrict on update restrict; + +alter table ogear_box add constraint fk_ogear_box_car_id foreign key (car_id) references ocar (id) on delete restrict on update restrict; + +create index ix_omvertex_other_omvertex_id on omvertex_other (omvertex_id); +alter table omvertex_other add constraint fk_omvertex_other_omvertex_id foreign key (omvertex_id) references omvertex (id) on delete restrict on update restrict; + +alter table oroad_show_msg add constraint fk_oroad_show_msg_company_id foreign key (company_id) references ocompany (id) on delete restrict on update restrict; + +create index ix_om_account_child_dbo_banana_rama_id on om_account_child_dbo (banana_rama_id); +alter table om_account_child_dbo add constraint fk_om_account_child_dbo_banana_rama_id foreign key (banana_rama_id) references om_account_dbo (id) on delete restrict on update restrict; + +create index ix_om_basic_child_parent_id on om_basic_child (parent_id); +alter table om_basic_child add constraint fk_om_basic_child_parent_id foreign key (parent_id) references om_basic_parent (id) on delete restrict on update restrict; + +create index ix_om_ordered_detail_master_id on om_ordered_detail (master_id); +alter table om_ordered_detail add constraint fk_om_ordered_detail_master_id foreign key (master_id) references om_ordered_master (id) on delete restrict on update restrict; + +create index ix_o_order_kcustomer_id on o_order (kcustomer_id); +alter table o_order add constraint fk_o_order_kcustomer_id foreign key (kcustomer_id) references o_customer (id) on delete restrict on update restrict; + +create index ix_o_order_detail_order_id on o_order_detail (order_id); +alter table o_order_detail add constraint fk_o_order_detail_order_id foreign key (order_id) references o_order (id) on delete restrict on update restrict; + +create index ix_o_order_detail_product_id on o_order_detail (product_id); +alter table o_order_detail add constraint fk_o_order_detail_product_id foreign key (product_id) references o_product (id) on delete restrict on update restrict; + +create index ix_s_order_items_order_uuid on s_order_items (order_uuid); +alter table s_order_items add constraint fk_s_order_items_order_uuid foreign key (order_uuid) references s_orders (uuid) on delete restrict on update restrict; + +create index ix_order_referenced_parent_master_id on order_referenced_parent (master_id); +alter table order_referenced_parent add constraint fk_order_referenced_parent_master_id foreign key (master_id) references order_master (id) on delete restrict on update restrict; + +create index ix_or_order_ship_order_id on or_order_ship (order_id); +alter table or_order_ship add constraint fk_or_order_ship_order_id foreign key (order_id) references o_order (id) on delete restrict on update restrict; + +create index ix_order_toy_child_id on order_toy (child_id); +alter table order_toy add constraint fk_order_toy_child_id foreign key (child_id) references order_referenced_parent (id) on delete restrict on update restrict; + +create index ix_ordered_parent_order_master_inheritance_id on ordered_parent (order_master_inheritance_id); +alter table ordered_parent add constraint fk_ordered_parent_order_master_inheritance_id foreign key (order_master_inheritance_id) references order_master_inheritance (id) on delete restrict on update restrict; + +alter table organization_node add constraint fk_organization_node_parent_tree_node_id foreign key (parent_tree_node_id) references organization_tree_node (id) on delete restrict on update restrict; + +create index ix_orp_detail_master_id on orp_detail (master_id); +alter table orp_detail add constraint fk_orp_detail_master_id foreign key (master_id) references orp_master (id) on delete restrict on update restrict; + +create index ix_orp_detail2_orp_master2_id on orp_detail2 (orp_master2_id); +alter table orp_detail2 add constraint fk_orp_detail2_orp_master2_id foreign key (orp_master2_id) references orp_master2 (id) on delete restrict on update restrict; + +alter table oto_atwo add constraint fk_oto_atwo_aone_id foreign key (aone_id) references oto_aone (id) on delete restrict on update restrict; + +alter table oto_bchild add constraint fk_oto_bchild_master_id foreign key (master_id) references oto_bmaster (id) on delete restrict on update restrict; + +alter table oto_child add constraint fk_oto_child_master_id foreign key (master_id) references oto_master (id) on delete restrict on update restrict; + +alter table oto_cust_address add constraint fk_oto_cust_address_customer_cid foreign key (customer_cid) references oto_cust (cid) on delete restrict on update restrict; + +alter table oto_level_a add constraint fk_oto_level_a_b_id foreign key (b_id) references oto_level_b (id) on delete restrict on update restrict; + +alter table oto_level_b add constraint fk_oto_level_b_c_id foreign key (c_id) references oto_level_c (id) on delete restrict on update restrict; + +alter table oto_prime_extra add constraint fk_oto_prime_extra_eid foreign key (eid) references oto_prime (pid) on delete restrict on update restrict; + +alter table oto_sd_child add constraint fk_oto_sd_child_master_id foreign key (master_id) references oto_sd_master (id) on delete restrict on update restrict; + +create index ix_oto_th_many_oto_th_top_id on oto_th_many (oto_th_top_id); +alter table oto_th_many add constraint fk_oto_th_many_oto_th_top_id foreign key (oto_th_top_id) references oto_th_top (id) on delete restrict on update restrict; + +alter table oto_th_one add constraint fk_oto_th_one_many_id foreign key (many_id) references oto_th_many (id) on delete restrict on update restrict; + +alter table oto_ubprime_extra add constraint fk_oto_ubprime_extra_eid foreign key (eid) references oto_ubprime (pid) on delete restrict on update restrict; + +alter table oto_user_model add constraint fk_oto_user_model_user_optional_id foreign key (user_optional_id) references oto_user_model_optional (id) on delete restrict on update restrict; + +alter table pfile add constraint fk_pfile_file_content_id foreign key (file_content_id) references pfile_content (id) on delete restrict on update restrict; + +alter table pfile add constraint fk_pfile_file_content2_id foreign key (file_content2_id) references pfile_content (id) on delete restrict on update restrict; + +alter table paggview add constraint fk_paggview_pview_id foreign key (pview_id) references pp (id) on delete restrict on update restrict; + +create index ix_pallet_location_zone_sid on pallet_location (zone_sid); +alter table pallet_location add constraint fk_pallet_location_zone_sid foreign key (zone_sid) references zones (id) on delete restrict on update restrict; + +alter table parcel_location add constraint fk_parcel_location_parcelid foreign key (parcelid) references parcel (parcelid) on delete restrict on update restrict; + +create index ix_rawinherit_parent_rawinherit_data_rawinherit_parent on rawinherit_parent_rawinherit_data (rawinherit_parent_id); +alter table rawinherit_parent_rawinherit_data add constraint fk_rawinherit_parent_rawinherit_data_rawinherit_parent foreign key (rawinherit_parent_id) references rawinherit_parent (id) on delete restrict on update restrict; + +create index ix_rawinherit_parent_rawinherit_data_rawinherit_data on rawinherit_parent_rawinherit_data (rawinherit_data_id); +alter table rawinherit_parent_rawinherit_data add constraint fk_rawinherit_parent_rawinherit_data_rawinherit_data foreign key (rawinherit_data_id) references rawinherit_data (id) on delete restrict on update restrict; + +create index ix_parent_person_some_bean_id on parent_person (some_bean_id); +alter table parent_person add constraint fk_parent_person_some_bean_id foreign key (some_bean_id) references e_basic (id) on delete restrict on update restrict; + +create index ix_parent_person_parent_identifier on parent_person (parent_identifier); +alter table parent_person add constraint fk_parent_person_parent_identifier foreign key (parent_identifier) references grand_parent_person (identifier) on delete restrict on update restrict; + +create index ix_c_participation_conversation_id on c_participation (conversation_id); +alter table c_participation add constraint fk_c_participation_conversation_id foreign key (conversation_id) references c_conversation (id) on delete restrict on update restrict; + +create index ix_c_participation_user_id on c_participation (user_id); +alter table c_participation add constraint fk_c_participation_user_id foreign key (user_id) references c_user (id) on delete restrict on update restrict; + +create index ix_pcf_calendar_pcf_person_id on pcf_calendar (pcf_person_id); +alter table pcf_calendar add constraint fk_pcf_calendar_pcf_person_id foreign key (pcf_person_id) references pcf_person (id) on delete restrict on update restrict; + +create index ix_pcf_city_pcf_country_id on pcf_city (pcf_country_id); +alter table pcf_city add constraint fk_pcf_city_pcf_country_id foreign key (pcf_country_id) references pcf_country (id) on delete restrict on update restrict; + +alter table pcf_city add constraint fk_pcf_city_mayor_id foreign key (mayor_id) references pcf_person (id) on delete restrict on update restrict; + +alter table pcf_city add constraint fk_pcf_city_vice_mayor_id foreign key (vice_mayor_id) references pcf_person (id) on delete restrict on update restrict; + +create index ix_pcf_event_pcf_calendar_id on pcf_event (pcf_calendar_id); +alter table pcf_event add constraint fk_pcf_event_pcf_calendar_id foreign key (pcf_calendar_id) references pcf_calendar (id) on delete restrict on update restrict; + +alter table persistent_file_content add constraint fk_persistent_file_content_persistent_file_id foreign key (persistent_file_id) references persistent_file (id) on delete restrict on update restrict; + +create index ix_person_default_address_oid on person (default_address_oid); +alter table person add constraint fk_person_default_address_oid foreign key (default_address_oid) references address (oid) on delete restrict on update restrict; + +create index ix_person_cache_email_person_info_person_id on person_cache_email (person_info_person_id); +alter table person_cache_email add constraint fk_person_cache_email_person_info_person_id foreign key (person_info_person_id) references person_cache_info (person_id) on delete restrict on update restrict; + +create index ix_phones_person_id on phones (person_id); +alter table phones add constraint fk_phones_person_id foreign key (person_id) references persons (id) on delete restrict on update restrict; + +create index ix_e_position_contract_id on e_position (contract_id); +alter table e_position add constraint fk_e_position_contract_id foreign key (contract_id) references contract (id) on delete restrict on update restrict; + +create index ix_pp_to_ww_pp on pp_to_ww (pp_id); +alter table pp_to_ww add constraint fk_pp_to_ww_pp foreign key (pp_id) references pp (id) on delete restrict on update restrict; + +create index ix_pp_to_ww_wview on pp_to_ww (ww_id); +alter table pp_to_ww add constraint fk_pp_to_ww_wview foreign key (ww_id) references wview (id) on delete restrict on update restrict; + +create index ix_question_groupobjectid on question (groupobjectid); +alter table question add constraint fk_question_groupobjectid foreign key (groupobjectid) references survey_group (id) on delete restrict on update restrict; + +create index ix_r_orders_customer on r_orders (company,customername); +alter table r_orders add constraint fk_r_orders_customer foreign key (company,customername) references rcustomer (company,name) on delete restrict on update restrict; + +alter table referenced_defaults_model add constraint fk_referenced_defaults_model_id foreign key (id) references referenced_defaults_model_draft (id) on delete restrict on update restrict; + +create index ix_referenced_defaults_model_defaults_model_id on referenced_defaults_model (defaults_model_id); +alter table referenced_defaults_model add constraint fk_referenced_defaults_model_defaults_model_id foreign key (defaults_model_id) references defaults_model (id) on delete restrict on update restrict; + +create index ix_referenced_defaults_model_draft_defaults_model_id on referenced_defaults_model_draft (defaults_model_id); +alter table referenced_defaults_model_draft add constraint fk_referenced_defaults_model_draft_defaults_model_id foreign key (defaults_model_id) references defaults_model_draft (id) on delete restrict on update restrict; + +create index ix_rel_master_detail_id on rel_master (detail_id); +alter table rel_master add constraint fk_rel_master_detail_id foreign key (detail_id) references rel_detail (id) on delete restrict on update restrict; + +create index ix_resourcefile_parentresourcefileid on resourcefile (parentresourcefileid); +alter table resourcefile add constraint fk_resourcefile_parentresourcefileid foreign key (parentresourcefileid) references resourcefile (id) on delete restrict on update restrict; + +create index ix_mt_role_tenant_id on mt_role (tenant_id); +alter table mt_role add constraint fk_mt_role_tenant_id foreign key (tenant_id) references mt_tenant (id) on delete restrict on update restrict; + +create index ix_mt_role_permission_mt_role on mt_role_permission (mt_role_id); +alter table mt_role_permission add constraint fk_mt_role_permission_mt_role foreign key (mt_role_id) references mt_role (id) on delete restrict on update restrict; + +create index ix_mt_role_permission_mt_permission on mt_role_permission (mt_permission_id); +alter table mt_role_permission add constraint fk_mt_role_permission_mt_permission foreign key (mt_permission_id) references mt_permission (id) on delete restrict on update restrict; + +create index ix_root_bean_referencing_bean_id on root_bean (referencing_bean_id); +alter table root_bean add constraint fk_root_bean_referencing_bean_id foreign key (referencing_bean_id) references referencing_bean (id) on delete restrict on update restrict; + +alter table f_second add constraint fk_f_second_first foreign key (first) references f_first (id) on delete restrict on update restrict; + +create index ix_section_article_id on section (article_id); +alter table section add constraint fk_section_article_id foreign key (article_id) references article (id) on delete restrict on update restrict; + +create index ix_self_parent_parent_id on self_parent (parent_id); +alter table self_parent add constraint fk_self_parent_parent_id foreign key (parent_id) references self_parent (id) on delete restrict on update restrict; + +create index ix_self_ref_customer_referred_by_id on self_ref_customer (referred_by_id); +alter table self_ref_customer add constraint fk_self_ref_customer_referred_by_id foreign key (referred_by_id) references self_ref_customer (id) on delete restrict on update restrict; + +create index ix_self_ref_example_parent_id on self_ref_example (parent_id); +alter table self_ref_example add constraint fk_self_ref_example_parent_id foreign key (parent_id) references self_ref_example (id) on delete restrict on update restrict; + +alter table e_save_test_b add constraint fk_e_save_test_b_sibling_a_id foreign key (sibling_a_id) references e_save_test_a (id) on delete restrict on update restrict; + +create index ix_site_parent_id on site (parent_id); +alter table site add constraint fk_site_parent_id foreign key (parent_id) references site (id) on delete restrict on update restrict; + +alter table site add constraint fk_site_data_container_id foreign key (data_container_id) references data_container (id) on delete restrict on update restrict; + +alter table site add constraint fk_site_site_address_id foreign key (site_address_id) references site_address (id) on delete restrict on update restrict; + +create index ix_source_base_target_id on source_base (target_id); +alter table source_base add constraint fk_source_base_target_id foreign key (target_id) references target_base (id) on delete restrict on update restrict; + +create index ix_stockforecast_inner_report_id on stockforecast (inner_report_id); +alter table stockforecast add constraint fk_stockforecast_inner_report_id foreign key (inner_report_id) references inner_report (id) on delete restrict on update restrict; + +create index ix_sub_section_section_id on sub_section (section_id); +alter table sub_section add constraint fk_sub_section_section_id foreign key (section_id) references section (id) on delete restrict on update restrict; + +create index ix_tevent_many_event_id on tevent_many (event_id); +alter table tevent_many add constraint fk_tevent_many_event_id foreign key (event_id) references tevent_one (id) on delete restrict on update restrict; + +alter table tevent_one add constraint fk_tevent_one_event_id foreign key (event_id) references tevent (id) on delete restrict on update restrict; + +create index ix_t_detail_with_other_namexxxyy_master_id on t_detail_with_other_namexxxyy (master_id); +alter table t_detail_with_other_namexxxyy add constraint fk_t_detail_with_other_namexxxyy_master_id foreign key (master_id) references t_atable_thatisrelatively (id) on delete restrict on update restrict; + +create index ix_ttruck_holder_truck_plate_no on ttruck_holder (truck_plate_no); +alter table ttruck_holder add constraint fk_ttruck_holder_truck_plate_no foreign key (truck_plate_no) references tcar (plate_no) on delete restrict on update restrict; + +create index ix_ttruck_holder_basic_id on ttruck_holder (basic_id); +alter table ttruck_holder add constraint fk_ttruck_holder_basic_id foreign key (basic_id) references e_basic (id) on delete restrict on update restrict; + +create index ix_ttruck_holder_item_owner_id on ttruck_holder_item (owner_id); +alter table ttruck_holder_item add constraint fk_ttruck_holder_item_owner_id foreign key (owner_id) references ttruck_holder (id) on delete restrict on update restrict; + +create index ix_twheel_owner_plate_no on twheel (owner_plate_no); +alter table twheel add constraint fk_twheel_owner_plate_no foreign key (owner_plate_no) references tcar (plate_no) on delete restrict on update restrict; + +alter table tire add constraint fk_tire_wheel foreign key (wheel) references wheel (id) on delete restrict on update restrict; + +create index ix_tree_entity_parent_id on tree_entity (parent_id); +alter table tree_entity add constraint fk_tree_entity_parent_id foreign key (parent_id) references tree_entity (id) on delete restrict on update restrict; + +create index ix_trip_vehicle_driver_id on trip (vehicle_driver_id); +alter table trip add constraint fk_trip_vehicle_driver_id foreign key (vehicle_driver_id) references vehicle_driver (id) on delete restrict on update restrict; + +create index ix_trip_address_id on trip (address_id); +alter table trip add constraint fk_trip_address_id foreign key (address_id) references o_address (id) on delete restrict on update restrict; + +create index ix_type_sub_type_id on `type` (sub_type_id); +alter table `type` add constraint fk_type_sub_type_id foreign key (sub_type_id) references sub_type (sub_type_id) on delete restrict on update restrict; + +create index ix_usib_child_parent_id on usib_child (parent_id); +alter table usib_child add constraint fk_usib_child_parent_id foreign key (parent_id) references usib_parent (id) on delete restrict on update restrict; + +alter table usib_child_sibling add constraint fk_usib_child_sibling_child_id foreign key (child_id) references usib_child (id) on delete restrict on update restrict; + +create index ix_ut_detail_utmaster_id on ut_detail (utmaster_id); +alter table ut_detail add constraint fk_ut_detail_utmaster_id foreign key (utmaster_id) references ut_master (id) on delete restrict on update restrict; + +create index ix_uutwo_master_id on uutwo (master_id); +alter table uutwo add constraint fk_uutwo_master_id foreign key (master_id) references uuone (id) on delete restrict on update restrict; + +alter table oto_user add constraint fk_oto_user_account_id foreign key (account_id) references oto_account (id) on delete restrict on update restrict; + +create index ix_c_user_group_id on c_user (group_id); +alter table c_user add constraint fk_c_user_group_id foreign key (group_id) references c_group (id) on delete restrict on update restrict; + +create index ix_em_user_role_user_id on em_user_role (user_id); +alter table em_user_role add constraint fk_em_user_role_user_id foreign key (user_id) references em_user (id) on delete restrict on update restrict; + +create index ix_em_user_role_role_id on em_user_role (role_id); +alter table em_user_role add constraint fk_em_user_role_role_id foreign key (role_id) references em_role (id) on delete restrict on update restrict; + +create index ix_vehicle_lease_id on vehicle (lease_id); +alter table vehicle add constraint fk_vehicle_lease_id foreign key (lease_id) references vehicle_lease (id) on delete restrict on update restrict; + +create index ix_vehicle_car_ref_id on vehicle (car_ref_id); +alter table vehicle add constraint fk_vehicle_car_ref_id foreign key (car_ref_id) references truck_ref (id) on delete restrict on update restrict; + +create index ix_vehicle_truck_ref_id on vehicle (truck_ref_id); +alter table vehicle add constraint fk_vehicle_truck_ref_id foreign key (truck_ref_id) references truck_ref (id) on delete restrict on update restrict; + +create index ix_vehicle_driver_vehicle_id on vehicle_driver (vehicle_id); +alter table vehicle_driver add constraint fk_vehicle_driver_vehicle_id foreign key (vehicle_id) references vehicle (id) on delete restrict on update restrict; + +create index ix_vehicle_driver_address_id on vehicle_driver (address_id); +alter table vehicle_driver add constraint fk_vehicle_driver_address_id foreign key (address_id) references o_address (id) on delete restrict on update restrict; + +create index ix_version_child_parent_id on version_child (parent_id); +alter table version_child add constraint fk_version_child_parent_id foreign key (parent_id) references version_parent (id) on delete restrict on update restrict; + +create index ix_version_toy_child_id on version_toy (child_id); +alter table version_toy add constraint fk_version_toy_child_id foreign key (child_id) references version_child (id) on delete restrict on update restrict; + +create index ix_warehouses_officezoneid on warehouses (officezoneid); +alter table warehouses add constraint fk_warehouses_officezoneid foreign key (officezoneid) references zones (id) on delete restrict on update restrict; + +create index ix_warehousesshippingzones_warehouses on warehousesshippingzones (warehouseid); +alter table warehousesshippingzones add constraint fk_warehousesshippingzones_warehouses foreign key (warehouseid) references warehouses (id) on delete restrict on update restrict; + +create index ix_warehousesshippingzones_zones on warehousesshippingzones (shippingzoneid); +alter table warehousesshippingzones add constraint fk_warehousesshippingzones_zones foreign key (shippingzoneid) references zones (id) on delete restrict on update restrict; + +create index ix_sa_wheel_tire on sa_wheel (tire); +alter table sa_wheel add constraint fk_sa_wheel_tire foreign key (tire) references sa_tire (id) on delete restrict on update restrict; + +create index ix_sa_wheel_car on sa_wheel (car); +alter table sa_wheel add constraint fk_sa_wheel_car foreign key (car) references sa_car (id) on delete restrict on update restrict; + +create index ix_g_who_props_otm_who_created_id on g_who_props_otm (who_created_id); +alter table g_who_props_otm add constraint fk_g_who_props_otm_who_created_id foreign key (who_created_id) references g_user (id) on delete restrict on update restrict; + +create index ix_g_who_props_otm_who_modified_id on g_who_props_otm (who_modified_id); +alter table g_who_props_otm add constraint fk_g_who_props_otm_who_modified_id foreign key (who_modified_id) references g_user (id) on delete restrict on update restrict; + +create index ix_with_zero_parent_id on with_zero (parent_id); +alter table with_zero add constraint fk_with_zero_parent_id foreign key (parent_id) references parent (id) on delete restrict on update restrict; + +alter table hx_link add system versioning; +alter table hi_link add system versioning; +alter table hi_link_doc add system versioning; +alter table hi_tone add system versioning; +alter table hi_tthree add system versioning; +alter table hi_ttwo add system versioning; +alter table hsd_setting add system versioning; +alter table hsd_user add system versioning; +alter table link add system versioning; +alter table c_user add system versioning; diff --git a/ebean-core/src/test/ddl-review/mariadb-drop-all.sql b/ebean-core/src/test/ddl-review/mariadb-drop-all.sql new file mode 100644 index 000000000..15f89f02d --- /dev/null +++ b/ebean-core/src/test/ddl-review/mariadb-drop-all.sql @@ -0,0 +1,1868 @@ +-- Generated by ebean unknown at 2020-06-29T03:48:37.908711Z +alter table bar drop foreign key fk_bar_foo_id; +drop index ix_bar_foo_id on bar; + +alter table acl_container_relation drop foreign key fk_acl_container_relation_container_id; +drop index ix_acl_container_relation_container_id on acl_container_relation; + +alter table acl_container_relation drop foreign key fk_acl_container_relation_acl_entry_id; +drop index ix_acl_container_relation_acl_entry_id on acl_container_relation; + +alter table addr drop foreign key fk_addr_employee_id; +drop index ix_addr_employee_id on addr; + +alter table o_address drop foreign key fk_o_address_country_code; +drop index ix_o_address_country_code on o_address; + +alter table album drop foreign key fk_album_cover_id; + +alter table animal drop foreign key fk_animal_shelter_id; +drop index ix_animal_shelter_id on animal; + +alter table attribute drop foreign key fk_attribute_attribute_holder_id; +drop index ix_attribute_attribute_holder_id on attribute; + +alter table bbookmark drop foreign key fk_bbookmark_user_id; +drop index ix_bbookmark_user_id on bbookmark; + +alter table bbookmark_user drop foreign key fk_bbookmark_user_org_id; +drop index ix_bbookmark_user_org_id on bbookmark_user; + +alter table bsite_user_a drop foreign key fk_bsite_user_a_site_id; +drop index ix_bsite_user_a_site_id on bsite_user_a; + +alter table bsite_user_a drop foreign key fk_bsite_user_a_user_id; +drop index ix_bsite_user_a_user_id on bsite_user_a; + +alter table bsite_user_b drop foreign key fk_bsite_user_b_site; +drop index ix_bsite_user_b_site on bsite_user_b; + +alter table bsite_user_b drop foreign key fk_bsite_user_b_usr; +drop index ix_bsite_user_b_usr on bsite_user_b; + +alter table bsite_user_c drop foreign key fk_bsite_user_c_site_uid; +drop index ix_bsite_user_c_site_uid on bsite_user_c; + +alter table bsite_user_c drop foreign key fk_bsite_user_c_user_uid; +drop index ix_bsite_user_c_user_uid on bsite_user_c; + +alter table bsite_user_e drop foreign key fk_bsite_user_e_site_id; +drop index ix_bsite_user_e_site_id on bsite_user_e; + +alter table bsite_user_e drop foreign key fk_bsite_user_e_user_id; +drop index ix_bsite_user_e_user_id on bsite_user_e; + +alter table basic_draftable_bean drop foreign key fk_basic_draftable_bean_id; + +alter table drel_booking drop foreign key fk_drel_booking_agent_invoice; + +alter table drel_booking drop foreign key fk_drel_booking_client_invoice; + +alter table cepproduct_category drop foreign key fk_cepproduct_category_category_id; +drop index ix_cepproduct_category_category_id on cepproduct_category; + +alter table cepproduct_category drop foreign key fk_cepproduct_category_product_id; +drop index ix_cepproduct_category_product_id on cepproduct_category; + +alter table ciaddress drop foreign key fk_ciaddress_street_id; +drop index ix_ciaddress_street_id on ciaddress; + +alter table cicustomer_parent drop foreign key fk_cicustomer_parent_address_id; +drop index ix_cicustomer_parent_address_id on cicustomer_parent; + +alter table cinh_ref drop foreign key fk_cinh_ref_ref_id; +drop index ix_cinh_ref_ref_id on cinh_ref; + +alter table ckey_detail drop foreign key fk_ckey_detail_parent; +drop index ix_ckey_detail_parent on ckey_detail; + +alter table ckey_parent drop foreign key fk_ckey_parent_assoc_id; +drop index ix_ckey_parent_assoc_id on ckey_parent; + +alter table coone_many drop foreign key fk_coone_many_coone_id; +drop index ix_coone_many_coone_id on coone_many; + +alter table coroot drop foreign key fk_coroot_one_id; + +alter table calculation_result drop foreign key fk_calculation_result_product_configuration_id; +drop index ix_calculation_result_product_configuration_id on calculation_result; + +alter table calculation_result drop foreign key fk_calculation_result_group_configuration_id; +drop index ix_calculation_result_group_configuration_id on calculation_result; + +alter table sp_car_car_wheels drop foreign key fk_sp_car_car_wheels_sp_car_car; +drop index ix_sp_car_car_wheels_sp_car_car on sp_car_car_wheels; + +alter table sp_car_car_wheels drop foreign key fk_sp_car_car_wheels_sp_car_wheel; +drop index ix_sp_car_car_wheels_sp_car_wheel on sp_car_car_wheels; + +alter table sp_car_car_doors drop foreign key fk_sp_car_car_doors_sp_car_car; +drop index ix_sp_car_car_doors_sp_car_car on sp_car_car_doors; + +alter table sp_car_car_doors drop foreign key fk_sp_car_car_doors_sp_car_door; +drop index ix_sp_car_car_doors_sp_car_door on sp_car_car_doors; + +alter table car_accessory drop foreign key fk_car_accessory_fuse_id; +drop index ix_car_accessory_fuse_id on car_accessory; + +alter table car_accessory drop foreign key fk_car_accessory_car_id; +drop index ix_car_accessory_car_id on car_accessory; + +alter table category drop foreign key fk_category_surveyobjectid; +drop index ix_category_surveyobjectid on category; + +alter table e_save_test_d drop foreign key fk_e_save_test_d_parent_id; + +alter table child_person drop foreign key fk_child_person_some_bean_id; +drop index ix_child_person_some_bean_id on child_person; + +alter table child_person drop foreign key fk_child_person_parent_identifier; +drop index ix_child_person_parent_identifier on child_person; + +alter table cke_client drop foreign key fk_cke_client_user; +drop index ix_cke_client_user on cke_client; + +alter table class_super_monkey drop foreign key fk_class_super_monkey_class_super; + +alter table class_super_monkey drop foreign key fk_class_super_monkey_monkey; + +alter table configuration drop foreign key fk_configuration_configurations_id; +drop index ix_configuration_configurations_id on configuration; + +alter table contact drop foreign key fk_contact_customer_id; +drop index ix_contact_customer_id on contact; + +alter table contact drop foreign key fk_contact_group_id; +drop index ix_contact_group_id on contact; + +alter table contact_note drop foreign key fk_contact_note_contact_id; +drop index ix_contact_note_contact_id on contact_note; + +alter table contract_costs drop foreign key fk_contract_costs_position_id; +drop index ix_contract_costs_position_id on contract_costs; + +alter table c_conversation drop foreign key fk_c_conversation_group_id; +drop index ix_c_conversation_group_id on c_conversation; + +alter table o_customer drop foreign key fk_o_customer_billing_address_id; +drop index ix_o_customer_billing_address_id on o_customer; + +alter table o_customer drop foreign key fk_o_customer_shipping_address_id; +drop index ix_o_customer_shipping_address_id on o_customer; + +alter table dcredit_drol drop foreign key fk_dcredit_drol_dcredit; +drop index ix_dcredit_drol_dcredit on dcredit_drol; + +alter table dcredit_drol drop foreign key fk_dcredit_drol_drol; +drop index ix_dcredit_drol_drol on dcredit_drol; + +alter table dmachine drop foreign key fk_dmachine_organisation_id; +drop index ix_dmachine_organisation_id on dmachine; + +alter table d_machine_aux_use drop foreign key fk_d_machine_aux_use_machine_id; +drop index ix_d_machine_aux_use_machine_id on d_machine_aux_use; + +alter table d_machine_stats drop foreign key fk_d_machine_stats_machine_id; +drop index ix_d_machine_stats_machine_id on d_machine_stats; + +alter table d_machine_use drop foreign key fk_d_machine_use_machine_id; +drop index ix_d_machine_use_machine_id on d_machine_use; + +alter table drot_drol drop foreign key fk_drot_drol_drot; +drop index ix_drot_drol_drot on drot_drol; + +alter table drot_drol drop foreign key fk_drot_drol_drol; +drop index ix_drot_drol_drol on drot_drol; + +alter table dc_detail drop foreign key fk_dc_detail_master_id; +drop index ix_dc_detail_master_id on dc_detail; + +alter table defaults_model drop foreign key fk_defaults_model_id; + +alter table dfk_cascade drop foreign key fk_dfk_cascade_one_id; +drop index ix_dfk_cascade_one_id on dfk_cascade; + +alter table dfk_set_null drop foreign key fk_dfk_set_null_one_id; +drop index ix_dfk_set_null_one_id on dfk_set_null; + +alter table doc drop foreign key fk_doc_id; + +alter table doc_link drop foreign key fk_doc_link_doc; +drop index ix_doc_link_doc on doc_link; + +alter table doc_link drop foreign key fk_doc_link_link; +drop index ix_doc_link_link on doc_link; + +alter table document drop foreign key fk_document_id; + +alter table document drop foreign key fk_document_organisation_id; +drop index ix_document_organisation_id on document; + +alter table document_draft drop foreign key fk_document_draft_organisation_id; +drop index ix_document_draft_organisation_id on document_draft; + +alter table document_media drop foreign key fk_document_media_document_id; +drop index ix_document_media_document_id on document_media; + +alter table document_media_draft drop foreign key fk_document_media_draft_document_id; +drop index ix_document_media_draft_document_id on document_media_draft; + +alter table e_basicenc_relate drop foreign key fk_e_basicenc_relate_other_id; +drop index ix_e_basicenc_relate_other_id on e_basicenc_relate; + +alter table ebasic_json_map_detail drop foreign key fk_ebasic_json_map_detail_owner_id; +drop index ix_ebasic_json_map_detail_owner_id on ebasic_json_map_detail; + +alter table ebasic_no_sdchild drop foreign key fk_ebasic_no_sdchild_owner_id; +drop index ix_ebasic_no_sdchild_owner_id on ebasic_no_sdchild; + +alter table ebasic_sdchild drop foreign key fk_ebasic_sdchild_owner_id; +drop index ix_ebasic_sdchild_owner_id on ebasic_sdchild; + +alter table ecache_child drop foreign key fk_ecache_child_root_id; +drop index ix_ecache_child_root_id on ecache_child; + +alter table edefault_prop drop foreign key fk_edefault_prop_e_simple_usertypeid; + +alter table eemb_inner drop foreign key fk_eemb_inner_outer_id; +drop index ix_eemb_inner_outer_id on eemb_inner; + +alter table einvoice drop foreign key fk_einvoice_person_id; +drop index ix_einvoice_person_id on einvoice; + +alter table enull_collection_detail drop foreign key fk_enull_collection_detail_enull_collection_id; +drop index ix_enull_collection_detail_enull_collection_id on enull_collection_detail; + +alter table eopt_one_a drop foreign key fk_eopt_one_a_b_id; +drop index ix_eopt_one_a_b_id on eopt_one_a; + +alter table eopt_one_b drop foreign key fk_eopt_one_b_c_id; +drop index ix_eopt_one_b_c_id on eopt_one_b; + +alter table eper_addr drop foreign key fk_eper_addr_ma_country_code; +drop index ix_eper_addr_ma_country_code on eper_addr; + +alter table esoft_del_book drop foreign key fk_esoft_del_book_lend_by_id; +drop index ix_esoft_del_book_lend_by_id on esoft_del_book; + +alter table esoft_del_book_esoft_del_user drop foreign key fk_esoft_del_book_esoft_del_user_esoft_del_book; +drop index ix_esoft_del_book_esoft_del_user_esoft_del_book on esoft_del_book_esoft_del_user; + +alter table esoft_del_book_esoft_del_user drop foreign key fk_esoft_del_book_esoft_del_user_esoft_del_user; +drop index ix_esoft_del_book_esoft_del_user_esoft_del_user on esoft_del_book_esoft_del_user; + +alter table esoft_del_down drop foreign key fk_esoft_del_down_esoft_del_mid_id; +drop index ix_esoft_del_down_esoft_del_mid_id on esoft_del_down; + +alter table esoft_del_mid drop foreign key fk_esoft_del_mid_top_id; +drop index ix_esoft_del_mid_top_id on esoft_del_mid; + +alter table esoft_del_mid drop foreign key fk_esoft_del_mid_up_id; +drop index ix_esoft_del_mid_up_id on esoft_del_mid; + +alter table esoft_del_one_a drop foreign key fk_esoft_del_one_a_oneb_id; + +alter table esoft_del_role_esoft_del_user drop foreign key fk_esoft_del_role_esoft_del_user_esoft_del_role; +drop index ix_esoft_del_role_esoft_del_user_esoft_del_role on esoft_del_role_esoft_del_user; + +alter table esoft_del_role_esoft_del_user drop foreign key fk_esoft_del_role_esoft_del_user_esoft_del_user; +drop index ix_esoft_del_role_esoft_del_user_esoft_del_user on esoft_del_role_esoft_del_user; + +alter table esoft_del_user_esoft_del_role drop foreign key fk_esoft_del_user_esoft_del_role_esoft_del_user; +drop index ix_esoft_del_user_esoft_del_role_esoft_del_user on esoft_del_user_esoft_del_role; + +alter table esoft_del_user_esoft_del_role drop foreign key fk_esoft_del_user_esoft_del_role_esoft_del_role; +drop index ix_esoft_del_user_esoft_del_role_esoft_del_role on esoft_del_user_esoft_del_role; + +alter table rawinherit_uncle drop foreign key fk_rawinherit_uncle_parent_id; +drop index ix_rawinherit_uncle_parent_id on rawinherit_uncle; + +alter table evanilla_collection_detail drop foreign key fk_evanilla_collection_detail_evanilla_collection_id; +drop index ix_evanilla_collection_detail_evanilla_collection_id on evanilla_collection_detail; + +alter table ec_enum_person_tags drop foreign key fk_ec_enum_person_tags_ec_enum_person_id; +drop index ix_ec_enum_person_tags_ec_enum_person_id on ec_enum_person_tags; + +alter table ec_person_phone drop foreign key fk_ec_person_phone_owner_id; +drop index ix_ec_person_phone_owner_id on ec_person_phone; + +alter table ec_top drop foreign key fk_ec_top_person_id; +drop index ix_ec_top_person_id on ec_top; + +alter table ec_top_ecs_person drop foreign key fk_ec_top_ecs_person_ec_top; +drop index ix_ec_top_ecs_person_ec_top on ec_top_ecs_person; + +alter table ec_top_ecs_person drop foreign key fk_ec_top_ecs_person_ecs_person; +drop index ix_ec_top_ecs_person_ecs_person on ec_top_ecs_person; + +alter table ecbl_person_phone_numbers drop foreign key fk_ecbl_person_phone_numbers_person_id; +drop index ix_ecbl_person_phone_numbers_person_id on ecbl_person_phone_numbers; + +alter table ecbm_person_phone_numbers drop foreign key fk_ecbm_person_phone_numbers_person_id; +drop index ix_ecbm_person_phone_numbers_person_id on ecbm_person_phone_numbers; + +alter table ecm_person_phone_numbers drop foreign key fk_ecm_person_phone_numbers_ecm_person_id; +drop index ix_ecm_person_phone_numbers_ecm_person_id on ecm_person_phone_numbers; + +alter table ecmc_person_phone_numbers drop foreign key fk_ecmc_person_phone_numbers_ecmc_person_id; +drop index ix_ecmc_person_phone_numbers_ecmc_person_id on ecmc_person_phone_numbers; + +alter table ecs_person_phone drop foreign key fk_ecs_person_phone_ecs_person_id; +drop index ix_ecs_person_phone_ecs_person_id on ecs_person_phone; + +alter table ecsm_child drop foreign key fk_ecsm_child_ecsm_parent_id; +drop index ix_ecsm_child_ecsm_parent_id on ecsm_child; + +alter table td_child drop foreign key fk_td_child_parent_id; +drop index ix_td_child_parent_id on td_child; + +alter table element_bean drop foreign key fk_element_bean_complex_bean_id; +drop index ix_element_bean_complex_bean_id on element_bean; + +alter table empl drop foreign key fk_empl_default_address_id; +drop index ix_empl_default_address_id on empl; + +alter table esd_detail drop foreign key fk_esd_detail_master_id; +drop index ix_esd_detail_master_id on esd_detail; + +alter table grand_parent_person drop foreign key fk_grand_parent_person_some_bean_id; +drop index ix_grand_parent_person_some_bean_id on grand_parent_person; + +alter table survey_group drop foreign key fk_survey_group_categoryobjectid; +drop index ix_survey_group_categoryobjectid on survey_group; + +alter table hx_link_doc drop foreign key fk_hx_link_doc_hx_link; +drop index ix_hx_link_doc_hx_link on hx_link_doc; + +alter table hx_link_doc drop foreign key fk_hx_link_doc_he_doc; +drop index ix_hx_link_doc_he_doc on hx_link_doc; + +alter table hi_link_doc drop foreign key fk_hi_link_doc_hi_link; +drop index ix_hi_link_doc_hi_link on hi_link_doc; + +alter table hi_link_doc drop foreign key fk_hi_link_doc_hi_doc; +drop index ix_hi_link_doc_hi_doc on hi_link_doc; + +alter table hi_tthree drop foreign key fk_hi_tthree_hi_ttwo_id; +drop index ix_hi_tthree_hi_ttwo_id on hi_tthree; + +alter table hi_ttwo drop foreign key fk_hi_ttwo_hi_tone_id; +drop index ix_hi_ttwo_hi_tone_id on hi_ttwo; + +alter table hsd_setting drop foreign key fk_hsd_setting_user_id; + +alter table iaf_segment drop foreign key fk_iaf_segment_status_id; +drop index ix_iaf_segment_status_id on iaf_segment; + +alter table imrelated drop foreign key fk_imrelated_owner_id; +drop index ix_imrelated_owner_id on imrelated; + +alter table info_contact drop foreign key fk_info_contact_company_id; +drop index ix_info_contact_company_id on info_contact; + +alter table info_customer drop foreign key fk_info_customer_company_id; + +alter table inner_report drop foreign key fk_inner_report_forecast_id; + +alter table drel_invoice drop foreign key fk_drel_invoice_booking; +drop index ix_drel_invoice_booking on drel_invoice; + +alter table item drop foreign key fk_item_etype; +drop index ix_item_etype on item; + +alter table item drop foreign key fk_item_eregion; +drop index ix_item_eregion on item; + +alter table mkeygroup_monkey drop foreign key fk_mkeygroup_monkey_mkeygroup; + +alter table mkeygroup_monkey drop foreign key fk_mkeygroup_monkey_monkey; + +alter table trainer_monkey drop foreign key fk_trainer_monkey_trainer; + +alter table trainer_monkey drop foreign key fk_trainer_monkey_monkey; + +alter table troop_monkey drop foreign key fk_troop_monkey_troop; + +alter table troop_monkey drop foreign key fk_troop_monkey_monkey; + +alter table l2_cldf_reset_bean_child drop foreign key fk_l2_cldf_reset_bean_child_parent_id; +drop index ix_l2_cldf_reset_bean_child_parent_id on l2_cldf_reset_bean_child; + +alter table level1_level4 drop foreign key fk_level1_level4_level1; +drop index ix_level1_level4_level1 on level1_level4; + +alter table level1_level4 drop foreign key fk_level1_level4_level4; +drop index ix_level1_level4_level4 on level1_level4; + +alter table level1_level2 drop foreign key fk_level1_level2_level1; +drop index ix_level1_level2_level1 on level1_level2; + +alter table level1_level2 drop foreign key fk_level1_level2_level2; +drop index ix_level1_level2_level2 on level1_level2; + +alter table level2_level3 drop foreign key fk_level2_level3_level2; +drop index ix_level2_level3_level2 on level2_level3; + +alter table level2_level3 drop foreign key fk_level2_level3_level3; +drop index ix_level2_level3_level3 on level2_level3; + +alter table link drop foreign key fk_link_id; + +alter table la_attr_value_attribute drop foreign key fk_la_attr_value_attribute_la_attr_value; +drop index ix_la_attr_value_attribute_la_attr_value on la_attr_value_attribute; + +alter table la_attr_value_attribute drop foreign key fk_la_attr_value_attribute_attribute; +drop index ix_la_attr_value_attribute_attribute on la_attr_value_attribute; + +alter table looney drop foreign key fk_looney_tune_id; +drop index ix_looney_tune_id on looney; + +alter table mcontact drop foreign key fk_mcontact_customer_id; +drop index ix_mcontact_customer_id on mcontact; + +alter table mcontact_message drop foreign key fk_mcontact_message_contact_id; +drop index ix_mcontact_message_contact_id on mcontact_message; + +alter table mcustomer drop foreign key fk_mcustomer_shipping_address_id; +drop index ix_mcustomer_shipping_address_id on mcustomer; + +alter table mcustomer drop foreign key fk_mcustomer_billing_address_id; +drop index ix_mcustomer_billing_address_id on mcustomer; + +alter table mmachine_mgroup drop foreign key fk_mmachine_mgroup_mmachine; +drop index ix_mmachine_mgroup_mmachine on mmachine_mgroup; + +alter table mmachine_mgroup drop foreign key fk_mmachine_mgroup_mgroup; +drop index ix_mmachine_mgroup_mgroup on mmachine_mgroup; + +alter table mprinter drop foreign key fk_mprinter_current_state_id; +drop index ix_mprinter_current_state_id on mprinter; + +alter table mprinter drop foreign key fk_mprinter_last_swap_cyan_id; + +alter table mprinter drop foreign key fk_mprinter_last_swap_magenta_id; + +alter table mprinter drop foreign key fk_mprinter_last_swap_yellow_id; + +alter table mprinter drop foreign key fk_mprinter_last_swap_black_id; + +alter table mprinter_state drop foreign key fk_mprinter_state_printer_id; +drop index ix_mprinter_state_printer_id on mprinter_state; + +alter table mprofile drop foreign key fk_mprofile_picture_id; +drop index ix_mprofile_picture_id on mprofile; + +alter table mrole_muser drop foreign key fk_mrole_muser_mrole; +drop index ix_mrole_muser_mrole on mrole_muser; + +alter table mrole_muser drop foreign key fk_mrole_muser_muser; +drop index ix_mrole_muser_muser on mrole_muser; + +alter table muser drop foreign key fk_muser_user_type_id; +drop index ix_muser_user_type_id on muser; + +alter table mail_user_inbox drop foreign key fk_mail_user_inbox_mail_user; +drop index ix_mail_user_inbox_mail_user on mail_user_inbox; + +alter table mail_user_inbox drop foreign key fk_mail_user_inbox_mail_box; +drop index ix_mail_user_inbox_mail_box on mail_user_inbox; + +alter table mail_user_outbox drop foreign key fk_mail_user_outbox_mail_user; +drop index ix_mail_user_outbox_mail_user on mail_user_outbox; + +alter table mail_user_outbox drop foreign key fk_mail_user_outbox_mail_box; +drop index ix_mail_user_outbox_mail_box on mail_user_outbox; + +alter table c_message drop foreign key fk_c_message_conversation_id; +drop index ix_c_message_conversation_id on c_message; + +alter table c_message drop foreign key fk_c_message_user_id; +drop index ix_c_message_user_id on c_message; + +alter table meter_contract_data drop foreign key fk_meter_contract_data_special_needs_client_id; + +alter table meter_special_needs_client drop foreign key fk_meter_special_needs_client_primary_id; + +alter table meter_version drop foreign key fk_meter_version_address_data_id; + +alter table meter_version drop foreign key fk_meter_version_contract_data_id; + +alter table mnoc_user_mnoc_role drop foreign key fk_mnoc_user_mnoc_role_mnoc_user; +drop index ix_mnoc_user_mnoc_role_mnoc_user on mnoc_user_mnoc_role; + +alter table mnoc_user_mnoc_role drop foreign key fk_mnoc_user_mnoc_role_mnoc_role; +drop index ix_mnoc_user_mnoc_role_mnoc_role on mnoc_user_mnoc_role; + +alter table mny_b drop foreign key fk_mny_b_a_id; +drop index ix_mny_b_a_id on mny_b; + +alter table mny_b_mny_c drop foreign key fk_mny_b_mny_c_mny_b; +drop index ix_mny_b_mny_c_mny_b on mny_b_mny_c; + +alter table mny_b_mny_c drop foreign key fk_mny_b_mny_c_mny_c; +drop index ix_mny_b_mny_c_mny_c on mny_b_mny_c; + +alter table subtopics drop foreign key fk_subtopics_mny_topic_1; +drop index ix_subtopics_mny_topic_1 on subtopics; + +alter table subtopics drop foreign key fk_subtopics_mny_topic_2; +drop index ix_subtopics_mny_topic_2 on subtopics; + +alter table mp_role drop foreign key fk_mp_role_mp_user_id; +drop index ix_mp_role_mp_user_id on mp_role; + +alter table ms_many_a_many_b drop foreign key fk_ms_many_a_many_b_ms_many_a; +drop index ix_ms_many_a_many_b_ms_many_a on ms_many_a_many_b; + +alter table ms_many_a_many_b drop foreign key fk_ms_many_a_many_b_ms_many_b; +drop index ix_ms_many_a_many_b_ms_many_b on ms_many_a_many_b; + +alter table ms_many_b_many_a drop foreign key fk_ms_many_b_many_a_ms_many_b; +drop index ix_ms_many_b_many_a_ms_many_b on ms_many_b_many_a; + +alter table ms_many_b_many_a drop foreign key fk_ms_many_b_many_a_ms_many_a; +drop index ix_ms_many_b_many_a_ms_many_a on ms_many_b_many_a; + +alter table my_lob_size_join_many drop foreign key fk_my_lob_size_join_many_parent_id; +drop index ix_my_lob_size_join_many_parent_id on my_lob_size_join_many; + +alter table o_bean_child drop foreign key fk_o_bean_child_cached_bean_id; +drop index ix_o_bean_child_cached_bean_id on o_bean_child; + +alter table ocached_app_detail drop foreign key fk_ocached_app_detail_app_id; +drop index ix_ocached_app_detail_app_id on ocached_app_detail; + +alter table o_cached_bean_country drop foreign key fk_o_cached_bean_country_o_cached_bean; +drop index ix_o_cached_bean_country_o_cached_bean on o_cached_bean_country; + +alter table o_cached_bean_country drop foreign key fk_o_cached_bean_country_o_country; +drop index ix_o_cached_bean_country_o_country on o_cached_bean_country; + +alter table o_cached_bean_child drop foreign key fk_o_cached_bean_child_cached_bean_id; +drop index ix_o_cached_bean_child_cached_bean_id on o_cached_bean_child; + +alter table oengine drop foreign key fk_oengine_car_id; + +alter table ogear_box drop foreign key fk_ogear_box_car_id; + +alter table omvertex_other drop foreign key fk_omvertex_other_omvertex_id; +drop index ix_omvertex_other_omvertex_id on omvertex_other; + +alter table oroad_show_msg drop foreign key fk_oroad_show_msg_company_id; + +alter table om_account_child_dbo drop foreign key fk_om_account_child_dbo_banana_rama_id; +drop index ix_om_account_child_dbo_banana_rama_id on om_account_child_dbo; + +alter table om_basic_child drop foreign key fk_om_basic_child_parent_id; +drop index ix_om_basic_child_parent_id on om_basic_child; + +alter table om_ordered_detail drop foreign key fk_om_ordered_detail_master_id; +drop index ix_om_ordered_detail_master_id on om_ordered_detail; + +alter table o_order drop foreign key fk_o_order_kcustomer_id; +drop index ix_o_order_kcustomer_id on o_order; + +alter table o_order_detail drop foreign key fk_o_order_detail_order_id; +drop index ix_o_order_detail_order_id on o_order_detail; + +alter table o_order_detail drop foreign key fk_o_order_detail_product_id; +drop index ix_o_order_detail_product_id on o_order_detail; + +alter table s_order_items drop foreign key fk_s_order_items_order_uuid; +drop index ix_s_order_items_order_uuid on s_order_items; + +alter table order_referenced_parent drop foreign key fk_order_referenced_parent_master_id; +drop index ix_order_referenced_parent_master_id on order_referenced_parent; + +alter table or_order_ship drop foreign key fk_or_order_ship_order_id; +drop index ix_or_order_ship_order_id on or_order_ship; + +alter table order_toy drop foreign key fk_order_toy_child_id; +drop index ix_order_toy_child_id on order_toy; + +alter table ordered_parent drop foreign key fk_ordered_parent_order_master_inheritance_id; +drop index ix_ordered_parent_order_master_inheritance_id on ordered_parent; + +alter table organization_node drop foreign key fk_organization_node_parent_tree_node_id; + +alter table orp_detail drop foreign key fk_orp_detail_master_id; +drop index ix_orp_detail_master_id on orp_detail; + +alter table orp_detail2 drop foreign key fk_orp_detail2_orp_master2_id; +drop index ix_orp_detail2_orp_master2_id on orp_detail2; + +alter table oto_atwo drop foreign key fk_oto_atwo_aone_id; + +alter table oto_bchild drop foreign key fk_oto_bchild_master_id; + +alter table oto_child drop foreign key fk_oto_child_master_id; + +alter table oto_cust_address drop foreign key fk_oto_cust_address_customer_cid; + +alter table oto_level_a drop foreign key fk_oto_level_a_b_id; + +alter table oto_level_b drop foreign key fk_oto_level_b_c_id; + +alter table oto_prime_extra drop foreign key fk_oto_prime_extra_eid; + +alter table oto_sd_child drop foreign key fk_oto_sd_child_master_id; + +alter table oto_th_many drop foreign key fk_oto_th_many_oto_th_top_id; +drop index ix_oto_th_many_oto_th_top_id on oto_th_many; + +alter table oto_th_one drop foreign key fk_oto_th_one_many_id; + +alter table oto_ubprime_extra drop foreign key fk_oto_ubprime_extra_eid; + +alter table oto_user_model drop foreign key fk_oto_user_model_user_optional_id; + +alter table pfile drop foreign key fk_pfile_file_content_id; + +alter table pfile drop foreign key fk_pfile_file_content2_id; + +alter table paggview drop foreign key fk_paggview_pview_id; + +alter table pallet_location drop foreign key fk_pallet_location_zone_sid; +drop index ix_pallet_location_zone_sid on pallet_location; + +alter table parcel_location drop foreign key fk_parcel_location_parcelid; + +alter table rawinherit_parent_rawinherit_data drop foreign key fk_rawinherit_parent_rawinherit_data_rawinherit_parent; +drop index ix_rawinherit_parent_rawinherit_data_rawinherit_parent on rawinherit_parent_rawinherit_data; + +alter table rawinherit_parent_rawinherit_data drop foreign key fk_rawinherit_parent_rawinherit_data_rawinherit_data; +drop index ix_rawinherit_parent_rawinherit_data_rawinherit_data on rawinherit_parent_rawinherit_data; + +alter table parent_person drop foreign key fk_parent_person_some_bean_id; +drop index ix_parent_person_some_bean_id on parent_person; + +alter table parent_person drop foreign key fk_parent_person_parent_identifier; +drop index ix_parent_person_parent_identifier on parent_person; + +alter table c_participation drop foreign key fk_c_participation_conversation_id; +drop index ix_c_participation_conversation_id on c_participation; + +alter table c_participation drop foreign key fk_c_participation_user_id; +drop index ix_c_participation_user_id on c_participation; + +alter table pcf_calendar drop foreign key fk_pcf_calendar_pcf_person_id; +drop index ix_pcf_calendar_pcf_person_id on pcf_calendar; + +alter table pcf_city drop foreign key fk_pcf_city_pcf_country_id; +drop index ix_pcf_city_pcf_country_id on pcf_city; + +alter table pcf_city drop foreign key fk_pcf_city_mayor_id; + +alter table pcf_city drop foreign key fk_pcf_city_vice_mayor_id; + +alter table pcf_event drop foreign key fk_pcf_event_pcf_calendar_id; +drop index ix_pcf_event_pcf_calendar_id on pcf_event; + +alter table persistent_file_content drop foreign key fk_persistent_file_content_persistent_file_id; + +alter table person drop foreign key fk_person_default_address_oid; +drop index ix_person_default_address_oid on person; + +alter table person_cache_email drop foreign key fk_person_cache_email_person_info_person_id; +drop index ix_person_cache_email_person_info_person_id on person_cache_email; + +alter table phones drop foreign key fk_phones_person_id; +drop index ix_phones_person_id on phones; + +alter table e_position drop foreign key fk_e_position_contract_id; +drop index ix_e_position_contract_id on e_position; + +alter table pp_to_ww drop foreign key fk_pp_to_ww_pp; +drop index ix_pp_to_ww_pp on pp_to_ww; + +alter table pp_to_ww drop foreign key fk_pp_to_ww_wview; +drop index ix_pp_to_ww_wview on pp_to_ww; + +alter table question drop foreign key fk_question_groupobjectid; +drop index ix_question_groupobjectid on question; + +alter table r_orders drop foreign key fk_r_orders_customer; +drop index ix_r_orders_customer on r_orders; + +alter table referenced_defaults_model drop foreign key fk_referenced_defaults_model_id; + +alter table referenced_defaults_model drop foreign key fk_referenced_defaults_model_defaults_model_id; +drop index ix_referenced_defaults_model_defaults_model_id on referenced_defaults_model; + +alter table referenced_defaults_model_draft drop foreign key fk_referenced_defaults_model_draft_defaults_model_id; +drop index ix_referenced_defaults_model_draft_defaults_model_id on referenced_defaults_model_draft; + +alter table rel_master drop foreign key fk_rel_master_detail_id; +drop index ix_rel_master_detail_id on rel_master; + +alter table resourcefile drop foreign key fk_resourcefile_parentresourcefileid; +drop index ix_resourcefile_parentresourcefileid on resourcefile; + +alter table mt_role drop foreign key fk_mt_role_tenant_id; +drop index ix_mt_role_tenant_id on mt_role; + +alter table mt_role_permission drop foreign key fk_mt_role_permission_mt_role; +drop index ix_mt_role_permission_mt_role on mt_role_permission; + +alter table mt_role_permission drop foreign key fk_mt_role_permission_mt_permission; +drop index ix_mt_role_permission_mt_permission on mt_role_permission; + +alter table root_bean drop foreign key fk_root_bean_referencing_bean_id; +drop index ix_root_bean_referencing_bean_id on root_bean; + +alter table f_second drop foreign key fk_f_second_first; + +alter table section drop foreign key fk_section_article_id; +drop index ix_section_article_id on section; + +alter table self_parent drop foreign key fk_self_parent_parent_id; +drop index ix_self_parent_parent_id on self_parent; + +alter table self_ref_customer drop foreign key fk_self_ref_customer_referred_by_id; +drop index ix_self_ref_customer_referred_by_id on self_ref_customer; + +alter table self_ref_example drop foreign key fk_self_ref_example_parent_id; +drop index ix_self_ref_example_parent_id on self_ref_example; + +alter table e_save_test_b drop foreign key fk_e_save_test_b_sibling_a_id; + +alter table site drop foreign key fk_site_parent_id; +drop index ix_site_parent_id on site; + +alter table site drop foreign key fk_site_data_container_id; + +alter table site drop foreign key fk_site_site_address_id; + +alter table source_base drop foreign key fk_source_base_target_id; +drop index ix_source_base_target_id on source_base; + +alter table stockforecast drop foreign key fk_stockforecast_inner_report_id; +drop index ix_stockforecast_inner_report_id on stockforecast; + +alter table sub_section drop foreign key fk_sub_section_section_id; +drop index ix_sub_section_section_id on sub_section; + +alter table tevent_many drop foreign key fk_tevent_many_event_id; +drop index ix_tevent_many_event_id on tevent_many; + +alter table tevent_one drop foreign key fk_tevent_one_event_id; + +alter table t_detail_with_other_namexxxyy drop foreign key fk_t_detail_with_other_namexxxyy_master_id; +drop index ix_t_detail_with_other_namexxxyy_master_id on t_detail_with_other_namexxxyy; + +alter table ttruck_holder drop foreign key fk_ttruck_holder_truck_plate_no; +drop index ix_ttruck_holder_truck_plate_no on ttruck_holder; + +alter table ttruck_holder drop foreign key fk_ttruck_holder_basic_id; +drop index ix_ttruck_holder_basic_id on ttruck_holder; + +alter table ttruck_holder_item drop foreign key fk_ttruck_holder_item_owner_id; +drop index ix_ttruck_holder_item_owner_id on ttruck_holder_item; + +alter table twheel drop foreign key fk_twheel_owner_plate_no; +drop index ix_twheel_owner_plate_no on twheel; + +alter table tire drop foreign key fk_tire_wheel; + +alter table tree_entity drop foreign key fk_tree_entity_parent_id; +drop index ix_tree_entity_parent_id on tree_entity; + +alter table trip drop foreign key fk_trip_vehicle_driver_id; +drop index ix_trip_vehicle_driver_id on trip; + +alter table trip drop foreign key fk_trip_address_id; +drop index ix_trip_address_id on trip; + +alter table `type` drop foreign key fk_type_sub_type_id; +drop index ix_type_sub_type_id on `type`; + +alter table usib_child drop foreign key fk_usib_child_parent_id; +drop index ix_usib_child_parent_id on usib_child; + +alter table usib_child_sibling drop foreign key fk_usib_child_sibling_child_id; + +alter table ut_detail drop foreign key fk_ut_detail_utmaster_id; +drop index ix_ut_detail_utmaster_id on ut_detail; + +alter table uutwo drop foreign key fk_uutwo_master_id; +drop index ix_uutwo_master_id on uutwo; + +alter table oto_user drop foreign key fk_oto_user_account_id; + +alter table c_user drop foreign key fk_c_user_group_id; +drop index ix_c_user_group_id on c_user; + +alter table em_user_role drop foreign key fk_em_user_role_user_id; +drop index ix_em_user_role_user_id on em_user_role; + +alter table em_user_role drop foreign key fk_em_user_role_role_id; +drop index ix_em_user_role_role_id on em_user_role; + +alter table vehicle drop foreign key fk_vehicle_lease_id; +drop index ix_vehicle_lease_id on vehicle; + +alter table vehicle drop foreign key fk_vehicle_car_ref_id; +drop index ix_vehicle_car_ref_id on vehicle; + +alter table vehicle drop foreign key fk_vehicle_truck_ref_id; +drop index ix_vehicle_truck_ref_id on vehicle; + +alter table vehicle_driver drop foreign key fk_vehicle_driver_vehicle_id; +drop index ix_vehicle_driver_vehicle_id on vehicle_driver; + +alter table vehicle_driver drop foreign key fk_vehicle_driver_address_id; +drop index ix_vehicle_driver_address_id on vehicle_driver; + +alter table version_child drop foreign key fk_version_child_parent_id; +drop index ix_version_child_parent_id on version_child; + +alter table version_toy drop foreign key fk_version_toy_child_id; +drop index ix_version_toy_child_id on version_toy; + +alter table warehouses drop foreign key fk_warehouses_officezoneid; +drop index ix_warehouses_officezoneid on warehouses; + +alter table warehousesshippingzones drop foreign key fk_warehousesshippingzones_warehouses; +drop index ix_warehousesshippingzones_warehouses on warehousesshippingzones; + +alter table warehousesshippingzones drop foreign key fk_warehousesshippingzones_zones; +drop index ix_warehousesshippingzones_zones on warehousesshippingzones; + +alter table sa_wheel drop foreign key fk_sa_wheel_tire; +drop index ix_sa_wheel_tire on sa_wheel; + +alter table sa_wheel drop foreign key fk_sa_wheel_car; +drop index ix_sa_wheel_car on sa_wheel; + +alter table g_who_props_otm drop foreign key fk_g_who_props_otm_who_created_id; +drop index ix_g_who_props_otm_who_created_id on g_who_props_otm; + +alter table g_who_props_otm drop foreign key fk_g_who_props_otm_who_modified_id; +drop index ix_g_who_props_otm_who_modified_id on g_who_props_otm; + +alter table with_zero drop foreign key fk_with_zero_parent_id; +drop index ix_with_zero_parent_id on with_zero; + +drop table if exists asimple_bean; + +drop table if exists bar; + +drop table if exists block; + +drop table if exists oto_account; + +drop table if exists acl; + +drop table if exists acl_container_relation; + +drop table if exists addr; + +drop table if exists address; + +drop table if exists o_address; + +drop table if exists album; + +drop table if exists animal; + +drop table if exists animal_shelter; + +drop table if exists article; + +drop table if exists attribute; + +drop table if exists attribute_holder; + +drop table if exists audit_log; + +drop table if exists bbookmark; + +drop table if exists bbookmark_org; + +drop table if exists bbookmark_user; + +drop table if exists bsimple_with_gen; + +drop table if exists bsite; + +drop table if exists bsite_user_a; + +drop table if exists bsite_user_b; + +drop table if exists bsite_user_c; + +drop table if exists bsite_user_d; + +drop table if exists bsite_user_e; + +drop table if exists buser; + +drop table if exists bwith_qident; + +drop table if exists basic_draftable_bean; + +drop table if exists basic_draftable_bean_draft; + +drop table if exists basic_joda_entity; + +drop table if exists bean_with_time_zone; + +drop table if exists drel_booking; + +drop table if exists bw_bean; + +drop table if exists cepcategory; + +drop table if exists cepproduct; + +drop table if exists cepproduct_category; + +drop table if exists ciaddress; + +drop table if exists cicustomer_parent; + +drop table if exists cistreet_parent; + +drop table if exists cinh_ref; + +drop table if exists cinh_root; + +drop table if exists ckey_assoc; + +drop table if exists ckey_detail; + +drop table if exists ckey_parent; + +drop table if exists coone; + +drop table if exists coone_many; + +drop table if exists coroot; + +drop table if exists calculation_result; + +drop table if exists cao_bean; + +drop table if exists sp_car_car; + +drop table if exists sp_car_car_wheels; + +drop table if exists sp_car_car_doors; + +drop table if exists sa_car; + +drop table if exists car_accessory; + +drop table if exists car_fuse; + +drop table if exists category; + +drop table if exists e_save_test_d; + +drop table if exists child_person; + +drop table if exists cke_client; + +drop table if exists cke_user; + +drop table if exists class_super; + +drop table if exists class_super_monkey; + +drop table if exists configuration; + +drop table if exists configurations; + +drop table if exists contact; + +drop table if exists contact_group; + +drop table if exists contact_note; + +drop table if exists contract; + +drop table if exists contract_costs; + +drop table if exists c_conversation; + +drop table if exists o_country; + +drop table if exists cover; + +drop table if exists o_customer; + +drop table if exists dcredit; + +drop table if exists dcredit_drol; + +drop table if exists dexh_entity; + +drop table if exists dint_parent; + +drop table if exists dmachine; + +drop table if exists d_machine_aux_use; + +drop table if exists d_machine_stats; + +drop table if exists d_machine_use; + +drop table if exists dorg; + +drop table if exists dperson; + +drop table if exists drol; + +drop table if exists drot; + +drop table if exists drot_drol; + +drop table if exists rawinherit_data; + +drop table if exists data_container; + +drop table if exists dc_detail; + +drop table if exists dc_master; + +drop table if exists defaults_model; + +drop table if exists defaults_model_draft; + +drop table if exists dfk_cascade; + +drop table if exists dfk_cascade_one; + +drop table if exists dfk_none; + +drop table if exists dfk_none_via_join; + +drop table if exists dfk_none_via_mto_m; + +drop table if exists dfk_none_via_mto_m_dfk_one; + +drop table if exists dfk_one; + +drop table if exists dfk_set_null; + +drop table if exists doc; + +drop table if exists doc_link; + +drop table if exists doc_link_draft; + +drop table if exists doc_draft; + +drop table if exists document; + +drop table if exists document_draft; + +drop table if exists document_media; + +drop table if exists document_media_draft; + +drop table if exists sp_car_door; + +drop table if exists earray_bean; + +drop table if exists earray_set_bean; + +drop table if exists e_basic; + +drop table if exists ebasic_change_log; + +drop table if exists ebasic_clob; + +drop table if exists ebasic_clob_fetch_eager; + +drop table if exists ebasic_clob_no_ver; + +drop table if exists e_basicenc; + +drop table if exists e_basicenc_bin; + +drop table if exists e_basicenc_client; + +drop table if exists e_basicenc_relate; + +drop table if exists e_basic_enum_id; + +drop table if exists e_basic_eni; + +drop table if exists ebasic_hstore; + +drop table if exists ebasic_json_jackson; + +drop table if exists ebasic_json_jackson2; + +drop table if exists ebasic_json_list; + +drop table if exists ebasic_json_map; + +drop table if exists ebasic_json_map_blob; + +drop table if exists ebasic_json_map_clob; + +drop table if exists ebasic_json_map_detail; + +drop table if exists ebasic_json_map_json_b; + +drop table if exists ebasic_json_map_varchar; + +drop table if exists ebasic_json_node; + +drop table if exists ebasic_json_node_blob; + +drop table if exists ebasic_json_node_json_b; + +drop table if exists ebasic_json_node_varchar; + +drop table if exists ebasic_json_unmapped; + +drop table if exists e_basic_ndc; + +drop table if exists ebasic_no_sdchild; + +drop table if exists ebasic_sdchild; + +drop table if exists ebasic_soft_delete; + +drop table if exists e_basicver; + +drop table if exists e_basic_withlife; + +drop table if exists e_basic_with_ex; + +drop table if exists e_basicverucon; + +drop table if exists ecache_child; + +drop table if exists ecache_root; + +drop table if exists e_col_ab; + +drop table if exists ecustom_id; + +drop table if exists edefault_prop; + +drop table if exists eemb_inner; + +drop table if exists eemb_outer; + +drop table if exists efile2_no_fk; + +drop table if exists efile_no_fk; + +drop table if exists efile_no_fk_euser_no_fk; + +drop table if exists efile_no_fk_euser_no_fk_soft_del; + +drop table if exists egen_props; + +drop table if exists eid_uid_bean; + +drop table if exists einvoice; + +drop table if exists e_main; + +drop table if exists enull_collection; + +drop table if exists enull_collection_detail; + +drop table if exists eopt_one_a; + +drop table if exists eopt_one_b; + +drop table if exists eopt_one_c; + +drop table if exists eper_addr; + +drop table if exists eperson; + +drop table if exists e_person_online; + +drop table if exists esimple; + +drop table if exists esoft_del_book; + +drop table if exists esoft_del_book_esoft_del_user; + +drop table if exists esoft_del_down; + +drop table if exists esoft_del_mid; + +drop table if exists esoft_del_one_a; + +drop table if exists esoft_del_one_b; + +drop table if exists esoft_del_role; + +drop table if exists esoft_del_role_esoft_del_user; + +drop table if exists esoft_del_top; + +drop table if exists esoft_del_up; + +drop table if exists esoft_del_user; + +drop table if exists esoft_del_user_esoft_del_role; + +drop table if exists esome_convert_type; + +drop table if exists esome_type; + +drop table if exists etrans_many; + +drop table if exists rawinherit_uncle; + +drop table if exists euser_no_fk; + +drop table if exists euser_no_fk_soft_del; + +drop table if exists evanilla_collection; + +drop table if exists evanilla_collection_detail; + +drop table if exists ewho_props; + +drop table if exists e_withinet; + +drop table if exists ec_enum_person; + +drop table if exists ec_enum_person_tags; + +drop table if exists ec_person; + +drop table if exists ec_person_phone; + +drop table if exists ec_top; + +drop table if exists ec_top_ecs_person; + +drop table if exists ecbl_person; + +drop table if exists ecbl_person_phone_numbers; + +drop table if exists ecbm_person; + +drop table if exists ecbm_person_phone_numbers; + +drop table if exists ecm_person; + +drop table if exists ecm_person_phone_numbers; + +drop table if exists ecmc_person; + +drop table if exists ecmc_person_phone_numbers; + +drop table if exists ecs_person; + +drop table if exists ecs_person_phone; + +drop table if exists ecsm_child; + +drop table if exists ecsm_values; + +drop table if exists ecsm_one; + +drop table if exists ecsm_parent; + +drop table if exists ecsm_two; + +drop table if exists td_child; + +drop table if exists td_parent; + +drop table if exists element_bean; + +drop table if exists empl; + +drop table if exists esd_detail; + +drop table if exists esd_master; + +drop table if exists feature_desc; + +drop table if exists f_first; + +drop table if exists foo; + +drop table if exists gen_key_identity; + +drop table if exists gen_key_sequence; + +drop table if exists grand_parent_person; + +drop table if exists survey_group; + +drop table if exists c_group; + +drop table if exists he_doc; + +alter table hx_link drop system versioning; +drop table if exists hx_link; + +drop table if exists hx_link_doc; + +drop table if exists hi_doc; + +alter table hi_link drop system versioning; +drop table if exists hi_link; + +alter table hi_link_doc drop system versioning; +drop table if exists hi_link_doc; + +alter table hi_tone drop system versioning; +drop table if exists hi_tone; + +alter table hi_tthree drop system versioning; +drop table if exists hi_tthree; + +alter table hi_ttwo drop system versioning; +drop table if exists hi_ttwo; + +alter table hsd_setting drop system versioning; +drop table if exists hsd_setting; + +alter table hsd_user drop system versioning; +drop table if exists hsd_user; + +drop table if exists iaf_segment; + +drop table if exists iaf_segment_status; + +drop table if exists imrelated; + +drop table if exists imroot; + +drop table if exists ixresource; + +drop table if exists info_company; + +drop table if exists info_contact; + +drop table if exists info_customer; + +drop table if exists inner_report; + +drop table if exists drel_invoice; + +drop table if exists item; + +drop table if exists monkey; + +drop table if exists mkeygroup; + +drop table if exists mkeygroup_monkey; + +drop table if exists trainer; + +drop table if exists trainer_monkey; + +drop table if exists troop; + +drop table if exists troop_monkey; + +drop table if exists l2_cldf_reset_bean; + +drop table if exists l2_cldf_reset_bean_child; + +drop table if exists level1; + +drop table if exists level1_level4; + +drop table if exists level1_level2; + +drop table if exists level2; + +drop table if exists level2_level3; + +drop table if exists level3; + +drop table if exists level4; + +alter table link drop system versioning; +drop table if exists link; + +drop table if exists link_draft; + +drop table if exists la_attr_value; + +drop table if exists la_attr_value_attribute; + +drop table if exists looney; + +drop table if exists maddress; + +drop table if exists mcontact; + +drop table if exists mcontact_message; + +drop table if exists mcustomer; + +drop table if exists mgroup; + +drop table if exists mmachine; + +drop table if exists mmachine_mgroup; + +drop table if exists mmedia; + +drop table if exists non_updateprop; + +drop table if exists mprinter; + +drop table if exists mprinter_state; + +drop table if exists mprofile; + +drop table if exists mprotected_construct_bean; + +drop table if exists mrole; + +drop table if exists mrole_muser; + +drop table if exists msome_other; + +drop table if exists muser; + +drop table if exists muser_type; + +drop table if exists mail_box; + +drop table if exists mail_user; + +drop table if exists mail_user_inbox; + +drop table if exists mail_user_outbox; + +drop table if exists main_entity; + +drop table if exists main_entity_relation; + +drop table if exists map_super_actual; + +drop table if exists c_message; + +drop table if exists meter_address_data; + +drop table if exists meter_contract_data; + +drop table if exists meter_special_needs_client; + +drop table if exists meter_special_needs_contact; + +drop table if exists meter_version; + +drop table if exists mnoc_role; + +drop table if exists mnoc_user; + +drop table if exists mnoc_user_mnoc_role; + +drop table if exists mny_a; + +drop table if exists mny_b; + +drop table if exists mny_b_mny_c; + +drop table if exists mny_c; + +drop table if exists mny_topic; + +drop table if exists subtopics; + +drop table if exists mp_role; + +drop table if exists mp_user; + +drop table if exists ms_many_a; + +drop table if exists ms_many_a_many_b; + +drop table if exists ms_many_b; + +drop table if exists ms_many_b_many_a; + +drop table if exists my_lob_size; + +drop table if exists my_lob_size_join_many; + +drop table if exists noidbean; + +drop table if exists o_bean_child; + +drop table if exists ocached_app; + +drop table if exists ocached_app_detail; + +drop table if exists o_cached_bean; + +drop table if exists o_cached_bean_country; + +drop table if exists o_cached_bean_child; + +drop table if exists o_cached_inherit; + +drop table if exists o_cached_natkey; + +drop table if exists o_cached_natkey3; + +drop table if exists ocached_nkey_uid; + +drop table if exists ocar; + +drop table if exists ocompany; + +drop table if exists oengine; + +drop table if exists ogear_box; + +drop table if exists omvertex; + +drop table if exists omvertex_other; + +drop table if exists oroad_show_msg; + +drop table if exists om_account_child_dbo; + +drop table if exists om_account_dbo; + +drop table if exists om_basic_child; + +drop table if exists om_basic_parent; + +drop table if exists om_ordered_detail; + +drop table if exists om_ordered_master; + +drop table if exists only_id_entity; + +drop table if exists o_order; + +drop table if exists o_order_detail; + +drop table if exists s_orders; + +drop table if exists s_order_items; + +drop table if exists order_master; + +drop table if exists order_master_inheritance; + +drop table if exists order_referenced_parent; + +drop table if exists or_order_ship; + +drop table if exists order_toy; + +drop table if exists ordered_parent; + +drop table if exists organisation; + +drop table if exists organization_node; + +drop table if exists organization_tree_node; + +drop table if exists orp_detail; + +drop table if exists orp_detail2; + +drop table if exists orp_master; + +drop table if exists orp_master2; + +drop table if exists oto_aone; + +drop table if exists oto_atwo; + +drop table if exists oto_bchild; + +drop table if exists oto_bmaster; + +drop table if exists oto_child; + +drop table if exists oto_cust; + +drop table if exists oto_cust_address; + +drop table if exists oto_level_a; + +drop table if exists oto_level_b; + +drop table if exists oto_level_c; + +drop table if exists oto_master; + +drop table if exists oto_prime; + +drop table if exists oto_prime_extra; + +drop table if exists oto_sd_child; + +drop table if exists oto_sd_master; + +drop table if exists oto_th_many; + +drop table if exists oto_th_one; + +drop table if exists oto_th_top; + +drop table if exists oto_ubprime; + +drop table if exists oto_ubprime_extra; + +drop table if exists oto_uprime; + +drop table if exists oto_uprime_extra; + +drop table if exists oto_user_model; + +drop table if exists oto_user_model_optional; + +drop table if exists pfile; + +drop table if exists pfile_content; + +drop table if exists paggview; + +drop table if exists pallet_location; + +drop table if exists parcel; + +drop table if exists parcel_location; + +drop table if exists rawinherit_parent; + +drop table if exists rawinherit_parent_rawinherit_data; + +drop table if exists e_save_test_c; + +drop table if exists parent_person; + +drop table if exists c_participation; + +drop table if exists password_store_model; + +drop table if exists pcf_calendar; + +drop table if exists pcf_city; + +drop table if exists pcf_country; + +drop table if exists pcf_event; + +drop table if exists pcf_person; + +drop table if exists mt_permission; + +drop table if exists persistent_file; + +drop table if exists persistent_file_content; + +drop table if exists person; + +drop table if exists persons; + +drop table if exists person_cache_email; + +drop table if exists person_cache_info; + +drop table if exists phones; + +drop table if exists e_position; + +drop table if exists primary_revision; + +drop table if exists o_product; + +drop table if exists pp; + +drop table if exists pp_to_ww; + +drop table if exists question; + +drop table if exists rcustomer; + +drop table if exists r_orders; + +drop table if exists referenced_defaults_model; + +drop table if exists referenced_defaults_model_draft; + +drop table if exists referencing_bean; + +drop table if exists region; + +drop table if exists rel_detail; + +drop table if exists rel_master; + +drop table if exists resourcefile; + +drop table if exists mt_role; + +drop table if exists mt_role_permission; + +drop table if exists em_role; + +drop table if exists root_bean; + +drop table if exists f_second; + +drop table if exists section; + +drop table if exists self_parent; + +drop table if exists self_ref_customer; + +drop table if exists self_ref_example; + +drop table if exists e_save_test_a; + +drop table if exists e_save_test_b; + +drop table if exists site; + +drop table if exists site_address; + +drop table if exists some_enum_bean; + +drop table if exists some_file_bean; + +drop table if exists some_new_types_bean; + +drop table if exists some_period_bean; + +drop table if exists source_base; + +drop table if exists stockforecast; + +drop table if exists sub_section; + +drop table if exists sub_type; + +drop table if exists survey; + +drop table if exists tbytes_only; + +drop table if exists tcar; + +drop table if exists tevent; + +drop table if exists tevent_many; + +drop table if exists tevent_one; + +drop table if exists tint_root; + +drop table if exists tjoda_entity; + +drop table if exists t_mapsuper1; + +drop table if exists t_oneb; + +drop table if exists t_detail_with_other_namexxxyy; + +drop table if exists t_atable_thatisrelatively; + +drop table if exists ttruck_holder; + +drop table if exists ttruck_holder_item; + +drop table if exists tuuid_entity; + +drop table if exists twheel; + +drop table if exists twith_pre_insert; + +drop table if exists target_base; + +drop table if exists mt_tenant; + +drop table if exists test_annotation_base_entity; + +drop table if exists tire; + +drop table if exists sa_tire; + +drop table if exists tree_entity; + +drop table if exists trip; + +drop table if exists truck_ref; + +drop table if exists tune; + +drop table if exists `type`; + +drop table if exists tz_bean; + +drop table if exists usib_child; + +drop table if exists usib_child_sibling; + +drop table if exists usib_parent; + +drop table if exists ut_detail; + +drop table if exists ut_master; + +drop table if exists uuone; + +drop table if exists uutwo; + +drop table if exists oto_user; + +alter table c_user drop system versioning; +drop table if exists c_user; + +drop table if exists tx_user; + +drop table if exists g_user; + +drop table if exists em_user; + +drop table if exists user_interest_live; + +drop table if exists em_user_role; + +drop table if exists vehicle; + +drop table if exists vehicle_driver; + +drop table if exists vehicle_lease; + +drop table if exists version_child; + +drop table if exists version_parent; + +drop table if exists version_toy; + +drop table if exists warehouses; + +drop table if exists warehousesshippingzones; + +drop table if exists wheel; + +drop table if exists sa_wheel; + +drop table if exists sp_car_wheel; + +drop table if exists g_who_props_otm; + +drop table if exists with_zero; + +drop table if exists parent; + +drop table if exists wview; + +drop table if exists zones; + +drop index ix_contact_last_name_first_name on contact; +drop index ix_e_basic_name on e_basic; +drop index ix_efile2_no_fk_owner_id on efile2_no_fk; +drop index ix_ecsm_values_host_id on ecsm_values; +drop index ix_order_referenced_parent_type on order_referenced_parent; +drop index ix_organization_node_kind on organization_node; +drop index ano_3 on test_annotation_base_entity; diff --git a/ebean-core/src/test/ddl-review/mysql-create-all.sql b/ebean-core/src/test/ddl-review/mysql-create-all.sql new file mode 100644 index 000000000..b81d42511 --- /dev/null +++ b/ebean-core/src/test/ddl-review/mysql-create-all.sql @@ -0,0 +1,5008 @@ +-- Generated by ebean unknown at 2020-02-21T19:45:37.488834Z +create table asimple_bean ( + id bigint auto_increment not null, + name varchar(255), + constraint pk_asimple_bean primary key (id) +); + +create table bar ( + bar_type varchar(31) not null, + bar_id integer auto_increment not null, + foo_id integer not null, + version integer not null, + constraint pk_bar primary key (bar_id) +); + +create table block ( + case_type integer(31) not null, + id bigint auto_increment not null, + name varchar(255), + version bigint not null, + notes varchar(255), + constraint pk_block primary key (id) +); + +create table oto_account ( + id bigint auto_increment not null, + name varchar(255), + version bigint not null, + when_created datetime(6) not null, + when_modified datetime(6) not null, + constraint pk_oto_account primary key (id) +); + +create table acl ( + id bigint auto_increment not null, + name varchar(255), + constraint pk_acl primary key (id) +); + +create table acl_container_relation ( + id bigint auto_increment not null, + container_id bigint not null, + acl_entry_id bigint not null, + constraint pk_acl_container_relation primary key (id) +); + +create table addr ( + id bigint auto_increment not null, + employee_id bigint, + name varchar(255), + address_line1 varchar(255), + address_line2 varchar(255), + city varchar(255), + version bigint not null, + constraint pk_addr primary key (id) +); + +create table address ( + oid bigint auto_increment not null, + street varchar(255), + version integer not null, + constraint pk_address primary key (oid) +); + +create table o_address ( + id integer auto_increment not null, + line_1 varchar(100), + line_2 varchar(100), + city varchar(100), + cretime datetime(6), + country_code varchar(2), + updtime datetime(6) not null, + constraint pk_o_address primary key (id) +); + +create table album ( + id bigint auto_increment not null, + name varchar(255), + cover_id bigint, + deleted tinyint(1) default 0 not null, + created_at datetime(6) not null, + last_update datetime(6) not null, + constraint uq_album_cover_id unique (cover_id), + constraint pk_album primary key (id) +); + +create table animal ( + species varchar(255) not null, + id bigint auto_increment not null, + shelter_id bigint, + version bigint not null, + name varchar(255), + registration_number varchar(255), + date_of_birth date, + dog_size varchar(255), + constraint pk_animal primary key (id) +); + +create table animal_shelter ( + id bigint auto_increment not null, + name varchar(255), + version bigint not null, + constraint pk_animal_shelter primary key (id) +); + +create table article ( + id integer auto_increment not null, + name varchar(255), + author varchar(255), + cretime datetime(6) not null, + updtime datetime(6) not null, + version bigint not null, + constraint pk_article primary key (id) +); + +create table attribute ( + option_type integer(31) not null, + id integer auto_increment not null, + attribute_holder_id integer, + cretime datetime(6) not null, + updtime datetime(6) not null, + version bigint not null, + constraint pk_attribute primary key (id) +); + +create table attribute_holder ( + id integer auto_increment not null, + cretime datetime(6) not null, + updtime datetime(6) not null, + version bigint not null, + constraint pk_attribute_holder primary key (id) +); + +create table audit_log ( + id bigint auto_increment not null, + description varchar(255), + modified_description varchar(255), + constraint pk_audit_log primary key (id) +); + +create table bbookmark ( + id integer auto_increment not null, + bookmark_reference varchar(255), + user_id integer, + constraint pk_bbookmark primary key (id) +); + +create table bbookmark_org ( + id integer auto_increment not null, + name varchar(255), + constraint pk_bbookmark_org primary key (id) +); + +create table bbookmark_user ( + id integer auto_increment not null, + name varchar(255), + password varchar(255), + email_address varchar(255), + country varchar(255), + org_id integer, + constraint pk_bbookmark_user primary key (id) +); + +create table bsimple_with_gen ( + id integer auto_increment not null, + name varchar(255), + constraint pk_bsimple_with_gen primary key (id) +); + +create table bsite ( + id varchar(40) not null, + name varchar(255), + constraint pk_bsite primary key (id) +); + +create table bsite_user_a ( + site_id varchar(40) not null, + user_id varchar(40) not null, + access_level integer, + version bigint not null, + constraint pk_bsite_user_a primary key (site_id,user_id) +); + +create table bsite_user_b ( + site varchar(40) not null, + usr varchar(40) not null, + access_level integer, + constraint pk_bsite_user_b primary key (site,usr) +); + +create table bsite_user_c ( + site_uid varchar(40) not null, + user_uid varchar(40) not null, + access_level integer, + constraint pk_bsite_user_c primary key (site_uid,user_uid) +); + +create table bsite_user_d ( + site_id varchar(40) not null, + user_id varchar(40) not null, + access_level integer, + version bigint not null +); + +create table bsite_user_e ( + site_id varchar(40) not null, + user_id varchar(40) not null, + access_level integer +); + +create table buser ( + id varchar(40) not null, + name varchar(255), + constraint pk_buser primary key (id) +); + +create table bwith_qident ( + id integer auto_increment not null, + `Name` varchar(191), + `CODE` varchar(255), + last_updated datetime(6) not null, + constraint uq_bwith_qident_name unique (`Name`), + constraint pk_bwith_qident primary key (id) +); + +create table basic_draftable_bean ( + id bigint auto_increment not null, + name varchar(255), + version bigint not null, + when_created datetime(6) not null, + when_modified datetime(6) not null, + constraint pk_basic_draftable_bean primary key (id) +); + +create table basic_draftable_bean_draft ( + id bigint auto_increment not null, + name varchar(255), + version bigint not null, + when_created datetime(6) not null, + when_modified datetime(6) not null, + constraint pk_basic_draftable_bean_draft primary key (id) +); + +create table basic_joda_entity ( + id bigint auto_increment not null, + name varchar(255), + period varchar(50), + local_date date, + created datetime(6) not null, + updated datetime(6) not null, + version datetime(6) not null, + constraint pk_basic_joda_entity primary key (id) +); + +create table bean_with_time_zone ( + id bigint auto_increment not null, + name varchar(255), + timezone varchar(20), + constraint pk_bean_with_time_zone primary key (id) +); + +create table drel_booking ( + id bigint auto_increment not null, + booking_uid bigint, + agent_invoice bigint, + client_invoice bigint, + version integer not null, + constraint uq_drel_booking_booking_uid unique (booking_uid), + constraint uq_drel_booking_agent_invoice unique (agent_invoice), + constraint uq_drel_booking_client_invoice unique (client_invoice), + constraint pk_drel_booking primary key (id) +); + +create table bw_bean ( + id bigint auto_increment not null, + name varchar(255), + flags integer not null, + version bigint not null, + constraint pk_bw_bean primary key (id) +); + +create table cepcategory ( + id bigint auto_increment not null, + name varchar(255), + version bigint not null, + constraint pk_cepcategory primary key (id) +); + +create table cepproduct ( + id bigint auto_increment not null, + name varchar(255), + version bigint not null, + constraint pk_cepproduct primary key (id) +); + +create table cepproduct_category ( + customer_id bigint not null, + address_id bigint not null, + category_id bigint not null, + product_id bigint not null, + priority integer +); + +create table cinh_ref ( + id integer auto_increment not null, + ref_id integer, + cretime datetime(6) not null, + updtime datetime(6) not null, + version bigint not null, + constraint pk_cinh_ref primary key (id) +); + +create table cinh_root ( + dtype varchar(3) not null, + id integer auto_increment not null, + license_number varchar(255), + cretime datetime(6) not null, + updtime datetime(6) not null, + version bigint not null, + driver varchar(255), + notes varchar(255), + action varchar(255), + constraint pk_cinh_root primary key (id) +); + +create table ckey_assoc ( + id integer auto_increment not null, + assoc_one varchar(255), + constraint pk_ckey_assoc primary key (id) +); + +create table ckey_detail ( + id integer auto_increment not null, + something varchar(255), + one_key integer, + two_key varchar(127), + constraint pk_ckey_detail primary key (id) +); + +create table ckey_parent ( + one_key integer not null, + two_key varchar(127) not null, + name varchar(255), + assoc_id integer, + version integer not null, + constraint pk_ckey_parent primary key (one_key,two_key) +); + +create table coone ( + id bigint auto_increment not null, + name varchar(255), + constraint pk_coone primary key (id) +); + +create table coone_many ( + id bigint auto_increment not null, + coone_id bigint not null, + name varchar(255), + deleted tinyint(1) default 0 not null, + constraint pk_coone_many primary key (id) +); + +create table coroot ( + id bigint auto_increment not null, + name varchar(255), + one_id bigint, + constraint uq_coroot_one_id unique (one_id), + constraint pk_coroot primary key (id) +); + +create table calculation_result ( + id integer auto_increment not null, + charge double not null, + product_configuration_id integer, + group_configuration_id integer, + constraint pk_calculation_result primary key (id) +); + +create table cao_bean ( + x_cust_id integer not null, + x_type_id integer not null, + description varchar(255), + version bigint not null, + constraint pk_cao_bean primary key (x_cust_id,x_type_id) +); + +create table sp_car_car ( + id bigint auto_increment not null, + name varchar(255), + version integer not null, + constraint pk_sp_car_car primary key (id) +); + +create table sp_car_car_wheels ( + car bigint not null, + wheel bigint not null, + constraint pk_sp_car_car_wheels primary key (car,wheel) +); + +create table sp_car_car_doors ( + car bigint not null, + door bigint not null, + constraint pk_sp_car_car_doors primary key (car,door) +); + +create table sa_car ( + id bigint auto_increment not null, + brand varchar(255), + sold integer not null, + version integer not null, + constraint pk_sa_car primary key (id) +); + +create table car_accessory ( + id integer auto_increment not null, + name varchar(255), + fuse_id bigint not null, + car_id integer, + cretime datetime(6) not null, + updtime datetime(6) not null, + version bigint not null, + constraint pk_car_accessory primary key (id) +); + +create table car_fuse ( + id bigint auto_increment not null, + location_code varchar(255), + constraint pk_car_fuse primary key (id) +); + +create table category ( + id bigint auto_increment not null, + name varchar(255), + surveyobjectid bigint, + sequence_number integer not null, + constraint pk_category primary key (id) +); + +create table e_save_test_d ( + id bigint auto_increment not null, + parent_id bigint, + test_property tinyint(1) default 0 not null, + version bigint not null, + constraint uq_e_save_test_d_parent_id unique (parent_id), + constraint pk_e_save_test_d primary key (id) +); + +create table child_person ( + identifier integer auto_increment not null, + name varchar(255), + age integer, + some_bean_id integer, + parent_identifier integer, + family_name varchar(255), + address varchar(255), + constraint pk_child_person primary key (identifier) +); + +create table cke_client ( + cod_cpny integer not null, + cod_client varchar(100) not null, + username varchar(100) not null, + notes varchar(255), + constraint pk_cke_client primary key (cod_cpny,cod_client) +); + +create table cke_user ( + username varchar(100) not null, + cod_cpny integer not null, + name varchar(255), + constraint pk_cke_user primary key (username,cod_cpny) +); + +create table class_super ( + dtype varchar(31) not null, + sid bigint auto_increment not null, + constraint pk_class_super primary key (sid) +); + +create table class_super_monkey ( + class_super_sid bigint not null, + monkey_mid bigint not null, + constraint uq_class_super_monkey_mid unique (monkey_mid), + constraint pk_class_super_monkey primary key (class_super_sid,monkey_mid) +); + +create table configuration ( + type varchar(21) not null, + id integer auto_increment not null, + name varchar(255), + configurations_id integer, + group_name varchar(255), + product_name varchar(255), + constraint pk_configuration primary key (id) +); + +create table configurations ( + id integer auto_increment not null, + name varchar(255), + constraint pk_configurations primary key (id) +); + +create table contact ( + id integer auto_increment not null, + first_name varchar(127), + last_name varchar(127), + phone varchar(255), + mobile varchar(255), + email varchar(255), + is_member tinyint(1) default 0 not null, + customer_id integer not null, + group_id integer, + cretime datetime(6) not null, + updtime datetime(6) not null, + constraint pk_contact primary key (id) +); + +create table contact_group ( + id integer auto_increment not null, + name varchar(255), + cretime datetime(6) not null, + updtime datetime(6) not null, + version bigint not null, + constraint pk_contact_group primary key (id) +); + +create table contact_note ( + id integer auto_increment not null, + contact_id integer, + title varchar(255), + note longtext, + cretime datetime(6) not null, + updtime datetime(6) not null, + version bigint not null, + constraint pk_contact_note primary key (id) +); + +create table contract ( + id bigint auto_increment not null, + name varchar(255), + constraint pk_contract primary key (id) +); + +create table contract_costs ( + id bigint auto_increment not null, + status varchar(255), + position_id bigint not null, + constraint pk_contract_costs primary key (id) +); + +create table c_conversation ( + id bigint auto_increment not null, + title varchar(255), + isopen tinyint(1) default 0 not null, + group_id bigint, + version bigint not null, + when_created datetime(6) not null, + when_modified datetime(6) not null, + constraint pk_c_conversation primary key (id) +); + +create table o_country ( + code varchar(2) not null, + name varchar(60), + constraint pk_o_country primary key (code) +); + +create table cover ( + id bigint auto_increment not null, + s3_url varchar(255), + deleted tinyint(1) default 0 not null, + constraint pk_cover primary key (id) +); + +create table o_customer ( + id integer auto_increment not null, + status varchar(1) comment 'status of the customer', + name varchar(40) not null, + smallnote varchar(100) comment 'Short notes regarding the customer', + anniversary date comment 'Join date of the customer', + billing_address_id integer, + shipping_address_id integer, + cretime datetime(6) not null, + updtime datetime(6) not null, + version bigint not null, + constraint pk_o_customer primary key (id) +) comment='Holds external customers'; + +create table dcredit ( + id bigint auto_increment not null, + credit varchar(255), + constraint pk_dcredit primary key (id) +); + +create table dcredit_drol ( + dcredit_id bigint not null, + drol_id bigint not null, + constraint pk_dcredit_drol primary key (dcredit_id,drol_id) +); + +create table dexh_entity ( + oid bigint auto_increment not null, + exhange varchar(255), + an_enum_type varchar(255), + last_updated datetime(6) not null, + constraint pk_dexh_entity primary key (oid) +); + +create table dint_parent ( + type integer(31) not null, + id bigint auto_increment not null, + val integer, + more varchar(255), + constraint pk_dint_parent primary key (id) +); + +create table dmachine ( + id bigint auto_increment not null, + name varchar(255), + organisation_id bigint, + version bigint not null, + constraint pk_dmachine primary key (id) +); + +create table d_machine_aux_use ( + id bigint auto_increment not null, + machine_id bigint not null, + name varchar(255), + edate date, + use_secs bigint not null, + fuel decimal(38), + version bigint not null, + constraint pk_d_machine_aux_use primary key (id) +); + +create table d_machine_stats ( + id bigint auto_increment not null, + machine_id bigint not null, + edate date, + total_kms bigint not null, + hours bigint not null, + rate decimal(38), + cost decimal(38), + version bigint not null, + constraint pk_d_machine_stats primary key (id) +); + +create table d_machine_use ( + id bigint auto_increment not null, + machine_id bigint not null, + edate date, + distance_kms bigint not null, + time_secs bigint not null, + fuel decimal(38), + version bigint not null, + constraint pk_d_machine_use primary key (id) +); + +create table dorg ( + id bigint auto_increment not null, + name varchar(255), + version bigint not null, + constraint pk_dorg primary key (id) +); + +create table dperson ( + id bigint auto_increment not null, + first_name varchar(255), + last_name varchar(255), + salary decimal(38), + constraint pk_dperson primary key (id) +); + +create table drol ( + id bigint auto_increment not null, + name varchar(255), + constraint pk_drol primary key (id) +); + +create table drot ( + id bigint auto_increment not null, + name varchar(255), + constraint pk_drot primary key (id) +); + +create table drot_drol ( + drot_id bigint not null, + drol_id bigint not null, + constraint pk_drot_drol primary key (drot_id,drol_id) +); + +create table rawinherit_data ( + id bigint auto_increment not null, + val integer, + constraint pk_rawinherit_data primary key (id) +); + +create table data_container ( + id varchar(40) not null, + content varchar(255), + constraint pk_data_container primary key (id) +); + +create table dc_detail ( + id bigint auto_increment not null, + master_id bigint, + description varchar(255), + version bigint not null, + constraint pk_dc_detail primary key (id) +); + +create table dc_master ( + id bigint auto_increment not null, + name varchar(255), + version bigint not null, + constraint pk_dc_master primary key (id) +); + +create table dfk_cascade ( + id bigint auto_increment not null, + name varchar(255), + one_id bigint, + constraint pk_dfk_cascade primary key (id) +); + +create table dfk_cascade_one ( + id bigint auto_increment not null, + name varchar(255), + constraint pk_dfk_cascade_one primary key (id) +); + +create table dfk_none ( + id bigint auto_increment not null, + name varchar(255), + one_id bigint, + constraint pk_dfk_none primary key (id) +); + +create table dfk_none_via_join ( + id bigint auto_increment not null, + name varchar(255), + one_id bigint, + constraint pk_dfk_none_via_join primary key (id) +); + +create table dfk_none_via_mto_m ( + id bigint auto_increment not null, + name varchar(255), + constraint pk_dfk_none_via_mto_m primary key (id) +); + +create table dfk_none_via_mto_m_dfk_one ( + dfk_none_via_mto_m_id bigint not null, + dfk_one_id bigint not null, + constraint pk_dfk_none_via_mto_m_dfk_one primary key (dfk_none_via_mto_m_id,dfk_one_id) +); + +create table dfk_one ( + id bigint auto_increment not null, + name varchar(255), + constraint pk_dfk_one primary key (id) +); + +create table dfk_set_null ( + id bigint auto_increment not null, + name varchar(255), + one_id bigint, + constraint pk_dfk_set_null primary key (id) +); + +create table doc ( + id bigint auto_increment not null, + name varchar(255), + version bigint not null, + when_created datetime(6) not null, + when_modified datetime(6) not null, + constraint pk_doc primary key (id) +); + +create table doc_link ( + doc_id bigint not null, + link_id bigint not null, + constraint pk_doc_link primary key (doc_id,link_id) +); + +create table doc_link_draft ( + doc_id bigint not null, + link_id bigint not null, + constraint pk_doc_link_draft primary key (doc_id,link_id) +); + +create table doc_draft ( + id bigint auto_increment not null, + name varchar(255), + version bigint not null, + when_created datetime(6) not null, + when_modified datetime(6) not null, + constraint pk_doc_draft primary key (id) +); + +create table document ( + id bigint auto_increment not null, + title varchar(127), + body varchar(255), + organisation_id bigint, + version bigint not null, + when_created datetime(6) not null, + when_modified datetime(6) not null, + constraint uq_document_title unique (title), + constraint pk_document primary key (id) +); + +create table document_draft ( + id bigint auto_increment not null, + title varchar(127), + body varchar(255), + when_publish datetime(6), + organisation_id bigint, + version bigint not null, + when_created datetime(6) not null, + when_modified datetime(6) not null, + constraint uq_document_draft_title unique (title), + constraint pk_document_draft primary key (id) +); + +create table document_media ( + id bigint auto_increment not null, + document_id bigint, + name varchar(255), + description varchar(255), + version bigint not null, + when_created datetime(6) not null, + when_modified datetime(6) not null, + constraint pk_document_media primary key (id) +); + +create table document_media_draft ( + id bigint auto_increment not null, + document_id bigint, + name varchar(255), + description varchar(255), + version bigint not null, + when_created datetime(6) not null, + when_modified datetime(6) not null, + constraint pk_document_media_draft primary key (id) +); + +create table sp_car_door ( + id bigint auto_increment not null, + name varchar(255), + version integer not null, + constraint pk_sp_car_door primary key (id) +); + +create table earray_bean ( + id bigint auto_increment not null, + foo integer, + name varchar(255), + phone_numbers varchar(300), + uids varchar(1000) not null, + other_ids varchar(1000), + doubs varchar(1000), + statuses varchar(1000), + vc_enums varchar(1000), + int_enums varchar(1000), + status2 varchar(1000), + version bigint not null, + constraint pk_earray_bean primary key (id) +); + +create table earray_set_bean ( + id bigint auto_increment not null, + name varchar(255), + phone_numbers varchar(300), + uids varchar(1000), + other_ids varchar(1000), + doubs varchar(1000), + version bigint not null, + constraint pk_earray_set_bean primary key (id) +); + +create table e_basic ( + id integer auto_increment not null, + status varchar(1), + name varchar(127), + description varchar(255), + some_date datetime(6), + constraint pk_e_basic primary key (id) +); + +create table ebasic_change_log ( + id bigint auto_increment not null, + name varchar(20), + short_description varchar(50), + long_description varchar(100), + who_created varchar(255) not null, + who_modified varchar(255) not null, + when_created datetime(6) not null, + when_modified datetime(6) not null, + version bigint not null, + constraint pk_ebasic_change_log primary key (id) +); + +create table ebasic_clob ( + id bigint auto_increment not null, + name varchar(255), + title varchar(255), + description longtext, + last_update datetime(6) not null, + constraint pk_ebasic_clob primary key (id) +); + +create table ebasic_clob_fetch_eager ( + id bigint auto_increment not null, + name varchar(255), + title varchar(255), + description longtext, + last_update datetime(6) not null, + constraint pk_ebasic_clob_fetch_eager primary key (id) +); + +create table ebasic_clob_no_ver ( + id bigint auto_increment not null, + name varchar(255), + description longtext, + constraint pk_ebasic_clob_no_ver primary key (id) +); + +create table e_basicenc ( + id integer auto_increment not null, + name varchar(255), + description varbinary(80), + dob varbinary(20), + status varbinary(20), + last_update datetime(6), + constraint pk_e_basicenc primary key (id) +); + +create table e_basicenc_bin ( + id integer auto_increment not null, + name varchar(255), + description varchar(255), + data longblob, + some_time varbinary(255), + last_update datetime(6) not null, + constraint pk_e_basicenc_bin primary key (id) +); + +create table e_basicenc_client ( + id bigint auto_increment not null, + name varchar(255), + description varbinary(80), + dob varbinary(20), + status varbinary(20), + version bigint not null, + constraint pk_e_basicenc_client primary key (id) +); + +create table e_basicenc_relate ( + id bigint auto_increment not null, + name varchar(255), + other_id integer, + constraint pk_e_basicenc_relate primary key (id) +); + +create table e_basic_enum_id ( + status varchar(1) not null, + name varchar(255), + description varchar(255), + constraint pk_e_basic_enum_id primary key (status) +); + +create table e_basic_eni ( + id integer auto_increment not null, + status integer, + name varchar(255), + description varchar(255), + some_date datetime(6), + constraint pk_e_basic_eni primary key (id) +); + +create table ebasic_hstore ( + id bigint auto_increment not null, + name varchar(255), + map varchar(800), + version bigint not null, + constraint pk_ebasic_hstore primary key (id) +); + +create table ebasic_json_jackson ( + id bigint auto_increment not null, + name varchar(255), + value_set json, + value_list json, + value_map json, + plain_value json, + version bigint not null, + constraint pk_ebasic_json_jackson primary key (id) +); + +create table ebasic_json_jackson2 ( + id bigint auto_increment not null, + name varchar(255), + value_set json, + value_list json, + value_map json, + plain_value json, + version bigint not null, + constraint pk_ebasic_json_jackson2 primary key (id) +); + +create table ebasic_json_list ( + id bigint auto_increment not null, + name varchar(255), + bean_set json, + bean_list json, + bean_map json, + plain_bean json, + flags json, + tags varchar(100), + version bigint not null, + constraint pk_ebasic_json_list primary key (id) +); + +create table ebasic_json_map ( + id bigint auto_increment not null, + name varchar(255), + content json, + version bigint not null, + constraint pk_ebasic_json_map primary key (id) +); + +create table ebasic_json_map_blob ( + id bigint auto_increment not null, + name varchar(255), + content longblob, + version bigint not null, + constraint pk_ebasic_json_map_blob primary key (id) +); + +create table ebasic_json_map_clob ( + id bigint auto_increment not null, + name varchar(255), + content longtext, + version bigint not null, + constraint pk_ebasic_json_map_clob primary key (id) +); + +create table ebasic_json_map_detail ( + id bigint auto_increment not null, + owner_id bigint, + name varchar(255), + content json, + version bigint not null, + constraint pk_ebasic_json_map_detail primary key (id) +); + +create table ebasic_json_map_json_b ( + id bigint auto_increment not null, + name varchar(255), + content json, + version bigint not null, + constraint pk_ebasic_json_map_json_b primary key (id) +); + +create table ebasic_json_map_varchar ( + id bigint auto_increment not null, + name varchar(255), + content varchar(3000), + version bigint not null, + constraint pk_ebasic_json_map_varchar primary key (id) +); + +create table ebasic_json_node ( + id bigint auto_increment not null, + name varchar(255), + content json, + version bigint not null, + constraint pk_ebasic_json_node primary key (id) +); + +create table ebasic_json_node_blob ( + id bigint auto_increment not null, + name varchar(255), + content longblob, + version bigint not null, + constraint pk_ebasic_json_node_blob primary key (id) +); + +create table ebasic_json_node_json_b ( + id bigint auto_increment not null, + name varchar(255), + content json, + version bigint not null, + constraint pk_ebasic_json_node_json_b primary key (id) +); + +create table ebasic_json_node_varchar ( + id bigint auto_increment not null, + name varchar(255), + content varchar(1000), + version bigint not null, + constraint pk_ebasic_json_node_varchar primary key (id) +); + +create table ebasic_json_unmapped ( + id bigint auto_increment not null, + name varchar(255), + version bigint not null, + constraint pk_ebasic_json_unmapped primary key (id) +); + +create table e_basic_ndc ( + id integer auto_increment not null, + name varchar(255), + constraint pk_e_basic_ndc primary key (id) +); + +create table ebasic_no_sdchild ( + id bigint auto_increment not null, + owner_id bigint not null, + child_name varchar(255), + amount bigint not null, + version bigint not null, + constraint pk_ebasic_no_sdchild primary key (id) +); + +create table ebasic_sdchild ( + id bigint auto_increment not null, + owner_id bigint not null, + child_name varchar(255), + amount bigint not null, + version bigint not null, + deleted tinyint(1) default 0 not null, + constraint pk_ebasic_sdchild primary key (id) +); + +create table ebasic_soft_delete ( + id bigint auto_increment not null, + name varchar(255), + description varchar(255), + version bigint not null, + deleted tinyint(1) default 0 not null, + constraint pk_ebasic_soft_delete primary key (id) +); + +create table e_basicver ( + id integer auto_increment not null, + name varchar(255), + description varchar(255), + other varchar(255), + last_update datetime(6) not null, + constraint pk_e_basicver primary key (id) +); + +create table e_basic_withlife ( + id bigint auto_increment not null, + name varchar(255), + other varchar(255), + deleted tinyint(1) default 0 not null, + version bigint not null, + constraint pk_e_basic_withlife primary key (id) +); + +create table e_basic_with_ex ( + id bigint auto_increment not null, + deleted tinyint(1) default 0 not null, + version bigint not null, + constraint pk_e_basic_with_ex primary key (id) +); + +create table e_basicverucon ( + id integer auto_increment not null, + name varchar(127), + other varchar(127), + other_one varchar(127), + description varchar(255), + last_update datetime(6) not null, + constraint uq_e_basicverucon_name unique (name), + constraint uq_e_basicverucon_other_other_one unique (other,other_one), + constraint pk_e_basicverucon primary key (id) +); + +create table ecache_child ( + id varchar(40) not null, + name varchar(100), + root_id varchar(40) not null, + constraint pk_ecache_child primary key (id) +); + +create table ecache_root ( + id varchar(40) not null, + name varchar(100), + constraint pk_ecache_root primary key (id) +); + +create table e_col_ab ( + id bigint auto_increment not null, + column_a varchar(255), + column_b varchar(255), + constraint pk_e_col_ab primary key (id) +); + +create table ecustom_id ( + id varchar(127) not null, + name varchar(255), + constraint pk_ecustom_id primary key (id) +); + +create table edefault_prop ( + id integer auto_increment not null, + e_simple_usertypeid integer, + name varchar(255), + constraint uq_edefault_prop_e_simple_usertypeid unique (e_simple_usertypeid), + constraint pk_edefault_prop primary key (id) +); + +create table eemb_inner ( + id integer auto_increment not null, + nome_inner varchar(255), + outer_id integer, + update_count integer not null, + constraint pk_eemb_inner primary key (id) +); + +create table eemb_outer ( + id integer auto_increment not null, + nome_outer varchar(255), + date1 datetime(6), + date2 datetime(6), + update_count integer not null, + constraint pk_eemb_outer primary key (id) +); + +create table efile2_no_fk ( + file_name varchar(64) not null, + owner_id integer not null, + constraint pk_efile2_no_fk primary key (file_name) +); + +create table efile_no_fk ( + file_name varchar(64) not null, + owner_user_id integer, + owner_soft_del_user_id integer, + constraint pk_efile_no_fk primary key (file_name) +); + +create table efile_no_fk_euser_no_fk ( + efile_no_fk_file_name varchar(64) not null, + euser_no_fk_user_id integer not null, + constraint pk_efile_no_fk_euser_no_fk primary key (efile_no_fk_file_name,euser_no_fk_user_id) +); + +create table efile_no_fk_euser_no_fk_soft_del ( + efile_no_fk_file_name varchar(64) not null, + euser_no_fk_soft_del_user_id integer not null, + constraint pk_efile_no_fk_euser_no_fk_soft_del primary key (efile_no_fk_file_name,euser_no_fk_soft_del_user_id) +); + +create table egen_props ( + id bigint auto_increment not null, + name varchar(255), + version bigint not null, + when_created datetime(6) not null, + when_modified datetime(6) not null, + ts_created datetime(6) not null, + ts_updated datetime(6) not null, + ldt_created datetime(6) not null, + ldt_updated datetime(6) not null, + odt_created datetime(6) not null, + odt_updated datetime(6) not null, + zdt_created datetime(6) not null, + zdt_updated datetime(6) not null, + instant_created datetime(6) not null, + instant_updated datetime(6) not null, + long_created bigint not null, + long_updated bigint not null, + constraint pk_egen_props primary key (id) +); + +create table eid_uid_bean ( + id bigint auto_increment not null, + uuid varchar(40) not null, + name varchar(255), + constraint uq_eid_uid_bean_uuid unique (uuid), + constraint pk_eid_uid_bean primary key (id) +); + +create table einvoice ( + id bigint auto_increment not null, + invoice_date datetime(6), + state integer, + person_id bigint, + ship_street varchar(255), + ship_suburb varchar(255), + ship_city varchar(255), + ship_status varchar(3), + bill_street varchar(255), + bill_suburb varchar(255), + bill_city varchar(255), + bill_status varchar(3), + version bigint not null, + constraint pk_einvoice primary key (id) +); + +create table e_main ( + id integer auto_increment not null, + name varchar(255), + description varchar(255), + version bigint not null, + constraint pk_e_main primary key (id) +); + +create table enull_collection ( + id integer auto_increment not null, + name varchar(255), + constraint pk_enull_collection primary key (id) +); + +create table enull_collection_detail ( + id integer auto_increment not null, + enull_collection_id integer not null, + something varchar(255), + constraint pk_enull_collection_detail primary key (id) +); + +create table eopt_one_a ( + id integer auto_increment not null, + name_for_a varchar(255), + b_id integer, + cretime datetime(6) not null, + updtime datetime(6) not null, + version bigint not null, + constraint pk_eopt_one_a primary key (id) +); + +create table eopt_one_b ( + id integer auto_increment not null, + name_for_b varchar(255), + c_id integer not null, + cretime datetime(6) not null, + updtime datetime(6) not null, + version bigint not null, + constraint pk_eopt_one_b primary key (id) +); + +create table eopt_one_c ( + id integer auto_increment not null, + name_for_c varchar(255), + cretime datetime(6) not null, + updtime datetime(6) not null, + version bigint not null, + constraint pk_eopt_one_c primary key (id) +); + +create table eper_addr ( + id bigint auto_increment not null, + name varchar(255), + ma_street varchar(255), + ma_suburb varchar(255), + ma_city varchar(255), + ma_country_code varchar(2), + version bigint not null, + constraint pk_eper_addr primary key (id) +); + +create table eperson ( + id bigint auto_increment not null, + name varchar(255), + notes varchar(255), + street varchar(255), + suburb varchar(255), + addr_city varchar(255), + addr_status varchar(3), + version bigint not null, + constraint pk_eperson primary key (id) +); + +create table e_person_online ( + id bigint auto_increment not null, + email varchar(127), + online_status tinyint(1) default 0 not null, + when_updated datetime(6) not null, + constraint uq_e_person_online_email unique (email), + constraint pk_e_person_online primary key (id) +); + +create table esimple ( + usertypeid integer auto_increment not null, + name varchar(255), + constraint pk_esimple primary key (usertypeid) +); + +create table esoft_del_book ( + id bigint auto_increment not null, + book_title varchar(255), + lend_by_id bigint, + version bigint not null, + deleted tinyint(1) default 0 not null, + constraint pk_esoft_del_book primary key (id) +); + +create table esoft_del_book_esoft_del_user ( + esoft_del_book_id bigint not null, + esoft_del_user_id bigint not null, + constraint pk_esoft_del_book_esoft_del_user primary key (esoft_del_book_id,esoft_del_user_id) +); + +create table esoft_del_down ( + id bigint auto_increment not null, + esoft_del_mid_id bigint not null, + down varchar(255), + version bigint not null, + deleted tinyint(1) default 0 not null, + constraint pk_esoft_del_down primary key (id) +); + +create table esoft_del_mid ( + id bigint auto_increment not null, + top_id bigint, + mid varchar(255), + up_id bigint, + version bigint not null, + deleted tinyint(1) default 0 not null, + constraint pk_esoft_del_mid primary key (id) +); + +create table esoft_del_one_a ( + id bigint auto_increment not null, + name varchar(255), + oneb_id bigint, + deleted tinyint(1) default 0 not null, + version bigint not null, + constraint uq_esoft_del_one_a_oneb_id unique (oneb_id), + constraint pk_esoft_del_one_a primary key (id) +); + +create table esoft_del_one_b ( + id bigint auto_increment not null, + name varchar(255), + version bigint not null, + constraint pk_esoft_del_one_b primary key (id) +); + +create table esoft_del_role ( + id bigint auto_increment not null, + role_name varchar(255), + version bigint not null, + deleted tinyint(1) default 0 not null, + constraint pk_esoft_del_role primary key (id) +); + +create table esoft_del_role_esoft_del_user ( + esoft_del_role_id bigint not null, + esoft_del_user_id bigint not null, + constraint pk_esoft_del_role_esoft_del_user primary key (esoft_del_role_id,esoft_del_user_id) +); + +create table esoft_del_top ( + id bigint auto_increment not null, + name varchar(255), + version bigint not null, + deleted tinyint(1) default 0 not null, + constraint pk_esoft_del_top primary key (id) +); + +create table esoft_del_up ( + id bigint auto_increment not null, + up varchar(255), + version bigint not null, + deleted tinyint(1) default 0 not null, + constraint pk_esoft_del_up primary key (id) +); + +create table esoft_del_user ( + id bigint auto_increment not null, + user_name varchar(255), + version bigint not null, + deleted tinyint(1) default 0 not null, + constraint pk_esoft_del_user primary key (id) +); + +create table esoft_del_user_esoft_del_role ( + esoft_del_user_id bigint not null, + esoft_del_role_id bigint not null, + constraint pk_esoft_del_user_esoft_del_role primary key (esoft_del_user_id,esoft_del_role_id) +); + +create table esome_convert_type ( + id bigint auto_increment not null, + name varchar(255), + money decimal(38), + constraint pk_esome_convert_type primary key (id) +); + +create table esome_type ( + id integer auto_increment not null, + currency varchar(3), + locale varchar(20), + time_zone varchar(20), + constraint pk_esome_type primary key (id) +); + +create table etrans_many ( + id integer auto_increment not null, + name varchar(255), + constraint pk_etrans_many primary key (id) +); + +create table rawinherit_uncle ( + id integer auto_increment not null, + name varchar(255), + parent_id bigint not null, + version bigint not null, + constraint pk_rawinherit_uncle primary key (id) +); + +create table euser_no_fk ( + user_id integer auto_increment not null, + user_name varchar(255), + constraint pk_euser_no_fk primary key (user_id) +); + +create table euser_no_fk_soft_del ( + user_id integer auto_increment not null, + user_name varchar(255), + constraint pk_euser_no_fk_soft_del primary key (user_id) +); + +create table evanilla_collection ( + id integer auto_increment not null, + name varchar(255), + constraint pk_evanilla_collection primary key (id) +); + +create table evanilla_collection_detail ( + id integer auto_increment not null, + evanilla_collection_id integer not null, + something varchar(255), + constraint pk_evanilla_collection_detail primary key (id) +); + +create table ewho_props ( + id bigint auto_increment not null, + name varchar(255), + version bigint not null, + when_created datetime(6) not null, + when_modified datetime(6) not null, + who_created varchar(255) not null, + who_modified varchar(255) not null, + constraint pk_ewho_props primary key (id) +); + +create table e_withinet ( + id bigint auto_increment not null, + name varchar(255), + inet_address varchar(50), + inet2 varchar(255), + cidr varchar(50), + version bigint not null, + constraint pk_e_withinet primary key (id) +); + +create table ec_enum_person ( + id bigint auto_increment not null, + name varchar(255), + version bigint not null, + constraint pk_ec_enum_person primary key (id) +); + +create table ec_enum_person_tags ( + ec_enum_person_id bigint not null, + value varchar(5) not null +); + +create table ec_person ( + id bigint auto_increment not null, + name varchar(255), + version bigint not null, + constraint pk_ec_person primary key (id) +); + +create table ec_person_phone ( + owner_id bigint not null, + phone varchar(255) not null +); + +create table ec_top ( + id bigint auto_increment not null, + name varchar(255), + person_id bigint, + version bigint not null, + constraint pk_ec_top primary key (id) +); + +create table ec_top_ecs_person ( + ec_top_id bigint not null, + ecs_person_id bigint not null, + constraint pk_ec_top_ecs_person primary key (ec_top_id,ecs_person_id) +); + +create table ecbl_person ( + id bigint auto_increment not null, + name varchar(255), + version bigint not null, + constraint pk_ecbl_person primary key (id) +); + +create table ecbl_person_phone_numbers ( + person_id bigint not null, + country_code varchar(2), + area varchar(6), + phnum varchar(20) +); + +create table ecbm_person ( + id bigint auto_increment not null, + name varchar(255), + version bigint not null, + constraint pk_ecbm_person primary key (id) +); + +create table ecbm_person_phone_numbers ( + person_id bigint not null, + mkey varchar(255) not null, + country_code varchar(2), + area varchar(6), + phnum varchar(20) +); + +create table ecm_person ( + id bigint auto_increment not null, + name varchar(255), + version bigint not null, + constraint pk_ecm_person primary key (id) +); + +create table ecm_person_phone_numbers ( + ecm_person_id bigint not null, + type varchar(4) not null, + phnum varchar(10) not null +); + +create table ecmc_person ( + id bigint auto_increment not null, + name varchar(255), + version bigint not null, + constraint pk_ecmc_person primary key (id) +); + +create table ecmc_person_phone_numbers ( + ecmc_person_id bigint not null, + type varchar(4) not null, + value longtext not null +); + +create table ecs_person ( + id bigint auto_increment not null, + name varchar(255), + version bigint not null, + constraint pk_ecs_person primary key (id) +); + +create table ecs_person_phone ( + ecs_person_id bigint not null, + phone varchar(255) not null +); + +create table ecsm_child ( + one_id varchar(40) not null, + ecsm_parent_id bigint not null, + name varchar(255), + version bigint not null, + constraint pk_ecsm_child primary key (one_id) +); + +create table ecsm_values ( + host_id varchar(40) not null, + value varchar(255) not null +); + +create table ecsm_one ( + one_id varchar(40) not null, + name varchar(255), + version bigint not null, + constraint pk_ecsm_one primary key (one_id) +); + +create table ecsm_parent ( + id bigint auto_increment not null, + name varchar(255), + version bigint not null, + constraint pk_ecsm_parent primary key (id) +); + +create table ecsm_two ( + id varchar(40) not null, + name varchar(255), + version bigint not null, + constraint pk_ecsm_two primary key (id) +); + +create table td_child ( + child_id integer auto_increment not null, + child_name varchar(255), + parent_id integer not null, + constraint pk_td_child primary key (child_id) +); + +create table td_parent ( + parent_type varchar(31) not null, + parent_id integer auto_increment not null, + parent_name varchar(255), + extended_name varchar(255), + constraint pk_td_parent primary key (parent_id) +); + +create table element_bean ( + id bigint auto_increment not null, + complex_bean_id varchar(40) not null, + value varchar(255) not null, + constraint pk_element_bean primary key (id) +); + +create table empl ( + id bigint auto_increment not null, + name varchar(255), + age integer, + default_address_id bigint, + constraint pk_empl primary key (id) +); + +create table esd_detail ( + id bigint auto_increment not null, + name varchar(255), + master_id bigint not null, + version bigint not null, + deleted tinyint(1) default 0 not null, + constraint pk_esd_detail primary key (id) +); + +create table esd_master ( + id bigint auto_increment not null, + name varchar(255), + version bigint not null, + deleted tinyint(1) default 0 not null, + constraint pk_esd_master primary key (id) +); + +create table feature_desc ( + id integer auto_increment not null, + name varchar(255), + description varchar(255), + constraint pk_feature_desc primary key (id) +); + +create table f_first ( + id bigint auto_increment not null, + name varchar(255), + constraint pk_f_first primary key (id) +); + +create table foo ( + foo_id integer auto_increment not null, + important_text varchar(255), + version integer not null, + constraint pk_foo primary key (foo_id) +); + +create table gen_key_identity ( + id bigint auto_increment not null, + description varchar(255), + constraint pk_gen_key_identity primary key (id) +); + +create table gen_key_sequence ( + id bigint auto_increment not null, + description varchar(255), + constraint pk_gen_key_sequence primary key (id) +); + +create table gen_key_table ( + id bigint auto_increment not null, + description varchar(255), + constraint pk_gen_key_table primary key (id) +); + +create table grand_parent_person ( + identifier integer auto_increment not null, + name varchar(255), + age integer, + some_bean_id integer, + family_name varchar(255), + address varchar(255), + constraint pk_grand_parent_person primary key (identifier) +); + +create table survey_group ( + id bigint auto_increment not null, + name varchar(255), + categoryobjectid bigint, + sequence_number integer not null, + constraint pk_survey_group primary key (id) +); + +create table c_group ( + id bigint auto_increment not null, + inactive tinyint(1) default 0 not null, + name varchar(255), + version bigint not null, + when_created datetime(6) not null, + when_modified datetime(6) not null, + constraint pk_c_group primary key (id) +); + +create table he_doc ( + id bigint auto_increment not null, + name varchar(255), + version bigint not null, + when_created datetime(6) not null, + when_modified datetime(6) not null, + constraint pk_he_doc primary key (id) +); + +create table hx_link ( + id bigint auto_increment not null, + name varchar(255), + location varchar(255), + comments varchar(255), + version bigint not null, + when_created datetime(6) not null, + when_modified datetime(6) not null, + deleted tinyint(1) default 0 not null, + constraint pk_hx_link primary key (id) +); + +create table hx_link_doc ( + hx_link_id bigint not null, + he_doc_id bigint not null, + constraint pk_hx_link_doc primary key (hx_link_id,he_doc_id) +); + +create table hi_doc ( + id bigint auto_increment not null, + name varchar(255), + version bigint not null, + when_created datetime(6) not null, + when_modified datetime(6) not null, + constraint pk_hi_doc primary key (id) +); + +create table hi_link ( + id bigint auto_increment not null, + name varchar(255), + location varchar(255), + comments varchar(255), + version bigint not null, + when_created datetime(6) not null, + when_modified datetime(6) not null, + constraint pk_hi_link primary key (id) +); + +create table hi_link_doc ( + hi_link_id bigint not null, + hi_doc_id bigint not null, + constraint pk_hi_link_doc primary key (hi_link_id,hi_doc_id) +); + +create table hi_tone ( + id bigint auto_increment not null, + name varchar(255), + comments varchar(255), + version bigint not null, + when_created datetime(6) not null, + when_modified datetime(6) not null, + constraint pk_hi_tone primary key (id) +); + +create table hi_tthree ( + id bigint auto_increment not null, + hi_ttwo_id bigint not null, + three varchar(255), + version bigint not null, + when_created datetime(6) not null, + when_modified datetime(6) not null, + constraint pk_hi_tthree primary key (id) +); + +create table hi_ttwo ( + id bigint auto_increment not null, + hi_tone_id bigint not null, + two varchar(255), + version bigint not null, + when_created datetime(6) not null, + when_modified datetime(6) not null, + constraint pk_hi_ttwo primary key (id) +); + +create table hsd_setting ( + id bigint auto_increment not null, + code varchar(255), + content varchar(255), + user_id bigint, + version bigint not null, + when_created datetime(6) not null, + when_modified datetime(6) not null, + deleted tinyint(1) default 0 not null, + constraint uq_hsd_setting_user_id unique (user_id), + constraint pk_hsd_setting primary key (id) +); + +create table hsd_user ( + id bigint auto_increment not null, + name varchar(255), + version bigint not null, + when_created datetime(6) not null, + when_modified datetime(6) not null, + deleted tinyint(1) default 0 not null, + constraint pk_hsd_user primary key (id) +); + +create table iaf_segment ( + ptype varchar(31) not null, + id bigint auto_increment not null, + segment_id_zat bigint not null, + status_id bigint not null, + constraint pk_iaf_segment primary key (id) +); + +create table iaf_segment_status ( + id bigint auto_increment not null, + name varchar(255), + constraint pk_iaf_segment_status primary key (id) +); + +create table imrelated ( + id bigint auto_increment not null, + name varchar(255), + owner_id bigint not null, + constraint pk_imrelated primary key (id) +); + +create table imroot ( + dtype varchar(31) not null, + id bigint auto_increment not null, + name varchar(255), + title varchar(255), + when_title datetime(6), + constraint pk_imroot primary key (id) +); + +create table ixresource ( + dtype varchar(255), + id varchar(40) not null, + name varchar(255), + constraint pk_ixresource primary key (id) +); + +create table info_company ( + id bigint auto_increment not null, + name varchar(255), + version bigint not null, + constraint pk_info_company primary key (id) +); + +create table info_contact ( + id bigint auto_increment not null, + name varchar(255), + company_id bigint not null, + version bigint not null, + constraint pk_info_contact primary key (id) +); + +create table info_customer ( + id bigint auto_increment not null, + name varchar(255), + company_id bigint, + version bigint not null, + constraint uq_info_customer_company_id unique (company_id), + constraint pk_info_customer primary key (id) +); + +create table inner_report ( + id bigint auto_increment not null, + name varchar(255), + forecast_id bigint, + constraint uq_inner_report_forecast_id unique (forecast_id), + constraint pk_inner_report primary key (id) +); + +create table drel_invoice ( + id bigint auto_increment not null, + booking bigint, + version integer not null, + constraint pk_drel_invoice primary key (id) +); + +create table item ( + customer integer not null, + itemnumber varchar(127) not null, + description varchar(255), + units varchar(255), + type integer not null, + region integer not null, + date_modified datetime(6), + date_created datetime(6), + modified_by varchar(255), + created_by varchar(255), + version bigint not null, + constraint pk_item primary key (customer,itemnumber) +); + +create table monkey ( + mid bigint auto_increment not null, + name varchar(255), + food_preference varchar(255), + version bigint not null, + constraint pk_monkey primary key (mid) +); + +create table mkeygroup ( + pid bigint auto_increment not null, + name varchar(255), + version bigint not null, + constraint pk_mkeygroup primary key (pid) +); + +create table mkeygroup_monkey ( + mkeygroup_pid bigint not null, + monkey_mid bigint not null, + constraint uq_mkeygroup_monkey_mid unique (monkey_mid), + constraint pk_mkeygroup_monkey primary key (mkeygroup_pid,monkey_mid) +); + +create table trainer ( + tid bigint auto_increment not null, + name varchar(255), + version bigint not null, + constraint pk_trainer primary key (tid) +); + +create table trainer_monkey ( + trainer_tid bigint not null, + monkey_mid bigint not null, + constraint uq_trainer_monkey_mid unique (monkey_mid), + constraint pk_trainer_monkey primary key (trainer_tid,monkey_mid) +); + +create table troop ( + pid bigint auto_increment not null, + name varchar(255), + version bigint not null, + constraint pk_troop primary key (pid) +); + +create table troop_monkey ( + troop_pid bigint not null, + monkey_mid bigint not null, + constraint uq_troop_monkey_mid unique (monkey_mid), + constraint pk_troop_monkey primary key (troop_pid,monkey_mid) +); + +create table l2_cldf_reset_bean ( + id bigint auto_increment not null, + name varchar(255), + constraint pk_l2_cldf_reset_bean primary key (id) +); + +create table l2_cldf_reset_bean_child ( + id bigint auto_increment not null, + parent_id bigint, + constraint pk_l2_cldf_reset_bean_child primary key (id) +); + +create table level1 ( + id bigint auto_increment not null, + name varchar(255), + constraint pk_level1 primary key (id) +); + +create table level1_level4 ( + level1_id bigint not null, + level4_id bigint not null, + constraint pk_level1_level4 primary key (level1_id,level4_id) +); + +create table level1_level2 ( + level1_id bigint not null, + level2_id bigint not null, + constraint pk_level1_level2 primary key (level1_id,level2_id) +); + +create table level2 ( + id bigint auto_increment not null, + name varchar(255), + constraint pk_level2 primary key (id) +); + +create table level2_level3 ( + level2_id bigint not null, + level3_id bigint not null, + constraint pk_level2_level3 primary key (level2_id,level3_id) +); + +create table level3 ( + id bigint auto_increment not null, + name varchar(255), + constraint pk_level3 primary key (id) +); + +create table level4 ( + id bigint auto_increment not null, + name varchar(255), + constraint pk_level4 primary key (id) +); + +create table link ( + id bigint auto_increment not null, + name varchar(255), + location varchar(255), + when_publish datetime(6), + link_comment varchar(255), + version bigint not null, + when_created datetime(6) not null, + when_modified datetime(6) not null, + deleted tinyint(1) default 0 not null, + constraint pk_link primary key (id) +); + +create table link_draft ( + id bigint auto_increment not null, + name varchar(255), + location varchar(255), + when_publish datetime(6), + link_comment varchar(255), + dirty tinyint(1) default 0 not null, + version bigint not null, + when_created datetime(6) not null, + when_modified datetime(6) not null, + deleted tinyint(1) default 0 not null, + constraint pk_link_draft primary key (id) +); + +create table la_attr_value ( + id integer auto_increment not null, + name varchar(255), + cretime datetime(6) not null, + updtime datetime(6) not null, + version bigint not null, + constraint pk_la_attr_value primary key (id) +); + +create table la_attr_value_attribute ( + la_attr_value_id integer not null, + attribute_id integer not null, + constraint pk_la_attr_value_attribute primary key (la_attr_value_id,attribute_id) +); + +create table looney ( + id bigint auto_increment not null, + tune_id bigint, + name varchar(255), + constraint pk_looney primary key (id) +); + +create table maddress ( + id varchar(40) not null, + street varchar(255), + city varchar(255), + version bigint not null, + constraint pk_maddress primary key (id) +); + +create table mcontact ( + id varchar(40) not null, + email varchar(255), + first_name varchar(255), + last_name varchar(255), + customer_id varchar(40), + version bigint not null, + constraint pk_mcontact primary key (id) +); + +create table mcontact_message ( + id varchar(40) not null, + title varchar(255), + subject varchar(255), + notes varchar(255), + contact_id varchar(40) not null, + version bigint not null, + constraint pk_mcontact_message primary key (id) +); + +create table mcustomer ( + id varchar(40) not null, + name varchar(255), + notes varchar(255), + shipping_address_id varchar(40), + billing_address_id varchar(40), + version bigint not null, + constraint pk_mcustomer primary key (id) +); + +create table mgroup ( + id bigint auto_increment not null, + name varchar(255), + constraint pk_mgroup primary key (id) +); + +create table mmachine ( + id bigint auto_increment not null, + name varchar(255), + version bigint not null, + constraint pk_mmachine primary key (id) +); + +create table mmachine_mgroup ( + mmachine_id bigint not null, + mgroup_id bigint not null, + constraint pk_mmachine_mgroup primary key (mmachine_id,mgroup_id) +); + +create table mmedia ( + type varchar(31) not null, + id bigint auto_increment not null, + url varchar(255), + note varchar(255), + constraint pk_mmedia primary key (id) +); + +create table non_updateprop ( + id integer auto_increment not null, + non_enum varchar(5), + name varchar(255), + note varchar(255), + constraint pk_non_updateprop primary key (id) +); + +create table mprinter ( + id bigint auto_increment not null, + name varchar(255), + flags bigint not null, + current_state_id bigint, + last_swap_cyan_id bigint, + last_swap_magenta_id bigint, + last_swap_yellow_id bigint, + last_swap_black_id bigint, + version bigint not null, + constraint uq_mprinter_last_swap_cyan_id unique (last_swap_cyan_id), + constraint uq_mprinter_last_swap_magenta_id unique (last_swap_magenta_id), + constraint uq_mprinter_last_swap_yellow_id unique (last_swap_yellow_id), + constraint uq_mprinter_last_swap_black_id unique (last_swap_black_id), + constraint pk_mprinter primary key (id) +); + +create table mprinter_state ( + id bigint auto_increment not null, + flags bigint not null, + printer_id bigint, + version bigint not null, + constraint pk_mprinter_state primary key (id) +); + +create table mprofile ( + id bigint auto_increment not null, + picture_id bigint, + name varchar(255), + constraint pk_mprofile primary key (id) +); + +create table mprotected_construct_bean ( + id bigint auto_increment not null, + name varchar(255), + constraint pk_mprotected_construct_bean primary key (id) +); + +create table mrole ( + roleid integer auto_increment not null, + role_name varchar(255), + constraint pk_mrole primary key (roleid) +); + +create table mrole_muser ( + mrole_roleid integer not null, + muser_userid integer not null, + constraint pk_mrole_muser primary key (mrole_roleid,muser_userid) +); + +create table msome_other ( + id bigint auto_increment not null, + name varchar(255), + constraint pk_msome_other primary key (id) +); + +create table muser ( + userid integer auto_increment not null, + user_name varchar(255), + user_type_id integer, + constraint pk_muser primary key (userid) +); + +create table muser_type ( + id integer auto_increment not null, + name varchar(255), + constraint pk_muser_type primary key (id) +); + +create table mail_box ( + id bigint auto_increment not null, + name varchar(255), + version bigint not null, + constraint pk_mail_box primary key (id) +); + +create table mail_user ( + id bigint auto_increment not null, + name varchar(255), + version bigint not null, + constraint pk_mail_user primary key (id) +); + +create table mail_user_inbox ( + mail_user_id bigint not null, + mail_box_id bigint not null, + constraint pk_mail_user_inbox primary key (mail_user_id,mail_box_id) +); + +create table mail_user_outbox ( + mail_user_id bigint not null, + mail_box_id bigint not null, + constraint pk_mail_user_outbox primary key (mail_user_id,mail_box_id) +); + +create table main_entity ( + id varchar(255) not null, + attr1 varchar(255), + attr2 varchar(255), + constraint pk_main_entity primary key (id) +); + +create table main_entity_relation ( + id varchar(40) not null, + id1 varchar(255), + id2 varchar(255), + attr1 varchar(255), + constraint pk_main_entity_relation primary key (id) +); + +create table map_super_actual ( + id bigint auto_increment not null, + name varchar(255), + when_created datetime(6) not null, + when_updated datetime(6) not null, + constraint pk_map_super_actual primary key (id) +); + +create table c_message ( + id bigint auto_increment not null, + title varchar(255), + body varchar(255), + conversation_id bigint, + user_id bigint, + version bigint not null, + when_created datetime(6) not null, + when_modified datetime(6) not null, + constraint pk_c_message primary key (id) +); + +create table meter_address_data ( + id varchar(40) not null, + street varchar(255) not null, + constraint pk_meter_address_data primary key (id) +); + +create table meter_contract_data ( + id varchar(40) not null, + special_needs_client_id varchar(40) not null, + constraint uq_meter_contract_data_special_needs_client_id unique (special_needs_client_id), + constraint pk_meter_contract_data primary key (id) +); + +create table meter_special_needs_client ( + id varchar(40) not null, + name varchar(255), + primary_id varchar(40), + constraint uq_meter_special_needs_client_primary_id unique (primary_id), + constraint pk_meter_special_needs_client primary key (id) +); + +create table meter_special_needs_contact ( + id varchar(40) not null, + name varchar(255), + constraint pk_meter_special_needs_contact primary key (id) +); + +create table meter_version ( + id varchar(40) not null, + address_data_id varchar(40), + contract_data_id varchar(40) not null, + constraint uq_meter_version_address_data_id unique (address_data_id), + constraint uq_meter_version_contract_data_id unique (contract_data_id), + constraint pk_meter_version primary key (id) +); + +create table mnoc_role ( + role_id integer auto_increment not null, + role_name varchar(255), + version integer not null, + constraint pk_mnoc_role primary key (role_id) +); + +create table mnoc_user ( + user_id integer auto_increment not null, + user_name varchar(255), + version integer not null, + constraint pk_mnoc_user primary key (user_id) +); + +create table mnoc_user_mnoc_role ( + mnoc_user_user_id integer not null, + mnoc_role_role_id integer not null, + constraint pk_mnoc_user_mnoc_role primary key (mnoc_user_user_id,mnoc_role_role_id) +); + +create table mny_a ( + id bigint auto_increment not null, + name varchar(255), + version bigint not null, + when_created datetime(6) not null, + when_modified datetime(6) not null, + constraint pk_mny_a primary key (id) +); + +create table mny_b ( + id bigint auto_increment not null, + name varchar(255), + a_id bigint, + version bigint not null, + when_created datetime(6) not null, + when_modified datetime(6) not null, + constraint pk_mny_b primary key (id) +); + +create table mny_b_mny_c ( + mny_b_id bigint not null, + mny_c_id bigint not null, + constraint pk_mny_b_mny_c primary key (mny_b_id,mny_c_id) +); + +create table mny_c ( + id bigint auto_increment not null, + name varchar(255), + version bigint not null, + when_created datetime(6) not null, + when_modified datetime(6) not null, + constraint pk_mny_c primary key (id) +); + +create table mny_topic ( + id bigint auto_increment not null, + name varchar(255), + version bigint not null, + constraint pk_mny_topic primary key (id) +); + +create table subtopics ( + topic bigint not null, + subtopic bigint not null, + constraint pk_subtopics primary key (topic,subtopic) +); + +create table mp_role ( + id bigint auto_increment not null, + mp_user_id bigint not null, + code varchar(255), + organization_id bigint, + constraint pk_mp_role primary key (id) +); + +create table mp_user ( + id bigint auto_increment not null, + name varchar(255), + constraint pk_mp_user primary key (id) +); + +create table ms_many_a ( + aid bigint auto_increment not null, + name varchar(255), + ms_many_a_many_b tinyint(1) default 0 not null, + ms_many_b tinyint(1) default 0 not null, + deleted tinyint(1) default 0 not null, + constraint pk_ms_many_a primary key (aid) +); + +create table ms_many_a_many_b ( + ms_many_a_aid bigint not null, + ms_many_b_bid bigint not null, + constraint pk_ms_many_a_many_b primary key (ms_many_a_aid,ms_many_b_bid) +); + +create table ms_many_b ( + bid bigint auto_increment not null, + name varchar(255), + deleted tinyint(1) default 0 not null, + constraint pk_ms_many_b primary key (bid) +); + +create table ms_many_b_many_a ( + ms_many_b_bid bigint not null, + ms_many_a_aid bigint not null, + constraint pk_ms_many_b_many_a primary key (ms_many_b_bid,ms_many_a_aid) +); + +create table my_lob_size ( + id integer auto_increment not null, + name varchar(255), + my_count integer not null, + my_lob longtext, + constraint pk_my_lob_size primary key (id) +); + +create table my_lob_size_join_many ( + id integer auto_increment not null, + something varchar(255), + other varchar(255), + parent_id integer, + constraint pk_my_lob_size_join_many primary key (id) +); + +create table noidbean ( + name varchar(255), + subject varchar(255), + when_created datetime(6) not null +); + +create table o_bean_child ( + id bigint auto_increment not null, + cached_bean_id bigint, + constraint pk_o_bean_child primary key (id) +); + +create table ocached_app ( + id bigint auto_increment not null, + app_name varchar(255), + version bigint not null, + constraint uq_ocached_app_app_name unique (app_name), + constraint pk_ocached_app primary key (id) +); + +create table ocached_app_detail ( + id bigint auto_increment not null, + app_id bigint not null, + detail varchar(255), + version bigint not null, + constraint uq_ocached_app_detail_app_id_detail unique (app_id,detail), + constraint pk_ocached_app_detail primary key (id) +); + +create table o_cached_bean ( + id bigint auto_increment not null, + name varchar(255), + constraint pk_o_cached_bean primary key (id) +); + +create table o_cached_bean_country ( + o_cached_bean_id bigint not null, + o_country_code varchar(2) not null, + constraint pk_o_cached_bean_country primary key (o_cached_bean_id,o_country_code) +); + +create table o_cached_bean_child ( + id bigint auto_increment not null, + cached_bean_id bigint, + constraint pk_o_cached_bean_child primary key (id) +); + +create table o_cached_inherit ( + dtype varchar(31) not null, + id bigint auto_increment not null, + name varchar(255), + child_adata varchar(255), + child_bdata varchar(255), + constraint pk_o_cached_inherit primary key (id) +); + +create table o_cached_natkey ( + id bigint auto_increment not null, + store varchar(255), + sku varchar(255), + description varchar(255), + constraint pk_o_cached_natkey primary key (id) +); + +create table o_cached_natkey3 ( + id bigint auto_increment not null, + store varchar(255), + code integer not null, + sku varchar(255), + description varchar(255), + constraint pk_o_cached_natkey3 primary key (id) +); + +create table ocached_nkey_uid ( + id bigint auto_increment not null, + cid varchar(40), + other varchar(255), + version bigint not null, + constraint pk_ocached_nkey_uid primary key (id) +); + +create table ocar ( + id integer auto_increment not null, + vin varchar(255), + name varchar(255), + cretime datetime(6) not null, + updtime datetime(6) not null, + version bigint not null, + constraint pk_ocar primary key (id) +); + +create table ocompany ( + id integer auto_increment not null, + corp_id varchar(50), + cretime datetime(6) not null, + updtime datetime(6) not null, + version bigint not null, + constraint uq_ocompany_corp_id unique (corp_id), + constraint pk_ocompany primary key (id) +); + +create table oengine ( + engine_id varchar(40) not null, + short_desc varchar(255), + car_id integer, + version integer not null, + constraint uq_oengine_car_id unique (car_id), + constraint pk_oengine primary key (engine_id) +); + +create table ogear_box ( + id varchar(40) not null, + box_desc varchar(255), + box_size integer, + car_id integer, + version integer not null, + constraint uq_ogear_box_car_id unique (car_id), + constraint pk_ogear_box primary key (id) +); + +create table omvertex ( + id varchar(40) not null, + constraint pk_omvertex primary key (id) +); + +create table omvertex_other ( + id varchar(40) not null, + omvertex_id varchar(40) not null, + name varchar(255), + constraint pk_omvertex_other primary key (id) +); + +create table oroad_show_msg ( + id integer auto_increment not null, + company_id integer not null, + cretime datetime(6) not null, + updtime datetime(6) not null, + version bigint not null, + constraint uq_oroad_show_msg_company_id unique (company_id), + constraint pk_oroad_show_msg primary key (id) +); + +create table om_account_child_dbo ( + id bigint auto_increment not null, + description varchar(255), + banana_rama_id bigint, + constraint pk_om_account_child_dbo primary key (id) +); + +create table om_account_dbo ( + id bigint auto_increment not null, + name varchar(255), + constraint pk_om_account_dbo primary key (id) +); + +create table om_basic_child ( + id bigint auto_increment not null, + name varchar(255), + parent_id bigint, + version bigint not null, + constraint pk_om_basic_child primary key (id) +); + +create table om_basic_parent ( + id bigint auto_increment not null, + name varchar(255), + version bigint not null, + constraint pk_om_basic_parent primary key (id) +); + +create table om_ordered_detail ( + id bigint auto_increment not null, + name varchar(255), + master_id bigint, + version bigint not null, + sort_order integer, + constraint pk_om_ordered_detail primary key (id) +); + +create table om_ordered_master ( + id bigint auto_increment not null, + name varchar(255), + version bigint not null, + constraint pk_om_ordered_master primary key (id) +); + +create table only_id_entity ( + id bigint auto_increment not null, + constraint pk_only_id_entity primary key (id) +); + +create table o_order ( + id integer auto_increment not null, + status integer, + order_date date, + ship_date date, + kcustomer_id integer not null, + cretime datetime(6) not null, + updtime datetime(6) not null, + constraint pk_o_order primary key (id) +); + +create table o_order_detail ( + id integer auto_increment not null, + order_id integer not null, + order_qty integer, + ship_qty integer, + unit_price double, + product_id integer, + cretime datetime(6), + updtime datetime(6) not null, + constraint pk_o_order_detail primary key (id) +); + +create table s_orders ( + uuid varchar(40) not null, + constraint pk_s_orders primary key (uuid) +); + +create table s_order_items ( + uuid varchar(40) not null, + product_variant_uuid varchar(255), + order_uuid varchar(40), + quantity integer not null, + amount decimal(38), + constraint pk_s_order_items primary key (uuid) +); + +create table or_order_ship ( + id integer auto_increment not null, + order_id integer, + ship_time datetime(6), + cretime datetime(6) not null, + updtime datetime(6) not null, + version bigint not null, + constraint pk_or_order_ship primary key (id) +); + +create table organisation ( + id bigint auto_increment not null, + name varchar(255), + version bigint not null, + when_created datetime(6) not null, + when_modified datetime(6) not null, + constraint pk_organisation primary key (id) +); + +create table organization_node ( + kind varchar(31) not null, + id bigint auto_increment not null, + parent_tree_node_id bigint not null, + title varchar(255), + constraint uq_organization_node_parent_tree_node_id unique (parent_tree_node_id), + constraint pk_organization_node primary key (id) +); + +create table organization_tree_node ( + id bigint auto_increment not null, + name varchar(255), + constraint pk_organization_tree_node primary key (id) +); + +create table orp_detail ( + id varchar(100) not null, + detail varchar(255), + master_id varchar(100), + version bigint not null, + constraint pk_orp_detail primary key (id) +); + +create table orp_detail2 ( + id varchar(100) not null, + orp_master2_id varchar(100) not null, + detail varchar(255), + master_id varchar(255), + version bigint not null, + constraint pk_orp_detail2 primary key (id) +); + +create table orp_master ( + id varchar(100) not null, + name varchar(255), + version bigint not null, + constraint pk_orp_master primary key (id) +); + +create table orp_master2 ( + id varchar(100) not null, + name varchar(255), + version bigint not null, + constraint pk_orp_master2 primary key (id) +); + +create table oto_aone ( + id varchar(100) not null, + description varchar(255), + constraint pk_oto_aone primary key (id) +); + +create table oto_atwo ( + id varchar(100) not null, + description varchar(255), + aone_id varchar(100), + constraint uq_oto_atwo_aone_id unique (aone_id), + constraint pk_oto_atwo primary key (id) +); + +create table oto_bchild ( + master_id bigint not null, + child varchar(255), + constraint pk_oto_bchild primary key (master_id) +); + +create table oto_bmaster ( + id bigint auto_increment not null, + name varchar(255), + constraint pk_oto_bmaster primary key (id) +); + +create table oto_child ( + id integer auto_increment not null, + name varchar(255), + master_id bigint, + constraint uq_oto_child_master_id unique (master_id), + constraint pk_oto_child primary key (id) +); + +create table oto_cust ( + cid bigint auto_increment not null, + name varchar(255), + version bigint not null, + constraint pk_oto_cust primary key (cid) +); + +create table oto_cust_address ( + aid bigint auto_increment not null, + line1 varchar(255), + line2 varchar(255), + line3 varchar(255), + customer_cid bigint, + version bigint not null, + constraint uq_oto_cust_address_customer_cid unique (customer_cid), + constraint pk_oto_cust_address primary key (aid) +); + +create table oto_level_a ( + id bigint auto_increment not null, + name varchar(255), + b_id bigint, + constraint uq_oto_level_a_b_id unique (b_id), + constraint pk_oto_level_a primary key (id) +); + +create table oto_level_b ( + id bigint auto_increment not null, + name varchar(255), + c_id bigint, + constraint uq_oto_level_b_c_id unique (c_id), + constraint pk_oto_level_b primary key (id) +); + +create table oto_level_c ( + id bigint auto_increment not null, + name varchar(255), + constraint pk_oto_level_c primary key (id) +); + +create table oto_master ( + id bigint auto_increment not null, + name varchar(255), + constraint pk_oto_master primary key (id) +); + +create table oto_prime ( + pid bigint auto_increment not null, + name varchar(255), + version bigint not null, + constraint pk_oto_prime primary key (pid) +); + +create table oto_prime_extra ( + eid bigint not null, + extra varchar(255), + version bigint not null, + constraint pk_oto_prime_extra primary key (eid) +); + +create table oto_sd_child ( + id bigint auto_increment not null, + child varchar(255), + master_id bigint, + deleted tinyint(1) default 0 not null, + version bigint not null, + constraint uq_oto_sd_child_master_id unique (master_id), + constraint pk_oto_sd_child primary key (id) +); + +create table oto_sd_master ( + id bigint auto_increment not null, + name varchar(255), + version bigint not null, + constraint pk_oto_sd_master primary key (id) +); + +create table oto_th_many ( + id bigint auto_increment not null, + oto_th_top_id bigint not null, + many varchar(255), + version bigint not null, + when_created datetime(6) not null, + when_modified datetime(6) not null, + constraint pk_oto_th_many primary key (id) +); + +create table oto_th_one ( + id bigint auto_increment not null, + one tinyint(1) default 0 not null, + many_id bigint, + version bigint not null, + when_created datetime(6) not null, + when_modified datetime(6) not null, + constraint uq_oto_th_one_many_id unique (many_id), + constraint pk_oto_th_one primary key (id) +); + +create table oto_th_top ( + id bigint auto_increment not null, + topp varchar(255), + version bigint not null, + when_created datetime(6) not null, + when_modified datetime(6) not null, + constraint pk_oto_th_top primary key (id) +); + +create table oto_ubprime ( + pid varchar(40) not null, + name varchar(255), + version bigint not null, + constraint pk_oto_ubprime primary key (pid) +); + +create table oto_ubprime_extra ( + eid varchar(40) not null, + extra varchar(255), + version bigint not null, + constraint pk_oto_ubprime_extra primary key (eid) +); + +create table oto_uprime ( + pid varchar(40) not null, + name varchar(255), + version bigint not null, + constraint pk_oto_uprime primary key (pid) +); + +create table oto_uprime_extra ( + eid varchar(40) not null, + extra varchar(255), + version bigint not null, + constraint pk_oto_uprime_extra primary key (eid) +); + +create table oto_user_model ( + id bigint auto_increment not null, + name varchar(255), + user_optional_id bigint, + version bigint not null, + when_created datetime(6) not null, + when_modified datetime(6) not null, + constraint uq_oto_user_model_user_optional_id unique (user_optional_id), + constraint pk_oto_user_model primary key (id) +); + +create table oto_user_model_optional ( + id bigint auto_increment not null, + optional varchar(255), + version bigint not null, + when_created datetime(6) not null, + when_modified datetime(6) not null, + constraint pk_oto_user_model_optional primary key (id) +); + +create table pfile ( + id integer auto_increment not null, + name varchar(255), + file_content_id integer, + file_content2_id integer, + cretime datetime(6) not null, + updtime datetime(6) not null, + version bigint not null, + constraint uq_pfile_file_content_id unique (file_content_id), + constraint uq_pfile_file_content2_id unique (file_content2_id), + constraint pk_pfile primary key (id) +); + +create table pfile_content ( + id integer auto_increment not null, + content longblob, + cretime datetime(6) not null, + updtime datetime(6) not null, + version bigint not null, + constraint pk_pfile_content primary key (id) +); + +create table paggview ( + pview_id varchar(40), + amount integer not null, + constraint uq_paggview_pview_id unique (pview_id) +); + +create table pallet_location ( + type varchar(31) not null, + id integer auto_increment not null, + zone_sid integer not null, + attribute varchar(255), + constraint pk_pallet_location primary key (id) +); + +create table parcel ( + parcelid bigint auto_increment not null, + description varchar(255), + constraint pk_parcel primary key (parcelid) +); + +create table parcel_location ( + parcellocid bigint auto_increment not null, + location varchar(255), + parcelid bigint, + constraint uq_parcel_location_parcelid unique (parcelid), + constraint pk_parcel_location primary key (parcellocid) +); + +create table rawinherit_parent ( + type varchar(31) not null, + id bigint auto_increment not null, + val integer, + more varchar(255), + constraint pk_rawinherit_parent primary key (id) +); + +create table rawinherit_parent_rawinherit_data ( + rawinherit_parent_id bigint not null, + rawinherit_data_id bigint not null, + constraint pk_rawinherit_parent_rawinherit_data primary key (rawinherit_parent_id,rawinherit_data_id) +); + +create table e_save_test_c ( + id bigint auto_increment not null, + version bigint not null, + constraint pk_e_save_test_c primary key (id) +); + +create table parent_person ( + identifier integer auto_increment not null, + name varchar(255), + age integer, + some_bean_id integer, + parent_identifier integer, + family_name varchar(255), + address varchar(255), + constraint pk_parent_person primary key (identifier) +); + +create table c_participation ( + id bigint auto_increment not null, + rating integer, + type integer, + conversation_id bigint not null, + user_id bigint not null, + version bigint not null, + when_created datetime(6) not null, + when_modified datetime(6) not null, + constraint pk_c_participation primary key (id) +); + +create table password_store_model ( + id bigint auto_increment not null, + enc1 varchar(30), + enc2 varchar(40), + enc3 longtext, + enc4 varbinary(30), + enc5 varbinary(40), + enc6 longblob, + version bigint not null, + when_created datetime(6) not null, + when_modified datetime(6) not null, + constraint pk_password_store_model primary key (id) +); + +create table pcf_calendar ( + id bigint auto_increment not null, + pcf_person_id bigint not null, + version bigint not null, + constraint pk_pcf_calendar primary key (id) +); + +create table pcf_city ( + id bigint auto_increment not null, + pcf_country_id bigint not null, + name varchar(255), + mayor_id bigint not null, + vice_mayor_id bigint not null, + version bigint not null, + constraint uq_pcf_city_mayor_id unique (mayor_id), + constraint uq_pcf_city_vice_mayor_id unique (vice_mayor_id), + constraint pk_pcf_city primary key (id) +); + +create table pcf_country ( + id bigint auto_increment not null, + version bigint not null, + constraint pk_pcf_country primary key (id) +); + +create table pcf_event ( + id bigint auto_increment not null, + pcf_calendar_id bigint not null, + name varchar(255), + version bigint not null, + constraint pk_pcf_event primary key (id) +); + +create table pcf_person ( + id bigint auto_increment not null, + name varchar(255), + version bigint not null, + constraint pk_pcf_person primary key (id) +); + +create table mt_permission ( + id varchar(40) not null, + name varchar(255), + constraint pk_mt_permission primary key (id) +); + +create table persistent_file ( + id integer auto_increment not null, + name varchar(255), + cretime datetime(6) not null, + updtime datetime(6) not null, + version bigint not null, + constraint pk_persistent_file primary key (id) +); + +create table persistent_file_content ( + id integer auto_increment not null, + persistent_file_id integer, + content longblob, + cretime datetime(6) not null, + updtime datetime(6) not null, + version bigint not null, + constraint uq_persistent_file_content_persistent_file_id unique (persistent_file_id), + constraint pk_persistent_file_content primary key (id) +); + +create table person ( + oid bigint auto_increment not null, + default_address_oid bigint, + version integer not null, + constraint pk_person primary key (oid) +); + +create table persons ( + id bigint auto_increment not null, + surname varchar(64) not null, + name varchar(64) not null, + constraint pk_persons primary key (id) +); + +create table person_cache_email ( + id varchar(128) not null, + person_info_person_id varchar(128), + email varchar(255), + constraint pk_person_cache_email primary key (id) +); + +create table person_cache_info ( + person_id varchar(128) not null, + name varchar(255), + constraint pk_person_cache_info primary key (person_id) +); + +create table phones ( + id bigint auto_increment not null, + phone_number varchar(7) not null, + person_id bigint not null, + constraint uq_phones_phone_number unique (phone_number), + constraint pk_phones primary key (id) +); + +create table e_position ( + id bigint auto_increment not null, + name varchar(255), + contract_id bigint not null, + constraint pk_e_position primary key (id) +); + +create table primary_revision ( + id bigint not null, + revision integer not null, + name varchar(255), + version bigint not null, + constraint pk_primary_revision primary key (id,revision) +); + +create table o_product ( + id integer auto_increment not null, + sku varchar(20), + name varchar(255), + cretime datetime(6) not null, + updtime datetime(6) not null, + constraint pk_o_product primary key (id) +); + +create table pp ( + id varchar(40) not null, + name varchar(255), + value varchar(100) not null, + constraint pk_pp primary key (id) +); + +create table pp_to_ww ( + pp_id varchar(40) not null, + ww_id varchar(40) not null, + constraint pk_pp_to_ww primary key (pp_id,ww_id) +); + +create table question ( + id bigint auto_increment not null, + name varchar(255), + groupobjectid bigint, + sequence_number integer not null, + constraint pk_question primary key (id) +); + +create table rcustomer ( + company varchar(127) not null, + name varchar(127) not null, + description varchar(255), + constraint pk_rcustomer primary key (company,name) +); + +create table r_orders ( + company varchar(127) not null, + order_number integer not null, + customername varchar(127), + item varchar(255), + constraint pk_r_orders primary key (company,order_number) +); + +create table referencing_bean ( + id varchar(40) not null, + constraint pk_referencing_bean primary key (id) +); + +create table region ( + customer integer not null, + type integer not null, + description varchar(255), + version bigint not null, + constraint pk_region primary key (customer,type) +); + +create table rel_detail ( + id bigint auto_increment not null, + name varchar(255), + version integer not null, + constraint pk_rel_detail primary key (id) +); + +create table rel_master ( + id bigint auto_increment not null, + name varchar(255), + detail_id bigint, + version integer not null, + constraint pk_rel_master primary key (id) +); + +create table resourcefile ( + id varchar(64) not null, + parentresourcefileid varchar(64), + name varchar(128) not null, + constraint pk_resourcefile primary key (id) +); + +create table mt_role ( + id varchar(40) not null, + name varchar(50), + tenant_id varchar(40), + version bigint not null, + constraint pk_mt_role primary key (id) +); + +create table mt_role_permission ( + mt_role_id varchar(40) not null, + mt_permission_id varchar(40) not null, + constraint pk_mt_role_permission primary key (mt_role_id,mt_permission_id) +); + +create table em_role ( + id bigint auto_increment not null, + name varchar(255), + constraint pk_em_role primary key (id) +); + +create table root_bean ( + dtype varchar(31) not null, + id varchar(40) not null, + referencing_bean_id varchar(40) not null, + value varchar(255), + constraint pk_root_bean primary key (id) +); + +create table f_second ( + id bigint auto_increment not null, + mod_name varchar(255), + first bigint, + title varchar(255), + constraint uq_f_second_first unique (first), + constraint pk_f_second primary key (id) +); + +create table section ( + id integer auto_increment not null, + article_id integer, + type integer, + content longtext, + cretime datetime(6) not null, + updtime datetime(6) not null, + version bigint not null, + constraint pk_section primary key (id) +); + +create table self_parent ( + id bigint auto_increment not null, + name varchar(255), + parent_id bigint, + version bigint not null, + constraint pk_self_parent primary key (id) +); + +create table self_ref_customer ( + id bigint auto_increment not null, + name varchar(255), + referred_by_id bigint, + constraint pk_self_ref_customer primary key (id) +); + +create table self_ref_example ( + id bigint auto_increment not null, + name varchar(255) not null, + parent_id bigint, + constraint pk_self_ref_example primary key (id) +); + +create table e_save_test_a ( + id bigint auto_increment not null, + version bigint not null, + constraint pk_e_save_test_a primary key (id) +); + +create table e_save_test_b ( + id bigint auto_increment not null, + sibling_a_id bigint, + test_property tinyint(1) default 0 not null, + version bigint not null, + constraint uq_e_save_test_b_sibling_a_id unique (sibling_a_id), + constraint pk_e_save_test_b primary key (id) +); + +create table site ( + id varchar(40) not null, + name varchar(255), + parent_id varchar(40), + data_container_id varchar(40), + site_address_id varchar(40), + constraint uq_site_data_container_id unique (data_container_id), + constraint uq_site_site_address_id unique (site_address_id), + constraint pk_site primary key (id) +); + +create table site_address ( + id varchar(40) not null, + street varchar(255), + city varchar(255), + zip_code varchar(255), + constraint pk_site_address primary key (id) +); + +create table some_enum_bean ( + id bigint auto_increment not null, + some_enum integer, + name varchar(255), + constraint pk_some_enum_bean primary key (id) +); + +create table some_file_bean ( + id bigint auto_increment not null, + name varchar(255), + content longblob, + version bigint not null, + constraint pk_some_file_bean primary key (id) +); + +create table some_new_types_bean ( + id bigint auto_increment not null, + dow integer(1), + mth integer(1), + yr integer, + yr_mth date, + month_day date, + sql_date date, + sql_time time, + local_date date, + local_date_time datetime(6), + offset_date_time datetime(6), + zoned_date_time datetime(6), + local_time time, + instant datetime(6), + zone_id varchar(60), + zone_offset varchar(60), + path varchar(255), + period varchar(20), + duration bigint, + version bigint not null, + constraint pk_some_new_types_bean primary key (id) +); + +create table some_period_bean ( + id bigint auto_increment not null, + anniversary date, + version bigint not null, + constraint pk_some_period_bean primary key (id) +); + +create table source_base ( + dtype varchar(31) not null, + id varchar(40) not null, + name varchar(255), + pos integer not null, + target_id varchar(40), + constraint pk_source_base primary key (id) +); + +create table stockforecast ( + type varchar(31) not null, + id bigint auto_increment not null, + inner_report_id bigint, + constraint pk_stockforecast primary key (id) +); + +create table sub_section ( + id integer auto_increment not null, + section_id integer, + title varchar(255), + cretime datetime(6) not null, + updtime datetime(6) not null, + version bigint not null, + constraint pk_sub_section primary key (id) +); + +create table sub_type ( + sub_type_id integer auto_increment not null, + description varchar(255), + version bigint not null, + constraint pk_sub_type primary key (sub_type_id) +); + +create table survey ( + id bigint auto_increment not null, + name varchar(255), + constraint pk_survey primary key (id) +); + +create table tbytes_only ( + id integer auto_increment not null, + content longblob, + constraint pk_tbytes_only primary key (id) +); + +create table tcar ( + type varchar(31) not null, + plate_no varchar(32) not null, + truckload bigint, + constraint pk_tcar primary key (plate_no) +); + +create table tevent ( + id bigint auto_increment not null, + name varchar(255), + version bigint not null, + constraint pk_tevent primary key (id) +); + +create table tevent_many ( + id bigint auto_increment not null, + description varchar(255), + event_id bigint, + units integer not null, + amount double not null, + version bigint not null, + constraint pk_tevent_many primary key (id) +); + +create table tevent_one ( + id bigint auto_increment not null, + name varchar(255), + status integer, + event_id bigint, + version bigint not null, + constraint uq_tevent_one_event_id unique (event_id), + constraint pk_tevent_one primary key (id) +); + +create table tint_root ( + my_type integer(3) not null, + id integer auto_increment not null, + name varchar(255), + child_property varchar(255), + constraint pk_tint_root primary key (id) +); + +create table tjoda_entity ( + id integer auto_increment not null, + local_time time, + constraint pk_tjoda_entity primary key (id) +); + +create table t_mapsuper1 ( + id integer auto_increment not null, + something varchar(255), + name varchar(255), + version integer not null, + constraint pk_t_mapsuper1 primary key (id) +); + +create table t_oneb ( + id integer auto_increment not null, + name varchar(255), + description varchar(255), + active tinyint(1) default 0 not null, + constraint pk_t_oneb primary key (id) +); + +create table t_detail_with_other_namexxxyy ( + id integer auto_increment not null, + name varchar(255), + description varchar(255), + some_unique_value varchar(127), + active tinyint(1) default 0 not null, + master_id integer, + constraint uq_t_detail_with_other_namexxxyy_some_unique_value unique (some_unique_value), + constraint pk_t_detail_with_other_namexxxyy primary key (id) +); + +create table t_atable_thatisrelatively ( + id integer auto_increment not null, + name varchar(255), + description varchar(255), + active tinyint(1) default 0 not null, + constraint pk_t_atable_thatisrelatively primary key (id) +); + +create table ttruck_holder ( + id bigint auto_increment not null, + name varchar(255), + truck_plate_no varchar(32) not null, + basic_id integer, + version bigint not null, + constraint pk_ttruck_holder primary key (id) +); + +create table ttruck_holder_item ( + id bigint auto_increment not null, + some_uid varchar(40), + foo varchar(255), + owner_id bigint not null, + constraint pk_ttruck_holder_item primary key (id) +); + +create table tuuid_entity ( + id varchar(40) not null, + name varchar(255), + constraint pk_tuuid_entity primary key (id) +); + +create table twheel ( + id bigint auto_increment not null, + owner_plate_no varchar(32) not null, + constraint pk_twheel primary key (id) +); + +create table twith_pre_insert ( + id integer auto_increment not null, + name varchar(255) not null, + title varchar(255), + constraint pk_twith_pre_insert primary key (id) +); + +create table target_base ( + dtype varchar(31) not null, + id varchar(40) not null, + name varchar(255), + constraint pk_target_base primary key (id) +); + +create table mt_tenant ( + id varchar(40) not null, + name varchar(255), + version bigint not null, + constraint pk_mt_tenant primary key (id) +); + +create table test_annotation_base_entity ( + direct varchar(255), + meta varchar(255), + mixed varchar(255), + constraint_annotation varchar(40), + null1 varchar(255) not null, + null2 varchar(255), + null3 varchar(255) +); + +create table tire ( + id bigint auto_increment not null, + wheel bigint, + version integer not null, + constraint uq_tire_wheel unique (wheel), + constraint pk_tire primary key (id) +); + +create table sa_tire ( + id bigint auto_increment not null, + version integer not null, + constraint pk_sa_tire primary key (id) +); + +create table tree_entity ( + id integer auto_increment not null, + text varchar(255), + parent_id integer, + constraint pk_tree_entity primary key (id) +); + +create table trip ( + id integer auto_increment not null, + vehicle_driver_id integer, + destination varchar(255), + address_id integer, + star_date datetime(6), + cretime datetime(6) not null, + updtime datetime(6) not null, + version bigint not null, + constraint pk_trip primary key (id) +); + +create table truck_ref ( + id integer auto_increment not null, + something varchar(255), + constraint pk_truck_ref primary key (id) +); + +create table tune ( + id bigint auto_increment not null, + name varchar(255), + constraint pk_tune primary key (id) +); + +create table `type` ( + customer integer not null, + type integer not null, + description varchar(255), + sub_type_id integer, + version bigint not null, + constraint pk_type primary key (customer,type) +); + +create table tz_bean ( + id bigint auto_increment not null, + moda varchar(255), + ts datetime(6), + tstz datetime(6), + constraint pk_tz_bean primary key (id) +); + +create table usib_child ( + id varchar(40) not null, + parent_id bigint, + deleted tinyint(1) default 0 not null, + constraint pk_usib_child primary key (id) +); + +create table usib_child_sibling ( + id bigint auto_increment not null, + child_id varchar(40), + deleted tinyint(1) default 0 not null, + constraint uq_usib_child_sibling_child_id unique (child_id), + constraint pk_usib_child_sibling primary key (id) +); + +create table usib_parent ( + id bigint auto_increment not null, + deleted tinyint(1) default 0 not null, + constraint pk_usib_parent primary key (id) +); + +create table ut_detail ( + id integer auto_increment not null, + utmaster_id integer not null, + name varchar(255), + qty integer, + amount double, + version integer not null, + constraint pk_ut_detail primary key (id) +); + +create table ut_master ( + id integer auto_increment not null, + name varchar(255), + description varchar(255), + event_date date, + version integer not null, + constraint pk_ut_master primary key (id) +); + +create table uuone ( + id varchar(40) not null, + name varchar(255), + description varchar(255), + version bigint not null, + constraint pk_uuone primary key (id) +); + +create table uutwo ( + id varchar(40) not null, + name varchar(255), + notes varchar(255), + master_id varchar(40), + version bigint not null, + constraint pk_uutwo primary key (id) +); + +create table oto_user ( + id bigint auto_increment not null, + name varchar(255), + account_id bigint not null, + version bigint not null, + when_created datetime(6) not null, + when_modified datetime(6) not null, + constraint uq_oto_user_account_id unique (account_id), + constraint pk_oto_user primary key (id) +); + +create table c_user ( + id bigint auto_increment not null, + inactive tinyint(1) default 0 not null, + name varchar(255), + email varchar(255), + password_hash varchar(255), + group_id bigint, + version bigint not null, + when_created datetime(6) not null, + when_modified datetime(6) not null, + constraint pk_c_user primary key (id) +); + +create table tx_user ( + id bigint auto_increment not null, + name varchar(255), + constraint pk_tx_user primary key (id) +); + +create table g_user ( + id bigint auto_increment not null, + username varchar(255), + version bigint not null, + constraint pk_g_user primary key (id) +); + +create table em_user ( + id bigint auto_increment not null, + name varchar(255), + constraint pk_em_user primary key (id) +); + +create table user_interest_live ( + user_id bigint not null, + live_id bigint not null, + created_at datetime(6) not null, + constraint pk_user_interest_live primary key (user_id,live_id) +); + +create table em_user_role ( + user_id bigint not null, + role_id bigint not null, + constraint pk_em_user_role primary key (user_id,role_id) +); + +create table vehicle ( + dtype varchar(3) not null, + id integer auto_increment not null, + license_number varchar(255), + registration_date datetime(6), + lease_id bigint, + cretime datetime(6) not null, + updtime datetime(6) not null, + version bigint not null, + siz varchar(3), + driver varchar(255), + car_ref_id integer, + notes varchar(255), + truck_ref_id integer, + capacity double, + constraint pk_vehicle primary key (id) +); + +create table vehicle_driver ( + id integer auto_increment not null, + name varchar(255), + vehicle_id integer, + address_id integer, + license_issued_on datetime(6), + cretime datetime(6) not null, + updtime datetime(6) not null, + version bigint not null, + constraint pk_vehicle_driver primary key (id) +); + +create table vehicle_lease ( + dtype varchar(31) not null, + id bigint auto_increment not null, + name varchar(255), + active_start date, + active_end date, + version bigint not null, + bond decimal(38), + min_duration integer not null, + day_rate decimal(38), + max_days integer, + constraint pk_vehicle_lease primary key (id) +); + +create table warehouses ( + id integer auto_increment not null, + officezoneid integer, + constraint pk_warehouses primary key (id) +); + +create table warehousesshippingzones ( + warehouseid integer not null, + shippingzoneid integer not null, + constraint pk_warehousesshippingzones primary key (warehouseid,shippingzoneid) +); + +create table wheel ( + id bigint auto_increment not null, + version integer not null, + constraint pk_wheel primary key (id) +); + +create table sa_wheel ( + id bigint auto_increment not null, + tire bigint, + car bigint, + version integer not null, + constraint pk_sa_wheel primary key (id) +); + +create table sp_car_wheel ( + id bigint auto_increment not null, + name varchar(255), + version integer not null, + constraint pk_sp_car_wheel primary key (id) +); + +create table g_who_props_otm ( + id bigint auto_increment not null, + name varchar(255), + version bigint not null, + when_created datetime(6) not null, + when_modified datetime(6) not null, + who_created_id bigint, + who_modified_id bigint, + constraint pk_g_who_props_otm primary key (id) +); + +create table with_zero ( + id bigint auto_increment not null, + name varchar(255), + parent_id integer, + lang varchar(2) default 'en' not null, + version bigint not null, + constraint pk_with_zero primary key (id) +); + +create table parent ( + id integer auto_increment not null, + name varchar(255), + constraint pk_parent primary key (id) +); + +create table wview ( + id varchar(40) not null, + name varchar(127) not null, + constraint uq_wview_name unique (name), + constraint pk_wview primary key (id) +); + +create table zones ( + type varchar(31) not null, + id integer auto_increment not null, + attribute varchar(255), + constraint pk_zones primary key (id) +); + +create index ix_contact_last_name_first_name on contact (last_name,first_name); +create index ix_e_basic_name on e_basic (name); +create index ix_efile2_no_fk_owner_id on efile2_no_fk (owner_id); +create index ix_ecsm_values_host_id on ecsm_values (host_id); +create index ix_organization_node_kind on organization_node (kind); +create index ix_bar_foo_id on bar (foo_id); +alter table bar add constraint fk_bar_foo_id foreign key (foo_id) references foo (foo_id) on delete restrict on update restrict; + +create index ix_acl_container_relation_container_id on acl_container_relation (container_id); +alter table acl_container_relation add constraint fk_acl_container_relation_container_id foreign key (container_id) references contract (id) on delete restrict on update restrict; + +create index ix_acl_container_relation_acl_entry_id on acl_container_relation (acl_entry_id); +alter table acl_container_relation add constraint fk_acl_container_relation_acl_entry_id foreign key (acl_entry_id) references acl (id) on delete restrict on update restrict; + +create index ix_addr_employee_id on addr (employee_id); +alter table addr add constraint fk_addr_employee_id foreign key (employee_id) references empl (id) on delete restrict on update restrict; + +create index ix_o_address_country_code on o_address (country_code); +alter table o_address add constraint fk_o_address_country_code foreign key (country_code) references o_country (code) on delete restrict on update restrict; + +alter table album add constraint fk_album_cover_id foreign key (cover_id) references cover (id) on delete restrict on update restrict; + +create index ix_animal_shelter_id on animal (shelter_id); +alter table animal add constraint fk_animal_shelter_id foreign key (shelter_id) references animal_shelter (id) on delete restrict on update restrict; + +create index ix_attribute_attribute_holder_id on attribute (attribute_holder_id); +alter table attribute add constraint fk_attribute_attribute_holder_id foreign key (attribute_holder_id) references attribute_holder (id) on delete restrict on update restrict; + +create index ix_bbookmark_user_id on bbookmark (user_id); +alter table bbookmark add constraint fk_bbookmark_user_id foreign key (user_id) references bbookmark_user (id) on delete restrict on update restrict; + +create index ix_bbookmark_user_org_id on bbookmark_user (org_id); +alter table bbookmark_user add constraint fk_bbookmark_user_org_id foreign key (org_id) references bbookmark_org (id) on delete restrict on update restrict; + +create index ix_bsite_user_a_site_id on bsite_user_a (site_id); +alter table bsite_user_a add constraint fk_bsite_user_a_site_id foreign key (site_id) references bsite (id) on delete restrict on update restrict; + +create index ix_bsite_user_a_user_id on bsite_user_a (user_id); +alter table bsite_user_a add constraint fk_bsite_user_a_user_id foreign key (user_id) references buser (id) on delete restrict on update restrict; + +create index ix_bsite_user_b_site on bsite_user_b (site); +alter table bsite_user_b add constraint fk_bsite_user_b_site foreign key (site) references bsite (id) on delete restrict on update restrict; + +create index ix_bsite_user_b_usr on bsite_user_b (usr); +alter table bsite_user_b add constraint fk_bsite_user_b_usr foreign key (usr) references buser (id) on delete restrict on update restrict; + +create index ix_bsite_user_c_site_uid on bsite_user_c (site_uid); +alter table bsite_user_c add constraint fk_bsite_user_c_site_uid foreign key (site_uid) references bsite (id) on delete restrict on update restrict; + +create index ix_bsite_user_c_user_uid on bsite_user_c (user_uid); +alter table bsite_user_c add constraint fk_bsite_user_c_user_uid foreign key (user_uid) references buser (id) on delete restrict on update restrict; + +create index ix_bsite_user_e_site_id on bsite_user_e (site_id); +alter table bsite_user_e add constraint fk_bsite_user_e_site_id foreign key (site_id) references bsite (id) on delete restrict on update restrict; + +create index ix_bsite_user_e_user_id on bsite_user_e (user_id); +alter table bsite_user_e add constraint fk_bsite_user_e_user_id foreign key (user_id) references buser (id) on delete restrict on update restrict; + +alter table basic_draftable_bean add constraint fk_basic_draftable_bean_id foreign key (id) references basic_draftable_bean_draft (id) on delete restrict on update restrict; + +alter table drel_booking add constraint fk_drel_booking_agent_invoice foreign key (agent_invoice) references drel_invoice (id) on delete restrict on update restrict; + +alter table drel_booking add constraint fk_drel_booking_client_invoice foreign key (client_invoice) references drel_invoice (id) on delete restrict on update restrict; + +create index ix_cepproduct_category_category_id on cepproduct_category (category_id); +alter table cepproduct_category add constraint fk_cepproduct_category_category_id foreign key (category_id) references cepcategory (id) on delete restrict on update restrict; + +create index ix_cepproduct_category_product_id on cepproduct_category (product_id); +alter table cepproduct_category add constraint fk_cepproduct_category_product_id foreign key (product_id) references cepproduct (id) on delete restrict on update restrict; + +create index ix_cinh_ref_ref_id on cinh_ref (ref_id); +alter table cinh_ref add constraint fk_cinh_ref_ref_id foreign key (ref_id) references cinh_root (id) on delete restrict on update restrict; + +create index ix_ckey_detail_parent on ckey_detail (one_key,two_key); +alter table ckey_detail add constraint fk_ckey_detail_parent foreign key (one_key,two_key) references ckey_parent (one_key,two_key) on delete restrict on update restrict; + +create index ix_ckey_parent_assoc_id on ckey_parent (assoc_id); +alter table ckey_parent add constraint fk_ckey_parent_assoc_id foreign key (assoc_id) references ckey_assoc (id) on delete restrict on update restrict; + +create index ix_coone_many_coone_id on coone_many (coone_id); +alter table coone_many add constraint fk_coone_many_coone_id foreign key (coone_id) references coone (id) on delete restrict on update restrict; + +alter table coroot add constraint fk_coroot_one_id foreign key (one_id) references coone (id) on delete restrict on update restrict; + +create index ix_calculation_result_product_configuration_id on calculation_result (product_configuration_id); +alter table calculation_result add constraint fk_calculation_result_product_configuration_id foreign key (product_configuration_id) references configuration (id) on delete restrict on update restrict; + +create index ix_calculation_result_group_configuration_id on calculation_result (group_configuration_id); +alter table calculation_result add constraint fk_calculation_result_group_configuration_id foreign key (group_configuration_id) references configuration (id) on delete restrict on update restrict; + +create index ix_sp_car_car_wheels_sp_car_car on sp_car_car_wheels (car); +alter table sp_car_car_wheels add constraint fk_sp_car_car_wheels_sp_car_car foreign key (car) references sp_car_car (id) on delete restrict on update restrict; + +create index ix_sp_car_car_wheels_sp_car_wheel on sp_car_car_wheels (wheel); +alter table sp_car_car_wheels add constraint fk_sp_car_car_wheels_sp_car_wheel foreign key (wheel) references sp_car_wheel (id) on delete restrict on update restrict; + +create index ix_sp_car_car_doors_sp_car_car on sp_car_car_doors (car); +alter table sp_car_car_doors add constraint fk_sp_car_car_doors_sp_car_car foreign key (car) references sp_car_car (id) on delete restrict on update restrict; + +create index ix_sp_car_car_doors_sp_car_door on sp_car_car_doors (door); +alter table sp_car_car_doors add constraint fk_sp_car_car_doors_sp_car_door foreign key (door) references sp_car_door (id) on delete restrict on update restrict; + +create index ix_car_accessory_fuse_id on car_accessory (fuse_id); +alter table car_accessory add constraint fk_car_accessory_fuse_id foreign key (fuse_id) references car_fuse (id) on delete restrict on update restrict; + +create index ix_car_accessory_car_id on car_accessory (car_id); +alter table car_accessory add constraint fk_car_accessory_car_id foreign key (car_id) references vehicle (id) on delete restrict on update restrict; + +create index ix_category_surveyobjectid on category (surveyobjectid); +alter table category add constraint fk_category_surveyobjectid foreign key (surveyobjectid) references survey (id) on delete restrict on update restrict; + +alter table e_save_test_d add constraint fk_e_save_test_d_parent_id foreign key (parent_id) references e_save_test_c (id) on delete restrict on update restrict; + +create index ix_child_person_some_bean_id on child_person (some_bean_id); +alter table child_person add constraint fk_child_person_some_bean_id foreign key (some_bean_id) references e_basic (id) on delete restrict on update restrict; + +create index ix_child_person_parent_identifier on child_person (parent_identifier); +alter table child_person add constraint fk_child_person_parent_identifier foreign key (parent_identifier) references parent_person (identifier) on delete restrict on update restrict; + +create index ix_cke_client_user on cke_client (username,cod_cpny); +alter table cke_client add constraint fk_cke_client_user foreign key (username,cod_cpny) references cke_user (username,cod_cpny) on delete restrict on update restrict; + +alter table class_super_monkey add constraint fk_class_super_monkey_class_super foreign key (class_super_sid) references class_super (sid) on delete restrict on update restrict; + +alter table class_super_monkey add constraint fk_class_super_monkey_monkey foreign key (monkey_mid) references monkey (mid) on delete restrict on update restrict; + +create index ix_configuration_configurations_id on configuration (configurations_id); +alter table configuration add constraint fk_configuration_configurations_id foreign key (configurations_id) references configurations (id) on delete restrict on update restrict; + +create index ix_contact_customer_id on contact (customer_id); +alter table contact add constraint fk_contact_customer_id foreign key (customer_id) references o_customer (id) on delete restrict on update restrict; + +create index ix_contact_group_id on contact (group_id); +alter table contact add constraint fk_contact_group_id foreign key (group_id) references contact_group (id) on delete restrict on update restrict; + +create index ix_contact_note_contact_id on contact_note (contact_id); +alter table contact_note add constraint fk_contact_note_contact_id foreign key (contact_id) references contact (id) on delete restrict on update restrict; + +create index ix_contract_costs_position_id on contract_costs (position_id); +alter table contract_costs add constraint fk_contract_costs_position_id foreign key (position_id) references e_position (id) on delete restrict on update restrict; + +create index ix_c_conversation_group_id on c_conversation (group_id); +alter table c_conversation add constraint fk_c_conversation_group_id foreign key (group_id) references c_group (id) on delete restrict on update restrict; + +create index ix_o_customer_billing_address_id on o_customer (billing_address_id); +alter table o_customer add constraint fk_o_customer_billing_address_id foreign key (billing_address_id) references o_address (id) on delete restrict on update restrict; + +create index ix_o_customer_shipping_address_id on o_customer (shipping_address_id); +alter table o_customer add constraint fk_o_customer_shipping_address_id foreign key (shipping_address_id) references o_address (id) on delete restrict on update restrict; + +create index ix_dcredit_drol_dcredit on dcredit_drol (dcredit_id); +alter table dcredit_drol add constraint fk_dcredit_drol_dcredit foreign key (dcredit_id) references dcredit (id) on delete restrict on update restrict; + +create index ix_dcredit_drol_drol on dcredit_drol (drol_id); +alter table dcredit_drol add constraint fk_dcredit_drol_drol foreign key (drol_id) references drol (id) on delete restrict on update restrict; + +create index ix_dmachine_organisation_id on dmachine (organisation_id); +alter table dmachine add constraint fk_dmachine_organisation_id foreign key (organisation_id) references dorg (id) on delete restrict on update restrict; + +create index ix_d_machine_aux_use_machine_id on d_machine_aux_use (machine_id); +alter table d_machine_aux_use add constraint fk_d_machine_aux_use_machine_id foreign key (machine_id) references dmachine (id) on delete restrict on update restrict; + +create index ix_d_machine_stats_machine_id on d_machine_stats (machine_id); +alter table d_machine_stats add constraint fk_d_machine_stats_machine_id foreign key (machine_id) references dmachine (id) on delete restrict on update restrict; + +create index ix_d_machine_use_machine_id on d_machine_use (machine_id); +alter table d_machine_use add constraint fk_d_machine_use_machine_id foreign key (machine_id) references dmachine (id) on delete restrict on update restrict; + +create index ix_drot_drol_drot on drot_drol (drot_id); +alter table drot_drol add constraint fk_drot_drol_drot foreign key (drot_id) references drot (id) on delete restrict on update restrict; + +create index ix_drot_drol_drol on drot_drol (drol_id); +alter table drot_drol add constraint fk_drot_drol_drol foreign key (drol_id) references drol (id) on delete restrict on update restrict; + +create index ix_dc_detail_master_id on dc_detail (master_id); +alter table dc_detail add constraint fk_dc_detail_master_id foreign key (master_id) references dc_master (id) on delete restrict on update restrict; + +create index ix_dfk_cascade_one_id on dfk_cascade (one_id); +alter table dfk_cascade add constraint fk_dfk_cascade_one_id foreign key (one_id) references dfk_cascade_one (id) on delete cascade on update cascade; + +create index ix_dfk_set_null_one_id on dfk_set_null (one_id); +alter table dfk_set_null add constraint fk_dfk_set_null_one_id foreign key (one_id) references dfk_one (id) on delete set null on update set null; + +alter table doc add constraint fk_doc_id foreign key (id) references doc_draft (id) on delete restrict on update restrict; + +create index ix_doc_link_doc on doc_link (doc_id); +alter table doc_link add constraint fk_doc_link_doc foreign key (doc_id) references doc (id) on delete restrict on update restrict; + +create index ix_doc_link_link on doc_link (link_id); +alter table doc_link add constraint fk_doc_link_link foreign key (link_id) references link (id) on delete restrict on update restrict; + +alter table document add constraint fk_document_id foreign key (id) references document_draft (id) on delete restrict on update restrict; + +create index ix_document_organisation_id on document (organisation_id); +alter table document add constraint fk_document_organisation_id foreign key (organisation_id) references organisation (id) on delete restrict on update restrict; + +create index ix_document_draft_organisation_id on document_draft (organisation_id); +alter table document_draft add constraint fk_document_draft_organisation_id foreign key (organisation_id) references organisation (id) on delete restrict on update restrict; + +create index ix_document_media_document_id on document_media (document_id); +alter table document_media add constraint fk_document_media_document_id foreign key (document_id) references document (id) on delete restrict on update restrict; + +create index ix_document_media_draft_document_id on document_media_draft (document_id); +alter table document_media_draft add constraint fk_document_media_draft_document_id foreign key (document_id) references document_draft (id) on delete restrict on update restrict; + +create index ix_e_basicenc_relate_other_id on e_basicenc_relate (other_id); +alter table e_basicenc_relate add constraint fk_e_basicenc_relate_other_id foreign key (other_id) references e_basicenc (id) on delete restrict on update restrict; + +create index ix_ebasic_json_map_detail_owner_id on ebasic_json_map_detail (owner_id); +alter table ebasic_json_map_detail add constraint fk_ebasic_json_map_detail_owner_id foreign key (owner_id) references ebasic_json_map (id) on delete restrict on update restrict; + +create index ix_ebasic_no_sdchild_owner_id on ebasic_no_sdchild (owner_id); +alter table ebasic_no_sdchild add constraint fk_ebasic_no_sdchild_owner_id foreign key (owner_id) references ebasic_soft_delete (id) on delete restrict on update restrict; + +create index ix_ebasic_sdchild_owner_id on ebasic_sdchild (owner_id); +alter table ebasic_sdchild add constraint fk_ebasic_sdchild_owner_id foreign key (owner_id) references ebasic_soft_delete (id) on delete restrict on update restrict; + +create index ix_ecache_child_root_id on ecache_child (root_id); +alter table ecache_child add constraint fk_ecache_child_root_id foreign key (root_id) references ecache_root (id) on delete restrict on update restrict; + +alter table edefault_prop add constraint fk_edefault_prop_e_simple_usertypeid foreign key (e_simple_usertypeid) references esimple (usertypeid) on delete restrict on update restrict; + +create index ix_eemb_inner_outer_id on eemb_inner (outer_id); +alter table eemb_inner add constraint fk_eemb_inner_outer_id foreign key (outer_id) references eemb_outer (id) on delete restrict on update restrict; + +create index ix_einvoice_person_id on einvoice (person_id); +alter table einvoice add constraint fk_einvoice_person_id foreign key (person_id) references eperson (id) on delete restrict on update restrict; + +create index ix_enull_collection_detail_enull_collection_id on enull_collection_detail (enull_collection_id); +alter table enull_collection_detail add constraint fk_enull_collection_detail_enull_collection_id foreign key (enull_collection_id) references enull_collection (id) on delete restrict on update restrict; + +create index ix_eopt_one_a_b_id on eopt_one_a (b_id); +alter table eopt_one_a add constraint fk_eopt_one_a_b_id foreign key (b_id) references eopt_one_b (id) on delete restrict on update restrict; + +create index ix_eopt_one_b_c_id on eopt_one_b (c_id); +alter table eopt_one_b add constraint fk_eopt_one_b_c_id foreign key (c_id) references eopt_one_c (id) on delete restrict on update restrict; + +create index ix_eper_addr_ma_country_code on eper_addr (ma_country_code); +alter table eper_addr add constraint fk_eper_addr_ma_country_code foreign key (ma_country_code) references o_country (code) on delete restrict on update restrict; + +create index ix_esoft_del_book_lend_by_id on esoft_del_book (lend_by_id); +alter table esoft_del_book add constraint fk_esoft_del_book_lend_by_id foreign key (lend_by_id) references esoft_del_user (id) on delete restrict on update restrict; + +create index ix_esoft_del_book_esoft_del_user_esoft_del_book on esoft_del_book_esoft_del_user (esoft_del_book_id); +alter table esoft_del_book_esoft_del_user add constraint fk_esoft_del_book_esoft_del_user_esoft_del_book foreign key (esoft_del_book_id) references esoft_del_book (id) on delete restrict on update restrict; + +create index ix_esoft_del_book_esoft_del_user_esoft_del_user on esoft_del_book_esoft_del_user (esoft_del_user_id); +alter table esoft_del_book_esoft_del_user add constraint fk_esoft_del_book_esoft_del_user_esoft_del_user foreign key (esoft_del_user_id) references esoft_del_user (id) on delete restrict on update restrict; + +create index ix_esoft_del_down_esoft_del_mid_id on esoft_del_down (esoft_del_mid_id); +alter table esoft_del_down add constraint fk_esoft_del_down_esoft_del_mid_id foreign key (esoft_del_mid_id) references esoft_del_mid (id) on delete restrict on update restrict; + +create index ix_esoft_del_mid_top_id on esoft_del_mid (top_id); +alter table esoft_del_mid add constraint fk_esoft_del_mid_top_id foreign key (top_id) references esoft_del_top (id) on delete restrict on update restrict; + +create index ix_esoft_del_mid_up_id on esoft_del_mid (up_id); +alter table esoft_del_mid add constraint fk_esoft_del_mid_up_id foreign key (up_id) references esoft_del_up (id) on delete restrict on update restrict; + +alter table esoft_del_one_a add constraint fk_esoft_del_one_a_oneb_id foreign key (oneb_id) references esoft_del_one_b (id) on delete restrict on update restrict; + +create index ix_esoft_del_role_esoft_del_user_esoft_del_role on esoft_del_role_esoft_del_user (esoft_del_role_id); +alter table esoft_del_role_esoft_del_user add constraint fk_esoft_del_role_esoft_del_user_esoft_del_role foreign key (esoft_del_role_id) references esoft_del_role (id) on delete restrict on update restrict; + +create index ix_esoft_del_role_esoft_del_user_esoft_del_user on esoft_del_role_esoft_del_user (esoft_del_user_id); +alter table esoft_del_role_esoft_del_user add constraint fk_esoft_del_role_esoft_del_user_esoft_del_user foreign key (esoft_del_user_id) references esoft_del_user (id) on delete restrict on update restrict; + +create index ix_esoft_del_user_esoft_del_role_esoft_del_user on esoft_del_user_esoft_del_role (esoft_del_user_id); +alter table esoft_del_user_esoft_del_role add constraint fk_esoft_del_user_esoft_del_role_esoft_del_user foreign key (esoft_del_user_id) references esoft_del_user (id) on delete restrict on update restrict; + +create index ix_esoft_del_user_esoft_del_role_esoft_del_role on esoft_del_user_esoft_del_role (esoft_del_role_id); +alter table esoft_del_user_esoft_del_role add constraint fk_esoft_del_user_esoft_del_role_esoft_del_role foreign key (esoft_del_role_id) references esoft_del_role (id) on delete restrict on update restrict; + +create index ix_rawinherit_uncle_parent_id on rawinherit_uncle (parent_id); +alter table rawinherit_uncle add constraint fk_rawinherit_uncle_parent_id foreign key (parent_id) references rawinherit_parent (id) on delete restrict on update restrict; + +create index ix_evanilla_collection_detail_evanilla_collection_id on evanilla_collection_detail (evanilla_collection_id); +alter table evanilla_collection_detail add constraint fk_evanilla_collection_detail_evanilla_collection_id foreign key (evanilla_collection_id) references evanilla_collection (id) on delete restrict on update restrict; + +create index ix_ec_enum_person_tags_ec_enum_person_id on ec_enum_person_tags (ec_enum_person_id); +alter table ec_enum_person_tags add constraint fk_ec_enum_person_tags_ec_enum_person_id foreign key (ec_enum_person_id) references ec_enum_person (id) on delete restrict on update restrict; + +create index ix_ec_person_phone_owner_id on ec_person_phone (owner_id); +alter table ec_person_phone add constraint fk_ec_person_phone_owner_id foreign key (owner_id) references ec_person (id) on delete restrict on update restrict; + +create index ix_ec_top_person_id on ec_top (person_id); +alter table ec_top add constraint fk_ec_top_person_id foreign key (person_id) references ecs_person (id) on delete restrict on update restrict; + +create index ix_ec_top_ecs_person_ec_top on ec_top_ecs_person (ec_top_id); +alter table ec_top_ecs_person add constraint fk_ec_top_ecs_person_ec_top foreign key (ec_top_id) references ec_top (id) on delete restrict on update restrict; + +create index ix_ec_top_ecs_person_ecs_person on ec_top_ecs_person (ecs_person_id); +alter table ec_top_ecs_person add constraint fk_ec_top_ecs_person_ecs_person foreign key (ecs_person_id) references ecs_person (id) on delete restrict on update restrict; + +create index ix_ecbl_person_phone_numbers_person_id on ecbl_person_phone_numbers (person_id); +alter table ecbl_person_phone_numbers add constraint fk_ecbl_person_phone_numbers_person_id foreign key (person_id) references ecbl_person (id) on delete restrict on update restrict; + +create index ix_ecbm_person_phone_numbers_person_id on ecbm_person_phone_numbers (person_id); +alter table ecbm_person_phone_numbers add constraint fk_ecbm_person_phone_numbers_person_id foreign key (person_id) references ecbm_person (id) on delete restrict on update restrict; + +create index ix_ecm_person_phone_numbers_ecm_person_id on ecm_person_phone_numbers (ecm_person_id); +alter table ecm_person_phone_numbers add constraint fk_ecm_person_phone_numbers_ecm_person_id foreign key (ecm_person_id) references ecm_person (id) on delete restrict on update restrict; + +create index ix_ecmc_person_phone_numbers_ecmc_person_id on ecmc_person_phone_numbers (ecmc_person_id); +alter table ecmc_person_phone_numbers add constraint fk_ecmc_person_phone_numbers_ecmc_person_id foreign key (ecmc_person_id) references ecmc_person (id) on delete restrict on update restrict; + +create index ix_ecs_person_phone_ecs_person_id on ecs_person_phone (ecs_person_id); +alter table ecs_person_phone add constraint fk_ecs_person_phone_ecs_person_id foreign key (ecs_person_id) references ecs_person (id) on delete restrict on update restrict; + +create index ix_ecsm_child_ecsm_parent_id on ecsm_child (ecsm_parent_id); +alter table ecsm_child add constraint fk_ecsm_child_ecsm_parent_id foreign key (ecsm_parent_id) references ecsm_parent (id) on delete restrict on update restrict; + +create index ix_td_child_parent_id on td_child (parent_id); +alter table td_child add constraint fk_td_child_parent_id foreign key (parent_id) references td_parent (parent_id) on delete restrict on update restrict; + +create index ix_element_bean_complex_bean_id on element_bean (complex_bean_id); +alter table element_bean add constraint fk_element_bean_complex_bean_id foreign key (complex_bean_id) references root_bean (id) on delete restrict on update restrict; + +create index ix_empl_default_address_id on empl (default_address_id); +alter table empl add constraint fk_empl_default_address_id foreign key (default_address_id) references addr (id) on delete restrict on update restrict; + +create index ix_esd_detail_master_id on esd_detail (master_id); +alter table esd_detail add constraint fk_esd_detail_master_id foreign key (master_id) references esd_master (id) on delete restrict on update restrict; + +create index ix_grand_parent_person_some_bean_id on grand_parent_person (some_bean_id); +alter table grand_parent_person add constraint fk_grand_parent_person_some_bean_id foreign key (some_bean_id) references e_basic (id) on delete restrict on update restrict; + +create index ix_survey_group_categoryobjectid on survey_group (categoryobjectid); +alter table survey_group add constraint fk_survey_group_categoryobjectid foreign key (categoryobjectid) references category (id) on delete restrict on update restrict; + +create index ix_hx_link_doc_hx_link on hx_link_doc (hx_link_id); +alter table hx_link_doc add constraint fk_hx_link_doc_hx_link foreign key (hx_link_id) references hx_link (id) on delete restrict on update restrict; + +create index ix_hx_link_doc_he_doc on hx_link_doc (he_doc_id); +alter table hx_link_doc add constraint fk_hx_link_doc_he_doc foreign key (he_doc_id) references he_doc (id) on delete restrict on update restrict; + +create index ix_hi_link_doc_hi_link on hi_link_doc (hi_link_id); +alter table hi_link_doc add constraint fk_hi_link_doc_hi_link foreign key (hi_link_id) references hi_link (id) on delete restrict on update restrict; + +create index ix_hi_link_doc_hi_doc on hi_link_doc (hi_doc_id); +alter table hi_link_doc add constraint fk_hi_link_doc_hi_doc foreign key (hi_doc_id) references hi_doc (id) on delete restrict on update restrict; + +create index ix_hi_tthree_hi_ttwo_id on hi_tthree (hi_ttwo_id); +alter table hi_tthree add constraint fk_hi_tthree_hi_ttwo_id foreign key (hi_ttwo_id) references hi_ttwo (id) on delete restrict on update restrict; + +create index ix_hi_ttwo_hi_tone_id on hi_ttwo (hi_tone_id); +alter table hi_ttwo add constraint fk_hi_ttwo_hi_tone_id foreign key (hi_tone_id) references hi_tone (id) on delete restrict on update restrict; + +alter table hsd_setting add constraint fk_hsd_setting_user_id foreign key (user_id) references hsd_user (id) on delete restrict on update restrict; + +create index ix_iaf_segment_status_id on iaf_segment (status_id); +alter table iaf_segment add constraint fk_iaf_segment_status_id foreign key (status_id) references iaf_segment_status (id) on delete restrict on update restrict; + +create index ix_imrelated_owner_id on imrelated (owner_id); +alter table imrelated add constraint fk_imrelated_owner_id foreign key (owner_id) references imroot (id) on delete restrict on update restrict; + +create index ix_info_contact_company_id on info_contact (company_id); +alter table info_contact add constraint fk_info_contact_company_id foreign key (company_id) references info_company (id) on delete restrict on update restrict; + +alter table info_customer add constraint fk_info_customer_company_id foreign key (company_id) references info_company (id) on delete restrict on update restrict; + +alter table inner_report add constraint fk_inner_report_forecast_id foreign key (forecast_id) references stockforecast (id) on delete restrict on update restrict; + +create index ix_drel_invoice_booking on drel_invoice (booking); +alter table drel_invoice add constraint fk_drel_invoice_booking foreign key (booking) references drel_booking (id) on delete restrict on update restrict; + +create index ix_item_etype on item (customer,type); +alter table item add constraint fk_item_etype foreign key (customer,type) references `type` (customer,type) on delete restrict on update restrict; + +create index ix_item_eregion on item (customer,region); +alter table item add constraint fk_item_eregion foreign key (customer,region) references region (customer,type) on delete restrict on update restrict; + +alter table mkeygroup_monkey add constraint fk_mkeygroup_monkey_mkeygroup foreign key (mkeygroup_pid) references mkeygroup (pid) on delete restrict on update restrict; + +alter table mkeygroup_monkey add constraint fk_mkeygroup_monkey_monkey foreign key (monkey_mid) references monkey (mid) on delete restrict on update restrict; + +alter table trainer_monkey add constraint fk_trainer_monkey_trainer foreign key (trainer_tid) references trainer (tid) on delete restrict on update restrict; + +alter table trainer_monkey add constraint fk_trainer_monkey_monkey foreign key (monkey_mid) references monkey (mid) on delete restrict on update restrict; + +alter table troop_monkey add constraint fk_troop_monkey_troop foreign key (troop_pid) references troop (pid) on delete restrict on update restrict; + +alter table troop_monkey add constraint fk_troop_monkey_monkey foreign key (monkey_mid) references monkey (mid) on delete restrict on update restrict; + +create index ix_l2_cldf_reset_bean_child_parent_id on l2_cldf_reset_bean_child (parent_id); +alter table l2_cldf_reset_bean_child add constraint fk_l2_cldf_reset_bean_child_parent_id foreign key (parent_id) references l2_cldf_reset_bean (id) on delete restrict on update restrict; + +create index ix_level1_level4_level1 on level1_level4 (level1_id); +alter table level1_level4 add constraint fk_level1_level4_level1 foreign key (level1_id) references level1 (id) on delete restrict on update restrict; + +create index ix_level1_level4_level4 on level1_level4 (level4_id); +alter table level1_level4 add constraint fk_level1_level4_level4 foreign key (level4_id) references level4 (id) on delete restrict on update restrict; + +create index ix_level1_level2_level1 on level1_level2 (level1_id); +alter table level1_level2 add constraint fk_level1_level2_level1 foreign key (level1_id) references level1 (id) on delete restrict on update restrict; + +create index ix_level1_level2_level2 on level1_level2 (level2_id); +alter table level1_level2 add constraint fk_level1_level2_level2 foreign key (level2_id) references level2 (id) on delete restrict on update restrict; + +create index ix_level2_level3_level2 on level2_level3 (level2_id); +alter table level2_level3 add constraint fk_level2_level3_level2 foreign key (level2_id) references level2 (id) on delete restrict on update restrict; + +create index ix_level2_level3_level3 on level2_level3 (level3_id); +alter table level2_level3 add constraint fk_level2_level3_level3 foreign key (level3_id) references level3 (id) on delete restrict on update restrict; + +alter table link add constraint fk_link_id foreign key (id) references link_draft (id) on delete restrict on update restrict; + +create index ix_la_attr_value_attribute_la_attr_value on la_attr_value_attribute (la_attr_value_id); +alter table la_attr_value_attribute add constraint fk_la_attr_value_attribute_la_attr_value foreign key (la_attr_value_id) references la_attr_value (id) on delete restrict on update restrict; + +create index ix_la_attr_value_attribute_attribute on la_attr_value_attribute (attribute_id); +alter table la_attr_value_attribute add constraint fk_la_attr_value_attribute_attribute foreign key (attribute_id) references attribute (id) on delete restrict on update restrict; + +create index ix_looney_tune_id on looney (tune_id); +alter table looney add constraint fk_looney_tune_id foreign key (tune_id) references tune (id) on delete restrict on update restrict; + +create index ix_mcontact_customer_id on mcontact (customer_id); +alter table mcontact add constraint fk_mcontact_customer_id foreign key (customer_id) references mcustomer (id) on delete restrict on update restrict; + +create index ix_mcontact_message_contact_id on mcontact_message (contact_id); +alter table mcontact_message add constraint fk_mcontact_message_contact_id foreign key (contact_id) references mcontact (id) on delete restrict on update restrict; + +create index ix_mcustomer_shipping_address_id on mcustomer (shipping_address_id); +alter table mcustomer add constraint fk_mcustomer_shipping_address_id foreign key (shipping_address_id) references maddress (id) on delete restrict on update restrict; + +create index ix_mcustomer_billing_address_id on mcustomer (billing_address_id); +alter table mcustomer add constraint fk_mcustomer_billing_address_id foreign key (billing_address_id) references maddress (id) on delete restrict on update restrict; + +create index ix_mmachine_mgroup_mmachine on mmachine_mgroup (mmachine_id); +alter table mmachine_mgroup add constraint fk_mmachine_mgroup_mmachine foreign key (mmachine_id) references mmachine (id) on delete restrict on update restrict; + +create index ix_mmachine_mgroup_mgroup on mmachine_mgroup (mgroup_id); +alter table mmachine_mgroup add constraint fk_mmachine_mgroup_mgroup foreign key (mgroup_id) references mgroup (id) on delete restrict on update restrict; + +create index ix_mprinter_current_state_id on mprinter (current_state_id); +alter table mprinter add constraint fk_mprinter_current_state_id foreign key (current_state_id) references mprinter_state (id) on delete restrict on update restrict; + +alter table mprinter add constraint fk_mprinter_last_swap_cyan_id foreign key (last_swap_cyan_id) references mprinter_state (id) on delete restrict on update restrict; + +alter table mprinter add constraint fk_mprinter_last_swap_magenta_id foreign key (last_swap_magenta_id) references mprinter_state (id) on delete restrict on update restrict; + +alter table mprinter add constraint fk_mprinter_last_swap_yellow_id foreign key (last_swap_yellow_id) references mprinter_state (id) on delete restrict on update restrict; + +alter table mprinter add constraint fk_mprinter_last_swap_black_id foreign key (last_swap_black_id) references mprinter_state (id) on delete restrict on update restrict; + +create index ix_mprinter_state_printer_id on mprinter_state (printer_id); +alter table mprinter_state add constraint fk_mprinter_state_printer_id foreign key (printer_id) references mprinter (id) on delete restrict on update restrict; + +create index ix_mprofile_picture_id on mprofile (picture_id); +alter table mprofile add constraint fk_mprofile_picture_id foreign key (picture_id) references mmedia (id) on delete restrict on update restrict; + +create index ix_mrole_muser_mrole on mrole_muser (mrole_roleid); +alter table mrole_muser add constraint fk_mrole_muser_mrole foreign key (mrole_roleid) references mrole (roleid) on delete restrict on update restrict; + +create index ix_mrole_muser_muser on mrole_muser (muser_userid); +alter table mrole_muser add constraint fk_mrole_muser_muser foreign key (muser_userid) references muser (userid) on delete restrict on update restrict; + +create index ix_muser_user_type_id on muser (user_type_id); +alter table muser add constraint fk_muser_user_type_id foreign key (user_type_id) references muser_type (id) on delete restrict on update restrict; + +create index ix_mail_user_inbox_mail_user on mail_user_inbox (mail_user_id); +alter table mail_user_inbox add constraint fk_mail_user_inbox_mail_user foreign key (mail_user_id) references mail_user (id) on delete restrict on update restrict; + +create index ix_mail_user_inbox_mail_box on mail_user_inbox (mail_box_id); +alter table mail_user_inbox add constraint fk_mail_user_inbox_mail_box foreign key (mail_box_id) references mail_box (id) on delete restrict on update restrict; + +create index ix_mail_user_outbox_mail_user on mail_user_outbox (mail_user_id); +alter table mail_user_outbox add constraint fk_mail_user_outbox_mail_user foreign key (mail_user_id) references mail_user (id) on delete restrict on update restrict; + +create index ix_mail_user_outbox_mail_box on mail_user_outbox (mail_box_id); +alter table mail_user_outbox add constraint fk_mail_user_outbox_mail_box foreign key (mail_box_id) references mail_box (id) on delete restrict on update restrict; + +create index ix_c_message_conversation_id on c_message (conversation_id); +alter table c_message add constraint fk_c_message_conversation_id foreign key (conversation_id) references c_conversation (id) on delete restrict on update restrict; + +create index ix_c_message_user_id on c_message (user_id); +alter table c_message add constraint fk_c_message_user_id foreign key (user_id) references c_user (id) on delete restrict on update restrict; + +alter table meter_contract_data add constraint fk_meter_contract_data_special_needs_client_id foreign key (special_needs_client_id) references meter_special_needs_client (id) on delete restrict on update restrict; + +alter table meter_special_needs_client add constraint fk_meter_special_needs_client_primary_id foreign key (primary_id) references meter_special_needs_contact (id) on delete restrict on update restrict; + +alter table meter_version add constraint fk_meter_version_address_data_id foreign key (address_data_id) references meter_address_data (id) on delete restrict on update restrict; + +alter table meter_version add constraint fk_meter_version_contract_data_id foreign key (contract_data_id) references meter_contract_data (id) on delete restrict on update restrict; + +create index ix_mnoc_user_mnoc_role_mnoc_user on mnoc_user_mnoc_role (mnoc_user_user_id); +alter table mnoc_user_mnoc_role add constraint fk_mnoc_user_mnoc_role_mnoc_user foreign key (mnoc_user_user_id) references mnoc_user (user_id) on delete restrict on update restrict; + +create index ix_mnoc_user_mnoc_role_mnoc_role on mnoc_user_mnoc_role (mnoc_role_role_id); +alter table mnoc_user_mnoc_role add constraint fk_mnoc_user_mnoc_role_mnoc_role foreign key (mnoc_role_role_id) references mnoc_role (role_id) on delete restrict on update restrict; + +create index ix_mny_b_a_id on mny_b (a_id); +alter table mny_b add constraint fk_mny_b_a_id foreign key (a_id) references mny_a (id) on delete restrict on update restrict; + +create index ix_mny_b_mny_c_mny_b on mny_b_mny_c (mny_b_id); +alter table mny_b_mny_c add constraint fk_mny_b_mny_c_mny_b foreign key (mny_b_id) references mny_b (id) on delete restrict on update restrict; + +create index ix_mny_b_mny_c_mny_c on mny_b_mny_c (mny_c_id); +alter table mny_b_mny_c add constraint fk_mny_b_mny_c_mny_c foreign key (mny_c_id) references mny_c (id) on delete restrict on update restrict; + +create index ix_subtopics_mny_topic_1 on subtopics (topic); +alter table subtopics add constraint fk_subtopics_mny_topic_1 foreign key (topic) references mny_topic (id) on delete restrict on update restrict; + +create index ix_subtopics_mny_topic_2 on subtopics (subtopic); +alter table subtopics add constraint fk_subtopics_mny_topic_2 foreign key (subtopic) references mny_topic (id) on delete restrict on update restrict; + +create index ix_mp_role_mp_user_id on mp_role (mp_user_id); +alter table mp_role add constraint fk_mp_role_mp_user_id foreign key (mp_user_id) references mp_user (id) on delete restrict on update restrict; + +create index ix_ms_many_a_many_b_ms_many_a on ms_many_a_many_b (ms_many_a_aid); +alter table ms_many_a_many_b add constraint fk_ms_many_a_many_b_ms_many_a foreign key (ms_many_a_aid) references ms_many_a (aid) on delete restrict on update restrict; + +create index ix_ms_many_a_many_b_ms_many_b on ms_many_a_many_b (ms_many_b_bid); +alter table ms_many_a_many_b add constraint fk_ms_many_a_many_b_ms_many_b foreign key (ms_many_b_bid) references ms_many_b (bid) on delete restrict on update restrict; + +create index ix_ms_many_b_many_a_ms_many_b on ms_many_b_many_a (ms_many_b_bid); +alter table ms_many_b_many_a add constraint fk_ms_many_b_many_a_ms_many_b foreign key (ms_many_b_bid) references ms_many_b (bid) on delete restrict on update restrict; + +create index ix_ms_many_b_many_a_ms_many_a on ms_many_b_many_a (ms_many_a_aid); +alter table ms_many_b_many_a add constraint fk_ms_many_b_many_a_ms_many_a foreign key (ms_many_a_aid) references ms_many_a (aid) on delete restrict on update restrict; + +create index ix_my_lob_size_join_many_parent_id on my_lob_size_join_many (parent_id); +alter table my_lob_size_join_many add constraint fk_my_lob_size_join_many_parent_id foreign key (parent_id) references my_lob_size (id) on delete restrict on update restrict; + +create index ix_o_bean_child_cached_bean_id on o_bean_child (cached_bean_id); +alter table o_bean_child add constraint fk_o_bean_child_cached_bean_id foreign key (cached_bean_id) references o_cached_bean (id) on delete restrict on update restrict; + +create index ix_ocached_app_detail_app_id on ocached_app_detail (app_id); +alter table ocached_app_detail add constraint fk_ocached_app_detail_app_id foreign key (app_id) references ocached_app (id) on delete restrict on update restrict; + +create index ix_o_cached_bean_country_o_cached_bean on o_cached_bean_country (o_cached_bean_id); +alter table o_cached_bean_country add constraint fk_o_cached_bean_country_o_cached_bean foreign key (o_cached_bean_id) references o_cached_bean (id) on delete restrict on update restrict; + +create index ix_o_cached_bean_country_o_country on o_cached_bean_country (o_country_code); +alter table o_cached_bean_country add constraint fk_o_cached_bean_country_o_country foreign key (o_country_code) references o_country (code) on delete restrict on update restrict; + +create index ix_o_cached_bean_child_cached_bean_id on o_cached_bean_child (cached_bean_id); +alter table o_cached_bean_child add constraint fk_o_cached_bean_child_cached_bean_id foreign key (cached_bean_id) references o_cached_bean (id) on delete restrict on update restrict; + +alter table oengine add constraint fk_oengine_car_id foreign key (car_id) references ocar (id) on delete restrict on update restrict; + +alter table ogear_box add constraint fk_ogear_box_car_id foreign key (car_id) references ocar (id) on delete restrict on update restrict; + +create index ix_omvertex_other_omvertex_id on omvertex_other (omvertex_id); +alter table omvertex_other add constraint fk_omvertex_other_omvertex_id foreign key (omvertex_id) references omvertex (id) on delete restrict on update restrict; + +alter table oroad_show_msg add constraint fk_oroad_show_msg_company_id foreign key (company_id) references ocompany (id) on delete restrict on update restrict; + +create index ix_om_account_child_dbo_banana_rama_id on om_account_child_dbo (banana_rama_id); +alter table om_account_child_dbo add constraint fk_om_account_child_dbo_banana_rama_id foreign key (banana_rama_id) references om_account_dbo (id) on delete restrict on update restrict; + +create index ix_om_basic_child_parent_id on om_basic_child (parent_id); +alter table om_basic_child add constraint fk_om_basic_child_parent_id foreign key (parent_id) references om_basic_parent (id) on delete restrict on update restrict; + +create index ix_om_ordered_detail_master_id on om_ordered_detail (master_id); +alter table om_ordered_detail add constraint fk_om_ordered_detail_master_id foreign key (master_id) references om_ordered_master (id) on delete restrict on update restrict; + +create index ix_o_order_kcustomer_id on o_order (kcustomer_id); +alter table o_order add constraint fk_o_order_kcustomer_id foreign key (kcustomer_id) references o_customer (id) on delete restrict on update restrict; + +create index ix_o_order_detail_order_id on o_order_detail (order_id); +alter table o_order_detail add constraint fk_o_order_detail_order_id foreign key (order_id) references o_order (id) on delete restrict on update restrict; + +create index ix_o_order_detail_product_id on o_order_detail (product_id); +alter table o_order_detail add constraint fk_o_order_detail_product_id foreign key (product_id) references o_product (id) on delete restrict on update restrict; + +create index ix_s_order_items_order_uuid on s_order_items (order_uuid); +alter table s_order_items add constraint fk_s_order_items_order_uuid foreign key (order_uuid) references s_orders (uuid) on delete restrict on update restrict; + +create index ix_or_order_ship_order_id on or_order_ship (order_id); +alter table or_order_ship add constraint fk_or_order_ship_order_id foreign key (order_id) references o_order (id) on delete restrict on update restrict; + +alter table organization_node add constraint fk_organization_node_parent_tree_node_id foreign key (parent_tree_node_id) references organization_tree_node (id) on delete restrict on update restrict; + +create index ix_orp_detail_master_id on orp_detail (master_id); +alter table orp_detail add constraint fk_orp_detail_master_id foreign key (master_id) references orp_master (id) on delete restrict on update restrict; + +create index ix_orp_detail2_orp_master2_id on orp_detail2 (orp_master2_id); +alter table orp_detail2 add constraint fk_orp_detail2_orp_master2_id foreign key (orp_master2_id) references orp_master2 (id) on delete restrict on update restrict; + +alter table oto_atwo add constraint fk_oto_atwo_aone_id foreign key (aone_id) references oto_aone (id) on delete restrict on update restrict; + +alter table oto_bchild add constraint fk_oto_bchild_master_id foreign key (master_id) references oto_bmaster (id) on delete restrict on update restrict; + +alter table oto_child add constraint fk_oto_child_master_id foreign key (master_id) references oto_master (id) on delete restrict on update restrict; + +alter table oto_cust_address add constraint fk_oto_cust_address_customer_cid foreign key (customer_cid) references oto_cust (cid) on delete restrict on update restrict; + +alter table oto_level_a add constraint fk_oto_level_a_b_id foreign key (b_id) references oto_level_b (id) on delete restrict on update restrict; + +alter table oto_level_b add constraint fk_oto_level_b_c_id foreign key (c_id) references oto_level_c (id) on delete restrict on update restrict; + +alter table oto_prime_extra add constraint fk_oto_prime_extra_eid foreign key (eid) references oto_prime (pid) on delete restrict on update restrict; + +alter table oto_sd_child add constraint fk_oto_sd_child_master_id foreign key (master_id) references oto_sd_master (id) on delete restrict on update restrict; + +create index ix_oto_th_many_oto_th_top_id on oto_th_many (oto_th_top_id); +alter table oto_th_many add constraint fk_oto_th_many_oto_th_top_id foreign key (oto_th_top_id) references oto_th_top (id) on delete restrict on update restrict; + +alter table oto_th_one add constraint fk_oto_th_one_many_id foreign key (many_id) references oto_th_many (id) on delete restrict on update restrict; + +alter table oto_ubprime_extra add constraint fk_oto_ubprime_extra_eid foreign key (eid) references oto_ubprime (pid) on delete restrict on update restrict; + +alter table oto_user_model add constraint fk_oto_user_model_user_optional_id foreign key (user_optional_id) references oto_user_model_optional (id) on delete restrict on update restrict; + +alter table pfile add constraint fk_pfile_file_content_id foreign key (file_content_id) references pfile_content (id) on delete restrict on update restrict; + +alter table pfile add constraint fk_pfile_file_content2_id foreign key (file_content2_id) references pfile_content (id) on delete restrict on update restrict; + +alter table paggview add constraint fk_paggview_pview_id foreign key (pview_id) references pp (id) on delete restrict on update restrict; + +create index ix_pallet_location_zone_sid on pallet_location (zone_sid); +alter table pallet_location add constraint fk_pallet_location_zone_sid foreign key (zone_sid) references zones (id) on delete restrict on update restrict; + +alter table parcel_location add constraint fk_parcel_location_parcelid foreign key (parcelid) references parcel (parcelid) on delete restrict on update restrict; + +create index ix_rawinherit_parent_rawinherit_data_rawinherit_parent on rawinherit_parent_rawinherit_data (rawinherit_parent_id); +alter table rawinherit_parent_rawinherit_data add constraint fk_rawinherit_parent_rawinherit_data_rawinherit_parent foreign key (rawinherit_parent_id) references rawinherit_parent (id) on delete restrict on update restrict; + +create index ix_rawinherit_parent_rawinherit_data_rawinherit_data on rawinherit_parent_rawinherit_data (rawinherit_data_id); +alter table rawinherit_parent_rawinherit_data add constraint fk_rawinherit_parent_rawinherit_data_rawinherit_data foreign key (rawinherit_data_id) references rawinherit_data (id) on delete restrict on update restrict; + +create index ix_parent_person_some_bean_id on parent_person (some_bean_id); +alter table parent_person add constraint fk_parent_person_some_bean_id foreign key (some_bean_id) references e_basic (id) on delete restrict on update restrict; + +create index ix_parent_person_parent_identifier on parent_person (parent_identifier); +alter table parent_person add constraint fk_parent_person_parent_identifier foreign key (parent_identifier) references grand_parent_person (identifier) on delete restrict on update restrict; + +create index ix_c_participation_conversation_id on c_participation (conversation_id); +alter table c_participation add constraint fk_c_participation_conversation_id foreign key (conversation_id) references c_conversation (id) on delete restrict on update restrict; + +create index ix_c_participation_user_id on c_participation (user_id); +alter table c_participation add constraint fk_c_participation_user_id foreign key (user_id) references c_user (id) on delete restrict on update restrict; + +create index ix_pcf_calendar_pcf_person_id on pcf_calendar (pcf_person_id); +alter table pcf_calendar add constraint fk_pcf_calendar_pcf_person_id foreign key (pcf_person_id) references pcf_person (id) on delete restrict on update restrict; + +create index ix_pcf_city_pcf_country_id on pcf_city (pcf_country_id); +alter table pcf_city add constraint fk_pcf_city_pcf_country_id foreign key (pcf_country_id) references pcf_country (id) on delete restrict on update restrict; + +alter table pcf_city add constraint fk_pcf_city_mayor_id foreign key (mayor_id) references pcf_person (id) on delete restrict on update restrict; + +alter table pcf_city add constraint fk_pcf_city_vice_mayor_id foreign key (vice_mayor_id) references pcf_person (id) on delete restrict on update restrict; + +create index ix_pcf_event_pcf_calendar_id on pcf_event (pcf_calendar_id); +alter table pcf_event add constraint fk_pcf_event_pcf_calendar_id foreign key (pcf_calendar_id) references pcf_calendar (id) on delete restrict on update restrict; + +alter table persistent_file_content add constraint fk_persistent_file_content_persistent_file_id foreign key (persistent_file_id) references persistent_file (id) on delete restrict on update restrict; + +create index ix_person_default_address_oid on person (default_address_oid); +alter table person add constraint fk_person_default_address_oid foreign key (default_address_oid) references address (oid) on delete restrict on update restrict; + +create index ix_person_cache_email_person_info_person_id on person_cache_email (person_info_person_id); +alter table person_cache_email add constraint fk_person_cache_email_person_info_person_id foreign key (person_info_person_id) references person_cache_info (person_id) on delete restrict on update restrict; + +create index ix_phones_person_id on phones (person_id); +alter table phones add constraint fk_phones_person_id foreign key (person_id) references persons (id) on delete restrict on update restrict; + +create index ix_e_position_contract_id on e_position (contract_id); +alter table e_position add constraint fk_e_position_contract_id foreign key (contract_id) references contract (id) on delete restrict on update restrict; + +create index ix_pp_to_ww_pp on pp_to_ww (pp_id); +alter table pp_to_ww add constraint fk_pp_to_ww_pp foreign key (pp_id) references pp (id) on delete restrict on update restrict; + +create index ix_pp_to_ww_wview on pp_to_ww (ww_id); +alter table pp_to_ww add constraint fk_pp_to_ww_wview foreign key (ww_id) references wview (id) on delete restrict on update restrict; + +create index ix_question_groupobjectid on question (groupobjectid); +alter table question add constraint fk_question_groupobjectid foreign key (groupobjectid) references survey_group (id) on delete restrict on update restrict; + +create index ix_r_orders_customer on r_orders (company,customername); +alter table r_orders add constraint fk_r_orders_customer foreign key (company,customername) references rcustomer (company,name) on delete restrict on update restrict; + +create index ix_rel_master_detail_id on rel_master (detail_id); +alter table rel_master add constraint fk_rel_master_detail_id foreign key (detail_id) references rel_detail (id) on delete restrict on update restrict; + +create index ix_resourcefile_parentresourcefileid on resourcefile (parentresourcefileid); +alter table resourcefile add constraint fk_resourcefile_parentresourcefileid foreign key (parentresourcefileid) references resourcefile (id) on delete restrict on update restrict; + +create index ix_mt_role_tenant_id on mt_role (tenant_id); +alter table mt_role add constraint fk_mt_role_tenant_id foreign key (tenant_id) references mt_tenant (id) on delete restrict on update restrict; + +create index ix_mt_role_permission_mt_role on mt_role_permission (mt_role_id); +alter table mt_role_permission add constraint fk_mt_role_permission_mt_role foreign key (mt_role_id) references mt_role (id) on delete restrict on update restrict; + +create index ix_mt_role_permission_mt_permission on mt_role_permission (mt_permission_id); +alter table mt_role_permission add constraint fk_mt_role_permission_mt_permission foreign key (mt_permission_id) references mt_permission (id) on delete restrict on update restrict; + +create index ix_root_bean_referencing_bean_id on root_bean (referencing_bean_id); +alter table root_bean add constraint fk_root_bean_referencing_bean_id foreign key (referencing_bean_id) references referencing_bean (id) on delete restrict on update restrict; + +alter table f_second add constraint fk_f_second_first foreign key (first) references f_first (id) on delete restrict on update restrict; + +create index ix_section_article_id on section (article_id); +alter table section add constraint fk_section_article_id foreign key (article_id) references article (id) on delete restrict on update restrict; + +create index ix_self_parent_parent_id on self_parent (parent_id); +alter table self_parent add constraint fk_self_parent_parent_id foreign key (parent_id) references self_parent (id) on delete restrict on update restrict; + +create index ix_self_ref_customer_referred_by_id on self_ref_customer (referred_by_id); +alter table self_ref_customer add constraint fk_self_ref_customer_referred_by_id foreign key (referred_by_id) references self_ref_customer (id) on delete restrict on update restrict; + +create index ix_self_ref_example_parent_id on self_ref_example (parent_id); +alter table self_ref_example add constraint fk_self_ref_example_parent_id foreign key (parent_id) references self_ref_example (id) on delete restrict on update restrict; + +alter table e_save_test_b add constraint fk_e_save_test_b_sibling_a_id foreign key (sibling_a_id) references e_save_test_a (id) on delete restrict on update restrict; + +create index ix_site_parent_id on site (parent_id); +alter table site add constraint fk_site_parent_id foreign key (parent_id) references site (id) on delete restrict on update restrict; + +alter table site add constraint fk_site_data_container_id foreign key (data_container_id) references data_container (id) on delete restrict on update restrict; + +alter table site add constraint fk_site_site_address_id foreign key (site_address_id) references site_address (id) on delete restrict on update restrict; + +create index ix_source_base_target_id on source_base (target_id); +alter table source_base add constraint fk_source_base_target_id foreign key (target_id) references target_base (id) on delete restrict on update restrict; + +create index ix_stockforecast_inner_report_id on stockforecast (inner_report_id); +alter table stockforecast add constraint fk_stockforecast_inner_report_id foreign key (inner_report_id) references inner_report (id) on delete restrict on update restrict; + +create index ix_sub_section_section_id on sub_section (section_id); +alter table sub_section add constraint fk_sub_section_section_id foreign key (section_id) references section (id) on delete restrict on update restrict; + +create index ix_tevent_many_event_id on tevent_many (event_id); +alter table tevent_many add constraint fk_tevent_many_event_id foreign key (event_id) references tevent_one (id) on delete restrict on update restrict; + +alter table tevent_one add constraint fk_tevent_one_event_id foreign key (event_id) references tevent (id) on delete restrict on update restrict; + +create index ix_t_detail_with_other_namexxxyy_master_id on t_detail_with_other_namexxxyy (master_id); +alter table t_detail_with_other_namexxxyy add constraint fk_t_detail_with_other_namexxxyy_master_id foreign key (master_id) references t_atable_thatisrelatively (id) on delete restrict on update restrict; + +create index ix_ttruck_holder_truck_plate_no on ttruck_holder (truck_plate_no); +alter table ttruck_holder add constraint fk_ttruck_holder_truck_plate_no foreign key (truck_plate_no) references tcar (plate_no) on delete restrict on update restrict; + +create index ix_ttruck_holder_basic_id on ttruck_holder (basic_id); +alter table ttruck_holder add constraint fk_ttruck_holder_basic_id foreign key (basic_id) references e_basic (id) on delete restrict on update restrict; + +create index ix_ttruck_holder_item_owner_id on ttruck_holder_item (owner_id); +alter table ttruck_holder_item add constraint fk_ttruck_holder_item_owner_id foreign key (owner_id) references ttruck_holder (id) on delete restrict on update restrict; + +create index ix_twheel_owner_plate_no on twheel (owner_plate_no); +alter table twheel add constraint fk_twheel_owner_plate_no foreign key (owner_plate_no) references tcar (plate_no) on delete restrict on update restrict; + +alter table tire add constraint fk_tire_wheel foreign key (wheel) references wheel (id) on delete restrict on update restrict; + +create index ix_tree_entity_parent_id on tree_entity (parent_id); +alter table tree_entity add constraint fk_tree_entity_parent_id foreign key (parent_id) references tree_entity (id) on delete restrict on update restrict; + +create index ix_trip_vehicle_driver_id on trip (vehicle_driver_id); +alter table trip add constraint fk_trip_vehicle_driver_id foreign key (vehicle_driver_id) references vehicle_driver (id) on delete restrict on update restrict; + +create index ix_trip_address_id on trip (address_id); +alter table trip add constraint fk_trip_address_id foreign key (address_id) references o_address (id) on delete restrict on update restrict; + +create index ix_type_sub_type_id on `type` (sub_type_id); +alter table `type` add constraint fk_type_sub_type_id foreign key (sub_type_id) references sub_type (sub_type_id) on delete restrict on update restrict; + +create index ix_usib_child_parent_id on usib_child (parent_id); +alter table usib_child add constraint fk_usib_child_parent_id foreign key (parent_id) references usib_parent (id) on delete restrict on update restrict; + +alter table usib_child_sibling add constraint fk_usib_child_sibling_child_id foreign key (child_id) references usib_child (id) on delete restrict on update restrict; + +create index ix_ut_detail_utmaster_id on ut_detail (utmaster_id); +alter table ut_detail add constraint fk_ut_detail_utmaster_id foreign key (utmaster_id) references ut_master (id) on delete restrict on update restrict; + +create index ix_uutwo_master_id on uutwo (master_id); +alter table uutwo add constraint fk_uutwo_master_id foreign key (master_id) references uuone (id) on delete restrict on update restrict; + +alter table oto_user add constraint fk_oto_user_account_id foreign key (account_id) references oto_account (id) on delete restrict on update restrict; + +create index ix_c_user_group_id on c_user (group_id); +alter table c_user add constraint fk_c_user_group_id foreign key (group_id) references c_group (id) on delete restrict on update restrict; + +create index ix_em_user_role_user_id on em_user_role (user_id); +alter table em_user_role add constraint fk_em_user_role_user_id foreign key (user_id) references em_user (id) on delete restrict on update restrict; + +create index ix_em_user_role_role_id on em_user_role (role_id); +alter table em_user_role add constraint fk_em_user_role_role_id foreign key (role_id) references em_role (id) on delete restrict on update restrict; + +create index ix_vehicle_lease_id on vehicle (lease_id); +alter table vehicle add constraint fk_vehicle_lease_id foreign key (lease_id) references vehicle_lease (id) on delete restrict on update restrict; + +create index ix_vehicle_car_ref_id on vehicle (car_ref_id); +alter table vehicle add constraint fk_vehicle_car_ref_id foreign key (car_ref_id) references truck_ref (id) on delete restrict on update restrict; + +create index ix_vehicle_truck_ref_id on vehicle (truck_ref_id); +alter table vehicle add constraint fk_vehicle_truck_ref_id foreign key (truck_ref_id) references truck_ref (id) on delete restrict on update restrict; + +create index ix_vehicle_driver_vehicle_id on vehicle_driver (vehicle_id); +alter table vehicle_driver add constraint fk_vehicle_driver_vehicle_id foreign key (vehicle_id) references vehicle (id) on delete restrict on update restrict; + +create index ix_vehicle_driver_address_id on vehicle_driver (address_id); +alter table vehicle_driver add constraint fk_vehicle_driver_address_id foreign key (address_id) references o_address (id) on delete restrict on update restrict; + +create index ix_warehouses_officezoneid on warehouses (officezoneid); +alter table warehouses add constraint fk_warehouses_officezoneid foreign key (officezoneid) references zones (id) on delete restrict on update restrict; + +create index ix_warehousesshippingzones_warehouses on warehousesshippingzones (warehouseid); +alter table warehousesshippingzones add constraint fk_warehousesshippingzones_warehouses foreign key (warehouseid) references warehouses (id) on delete restrict on update restrict; + +create index ix_warehousesshippingzones_zones on warehousesshippingzones (shippingzoneid); +alter table warehousesshippingzones add constraint fk_warehousesshippingzones_zones foreign key (shippingzoneid) references zones (id) on delete restrict on update restrict; + +create index ix_sa_wheel_tire on sa_wheel (tire); +alter table sa_wheel add constraint fk_sa_wheel_tire foreign key (tire) references sa_tire (id) on delete restrict on update restrict; + +create index ix_sa_wheel_car on sa_wheel (car); +alter table sa_wheel add constraint fk_sa_wheel_car foreign key (car) references sa_car (id) on delete restrict on update restrict; + +create index ix_g_who_props_otm_who_created_id on g_who_props_otm (who_created_id); +alter table g_who_props_otm add constraint fk_g_who_props_otm_who_created_id foreign key (who_created_id) references g_user (id) on delete restrict on update restrict; + +create index ix_g_who_props_otm_who_modified_id on g_who_props_otm (who_modified_id); +alter table g_who_props_otm add constraint fk_g_who_props_otm_who_modified_id foreign key (who_modified_id) references g_user (id) on delete restrict on update restrict; + +create index ix_with_zero_parent_id on with_zero (parent_id); +alter table with_zero add constraint fk_with_zero_parent_id foreign key (parent_id) references parent (id) on delete restrict on update restrict; + +alter table hx_link add column sys_period_start datetime(6) default now(6); +alter table hx_link add column sys_period_end datetime(6); +update hx_link set sys_period_start = when_created; +create table hx_link_history( + id bigint, + name varchar(255), + location varchar(255), + comments varchar(255), + version bigint, + when_created datetime(6), + when_modified datetime(6), + deleted tinyint(1), + sys_period_start datetime(6), + sys_period_end datetime(6) +); +create view hx_link_with_history as select * from hx_link union all select * from hx_link_history; + +alter table hi_link add column sys_period_start datetime(6) default now(6); +alter table hi_link add column sys_period_end datetime(6); +update hi_link set sys_period_start = when_created; +create table hi_link_history( + id bigint, + name varchar(255), + location varchar(255), + comments varchar(255), + version bigint, + when_created datetime(6), + when_modified datetime(6), + sys_period_start datetime(6), + sys_period_end datetime(6) +); +create view hi_link_with_history as select * from hi_link union all select * from hi_link_history; + +alter table hi_link_doc add column sys_period_start datetime(6) default now(6); +alter table hi_link_doc add column sys_period_end datetime(6); +create table hi_link_doc_history( + hi_link_id bigint, + hi_doc_id bigint, + sys_period_start datetime(6), + sys_period_end datetime(6) +); +create view hi_link_doc_with_history as select * from hi_link_doc union all select * from hi_link_doc_history; + +alter table hi_tone add column sys_period_start datetime(6) default now(6); +alter table hi_tone add column sys_period_end datetime(6); +update hi_tone set sys_period_start = when_created; +create table hi_tone_history( + id bigint, + name varchar(255), + comments varchar(255), + version bigint, + when_created datetime(6), + when_modified datetime(6), + sys_period_start datetime(6), + sys_period_end datetime(6) +); +create view hi_tone_with_history as select * from hi_tone union all select * from hi_tone_history; + +alter table hi_tthree add column sys_period_start datetime(6) default now(6); +alter table hi_tthree add column sys_period_end datetime(6); +update hi_tthree set sys_period_start = when_created; +create table hi_tthree_history( + id bigint, + hi_ttwo_id bigint, + three varchar(255), + version bigint, + when_created datetime(6), + when_modified datetime(6), + sys_period_start datetime(6), + sys_period_end datetime(6) +); +create view hi_tthree_with_history as select * from hi_tthree union all select * from hi_tthree_history; + +alter table hi_ttwo add column sys_period_start datetime(6) default now(6); +alter table hi_ttwo add column sys_period_end datetime(6); +update hi_ttwo set sys_period_start = when_created; +create table hi_ttwo_history( + id bigint, + hi_tone_id bigint, + two varchar(255), + version bigint, + when_created datetime(6), + when_modified datetime(6), + sys_period_start datetime(6), + sys_period_end datetime(6) +); +create view hi_ttwo_with_history as select * from hi_ttwo union all select * from hi_ttwo_history; + +alter table hsd_setting add column sys_period_start datetime(6) default now(6); +alter table hsd_setting add column sys_period_end datetime(6); +update hsd_setting set sys_period_start = when_created; +create table hsd_setting_history( + id bigint, + code varchar(255), + content varchar(255), + user_id bigint, + version bigint, + when_created datetime(6), + when_modified datetime(6), + deleted tinyint(1), + sys_period_start datetime(6), + sys_period_end datetime(6) +); +create view hsd_setting_with_history as select * from hsd_setting union all select * from hsd_setting_history; + +alter table hsd_user add column sys_period_start datetime(6) default now(6); +alter table hsd_user add column sys_period_end datetime(6); +update hsd_user set sys_period_start = when_created; +create table hsd_user_history( + id bigint, + name varchar(255), + version bigint, + when_created datetime(6), + when_modified datetime(6), + deleted tinyint(1), + sys_period_start datetime(6), + sys_period_end datetime(6) +); +create view hsd_user_with_history as select * from hsd_user union all select * from hsd_user_history; + +alter table link add column sys_period_start datetime(6) default now(6); +alter table link add column sys_period_end datetime(6); +update link set sys_period_start = when_created; +create table link_history( + id bigint, + name varchar(255), + location varchar(255), + when_publish datetime(6), + link_comment varchar(255), + version bigint, + when_created datetime(6), + when_modified datetime(6), + deleted tinyint(1), + sys_period_start datetime(6), + sys_period_end datetime(6) +); +create view link_with_history as select * from link union all select * from link_history; + +alter table c_user add column sys_period_start datetime(6) default now(6); +alter table c_user add column sys_period_end datetime(6); +update c_user set sys_period_start = when_created; +create table c_user_history( + id bigint, + inactive tinyint(1), + name varchar(255), + email varchar(255), + password_hash varchar(255), + group_id bigint, + version bigint, + when_created datetime(6), + when_modified datetime(6), + sys_period_start datetime(6), + sys_period_end datetime(6) +); +create view c_user_with_history as select * from c_user union all select * from c_user_history; + +delimiter $$ +create trigger hx_link_history_upd before update on hx_link for each row begin + insert into hx_link_history (sys_period_start,sys_period_end,id, name, location, comments, version, when_created, when_modified, deleted) values (OLD.sys_period_start, now(6),OLD.id, OLD.name, OLD.location, OLD.comments, OLD.version, OLD.when_created, OLD.when_modified, OLD.deleted); + set NEW.sys_period_start = now(6); +end$$ +delimiter $$ +create trigger hx_link_history_del before delete on hx_link for each row begin + insert into hx_link_history (sys_period_start,sys_period_end,id, name, location, comments, version, when_created, when_modified, deleted) values (OLD.sys_period_start, now(6),OLD.id, OLD.name, OLD.location, OLD.comments, OLD.version, OLD.when_created, OLD.when_modified, OLD.deleted); +end$$ +delimiter $$ +create trigger hi_link_history_upd before update on hi_link for each row begin + insert into hi_link_history (sys_period_start,sys_period_end,id, name, location, comments, version, when_created, when_modified) values (OLD.sys_period_start, now(6),OLD.id, OLD.name, OLD.location, OLD.comments, OLD.version, OLD.when_created, OLD.when_modified); + set NEW.sys_period_start = now(6); +end$$ +delimiter $$ +create trigger hi_link_history_del before delete on hi_link for each row begin + insert into hi_link_history (sys_period_start,sys_period_end,id, name, location, comments, version, when_created, when_modified) values (OLD.sys_period_start, now(6),OLD.id, OLD.name, OLD.location, OLD.comments, OLD.version, OLD.when_created, OLD.when_modified); +end$$ +delimiter $$ +create trigger hi_link_doc_history_upd before update on hi_link_doc for each row begin + insert into hi_link_doc_history (sys_period_start,sys_period_end,hi_link_id, hi_doc_id) values (OLD.sys_period_start, now(6),OLD.hi_link_id, OLD.hi_doc_id); + set NEW.sys_period_start = now(6); +end$$ +delimiter $$ +create trigger hi_link_doc_history_del before delete on hi_link_doc for each row begin + insert into hi_link_doc_history (sys_period_start,sys_period_end,hi_link_id, hi_doc_id) values (OLD.sys_period_start, now(6),OLD.hi_link_id, OLD.hi_doc_id); +end$$ +delimiter $$ +create trigger hi_tone_history_upd before update on hi_tone for each row begin + insert into hi_tone_history (sys_period_start,sys_period_end,id, name, comments, version, when_created, when_modified) values (OLD.sys_period_start, now(6),OLD.id, OLD.name, OLD.comments, OLD.version, OLD.when_created, OLD.when_modified); + set NEW.sys_period_start = now(6); +end$$ +delimiter $$ +create trigger hi_tone_history_del before delete on hi_tone for each row begin + insert into hi_tone_history (sys_period_start,sys_period_end,id, name, comments, version, when_created, when_modified) values (OLD.sys_period_start, now(6),OLD.id, OLD.name, OLD.comments, OLD.version, OLD.when_created, OLD.when_modified); +end$$ +delimiter $$ +create trigger hi_tthree_history_upd before update on hi_tthree for each row begin + insert into hi_tthree_history (sys_period_start,sys_period_end,id, hi_ttwo_id, three, version, when_created, when_modified) values (OLD.sys_period_start, now(6),OLD.id, OLD.hi_ttwo_id, OLD.three, OLD.version, OLD.when_created, OLD.when_modified); + set NEW.sys_period_start = now(6); +end$$ +delimiter $$ +create trigger hi_tthree_history_del before delete on hi_tthree for each row begin + insert into hi_tthree_history (sys_period_start,sys_period_end,id, hi_ttwo_id, three, version, when_created, when_modified) values (OLD.sys_period_start, now(6),OLD.id, OLD.hi_ttwo_id, OLD.three, OLD.version, OLD.when_created, OLD.when_modified); +end$$ +delimiter $$ +create trigger hi_ttwo_history_upd before update on hi_ttwo for each row begin + insert into hi_ttwo_history (sys_period_start,sys_period_end,id, hi_tone_id, two, version, when_created, when_modified) values (OLD.sys_period_start, now(6),OLD.id, OLD.hi_tone_id, OLD.two, OLD.version, OLD.when_created, OLD.when_modified); + set NEW.sys_period_start = now(6); +end$$ +delimiter $$ +create trigger hi_ttwo_history_del before delete on hi_ttwo for each row begin + insert into hi_ttwo_history (sys_period_start,sys_period_end,id, hi_tone_id, two, version, when_created, when_modified) values (OLD.sys_period_start, now(6),OLD.id, OLD.hi_tone_id, OLD.two, OLD.version, OLD.when_created, OLD.when_modified); +end$$ +delimiter $$ +create trigger hsd_setting_history_upd before update on hsd_setting for each row begin + insert into hsd_setting_history (sys_period_start,sys_period_end,id, code, content, user_id, version, when_created, when_modified, deleted) values (OLD.sys_period_start, now(6),OLD.id, OLD.code, OLD.content, OLD.user_id, OLD.version, OLD.when_created, OLD.when_modified, OLD.deleted); + set NEW.sys_period_start = now(6); +end$$ +delimiter $$ +create trigger hsd_setting_history_del before delete on hsd_setting for each row begin + insert into hsd_setting_history (sys_period_start,sys_period_end,id, code, content, user_id, version, when_created, when_modified, deleted) values (OLD.sys_period_start, now(6),OLD.id, OLD.code, OLD.content, OLD.user_id, OLD.version, OLD.when_created, OLD.when_modified, OLD.deleted); +end$$ +delimiter $$ +create trigger hsd_user_history_upd before update on hsd_user for each row begin + insert into hsd_user_history (sys_period_start,sys_period_end,id, name, version, when_created, when_modified, deleted) values (OLD.sys_period_start, now(6),OLD.id, OLD.name, OLD.version, OLD.when_created, OLD.when_modified, OLD.deleted); + set NEW.sys_period_start = now(6); +end$$ +delimiter $$ +create trigger hsd_user_history_del before delete on hsd_user for each row begin + insert into hsd_user_history (sys_period_start,sys_period_end,id, name, version, when_created, when_modified, deleted) values (OLD.sys_period_start, now(6),OLD.id, OLD.name, OLD.version, OLD.when_created, OLD.when_modified, OLD.deleted); +end$$ +delimiter $$ +create trigger link_history_upd before update on link for each row begin + insert into link_history (sys_period_start,sys_period_end,id, name, location, when_publish, link_comment, version, when_created, when_modified, deleted) values (OLD.sys_period_start, now(6),OLD.id, OLD.name, OLD.location, OLD.when_publish, OLD.link_comment, OLD.version, OLD.when_created, OLD.when_modified, OLD.deleted); + set NEW.sys_period_start = now(6); +end$$ +delimiter $$ +create trigger link_history_del before delete on link for each row begin + insert into link_history (sys_period_start,sys_period_end,id, name, location, when_publish, link_comment, version, when_created, when_modified, deleted) values (OLD.sys_period_start, now(6),OLD.id, OLD.name, OLD.location, OLD.when_publish, OLD.link_comment, OLD.version, OLD.when_created, OLD.when_modified, OLD.deleted); +end$$ +delimiter $$ +create trigger c_user_history_upd before update on c_user for each row begin + insert into c_user_history (sys_period_start,sys_period_end,id, inactive, name, email, group_id, version, when_created, when_modified) values (OLD.sys_period_start, now(6),OLD.id, OLD.inactive, OLD.name, OLD.email, OLD.group_id, OLD.version, OLD.when_created, OLD.when_modified); + set NEW.sys_period_start = now(6); +end$$ +delimiter $$ +create trigger c_user_history_del before delete on c_user for each row begin + insert into c_user_history (sys_period_start,sys_period_end,id, inactive, name, email, group_id, version, when_created, when_modified) values (OLD.sys_period_start, now(6),OLD.id, OLD.inactive, OLD.name, OLD.email, OLD.group_id, OLD.version, OLD.when_created, OLD.when_modified); +end$$ diff --git a/ebean-core/src/test/ddl-review/mysql-drop-all.sql b/ebean-core/src/test/ddl-review/mysql-drop-all.sql new file mode 100644 index 000000000..eb2ce81b6 --- /dev/null +++ b/ebean-core/src/test/ddl-review/mysql-drop-all.sql @@ -0,0 +1,1867 @@ +-- Generated by ebean unknown at 2020-02-21T19:45:37.488834Z +alter table bar drop foreign key fk_bar_foo_id; +drop index ix_bar_foo_id on bar; + +alter table acl_container_relation drop foreign key fk_acl_container_relation_container_id; +drop index ix_acl_container_relation_container_id on acl_container_relation; + +alter table acl_container_relation drop foreign key fk_acl_container_relation_acl_entry_id; +drop index ix_acl_container_relation_acl_entry_id on acl_container_relation; + +alter table addr drop foreign key fk_addr_employee_id; +drop index ix_addr_employee_id on addr; + +alter table o_address drop foreign key fk_o_address_country_code; +drop index ix_o_address_country_code on o_address; + +alter table album drop foreign key fk_album_cover_id; + +alter table animal drop foreign key fk_animal_shelter_id; +drop index ix_animal_shelter_id on animal; + +alter table attribute drop foreign key fk_attribute_attribute_holder_id; +drop index ix_attribute_attribute_holder_id on attribute; + +alter table bbookmark drop foreign key fk_bbookmark_user_id; +drop index ix_bbookmark_user_id on bbookmark; + +alter table bbookmark_user drop foreign key fk_bbookmark_user_org_id; +drop index ix_bbookmark_user_org_id on bbookmark_user; + +alter table bsite_user_a drop foreign key fk_bsite_user_a_site_id; +drop index ix_bsite_user_a_site_id on bsite_user_a; + +alter table bsite_user_a drop foreign key fk_bsite_user_a_user_id; +drop index ix_bsite_user_a_user_id on bsite_user_a; + +alter table bsite_user_b drop foreign key fk_bsite_user_b_site; +drop index ix_bsite_user_b_site on bsite_user_b; + +alter table bsite_user_b drop foreign key fk_bsite_user_b_usr; +drop index ix_bsite_user_b_usr on bsite_user_b; + +alter table bsite_user_c drop foreign key fk_bsite_user_c_site_uid; +drop index ix_bsite_user_c_site_uid on bsite_user_c; + +alter table bsite_user_c drop foreign key fk_bsite_user_c_user_uid; +drop index ix_bsite_user_c_user_uid on bsite_user_c; + +alter table bsite_user_e drop foreign key fk_bsite_user_e_site_id; +drop index ix_bsite_user_e_site_id on bsite_user_e; + +alter table bsite_user_e drop foreign key fk_bsite_user_e_user_id; +drop index ix_bsite_user_e_user_id on bsite_user_e; + +alter table basic_draftable_bean drop foreign key fk_basic_draftable_bean_id; + +alter table drel_booking drop foreign key fk_drel_booking_agent_invoice; + +alter table drel_booking drop foreign key fk_drel_booking_client_invoice; + +alter table cepproduct_category drop foreign key fk_cepproduct_category_category_id; +drop index ix_cepproduct_category_category_id on cepproduct_category; + +alter table cepproduct_category drop foreign key fk_cepproduct_category_product_id; +drop index ix_cepproduct_category_product_id on cepproduct_category; + +alter table cinh_ref drop foreign key fk_cinh_ref_ref_id; +drop index ix_cinh_ref_ref_id on cinh_ref; + +alter table ckey_detail drop foreign key fk_ckey_detail_parent; +drop index ix_ckey_detail_parent on ckey_detail; + +alter table ckey_parent drop foreign key fk_ckey_parent_assoc_id; +drop index ix_ckey_parent_assoc_id on ckey_parent; + +alter table coone_many drop foreign key fk_coone_many_coone_id; +drop index ix_coone_many_coone_id on coone_many; + +alter table coroot drop foreign key fk_coroot_one_id; + +alter table calculation_result drop foreign key fk_calculation_result_product_configuration_id; +drop index ix_calculation_result_product_configuration_id on calculation_result; + +alter table calculation_result drop foreign key fk_calculation_result_group_configuration_id; +drop index ix_calculation_result_group_configuration_id on calculation_result; + +alter table sp_car_car_wheels drop foreign key fk_sp_car_car_wheels_sp_car_car; +drop index ix_sp_car_car_wheels_sp_car_car on sp_car_car_wheels; + +alter table sp_car_car_wheels drop foreign key fk_sp_car_car_wheels_sp_car_wheel; +drop index ix_sp_car_car_wheels_sp_car_wheel on sp_car_car_wheels; + +alter table sp_car_car_doors drop foreign key fk_sp_car_car_doors_sp_car_car; +drop index ix_sp_car_car_doors_sp_car_car on sp_car_car_doors; + +alter table sp_car_car_doors drop foreign key fk_sp_car_car_doors_sp_car_door; +drop index ix_sp_car_car_doors_sp_car_door on sp_car_car_doors; + +alter table car_accessory drop foreign key fk_car_accessory_fuse_id; +drop index ix_car_accessory_fuse_id on car_accessory; + +alter table car_accessory drop foreign key fk_car_accessory_car_id; +drop index ix_car_accessory_car_id on car_accessory; + +alter table category drop foreign key fk_category_surveyobjectid; +drop index ix_category_surveyobjectid on category; + +alter table e_save_test_d drop foreign key fk_e_save_test_d_parent_id; + +alter table child_person drop foreign key fk_child_person_some_bean_id; +drop index ix_child_person_some_bean_id on child_person; + +alter table child_person drop foreign key fk_child_person_parent_identifier; +drop index ix_child_person_parent_identifier on child_person; + +alter table cke_client drop foreign key fk_cke_client_user; +drop index ix_cke_client_user on cke_client; + +alter table class_super_monkey drop foreign key fk_class_super_monkey_class_super; + +alter table class_super_monkey drop foreign key fk_class_super_monkey_monkey; + +alter table configuration drop foreign key fk_configuration_configurations_id; +drop index ix_configuration_configurations_id on configuration; + +alter table contact drop foreign key fk_contact_customer_id; +drop index ix_contact_customer_id on contact; + +alter table contact drop foreign key fk_contact_group_id; +drop index ix_contact_group_id on contact; + +alter table contact_note drop foreign key fk_contact_note_contact_id; +drop index ix_contact_note_contact_id on contact_note; + +alter table contract_costs drop foreign key fk_contract_costs_position_id; +drop index ix_contract_costs_position_id on contract_costs; + +alter table c_conversation drop foreign key fk_c_conversation_group_id; +drop index ix_c_conversation_group_id on c_conversation; + +alter table o_customer drop foreign key fk_o_customer_billing_address_id; +drop index ix_o_customer_billing_address_id on o_customer; + +alter table o_customer drop foreign key fk_o_customer_shipping_address_id; +drop index ix_o_customer_shipping_address_id on o_customer; + +alter table dcredit_drol drop foreign key fk_dcredit_drol_dcredit; +drop index ix_dcredit_drol_dcredit on dcredit_drol; + +alter table dcredit_drol drop foreign key fk_dcredit_drol_drol; +drop index ix_dcredit_drol_drol on dcredit_drol; + +alter table dmachine drop foreign key fk_dmachine_organisation_id; +drop index ix_dmachine_organisation_id on dmachine; + +alter table d_machine_aux_use drop foreign key fk_d_machine_aux_use_machine_id; +drop index ix_d_machine_aux_use_machine_id on d_machine_aux_use; + +alter table d_machine_stats drop foreign key fk_d_machine_stats_machine_id; +drop index ix_d_machine_stats_machine_id on d_machine_stats; + +alter table d_machine_use drop foreign key fk_d_machine_use_machine_id; +drop index ix_d_machine_use_machine_id on d_machine_use; + +alter table drot_drol drop foreign key fk_drot_drol_drot; +drop index ix_drot_drol_drot on drot_drol; + +alter table drot_drol drop foreign key fk_drot_drol_drol; +drop index ix_drot_drol_drol on drot_drol; + +alter table dc_detail drop foreign key fk_dc_detail_master_id; +drop index ix_dc_detail_master_id on dc_detail; + +alter table dfk_cascade drop foreign key fk_dfk_cascade_one_id; +drop index ix_dfk_cascade_one_id on dfk_cascade; + +alter table dfk_set_null drop foreign key fk_dfk_set_null_one_id; +drop index ix_dfk_set_null_one_id on dfk_set_null; + +alter table doc drop foreign key fk_doc_id; + +alter table doc_link drop foreign key fk_doc_link_doc; +drop index ix_doc_link_doc on doc_link; + +alter table doc_link drop foreign key fk_doc_link_link; +drop index ix_doc_link_link on doc_link; + +alter table document drop foreign key fk_document_id; + +alter table document drop foreign key fk_document_organisation_id; +drop index ix_document_organisation_id on document; + +alter table document_draft drop foreign key fk_document_draft_organisation_id; +drop index ix_document_draft_organisation_id on document_draft; + +alter table document_media drop foreign key fk_document_media_document_id; +drop index ix_document_media_document_id on document_media; + +alter table document_media_draft drop foreign key fk_document_media_draft_document_id; +drop index ix_document_media_draft_document_id on document_media_draft; + +alter table e_basicenc_relate drop foreign key fk_e_basicenc_relate_other_id; +drop index ix_e_basicenc_relate_other_id on e_basicenc_relate; + +alter table ebasic_json_map_detail drop foreign key fk_ebasic_json_map_detail_owner_id; +drop index ix_ebasic_json_map_detail_owner_id on ebasic_json_map_detail; + +alter table ebasic_no_sdchild drop foreign key fk_ebasic_no_sdchild_owner_id; +drop index ix_ebasic_no_sdchild_owner_id on ebasic_no_sdchild; + +alter table ebasic_sdchild drop foreign key fk_ebasic_sdchild_owner_id; +drop index ix_ebasic_sdchild_owner_id on ebasic_sdchild; + +alter table ecache_child drop foreign key fk_ecache_child_root_id; +drop index ix_ecache_child_root_id on ecache_child; + +alter table edefault_prop drop foreign key fk_edefault_prop_e_simple_usertypeid; + +alter table eemb_inner drop foreign key fk_eemb_inner_outer_id; +drop index ix_eemb_inner_outer_id on eemb_inner; + +alter table einvoice drop foreign key fk_einvoice_person_id; +drop index ix_einvoice_person_id on einvoice; + +alter table enull_collection_detail drop foreign key fk_enull_collection_detail_enull_collection_id; +drop index ix_enull_collection_detail_enull_collection_id on enull_collection_detail; + +alter table eopt_one_a drop foreign key fk_eopt_one_a_b_id; +drop index ix_eopt_one_a_b_id on eopt_one_a; + +alter table eopt_one_b drop foreign key fk_eopt_one_b_c_id; +drop index ix_eopt_one_b_c_id on eopt_one_b; + +alter table eper_addr drop foreign key fk_eper_addr_ma_country_code; +drop index ix_eper_addr_ma_country_code on eper_addr; + +alter table esoft_del_book drop foreign key fk_esoft_del_book_lend_by_id; +drop index ix_esoft_del_book_lend_by_id on esoft_del_book; + +alter table esoft_del_book_esoft_del_user drop foreign key fk_esoft_del_book_esoft_del_user_esoft_del_book; +drop index ix_esoft_del_book_esoft_del_user_esoft_del_book on esoft_del_book_esoft_del_user; + +alter table esoft_del_book_esoft_del_user drop foreign key fk_esoft_del_book_esoft_del_user_esoft_del_user; +drop index ix_esoft_del_book_esoft_del_user_esoft_del_user on esoft_del_book_esoft_del_user; + +alter table esoft_del_down drop foreign key fk_esoft_del_down_esoft_del_mid_id; +drop index ix_esoft_del_down_esoft_del_mid_id on esoft_del_down; + +alter table esoft_del_mid drop foreign key fk_esoft_del_mid_top_id; +drop index ix_esoft_del_mid_top_id on esoft_del_mid; + +alter table esoft_del_mid drop foreign key fk_esoft_del_mid_up_id; +drop index ix_esoft_del_mid_up_id on esoft_del_mid; + +alter table esoft_del_one_a drop foreign key fk_esoft_del_one_a_oneb_id; + +alter table esoft_del_role_esoft_del_user drop foreign key fk_esoft_del_role_esoft_del_user_esoft_del_role; +drop index ix_esoft_del_role_esoft_del_user_esoft_del_role on esoft_del_role_esoft_del_user; + +alter table esoft_del_role_esoft_del_user drop foreign key fk_esoft_del_role_esoft_del_user_esoft_del_user; +drop index ix_esoft_del_role_esoft_del_user_esoft_del_user on esoft_del_role_esoft_del_user; + +alter table esoft_del_user_esoft_del_role drop foreign key fk_esoft_del_user_esoft_del_role_esoft_del_user; +drop index ix_esoft_del_user_esoft_del_role_esoft_del_user on esoft_del_user_esoft_del_role; + +alter table esoft_del_user_esoft_del_role drop foreign key fk_esoft_del_user_esoft_del_role_esoft_del_role; +drop index ix_esoft_del_user_esoft_del_role_esoft_del_role on esoft_del_user_esoft_del_role; + +alter table rawinherit_uncle drop foreign key fk_rawinherit_uncle_parent_id; +drop index ix_rawinherit_uncle_parent_id on rawinherit_uncle; + +alter table evanilla_collection_detail drop foreign key fk_evanilla_collection_detail_evanilla_collection_id; +drop index ix_evanilla_collection_detail_evanilla_collection_id on evanilla_collection_detail; + +alter table ec_enum_person_tags drop foreign key fk_ec_enum_person_tags_ec_enum_person_id; +drop index ix_ec_enum_person_tags_ec_enum_person_id on ec_enum_person_tags; + +alter table ec_person_phone drop foreign key fk_ec_person_phone_owner_id; +drop index ix_ec_person_phone_owner_id on ec_person_phone; + +alter table ec_top drop foreign key fk_ec_top_person_id; +drop index ix_ec_top_person_id on ec_top; + +alter table ec_top_ecs_person drop foreign key fk_ec_top_ecs_person_ec_top; +drop index ix_ec_top_ecs_person_ec_top on ec_top_ecs_person; + +alter table ec_top_ecs_person drop foreign key fk_ec_top_ecs_person_ecs_person; +drop index ix_ec_top_ecs_person_ecs_person on ec_top_ecs_person; + +alter table ecbl_person_phone_numbers drop foreign key fk_ecbl_person_phone_numbers_person_id; +drop index ix_ecbl_person_phone_numbers_person_id on ecbl_person_phone_numbers; + +alter table ecbm_person_phone_numbers drop foreign key fk_ecbm_person_phone_numbers_person_id; +drop index ix_ecbm_person_phone_numbers_person_id on ecbm_person_phone_numbers; + +alter table ecm_person_phone_numbers drop foreign key fk_ecm_person_phone_numbers_ecm_person_id; +drop index ix_ecm_person_phone_numbers_ecm_person_id on ecm_person_phone_numbers; + +alter table ecmc_person_phone_numbers drop foreign key fk_ecmc_person_phone_numbers_ecmc_person_id; +drop index ix_ecmc_person_phone_numbers_ecmc_person_id on ecmc_person_phone_numbers; + +alter table ecs_person_phone drop foreign key fk_ecs_person_phone_ecs_person_id; +drop index ix_ecs_person_phone_ecs_person_id on ecs_person_phone; + +alter table ecsm_child drop foreign key fk_ecsm_child_ecsm_parent_id; +drop index ix_ecsm_child_ecsm_parent_id on ecsm_child; + +alter table td_child drop foreign key fk_td_child_parent_id; +drop index ix_td_child_parent_id on td_child; + +alter table element_bean drop foreign key fk_element_bean_complex_bean_id; +drop index ix_element_bean_complex_bean_id on element_bean; + +alter table empl drop foreign key fk_empl_default_address_id; +drop index ix_empl_default_address_id on empl; + +alter table esd_detail drop foreign key fk_esd_detail_master_id; +drop index ix_esd_detail_master_id on esd_detail; + +alter table grand_parent_person drop foreign key fk_grand_parent_person_some_bean_id; +drop index ix_grand_parent_person_some_bean_id on grand_parent_person; + +alter table survey_group drop foreign key fk_survey_group_categoryobjectid; +drop index ix_survey_group_categoryobjectid on survey_group; + +alter table hx_link_doc drop foreign key fk_hx_link_doc_hx_link; +drop index ix_hx_link_doc_hx_link on hx_link_doc; + +alter table hx_link_doc drop foreign key fk_hx_link_doc_he_doc; +drop index ix_hx_link_doc_he_doc on hx_link_doc; + +alter table hi_link_doc drop foreign key fk_hi_link_doc_hi_link; +drop index ix_hi_link_doc_hi_link on hi_link_doc; + +alter table hi_link_doc drop foreign key fk_hi_link_doc_hi_doc; +drop index ix_hi_link_doc_hi_doc on hi_link_doc; + +alter table hi_tthree drop foreign key fk_hi_tthree_hi_ttwo_id; +drop index ix_hi_tthree_hi_ttwo_id on hi_tthree; + +alter table hi_ttwo drop foreign key fk_hi_ttwo_hi_tone_id; +drop index ix_hi_ttwo_hi_tone_id on hi_ttwo; + +alter table hsd_setting drop foreign key fk_hsd_setting_user_id; + +alter table iaf_segment drop foreign key fk_iaf_segment_status_id; +drop index ix_iaf_segment_status_id on iaf_segment; + +alter table imrelated drop foreign key fk_imrelated_owner_id; +drop index ix_imrelated_owner_id on imrelated; + +alter table info_contact drop foreign key fk_info_contact_company_id; +drop index ix_info_contact_company_id on info_contact; + +alter table info_customer drop foreign key fk_info_customer_company_id; + +alter table inner_report drop foreign key fk_inner_report_forecast_id; + +alter table drel_invoice drop foreign key fk_drel_invoice_booking; +drop index ix_drel_invoice_booking on drel_invoice; + +alter table item drop foreign key fk_item_etype; +drop index ix_item_etype on item; + +alter table item drop foreign key fk_item_eregion; +drop index ix_item_eregion on item; + +alter table mkeygroup_monkey drop foreign key fk_mkeygroup_monkey_mkeygroup; + +alter table mkeygroup_monkey drop foreign key fk_mkeygroup_monkey_monkey; + +alter table trainer_monkey drop foreign key fk_trainer_monkey_trainer; + +alter table trainer_monkey drop foreign key fk_trainer_monkey_monkey; + +alter table troop_monkey drop foreign key fk_troop_monkey_troop; + +alter table troop_monkey drop foreign key fk_troop_monkey_monkey; + +alter table l2_cldf_reset_bean_child drop foreign key fk_l2_cldf_reset_bean_child_parent_id; +drop index ix_l2_cldf_reset_bean_child_parent_id on l2_cldf_reset_bean_child; + +alter table level1_level4 drop foreign key fk_level1_level4_level1; +drop index ix_level1_level4_level1 on level1_level4; + +alter table level1_level4 drop foreign key fk_level1_level4_level4; +drop index ix_level1_level4_level4 on level1_level4; + +alter table level1_level2 drop foreign key fk_level1_level2_level1; +drop index ix_level1_level2_level1 on level1_level2; + +alter table level1_level2 drop foreign key fk_level1_level2_level2; +drop index ix_level1_level2_level2 on level1_level2; + +alter table level2_level3 drop foreign key fk_level2_level3_level2; +drop index ix_level2_level3_level2 on level2_level3; + +alter table level2_level3 drop foreign key fk_level2_level3_level3; +drop index ix_level2_level3_level3 on level2_level3; + +alter table link drop foreign key fk_link_id; + +alter table la_attr_value_attribute drop foreign key fk_la_attr_value_attribute_la_attr_value; +drop index ix_la_attr_value_attribute_la_attr_value on la_attr_value_attribute; + +alter table la_attr_value_attribute drop foreign key fk_la_attr_value_attribute_attribute; +drop index ix_la_attr_value_attribute_attribute on la_attr_value_attribute; + +alter table looney drop foreign key fk_looney_tune_id; +drop index ix_looney_tune_id on looney; + +alter table mcontact drop foreign key fk_mcontact_customer_id; +drop index ix_mcontact_customer_id on mcontact; + +alter table mcontact_message drop foreign key fk_mcontact_message_contact_id; +drop index ix_mcontact_message_contact_id on mcontact_message; + +alter table mcustomer drop foreign key fk_mcustomer_shipping_address_id; +drop index ix_mcustomer_shipping_address_id on mcustomer; + +alter table mcustomer drop foreign key fk_mcustomer_billing_address_id; +drop index ix_mcustomer_billing_address_id on mcustomer; + +alter table mmachine_mgroup drop foreign key fk_mmachine_mgroup_mmachine; +drop index ix_mmachine_mgroup_mmachine on mmachine_mgroup; + +alter table mmachine_mgroup drop foreign key fk_mmachine_mgroup_mgroup; +drop index ix_mmachine_mgroup_mgroup on mmachine_mgroup; + +alter table mprinter drop foreign key fk_mprinter_current_state_id; +drop index ix_mprinter_current_state_id on mprinter; + +alter table mprinter drop foreign key fk_mprinter_last_swap_cyan_id; + +alter table mprinter drop foreign key fk_mprinter_last_swap_magenta_id; + +alter table mprinter drop foreign key fk_mprinter_last_swap_yellow_id; + +alter table mprinter drop foreign key fk_mprinter_last_swap_black_id; + +alter table mprinter_state drop foreign key fk_mprinter_state_printer_id; +drop index ix_mprinter_state_printer_id on mprinter_state; + +alter table mprofile drop foreign key fk_mprofile_picture_id; +drop index ix_mprofile_picture_id on mprofile; + +alter table mrole_muser drop foreign key fk_mrole_muser_mrole; +drop index ix_mrole_muser_mrole on mrole_muser; + +alter table mrole_muser drop foreign key fk_mrole_muser_muser; +drop index ix_mrole_muser_muser on mrole_muser; + +alter table muser drop foreign key fk_muser_user_type_id; +drop index ix_muser_user_type_id on muser; + +alter table mail_user_inbox drop foreign key fk_mail_user_inbox_mail_user; +drop index ix_mail_user_inbox_mail_user on mail_user_inbox; + +alter table mail_user_inbox drop foreign key fk_mail_user_inbox_mail_box; +drop index ix_mail_user_inbox_mail_box on mail_user_inbox; + +alter table mail_user_outbox drop foreign key fk_mail_user_outbox_mail_user; +drop index ix_mail_user_outbox_mail_user on mail_user_outbox; + +alter table mail_user_outbox drop foreign key fk_mail_user_outbox_mail_box; +drop index ix_mail_user_outbox_mail_box on mail_user_outbox; + +alter table c_message drop foreign key fk_c_message_conversation_id; +drop index ix_c_message_conversation_id on c_message; + +alter table c_message drop foreign key fk_c_message_user_id; +drop index ix_c_message_user_id on c_message; + +alter table meter_contract_data drop foreign key fk_meter_contract_data_special_needs_client_id; + +alter table meter_special_needs_client drop foreign key fk_meter_special_needs_client_primary_id; + +alter table meter_version drop foreign key fk_meter_version_address_data_id; + +alter table meter_version drop foreign key fk_meter_version_contract_data_id; + +alter table mnoc_user_mnoc_role drop foreign key fk_mnoc_user_mnoc_role_mnoc_user; +drop index ix_mnoc_user_mnoc_role_mnoc_user on mnoc_user_mnoc_role; + +alter table mnoc_user_mnoc_role drop foreign key fk_mnoc_user_mnoc_role_mnoc_role; +drop index ix_mnoc_user_mnoc_role_mnoc_role on mnoc_user_mnoc_role; + +alter table mny_b drop foreign key fk_mny_b_a_id; +drop index ix_mny_b_a_id on mny_b; + +alter table mny_b_mny_c drop foreign key fk_mny_b_mny_c_mny_b; +drop index ix_mny_b_mny_c_mny_b on mny_b_mny_c; + +alter table mny_b_mny_c drop foreign key fk_mny_b_mny_c_mny_c; +drop index ix_mny_b_mny_c_mny_c on mny_b_mny_c; + +alter table subtopics drop foreign key fk_subtopics_mny_topic_1; +drop index ix_subtopics_mny_topic_1 on subtopics; + +alter table subtopics drop foreign key fk_subtopics_mny_topic_2; +drop index ix_subtopics_mny_topic_2 on subtopics; + +alter table mp_role drop foreign key fk_mp_role_mp_user_id; +drop index ix_mp_role_mp_user_id on mp_role; + +alter table ms_many_a_many_b drop foreign key fk_ms_many_a_many_b_ms_many_a; +drop index ix_ms_many_a_many_b_ms_many_a on ms_many_a_many_b; + +alter table ms_many_a_many_b drop foreign key fk_ms_many_a_many_b_ms_many_b; +drop index ix_ms_many_a_many_b_ms_many_b on ms_many_a_many_b; + +alter table ms_many_b_many_a drop foreign key fk_ms_many_b_many_a_ms_many_b; +drop index ix_ms_many_b_many_a_ms_many_b on ms_many_b_many_a; + +alter table ms_many_b_many_a drop foreign key fk_ms_many_b_many_a_ms_many_a; +drop index ix_ms_many_b_many_a_ms_many_a on ms_many_b_many_a; + +alter table my_lob_size_join_many drop foreign key fk_my_lob_size_join_many_parent_id; +drop index ix_my_lob_size_join_many_parent_id on my_lob_size_join_many; + +alter table o_bean_child drop foreign key fk_o_bean_child_cached_bean_id; +drop index ix_o_bean_child_cached_bean_id on o_bean_child; + +alter table ocached_app_detail drop foreign key fk_ocached_app_detail_app_id; +drop index ix_ocached_app_detail_app_id on ocached_app_detail; + +alter table o_cached_bean_country drop foreign key fk_o_cached_bean_country_o_cached_bean; +drop index ix_o_cached_bean_country_o_cached_bean on o_cached_bean_country; + +alter table o_cached_bean_country drop foreign key fk_o_cached_bean_country_o_country; +drop index ix_o_cached_bean_country_o_country on o_cached_bean_country; + +alter table o_cached_bean_child drop foreign key fk_o_cached_bean_child_cached_bean_id; +drop index ix_o_cached_bean_child_cached_bean_id on o_cached_bean_child; + +alter table oengine drop foreign key fk_oengine_car_id; + +alter table ogear_box drop foreign key fk_ogear_box_car_id; + +alter table omvertex_other drop foreign key fk_omvertex_other_omvertex_id; +drop index ix_omvertex_other_omvertex_id on omvertex_other; + +alter table oroad_show_msg drop foreign key fk_oroad_show_msg_company_id; + +alter table om_account_child_dbo drop foreign key fk_om_account_child_dbo_banana_rama_id; +drop index ix_om_account_child_dbo_banana_rama_id on om_account_child_dbo; + +alter table om_basic_child drop foreign key fk_om_basic_child_parent_id; +drop index ix_om_basic_child_parent_id on om_basic_child; + +alter table om_ordered_detail drop foreign key fk_om_ordered_detail_master_id; +drop index ix_om_ordered_detail_master_id on om_ordered_detail; + +alter table o_order drop foreign key fk_o_order_kcustomer_id; +drop index ix_o_order_kcustomer_id on o_order; + +alter table o_order_detail drop foreign key fk_o_order_detail_order_id; +drop index ix_o_order_detail_order_id on o_order_detail; + +alter table o_order_detail drop foreign key fk_o_order_detail_product_id; +drop index ix_o_order_detail_product_id on o_order_detail; + +alter table s_order_items drop foreign key fk_s_order_items_order_uuid; +drop index ix_s_order_items_order_uuid on s_order_items; + +alter table or_order_ship drop foreign key fk_or_order_ship_order_id; +drop index ix_or_order_ship_order_id on or_order_ship; + +alter table organization_node drop foreign key fk_organization_node_parent_tree_node_id; + +alter table orp_detail drop foreign key fk_orp_detail_master_id; +drop index ix_orp_detail_master_id on orp_detail; + +alter table orp_detail2 drop foreign key fk_orp_detail2_orp_master2_id; +drop index ix_orp_detail2_orp_master2_id on orp_detail2; + +alter table oto_atwo drop foreign key fk_oto_atwo_aone_id; + +alter table oto_bchild drop foreign key fk_oto_bchild_master_id; + +alter table oto_child drop foreign key fk_oto_child_master_id; + +alter table oto_cust_address drop foreign key fk_oto_cust_address_customer_cid; + +alter table oto_level_a drop foreign key fk_oto_level_a_b_id; + +alter table oto_level_b drop foreign key fk_oto_level_b_c_id; + +alter table oto_prime_extra drop foreign key fk_oto_prime_extra_eid; + +alter table oto_sd_child drop foreign key fk_oto_sd_child_master_id; + +alter table oto_th_many drop foreign key fk_oto_th_many_oto_th_top_id; +drop index ix_oto_th_many_oto_th_top_id on oto_th_many; + +alter table oto_th_one drop foreign key fk_oto_th_one_many_id; + +alter table oto_ubprime_extra drop foreign key fk_oto_ubprime_extra_eid; + +alter table oto_user_model drop foreign key fk_oto_user_model_user_optional_id; + +alter table pfile drop foreign key fk_pfile_file_content_id; + +alter table pfile drop foreign key fk_pfile_file_content2_id; + +alter table paggview drop foreign key fk_paggview_pview_id; + +alter table pallet_location drop foreign key fk_pallet_location_zone_sid; +drop index ix_pallet_location_zone_sid on pallet_location; + +alter table parcel_location drop foreign key fk_parcel_location_parcelid; + +alter table rawinherit_parent_rawinherit_data drop foreign key fk_rawinherit_parent_rawinherit_data_rawinherit_parent; +drop index ix_rawinherit_parent_rawinherit_data_rawinherit_parent on rawinherit_parent_rawinherit_data; + +alter table rawinherit_parent_rawinherit_data drop foreign key fk_rawinherit_parent_rawinherit_data_rawinherit_data; +drop index ix_rawinherit_parent_rawinherit_data_rawinherit_data on rawinherit_parent_rawinherit_data; + +alter table parent_person drop foreign key fk_parent_person_some_bean_id; +drop index ix_parent_person_some_bean_id on parent_person; + +alter table parent_person drop foreign key fk_parent_person_parent_identifier; +drop index ix_parent_person_parent_identifier on parent_person; + +alter table c_participation drop foreign key fk_c_participation_conversation_id; +drop index ix_c_participation_conversation_id on c_participation; + +alter table c_participation drop foreign key fk_c_participation_user_id; +drop index ix_c_participation_user_id on c_participation; + +alter table pcf_calendar drop foreign key fk_pcf_calendar_pcf_person_id; +drop index ix_pcf_calendar_pcf_person_id on pcf_calendar; + +alter table pcf_city drop foreign key fk_pcf_city_pcf_country_id; +drop index ix_pcf_city_pcf_country_id on pcf_city; + +alter table pcf_city drop foreign key fk_pcf_city_mayor_id; + +alter table pcf_city drop foreign key fk_pcf_city_vice_mayor_id; + +alter table pcf_event drop foreign key fk_pcf_event_pcf_calendar_id; +drop index ix_pcf_event_pcf_calendar_id on pcf_event; + +alter table persistent_file_content drop foreign key fk_persistent_file_content_persistent_file_id; + +alter table person drop foreign key fk_person_default_address_oid; +drop index ix_person_default_address_oid on person; + +alter table person_cache_email drop foreign key fk_person_cache_email_person_info_person_id; +drop index ix_person_cache_email_person_info_person_id on person_cache_email; + +alter table phones drop foreign key fk_phones_person_id; +drop index ix_phones_person_id on phones; + +alter table e_position drop foreign key fk_e_position_contract_id; +drop index ix_e_position_contract_id on e_position; + +alter table pp_to_ww drop foreign key fk_pp_to_ww_pp; +drop index ix_pp_to_ww_pp on pp_to_ww; + +alter table pp_to_ww drop foreign key fk_pp_to_ww_wview; +drop index ix_pp_to_ww_wview on pp_to_ww; + +alter table question drop foreign key fk_question_groupobjectid; +drop index ix_question_groupobjectid on question; + +alter table r_orders drop foreign key fk_r_orders_customer; +drop index ix_r_orders_customer on r_orders; + +alter table rel_master drop foreign key fk_rel_master_detail_id; +drop index ix_rel_master_detail_id on rel_master; + +alter table resourcefile drop foreign key fk_resourcefile_parentresourcefileid; +drop index ix_resourcefile_parentresourcefileid on resourcefile; + +alter table mt_role drop foreign key fk_mt_role_tenant_id; +drop index ix_mt_role_tenant_id on mt_role; + +alter table mt_role_permission drop foreign key fk_mt_role_permission_mt_role; +drop index ix_mt_role_permission_mt_role on mt_role_permission; + +alter table mt_role_permission drop foreign key fk_mt_role_permission_mt_permission; +drop index ix_mt_role_permission_mt_permission on mt_role_permission; + +alter table root_bean drop foreign key fk_root_bean_referencing_bean_id; +drop index ix_root_bean_referencing_bean_id on root_bean; + +alter table f_second drop foreign key fk_f_second_first; + +alter table section drop foreign key fk_section_article_id; +drop index ix_section_article_id on section; + +alter table self_parent drop foreign key fk_self_parent_parent_id; +drop index ix_self_parent_parent_id on self_parent; + +alter table self_ref_customer drop foreign key fk_self_ref_customer_referred_by_id; +drop index ix_self_ref_customer_referred_by_id on self_ref_customer; + +alter table self_ref_example drop foreign key fk_self_ref_example_parent_id; +drop index ix_self_ref_example_parent_id on self_ref_example; + +alter table e_save_test_b drop foreign key fk_e_save_test_b_sibling_a_id; + +alter table site drop foreign key fk_site_parent_id; +drop index ix_site_parent_id on site; + +alter table site drop foreign key fk_site_data_container_id; + +alter table site drop foreign key fk_site_site_address_id; + +alter table source_base drop foreign key fk_source_base_target_id; +drop index ix_source_base_target_id on source_base; + +alter table stockforecast drop foreign key fk_stockforecast_inner_report_id; +drop index ix_stockforecast_inner_report_id on stockforecast; + +alter table sub_section drop foreign key fk_sub_section_section_id; +drop index ix_sub_section_section_id on sub_section; + +alter table tevent_many drop foreign key fk_tevent_many_event_id; +drop index ix_tevent_many_event_id on tevent_many; + +alter table tevent_one drop foreign key fk_tevent_one_event_id; + +alter table t_detail_with_other_namexxxyy drop foreign key fk_t_detail_with_other_namexxxyy_master_id; +drop index ix_t_detail_with_other_namexxxyy_master_id on t_detail_with_other_namexxxyy; + +alter table ttruck_holder drop foreign key fk_ttruck_holder_truck_plate_no; +drop index ix_ttruck_holder_truck_plate_no on ttruck_holder; + +alter table ttruck_holder drop foreign key fk_ttruck_holder_basic_id; +drop index ix_ttruck_holder_basic_id on ttruck_holder; + +alter table ttruck_holder_item drop foreign key fk_ttruck_holder_item_owner_id; +drop index ix_ttruck_holder_item_owner_id on ttruck_holder_item; + +alter table twheel drop foreign key fk_twheel_owner_plate_no; +drop index ix_twheel_owner_plate_no on twheel; + +alter table tire drop foreign key fk_tire_wheel; + +alter table tree_entity drop foreign key fk_tree_entity_parent_id; +drop index ix_tree_entity_parent_id on tree_entity; + +alter table trip drop foreign key fk_trip_vehicle_driver_id; +drop index ix_trip_vehicle_driver_id on trip; + +alter table trip drop foreign key fk_trip_address_id; +drop index ix_trip_address_id on trip; + +alter table `type` drop foreign key fk_type_sub_type_id; +drop index ix_type_sub_type_id on `type`; + +alter table usib_child drop foreign key fk_usib_child_parent_id; +drop index ix_usib_child_parent_id on usib_child; + +alter table usib_child_sibling drop foreign key fk_usib_child_sibling_child_id; + +alter table ut_detail drop foreign key fk_ut_detail_utmaster_id; +drop index ix_ut_detail_utmaster_id on ut_detail; + +alter table uutwo drop foreign key fk_uutwo_master_id; +drop index ix_uutwo_master_id on uutwo; + +alter table oto_user drop foreign key fk_oto_user_account_id; + +alter table c_user drop foreign key fk_c_user_group_id; +drop index ix_c_user_group_id on c_user; + +alter table em_user_role drop foreign key fk_em_user_role_user_id; +drop index ix_em_user_role_user_id on em_user_role; + +alter table em_user_role drop foreign key fk_em_user_role_role_id; +drop index ix_em_user_role_role_id on em_user_role; + +alter table vehicle drop foreign key fk_vehicle_lease_id; +drop index ix_vehicle_lease_id on vehicle; + +alter table vehicle drop foreign key fk_vehicle_car_ref_id; +drop index ix_vehicle_car_ref_id on vehicle; + +alter table vehicle drop foreign key fk_vehicle_truck_ref_id; +drop index ix_vehicle_truck_ref_id on vehicle; + +alter table vehicle_driver drop foreign key fk_vehicle_driver_vehicle_id; +drop index ix_vehicle_driver_vehicle_id on vehicle_driver; + +alter table vehicle_driver drop foreign key fk_vehicle_driver_address_id; +drop index ix_vehicle_driver_address_id on vehicle_driver; + +alter table warehouses drop foreign key fk_warehouses_officezoneid; +drop index ix_warehouses_officezoneid on warehouses; + +alter table warehousesshippingzones drop foreign key fk_warehousesshippingzones_warehouses; +drop index ix_warehousesshippingzones_warehouses on warehousesshippingzones; + +alter table warehousesshippingzones drop foreign key fk_warehousesshippingzones_zones; +drop index ix_warehousesshippingzones_zones on warehousesshippingzones; + +alter table sa_wheel drop foreign key fk_sa_wheel_tire; +drop index ix_sa_wheel_tire on sa_wheel; + +alter table sa_wheel drop foreign key fk_sa_wheel_car; +drop index ix_sa_wheel_car on sa_wheel; + +alter table g_who_props_otm drop foreign key fk_g_who_props_otm_who_created_id; +drop index ix_g_who_props_otm_who_created_id on g_who_props_otm; + +alter table g_who_props_otm drop foreign key fk_g_who_props_otm_who_modified_id; +drop index ix_g_who_props_otm_who_modified_id on g_who_props_otm; + +alter table with_zero drop foreign key fk_with_zero_parent_id; +drop index ix_with_zero_parent_id on with_zero; + +drop table if exists asimple_bean; + +drop table if exists bar; + +drop table if exists block; + +drop table if exists oto_account; + +drop table if exists acl; + +drop table if exists acl_container_relation; + +drop table if exists addr; + +drop table if exists address; + +drop table if exists o_address; + +drop table if exists album; + +drop table if exists animal; + +drop table if exists animal_shelter; + +drop table if exists article; + +drop table if exists attribute; + +drop table if exists attribute_holder; + +drop table if exists audit_log; + +drop table if exists bbookmark; + +drop table if exists bbookmark_org; + +drop table if exists bbookmark_user; + +drop table if exists bsimple_with_gen; + +drop table if exists bsite; + +drop table if exists bsite_user_a; + +drop table if exists bsite_user_b; + +drop table if exists bsite_user_c; + +drop table if exists bsite_user_d; + +drop table if exists bsite_user_e; + +drop table if exists buser; + +drop table if exists bwith_qident; + +drop table if exists basic_draftable_bean; + +drop table if exists basic_draftable_bean_draft; + +drop table if exists basic_joda_entity; + +drop table if exists bean_with_time_zone; + +drop table if exists drel_booking; + +drop table if exists bw_bean; + +drop table if exists cepcategory; + +drop table if exists cepproduct; + +drop table if exists cepproduct_category; + +drop table if exists cinh_ref; + +drop table if exists cinh_root; + +drop table if exists ckey_assoc; + +drop table if exists ckey_detail; + +drop table if exists ckey_parent; + +drop table if exists coone; + +drop table if exists coone_many; + +drop table if exists coroot; + +drop table if exists calculation_result; + +drop table if exists cao_bean; + +drop table if exists sp_car_car; + +drop table if exists sp_car_car_wheels; + +drop table if exists sp_car_car_doors; + +drop table if exists sa_car; + +drop table if exists car_accessory; + +drop table if exists car_fuse; + +drop table if exists category; + +drop table if exists e_save_test_d; + +drop table if exists child_person; + +drop table if exists cke_client; + +drop table if exists cke_user; + +drop table if exists class_super; + +drop table if exists class_super_monkey; + +drop table if exists configuration; + +drop table if exists configurations; + +drop table if exists contact; + +drop table if exists contact_group; + +drop table if exists contact_note; + +drop table if exists contract; + +drop table if exists contract_costs; + +drop table if exists c_conversation; + +drop table if exists o_country; + +drop table if exists cover; + +drop table if exists o_customer; + +drop table if exists dcredit; + +drop table if exists dcredit_drol; + +drop table if exists dexh_entity; + +drop table if exists dint_parent; + +drop table if exists dmachine; + +drop table if exists d_machine_aux_use; + +drop table if exists d_machine_stats; + +drop table if exists d_machine_use; + +drop table if exists dorg; + +drop table if exists dperson; + +drop table if exists drol; + +drop table if exists drot; + +drop table if exists drot_drol; + +drop table if exists rawinherit_data; + +drop table if exists data_container; + +drop table if exists dc_detail; + +drop table if exists dc_master; + +drop table if exists dfk_cascade; + +drop table if exists dfk_cascade_one; + +drop table if exists dfk_none; + +drop table if exists dfk_none_via_join; + +drop table if exists dfk_none_via_mto_m; + +drop table if exists dfk_none_via_mto_m_dfk_one; + +drop table if exists dfk_one; + +drop table if exists dfk_set_null; + +drop table if exists doc; + +drop table if exists doc_link; + +drop table if exists doc_link_draft; + +drop table if exists doc_draft; + +drop table if exists document; + +drop table if exists document_draft; + +drop table if exists document_media; + +drop table if exists document_media_draft; + +drop table if exists sp_car_door; + +drop table if exists earray_bean; + +drop table if exists earray_set_bean; + +drop table if exists e_basic; + +drop table if exists ebasic_change_log; + +drop table if exists ebasic_clob; + +drop table if exists ebasic_clob_fetch_eager; + +drop table if exists ebasic_clob_no_ver; + +drop table if exists e_basicenc; + +drop table if exists e_basicenc_bin; + +drop table if exists e_basicenc_client; + +drop table if exists e_basicenc_relate; + +drop table if exists e_basic_enum_id; + +drop table if exists e_basic_eni; + +drop table if exists ebasic_hstore; + +drop table if exists ebasic_json_jackson; + +drop table if exists ebasic_json_jackson2; + +drop table if exists ebasic_json_list; + +drop table if exists ebasic_json_map; + +drop table if exists ebasic_json_map_blob; + +drop table if exists ebasic_json_map_clob; + +drop table if exists ebasic_json_map_detail; + +drop table if exists ebasic_json_map_json_b; + +drop table if exists ebasic_json_map_varchar; + +drop table if exists ebasic_json_node; + +drop table if exists ebasic_json_node_blob; + +drop table if exists ebasic_json_node_json_b; + +drop table if exists ebasic_json_node_varchar; + +drop table if exists ebasic_json_unmapped; + +drop table if exists e_basic_ndc; + +drop table if exists ebasic_no_sdchild; + +drop table if exists ebasic_sdchild; + +drop table if exists ebasic_soft_delete; + +drop table if exists e_basicver; + +drop table if exists e_basic_withlife; + +drop table if exists e_basic_with_ex; + +drop table if exists e_basicverucon; + +drop table if exists ecache_child; + +drop table if exists ecache_root; + +drop table if exists e_col_ab; + +drop table if exists ecustom_id; + +drop table if exists edefault_prop; + +drop table if exists eemb_inner; + +drop table if exists eemb_outer; + +drop table if exists efile2_no_fk; + +drop table if exists efile_no_fk; + +drop table if exists efile_no_fk_euser_no_fk; + +drop table if exists efile_no_fk_euser_no_fk_soft_del; + +drop table if exists egen_props; + +drop table if exists eid_uid_bean; + +drop table if exists einvoice; + +drop table if exists e_main; + +drop table if exists enull_collection; + +drop table if exists enull_collection_detail; + +drop table if exists eopt_one_a; + +drop table if exists eopt_one_b; + +drop table if exists eopt_one_c; + +drop table if exists eper_addr; + +drop table if exists eperson; + +drop table if exists e_person_online; + +drop table if exists esimple; + +drop table if exists esoft_del_book; + +drop table if exists esoft_del_book_esoft_del_user; + +drop table if exists esoft_del_down; + +drop table if exists esoft_del_mid; + +drop table if exists esoft_del_one_a; + +drop table if exists esoft_del_one_b; + +drop table if exists esoft_del_role; + +drop table if exists esoft_del_role_esoft_del_user; + +drop table if exists esoft_del_top; + +drop table if exists esoft_del_up; + +drop table if exists esoft_del_user; + +drop table if exists esoft_del_user_esoft_del_role; + +drop table if exists esome_convert_type; + +drop table if exists esome_type; + +drop table if exists etrans_many; + +drop table if exists rawinherit_uncle; + +drop table if exists euser_no_fk; + +drop table if exists euser_no_fk_soft_del; + +drop table if exists evanilla_collection; + +drop table if exists evanilla_collection_detail; + +drop table if exists ewho_props; + +drop table if exists e_withinet; + +drop table if exists ec_enum_person; + +drop table if exists ec_enum_person_tags; + +drop table if exists ec_person; + +drop table if exists ec_person_phone; + +drop table if exists ec_top; + +drop table if exists ec_top_ecs_person; + +drop table if exists ecbl_person; + +drop table if exists ecbl_person_phone_numbers; + +drop table if exists ecbm_person; + +drop table if exists ecbm_person_phone_numbers; + +drop table if exists ecm_person; + +drop table if exists ecm_person_phone_numbers; + +drop table if exists ecmc_person; + +drop table if exists ecmc_person_phone_numbers; + +drop table if exists ecs_person; + +drop table if exists ecs_person_phone; + +drop table if exists ecsm_child; + +drop table if exists ecsm_values; + +drop table if exists ecsm_one; + +drop table if exists ecsm_parent; + +drop table if exists ecsm_two; + +drop table if exists td_child; + +drop table if exists td_parent; + +drop table if exists element_bean; + +drop table if exists empl; + +drop table if exists esd_detail; + +drop table if exists esd_master; + +drop table if exists feature_desc; + +drop table if exists f_first; + +drop table if exists foo; + +drop table if exists gen_key_identity; + +drop table if exists gen_key_sequence; + +drop table if exists gen_key_table; + +drop table if exists grand_parent_person; + +drop table if exists survey_group; + +drop table if exists c_group; + +drop table if exists he_doc; + +drop trigger hx_link_history_upd; +drop trigger hx_link_history_del; +drop view hx_link_with_history; +alter table hx_link drop column sys_period_start; +alter table hx_link drop column sys_period_end; +drop table hx_link_history; + +drop table if exists hx_link; + +drop table if exists hx_link_doc; + +drop table if exists hi_doc; + +drop trigger hi_link_history_upd; +drop trigger hi_link_history_del; +drop view hi_link_with_history; +alter table hi_link drop column sys_period_start; +alter table hi_link drop column sys_period_end; +drop table hi_link_history; + +drop table if exists hi_link; + +drop trigger hi_link_doc_history_upd; +drop trigger hi_link_doc_history_del; +drop view hi_link_doc_with_history; +alter table hi_link_doc drop column sys_period_start; +alter table hi_link_doc drop column sys_period_end; +drop table hi_link_doc_history; + +drop table if exists hi_link_doc; + +drop trigger hi_tone_history_upd; +drop trigger hi_tone_history_del; +drop view hi_tone_with_history; +alter table hi_tone drop column sys_period_start; +alter table hi_tone drop column sys_period_end; +drop table hi_tone_history; + +drop table if exists hi_tone; + +drop trigger hi_tthree_history_upd; +drop trigger hi_tthree_history_del; +drop view hi_tthree_with_history; +alter table hi_tthree drop column sys_period_start; +alter table hi_tthree drop column sys_period_end; +drop table hi_tthree_history; + +drop table if exists hi_tthree; + +drop trigger hi_ttwo_history_upd; +drop trigger hi_ttwo_history_del; +drop view hi_ttwo_with_history; +alter table hi_ttwo drop column sys_period_start; +alter table hi_ttwo drop column sys_period_end; +drop table hi_ttwo_history; + +drop table if exists hi_ttwo; + +drop trigger hsd_setting_history_upd; +drop trigger hsd_setting_history_del; +drop view hsd_setting_with_history; +alter table hsd_setting drop column sys_period_start; +alter table hsd_setting drop column sys_period_end; +drop table hsd_setting_history; + +drop table if exists hsd_setting; + +drop trigger hsd_user_history_upd; +drop trigger hsd_user_history_del; +drop view hsd_user_with_history; +alter table hsd_user drop column sys_period_start; +alter table hsd_user drop column sys_period_end; +drop table hsd_user_history; + +drop table if exists hsd_user; + +drop table if exists iaf_segment; + +drop table if exists iaf_segment_status; + +drop table if exists imrelated; + +drop table if exists imroot; + +drop table if exists ixresource; + +drop table if exists info_company; + +drop table if exists info_contact; + +drop table if exists info_customer; + +drop table if exists inner_report; + +drop table if exists drel_invoice; + +drop table if exists item; + +drop table if exists monkey; + +drop table if exists mkeygroup; + +drop table if exists mkeygroup_monkey; + +drop table if exists trainer; + +drop table if exists trainer_monkey; + +drop table if exists troop; + +drop table if exists troop_monkey; + +drop table if exists l2_cldf_reset_bean; + +drop table if exists l2_cldf_reset_bean_child; + +drop table if exists level1; + +drop table if exists level1_level4; + +drop table if exists level1_level2; + +drop table if exists level2; + +drop table if exists level2_level3; + +drop table if exists level3; + +drop table if exists level4; + +drop trigger link_history_upd; +drop trigger link_history_del; +drop view link_with_history; +alter table link drop column sys_period_start; +alter table link drop column sys_period_end; +drop table link_history; + +drop table if exists link; + +drop table if exists link_draft; + +drop table if exists la_attr_value; + +drop table if exists la_attr_value_attribute; + +drop table if exists looney; + +drop table if exists maddress; + +drop table if exists mcontact; + +drop table if exists mcontact_message; + +drop table if exists mcustomer; + +drop table if exists mgroup; + +drop table if exists mmachine; + +drop table if exists mmachine_mgroup; + +drop table if exists mmedia; + +drop table if exists non_updateprop; + +drop table if exists mprinter; + +drop table if exists mprinter_state; + +drop table if exists mprofile; + +drop table if exists mprotected_construct_bean; + +drop table if exists mrole; + +drop table if exists mrole_muser; + +drop table if exists msome_other; + +drop table if exists muser; + +drop table if exists muser_type; + +drop table if exists mail_box; + +drop table if exists mail_user; + +drop table if exists mail_user_inbox; + +drop table if exists mail_user_outbox; + +drop table if exists main_entity; + +drop table if exists main_entity_relation; + +drop table if exists map_super_actual; + +drop table if exists c_message; + +drop table if exists meter_address_data; + +drop table if exists meter_contract_data; + +drop table if exists meter_special_needs_client; + +drop table if exists meter_special_needs_contact; + +drop table if exists meter_version; + +drop table if exists mnoc_role; + +drop table if exists mnoc_user; + +drop table if exists mnoc_user_mnoc_role; + +drop table if exists mny_a; + +drop table if exists mny_b; + +drop table if exists mny_b_mny_c; + +drop table if exists mny_c; + +drop table if exists mny_topic; + +drop table if exists subtopics; + +drop table if exists mp_role; + +drop table if exists mp_user; + +drop table if exists ms_many_a; + +drop table if exists ms_many_a_many_b; + +drop table if exists ms_many_b; + +drop table if exists ms_many_b_many_a; + +drop table if exists my_lob_size; + +drop table if exists my_lob_size_join_many; + +drop table if exists noidbean; + +drop table if exists o_bean_child; + +drop table if exists ocached_app; + +drop table if exists ocached_app_detail; + +drop table if exists o_cached_bean; + +drop table if exists o_cached_bean_country; + +drop table if exists o_cached_bean_child; + +drop table if exists o_cached_inherit; + +drop table if exists o_cached_natkey; + +drop table if exists o_cached_natkey3; + +drop table if exists ocached_nkey_uid; + +drop table if exists ocar; + +drop table if exists ocompany; + +drop table if exists oengine; + +drop table if exists ogear_box; + +drop table if exists omvertex; + +drop table if exists omvertex_other; + +drop table if exists oroad_show_msg; + +drop table if exists om_account_child_dbo; + +drop table if exists om_account_dbo; + +drop table if exists om_basic_child; + +drop table if exists om_basic_parent; + +drop table if exists om_ordered_detail; + +drop table if exists om_ordered_master; + +drop table if exists only_id_entity; + +drop table if exists o_order; + +drop table if exists o_order_detail; + +drop table if exists s_orders; + +drop table if exists s_order_items; + +drop table if exists or_order_ship; + +drop table if exists organisation; + +drop table if exists organization_node; + +drop table if exists organization_tree_node; + +drop table if exists orp_detail; + +drop table if exists orp_detail2; + +drop table if exists orp_master; + +drop table if exists orp_master2; + +drop table if exists oto_aone; + +drop table if exists oto_atwo; + +drop table if exists oto_bchild; + +drop table if exists oto_bmaster; + +drop table if exists oto_child; + +drop table if exists oto_cust; + +drop table if exists oto_cust_address; + +drop table if exists oto_level_a; + +drop table if exists oto_level_b; + +drop table if exists oto_level_c; + +drop table if exists oto_master; + +drop table if exists oto_prime; + +drop table if exists oto_prime_extra; + +drop table if exists oto_sd_child; + +drop table if exists oto_sd_master; + +drop table if exists oto_th_many; + +drop table if exists oto_th_one; + +drop table if exists oto_th_top; + +drop table if exists oto_ubprime; + +drop table if exists oto_ubprime_extra; + +drop table if exists oto_uprime; + +drop table if exists oto_uprime_extra; + +drop table if exists oto_user_model; + +drop table if exists oto_user_model_optional; + +drop table if exists pfile; + +drop table if exists pfile_content; + +drop table if exists paggview; + +drop table if exists pallet_location; + +drop table if exists parcel; + +drop table if exists parcel_location; + +drop table if exists rawinherit_parent; + +drop table if exists rawinherit_parent_rawinherit_data; + +drop table if exists e_save_test_c; + +drop table if exists parent_person; + +drop table if exists c_participation; + +drop table if exists password_store_model; + +drop table if exists pcf_calendar; + +drop table if exists pcf_city; + +drop table if exists pcf_country; + +drop table if exists pcf_event; + +drop table if exists pcf_person; + +drop table if exists mt_permission; + +drop table if exists persistent_file; + +drop table if exists persistent_file_content; + +drop table if exists person; + +drop table if exists persons; + +drop table if exists person_cache_email; + +drop table if exists person_cache_info; + +drop table if exists phones; + +drop table if exists e_position; + +drop table if exists primary_revision; + +drop table if exists o_product; + +drop table if exists pp; + +drop table if exists pp_to_ww; + +drop table if exists question; + +drop table if exists rcustomer; + +drop table if exists r_orders; + +drop table if exists referencing_bean; + +drop table if exists region; + +drop table if exists rel_detail; + +drop table if exists rel_master; + +drop table if exists resourcefile; + +drop table if exists mt_role; + +drop table if exists mt_role_permission; + +drop table if exists em_role; + +drop table if exists root_bean; + +drop table if exists f_second; + +drop table if exists section; + +drop table if exists self_parent; + +drop table if exists self_ref_customer; + +drop table if exists self_ref_example; + +drop table if exists e_save_test_a; + +drop table if exists e_save_test_b; + +drop table if exists site; + +drop table if exists site_address; + +drop table if exists some_enum_bean; + +drop table if exists some_file_bean; + +drop table if exists some_new_types_bean; + +drop table if exists some_period_bean; + +drop table if exists source_base; + +drop table if exists stockforecast; + +drop table if exists sub_section; + +drop table if exists sub_type; + +drop table if exists survey; + +drop table if exists tbytes_only; + +drop table if exists tcar; + +drop table if exists tevent; + +drop table if exists tevent_many; + +drop table if exists tevent_one; + +drop table if exists tint_root; + +drop table if exists tjoda_entity; + +drop table if exists t_mapsuper1; + +drop table if exists t_oneb; + +drop table if exists t_detail_with_other_namexxxyy; + +drop table if exists t_atable_thatisrelatively; + +drop table if exists ttruck_holder; + +drop table if exists ttruck_holder_item; + +drop table if exists tuuid_entity; + +drop table if exists twheel; + +drop table if exists twith_pre_insert; + +drop table if exists target_base; + +drop table if exists mt_tenant; + +drop table if exists test_annotation_base_entity; + +drop table if exists tire; + +drop table if exists sa_tire; + +drop table if exists tree_entity; + +drop table if exists trip; + +drop table if exists truck_ref; + +drop table if exists tune; + +drop table if exists `type`; + +drop table if exists tz_bean; + +drop table if exists usib_child; + +drop table if exists usib_child_sibling; + +drop table if exists usib_parent; + +drop table if exists ut_detail; + +drop table if exists ut_master; + +drop table if exists uuone; + +drop table if exists uutwo; + +drop table if exists oto_user; + +drop trigger c_user_history_upd; +drop trigger c_user_history_del; +drop view c_user_with_history; +alter table c_user drop column sys_period_start; +alter table c_user drop column sys_period_end; +drop table c_user_history; + +drop table if exists c_user; + +drop table if exists tx_user; + +drop table if exists g_user; + +drop table if exists em_user; + +drop table if exists user_interest_live; + +drop table if exists em_user_role; + +drop table if exists vehicle; + +drop table if exists vehicle_driver; + +drop table if exists vehicle_lease; + +drop table if exists warehouses; + +drop table if exists warehousesshippingzones; + +drop table if exists wheel; + +drop table if exists sa_wheel; + +drop table if exists sp_car_wheel; + +drop table if exists g_who_props_otm; + +drop table if exists with_zero; + +drop table if exists parent; + +drop table if exists wview; + +drop table if exists zones; + +drop index ix_contact_last_name_first_name on contact; +drop index ix_e_basic_name on e_basic; +drop index ix_efile2_no_fk_owner_id on efile2_no_fk; +drop index ix_ecsm_values_host_id on ecsm_values; +drop index ix_organization_node_kind on organization_node; diff --git a/ebean-core/src/test/ddl-review/oracle-create-all.sql b/ebean-core/src/test/ddl-review/oracle-create-all.sql new file mode 100644 index 000000000..6c3b054cf --- /dev/null +++ b/ebean-core/src/test/ddl-review/oracle-create-all.sql @@ -0,0 +1,4826 @@ +-- Generated by ebean unknown at 2020-03-17T09:34:02.384264Z +create table asimple_bean ( + id number(19) generated by default as identity not null, + name varchar2(255), + constraint pk_asimple_bean primary key (id) +); + +create table bar ( + bar_type varchar2(31) not null, + bar_id number(10) generated by default as identity not null, + foo_id number(10) not null, + version number(10) not null, + constraint pk_bar primary key (bar_id) +); + +create table block ( + case_type number(31) not null, + id number(19) generated by default as identity not null, + name varchar2(255), + version number(19) not null, + notes varchar2(255), + constraint pk_block primary key (id) +); + +create table oto_account ( + id number(19) generated by default as identity not null, + name varchar2(255), + version number(19) not null, + when_created timestamp not null, + when_modified timestamp not null, + constraint pk_oto_account primary key (id) +); + +create table acl ( + id number(19) generated by default as identity not null, + name varchar2(255), + constraint pk_acl primary key (id) +); + +create table acl_container_relation ( + id number(19) generated by default as identity not null, + container_id number(19) not null, + acl_entry_id number(19) not null, + constraint pk_acl_container_relation primary key (id) +); + +create table addr ( + id number(19) generated by default as identity not null, + employee_id number(19), + name varchar2(255), + address_line1 varchar2(255), + address_line2 varchar2(255), + city varchar2(255), + version number(19) not null, + constraint pk_addr primary key (id) +); + +create table address ( + oid number(19) generated by default as identity not null, + street varchar2(255), + version number(10) not null, + constraint pk_address primary key (oid) +); + +create table o_address ( + id number(10) generated by default as identity not null, + line_1 varchar2(100), + line_2 varchar2(100), + city varchar2(100), + cretime timestamp, + country_code varchar2(2), + updtime timestamp not null, + constraint pk_o_address primary key (id) +); + +create table album ( + id number(19) generated by default as identity not null, + name varchar2(255), + cover_id number(19), + deleted number(1) default 0 not null, + created_at timestamp not null, + last_update timestamp not null, + constraint uq_album_cover_id unique (cover_id), + constraint pk_album primary key (id) +); + +create table animal ( + species varchar2(255) not null, + id number(19) generated by default as identity not null, + shelter_id number(19), + version number(19) not null, + name varchar2(255), + registration_number varchar2(255), + date_of_birth date, + dog_size varchar2(255), + constraint pk_animal primary key (id) +); + +create table animal_shelter ( + id number(19) generated by default as identity not null, + name varchar2(255), + version number(19) not null, + constraint pk_animal_shelter primary key (id) +); + +create table article ( + id number(10) generated by default as identity not null, + name varchar2(255), + author varchar2(255), + cretime timestamp not null, + updtime timestamp not null, + version number(19) not null, + constraint pk_article primary key (id) +); + +create table attribute ( + option_type number(31) not null, + id number(10) generated by default as identity not null, + attribute_holder_id number(10), + cretime timestamp not null, + updtime timestamp not null, + version number(19) not null, + constraint pk_attribute primary key (id) +); + +create table attribute_holder ( + id number(10) generated by default as identity not null, + cretime timestamp not null, + updtime timestamp not null, + version number(19) not null, + constraint pk_attribute_holder primary key (id) +); + +create table audit_log ( + id number(19) generated by default as identity (start with 1000 cache 100) not null, + description varchar2(255), + modified_description varchar2(255), + constraint pk_audit_log primary key (id) +); + +create table bbookmark ( + id number(10) generated by default as identity not null, + bookmark_reference varchar2(255), + user_id number(10), + constraint pk_bbookmark primary key (id) +); + +create table bbookmark_org ( + id number(10) generated by default as identity not null, + name varchar2(255), + constraint pk_bbookmark_org primary key (id) +); + +create table bbookmark_user ( + id number(10) generated by default as identity not null, + name varchar2(255), + password varchar2(255), + email_address varchar2(255), + country varchar2(255), + org_id number(10), + constraint pk_bbookmark_user primary key (id) +); + +create table bsimple_with_gen ( + id number(10) generated by default as identity not null, + name varchar2(255), + constraint pk_bsimple_with_gen primary key (id) +); + +create table bsite ( + id varchar2(40) not null, + name varchar2(255), + constraint pk_bsite primary key (id) +); + +create table bsite_user_a ( + site_id varchar2(40) not null, + user_id varchar2(40) not null, + access_level number(10), + version number(19) not null, + constraint ck_bsite_user_a_access_level check ( access_level in (0,1,2)), + constraint pk_bsite_user_a primary key (site_id,user_id) +); + +create table bsite_user_b ( + site varchar2(40) not null, + usr varchar2(40) not null, + access_level number(10), + constraint ck_bsite_user_b_access_level check ( access_level in (0,1,2)), + constraint pk_bsite_user_b primary key (site,usr) +); + +create table bsite_user_c ( + site_uid varchar2(40) not null, + user_uid varchar2(40) not null, + access_level number(10), + constraint ck_bsite_user_c_access_level check ( access_level in (0,1,2)), + constraint pk_bsite_user_c primary key (site_uid,user_uid) +); + +create table bsite_user_d ( + site_id varchar2(40) not null, + user_id varchar2(40) not null, + access_level number(10), + version number(19) not null, + constraint ck_bsite_user_d_access_level check ( access_level in (0,1,2)) +); + +create table bsite_user_e ( + site_id varchar2(40) not null, + user_id varchar2(40) not null, + access_level number(10), + constraint ck_bsite_user_e_access_level check ( access_level in (0,1,2)) +); + +create table buser ( + id varchar2(40) not null, + name varchar2(255), + constraint pk_buser primary key (id) +); + +create table bwith_qident ( + id number(10) generated by default as identity not null, + "Name" varchar2(191), + "CODE" varchar2(255), + last_updated timestamp not null, + constraint uq_bwith_qident_name unique ("Name"), + constraint pk_bwith_qident primary key (id) +); + +create table basic_draftable_bean ( + id number(19) generated by default as identity not null, + name varchar2(255), + version number(19) not null, + when_created timestamp not null, + when_modified timestamp not null, + constraint pk_basic_draftable_bean primary key (id) +); + +create table basic_draftable_bean_draft ( + id number(19) generated by default as identity not null, + name varchar2(255), + version number(19) not null, + when_created timestamp not null, + when_modified timestamp not null, + constraint pk_basic_draftable_bean_draft primary key (id) +); + +create table basic_joda_entity ( + id number(19) generated by default as identity not null, + name varchar2(255), + period varchar2(50), + local_date date, + created timestamp not null, + updated timestamp not null, + version timestamp not null, + constraint pk_basic_joda_entity primary key (id) +); + +create table bean_with_time_zone ( + id number(19) generated by default as identity not null, + name varchar2(255), + timezone varchar2(20), + constraint pk_bean_with_time_zone primary key (id) +); + +create table drel_booking ( + id number(19) not null, + booking_uid number(19), + agent_invoice number(19), + client_invoice number(19), + version number(10) not null, + constraint uq_drel_booking_booking_uid unique (booking_uid), + constraint uq_drel_booking_agent_invoice unique (agent_invoice), + constraint uq_drl_bkng_clnt_nvc unique (client_invoice), + constraint pk_drel_booking primary key (id) +); +create sequence drel_booking_seq increment by 1; + +create table bw_bean ( + id number(19) generated by default as identity not null, + name varchar2(255), + flags number(10) not null, + version number(19) not null, + constraint pk_bw_bean primary key (id) +); + +create table cepcategory ( + id number(19) generated by default as identity not null, + name varchar2(255), + version number(19) not null, + constraint pk_cepcategory primary key (id) +); + +create table cepproduct ( + id number(19) generated by default as identity not null, + name varchar2(255), + version number(19) not null, + constraint pk_cepproduct primary key (id) +); + +create table cepproduct_category ( + customer_id number(19) not null, + address_id number(19) not null, + category_id number(19) not null, + product_id number(19) not null, + priority number(10) +); + +create table ciaddress ( + id number(19) generated by default as identity not null, + street_id number(19), + constraint pk_ciaddress primary key (id) +); + +create table cicustomer_parent ( + dtype number(31) not null, + id number(19) generated by default as identity not null, + address_id number(19), + notes varchar2(255), + constraint pk_cicustomer_parent primary key (id) +); + +create table cistreet_parent ( + dtype number(31) not null, + id number(19) generated by default as identity not null, + name varchar2(255), + num varchar2(255), + constraint pk_cistreet_parent primary key (id) +); + +create table cinh_ref ( + id number(10) generated by default as identity not null, + ref_id number(10), + cretime timestamp not null, + updtime timestamp not null, + version number(19) not null, + constraint pk_cinh_ref primary key (id) +); + +create table cinh_root ( + dtype varchar2(3) not null, + id number(10) generated by default as identity not null, + license_number varchar2(255), + cretime timestamp not null, + updtime timestamp not null, + version number(19) not null, + driver varchar2(255), + notes varchar2(255), + action varchar2(255), + constraint pk_cinh_root primary key (id) +); + +create table ckey_assoc ( + id number(10) generated by default as identity not null, + assoc_one varchar2(255), + constraint pk_ckey_assoc primary key (id) +); + +create table ckey_detail ( + id number(10) generated by default as identity not null, + something varchar2(255), + one_key number(10), + two_key varchar2(127), + constraint pk_ckey_detail primary key (id) +); + +create table ckey_parent ( + one_key number(10) not null, + two_key varchar2(127) not null, + name varchar2(255), + assoc_id number(10), + version number(10) not null, + constraint pk_ckey_parent primary key (one_key,two_key) +); + +create table coone ( + id number(19) generated by default as identity not null, + name varchar2(255), + constraint pk_coone primary key (id) +); + +create table coone_many ( + id number(19) generated by default as identity not null, + coone_id number(19) not null, + name varchar2(255), + deleted number(1) default 0 not null, + constraint pk_coone_many primary key (id) +); + +create table coroot ( + id number(19) generated by default as identity not null, + name varchar2(255), + one_id number(19), + constraint uq_coroot_one_id unique (one_id), + constraint pk_coroot primary key (id) +); + +create table calculation_result ( + id number(10) generated by default as identity not null, + charge number(19,4) not null, + product_configuration_id number(10), + group_configuration_id number(10), + constraint pk_calculation_result primary key (id) +); + +create table cao_bean ( + x_cust_id number(10) not null, + x_type_id number(10) not null, + description varchar2(255), + version number(19) not null, + constraint pk_cao_bean primary key (x_cust_id,x_type_id) +); + +create table sp_car_car ( + id number(19) not null, + name varchar2(255), + version number(10) not null, + constraint pk_sp_car_car primary key (id) +); +create sequence sp_car_car_seq increment by 1; + +create table sp_car_car_wheels ( + car number(19) not null, + wheel number(19) not null, + constraint pk_sp_car_car_wheels primary key (car,wheel) +); + +create table sp_car_car_doors ( + car number(19) not null, + door number(19) not null, + constraint pk_sp_car_car_doors primary key (car,door) +); + +create table sa_car ( + id number(19) not null, + brand varchar2(255), + sold number(10) not null, + version number(10) not null, + constraint pk_sa_car primary key (id) +); +create sequence sa_car_seq increment by 1; + +create table car_accessory ( + id number(10) generated by default as identity not null, + name varchar2(255), + fuse_id number(19) not null, + car_id number(10), + cretime timestamp not null, + updtime timestamp not null, + version number(19) not null, + constraint pk_car_accessory primary key (id) +); + +create table car_fuse ( + id number(19) generated by default as identity not null, + location_code varchar2(255), + constraint pk_car_fuse primary key (id) +); + +create table category ( + id number(19) generated by default as identity not null, + name varchar2(255), + surveyobjectid number(19), + sequence_number number(10) not null, + constraint pk_category primary key (id) +); + +create table e_save_test_d ( + id number(19) generated by default as identity not null, + parent_id number(19), + test_property number(1) default 0 not null, + version number(19) not null, + constraint uq_e_save_test_d_parent_id unique (parent_id), + constraint pk_e_save_test_d primary key (id) +); + +create table child_person ( + identifier number(10) generated by default as identity not null, + name varchar2(255), + age number(10), + some_bean_id number(10), + parent_identifier number(10), + family_name varchar2(255), + address varchar2(255), + constraint pk_child_person primary key (identifier) +); + +create table cke_client ( + cod_cpny number(10) not null, + cod_client varchar2(100) not null, + username varchar2(100) not null, + notes varchar2(255), + constraint pk_cke_client primary key (cod_cpny,cod_client) +); + +create table cke_user ( + username varchar2(100) not null, + cod_cpny number(10) not null, + name varchar2(255), + constraint pk_cke_user primary key (username,cod_cpny) +); + +create table class_super ( + dtype varchar2(31) not null, + sid number(19) generated by default as identity not null, + constraint pk_class_super primary key (sid) +); + +create table class_super_monkey ( + class_super_sid number(19) not null, + monkey_mid number(19) not null, + constraint uq_class_super_monkey_mid unique (monkey_mid), + constraint pk_class_super_monkey primary key (class_super_sid,monkey_mid) +); + +create table configuration ( + type varchar2(21) not null, + id number(10) generated by default as identity not null, + name varchar2(255), + configurations_id number(10), + group_name varchar2(255), + product_name varchar2(255), + constraint pk_configuration primary key (id) +); + +create table configurations ( + id number(10) generated by default as identity not null, + name varchar2(255), + constraint pk_configurations primary key (id) +); + +create table contact ( + id number(10) generated by default as identity not null, + first_name varchar2(127), + last_name varchar2(127), + phone varchar2(255), + mobile varchar2(255), + email varchar2(255), + is_member number(1) default 0 not null, + customer_id number(10) not null, + group_id number(10), + cretime timestamp not null, + updtime timestamp not null, + constraint pk_contact primary key (id) +); + +create table contact_group ( + id number(10) generated by default as identity not null, + name varchar2(255), + cretime timestamp not null, + updtime timestamp not null, + version number(19) not null, + constraint pk_contact_group primary key (id) +); + +create table contact_note ( + id number(10) generated by default as identity not null, + contact_id number(10), + title varchar2(255), + note clob, + cretime timestamp not null, + updtime timestamp not null, + version number(19) not null, + constraint pk_contact_note primary key (id) +); + +create table contract ( + id number(19) generated by default as identity not null, + name varchar2(255), + constraint pk_contract primary key (id) +); + +create table contract_costs ( + id number(19) generated by default as identity not null, + status varchar2(255), + position_id number(19) not null, + constraint pk_contract_costs primary key (id) +); + +create table c_conversation ( + id number(19) generated by default as identity not null, + title varchar2(255), + isopen number(1) default 0 not null, + group_id number(19), + version number(19) not null, + when_created timestamp not null, + when_modified timestamp not null, + constraint pk_c_conversation primary key (id) +); + +create table o_country ( + code varchar2(2) not null, + name varchar2(60), + constraint pk_o_country primary key (code) +); + +create table cover ( + id number(19) generated by default as identity not null, + s3_url varchar2(255), + deleted number(1) default 0 not null, + constraint pk_cover primary key (id) +); + +create table o_customer ( + id number(10) generated by default as identity not null, + status varchar2(1), + name varchar2(40) not null, + smallnote varchar2(100), + anniversary date, + billing_address_id number(10), + shipping_address_id number(10), + cretime timestamp not null, + updtime timestamp not null, + version number(19) not null, + constraint ck_o_customer_status check ( status in ('N','A','I')), + constraint pk_o_customer primary key (id) +); +comment on table o_customer is 'Holds external customers'; +comment on column o_customer.status is 'status of the customer'; +comment on column o_customer.smallnote is 'Short notes regarding the customer'; +comment on column o_customer.anniversary is 'Join date of the customer'; + +create table dcredit ( + id number(19) generated by default as identity not null, + credit varchar2(255), + constraint pk_dcredit primary key (id) +); + +create table dcredit_drol ( + dcredit_id number(19) not null, + drol_id number(19) not null, + constraint pk_dcredit_drol primary key (dcredit_id,drol_id) +); + +create table dexh_entity ( + oid number(19) generated by default as identity not null, + exhange varchar2(255), + an_enum_type varchar2(255), + last_updated timestamp not null, + constraint pk_dexh_entity primary key (oid) +); + +create table dint_parent ( + type number(31) not null, + id number(19) generated by default as identity not null, + val number(10), + more varchar2(255), + constraint pk_dint_parent primary key (id) +); + +create table dmachine ( + id number(19) generated by default as identity not null, + name varchar2(255), + organisation_id number(19), + version number(19) not null, + constraint pk_dmachine primary key (id) +); + +create table d_machine_aux_use ( + id number(19) generated by default as identity not null, + machine_id number(19) not null, + name varchar2(255), + edate date, + use_secs number(19) not null, + fuel number(16,3), + version number(19) not null, + constraint pk_d_machine_aux_use primary key (id) +); + +create table d_machine_stats ( + id number(19) generated by default as identity not null, + machine_id number(19) not null, + edate date, + total_kms number(19) not null, + hours number(19) not null, + rate number(16,3), + cost number(16,3), + version number(19) not null, + constraint pk_d_machine_stats primary key (id) +); + +create table d_machine_use ( + id number(19) generated by default as identity not null, + machine_id number(19) not null, + edate date, + distance_kms number(19) not null, + time_secs number(19) not null, + fuel number(9,3), + version number(19) not null, + constraint pk_d_machine_use primary key (id) +); + +create table dorg ( + id number(19) generated by default as identity not null, + name varchar2(255), + version number(19) not null, + constraint pk_dorg primary key (id) +); + +create table dperson ( + id number(19) generated by default as identity not null, + first_name varchar2(255), + last_name varchar2(255), + salary number(16,3), + constraint pk_dperson primary key (id) +); + +create table drol ( + id number(19) generated by default as identity not null, + name varchar2(255), + constraint pk_drol primary key (id) +); + +create table drot ( + id number(19) generated by default as identity not null, + name varchar2(255), + constraint pk_drot primary key (id) +); + +create table drot_drol ( + drot_id number(19) not null, + drol_id number(19) not null, + constraint pk_drot_drol primary key (drot_id,drol_id) +); + +create table rawinherit_data ( + id number(19) generated by default as identity not null, + val number(10), + constraint pk_rawinherit_data primary key (id) +); + +create table data_container ( + id varchar2(40) not null, + content varchar2(255), + constraint pk_data_container primary key (id) +); + +create table dc_detail ( + id number(19) generated by default as identity not null, + master_id number(19), + description varchar2(255), + version number(19) not null, + constraint pk_dc_detail primary key (id) +); + +create table dc_master ( + id number(19) generated by default as identity not null, + name varchar2(255), + version number(19) not null, + constraint pk_dc_master primary key (id) +); + +create table dfk_cascade ( + id number(19) generated by default as identity not null, + name varchar2(255), + one_id number(19), + constraint pk_dfk_cascade primary key (id) +); + +create table dfk_cascade_one ( + id number(19) generated by default as identity not null, + name varchar2(255), + constraint pk_dfk_cascade_one primary key (id) +); + +create table dfk_none ( + id number(19) generated by default as identity not null, + name varchar2(255), + one_id number(19), + constraint pk_dfk_none primary key (id) +); + +create table dfk_none_via_join ( + id number(19) generated by default as identity not null, + name varchar2(255), + one_id number(19), + constraint pk_dfk_none_via_join primary key (id) +); + +create table dfk_none_via_mto_m ( + id number(19) generated by default as identity not null, + name varchar2(255), + constraint pk_dfk_none_via_mto_m primary key (id) +); + +create table dfk_none_via_mto_m_dfk_one ( + dfk_none_via_mto_m_id number(19) not null, + dfk_one_id number(19) not null, + constraint pk_dfk_none_via_mto_m_dfk_one primary key (dfk_none_via_mto_m_id,dfk_one_id) +); + +create table dfk_one ( + id number(19) generated by default as identity not null, + name varchar2(255), + constraint pk_dfk_one primary key (id) +); + +create table dfk_set_null ( + id number(19) generated by default as identity not null, + name varchar2(255), + one_id number(19), + constraint pk_dfk_set_null primary key (id) +); + +create table doc ( + id number(19) generated by default as identity not null, + name varchar2(255), + version number(19) not null, + when_created timestamp not null, + when_modified timestamp not null, + constraint pk_doc primary key (id) +); + +create table doc_link ( + doc_id number(19) not null, + link_id number(19) not null, + constraint pk_doc_link primary key (doc_id,link_id) +); + +create table doc_link_draft ( + doc_id number(19) not null, + link_id number(19) not null, + constraint pk_doc_link_draft primary key (doc_id,link_id) +); + +create table doc_draft ( + id number(19) generated by default as identity not null, + name varchar2(255), + version number(19) not null, + when_created timestamp not null, + when_modified timestamp not null, + constraint pk_doc_draft primary key (id) +); + +create table document ( + id number(19) generated by default as identity not null, + title varchar2(127), + body varchar2(255), + organisation_id number(19), + version number(19) not null, + when_created timestamp not null, + when_modified timestamp not null, + constraint uq_document_title unique (title), + constraint pk_document primary key (id) +); + +create table document_draft ( + id number(19) generated by default as identity not null, + title varchar2(127), + body varchar2(255), + when_publish timestamp, + organisation_id number(19), + version number(19) not null, + when_created timestamp not null, + when_modified timestamp not null, + constraint uq_document_draft_title unique (title), + constraint pk_document_draft primary key (id) +); + +create table document_media ( + id number(19) generated by default as identity not null, + document_id number(19), + name varchar2(255), + description varchar2(255), + version number(19) not null, + when_created timestamp not null, + when_modified timestamp not null, + constraint pk_document_media primary key (id) +); + +create table document_media_draft ( + id number(19) generated by default as identity not null, + document_id number(19), + name varchar2(255), + description varchar2(255), + version number(19) not null, + when_created timestamp not null, + when_modified timestamp not null, + constraint pk_document_media_draft primary key (id) +); + +create table sp_car_door ( + id number(19) not null, + name varchar2(255), + version number(10) not null, + constraint pk_sp_car_door primary key (id) +); +create sequence sp_car_door_seq increment by 1; + +create table earray_bean ( + id number(19) generated by default as identity not null, + foo number(10), + name varchar2(255), + phone_numbers varchar(300), + uids varchar(1000) not null, + other_ids varchar(1000), + doubs varchar(1000), + statuses varchar(1000), + vc_enums varchar(1000), + int_enums varchar(1000), + status2 varchar(1000), + version number(19) not null, + constraint ck_earray_bean_foo check ( foo in (100,101,102)), + constraint pk_earray_bean primary key (id) +); + +create table earray_set_bean ( + id number(19) generated by default as identity not null, + name varchar2(255), + phone_numbers varchar(300), + uids varchar(1000), + other_ids varchar(1000), + doubs varchar(1000), + version number(19) not null, + constraint pk_earray_set_bean primary key (id) +); + +create table e_basic ( + id number(10) generated by default as identity not null, + status varchar2(1), + name varchar2(127), + description varchar2(255), + some_date timestamp, + constraint ck_e_basic_status check ( status in ('N','A','I')), + constraint pk_e_basic primary key (id) +); + +create table ebasic_change_log ( + id number(19) generated by default as identity not null, + name varchar2(20), + short_description varchar2(50), + long_description varchar2(100), + who_created varchar2(255) not null, + who_modified varchar2(255) not null, + when_created timestamp not null, + when_modified timestamp not null, + version number(19) not null, + constraint pk_ebasic_change_log primary key (id) +); + +create table ebasic_clob ( + id number(19) generated by default as identity not null, + name varchar2(255), + title varchar2(255), + description clob, + last_update timestamp not null, + constraint pk_ebasic_clob primary key (id) +); + +create table ebasic_clob_fetch_eager ( + id number(19) generated by default as identity not null, + name varchar2(255), + title varchar2(255), + description clob, + last_update timestamp not null, + constraint pk_ebasic_clob_fetch_eager primary key (id) +); + +create table ebasic_clob_no_ver ( + id number(19) generated by default as identity not null, + name varchar2(255), + description clob, + constraint pk_ebasic_clob_no_ver primary key (id) +); + +create table e_basicenc ( + id number(10) generated by default as identity not null, + name varchar2(255), + description raw(80), + dob raw(20), + status raw(20), + last_update timestamp, + constraint pk_e_basicenc primary key (id) +); + +create table e_basicenc_bin ( + id number(10) generated by default as identity not null, + name varchar2(255), + description varchar2(255), + data blob, + some_time raw(255), + last_update timestamp not null, + constraint pk_e_basicenc_bin primary key (id) +); + +create table e_basicenc_client ( + id number(19) generated by default as identity not null, + name varchar2(255), + description raw(80), + dob raw(20), + status raw(20), + version number(19) not null, + constraint pk_e_basicenc_client primary key (id) +); + +create table e_basicenc_relate ( + id number(19) generated by default as identity not null, + name varchar2(255), + other_id number(10), + constraint pk_e_basicenc_relate primary key (id) +); + +create table e_basic_enum_id ( + status varchar2(1) not null, + name varchar2(255), + description varchar2(255), + constraint ck_e_basic_enum_id_status check ( status in ('N','A','I')), + constraint pk_e_basic_enum_id primary key (status) +); + +create table e_basic_eni ( + id number(10) generated by default as identity not null, + status number(10), + name varchar2(255), + description varchar2(255), + some_date timestamp, + constraint ck_e_basic_eni_status check ( status in (1,2,3)), + constraint pk_e_basic_eni primary key (id) +); + +create table ebasic_hstore ( + id number(19) generated by default as identity not null, + name varchar2(255), + map varchar2(800), + version number(19) not null, + constraint pk_ebasic_hstore primary key (id) +); + +create table ebasic_json_jackson ( + id number(19) generated by default as identity not null, + name varchar2(255), + value_set varchar2(700), + value_list clob, + value_map varchar2(700), + plain_value varchar2(500), + version number(19) not null, + constraint pk_ebasic_json_jackson primary key (id) +); + +create table ebasic_json_jackson2 ( + id number(19) generated by default as identity not null, + name varchar2(255), + value_set varchar2(700), + value_list clob, + value_map varchar2(700), + plain_value varchar2(500), + version number(19) not null, + constraint pk_ebasic_json_jackson2 primary key (id) +); + +create table ebasic_json_list ( + id number(19) generated by default as identity not null, + name varchar2(255), + bean_set varchar2(700), + bean_list clob, + bean_map varchar2(700), + plain_bean varchar2(500), + flags varchar2(50), + tags varchar2(100), + version number(19) not null, + constraint pk_ebasic_json_list primary key (id) +); + +create table ebasic_json_map ( + id number(19) generated by default as identity not null, + name varchar2(255), + content clob, + version number(19) not null, + constraint pk_ebasic_json_map primary key (id) +); + +create table ebasic_json_map_blob ( + id number(19) generated by default as identity not null, + name varchar2(255), + content blob, + version number(19) not null, + constraint pk_ebasic_json_map_blob primary key (id) +); + +create table ebasic_json_map_clob ( + id number(19) generated by default as identity not null, + name varchar2(255), + content clob, + version number(19) not null, + constraint pk_ebasic_json_map_clob primary key (id) +); + +create table ebasic_json_map_detail ( + id number(19) generated by default as identity not null, + owner_id number(19), + name varchar2(255), + content clob, + version number(19) not null, + constraint pk_ebasic_json_map_detail primary key (id) +); + +create table ebasic_json_map_json_b ( + id number(19) generated by default as identity not null, + name varchar2(255), + content clob, + version number(19) not null, + constraint pk_ebasic_json_map_json_b primary key (id) +); + +create table ebasic_json_map_varchar ( + id number(19) generated by default as identity not null, + name varchar2(255), + content varchar2(3000), + version number(19) not null, + constraint pk_ebasic_json_map_varchar primary key (id) +); + +create table ebasic_json_node ( + id number(19) generated by default as identity not null, + name varchar2(255), + content clob, + version number(19) not null, + constraint pk_ebasic_json_node primary key (id) +); + +create table ebasic_json_node_blob ( + id number(19) generated by default as identity not null, + name varchar2(255), + content blob, + version number(19) not null, + constraint pk_ebasic_json_node_blob primary key (id) +); + +create table ebasic_json_node_json_b ( + id number(19) generated by default as identity not null, + name varchar2(255), + content clob, + version number(19) not null, + constraint pk_ebasic_json_node_json_b primary key (id) +); + +create table ebasic_json_node_varchar ( + id number(19) generated by default as identity not null, + name varchar2(255), + content varchar2(1000), + version number(19) not null, + constraint pk_ebasic_json_node_varchar primary key (id) +); + +create table ebasic_json_unmapped ( + id number(19) generated by default as identity not null, + name varchar2(255), + version number(19) not null, + constraint pk_ebasic_json_unmapped primary key (id) +); + +create table e_basic_ndc ( + id number(10) generated by default as identity not null, + name varchar2(255), + constraint pk_e_basic_ndc primary key (id) +); + +create table ebasic_no_sdchild ( + id number(19) generated by default as identity not null, + owner_id number(19) not null, + child_name varchar2(255), + amount number(19) not null, + version number(19) not null, + constraint pk_ebasic_no_sdchild primary key (id) +); + +create table ebasic_sdchild ( + id number(19) generated by default as identity not null, + owner_id number(19) not null, + child_name varchar2(255), + amount number(19) not null, + version number(19) not null, + deleted number(1) default 0 not null, + constraint pk_ebasic_sdchild primary key (id) +); + +create table ebasic_soft_delete ( + id number(19) generated by default as identity not null, + name varchar2(255), + description varchar2(255), + version number(19) not null, + deleted number(1) default 0 not null, + constraint pk_ebasic_soft_delete primary key (id) +); + +create table e_basicver ( + id number(10) generated by default as identity not null, + name varchar2(255), + description varchar2(255), + other varchar2(255), + last_update timestamp not null, + constraint pk_e_basicver primary key (id) +); + +create table e_basic_withlife ( + id number(19) generated by default as identity not null, + name varchar2(255), + other varchar2(255), + deleted number(1) default 0 not null, + version number(19) not null, + constraint pk_e_basic_withlife primary key (id) +); + +create table e_basic_with_ex ( + id number(19) generated by default as identity not null, + deleted number(1) default 0 not null, + version number(19) not null, + constraint pk_e_basic_with_ex primary key (id) +); + +create table e_basicverucon ( + id number(10) generated by default as identity not null, + name varchar2(127), + other varchar2(127), + other_one varchar2(127), + description varchar2(255), + last_update timestamp not null, + constraint uq_e_basicverucon_name unique (name), + constraint uq_e_bscvrcn_thr_thr_n unique (other,other_one), + constraint pk_e_basicverucon primary key (id) +); + +create table ecache_child ( + id varchar2(40) not null, + name varchar2(100), + root_id varchar2(40) not null, + constraint pk_ecache_child primary key (id) +); + +create table ecache_root ( + id varchar2(40) not null, + name varchar2(100), + constraint pk_ecache_root primary key (id) +); + +create table e_col_ab ( + id number(19) generated by default as identity not null, + column_a varchar2(255), + column_b varchar2(255), + constraint pk_e_col_ab primary key (id) +); + +create table ecustom_id ( + id varchar2(127) not null, + name varchar2(255), + constraint pk_ecustom_id primary key (id) +); + +create table edefault_prop ( + id number(10) generated by default as identity not null, + e_simple_usertypeid number(10), + name varchar2(255), + constraint uq_edflt_prp__smpl_srtypd unique (e_simple_usertypeid), + constraint pk_edefault_prop primary key (id) +); + +create table eemb_inner ( + id number(10) generated by default as identity not null, + nome_inner varchar2(255), + outer_id number(10), + update_count number(10) not null, + constraint pk_eemb_inner primary key (id) +); + +create table eemb_outer ( + id number(10) generated by default as identity not null, + nome_outer varchar2(255), + date1 timestamp, + date2 timestamp, + update_count number(10) not null, + constraint pk_eemb_outer primary key (id) +); + +create table efile2_no_fk ( + file_name varchar2(64) not null, + owner_id number(10) not null, + constraint pk_efile2_no_fk primary key (file_name) +); + +create table efile_no_fk ( + file_name varchar2(64) not null, + owner_user_id number(10), + owner_soft_del_user_id number(10), + constraint pk_efile_no_fk primary key (file_name) +); + +create table efile_no_fk_euser_no_fk ( + efile_no_fk_file_name varchar2(64) not null, + euser_no_fk_user_id number(10) not null, + constraint pk_efile_no_fk_euser_no_fk primary key (efile_no_fk_file_name,euser_no_fk_user_id) +); + +create table efile_no_fk_euser_no_fk_soft_d ( + efile_no_fk_file_name varchar2(64) not null, + euser_no_fk_soft_del_user_id number(10) not null, + constraint pk_efl_n_fk_sr_n_fk_sft_d primary key (efile_no_fk_file_name,euser_no_fk_soft_del_user_id) +); + +create table egen_props ( + id number(19) generated by default as identity not null, + name varchar2(255), + version number(19) not null, + when_created timestamp not null, + when_modified timestamp not null, + ts_created timestamp not null, + ts_updated timestamp not null, + ldt_created timestamp not null, + ldt_updated timestamp not null, + odt_created timestamp not null, + odt_updated timestamp not null, + zdt_created timestamp not null, + zdt_updated timestamp not null, + instant_created timestamp not null, + instant_updated timestamp not null, + long_created number(19) not null, + long_updated number(19) not null, + constraint pk_egen_props primary key (id) +); + +create table eid_uid_bean ( + id number(19) generated by default as identity not null, + uuid varchar2(40) not null, + name varchar2(255), + constraint uq_eid_uid_bean_uuid unique (uuid), + constraint pk_eid_uid_bean primary key (id) +); + +create table einvoice ( + id number(19) generated by default as identity not null, + invoice_date timestamp, + state number(10), + person_id number(19), + ship_street varchar2(255), + ship_suburb varchar2(255), + ship_city varchar2(255), + ship_status varchar2(3), + bill_street varchar2(255), + bill_suburb varchar2(255), + bill_city varchar2(255), + bill_status varchar2(3), + version number(19) not null, + constraint ck_einvoice_state check ( state in (0,1,2)), + constraint ck_einvoice_ship_status check ( ship_status in ('ONE','TWO')), + constraint ck_einvoice_bill_status check ( bill_status in ('ONE','TWO')), + constraint pk_einvoice primary key (id) +); + +create table e_main ( + id number(10) generated by default as identity not null, + name varchar2(255), + description varchar2(255), + version number(19) not null, + constraint pk_e_main primary key (id) +); + +create table enull_collection ( + id number(10) generated by default as identity not null, + name varchar2(255), + constraint pk_enull_collection primary key (id) +); + +create table enull_collection_detail ( + id number(10) generated by default as identity not null, + enull_collection_id number(10) not null, + something varchar2(255), + constraint pk_enull_collection_detail primary key (id) +); + +create table eopt_one_a ( + id number(10) generated by default as identity not null, + name_for_a varchar2(255), + b_id number(10), + cretime timestamp not null, + updtime timestamp not null, + version number(19) not null, + constraint pk_eopt_one_a primary key (id) +); + +create table eopt_one_b ( + id number(10) generated by default as identity not null, + name_for_b varchar2(255), + c_id number(10) not null, + cretime timestamp not null, + updtime timestamp not null, + version number(19) not null, + constraint pk_eopt_one_b primary key (id) +); + +create table eopt_one_c ( + id number(10) generated by default as identity not null, + name_for_c varchar2(255), + cretime timestamp not null, + updtime timestamp not null, + version number(19) not null, + constraint pk_eopt_one_c primary key (id) +); + +create table eper_addr ( + id number(19) generated by default as identity not null, + name varchar2(255), + ma_street varchar2(255), + ma_suburb varchar2(255), + ma_city varchar2(255), + ma_country_code varchar2(2), + version number(19) not null, + constraint pk_eper_addr primary key (id) +); + +create table eperson ( + id number(19) generated by default as identity not null, + name varchar2(255), + notes varchar2(255), + street varchar2(255), + suburb varchar2(255), + addr_city varchar2(255), + addr_status varchar2(3), + version number(19) not null, + constraint ck_eperson_addr_status check ( addr_status in ('ONE','TWO')), + constraint pk_eperson primary key (id) +); + +create table e_person_online ( + id number(19) generated by default as identity not null, + email varchar2(127), + online_status number(1) default 0 not null, + when_updated timestamp not null, + constraint uq_e_person_online_email unique (email), + constraint pk_e_person_online primary key (id) +); + +create table esimple ( + usertypeid number(10) generated by default as identity not null, + name varchar2(255), + constraint pk_esimple primary key (usertypeid) +); + +create table esoft_del_book ( + id number(19) generated by default as identity not null, + book_title varchar2(255), + lend_by_id number(19), + version number(19) not null, + deleted number(1) default 0 not null, + constraint pk_esoft_del_book primary key (id) +); + +create table esoft_del_book_esoft_del_user ( + esoft_del_book_id number(19) not null, + esoft_del_user_id number(19) not null, + constraint pk_esft_dl_bk_sft_dl_sr primary key (esoft_del_book_id,esoft_del_user_id) +); + +create table esoft_del_down ( + id number(19) generated by default as identity not null, + esoft_del_mid_id number(19) not null, + down varchar2(255), + version number(19) not null, + deleted number(1) default 0 not null, + constraint pk_esoft_del_down primary key (id) +); + +create table esoft_del_mid ( + id number(19) generated by default as identity not null, + top_id number(19), + mid varchar2(255), + up_id number(19), + version number(19) not null, + deleted number(1) default 0 not null, + constraint pk_esoft_del_mid primary key (id) +); + +create table esoft_del_one_a ( + id number(19) generated by default as identity not null, + name varchar2(255), + oneb_id number(19), + deleted number(1) default 0 not null, + version number(19) not null, + constraint uq_esoft_del_one_a_oneb_id unique (oneb_id), + constraint pk_esoft_del_one_a primary key (id) +); + +create table esoft_del_one_b ( + id number(19) generated by default as identity not null, + name varchar2(255), + version number(19) not null, + constraint pk_esoft_del_one_b primary key (id) +); + +create table esoft_del_role ( + id number(19) generated by default as identity not null, + role_name varchar2(255), + version number(19) not null, + deleted number(1) default 0 not null, + constraint pk_esoft_del_role primary key (id) +); + +create table esoft_del_role_esoft_del_user ( + esoft_del_role_id number(19) not null, + esoft_del_user_id number(19) not null, + constraint pk_esft_dl_rl_sft_dl_sr primary key (esoft_del_role_id,esoft_del_user_id) +); + +create table esoft_del_top ( + id number(19) generated by default as identity not null, + name varchar2(255), + version number(19) not null, + deleted number(1) default 0 not null, + constraint pk_esoft_del_top primary key (id) +); + +create table esoft_del_up ( + id number(19) generated by default as identity not null, + up varchar2(255), + version number(19) not null, + deleted number(1) default 0 not null, + constraint pk_esoft_del_up primary key (id) +); + +create table esoft_del_user ( + id number(19) generated by default as identity not null, + user_name varchar2(255), + version number(19) not null, + deleted number(1) default 0 not null, + constraint pk_esoft_del_user primary key (id) +); + +create table esoft_del_user_esoft_del_role ( + esoft_del_user_id number(19) not null, + esoft_del_role_id number(19) not null, + constraint pk_esft_dl_sr_sft_dl_rl primary key (esoft_del_user_id,esoft_del_role_id) +); + +create table esome_convert_type ( + id number(19) generated by default as identity not null, + name varchar2(255), + money number(16,3), + constraint pk_esome_convert_type primary key (id) +); + +create table esome_type ( + id number(10) generated by default as identity not null, + currency varchar2(3), + locale varchar2(20), + time_zone varchar2(20), + constraint pk_esome_type primary key (id) +); + +create table etrans_many ( + id number(10) generated by default as identity not null, + name varchar2(255), + constraint pk_etrans_many primary key (id) +); + +create table rawinherit_uncle ( + id number(10) generated by default as identity not null, + name varchar2(255), + parent_id number(19) not null, + version number(19) not null, + constraint pk_rawinherit_uncle primary key (id) +); + +create table euser_no_fk ( + user_id number(10) generated by default as identity not null, + user_name varchar2(255), + constraint pk_euser_no_fk primary key (user_id) +); + +create table euser_no_fk_soft_del ( + user_id number(10) generated by default as identity not null, + user_name varchar2(255), + constraint pk_euser_no_fk_soft_del primary key (user_id) +); + +create table evanilla_collection ( + id number(10) generated by default as identity not null, + name varchar2(255), + constraint pk_evanilla_collection primary key (id) +); + +create table evanilla_collection_detail ( + id number(10) generated by default as identity not null, + evanilla_collection_id number(10) not null, + something varchar2(255), + constraint pk_evanilla_collection_detail primary key (id) +); + +create table ewho_props ( + id number(19) generated by default as identity not null, + name varchar2(255), + version number(19) not null, + when_created timestamp not null, + when_modified timestamp not null, + who_created varchar2(255) not null, + who_modified varchar2(255) not null, + constraint pk_ewho_props primary key (id) +); + +create table e_withinet ( + id number(19) generated by default as identity not null, + name varchar2(255), + inet_address varchar2(50), + inet2 varchar2(255), + cidr varchar(50), + version number(19) not null, + constraint pk_e_withinet primary key (id) +); + +create table ec_enum_person ( + id number(19) generated by default as identity not null, + name varchar2(255), + version number(19) not null, + constraint pk_ec_enum_person primary key (id) +); + +create table ec_enum_person_tags ( + ec_enum_person_id number(19) not null, + value varchar2(5) not null, + constraint ck_ec_enum_person_tags_value check ( value in ('RED','BLUE','GREEN')) +); + +create table ec_person ( + id number(19) generated by default as identity not null, + name varchar2(255), + version number(19) not null, + constraint pk_ec_person primary key (id) +); + +create table ec_person_phone ( + owner_id number(19) not null, + phone varchar2(255) not null +); + +create table ec_top ( + id number(19) generated by default as identity not null, + name varchar2(255), + person_id number(19), + version number(19) not null, + constraint pk_ec_top primary key (id) +); + +create table ec_top_ecs_person ( + ec_top_id number(19) not null, + ecs_person_id number(19) not null, + constraint pk_ec_top_ecs_person primary key (ec_top_id,ecs_person_id) +); + +create table ecbl_person ( + id number(19) generated by default as identity not null, + name varchar2(255), + version number(19) not null, + constraint pk_ecbl_person primary key (id) +); + +create table ecbl_person_phone_numbers ( + person_id number(19) not null, + country_code varchar2(2), + area varchar2(6), + phnum varchar2(20) +); + +create table ecbm_person ( + id number(19) generated by default as identity not null, + name varchar2(255), + version number(19) not null, + constraint pk_ecbm_person primary key (id) +); + +create table ecbm_person_phone_numbers ( + person_id number(19) not null, + mkey varchar2(255) not null, + country_code varchar2(2), + area varchar2(6), + phnum varchar2(20) +); + +create table ecm_person ( + id number(19) generated by default as identity not null, + name varchar2(255), + version number(19) not null, + constraint pk_ecm_person primary key (id) +); + +create table ecm_person_phone_numbers ( + ecm_person_id number(19) not null, + type varchar2(4) not null, + phnum varchar2(10) not null +); + +create table ecmc_person ( + id number(19) generated by default as identity not null, + name varchar2(255), + version number(19) not null, + constraint pk_ecmc_person primary key (id) +); + +create table ecmc_person_phone_numbers ( + ecmc_person_id number(19) not null, + type varchar2(4) not null, + value clob not null +); + +create table ecs_person ( + id number(19) generated by default as identity not null, + name varchar2(255), + version number(19) not null, + constraint pk_ecs_person primary key (id) +); + +create table ecs_person_phone ( + ecs_person_id number(19) not null, + phone varchar2(255) not null +); + +create table ecsm_child ( + one_id varchar2(40) not null, + ecsm_parent_id number(19) not null, + name varchar2(255), + version number(19) not null, + constraint pk_ecsm_child primary key (one_id) +); + +create table ecsm_values ( + host_id varchar2(40) not null, + value varchar2(255) not null +); + +create table ecsm_one ( + one_id varchar2(40) not null, + name varchar2(255), + version number(19) not null, + constraint pk_ecsm_one primary key (one_id) +); + +create table ecsm_parent ( + id number(19) generated by default as identity not null, + name varchar2(255), + version number(19) not null, + constraint pk_ecsm_parent primary key (id) +); + +create table ecsm_two ( + id varchar2(40) not null, + name varchar2(255), + version number(19) not null, + constraint pk_ecsm_two primary key (id) +); + +create table td_child ( + child_id number(10) generated by default as identity not null, + child_name varchar2(255), + parent_id number(10) not null, + constraint pk_td_child primary key (child_id) +); + +create table td_parent ( + parent_type varchar2(31) not null, + parent_id number(10) generated by default as identity not null, + parent_name varchar2(255), + extended_name varchar2(255), + constraint pk_td_parent primary key (parent_id) +); + +create table element_bean ( + id number(19) generated by default as identity not null, + complex_bean_id varchar2(40) not null, + value varchar2(255) not null, + constraint pk_element_bean primary key (id) +); + +create table empl ( + id number(19) generated by default as identity not null, + name varchar2(255), + age number(10), + default_address_id number(19), + constraint pk_empl primary key (id) +); + +create table esd_detail ( + id number(19) generated by default as identity not null, + name varchar2(255), + master_id number(19) not null, + version number(19) not null, + deleted number(1) default 0 not null, + constraint pk_esd_detail primary key (id) +); + +create table esd_master ( + id number(19) generated by default as identity not null, + name varchar2(255), + version number(19) not null, + deleted number(1) default 0 not null, + constraint pk_esd_master primary key (id) +); + +create table feature_desc ( + id number(10) generated by default as identity not null, + name varchar2(255), + description varchar2(255), + constraint pk_feature_desc primary key (id) +); + +create table f_first ( + id number(19) generated by default as identity not null, + name varchar2(255), + constraint pk_f_first primary key (id) +); + +create table foo ( + foo_id number(10) generated by default as identity not null, + important_text varchar2(255), + version number(10) not null, + constraint pk_foo primary key (foo_id) +); + +create table gen_key_identity ( + id number(19) generated by default as identity not null, + description varchar2(255), + constraint pk_gen_key_identity primary key (id) +); + +create table gen_key_sequence ( + id number(19) not null, + description varchar2(255), + constraint pk_gen_key_sequence primary key (id) +); +create sequence SEQ_NAME increment by 1; + +create table grand_parent_person ( + identifier number(10) generated by default as identity not null, + name varchar2(255), + age number(10), + some_bean_id number(10), + family_name varchar2(255), + address varchar2(255), + constraint pk_grand_parent_person primary key (identifier) +); + +create table survey_group ( + id number(19) generated by default as identity not null, + name varchar2(255), + categoryobjectid number(19), + sequence_number number(10) not null, + constraint pk_survey_group primary key (id) +); + +create table c_group ( + id number(19) generated by default as identity not null, + inactive number(1) default 0 not null, + name varchar2(255), + version number(19) not null, + when_created timestamp not null, + when_modified timestamp not null, + constraint pk_c_group primary key (id) +); + +create table he_doc ( + id number(19) generated by default as identity not null, + name varchar2(255), + version number(19) not null, + when_created timestamp not null, + when_modified timestamp not null, + constraint pk_he_doc primary key (id) +); + +create table hx_link ( + id number(19) generated by default as identity not null, + name varchar2(255), + location varchar2(255), + comments varchar2(255), + version number(19) not null, + when_created timestamp not null, + when_modified timestamp not null, + deleted number(1) default 0 not null, + constraint pk_hx_link primary key (id) +); + +create table hx_link_doc ( + hx_link_id number(19) not null, + he_doc_id number(19) not null, + constraint pk_hx_link_doc primary key (hx_link_id,he_doc_id) +); + +create table hi_doc ( + id number(19) generated by default as identity not null, + name varchar2(255), + version number(19) not null, + when_created timestamp not null, + when_modified timestamp not null, + constraint pk_hi_doc primary key (id) +); + +create table hi_link ( + id number(19) generated by default as identity not null, + name varchar2(255), + location varchar2(255), + comments varchar2(255), + version number(19) not null, + when_created timestamp not null, + when_modified timestamp not null, + constraint pk_hi_link primary key (id) +); + +create table hi_link_doc ( + hi_link_id number(19) not null, + hi_doc_id number(19) not null, + constraint pk_hi_link_doc primary key (hi_link_id,hi_doc_id) +); + +create table hi_tone ( + id number(19) generated by default as identity not null, + name varchar2(255), + comments varchar2(255), + version number(19) not null, + when_created timestamp not null, + when_modified timestamp not null, + constraint pk_hi_tone primary key (id) +); + +create table hi_tthree ( + id number(19) generated by default as identity not null, + hi_ttwo_id number(19) not null, + three varchar2(255), + version number(19) not null, + when_created timestamp not null, + when_modified timestamp not null, + constraint pk_hi_tthree primary key (id) +); + +create table hi_ttwo ( + id number(19) generated by default as identity not null, + hi_tone_id number(19) not null, + two varchar2(255), + version number(19) not null, + when_created timestamp not null, + when_modified timestamp not null, + constraint pk_hi_ttwo primary key (id) +); + +create table hsd_setting ( + id number(19) generated by default as identity not null, + code varchar2(255), + content varchar2(255), + user_id number(19), + version number(19) not null, + when_created timestamp not null, + when_modified timestamp not null, + deleted number(1) default 0 not null, + constraint uq_hsd_setting_user_id unique (user_id), + constraint pk_hsd_setting primary key (id) +); + +create table hsd_user ( + id number(19) generated by default as identity not null, + name varchar2(255), + version number(19) not null, + when_created timestamp not null, + when_modified timestamp not null, + deleted number(1) default 0 not null, + constraint pk_hsd_user primary key (id) +); + +create table iaf_segment ( + ptype varchar2(31) not null, + id number(19) generated by default as identity not null, + segment_id_zat number(19) not null, + status_id number(19) not null, + constraint pk_iaf_segment primary key (id) +); + +create table iaf_segment_status ( + id number(19) generated by default as identity not null, + name varchar2(255), + constraint pk_iaf_segment_status primary key (id) +); + +create table imrelated ( + id number(19) generated by default as identity not null, + name varchar2(255), + owner_id number(19) not null, + constraint pk_imrelated primary key (id) +); + +create table imroot ( + dtype varchar2(31) not null, + id number(19) generated by default as identity not null, + name varchar2(255), + title varchar2(255), + when_title timestamp, + constraint pk_imroot primary key (id) +); + +create table ixresource ( + dtype varchar2(255), + id varchar2(40) not null, + name varchar2(255), + constraint pk_ixresource primary key (id) +); + +create table info_company ( + id number(19) generated by default as identity not null, + name varchar2(255), + version number(19) not null, + constraint pk_info_company primary key (id) +); + +create table info_contact ( + id number(19) generated by default as identity not null, + name varchar2(255), + company_id number(19) not null, + version number(19) not null, + constraint pk_info_contact primary key (id) +); + +create table info_customer ( + id number(19) generated by default as identity not null, + name varchar2(255), + company_id number(19), + version number(19) not null, + constraint uq_info_customer_company_id unique (company_id), + constraint pk_info_customer primary key (id) +); + +create table inner_report ( + id number(19) generated by default as identity not null, + name varchar2(255), + forecast_id number(19), + constraint uq_inner_report_forecast_id unique (forecast_id), + constraint pk_inner_report primary key (id) +); + +create table drel_invoice ( + id number(19) not null, + booking number(19), + version number(10) not null, + constraint pk_drel_invoice primary key (id) +); +create sequence drel_invoice_seq increment by 1; + +create table item ( + customer number(10) not null, + itemnumber varchar2(127) not null, + description varchar2(255), + units varchar2(255), + type number(10) not null, + region number(10) not null, + date_modified timestamp, + date_created timestamp, + modified_by varchar2(255), + created_by varchar2(255), + version number(19) not null, + constraint pk_item primary key (customer,itemnumber) +); + +create table monkey ( + mid number(19) generated by default as identity not null, + name varchar2(255), + food_preference varchar2(255), + version number(19) not null, + constraint pk_monkey primary key (mid) +); + +create table mkeygroup ( + pid number(19) generated by default as identity not null, + name varchar2(255), + version number(19) not null, + constraint pk_mkeygroup primary key (pid) +); + +create table mkeygroup_monkey ( + mkeygroup_pid number(19) not null, + monkey_mid number(19) not null, + constraint uq_mkeygroup_monkey_mid unique (monkey_mid), + constraint pk_mkeygroup_monkey primary key (mkeygroup_pid,monkey_mid) +); + +create table trainer ( + tid number(19) generated by default as identity not null, + name varchar2(255), + version number(19) not null, + constraint pk_trainer primary key (tid) +); + +create table trainer_monkey ( + trainer_tid number(19) not null, + monkey_mid number(19) not null, + constraint uq_trainer_monkey_mid unique (monkey_mid), + constraint pk_trainer_monkey primary key (trainer_tid,monkey_mid) +); + +create table troop ( + pid number(19) generated by default as identity not null, + name varchar2(255), + version number(19) not null, + constraint pk_troop primary key (pid) +); + +create table troop_monkey ( + troop_pid number(19) not null, + monkey_mid number(19) not null, + constraint uq_troop_monkey_mid unique (monkey_mid), + constraint pk_troop_monkey primary key (troop_pid,monkey_mid) +); + +create table l2_cldf_reset_bean ( + id number(19) generated by default as identity not null, + name varchar2(255), + constraint pk_l2_cldf_reset_bean primary key (id) +); + +create table l2_cldf_reset_bean_child ( + id number(19) generated by default as identity not null, + parent_id number(19), + constraint pk_l2_cldf_reset_bean_child primary key (id) +); + +create table level1 ( + id number(19) generated by default as identity not null, + name varchar2(255), + constraint pk_level1 primary key (id) +); + +create table level1_level4 ( + level1_id number(19) not null, + level4_id number(19) not null, + constraint pk_level1_level4 primary key (level1_id,level4_id) +); + +create table level1_level2 ( + level1_id number(19) not null, + level2_id number(19) not null, + constraint pk_level1_level2 primary key (level1_id,level2_id) +); + +create table level2 ( + id number(19) generated by default as identity not null, + name varchar2(255), + constraint pk_level2 primary key (id) +); + +create table level2_level3 ( + level2_id number(19) not null, + level3_id number(19) not null, + constraint pk_level2_level3 primary key (level2_id,level3_id) +); + +create table level3 ( + id number(19) generated by default as identity not null, + name varchar2(255), + constraint pk_level3 primary key (id) +); + +create table level4 ( + id number(19) generated by default as identity not null, + name varchar2(255), + constraint pk_level4 primary key (id) +); + +create table link ( + id number(19) generated by default as identity not null, + name varchar2(255), + location varchar2(255), + when_publish timestamp, + link_comment varchar2(255), + version number(19) not null, + when_created timestamp not null, + when_modified timestamp not null, + deleted number(1) default 0 not null, + constraint pk_link primary key (id) +); + +create table link_draft ( + id number(19) generated by default as identity not null, + name varchar2(255), + location varchar2(255), + when_publish timestamp, + link_comment varchar2(255), + dirty number(1) default 0 not null, + version number(19) not null, + when_created timestamp not null, + when_modified timestamp not null, + deleted number(1) default 0 not null, + constraint pk_link_draft primary key (id) +); + +create table la_attr_value ( + id number(10) generated by default as identity not null, + name varchar2(255), + cretime timestamp not null, + updtime timestamp not null, + version number(19) not null, + constraint pk_la_attr_value primary key (id) +); + +create table la_attr_value_attribute ( + la_attr_value_id number(10) not null, + attribute_id number(10) not null, + constraint pk_la_attr_value_attribute primary key (la_attr_value_id,attribute_id) +); + +create table looney ( + id number(19) generated by default as identity not null, + tune_id number(19), + name varchar2(255), + constraint pk_looney primary key (id) +); + +create table maddress ( + id varchar2(40) not null, + street varchar2(255), + city varchar2(255), + version number(19) not null, + constraint pk_maddress primary key (id) +); + +create table mcontact ( + id varchar2(40) not null, + email varchar2(255), + first_name varchar2(255), + last_name varchar2(255), + customer_id varchar2(40), + version number(19) not null, + constraint pk_mcontact primary key (id) +); + +create table mcontact_message ( + id varchar2(40) not null, + title varchar2(255), + subject varchar2(255), + notes varchar2(255), + contact_id varchar2(40) not null, + version number(19) not null, + constraint pk_mcontact_message primary key (id) +); + +create table mcustomer ( + id varchar2(40) not null, + name varchar2(255), + notes varchar2(255), + shipping_address_id varchar2(40), + billing_address_id varchar2(40), + version number(19) not null, + constraint pk_mcustomer primary key (id) +); + +create table mgroup ( + id number(19) generated by default as identity not null, + name varchar2(255), + constraint pk_mgroup primary key (id) +); + +create table mmachine ( + id number(19) generated by default as identity not null, + name varchar2(255), + version number(19) not null, + constraint pk_mmachine primary key (id) +); + +create table mmachine_mgroup ( + mmachine_id number(19) not null, + mgroup_id number(19) not null, + constraint pk_mmachine_mgroup primary key (mmachine_id,mgroup_id) +); + +create table mmedia ( + type varchar2(31) not null, + id number(19) generated by default as identity not null, + url varchar2(255), + note varchar2(255), + constraint pk_mmedia primary key (id) +); + +create table non_updateprop ( + id number(10) generated by default as identity not null, + non_enum varchar2(5), + name varchar2(255), + note varchar2(255), + constraint ck_non_updateprop_non_enum check ( non_enum in ('BEGIN','END')), + constraint pk_non_updateprop primary key (id) +); + +create table mprinter ( + id number(19) generated by default as identity not null, + name varchar2(255), + flags number(19) not null, + current_state_id number(19), + last_swap_cyan_id number(19), + last_swap_magenta_id number(19), + last_swap_yellow_id number(19), + last_swap_black_id number(19), + version number(19) not null, + constraint uq_mprinter_last_swap_cyan_id unique (last_swap_cyan_id), + constraint uq_mprntr_lst_swp_mgnt_d unique (last_swap_magenta_id), + constraint uq_mprntr_lst_swp_yllw_d unique (last_swap_yellow_id), + constraint uq_mprntr_lst_swp_blck_d unique (last_swap_black_id), + constraint pk_mprinter primary key (id) +); + +create table mprinter_state ( + id number(19) generated by default as identity not null, + flags number(19) not null, + printer_id number(19), + version number(19) not null, + constraint pk_mprinter_state primary key (id) +); + +create table mprofile ( + id number(19) generated by default as identity not null, + picture_id number(19), + name varchar2(255), + constraint pk_mprofile primary key (id) +); + +create table mprotected_construct_bean ( + id number(19) generated by default as identity not null, + name varchar2(255), + constraint pk_mprotected_construct_bean primary key (id) +); + +create table mrole ( + roleid number(10) generated by default as identity not null, + role_name varchar2(255), + constraint pk_mrole primary key (roleid) +); + +create table mrole_muser ( + mrole_roleid number(10) not null, + muser_userid number(10) not null, + constraint pk_mrole_muser primary key (mrole_roleid,muser_userid) +); + +create table msome_other ( + id number(19) generated by default as identity not null, + name varchar2(255), + constraint pk_msome_other primary key (id) +); + +create table muser ( + userid number(10) generated by default as identity not null, + user_name varchar2(255), + user_type_id number(10), + constraint pk_muser primary key (userid) +); + +create table muser_type ( + id number(10) generated by default as identity not null, + name varchar2(255), + constraint pk_muser_type primary key (id) +); + +create table mail_box ( + id number(19) generated by default as identity not null, + name varchar2(255), + version number(19) not null, + constraint pk_mail_box primary key (id) +); + +create table mail_user ( + id number(19) generated by default as identity not null, + name varchar2(255), + version number(19) not null, + constraint pk_mail_user primary key (id) +); + +create table mail_user_inbox ( + mail_user_id number(19) not null, + mail_box_id number(19) not null, + constraint pk_mail_user_inbox primary key (mail_user_id,mail_box_id) +); + +create table mail_user_outbox ( + mail_user_id number(19) not null, + mail_box_id number(19) not null, + constraint pk_mail_user_outbox primary key (mail_user_id,mail_box_id) +); + +create table main_entity ( + id varchar2(255) not null, + attr1 varchar2(255), + attr2 varchar2(255), + constraint pk_main_entity primary key (id) +); + +create table main_entity_relation ( + id varchar2(40) not null, + id1 varchar2(255), + id2 varchar2(255), + attr1 varchar2(255), + constraint pk_main_entity_relation primary key (id) +); + +create table map_super_actual ( + id number(19) generated by default as identity not null, + name varchar2(255), + when_created timestamp not null, + when_updated timestamp not null, + constraint pk_map_super_actual primary key (id) +); + +create table c_message ( + id number(19) generated by default as identity not null, + title varchar2(255), + body varchar2(255), + conversation_id number(19), + user_id number(19), + version number(19) not null, + when_created timestamp not null, + when_modified timestamp not null, + constraint pk_c_message primary key (id) +); + +create table meter_address_data ( + id varchar2(40) not null, + street varchar2(255) not null, + constraint pk_meter_address_data primary key (id) +); + +create table meter_contract_data ( + id varchar2(40) not null, + special_needs_client_id varchar2(40) not null, + constraint uq_mtr_cntrct_dt_spcl_nds_c_1 unique (special_needs_client_id), + constraint pk_meter_contract_data primary key (id) +); + +create table meter_special_needs_client ( + id varchar2(40) not null, + name varchar2(255), + primary_id varchar2(40), + constraint uq_mtr_spcl_nds_clnt_prmry_d unique (primary_id), + constraint pk_meter_special_needs_client primary key (id) +); + +create table meter_special_needs_contact ( + id varchar2(40) not null, + name varchar2(255), + constraint pk_mtr_spcl_nds_cntct primary key (id) +); + +create table meter_version ( + id varchar2(40) not null, + address_data_id varchar2(40), + contract_data_id varchar2(40) not null, + constraint uq_mtr_vrsn_ddrss_dt_d unique (address_data_id), + constraint uq_mtr_vrsn_cntrct_dt_d unique (contract_data_id), + constraint pk_meter_version primary key (id) +); + +create table mnoc_role ( + role_id number(10) generated by default as identity not null, + role_name varchar2(255), + version number(10) not null, + constraint pk_mnoc_role primary key (role_id) +); + +create table mnoc_user ( + user_id number(10) generated by default as identity not null, + user_name varchar2(255), + version number(10) not null, + constraint pk_mnoc_user primary key (user_id) +); + +create table mnoc_user_mnoc_role ( + mnoc_user_user_id number(10) not null, + mnoc_role_role_id number(10) not null, + constraint pk_mnoc_user_mnoc_role primary key (mnoc_user_user_id,mnoc_role_role_id) +); + +create table mny_a ( + id number(19) generated by default as identity not null, + name varchar2(255), + version number(19) not null, + when_created timestamp not null, + when_modified timestamp not null, + constraint pk_mny_a primary key (id) +); + +create table mny_b ( + id number(19) generated by default as identity not null, + name varchar2(255), + a_id number(19), + version number(19) not null, + when_created timestamp not null, + when_modified timestamp not null, + constraint pk_mny_b primary key (id) +); + +create table mny_b_mny_c ( + mny_b_id number(19) not null, + mny_c_id number(19) not null, + constraint pk_mny_b_mny_c primary key (mny_b_id,mny_c_id) +); + +create table mny_c ( + id number(19) generated by default as identity not null, + name varchar2(255), + version number(19) not null, + when_created timestamp not null, + when_modified timestamp not null, + constraint pk_mny_c primary key (id) +); + +create table mny_topic ( + id number(19) generated by default as identity not null, + name varchar2(255), + version number(19) not null, + constraint pk_mny_topic primary key (id) +); + +create table subtopics ( + topic number(19) not null, + subtopic number(19) not null, + constraint pk_subtopics primary key (topic,subtopic) +); + +create table mp_role ( + id number(19) generated by default as identity not null, + mp_user_id number(19) not null, + code varchar2(255), + organization_id number(19), + constraint pk_mp_role primary key (id) +); + +create table mp_user ( + id number(19) generated by default as identity not null, + name varchar2(255), + constraint pk_mp_user primary key (id) +); + +create table ms_many_a ( + aid number(19) generated by default as identity not null, + name varchar2(255), + ms_many_a_many_b number(1) default 0 not null, + ms_many_b number(1) default 0 not null, + deleted number(1) default 0 not null, + constraint pk_ms_many_a primary key (aid) +); + +create table ms_many_a_many_b ( + ms_many_a_aid number(19) not null, + ms_many_b_bid number(19) not null, + constraint pk_ms_many_a_many_b primary key (ms_many_a_aid,ms_many_b_bid) +); + +create table ms_many_b ( + bid number(19) generated by default as identity not null, + name varchar2(255), + deleted number(1) default 0 not null, + constraint pk_ms_many_b primary key (bid) +); + +create table ms_many_b_many_a ( + ms_many_b_bid number(19) not null, + ms_many_a_aid number(19) not null, + constraint pk_ms_many_b_many_a primary key (ms_many_b_bid,ms_many_a_aid) +); + +create table my_lob_size ( + id number(10) generated by default as identity not null, + name varchar2(255), + my_count number(10) not null, + my_lob clob, + constraint pk_my_lob_size primary key (id) +); + +create table my_lob_size_join_many ( + id number(10) generated by default as identity not null, + something varchar2(255), + other varchar2(255), + parent_id number(10), + constraint pk_my_lob_size_join_many primary key (id) +); + +create table noidbean ( + name varchar2(255), + subject varchar2(255), + when_created timestamp not null +); + +create table o_bean_child ( + id number(19) generated by default as identity not null, + cached_bean_id number(19), + constraint pk_o_bean_child primary key (id) +); + +create table ocached_app ( + id number(19) generated by default as identity not null, + app_name varchar2(255), + version number(19) not null, + constraint uq_ocached_app_app_name unique (app_name), + constraint pk_ocached_app primary key (id) +); + +create table ocached_app_detail ( + id number(19) generated by default as identity not null, + app_id number(19) not null, + detail varchar2(255), + version number(19) not null, + constraint uq_occhd_pp_dtl_pp_d_dtl unique (app_id,detail), + constraint pk_ocached_app_detail primary key (id) +); + +create table o_cached_bean ( + id number(19) generated by default as identity not null, + name varchar2(255), + constraint pk_o_cached_bean primary key (id) +); + +create table o_cached_bean_country ( + o_cached_bean_id number(19) not null, + o_country_code varchar2(2) not null, + constraint pk_o_cached_bean_country primary key (o_cached_bean_id,o_country_code) +); + +create table o_cached_bean_child ( + id number(19) generated by default as identity not null, + cached_bean_id number(19), + constraint pk_o_cached_bean_child primary key (id) +); + +create table o_cached_inherit ( + dtype varchar2(31) not null, + id number(19) generated by default as identity not null, + name varchar2(255), + child_adata varchar2(255), + child_bdata varchar2(255), + constraint pk_o_cached_inherit primary key (id) +); + +create table o_cached_natkey ( + id number(19) generated by default as identity not null, + store varchar2(255), + sku varchar2(255), + description varchar2(255), + constraint pk_o_cached_natkey primary key (id) +); + +create table o_cached_natkey3 ( + id number(19) generated by default as identity not null, + store varchar2(255), + code number(10) not null, + sku varchar2(255), + description varchar2(255), + constraint pk_o_cached_natkey3 primary key (id) +); + +create table ocached_nkey_uid ( + id number(19) generated by default as identity not null, + cid varchar2(40), + other varchar2(255), + version number(19) not null, + constraint pk_ocached_nkey_uid primary key (id) +); + +create table ocar ( + id number(10) generated by default as identity not null, + vin varchar2(255), + name varchar2(255), + cretime timestamp not null, + updtime timestamp not null, + version number(19) not null, + constraint pk_ocar primary key (id) +); + +create table ocompany ( + id number(10) generated by default as identity not null, + corp_id varchar2(50), + cretime timestamp not null, + updtime timestamp not null, + version number(19) not null, + constraint uq_ocompany_corp_id unique (corp_id), + constraint pk_ocompany primary key (id) +); + +create table oengine ( + engine_id varchar2(40) not null, + short_desc varchar2(255), + car_id number(10), + version number(10) not null, + constraint uq_oengine_car_id unique (car_id), + constraint pk_oengine primary key (engine_id) +); + +create table ogear_box ( + id varchar2(40) not null, + box_desc varchar2(255), + box_size number(10), + car_id number(10), + version number(10) not null, + constraint uq_ogear_box_car_id unique (car_id), + constraint pk_ogear_box primary key (id) +); + +create table omvertex ( + id varchar2(40) not null, + constraint pk_omvertex primary key (id) +); + +create table omvertex_other ( + id varchar2(40) not null, + omvertex_id varchar2(40) not null, + name varchar2(255), + constraint pk_omvertex_other primary key (id) +); + +create table oroad_show_msg ( + id number(10) generated by default as identity not null, + company_id number(10) not null, + cretime timestamp not null, + updtime timestamp not null, + version number(19) not null, + constraint uq_oroad_show_msg_company_id unique (company_id), + constraint pk_oroad_show_msg primary key (id) +); + +create table om_account_child_dbo ( + id number(19) generated by default as identity not null, + description varchar2(255), + banana_rama_id number(19), + constraint pk_om_account_child_dbo primary key (id) +); + +create table om_account_dbo ( + id number(19) generated by default as identity not null, + name varchar2(255), + constraint pk_om_account_dbo primary key (id) +); + +create table om_basic_child ( + id number(19) generated by default as identity not null, + name varchar2(255), + parent_id number(19), + version number(19) not null, + constraint pk_om_basic_child primary key (id) +); + +create table om_basic_parent ( + id number(19) generated by default as identity not null, + name varchar2(255), + version number(19) not null, + constraint pk_om_basic_parent primary key (id) +); + +create table om_ordered_detail ( + id number(19) generated by default as identity not null, + name varchar2(255), + master_id number(19), + version number(19) not null, + sort_order number(10), + constraint pk_om_ordered_detail primary key (id) +); + +create table om_ordered_master ( + id number(19) generated by default as identity not null, + name varchar2(255), + version number(19) not null, + constraint pk_om_ordered_master primary key (id) +); + +create table only_id_entity ( + id number(19) generated by default as identity not null, + constraint pk_only_id_entity primary key (id) +); + +create table o_order ( + id number(10) generated by default as identity not null, + status number(10), + order_date date, + ship_date date, + kcustomer_id number(10) not null, + cretime timestamp not null, + updtime timestamp not null, + constraint ck_o_order_status check ( status in (0,1,2,3)), + constraint pk_o_order primary key (id) +); + +create table o_order_detail ( + id number(10) generated by default as identity not null, + order_id number(10) not null, + order_qty number(10), + ship_qty number(10), + unit_price number(19,4), + product_id number(10), + cretime timestamp, + updtime timestamp not null, + constraint pk_o_order_detail primary key (id) +); + +create table s_orders ( + uuid varchar2(40) not null, + constraint pk_s_orders primary key (uuid) +); + +create table s_order_items ( + uuid varchar2(40) not null, + product_variant_uuid varchar2(255), + order_uuid varchar2(40), + quantity number(10) not null, + amount number(16,3), + constraint pk_s_order_items primary key (uuid) +); + +create table or_order_ship ( + id number(10) generated by default as identity not null, + order_id number(10), + ship_time timestamp, + cretime timestamp not null, + updtime timestamp not null, + version number(19) not null, + constraint pk_or_order_ship primary key (id) +); + +create table organisation ( + id number(19) generated by default as identity not null, + name varchar2(255), + version number(19) not null, + when_created timestamp not null, + when_modified timestamp not null, + constraint pk_organisation primary key (id) +); + +create table organization_node ( + kind varchar2(31) not null, + id number(19) generated by default as identity not null, + parent_tree_node_id number(19) not null, + title varchar2(255), + constraint uq_orgnztn_nd_prnt_tr_nd_d unique (parent_tree_node_id), + constraint pk_organization_node primary key (id) +); + +create table organization_tree_node ( + id number(19) generated by default as identity not null, + name varchar2(255), + constraint pk_organization_tree_node primary key (id) +); + +create table orp_detail ( + id varchar2(100) not null, + detail varchar2(255), + master_id varchar2(100), + version number(19) not null, + constraint pk_orp_detail primary key (id) +); + +create table orp_detail2 ( + id varchar2(100) not null, + orp_master2_id varchar2(100) not null, + detail varchar2(255), + master_id varchar2(255), + version number(19) not null, + constraint pk_orp_detail2 primary key (id) +); + +create table orp_master ( + id varchar2(100) not null, + name varchar2(255), + version number(19) not null, + constraint pk_orp_master primary key (id) +); + +create table orp_master2 ( + id varchar2(100) not null, + name varchar2(255), + version number(19) not null, + constraint pk_orp_master2 primary key (id) +); + +create table oto_aone ( + id varchar2(100) not null, + description varchar2(255), + constraint pk_oto_aone primary key (id) +); + +create table oto_atwo ( + id varchar2(100) not null, + description varchar2(255), + aone_id varchar2(100), + constraint uq_oto_atwo_aone_id unique (aone_id), + constraint pk_oto_atwo primary key (id) +); + +create table oto_bchild ( + master_id number(19) generated by default as identity not null, + child varchar2(255), + constraint pk_oto_bchild primary key (master_id) +); + +create table oto_bmaster ( + id number(19) generated by default as identity not null, + name varchar2(255), + constraint pk_oto_bmaster primary key (id) +); + +create table oto_child ( + id number(10) generated by default as identity not null, + name varchar2(255), + master_id number(19), + constraint uq_oto_child_master_id unique (master_id), + constraint pk_oto_child primary key (id) +); + +create table oto_cust ( + cid number(19) generated by default as identity not null, + name varchar2(255), + version number(19) not null, + constraint pk_oto_cust primary key (cid) +); + +create table oto_cust_address ( + aid number(19) generated by default as identity not null, + line1 varchar2(255), + line2 varchar2(255), + line3 varchar2(255), + customer_cid number(19), + version number(19) not null, + constraint uq_ot_cst_ddrss_cstmr_cd unique (customer_cid), + constraint pk_oto_cust_address primary key (aid) +); + +create table oto_level_a ( + id number(19) generated by default as identity not null, + name varchar2(255), + b_id number(19), + constraint uq_oto_level_a_b_id unique (b_id), + constraint pk_oto_level_a primary key (id) +); + +create table oto_level_b ( + id number(19) generated by default as identity not null, + name varchar2(255), + c_id number(19), + constraint uq_oto_level_b_c_id unique (c_id), + constraint pk_oto_level_b primary key (id) +); + +create table oto_level_c ( + id number(19) generated by default as identity not null, + name varchar2(255), + constraint pk_oto_level_c primary key (id) +); + +create table oto_master ( + id number(19) generated by default as identity not null, + name varchar2(255), + constraint pk_oto_master primary key (id) +); + +create table oto_prime ( + pid number(19) generated by default as identity not null, + name varchar2(255), + version number(19) not null, + constraint pk_oto_prime primary key (pid) +); + +create table oto_prime_extra ( + eid number(19) generated by default as identity not null, + extra varchar2(255), + version number(19) not null, + constraint pk_oto_prime_extra primary key (eid) +); + +create table oto_sd_child ( + id number(19) generated by default as identity not null, + child varchar2(255), + master_id number(19), + deleted number(1) default 0 not null, + version number(19) not null, + constraint uq_oto_sd_child_master_id unique (master_id), + constraint pk_oto_sd_child primary key (id) +); + +create table oto_sd_master ( + id number(19) generated by default as identity not null, + name varchar2(255), + version number(19) not null, + constraint pk_oto_sd_master primary key (id) +); + +create table oto_th_many ( + id number(19) generated by default as identity not null, + oto_th_top_id number(19) not null, + many varchar2(255), + version number(19) not null, + when_created timestamp not null, + when_modified timestamp not null, + constraint pk_oto_th_many primary key (id) +); + +create table oto_th_one ( + id number(19) generated by default as identity not null, + one number(1) default 0 not null, + many_id number(19), + version number(19) not null, + when_created timestamp not null, + when_modified timestamp not null, + constraint uq_oto_th_one_many_id unique (many_id), + constraint pk_oto_th_one primary key (id) +); + +create table oto_th_top ( + id number(19) generated by default as identity not null, + topp varchar2(255), + version number(19) not null, + when_created timestamp not null, + when_modified timestamp not null, + constraint pk_oto_th_top primary key (id) +); + +create table oto_ubprime ( + pid varchar2(40) not null, + name varchar2(255), + version number(19) not null, + constraint pk_oto_ubprime primary key (pid) +); + +create table oto_ubprime_extra ( + eid varchar2(40) not null, + extra varchar2(255), + version number(19) not null, + constraint pk_oto_ubprime_extra primary key (eid) +); + +create table oto_uprime ( + pid varchar2(40) not null, + name varchar2(255), + version number(19) not null, + constraint pk_oto_uprime primary key (pid) +); + +create table oto_uprime_extra ( + eid varchar2(40) not null, + extra varchar2(255), + version number(19) not null, + constraint pk_oto_uprime_extra primary key (eid) +); + +create table oto_user_model ( + id number(19) generated by default as identity not null, + name varchar2(255), + user_optional_id number(19), + version number(19) not null, + when_created timestamp not null, + when_modified timestamp not null, + constraint uq_ot_sr_mdl_sr_ptnl_d unique (user_optional_id), + constraint pk_oto_user_model primary key (id) +); + +create table oto_user_model_optional ( + id number(19) generated by default as identity not null, + optional varchar2(255), + version number(19) not null, + when_created timestamp not null, + when_modified timestamp not null, + constraint pk_oto_user_model_optional primary key (id) +); + +create table pfile ( + id number(10) generated by default as identity not null, + name varchar2(255), + file_content_id number(10), + file_content2_id number(10), + cretime timestamp not null, + updtime timestamp not null, + version number(19) not null, + constraint uq_pfile_file_content_id unique (file_content_id), + constraint uq_pfile_file_content2_id unique (file_content2_id), + constraint pk_pfile primary key (id) +); + +create table pfile_content ( + id number(10) generated by default as identity not null, + content blob, + cretime timestamp not null, + updtime timestamp not null, + version number(19) not null, + constraint pk_pfile_content primary key (id) +); + +create table paggview ( + pview_id varchar2(40), + amount number(10) not null, + constraint uq_paggview_pview_id unique (pview_id) +); + +create table pallet_location ( + type varchar2(31) not null, + id number(10) generated by default as identity not null, + zone_sid number(10) not null, + attribute varchar2(255), + constraint pk_pallet_location primary key (id) +); + +create table parcel ( + parcelid number(19) generated by default as identity not null, + description varchar2(255), + constraint pk_parcel primary key (parcelid) +); + +create table parcel_location ( + parcellocid number(19) generated by default as identity not null, + location varchar2(255), + parcelid number(19), + constraint uq_parcel_location_parcelid unique (parcelid), + constraint pk_parcel_location primary key (parcellocid) +); + +create table rawinherit_parent ( + type varchar2(31) not null, + id number(19) generated by default as identity not null, + val number(10), + more varchar2(255), + constraint pk_rawinherit_parent primary key (id) +); + +create table rawinherit_parent_rawinherit_d ( + rawinherit_parent_id number(19) not null, + rawinherit_data_id number(19) not null, + constraint pk_rwnhrt_prnt_rwnhrt_d primary key (rawinherit_parent_id,rawinherit_data_id) +); + +create table e_save_test_c ( + id number(19) generated by default as identity not null, + version number(19) not null, + constraint pk_e_save_test_c primary key (id) +); + +create table parent_person ( + identifier number(10) generated by default as identity not null, + name varchar2(255), + age number(10), + some_bean_id number(10), + parent_identifier number(10), + family_name varchar2(255), + address varchar2(255), + constraint pk_parent_person primary key (identifier) +); + +create table c_participation ( + id number(19) generated by default as identity not null, + rating number(10), + type number(10), + conversation_id number(19) not null, + user_id number(19) not null, + version number(19) not null, + when_created timestamp not null, + when_modified timestamp not null, + constraint ck_c_participation_type check ( type in (0,1)), + constraint pk_c_participation primary key (id) +); + +create table password_store_model ( + id number(19) generated by default as identity not null, + enc1 varchar2(30), + enc2 varchar2(40), + enc3 clob, + enc4 raw(30), + enc5 raw(40), + enc6 blob, + version number(19) not null, + when_created timestamp not null, + when_modified timestamp not null, + constraint pk_password_store_model primary key (id) +); + +create table pcf_calendar ( + id number(19) generated by default as identity not null, + pcf_person_id number(19) not null, + version number(19) not null, + constraint pk_pcf_calendar primary key (id) +); + +create table pcf_city ( + id number(19) generated by default as identity not null, + pcf_country_id number(19) not null, + name varchar2(255), + mayor_id number(19) not null, + vice_mayor_id number(19) not null, + version number(19) not null, + constraint uq_pcf_city_mayor_id unique (mayor_id), + constraint uq_pcf_city_vice_mayor_id unique (vice_mayor_id), + constraint pk_pcf_city primary key (id) +); + +create table pcf_country ( + id number(19) generated by default as identity not null, + version number(19) not null, + constraint pk_pcf_country primary key (id) +); + +create table pcf_event ( + id number(19) generated by default as identity not null, + pcf_calendar_id number(19) not null, + name varchar2(255), + version number(19) not null, + constraint pk_pcf_event primary key (id) +); + +create table pcf_person ( + id number(19) generated by default as identity not null, + name varchar2(255), + version number(19) not null, + constraint pk_pcf_person primary key (id) +); + +create table mt_permission ( + id varchar2(40) not null, + name varchar2(255), + constraint pk_mt_permission primary key (id) +); + +create table persistent_file ( + id number(10) generated by default as identity not null, + name varchar2(255), + cretime timestamp not null, + updtime timestamp not null, + version number(19) not null, + constraint pk_persistent_file primary key (id) +); + +create table persistent_file_content ( + id number(10) generated by default as identity not null, + persistent_file_id number(10), + content blob, + cretime timestamp not null, + updtime timestamp not null, + version number(19) not null, + constraint uq_prsstnt_fl_cntnt_prsstnt_1 unique (persistent_file_id), + constraint pk_persistent_file_content primary key (id) +); + +create table person ( + oid number(19) generated by default as identity not null, + default_address_oid number(19), + version number(10) not null, + constraint pk_person primary key (oid) +); + +create table persons ( + id number(19) generated by default as identity (start with 1000 increment by 40) not null, + surname varchar2(64) not null, + name varchar2(64) not null, + constraint pk_persons primary key (id) +); + +create table person_cache_email ( + id varchar2(128) not null, + person_info_person_id varchar2(128), + email varchar2(255), + constraint pk_person_cache_email primary key (id) +); + +create table person_cache_info ( + person_id varchar2(128) not null, + name varchar2(255), + constraint pk_person_cache_info primary key (person_id) +); + +create table phones ( + id number(19) generated by default as identity not null, + phone_number varchar2(7) not null, + person_id number(19) not null, + constraint uq_phones_phone_number unique (phone_number), + constraint pk_phones primary key (id) +); + +create table e_position ( + id number(19) generated by default as identity not null, + name varchar2(255), + contract_id number(19) not null, + constraint pk_e_position primary key (id) +); + +create table primary_revision ( + id number(19) not null, + revision number(10) not null, + name varchar2(255), + version number(19) not null, + constraint pk_primary_revision primary key (id,revision) +); + +create table o_product ( + id number(10) generated by default as identity not null, + sku varchar2(20), + name varchar2(255), + cretime timestamp not null, + updtime timestamp not null, + constraint pk_o_product primary key (id) +); + +create table pp ( + id varchar2(40) not null, + name varchar2(255), + value varchar2(100) not null, + constraint pk_pp primary key (id) +); + +create table pp_to_ww ( + pp_id varchar2(40) not null, + ww_id varchar2(40) not null, + constraint pk_pp_to_ww primary key (pp_id,ww_id) +); + +create table question ( + id number(19) generated by default as identity not null, + name varchar2(255), + groupobjectid number(19), + sequence_number number(10) not null, + constraint pk_question primary key (id) +); + +create table rcustomer ( + company varchar2(127) not null, + name varchar2(127) not null, + description varchar2(255), + constraint pk_rcustomer primary key (company,name) +); + +create table r_orders ( + company varchar2(127) not null, + order_number number(10) not null, + customername varchar2(127), + item varchar2(255), + constraint pk_r_orders primary key (company,order_number) +); + +create table referencing_bean ( + id varchar2(40) not null, + constraint pk_referencing_bean primary key (id) +); + +create table region ( + customer number(10) not null, + type number(10) not null, + description varchar2(255), + version number(19) not null, + constraint pk_region primary key (customer,type) +); + +create table rel_detail ( + id number(19) generated by default as identity not null, + name varchar2(255), + version number(10) not null, + constraint pk_rel_detail primary key (id) +); + +create table rel_master ( + id number(19) generated by default as identity not null, + name varchar2(255), + detail_id number(19), + version number(10) not null, + constraint pk_rel_master primary key (id) +); + +create table resourcefile ( + id varchar2(64) not null, + parentresourcefileid varchar2(64), + name varchar2(128) not null, + constraint pk_resourcefile primary key (id) +); + +create table mt_role ( + id varchar2(40) not null, + name varchar2(50), + tenant_id varchar2(40), + version number(19) not null, + constraint pk_mt_role primary key (id) +); + +create table mt_role_permission ( + mt_role_id varchar2(40) not null, + mt_permission_id varchar2(40) not null, + constraint pk_mt_role_permission primary key (mt_role_id,mt_permission_id) +); + +create table em_role ( + id number(19) generated by default as identity not null, + name varchar2(255), + constraint pk_em_role primary key (id) +); + +create table root_bean ( + dtype varchar2(31) not null, + id varchar2(40) not null, + referencing_bean_id varchar2(40) not null, + value varchar2(255), + constraint pk_root_bean primary key (id) +); + +create table f_second ( + id number(19) generated by default as identity not null, + mod_name varchar2(255), + first number(19), + title varchar2(255), + constraint uq_f_second_first unique (first), + constraint pk_f_second primary key (id) +); + +create table section ( + id number(10) generated by default as identity not null, + article_id number(10), + type number(10), + content clob, + cretime timestamp not null, + updtime timestamp not null, + version number(19) not null, + constraint ck_section_type check ( type in (0,1)), + constraint pk_section primary key (id) +); + +create table self_parent ( + id number(19) generated by default as identity not null, + name varchar2(255), + parent_id number(19), + version number(19) not null, + constraint pk_self_parent primary key (id) +); + +create table self_ref_customer ( + id number(19) generated by default as identity not null, + name varchar2(255), + referred_by_id number(19), + constraint pk_self_ref_customer primary key (id) +); + +create table self_ref_example ( + id number(19) generated by default as identity not null, + name varchar2(255) not null, + parent_id number(19), + constraint pk_self_ref_example primary key (id) +); + +create table e_save_test_a ( + id number(19) generated by default as identity not null, + version number(19) not null, + constraint pk_e_save_test_a primary key (id) +); + +create table e_save_test_b ( + id number(19) generated by default as identity not null, + sibling_a_id number(19), + test_property number(1) default 0 not null, + version number(19) not null, + constraint uq_e_save_test_b_sibling_a_id unique (sibling_a_id), + constraint pk_e_save_test_b primary key (id) +); + +create table site ( + id varchar2(40) not null, + name varchar2(255), + parent_id varchar2(40), + data_container_id varchar2(40), + site_address_id varchar2(40), + constraint uq_site_data_container_id unique (data_container_id), + constraint uq_site_site_address_id unique (site_address_id), + constraint pk_site primary key (id) +); + +create table site_address ( + id varchar2(40) not null, + street varchar2(255), + city varchar2(255), + zip_code varchar2(255), + constraint pk_site_address primary key (id) +); + +create table some_enum_bean ( + id number(19) generated by default as identity not null, + some_enum number(10), + name varchar2(255), + constraint ck_some_enum_bean_some_enum check ( some_enum in (0,1)), + constraint pk_some_enum_bean primary key (id) +); + +create table some_file_bean ( + id number(19) generated by default as identity not null, + name varchar2(255), + content blob, + version number(19) not null, + constraint pk_some_file_bean primary key (id) +); + +create table some_new_types_bean ( + id number(19) generated by default as identity not null, + dow number(1), + mth number(1), + yr number(10), + yr_mth date, + month_day date, + sql_date date, + sql_time timestamp, + local_date date, + local_date_time timestamp, + offset_date_time timestamp, + zoned_date_time timestamp, + local_time timestamp, + instant timestamp, + zone_id varchar2(60), + zone_offset varchar2(60), + path varchar2(255), + period varchar2(20), + duration number(19), + version number(19) not null, + constraint ck_some_new_types_bean_dow check ( dow in (1,2,3,4,5,6,7)), + constraint ck_some_new_types_bean_mth check ( mth in (1,2,3,4,5,6,7,8,9,10,11,12)), + constraint pk_some_new_types_bean primary key (id) +); + +create table some_period_bean ( + id number(19) generated by default as identity not null, + anniversary date, + version number(19) not null, + constraint pk_some_period_bean primary key (id) +); + +create table source_base ( + dtype varchar2(31) not null, + id varchar2(40) not null, + name varchar2(255), + pos number(10) not null, + target_id varchar2(40), + constraint pk_source_base primary key (id) +); + +create table stockforecast ( + type varchar2(31) not null, + id number(19) generated by default as identity not null, + inner_report_id number(19), + constraint pk_stockforecast primary key (id) +); + +create table sub_section ( + id number(10) generated by default as identity not null, + section_id number(10), + title varchar2(255), + cretime timestamp not null, + updtime timestamp not null, + version number(19) not null, + constraint pk_sub_section primary key (id) +); + +create table sub_type ( + sub_type_id number(10) generated by default as identity not null, + description varchar2(255), + version number(19) not null, + constraint pk_sub_type primary key (sub_type_id) +); + +create table survey ( + id number(19) generated by default as identity not null, + name varchar2(255), + constraint pk_survey primary key (id) +); + +create table tbytes_only ( + id number(10) generated by default as identity not null, + content blob, + constraint pk_tbytes_only primary key (id) +); + +create table tcar ( + type varchar2(31) not null, + plate_no varchar2(32) not null, + truckload number(19), + constraint pk_tcar primary key (plate_no) +); + +create table tevent ( + id number(19) generated by default as identity not null, + name varchar2(255), + version number(19) not null, + constraint pk_tevent primary key (id) +); + +create table tevent_many ( + id number(19) generated by default as identity not null, + description varchar2(255), + event_id number(19), + units number(10) not null, + amount number(19,4) not null, + version number(19) not null, + constraint pk_tevent_many primary key (id) +); + +create table tevent_one ( + id number(19) generated by default as identity not null, + name varchar2(255), + status number(10), + event_id number(19), + version number(19) not null, + constraint ck_tevent_one_status check ( status in (0,1)), + constraint uq_tevent_one_event_id unique (event_id), + constraint pk_tevent_one primary key (id) +); + +create table tint_root ( + my_type number(3) not null, + id number(10) generated by default as identity not null, + name varchar2(255), + child_property varchar2(255), + constraint pk_tint_root primary key (id) +); + +create table tjoda_entity ( + id number(10) generated by default as identity not null, + local_time timestamp, + constraint pk_tjoda_entity primary key (id) +); + +create table t_mapsuper1 ( + id number(10) generated by default as identity not null, + something varchar2(255), + name varchar2(255), + version number(10) not null, + constraint pk_t_mapsuper1 primary key (id) +); + +create table t_oneb ( + id number(10) generated by default as identity not null, + name varchar2(255), + description varchar2(255), + active number(1) default 0 not null, + constraint pk_t_oneb primary key (id) +); + +create table t_detail_with_other_namexxxyy ( + id number(10) not null, + name varchar2(255), + description varchar2(255), + some_unique_value varchar2(127), + active number(1) default 0 not null, + master_id number(10), + constraint uq_t_dtl_wth_thr_nmxxxyy_sm_1 unique (some_unique_value), + constraint pk_t_dtl_wth_thr_nmxxxyy primary key (id) +); +create sequence t_atable_detail_seq increment by 1; + +create table t_atable_thatisrelatively ( + id number(10) not null, + name varchar2(255), + description varchar2(255), + active number(1) default 0 not null, + constraint pk_t_atable_thatisrelatively primary key (id) +); +create sequence t_atable_master_seq increment by 1; + +create table ttruck_holder ( + id number(19) generated by default as identity not null, + name varchar2(255), + truck_plate_no varchar2(32) not null, + basic_id number(10), + version number(19) not null, + constraint pk_ttruck_holder primary key (id) +); + +create table ttruck_holder_item ( + id number(19) generated by default as identity not null, + some_uid varchar2(40), + foo varchar2(255), + owner_id number(19) not null, + constraint pk_ttruck_holder_item primary key (id) +); + +create table tuuid_entity ( + id varchar2(40) not null, + name varchar2(255), + constraint pk_tuuid_entity primary key (id) +); + +create table twheel ( + id number(19) generated by default as identity not null, + owner_plate_no varchar2(32) not null, + constraint pk_twheel primary key (id) +); + +create table twith_pre_insert ( + id number(10) generated by default as identity not null, + name varchar2(255) not null, + title varchar2(255), + constraint pk_twith_pre_insert primary key (id) +); + +create table target_base ( + dtype varchar2(31) not null, + id varchar2(40) not null, + name varchar2(255), + constraint pk_target_base primary key (id) +); + +create table mt_tenant ( + id varchar2(40) not null, + name varchar2(255), + version number(19) not null, + constraint pk_mt_tenant primary key (id) +); + +create table test_annotation_base_entity ( + direct varchar2(255), + meta varchar2(255), + mixed varchar2(255), + constraint_annotation varchar2(40), + null1 varchar2(255) not null, + null2 varchar2(255), + null3 varchar2(255) +); + +create table tire ( + id number(19) not null, + wheel number(19), + version number(10) not null, + constraint uq_tire_wheel unique (wheel), + constraint pk_tire primary key (id) +); +create sequence tire_seq increment by 1; + +create table sa_tire ( + id number(19) not null, + version number(10) not null, + constraint pk_sa_tire primary key (id) +); +create sequence sa_tire_seq increment by 1; + +create table tree_entity ( + id number(10) generated by default as identity not null, + text varchar2(255), + parent_id number(10), + constraint pk_tree_entity primary key (id) +); + +create table trip ( + id number(10) generated by default as identity not null, + vehicle_driver_id number(10), + destination varchar2(255), + address_id number(10), + star_date timestamp, + cretime timestamp not null, + updtime timestamp not null, + version number(19) not null, + constraint pk_trip primary key (id) +); + +create table truck_ref ( + id number(10) generated by default as identity not null, + something varchar2(255), + constraint pk_truck_ref primary key (id) +); + +create table tune ( + id number(19) generated by default as identity not null, + name varchar2(255), + constraint pk_tune primary key (id) +); + +create table "type" ( + customer number(10) not null, + type number(10) not null, + description varchar2(255), + sub_type_id number(10), + version number(19) not null, + constraint pk_type primary key (customer,type) +); + +create table tz_bean ( + id number(19) generated by default as identity not null, + moda varchar2(255), + ts timestamp, + tstz timestamp, + constraint pk_tz_bean primary key (id) +); + +create table usib_child ( + id varchar2(40) not null, + parent_id number(19), + deleted number(1) default 0 not null, + constraint pk_usib_child primary key (id) +); + +create table usib_child_sibling ( + id number(19) generated by default as identity not null, + child_id varchar2(40), + deleted number(1) default 0 not null, + constraint uq_usb_chld_sblng_chld_d unique (child_id), + constraint pk_usib_child_sibling primary key (id) +); + +create table usib_parent ( + id number(19) generated by default as identity not null, + deleted number(1) default 0 not null, + constraint pk_usib_parent primary key (id) +); + +create table ut_detail ( + id number(10) generated by default as identity not null, + utmaster_id number(10) not null, + name varchar2(255), + qty number(10), + amount number(19,4), + version number(10) not null, + constraint pk_ut_detail primary key (id) +); + +create table ut_master ( + id number(10) generated by default as identity not null, + name varchar2(255), + description varchar2(255), + event_date date, + version number(10) not null, + constraint pk_ut_master primary key (id) +); + +create table uuone ( + id varchar2(40) not null, + name varchar2(255), + description varchar2(255), + version number(19) not null, + constraint pk_uuone primary key (id) +); + +create table uutwo ( + id varchar2(40) not null, + name varchar2(255), + notes varchar2(255), + master_id varchar2(40), + version number(19) not null, + constraint pk_uutwo primary key (id) +); + +create table oto_user ( + id number(19) generated by default as identity not null, + name varchar2(255), + account_id number(19) not null, + version number(19) not null, + when_created timestamp not null, + when_modified timestamp not null, + constraint uq_oto_user_account_id unique (account_id), + constraint pk_oto_user primary key (id) +); + +create table c_user ( + id number(19) generated by default as identity not null, + inactive number(1) default 0 not null, + name varchar2(255), + email varchar2(255), + password_hash varchar2(255), + group_id number(19), + version number(19) not null, + when_created timestamp not null, + when_modified timestamp not null, + constraint pk_c_user primary key (id) +); + +create table tx_user ( + id number(19) generated by default as identity not null, + name varchar2(255), + constraint pk_tx_user primary key (id) +); + +create table g_user ( + id number(19) generated by default as identity not null, + username varchar2(255), + version number(19) not null, + constraint pk_g_user primary key (id) +); + +create table em_user ( + id number(19) generated by default as identity not null, + name varchar2(255), + constraint pk_em_user primary key (id) +); + +create table user_interest_live ( + user_id number(19) not null, + live_id number(19) not null, + created_at timestamp not null, + constraint pk_user_interest_live primary key (user_id,live_id) +); + +create table em_user_role ( + user_id number(19) not null, + role_id number(19) not null, + constraint pk_em_user_role primary key (user_id,role_id) +); + +create table vehicle ( + dtype varchar2(3) not null, + id number(10) generated by default as identity not null, + license_number varchar2(255), + registration_date timestamp, + lease_id number(19), + cretime timestamp not null, + updtime timestamp not null, + version number(19) not null, + siz varchar2(3), + driver varchar2(255), + car_ref_id number(10), + notes varchar2(255), + truck_ref_id number(10), + capacity number(19,4), + constraint ck_vehicle_siz check ( siz in ('S','M','L','H')), + constraint pk_vehicle primary key (id) +); + +create table vehicle_driver ( + id number(10) generated by default as identity not null, + name varchar2(255), + vehicle_id number(10), + address_id number(10), + license_issued_on timestamp, + cretime timestamp not null, + updtime timestamp not null, + version number(19) not null, + constraint pk_vehicle_driver primary key (id) +); + +create table vehicle_lease ( + dtype varchar2(31) not null, + id number(19) generated by default as identity not null, + name varchar2(255), + active_start date, + active_end date, + version number(19) not null, + bond number(16,3), + min_duration number(10) not null, + day_rate number(16,3), + max_days number(10), + constraint pk_vehicle_lease primary key (id) +); + +create table warehouses ( + id number(10) generated by default as identity not null, + officezoneid number(10), + constraint pk_warehouses primary key (id) +); + +create table warehousesshippingzones ( + warehouseid number(10) not null, + shippingzoneid number(10) not null, + constraint pk_warehousesshippingzones primary key (warehouseid,shippingzoneid) +); + +create table wheel ( + id number(19) not null, + version number(10) not null, + constraint pk_wheel primary key (id) +); +create sequence wheel_seq increment by 1; + +create table sa_wheel ( + id number(19) not null, + tire number(19), + car number(19), + version number(10) not null, + constraint pk_sa_wheel primary key (id) +); +create sequence sa_wheel_seq increment by 1; + +create table sp_car_wheel ( + id number(19) not null, + name varchar2(255), + version number(10) not null, + constraint pk_sp_car_wheel primary key (id) +); +create sequence sp_car_wheel_seq increment by 1; + +create table g_who_props_otm ( + id number(19) generated by default as identity not null, + name varchar2(255), + version number(19) not null, + when_created timestamp not null, + when_modified timestamp not null, + who_created_id number(19), + who_modified_id number(19), + constraint pk_g_who_props_otm primary key (id) +); + +create table with_zero ( + id number(19) generated by default as identity not null, + name varchar2(255), + parent_id number(10), + lang varchar2(2) default 'en' not null, + version number(19) not null, + constraint pk_with_zero primary key (id) +); + +create table parent ( + id number(10) generated by default as identity not null, + name varchar2(255), + constraint pk_parent primary key (id) +); + +create table wview ( + id varchar2(40) not null, + name varchar2(127) not null, + constraint uq_wview_name unique (name), + constraint pk_wview primary key (id) +); + +create table zones ( + type varchar2(31) not null, + id number(10) generated by default as identity not null, + attribute varchar2(255), + constraint pk_zones primary key (id) +); + +create index ix_cntct_lst_nm_frst_nm on contact (last_name,first_name); +create index ix_e_basic_name on e_basic (name); +create index ix_efile2_no_fk_owner_id on efile2_no_fk (owner_id); +create index ix_ecsm_values_host_id on ecsm_values (host_id); +create index ix_organization_node_kind on organization_node (kind); +create index ano_3 on test_annotation_base_entity (direct); +create index ix_bar_foo_id on bar (foo_id); +alter table bar add constraint fk_bar_foo_id foreign key (foo_id) references foo (foo_id); + +create index ix_acl_cntnr_rltn_cntnr_d on acl_container_relation (container_id); +alter table acl_container_relation add constraint fk_acl_cntnr_rltn_cntnr_d foreign key (container_id) references contract (id); + +create index ix_acl_cntnr_rltn_cl_ntry_d on acl_container_relation (acl_entry_id); +alter table acl_container_relation add constraint fk_acl_cntnr_rltn_cl_ntry_d foreign key (acl_entry_id) references acl (id); + +create index ix_addr_employee_id on addr (employee_id); +alter table addr add constraint fk_addr_employee_id foreign key (employee_id) references empl (id); + +create index ix_o_address_country_code on o_address (country_code); +alter table o_address add constraint fk_o_address_country_code foreign key (country_code) references o_country (code); + +alter table album add constraint fk_album_cover_id foreign key (cover_id) references cover (id); + +create index ix_animal_shelter_id on animal (shelter_id); +alter table animal add constraint fk_animal_shelter_id foreign key (shelter_id) references animal_shelter (id); + +create index ix_attrbt_ttrbt_hldr_d on attribute (attribute_holder_id); +alter table attribute add constraint fk_attrbt_ttrbt_hldr_d foreign key (attribute_holder_id) references attribute_holder (id); + +create index ix_bbookmark_user_id on bbookmark (user_id); +alter table bbookmark add constraint fk_bbookmark_user_id foreign key (user_id) references bbookmark_user (id); + +create index ix_bbookmark_user_org_id on bbookmark_user (org_id); +alter table bbookmark_user add constraint fk_bbookmark_user_org_id foreign key (org_id) references bbookmark_org (id); + +create index ix_bsite_user_a_site_id on bsite_user_a (site_id); +alter table bsite_user_a add constraint fk_bsite_user_a_site_id foreign key (site_id) references bsite (id); + +create index ix_bsite_user_a_user_id on bsite_user_a (user_id); +alter table bsite_user_a add constraint fk_bsite_user_a_user_id foreign key (user_id) references buser (id); + +create index ix_bsite_user_b_site on bsite_user_b (site); +alter table bsite_user_b add constraint fk_bsite_user_b_site foreign key (site) references bsite (id); + +create index ix_bsite_user_b_usr on bsite_user_b (usr); +alter table bsite_user_b add constraint fk_bsite_user_b_usr foreign key (usr) references buser (id); + +create index ix_bsite_user_c_site_uid on bsite_user_c (site_uid); +alter table bsite_user_c add constraint fk_bsite_user_c_site_uid foreign key (site_uid) references bsite (id); + +create index ix_bsite_user_c_user_uid on bsite_user_c (user_uid); +alter table bsite_user_c add constraint fk_bsite_user_c_user_uid foreign key (user_uid) references buser (id); + +create index ix_bsite_user_e_site_id on bsite_user_e (site_id); +alter table bsite_user_e add constraint fk_bsite_user_e_site_id foreign key (site_id) references bsite (id); + +create index ix_bsite_user_e_user_id on bsite_user_e (user_id); +alter table bsite_user_e add constraint fk_bsite_user_e_user_id foreign key (user_id) references buser (id); + +alter table basic_draftable_bean add constraint fk_basic_draftable_bean_id foreign key (id) references basic_draftable_bean_draft (id); + +alter table drel_booking add constraint fk_drel_booking_agent_invoice foreign key (agent_invoice) references drel_invoice (id); + +alter table drel_booking add constraint fk_drl_bkng_clnt_nvc foreign key (client_invoice) references drel_invoice (id); + +create index ix_cpprdct_ctgry_ctgry_d on cepproduct_category (category_id); +alter table cepproduct_category add constraint fk_cpprdct_ctgry_ctgry_d foreign key (category_id) references cepcategory (id); + +create index ix_cpprdct_ctgry_prdct_d on cepproduct_category (product_id); +alter table cepproduct_category add constraint fk_cpprdct_ctgry_prdct_d foreign key (product_id) references cepproduct (id); + +create index ix_ciaddress_street_id on ciaddress (street_id); +alter table ciaddress add constraint fk_ciaddress_street_id foreign key (street_id) references cistreet_parent (id); + +create index ix_ccstmr_prnt_ddrss_d on cicustomer_parent (address_id); +alter table cicustomer_parent add constraint fk_ccstmr_prnt_ddrss_d foreign key (address_id) references ciaddress (id); + +create index ix_cinh_ref_ref_id on cinh_ref (ref_id); +alter table cinh_ref add constraint fk_cinh_ref_ref_id foreign key (ref_id) references cinh_root (id); + +create index ix_ckey_detail_parent on ckey_detail (one_key,two_key); +alter table ckey_detail add constraint fk_ckey_detail_parent foreign key (one_key,two_key) references ckey_parent (one_key,two_key); + +create index ix_ckey_parent_assoc_id on ckey_parent (assoc_id); +alter table ckey_parent add constraint fk_ckey_parent_assoc_id foreign key (assoc_id) references ckey_assoc (id); + +create index ix_coone_many_coone_id on coone_many (coone_id); +alter table coone_many add constraint fk_coone_many_coone_id foreign key (coone_id) references coone (id); + +alter table coroot add constraint fk_coroot_one_id foreign key (one_id) references coone (id); + +create index ix_clcltn_rslt_prdct_cnfgrt_1 on calculation_result (product_configuration_id); +alter table calculation_result add constraint fk_clcltn_rslt_prdct_cnfgrt_1 foreign key (product_configuration_id) references configuration (id); + +create index ix_clcltn_rslt_grp_cnfgrtn_d on calculation_result (group_configuration_id); +alter table calculation_result add constraint fk_clcltn_rslt_grp_cnfgrtn_d foreign key (group_configuration_id) references configuration (id); + +create index ix_sp_cr_cr_whls_sp_cr_cr on sp_car_car_wheels (car); +alter table sp_car_car_wheels add constraint fk_sp_cr_cr_whls_sp_cr_cr foreign key (car) references sp_car_car (id); + +create index ix_sp_cr_cr_whls_sp_cr_whl on sp_car_car_wheels (wheel); +alter table sp_car_car_wheels add constraint fk_sp_cr_cr_whls_sp_cr_whl foreign key (wheel) references sp_car_wheel (id); + +create index ix_sp_cr_cr_drs_sp_cr_cr on sp_car_car_doors (car); +alter table sp_car_car_doors add constraint fk_sp_cr_cr_drs_sp_cr_cr foreign key (car) references sp_car_car (id); + +create index ix_sp_cr_cr_drs_sp_cr_dr on sp_car_car_doors (door); +alter table sp_car_car_doors add constraint fk_sp_cr_cr_drs_sp_cr_dr foreign key (door) references sp_car_door (id); + +create index ix_car_accessory_fuse_id on car_accessory (fuse_id); +alter table car_accessory add constraint fk_car_accessory_fuse_id foreign key (fuse_id) references car_fuse (id); + +create index ix_car_accessory_car_id on car_accessory (car_id); +alter table car_accessory add constraint fk_car_accessory_car_id foreign key (car_id) references vehicle (id); + +create index ix_category_surveyobjectid on category (surveyobjectid); +alter table category add constraint fk_category_surveyobjectid foreign key (surveyobjectid) references survey (id); + +alter table e_save_test_d add constraint fk_e_save_test_d_parent_id foreign key (parent_id) references e_save_test_c (id); + +create index ix_child_person_some_bean_id on child_person (some_bean_id); +alter table child_person add constraint fk_child_person_some_bean_id foreign key (some_bean_id) references e_basic (id); + +create index ix_chld_prsn_prnt_dntfr on child_person (parent_identifier); +alter table child_person add constraint fk_chld_prsn_prnt_dntfr foreign key (parent_identifier) references parent_person (identifier); + +create index ix_cke_client_user on cke_client (username,cod_cpny); +alter table cke_client add constraint fk_cke_client_user foreign key (username,cod_cpny) references cke_user (username,cod_cpny); + +alter table class_super_monkey add constraint fk_clss_spr_mnky_clss_spr foreign key (class_super_sid) references class_super (sid); + +alter table class_super_monkey add constraint fk_class_super_monkey_monkey foreign key (monkey_mid) references monkey (mid); + +create index ix_cnfgrtn_cnfgrtns_d on configuration (configurations_id); +alter table configuration add constraint fk_cnfgrtn_cnfgrtns_d foreign key (configurations_id) references configurations (id); + +create index ix_contact_customer_id on contact (customer_id); +alter table contact add constraint fk_contact_customer_id foreign key (customer_id) references o_customer (id); + +create index ix_contact_group_id on contact (group_id); +alter table contact add constraint fk_contact_group_id foreign key (group_id) references contact_group (id); + +create index ix_contact_note_contact_id on contact_note (contact_id); +alter table contact_note add constraint fk_contact_note_contact_id foreign key (contact_id) references contact (id); + +create index ix_contract_costs_position_id on contract_costs (position_id); +alter table contract_costs add constraint fk_contract_costs_position_id foreign key (position_id) references e_position (id); + +create index ix_c_conversation_group_id on c_conversation (group_id); +alter table c_conversation add constraint fk_c_conversation_group_id foreign key (group_id) references c_group (id); + +create index ix_o_cstmr_bllng_ddrss_d on o_customer (billing_address_id); +alter table o_customer add constraint fk_o_cstmr_bllng_ddrss_d foreign key (billing_address_id) references o_address (id); + +create index ix_o_cstmr_shppng_ddrss_d on o_customer (shipping_address_id); +alter table o_customer add constraint fk_o_cstmr_shppng_ddrss_d foreign key (shipping_address_id) references o_address (id); + +create index ix_dcredit_drol_dcredit on dcredit_drol (dcredit_id); +alter table dcredit_drol add constraint fk_dcredit_drol_dcredit foreign key (dcredit_id) references dcredit (id); + +create index ix_dcredit_drol_drol on dcredit_drol (drol_id); +alter table dcredit_drol add constraint fk_dcredit_drol_drol foreign key (drol_id) references drol (id); + +create index ix_dmachine_organisation_id on dmachine (organisation_id); +alter table dmachine add constraint fk_dmachine_organisation_id foreign key (organisation_id) references dorg (id); + +create index ix_d_mchn_x_s_mchn_d on d_machine_aux_use (machine_id); +alter table d_machine_aux_use add constraint fk_d_mchn_x_s_mchn_d foreign key (machine_id) references dmachine (id); + +create index ix_d_machine_stats_machine_id on d_machine_stats (machine_id); +alter table d_machine_stats add constraint fk_d_machine_stats_machine_id foreign key (machine_id) references dmachine (id); + +create index ix_d_machine_use_machine_id on d_machine_use (machine_id); +alter table d_machine_use add constraint fk_d_machine_use_machine_id foreign key (machine_id) references dmachine (id); + +create index ix_drot_drol_drot on drot_drol (drot_id); +alter table drot_drol add constraint fk_drot_drol_drot foreign key (drot_id) references drot (id); + +create index ix_drot_drol_drol on drot_drol (drol_id); +alter table drot_drol add constraint fk_drot_drol_drol foreign key (drol_id) references drol (id); + +create index ix_dc_detail_master_id on dc_detail (master_id); +alter table dc_detail add constraint fk_dc_detail_master_id foreign key (master_id) references dc_master (id); + +create index ix_dfk_cascade_one_id on dfk_cascade (one_id); +alter table dfk_cascade add constraint fk_dfk_cascade_one_id foreign key (one_id) references dfk_cascade_one (id) on delete cascade; + +create index ix_dfk_set_null_one_id on dfk_set_null (one_id); +alter table dfk_set_null add constraint fk_dfk_set_null_one_id foreign key (one_id) references dfk_one (id) on delete set null; + +alter table doc add constraint fk_doc_id foreign key (id) references doc_draft (id); + +create index ix_doc_link_doc on doc_link (doc_id); +alter table doc_link add constraint fk_doc_link_doc foreign key (doc_id) references doc (id); + +create index ix_doc_link_link on doc_link (link_id); +alter table doc_link add constraint fk_doc_link_link foreign key (link_id) references link (id); + +alter table document add constraint fk_document_id foreign key (id) references document_draft (id); + +create index ix_document_organisation_id on document (organisation_id); +alter table document add constraint fk_document_organisation_id foreign key (organisation_id) references organisation (id); + +create index ix_dcmnt_drft_rgnstn_d on document_draft (organisation_id); +alter table document_draft add constraint fk_dcmnt_drft_rgnstn_d foreign key (organisation_id) references organisation (id); + +create index ix_document_media_document_id on document_media (document_id); +alter table document_media add constraint fk_document_media_document_id foreign key (document_id) references document (id); + +create index ix_dcmnt_md_drft_dcmnt_d on document_media_draft (document_id); +alter table document_media_draft add constraint fk_dcmnt_md_drft_dcmnt_d foreign key (document_id) references document_draft (id); + +create index ix_e_basicenc_relate_other_id on e_basicenc_relate (other_id); +alter table e_basicenc_relate add constraint fk_e_basicenc_relate_other_id foreign key (other_id) references e_basicenc (id); + +create index ix_ebsc_jsn_mp_dtl_wnr_d on ebasic_json_map_detail (owner_id); +alter table ebasic_json_map_detail add constraint fk_ebsc_jsn_mp_dtl_wnr_d foreign key (owner_id) references ebasic_json_map (id); + +create index ix_ebasic_no_sdchild_owner_id on ebasic_no_sdchild (owner_id); +alter table ebasic_no_sdchild add constraint fk_ebasic_no_sdchild_owner_id foreign key (owner_id) references ebasic_soft_delete (id); + +create index ix_ebasic_sdchild_owner_id on ebasic_sdchild (owner_id); +alter table ebasic_sdchild add constraint fk_ebasic_sdchild_owner_id foreign key (owner_id) references ebasic_soft_delete (id); + +create index ix_ecache_child_root_id on ecache_child (root_id); +alter table ecache_child add constraint fk_ecache_child_root_id foreign key (root_id) references ecache_root (id); + +alter table edefault_prop add constraint fk_edflt_prp__smpl_srtypd foreign key (e_simple_usertypeid) references esimple (usertypeid); + +create index ix_eemb_inner_outer_id on eemb_inner (outer_id); +alter table eemb_inner add constraint fk_eemb_inner_outer_id foreign key (outer_id) references eemb_outer (id); + +create index ix_einvoice_person_id on einvoice (person_id); +alter table einvoice add constraint fk_einvoice_person_id foreign key (person_id) references eperson (id); + +create index ix_enll_cllctn_dtl_nll_cllc_1 on enull_collection_detail (enull_collection_id); +alter table enull_collection_detail add constraint fk_enll_cllctn_dtl_nll_cllc_1 foreign key (enull_collection_id) references enull_collection (id); + +create index ix_eopt_one_a_b_id on eopt_one_a (b_id); +alter table eopt_one_a add constraint fk_eopt_one_a_b_id foreign key (b_id) references eopt_one_b (id); + +create index ix_eopt_one_b_c_id on eopt_one_b (c_id); +alter table eopt_one_b add constraint fk_eopt_one_b_c_id foreign key (c_id) references eopt_one_c (id); + +create index ix_eper_addr_ma_country_code on eper_addr (ma_country_code); +alter table eper_addr add constraint fk_eper_addr_ma_country_code foreign key (ma_country_code) references o_country (code); + +create index ix_esoft_del_book_lend_by_id on esoft_del_book (lend_by_id); +alter table esoft_del_book add constraint fk_esoft_del_book_lend_by_id foreign key (lend_by_id) references esoft_del_user (id); + +create index ix_esft_dl_bk_sft_dl_sr_sft_1 on esoft_del_book_esoft_del_user (esoft_del_book_id); +alter table esoft_del_book_esoft_del_user add constraint fk_esft_dl_bk_sft_dl_sr_sft_1 foreign key (esoft_del_book_id) references esoft_del_book (id); + +create index ix_esft_dl_bk_sft_dl_sr_sft_2 on esoft_del_book_esoft_del_user (esoft_del_user_id); +alter table esoft_del_book_esoft_del_user add constraint fk_esft_dl_bk_sft_dl_sr_sft_2 foreign key (esoft_del_user_id) references esoft_del_user (id); + +create index ix_esft_dl_dwn_sft_dl_md_d on esoft_del_down (esoft_del_mid_id); +alter table esoft_del_down add constraint fk_esft_dl_dwn_sft_dl_md_d foreign key (esoft_del_mid_id) references esoft_del_mid (id); + +create index ix_esoft_del_mid_top_id on esoft_del_mid (top_id); +alter table esoft_del_mid add constraint fk_esoft_del_mid_top_id foreign key (top_id) references esoft_del_top (id); + +create index ix_esoft_del_mid_up_id on esoft_del_mid (up_id); +alter table esoft_del_mid add constraint fk_esoft_del_mid_up_id foreign key (up_id) references esoft_del_up (id); + +alter table esoft_del_one_a add constraint fk_esoft_del_one_a_oneb_id foreign key (oneb_id) references esoft_del_one_b (id); + +create index ix_esft_dl_rl_sft_dl_sr_sft_1 on esoft_del_role_esoft_del_user (esoft_del_role_id); +alter table esoft_del_role_esoft_del_user add constraint fk_esft_dl_rl_sft_dl_sr_sft_1 foreign key (esoft_del_role_id) references esoft_del_role (id); + +create index ix_esft_dl_rl_sft_dl_sr_sft_2 on esoft_del_role_esoft_del_user (esoft_del_user_id); +alter table esoft_del_role_esoft_del_user add constraint fk_esft_dl_rl_sft_dl_sr_sft_2 foreign key (esoft_del_user_id) references esoft_del_user (id); + +create index ix_esft_dl_sr_sft_dl_rl_sft_1 on esoft_del_user_esoft_del_role (esoft_del_user_id); +alter table esoft_del_user_esoft_del_role add constraint fk_esft_dl_sr_sft_dl_rl_sft_1 foreign key (esoft_del_user_id) references esoft_del_user (id); + +create index ix_esft_dl_sr_sft_dl_rl_sft_2 on esoft_del_user_esoft_del_role (esoft_del_role_id); +alter table esoft_del_user_esoft_del_role add constraint fk_esft_dl_sr_sft_dl_rl_sft_2 foreign key (esoft_del_role_id) references esoft_del_role (id); + +create index ix_rawinherit_uncle_parent_id on rawinherit_uncle (parent_id); +alter table rawinherit_uncle add constraint fk_rawinherit_uncle_parent_id foreign key (parent_id) references rawinherit_parent (id); + +create index ix_evnll_cllctn_dtl_vnll_cl_1 on evanilla_collection_detail (evanilla_collection_id); +alter table evanilla_collection_detail add constraint fk_evnll_cllctn_dtl_vnll_cl_1 foreign key (evanilla_collection_id) references evanilla_collection (id); + +create index ix_ec_nm_prsn_tgs_c_nm_prsn_d on ec_enum_person_tags (ec_enum_person_id); +alter table ec_enum_person_tags add constraint fk_ec_nm_prsn_tgs_c_nm_prsn_d foreign key (ec_enum_person_id) references ec_enum_person (id); + +create index ix_ec_person_phone_owner_id on ec_person_phone (owner_id); +alter table ec_person_phone add constraint fk_ec_person_phone_owner_id foreign key (owner_id) references ec_person (id); + +create index ix_ec_top_person_id on ec_top (person_id); +alter table ec_top add constraint fk_ec_top_person_id foreign key (person_id) references ecs_person (id); + +create index ix_ec_top_ecs_person_ec_top on ec_top_ecs_person (ec_top_id); +alter table ec_top_ecs_person add constraint fk_ec_top_ecs_person_ec_top foreign key (ec_top_id) references ec_top (id); + +create index ix_ec_tp_cs_prsn_cs_prsn on ec_top_ecs_person (ecs_person_id); +alter table ec_top_ecs_person add constraint fk_ec_tp_cs_prsn_cs_prsn foreign key (ecs_person_id) references ecs_person (id); + +create index ix_ecbl_prsn_phn_nmbrs_prsn_d on ecbl_person_phone_numbers (person_id); +alter table ecbl_person_phone_numbers add constraint fk_ecbl_prsn_phn_nmbrs_prsn_d foreign key (person_id) references ecbl_person (id); + +create index ix_ecbm_prsn_phn_nmbrs_prsn_d on ecbm_person_phone_numbers (person_id); +alter table ecbm_person_phone_numbers add constraint fk_ecbm_prsn_phn_nmbrs_prsn_d foreign key (person_id) references ecbm_person (id); + +create index ix_ecm_prsn_phn_nmbrs_cm_pr_1 on ecm_person_phone_numbers (ecm_person_id); +alter table ecm_person_phone_numbers add constraint fk_ecm_prsn_phn_nmbrs_cm_pr_1 foreign key (ecm_person_id) references ecm_person (id); + +create index ix_ecmc_prsn_phn_nmbrs_cmc__1 on ecmc_person_phone_numbers (ecmc_person_id); +alter table ecmc_person_phone_numbers add constraint fk_ecmc_prsn_phn_nmbrs_cmc__1 foreign key (ecmc_person_id) references ecmc_person (id); + +create index ix_ecs_prsn_phn_cs_prsn_d on ecs_person_phone (ecs_person_id); +alter table ecs_person_phone add constraint fk_ecs_prsn_phn_cs_prsn_d foreign key (ecs_person_id) references ecs_person (id); + +create index ix_ecsm_child_ecsm_parent_id on ecsm_child (ecsm_parent_id); +alter table ecsm_child add constraint fk_ecsm_child_ecsm_parent_id foreign key (ecsm_parent_id) references ecsm_parent (id); + +create index ix_td_child_parent_id on td_child (parent_id); +alter table td_child add constraint fk_td_child_parent_id foreign key (parent_id) references td_parent (parent_id); + +create index ix_elmnt_bn_cmplx_bn_d on element_bean (complex_bean_id); +alter table element_bean add constraint fk_elmnt_bn_cmplx_bn_d foreign key (complex_bean_id) references root_bean (id); + +create index ix_empl_default_address_id on empl (default_address_id); +alter table empl add constraint fk_empl_default_address_id foreign key (default_address_id) references addr (id); + +create index ix_esd_detail_master_id on esd_detail (master_id); +alter table esd_detail add constraint fk_esd_detail_master_id foreign key (master_id) references esd_master (id); + +create index ix_grnd_prnt_prsn_sm_bn_d on grand_parent_person (some_bean_id); +alter table grand_parent_person add constraint fk_grnd_prnt_prsn_sm_bn_d foreign key (some_bean_id) references e_basic (id); + +create index ix_srvy_grp_ctgrybjctd on survey_group (categoryobjectid); +alter table survey_group add constraint fk_srvy_grp_ctgrybjctd foreign key (categoryobjectid) references category (id); + +create index ix_hx_link_doc_hx_link on hx_link_doc (hx_link_id); +alter table hx_link_doc add constraint fk_hx_link_doc_hx_link foreign key (hx_link_id) references hx_link (id); + +create index ix_hx_link_doc_he_doc on hx_link_doc (he_doc_id); +alter table hx_link_doc add constraint fk_hx_link_doc_he_doc foreign key (he_doc_id) references he_doc (id); + +create index ix_hi_link_doc_hi_link on hi_link_doc (hi_link_id); +alter table hi_link_doc add constraint fk_hi_link_doc_hi_link foreign key (hi_link_id) references hi_link (id); + +create index ix_hi_link_doc_hi_doc on hi_link_doc (hi_doc_id); +alter table hi_link_doc add constraint fk_hi_link_doc_hi_doc foreign key (hi_doc_id) references hi_doc (id); + +create index ix_hi_tthree_hi_ttwo_id on hi_tthree (hi_ttwo_id); +alter table hi_tthree add constraint fk_hi_tthree_hi_ttwo_id foreign key (hi_ttwo_id) references hi_ttwo (id); + +create index ix_hi_ttwo_hi_tone_id on hi_ttwo (hi_tone_id); +alter table hi_ttwo add constraint fk_hi_ttwo_hi_tone_id foreign key (hi_tone_id) references hi_tone (id); + +alter table hsd_setting add constraint fk_hsd_setting_user_id foreign key (user_id) references hsd_user (id); + +create index ix_iaf_segment_status_id on iaf_segment (status_id); +alter table iaf_segment add constraint fk_iaf_segment_status_id foreign key (status_id) references iaf_segment_status (id); + +create index ix_imrelated_owner_id on imrelated (owner_id); +alter table imrelated add constraint fk_imrelated_owner_id foreign key (owner_id) references imroot (id); + +create index ix_info_contact_company_id on info_contact (company_id); +alter table info_contact add constraint fk_info_contact_company_id foreign key (company_id) references info_company (id); + +alter table info_customer add constraint fk_info_customer_company_id foreign key (company_id) references info_company (id); + +alter table inner_report add constraint fk_inner_report_forecast_id foreign key (forecast_id) references stockforecast (id); + +create index ix_drel_invoice_booking on drel_invoice (booking); +alter table drel_invoice add constraint fk_drel_invoice_booking foreign key (booking) references drel_booking (id); + +create index ix_item_etype on item (customer,type); +alter table item add constraint fk_item_etype foreign key (customer,type) references "type" (customer,type); + +create index ix_item_eregion on item (customer,region); +alter table item add constraint fk_item_eregion foreign key (customer,region) references region (customer,type); + +alter table mkeygroup_monkey add constraint fk_mkeygroup_monkey_mkeygroup foreign key (mkeygroup_pid) references mkeygroup (pid); + +alter table mkeygroup_monkey add constraint fk_mkeygroup_monkey_monkey foreign key (monkey_mid) references monkey (mid); + +alter table trainer_monkey add constraint fk_trainer_monkey_trainer foreign key (trainer_tid) references trainer (tid); + +alter table trainer_monkey add constraint fk_trainer_monkey_monkey foreign key (monkey_mid) references monkey (mid); + +alter table troop_monkey add constraint fk_troop_monkey_troop foreign key (troop_pid) references troop (pid); + +alter table troop_monkey add constraint fk_troop_monkey_monkey foreign key (monkey_mid) references monkey (mid); + +create index ix_l2_cldf_rst_bn_chld_prnt_d on l2_cldf_reset_bean_child (parent_id); +alter table l2_cldf_reset_bean_child add constraint fk_l2_cldf_rst_bn_chld_prnt_d foreign key (parent_id) references l2_cldf_reset_bean (id); + +create index ix_level1_level4_level1 on level1_level4 (level1_id); +alter table level1_level4 add constraint fk_level1_level4_level1 foreign key (level1_id) references level1 (id); + +create index ix_level1_level4_level4 on level1_level4 (level4_id); +alter table level1_level4 add constraint fk_level1_level4_level4 foreign key (level4_id) references level4 (id); + +create index ix_level1_level2_level1 on level1_level2 (level1_id); +alter table level1_level2 add constraint fk_level1_level2_level1 foreign key (level1_id) references level1 (id); + +create index ix_level1_level2_level2 on level1_level2 (level2_id); +alter table level1_level2 add constraint fk_level1_level2_level2 foreign key (level2_id) references level2 (id); + +create index ix_level2_level3_level2 on level2_level3 (level2_id); +alter table level2_level3 add constraint fk_level2_level3_level2 foreign key (level2_id) references level2 (id); + +create index ix_level2_level3_level3 on level2_level3 (level3_id); +alter table level2_level3 add constraint fk_level2_level3_level3 foreign key (level3_id) references level3 (id); + +alter table link add constraint fk_link_id foreign key (id) references link_draft (id); + +create index ix_l_ttr_vl_ttrbt_l_ttr_vl on la_attr_value_attribute (la_attr_value_id); +alter table la_attr_value_attribute add constraint fk_l_ttr_vl_ttrbt_l_ttr_vl foreign key (la_attr_value_id) references la_attr_value (id); + +create index ix_l_ttr_vl_ttrbt_ttrbt on la_attr_value_attribute (attribute_id); +alter table la_attr_value_attribute add constraint fk_l_ttr_vl_ttrbt_ttrbt foreign key (attribute_id) references attribute (id); + +create index ix_looney_tune_id on looney (tune_id); +alter table looney add constraint fk_looney_tune_id foreign key (tune_id) references tune (id); + +create index ix_mcontact_customer_id on mcontact (customer_id); +alter table mcontact add constraint fk_mcontact_customer_id foreign key (customer_id) references mcustomer (id); + +create index ix_mcntct_mssg_cntct_d on mcontact_message (contact_id); +alter table mcontact_message add constraint fk_mcntct_mssg_cntct_d foreign key (contact_id) references mcontact (id); + +create index ix_mcstmr_shppng_ddrss_d on mcustomer (shipping_address_id); +alter table mcustomer add constraint fk_mcstmr_shppng_ddrss_d foreign key (shipping_address_id) references maddress (id); + +create index ix_mcstmr_bllng_ddrss_d on mcustomer (billing_address_id); +alter table mcustomer add constraint fk_mcstmr_bllng_ddrss_d foreign key (billing_address_id) references maddress (id); + +create index ix_mmachine_mgroup_mmachine on mmachine_mgroup (mmachine_id); +alter table mmachine_mgroup add constraint fk_mmachine_mgroup_mmachine foreign key (mmachine_id) references mmachine (id); + +create index ix_mmachine_mgroup_mgroup on mmachine_mgroup (mgroup_id); +alter table mmachine_mgroup add constraint fk_mmachine_mgroup_mgroup foreign key (mgroup_id) references mgroup (id); + +create index ix_mprinter_current_state_id on mprinter (current_state_id); +alter table mprinter add constraint fk_mprinter_current_state_id foreign key (current_state_id) references mprinter_state (id); + +alter table mprinter add constraint fk_mprinter_last_swap_cyan_id foreign key (last_swap_cyan_id) references mprinter_state (id); + +alter table mprinter add constraint fk_mprntr_lst_swp_mgnt_d foreign key (last_swap_magenta_id) references mprinter_state (id); + +alter table mprinter add constraint fk_mprntr_lst_swp_yllw_d foreign key (last_swap_yellow_id) references mprinter_state (id); + +alter table mprinter add constraint fk_mprntr_lst_swp_blck_d foreign key (last_swap_black_id) references mprinter_state (id); + +create index ix_mprinter_state_printer_id on mprinter_state (printer_id); +alter table mprinter_state add constraint fk_mprinter_state_printer_id foreign key (printer_id) references mprinter (id); + +create index ix_mprofile_picture_id on mprofile (picture_id); +alter table mprofile add constraint fk_mprofile_picture_id foreign key (picture_id) references mmedia (id); + +create index ix_mrole_muser_mrole on mrole_muser (mrole_roleid); +alter table mrole_muser add constraint fk_mrole_muser_mrole foreign key (mrole_roleid) references mrole (roleid); + +create index ix_mrole_muser_muser on mrole_muser (muser_userid); +alter table mrole_muser add constraint fk_mrole_muser_muser foreign key (muser_userid) references muser (userid); + +create index ix_muser_user_type_id on muser (user_type_id); +alter table muser add constraint fk_muser_user_type_id foreign key (user_type_id) references muser_type (id); + +create index ix_mail_user_inbox_mail_user on mail_user_inbox (mail_user_id); +alter table mail_user_inbox add constraint fk_mail_user_inbox_mail_user foreign key (mail_user_id) references mail_user (id); + +create index ix_mail_user_inbox_mail_box on mail_user_inbox (mail_box_id); +alter table mail_user_inbox add constraint fk_mail_user_inbox_mail_box foreign key (mail_box_id) references mail_box (id); + +create index ix_mail_user_outbox_mail_user on mail_user_outbox (mail_user_id); +alter table mail_user_outbox add constraint fk_mail_user_outbox_mail_user foreign key (mail_user_id) references mail_user (id); + +create index ix_mail_user_outbox_mail_box on mail_user_outbox (mail_box_id); +alter table mail_user_outbox add constraint fk_mail_user_outbox_mail_box foreign key (mail_box_id) references mail_box (id); + +create index ix_c_message_conversation_id on c_message (conversation_id); +alter table c_message add constraint fk_c_message_conversation_id foreign key (conversation_id) references c_conversation (id); + +create index ix_c_message_user_id on c_message (user_id); +alter table c_message add constraint fk_c_message_user_id foreign key (user_id) references c_user (id); + +alter table meter_contract_data add constraint fk_mtr_cntrct_dt_spcl_nds_c_1 foreign key (special_needs_client_id) references meter_special_needs_client (id); + +alter table meter_special_needs_client add constraint fk_mtr_spcl_nds_clnt_prmry_d foreign key (primary_id) references meter_special_needs_contact (id); + +alter table meter_version add constraint fk_mtr_vrsn_ddrss_dt_d foreign key (address_data_id) references meter_address_data (id); + +alter table meter_version add constraint fk_mtr_vrsn_cntrct_dt_d foreign key (contract_data_id) references meter_contract_data (id); + +create index ix_mnc_sr_mnc_rl_mnc_sr on mnoc_user_mnoc_role (mnoc_user_user_id); +alter table mnoc_user_mnoc_role add constraint fk_mnc_sr_mnc_rl_mnc_sr foreign key (mnoc_user_user_id) references mnoc_user (user_id); + +create index ix_mnc_sr_mnc_rl_mnc_rl on mnoc_user_mnoc_role (mnoc_role_role_id); +alter table mnoc_user_mnoc_role add constraint fk_mnc_sr_mnc_rl_mnc_rl foreign key (mnoc_role_role_id) references mnoc_role (role_id); + +create index ix_mny_b_a_id on mny_b (a_id); +alter table mny_b add constraint fk_mny_b_a_id foreign key (a_id) references mny_a (id); + +create index ix_mny_b_mny_c_mny_b on mny_b_mny_c (mny_b_id); +alter table mny_b_mny_c add constraint fk_mny_b_mny_c_mny_b foreign key (mny_b_id) references mny_b (id); + +create index ix_mny_b_mny_c_mny_c on mny_b_mny_c (mny_c_id); +alter table mny_b_mny_c add constraint fk_mny_b_mny_c_mny_c foreign key (mny_c_id) references mny_c (id); + +create index ix_subtopics_mny_topic_1 on subtopics (topic); +alter table subtopics add constraint fk_subtopics_mny_topic_1 foreign key (topic) references mny_topic (id); + +create index ix_subtopics_mny_topic_2 on subtopics (subtopic); +alter table subtopics add constraint fk_subtopics_mny_topic_2 foreign key (subtopic) references mny_topic (id); + +create index ix_mp_role_mp_user_id on mp_role (mp_user_id); +alter table mp_role add constraint fk_mp_role_mp_user_id foreign key (mp_user_id) references mp_user (id); + +create index ix_ms_many_a_many_b_ms_many_a on ms_many_a_many_b (ms_many_a_aid); +alter table ms_many_a_many_b add constraint fk_ms_many_a_many_b_ms_many_a foreign key (ms_many_a_aid) references ms_many_a (aid); + +create index ix_ms_many_a_many_b_ms_many_b on ms_many_a_many_b (ms_many_b_bid); +alter table ms_many_a_many_b add constraint fk_ms_many_a_many_b_ms_many_b foreign key (ms_many_b_bid) references ms_many_b (bid); + +create index ix_ms_many_b_many_a_ms_many_b on ms_many_b_many_a (ms_many_b_bid); +alter table ms_many_b_many_a add constraint fk_ms_many_b_many_a_ms_many_b foreign key (ms_many_b_bid) references ms_many_b (bid); + +create index ix_ms_many_b_many_a_ms_many_a on ms_many_b_many_a (ms_many_a_aid); +alter table ms_many_b_many_a add constraint fk_ms_many_b_many_a_ms_many_a foreign key (ms_many_a_aid) references ms_many_a (aid); + +create index ix_my_lb_sz_jn_mny_prnt_d on my_lob_size_join_many (parent_id); +alter table my_lob_size_join_many add constraint fk_my_lb_sz_jn_mny_prnt_d foreign key (parent_id) references my_lob_size (id); + +create index ix_o_bn_chld_cchd_bn_d on o_bean_child (cached_bean_id); +alter table o_bean_child add constraint fk_o_bn_chld_cchd_bn_d foreign key (cached_bean_id) references o_cached_bean (id); + +create index ix_ocached_app_detail_app_id on ocached_app_detail (app_id); +alter table ocached_app_detail add constraint fk_ocached_app_detail_app_id foreign key (app_id) references ocached_app (id); + +create index ix_o_cchd_bn_cntry__cchd_bn on o_cached_bean_country (o_cached_bean_id); +alter table o_cached_bean_country add constraint fk_o_cchd_bn_cntry__cchd_bn foreign key (o_cached_bean_id) references o_cached_bean (id); + +create index ix_o_cchd_bn_cntry__cntry on o_cached_bean_country (o_country_code); +alter table o_cached_bean_country add constraint fk_o_cchd_bn_cntry__cntry foreign key (o_country_code) references o_country (code); + +create index ix_o_cchd_bn_chld_cchd_bn_d on o_cached_bean_child (cached_bean_id); +alter table o_cached_bean_child add constraint fk_o_cchd_bn_chld_cchd_bn_d foreign key (cached_bean_id) references o_cached_bean (id); + +alter table oengine add constraint fk_oengine_car_id foreign key (car_id) references ocar (id); + +alter table ogear_box add constraint fk_ogear_box_car_id foreign key (car_id) references ocar (id); + +create index ix_omvertex_other_omvertex_id on omvertex_other (omvertex_id); +alter table omvertex_other add constraint fk_omvertex_other_omvertex_id foreign key (omvertex_id) references omvertex (id); + +alter table oroad_show_msg add constraint fk_oroad_show_msg_company_id foreign key (company_id) references ocompany (id); + +create index ix_om_ccnt_chld_db_bnn_rm_d on om_account_child_dbo (banana_rama_id); +alter table om_account_child_dbo add constraint fk_om_ccnt_chld_db_bnn_rm_d foreign key (banana_rama_id) references om_account_dbo (id); + +create index ix_om_basic_child_parent_id on om_basic_child (parent_id); +alter table om_basic_child add constraint fk_om_basic_child_parent_id foreign key (parent_id) references om_basic_parent (id); + +create index ix_om_rdrd_dtl_mstr_d on om_ordered_detail (master_id); +alter table om_ordered_detail add constraint fk_om_rdrd_dtl_mstr_d foreign key (master_id) references om_ordered_master (id); + +create index ix_o_order_kcustomer_id on o_order (kcustomer_id); +alter table o_order add constraint fk_o_order_kcustomer_id foreign key (kcustomer_id) references o_customer (id); + +create index ix_o_order_detail_order_id on o_order_detail (order_id); +alter table o_order_detail add constraint fk_o_order_detail_order_id foreign key (order_id) references o_order (id); + +create index ix_o_order_detail_product_id on o_order_detail (product_id); +alter table o_order_detail add constraint fk_o_order_detail_product_id foreign key (product_id) references o_product (id); + +create index ix_s_order_items_order_uuid on s_order_items (order_uuid); +alter table s_order_items add constraint fk_s_order_items_order_uuid foreign key (order_uuid) references s_orders (uuid); + +create index ix_or_order_ship_order_id on or_order_ship (order_id); +alter table or_order_ship add constraint fk_or_order_ship_order_id foreign key (order_id) references o_order (id); + +alter table organization_node add constraint fk_orgnztn_nd_prnt_tr_nd_d foreign key (parent_tree_node_id) references organization_tree_node (id); + +create index ix_orp_detail_master_id on orp_detail (master_id); +alter table orp_detail add constraint fk_orp_detail_master_id foreign key (master_id) references orp_master (id); + +create index ix_orp_detail2_orp_master2_id on orp_detail2 (orp_master2_id); +alter table orp_detail2 add constraint fk_orp_detail2_orp_master2_id foreign key (orp_master2_id) references orp_master2 (id); + +alter table oto_atwo add constraint fk_oto_atwo_aone_id foreign key (aone_id) references oto_aone (id); + +alter table oto_bchild add constraint fk_oto_bchild_master_id foreign key (master_id) references oto_bmaster (id); + +alter table oto_child add constraint fk_oto_child_master_id foreign key (master_id) references oto_master (id); + +alter table oto_cust_address add constraint fk_ot_cst_ddrss_cstmr_cd foreign key (customer_cid) references oto_cust (cid); + +alter table oto_level_a add constraint fk_oto_level_a_b_id foreign key (b_id) references oto_level_b (id); + +alter table oto_level_b add constraint fk_oto_level_b_c_id foreign key (c_id) references oto_level_c (id); + +alter table oto_prime_extra add constraint fk_oto_prime_extra_eid foreign key (eid) references oto_prime (pid); + +alter table oto_sd_child add constraint fk_oto_sd_child_master_id foreign key (master_id) references oto_sd_master (id); + +create index ix_oto_th_many_oto_th_top_id on oto_th_many (oto_th_top_id); +alter table oto_th_many add constraint fk_oto_th_many_oto_th_top_id foreign key (oto_th_top_id) references oto_th_top (id); + +alter table oto_th_one add constraint fk_oto_th_one_many_id foreign key (many_id) references oto_th_many (id); + +alter table oto_ubprime_extra add constraint fk_oto_ubprime_extra_eid foreign key (eid) references oto_ubprime (pid); + +alter table oto_user_model add constraint fk_ot_sr_mdl_sr_ptnl_d foreign key (user_optional_id) references oto_user_model_optional (id); + +alter table pfile add constraint fk_pfile_file_content_id foreign key (file_content_id) references pfile_content (id); + +alter table pfile add constraint fk_pfile_file_content2_id foreign key (file_content2_id) references pfile_content (id); + +alter table paggview add constraint fk_paggview_pview_id foreign key (pview_id) references pp (id); + +create index ix_pallet_location_zone_sid on pallet_location (zone_sid); +alter table pallet_location add constraint fk_pallet_location_zone_sid foreign key (zone_sid) references zones (id); + +alter table parcel_location add constraint fk_parcel_location_parcelid foreign key (parcelid) references parcel (parcelid); + +create index ix_rwnhrt_prnt_rwnhrt_d_rwn_1 on rawinherit_parent_rawinherit_d (rawinherit_parent_id); +alter table rawinherit_parent_rawinherit_d add constraint fk_rwnhrt_prnt_rwnhrt_d_rwn_1 foreign key (rawinherit_parent_id) references rawinherit_parent (id); + +create index ix_rwnhrt_prnt_rwnhrt_d_rwn_2 on rawinherit_parent_rawinherit_d (rawinherit_data_id); +alter table rawinherit_parent_rawinherit_d add constraint fk_rwnhrt_prnt_rwnhrt_d_rwn_2 foreign key (rawinherit_data_id) references rawinherit_data (id); + +create index ix_parent_person_some_bean_id on parent_person (some_bean_id); +alter table parent_person add constraint fk_parent_person_some_bean_id foreign key (some_bean_id) references e_basic (id); + +create index ix_prnt_prsn_prnt_dntfr on parent_person (parent_identifier); +alter table parent_person add constraint fk_prnt_prsn_prnt_dntfr foreign key (parent_identifier) references grand_parent_person (identifier); + +create index ix_c_prtcptn_cnvrstn_d on c_participation (conversation_id); +alter table c_participation add constraint fk_c_prtcptn_cnvrstn_d foreign key (conversation_id) references c_conversation (id); + +create index ix_c_participation_user_id on c_participation (user_id); +alter table c_participation add constraint fk_c_participation_user_id foreign key (user_id) references c_user (id); + +create index ix_pcf_calendar_pcf_person_id on pcf_calendar (pcf_person_id); +alter table pcf_calendar add constraint fk_pcf_calendar_pcf_person_id foreign key (pcf_person_id) references pcf_person (id); + +create index ix_pcf_city_pcf_country_id on pcf_city (pcf_country_id); +alter table pcf_city add constraint fk_pcf_city_pcf_country_id foreign key (pcf_country_id) references pcf_country (id); + +alter table pcf_city add constraint fk_pcf_city_mayor_id foreign key (mayor_id) references pcf_person (id); + +alter table pcf_city add constraint fk_pcf_city_vice_mayor_id foreign key (vice_mayor_id) references pcf_person (id); + +create index ix_pcf_event_pcf_calendar_id on pcf_event (pcf_calendar_id); +alter table pcf_event add constraint fk_pcf_event_pcf_calendar_id foreign key (pcf_calendar_id) references pcf_calendar (id); + +alter table persistent_file_content add constraint fk_prsstnt_fl_cntnt_prsstnt_1 foreign key (persistent_file_id) references persistent_file (id); + +create index ix_person_default_address_oid on person (default_address_oid); +alter table person add constraint fk_person_default_address_oid foreign key (default_address_oid) references address (oid); + +create index ix_prsn_cch_ml_prsn_nf_prsn_d on person_cache_email (person_info_person_id); +alter table person_cache_email add constraint fk_prsn_cch_ml_prsn_nf_prsn_d foreign key (person_info_person_id) references person_cache_info (person_id); + +create index ix_phones_person_id on phones (person_id); +alter table phones add constraint fk_phones_person_id foreign key (person_id) references persons (id); + +create index ix_e_position_contract_id on e_position (contract_id); +alter table e_position add constraint fk_e_position_contract_id foreign key (contract_id) references contract (id); + +create index ix_pp_to_ww_pp on pp_to_ww (pp_id); +alter table pp_to_ww add constraint fk_pp_to_ww_pp foreign key (pp_id) references pp (id); + +create index ix_pp_to_ww_wview on pp_to_ww (ww_id); +alter table pp_to_ww add constraint fk_pp_to_ww_wview foreign key (ww_id) references wview (id); + +create index ix_question_groupobjectid on question (groupobjectid); +alter table question add constraint fk_question_groupobjectid foreign key (groupobjectid) references survey_group (id); + +create index ix_r_orders_customer on r_orders (company,customername); +alter table r_orders add constraint fk_r_orders_customer foreign key (company,customername) references rcustomer (company,name); + +create index ix_rel_master_detail_id on rel_master (detail_id); +alter table rel_master add constraint fk_rel_master_detail_id foreign key (detail_id) references rel_detail (id); + +create index ix_rsrcfl_prntrsrcfld on resourcefile (parentresourcefileid); +alter table resourcefile add constraint fk_rsrcfl_prntrsrcfld foreign key (parentresourcefileid) references resourcefile (id); + +create index ix_mt_role_tenant_id on mt_role (tenant_id); +alter table mt_role add constraint fk_mt_role_tenant_id foreign key (tenant_id) references mt_tenant (id); + +create index ix_mt_role_permission_mt_role on mt_role_permission (mt_role_id); +alter table mt_role_permission add constraint fk_mt_role_permission_mt_role foreign key (mt_role_id) references mt_role (id); + +create index ix_mt_rl_prmssn_mt_prmssn on mt_role_permission (mt_permission_id); +alter table mt_role_permission add constraint fk_mt_rl_prmssn_mt_prmssn foreign key (mt_permission_id) references mt_permission (id); + +create index ix_rt_bn_rfrncng_bn_d on root_bean (referencing_bean_id); +alter table root_bean add constraint fk_rt_bn_rfrncng_bn_d foreign key (referencing_bean_id) references referencing_bean (id); + +alter table f_second add constraint fk_f_second_first foreign key (first) references f_first (id); + +create index ix_section_article_id on section (article_id); +alter table section add constraint fk_section_article_id foreign key (article_id) references article (id); + +create index ix_self_parent_parent_id on self_parent (parent_id); +alter table self_parent add constraint fk_self_parent_parent_id foreign key (parent_id) references self_parent (id); + +create index ix_slf_rf_cstmr_rfrrd_by_d on self_ref_customer (referred_by_id); +alter table self_ref_customer add constraint fk_slf_rf_cstmr_rfrrd_by_d foreign key (referred_by_id) references self_ref_customer (id); + +create index ix_self_ref_example_parent_id on self_ref_example (parent_id); +alter table self_ref_example add constraint fk_self_ref_example_parent_id foreign key (parent_id) references self_ref_example (id); + +alter table e_save_test_b add constraint fk_e_save_test_b_sibling_a_id foreign key (sibling_a_id) references e_save_test_a (id); + +create index ix_site_parent_id on site (parent_id); +alter table site add constraint fk_site_parent_id foreign key (parent_id) references site (id); + +alter table site add constraint fk_site_data_container_id foreign key (data_container_id) references data_container (id); + +alter table site add constraint fk_site_site_address_id foreign key (site_address_id) references site_address (id); + +create index ix_source_base_target_id on source_base (target_id); +alter table source_base add constraint fk_source_base_target_id foreign key (target_id) references target_base (id); + +create index ix_stckfrcst_nnr_rprt_d on stockforecast (inner_report_id); +alter table stockforecast add constraint fk_stckfrcst_nnr_rprt_d foreign key (inner_report_id) references inner_report (id); + +create index ix_sub_section_section_id on sub_section (section_id); +alter table sub_section add constraint fk_sub_section_section_id foreign key (section_id) references section (id); + +create index ix_tevent_many_event_id on tevent_many (event_id); +alter table tevent_many add constraint fk_tevent_many_event_id foreign key (event_id) references tevent_one (id); + +alter table tevent_one add constraint fk_tevent_one_event_id foreign key (event_id) references tevent (id); + +create index ix_t_dtl_wth_thr_nmxxxyy_ms_1 on t_detail_with_other_namexxxyy (master_id); +alter table t_detail_with_other_namexxxyy add constraint fk_t_dtl_wth_thr_nmxxxyy_ms_1 foreign key (master_id) references t_atable_thatisrelatively (id); + +create index ix_ttrck_hldr_trck_plt_n on ttruck_holder (truck_plate_no); +alter table ttruck_holder add constraint fk_ttrck_hldr_trck_plt_n foreign key (truck_plate_no) references tcar (plate_no); + +create index ix_ttruck_holder_basic_id on ttruck_holder (basic_id); +alter table ttruck_holder add constraint fk_ttruck_holder_basic_id foreign key (basic_id) references e_basic (id); + +create index ix_ttrck_hldr_tm_wnr_d on ttruck_holder_item (owner_id); +alter table ttruck_holder_item add constraint fk_ttrck_hldr_tm_wnr_d foreign key (owner_id) references ttruck_holder (id); + +create index ix_twheel_owner_plate_no on twheel (owner_plate_no); +alter table twheel add constraint fk_twheel_owner_plate_no foreign key (owner_plate_no) references tcar (plate_no); + +alter table tire add constraint fk_tire_wheel foreign key (wheel) references wheel (id); + +create index ix_tree_entity_parent_id on tree_entity (parent_id); +alter table tree_entity add constraint fk_tree_entity_parent_id foreign key (parent_id) references tree_entity (id); + +create index ix_trip_vehicle_driver_id on trip (vehicle_driver_id); +alter table trip add constraint fk_trip_vehicle_driver_id foreign key (vehicle_driver_id) references vehicle_driver (id); + +create index ix_trip_address_id on trip (address_id); +alter table trip add constraint fk_trip_address_id foreign key (address_id) references o_address (id); + +create index ix_type_sub_type_id on "type" (sub_type_id); +alter table "type" add constraint fk_type_sub_type_id foreign key (sub_type_id) references sub_type (sub_type_id); + +create index ix_usib_child_parent_id on usib_child (parent_id); +alter table usib_child add constraint fk_usib_child_parent_id foreign key (parent_id) references usib_parent (id); + +alter table usib_child_sibling add constraint fk_usb_chld_sblng_chld_d foreign key (child_id) references usib_child (id); + +create index ix_ut_detail_utmaster_id on ut_detail (utmaster_id); +alter table ut_detail add constraint fk_ut_detail_utmaster_id foreign key (utmaster_id) references ut_master (id); + +create index ix_uutwo_master_id on uutwo (master_id); +alter table uutwo add constraint fk_uutwo_master_id foreign key (master_id) references uuone (id); + +alter table oto_user add constraint fk_oto_user_account_id foreign key (account_id) references oto_account (id); + +create index ix_c_user_group_id on c_user (group_id); +alter table c_user add constraint fk_c_user_group_id foreign key (group_id) references c_group (id); + +create index ix_em_user_role_user_id on em_user_role (user_id); +alter table em_user_role add constraint fk_em_user_role_user_id foreign key (user_id) references em_user (id); + +create index ix_em_user_role_role_id on em_user_role (role_id); +alter table em_user_role add constraint fk_em_user_role_role_id foreign key (role_id) references em_role (id); + +create index ix_vehicle_lease_id on vehicle (lease_id); +alter table vehicle add constraint fk_vehicle_lease_id foreign key (lease_id) references vehicle_lease (id); + +create index ix_vehicle_car_ref_id on vehicle (car_ref_id); +alter table vehicle add constraint fk_vehicle_car_ref_id foreign key (car_ref_id) references truck_ref (id); + +create index ix_vehicle_truck_ref_id on vehicle (truck_ref_id); +alter table vehicle add constraint fk_vehicle_truck_ref_id foreign key (truck_ref_id) references truck_ref (id); + +create index ix_vehicle_driver_vehicle_id on vehicle_driver (vehicle_id); +alter table vehicle_driver add constraint fk_vehicle_driver_vehicle_id foreign key (vehicle_id) references vehicle (id); + +create index ix_vehicle_driver_address_id on vehicle_driver (address_id); +alter table vehicle_driver add constraint fk_vehicle_driver_address_id foreign key (address_id) references o_address (id); + +create index ix_warehouses_officezoneid on warehouses (officezoneid); +alter table warehouses add constraint fk_warehouses_officezoneid foreign key (officezoneid) references zones (id); + +create index ix_wrhssshppngzns_wrhss on warehousesshippingzones (warehouseid); +alter table warehousesshippingzones add constraint fk_wrhssshppngzns_wrhss foreign key (warehouseid) references warehouses (id); + +create index ix_wrhssshppngzns_zns on warehousesshippingzones (shippingzoneid); +alter table warehousesshippingzones add constraint fk_wrhssshppngzns_zns foreign key (shippingzoneid) references zones (id); + +create index ix_sa_wheel_tire on sa_wheel (tire); +alter table sa_wheel add constraint fk_sa_wheel_tire foreign key (tire) references sa_tire (id); + +create index ix_sa_wheel_car on sa_wheel (car); +alter table sa_wheel add constraint fk_sa_wheel_car foreign key (car) references sa_car (id); + +create index ix_g_wh_prps_tm_wh_crtd_d on g_who_props_otm (who_created_id); +alter table g_who_props_otm add constraint fk_g_wh_prps_tm_wh_crtd_d foreign key (who_created_id) references g_user (id); + +create index ix_g_wh_prps_tm_wh_mdfd_d on g_who_props_otm (who_modified_id); +alter table g_who_props_otm add constraint fk_g_wh_prps_tm_wh_mdfd_d foreign key (who_modified_id) references g_user (id); + +create index ix_with_zero_parent_id on with_zero (parent_id); +alter table with_zero add constraint fk_with_zero_parent_id foreign key (parent_id) references parent (id); + diff --git a/ebean-core/src/test/ddl-review/oracle-drop-all.sql b/ebean-core/src/test/ddl-review/oracle-drop-all.sql new file mode 100644 index 000000000..318c4b276 --- /dev/null +++ b/ebean-core/src/test/ddl-review/oracle-drop-all.sql @@ -0,0 +1,1821 @@ +-- Generated by ebean unknown at 2020-03-17T09:34:02.384264Z +alter table bar drop constraint fk_bar_foo_id; +drop index ix_bar_foo_id; + +alter table acl_container_relation drop constraint fk_acl_cntnr_rltn_cntnr_d; +drop index ix_acl_cntnr_rltn_cntnr_d; + +alter table acl_container_relation drop constraint fk_acl_cntnr_rltn_cl_ntry_d; +drop index ix_acl_cntnr_rltn_cl_ntry_d; + +alter table addr drop constraint fk_addr_employee_id; +drop index ix_addr_employee_id; + +alter table o_address drop constraint fk_o_address_country_code; +drop index ix_o_address_country_code; + +alter table album drop constraint fk_album_cover_id; + +alter table animal drop constraint fk_animal_shelter_id; +drop index ix_animal_shelter_id; + +alter table attribute drop constraint fk_attrbt_ttrbt_hldr_d; +drop index ix_attrbt_ttrbt_hldr_d; + +alter table bbookmark drop constraint fk_bbookmark_user_id; +drop index ix_bbookmark_user_id; + +alter table bbookmark_user drop constraint fk_bbookmark_user_org_id; +drop index ix_bbookmark_user_org_id; + +alter table bsite_user_a drop constraint fk_bsite_user_a_site_id; +drop index ix_bsite_user_a_site_id; + +alter table bsite_user_a drop constraint fk_bsite_user_a_user_id; +drop index ix_bsite_user_a_user_id; + +alter table bsite_user_b drop constraint fk_bsite_user_b_site; +drop index ix_bsite_user_b_site; + +alter table bsite_user_b drop constraint fk_bsite_user_b_usr; +drop index ix_bsite_user_b_usr; + +alter table bsite_user_c drop constraint fk_bsite_user_c_site_uid; +drop index ix_bsite_user_c_site_uid; + +alter table bsite_user_c drop constraint fk_bsite_user_c_user_uid; +drop index ix_bsite_user_c_user_uid; + +alter table bsite_user_e drop constraint fk_bsite_user_e_site_id; +drop index ix_bsite_user_e_site_id; + +alter table bsite_user_e drop constraint fk_bsite_user_e_user_id; +drop index ix_bsite_user_e_user_id; + +alter table basic_draftable_bean drop constraint fk_basic_draftable_bean_id; + +alter table drel_booking drop constraint fk_drel_booking_agent_invoice; + +alter table drel_booking drop constraint fk_drl_bkng_clnt_nvc; + +alter table cepproduct_category drop constraint fk_cpprdct_ctgry_ctgry_d; +drop index ix_cpprdct_ctgry_ctgry_d; + +alter table cepproduct_category drop constraint fk_cpprdct_ctgry_prdct_d; +drop index ix_cpprdct_ctgry_prdct_d; + +alter table ciaddress drop constraint fk_ciaddress_street_id; +drop index ix_ciaddress_street_id; + +alter table cicustomer_parent drop constraint fk_ccstmr_prnt_ddrss_d; +drop index ix_ccstmr_prnt_ddrss_d; + +alter table cinh_ref drop constraint fk_cinh_ref_ref_id; +drop index ix_cinh_ref_ref_id; + +alter table ckey_detail drop constraint fk_ckey_detail_parent; +drop index ix_ckey_detail_parent; + +alter table ckey_parent drop constraint fk_ckey_parent_assoc_id; +drop index ix_ckey_parent_assoc_id; + +alter table coone_many drop constraint fk_coone_many_coone_id; +drop index ix_coone_many_coone_id; + +alter table coroot drop constraint fk_coroot_one_id; + +alter table calculation_result drop constraint fk_clcltn_rslt_prdct_cnfgrt_1; +drop index ix_clcltn_rslt_prdct_cnfgrt_1; + +alter table calculation_result drop constraint fk_clcltn_rslt_grp_cnfgrtn_d; +drop index ix_clcltn_rslt_grp_cnfgrtn_d; + +alter table sp_car_car_wheels drop constraint fk_sp_cr_cr_whls_sp_cr_cr; +drop index ix_sp_cr_cr_whls_sp_cr_cr; + +alter table sp_car_car_wheels drop constraint fk_sp_cr_cr_whls_sp_cr_whl; +drop index ix_sp_cr_cr_whls_sp_cr_whl; + +alter table sp_car_car_doors drop constraint fk_sp_cr_cr_drs_sp_cr_cr; +drop index ix_sp_cr_cr_drs_sp_cr_cr; + +alter table sp_car_car_doors drop constraint fk_sp_cr_cr_drs_sp_cr_dr; +drop index ix_sp_cr_cr_drs_sp_cr_dr; + +alter table car_accessory drop constraint fk_car_accessory_fuse_id; +drop index ix_car_accessory_fuse_id; + +alter table car_accessory drop constraint fk_car_accessory_car_id; +drop index ix_car_accessory_car_id; + +alter table category drop constraint fk_category_surveyobjectid; +drop index ix_category_surveyobjectid; + +alter table e_save_test_d drop constraint fk_e_save_test_d_parent_id; + +alter table child_person drop constraint fk_child_person_some_bean_id; +drop index ix_child_person_some_bean_id; + +alter table child_person drop constraint fk_chld_prsn_prnt_dntfr; +drop index ix_chld_prsn_prnt_dntfr; + +alter table cke_client drop constraint fk_cke_client_user; +drop index ix_cke_client_user; + +alter table class_super_monkey drop constraint fk_clss_spr_mnky_clss_spr; + +alter table class_super_monkey drop constraint fk_class_super_monkey_monkey; + +alter table configuration drop constraint fk_cnfgrtn_cnfgrtns_d; +drop index ix_cnfgrtn_cnfgrtns_d; + +alter table contact drop constraint fk_contact_customer_id; +drop index ix_contact_customer_id; + +alter table contact drop constraint fk_contact_group_id; +drop index ix_contact_group_id; + +alter table contact_note drop constraint fk_contact_note_contact_id; +drop index ix_contact_note_contact_id; + +alter table contract_costs drop constraint fk_contract_costs_position_id; +drop index ix_contract_costs_position_id; + +alter table c_conversation drop constraint fk_c_conversation_group_id; +drop index ix_c_conversation_group_id; + +alter table o_customer drop constraint fk_o_cstmr_bllng_ddrss_d; +drop index ix_o_cstmr_bllng_ddrss_d; + +alter table o_customer drop constraint fk_o_cstmr_shppng_ddrss_d; +drop index ix_o_cstmr_shppng_ddrss_d; + +alter table dcredit_drol drop constraint fk_dcredit_drol_dcredit; +drop index ix_dcredit_drol_dcredit; + +alter table dcredit_drol drop constraint fk_dcredit_drol_drol; +drop index ix_dcredit_drol_drol; + +alter table dmachine drop constraint fk_dmachine_organisation_id; +drop index ix_dmachine_organisation_id; + +alter table d_machine_aux_use drop constraint fk_d_mchn_x_s_mchn_d; +drop index ix_d_mchn_x_s_mchn_d; + +alter table d_machine_stats drop constraint fk_d_machine_stats_machine_id; +drop index ix_d_machine_stats_machine_id; + +alter table d_machine_use drop constraint fk_d_machine_use_machine_id; +drop index ix_d_machine_use_machine_id; + +alter table drot_drol drop constraint fk_drot_drol_drot; +drop index ix_drot_drol_drot; + +alter table drot_drol drop constraint fk_drot_drol_drol; +drop index ix_drot_drol_drol; + +alter table dc_detail drop constraint fk_dc_detail_master_id; +drop index ix_dc_detail_master_id; + +alter table dfk_cascade drop constraint fk_dfk_cascade_one_id; +drop index ix_dfk_cascade_one_id; + +alter table dfk_set_null drop constraint fk_dfk_set_null_one_id; +drop index ix_dfk_set_null_one_id; + +alter table doc drop constraint fk_doc_id; + +alter table doc_link drop constraint fk_doc_link_doc; +drop index ix_doc_link_doc; + +alter table doc_link drop constraint fk_doc_link_link; +drop index ix_doc_link_link; + +alter table document drop constraint fk_document_id; + +alter table document drop constraint fk_document_organisation_id; +drop index ix_document_organisation_id; + +alter table document_draft drop constraint fk_dcmnt_drft_rgnstn_d; +drop index ix_dcmnt_drft_rgnstn_d; + +alter table document_media drop constraint fk_document_media_document_id; +drop index ix_document_media_document_id; + +alter table document_media_draft drop constraint fk_dcmnt_md_drft_dcmnt_d; +drop index ix_dcmnt_md_drft_dcmnt_d; + +alter table e_basicenc_relate drop constraint fk_e_basicenc_relate_other_id; +drop index ix_e_basicenc_relate_other_id; + +alter table ebasic_json_map_detail drop constraint fk_ebsc_jsn_mp_dtl_wnr_d; +drop index ix_ebsc_jsn_mp_dtl_wnr_d; + +alter table ebasic_no_sdchild drop constraint fk_ebasic_no_sdchild_owner_id; +drop index ix_ebasic_no_sdchild_owner_id; + +alter table ebasic_sdchild drop constraint fk_ebasic_sdchild_owner_id; +drop index ix_ebasic_sdchild_owner_id; + +alter table ecache_child drop constraint fk_ecache_child_root_id; +drop index ix_ecache_child_root_id; + +alter table edefault_prop drop constraint fk_edflt_prp__smpl_srtypd; + +alter table eemb_inner drop constraint fk_eemb_inner_outer_id; +drop index ix_eemb_inner_outer_id; + +alter table einvoice drop constraint fk_einvoice_person_id; +drop index ix_einvoice_person_id; + +alter table enull_collection_detail drop constraint fk_enll_cllctn_dtl_nll_cllc_1; +drop index ix_enll_cllctn_dtl_nll_cllc_1; + +alter table eopt_one_a drop constraint fk_eopt_one_a_b_id; +drop index ix_eopt_one_a_b_id; + +alter table eopt_one_b drop constraint fk_eopt_one_b_c_id; +drop index ix_eopt_one_b_c_id; + +alter table eper_addr drop constraint fk_eper_addr_ma_country_code; +drop index ix_eper_addr_ma_country_code; + +alter table esoft_del_book drop constraint fk_esoft_del_book_lend_by_id; +drop index ix_esoft_del_book_lend_by_id; + +alter table esoft_del_book_esoft_del_user drop constraint fk_esft_dl_bk_sft_dl_sr_sft_1; +drop index ix_esft_dl_bk_sft_dl_sr_sft_1; + +alter table esoft_del_book_esoft_del_user drop constraint fk_esft_dl_bk_sft_dl_sr_sft_2; +drop index ix_esft_dl_bk_sft_dl_sr_sft_2; + +alter table esoft_del_down drop constraint fk_esft_dl_dwn_sft_dl_md_d; +drop index ix_esft_dl_dwn_sft_dl_md_d; + +alter table esoft_del_mid drop constraint fk_esoft_del_mid_top_id; +drop index ix_esoft_del_mid_top_id; + +alter table esoft_del_mid drop constraint fk_esoft_del_mid_up_id; +drop index ix_esoft_del_mid_up_id; + +alter table esoft_del_one_a drop constraint fk_esoft_del_one_a_oneb_id; + +alter table esoft_del_role_esoft_del_user drop constraint fk_esft_dl_rl_sft_dl_sr_sft_1; +drop index ix_esft_dl_rl_sft_dl_sr_sft_1; + +alter table esoft_del_role_esoft_del_user drop constraint fk_esft_dl_rl_sft_dl_sr_sft_2; +drop index ix_esft_dl_rl_sft_dl_sr_sft_2; + +alter table esoft_del_user_esoft_del_role drop constraint fk_esft_dl_sr_sft_dl_rl_sft_1; +drop index ix_esft_dl_sr_sft_dl_rl_sft_1; + +alter table esoft_del_user_esoft_del_role drop constraint fk_esft_dl_sr_sft_dl_rl_sft_2; +drop index ix_esft_dl_sr_sft_dl_rl_sft_2; + +alter table rawinherit_uncle drop constraint fk_rawinherit_uncle_parent_id; +drop index ix_rawinherit_uncle_parent_id; + +alter table evanilla_collection_detail drop constraint fk_evnll_cllctn_dtl_vnll_cl_1; +drop index ix_evnll_cllctn_dtl_vnll_cl_1; + +alter table ec_enum_person_tags drop constraint fk_ec_nm_prsn_tgs_c_nm_prsn_d; +drop index ix_ec_nm_prsn_tgs_c_nm_prsn_d; + +alter table ec_person_phone drop constraint fk_ec_person_phone_owner_id; +drop index ix_ec_person_phone_owner_id; + +alter table ec_top drop constraint fk_ec_top_person_id; +drop index ix_ec_top_person_id; + +alter table ec_top_ecs_person drop constraint fk_ec_top_ecs_person_ec_top; +drop index ix_ec_top_ecs_person_ec_top; + +alter table ec_top_ecs_person drop constraint fk_ec_tp_cs_prsn_cs_prsn; +drop index ix_ec_tp_cs_prsn_cs_prsn; + +alter table ecbl_person_phone_numbers drop constraint fk_ecbl_prsn_phn_nmbrs_prsn_d; +drop index ix_ecbl_prsn_phn_nmbrs_prsn_d; + +alter table ecbm_person_phone_numbers drop constraint fk_ecbm_prsn_phn_nmbrs_prsn_d; +drop index ix_ecbm_prsn_phn_nmbrs_prsn_d; + +alter table ecm_person_phone_numbers drop constraint fk_ecm_prsn_phn_nmbrs_cm_pr_1; +drop index ix_ecm_prsn_phn_nmbrs_cm_pr_1; + +alter table ecmc_person_phone_numbers drop constraint fk_ecmc_prsn_phn_nmbrs_cmc__1; +drop index ix_ecmc_prsn_phn_nmbrs_cmc__1; + +alter table ecs_person_phone drop constraint fk_ecs_prsn_phn_cs_prsn_d; +drop index ix_ecs_prsn_phn_cs_prsn_d; + +alter table ecsm_child drop constraint fk_ecsm_child_ecsm_parent_id; +drop index ix_ecsm_child_ecsm_parent_id; + +alter table td_child drop constraint fk_td_child_parent_id; +drop index ix_td_child_parent_id; + +alter table element_bean drop constraint fk_elmnt_bn_cmplx_bn_d; +drop index ix_elmnt_bn_cmplx_bn_d; + +alter table empl drop constraint fk_empl_default_address_id; +drop index ix_empl_default_address_id; + +alter table esd_detail drop constraint fk_esd_detail_master_id; +drop index ix_esd_detail_master_id; + +alter table grand_parent_person drop constraint fk_grnd_prnt_prsn_sm_bn_d; +drop index ix_grnd_prnt_prsn_sm_bn_d; + +alter table survey_group drop constraint fk_srvy_grp_ctgrybjctd; +drop index ix_srvy_grp_ctgrybjctd; + +alter table hx_link_doc drop constraint fk_hx_link_doc_hx_link; +drop index ix_hx_link_doc_hx_link; + +alter table hx_link_doc drop constraint fk_hx_link_doc_he_doc; +drop index ix_hx_link_doc_he_doc; + +alter table hi_link_doc drop constraint fk_hi_link_doc_hi_link; +drop index ix_hi_link_doc_hi_link; + +alter table hi_link_doc drop constraint fk_hi_link_doc_hi_doc; +drop index ix_hi_link_doc_hi_doc; + +alter table hi_tthree drop constraint fk_hi_tthree_hi_ttwo_id; +drop index ix_hi_tthree_hi_ttwo_id; + +alter table hi_ttwo drop constraint fk_hi_ttwo_hi_tone_id; +drop index ix_hi_ttwo_hi_tone_id; + +alter table hsd_setting drop constraint fk_hsd_setting_user_id; + +alter table iaf_segment drop constraint fk_iaf_segment_status_id; +drop index ix_iaf_segment_status_id; + +alter table imrelated drop constraint fk_imrelated_owner_id; +drop index ix_imrelated_owner_id; + +alter table info_contact drop constraint fk_info_contact_company_id; +drop index ix_info_contact_company_id; + +alter table info_customer drop constraint fk_info_customer_company_id; + +alter table inner_report drop constraint fk_inner_report_forecast_id; + +alter table drel_invoice drop constraint fk_drel_invoice_booking; +drop index ix_drel_invoice_booking; + +alter table item drop constraint fk_item_etype; +drop index ix_item_etype; + +alter table item drop constraint fk_item_eregion; +drop index ix_item_eregion; + +alter table mkeygroup_monkey drop constraint fk_mkeygroup_monkey_mkeygroup; + +alter table mkeygroup_monkey drop constraint fk_mkeygroup_monkey_monkey; + +alter table trainer_monkey drop constraint fk_trainer_monkey_trainer; + +alter table trainer_monkey drop constraint fk_trainer_monkey_monkey; + +alter table troop_monkey drop constraint fk_troop_monkey_troop; + +alter table troop_monkey drop constraint fk_troop_monkey_monkey; + +alter table l2_cldf_reset_bean_child drop constraint fk_l2_cldf_rst_bn_chld_prnt_d; +drop index ix_l2_cldf_rst_bn_chld_prnt_d; + +alter table level1_level4 drop constraint fk_level1_level4_level1; +drop index ix_level1_level4_level1; + +alter table level1_level4 drop constraint fk_level1_level4_level4; +drop index ix_level1_level4_level4; + +alter table level1_level2 drop constraint fk_level1_level2_level1; +drop index ix_level1_level2_level1; + +alter table level1_level2 drop constraint fk_level1_level2_level2; +drop index ix_level1_level2_level2; + +alter table level2_level3 drop constraint fk_level2_level3_level2; +drop index ix_level2_level3_level2; + +alter table level2_level3 drop constraint fk_level2_level3_level3; +drop index ix_level2_level3_level3; + +alter table link drop constraint fk_link_id; + +alter table la_attr_value_attribute drop constraint fk_l_ttr_vl_ttrbt_l_ttr_vl; +drop index ix_l_ttr_vl_ttrbt_l_ttr_vl; + +alter table la_attr_value_attribute drop constraint fk_l_ttr_vl_ttrbt_ttrbt; +drop index ix_l_ttr_vl_ttrbt_ttrbt; + +alter table looney drop constraint fk_looney_tune_id; +drop index ix_looney_tune_id; + +alter table mcontact drop constraint fk_mcontact_customer_id; +drop index ix_mcontact_customer_id; + +alter table mcontact_message drop constraint fk_mcntct_mssg_cntct_d; +drop index ix_mcntct_mssg_cntct_d; + +alter table mcustomer drop constraint fk_mcstmr_shppng_ddrss_d; +drop index ix_mcstmr_shppng_ddrss_d; + +alter table mcustomer drop constraint fk_mcstmr_bllng_ddrss_d; +drop index ix_mcstmr_bllng_ddrss_d; + +alter table mmachine_mgroup drop constraint fk_mmachine_mgroup_mmachine; +drop index ix_mmachine_mgroup_mmachine; + +alter table mmachine_mgroup drop constraint fk_mmachine_mgroup_mgroup; +drop index ix_mmachine_mgroup_mgroup; + +alter table mprinter drop constraint fk_mprinter_current_state_id; +drop index ix_mprinter_current_state_id; + +alter table mprinter drop constraint fk_mprinter_last_swap_cyan_id; + +alter table mprinter drop constraint fk_mprntr_lst_swp_mgnt_d; + +alter table mprinter drop constraint fk_mprntr_lst_swp_yllw_d; + +alter table mprinter drop constraint fk_mprntr_lst_swp_blck_d; + +alter table mprinter_state drop constraint fk_mprinter_state_printer_id; +drop index ix_mprinter_state_printer_id; + +alter table mprofile drop constraint fk_mprofile_picture_id; +drop index ix_mprofile_picture_id; + +alter table mrole_muser drop constraint fk_mrole_muser_mrole; +drop index ix_mrole_muser_mrole; + +alter table mrole_muser drop constraint fk_mrole_muser_muser; +drop index ix_mrole_muser_muser; + +alter table muser drop constraint fk_muser_user_type_id; +drop index ix_muser_user_type_id; + +alter table mail_user_inbox drop constraint fk_mail_user_inbox_mail_user; +drop index ix_mail_user_inbox_mail_user; + +alter table mail_user_inbox drop constraint fk_mail_user_inbox_mail_box; +drop index ix_mail_user_inbox_mail_box; + +alter table mail_user_outbox drop constraint fk_mail_user_outbox_mail_user; +drop index ix_mail_user_outbox_mail_user; + +alter table mail_user_outbox drop constraint fk_mail_user_outbox_mail_box; +drop index ix_mail_user_outbox_mail_box; + +alter table c_message drop constraint fk_c_message_conversation_id; +drop index ix_c_message_conversation_id; + +alter table c_message drop constraint fk_c_message_user_id; +drop index ix_c_message_user_id; + +alter table meter_contract_data drop constraint fk_mtr_cntrct_dt_spcl_nds_c_1; + +alter table meter_special_needs_client drop constraint fk_mtr_spcl_nds_clnt_prmry_d; + +alter table meter_version drop constraint fk_mtr_vrsn_ddrss_dt_d; + +alter table meter_version drop constraint fk_mtr_vrsn_cntrct_dt_d; + +alter table mnoc_user_mnoc_role drop constraint fk_mnc_sr_mnc_rl_mnc_sr; +drop index ix_mnc_sr_mnc_rl_mnc_sr; + +alter table mnoc_user_mnoc_role drop constraint fk_mnc_sr_mnc_rl_mnc_rl; +drop index ix_mnc_sr_mnc_rl_mnc_rl; + +alter table mny_b drop constraint fk_mny_b_a_id; +drop index ix_mny_b_a_id; + +alter table mny_b_mny_c drop constraint fk_mny_b_mny_c_mny_b; +drop index ix_mny_b_mny_c_mny_b; + +alter table mny_b_mny_c drop constraint fk_mny_b_mny_c_mny_c; +drop index ix_mny_b_mny_c_mny_c; + +alter table subtopics drop constraint fk_subtopics_mny_topic_1; +drop index ix_subtopics_mny_topic_1; + +alter table subtopics drop constraint fk_subtopics_mny_topic_2; +drop index ix_subtopics_mny_topic_2; + +alter table mp_role drop constraint fk_mp_role_mp_user_id; +drop index ix_mp_role_mp_user_id; + +alter table ms_many_a_many_b drop constraint fk_ms_many_a_many_b_ms_many_a; +drop index ix_ms_many_a_many_b_ms_many_a; + +alter table ms_many_a_many_b drop constraint fk_ms_many_a_many_b_ms_many_b; +drop index ix_ms_many_a_many_b_ms_many_b; + +alter table ms_many_b_many_a drop constraint fk_ms_many_b_many_a_ms_many_b; +drop index ix_ms_many_b_many_a_ms_many_b; + +alter table ms_many_b_many_a drop constraint fk_ms_many_b_many_a_ms_many_a; +drop index ix_ms_many_b_many_a_ms_many_a; + +alter table my_lob_size_join_many drop constraint fk_my_lb_sz_jn_mny_prnt_d; +drop index ix_my_lb_sz_jn_mny_prnt_d; + +alter table o_bean_child drop constraint fk_o_bn_chld_cchd_bn_d; +drop index ix_o_bn_chld_cchd_bn_d; + +alter table ocached_app_detail drop constraint fk_ocached_app_detail_app_id; +drop index ix_ocached_app_detail_app_id; + +alter table o_cached_bean_country drop constraint fk_o_cchd_bn_cntry__cchd_bn; +drop index ix_o_cchd_bn_cntry__cchd_bn; + +alter table o_cached_bean_country drop constraint fk_o_cchd_bn_cntry__cntry; +drop index ix_o_cchd_bn_cntry__cntry; + +alter table o_cached_bean_child drop constraint fk_o_cchd_bn_chld_cchd_bn_d; +drop index ix_o_cchd_bn_chld_cchd_bn_d; + +alter table oengine drop constraint fk_oengine_car_id; + +alter table ogear_box drop constraint fk_ogear_box_car_id; + +alter table omvertex_other drop constraint fk_omvertex_other_omvertex_id; +drop index ix_omvertex_other_omvertex_id; + +alter table oroad_show_msg drop constraint fk_oroad_show_msg_company_id; + +alter table om_account_child_dbo drop constraint fk_om_ccnt_chld_db_bnn_rm_d; +drop index ix_om_ccnt_chld_db_bnn_rm_d; + +alter table om_basic_child drop constraint fk_om_basic_child_parent_id; +drop index ix_om_basic_child_parent_id; + +alter table om_ordered_detail drop constraint fk_om_rdrd_dtl_mstr_d; +drop index ix_om_rdrd_dtl_mstr_d; + +alter table o_order drop constraint fk_o_order_kcustomer_id; +drop index ix_o_order_kcustomer_id; + +alter table o_order_detail drop constraint fk_o_order_detail_order_id; +drop index ix_o_order_detail_order_id; + +alter table o_order_detail drop constraint fk_o_order_detail_product_id; +drop index ix_o_order_detail_product_id; + +alter table s_order_items drop constraint fk_s_order_items_order_uuid; +drop index ix_s_order_items_order_uuid; + +alter table or_order_ship drop constraint fk_or_order_ship_order_id; +drop index ix_or_order_ship_order_id; + +alter table organization_node drop constraint fk_orgnztn_nd_prnt_tr_nd_d; + +alter table orp_detail drop constraint fk_orp_detail_master_id; +drop index ix_orp_detail_master_id; + +alter table orp_detail2 drop constraint fk_orp_detail2_orp_master2_id; +drop index ix_orp_detail2_orp_master2_id; + +alter table oto_atwo drop constraint fk_oto_atwo_aone_id; + +alter table oto_bchild drop constraint fk_oto_bchild_master_id; + +alter table oto_child drop constraint fk_oto_child_master_id; + +alter table oto_cust_address drop constraint fk_ot_cst_ddrss_cstmr_cd; + +alter table oto_level_a drop constraint fk_oto_level_a_b_id; + +alter table oto_level_b drop constraint fk_oto_level_b_c_id; + +alter table oto_prime_extra drop constraint fk_oto_prime_extra_eid; + +alter table oto_sd_child drop constraint fk_oto_sd_child_master_id; + +alter table oto_th_many drop constraint fk_oto_th_many_oto_th_top_id; +drop index ix_oto_th_many_oto_th_top_id; + +alter table oto_th_one drop constraint fk_oto_th_one_many_id; + +alter table oto_ubprime_extra drop constraint fk_oto_ubprime_extra_eid; + +alter table oto_user_model drop constraint fk_ot_sr_mdl_sr_ptnl_d; + +alter table pfile drop constraint fk_pfile_file_content_id; + +alter table pfile drop constraint fk_pfile_file_content2_id; + +alter table paggview drop constraint fk_paggview_pview_id; + +alter table pallet_location drop constraint fk_pallet_location_zone_sid; +drop index ix_pallet_location_zone_sid; + +alter table parcel_location drop constraint fk_parcel_location_parcelid; + +alter table rawinherit_parent_rawinherit_d drop constraint fk_rwnhrt_prnt_rwnhrt_d_rwn_1; +drop index ix_rwnhrt_prnt_rwnhrt_d_rwn_1; + +alter table rawinherit_parent_rawinherit_d drop constraint fk_rwnhrt_prnt_rwnhrt_d_rwn_2; +drop index ix_rwnhrt_prnt_rwnhrt_d_rwn_2; + +alter table parent_person drop constraint fk_parent_person_some_bean_id; +drop index ix_parent_person_some_bean_id; + +alter table parent_person drop constraint fk_prnt_prsn_prnt_dntfr; +drop index ix_prnt_prsn_prnt_dntfr; + +alter table c_participation drop constraint fk_c_prtcptn_cnvrstn_d; +drop index ix_c_prtcptn_cnvrstn_d; + +alter table c_participation drop constraint fk_c_participation_user_id; +drop index ix_c_participation_user_id; + +alter table pcf_calendar drop constraint fk_pcf_calendar_pcf_person_id; +drop index ix_pcf_calendar_pcf_person_id; + +alter table pcf_city drop constraint fk_pcf_city_pcf_country_id; +drop index ix_pcf_city_pcf_country_id; + +alter table pcf_city drop constraint fk_pcf_city_mayor_id; + +alter table pcf_city drop constraint fk_pcf_city_vice_mayor_id; + +alter table pcf_event drop constraint fk_pcf_event_pcf_calendar_id; +drop index ix_pcf_event_pcf_calendar_id; + +alter table persistent_file_content drop constraint fk_prsstnt_fl_cntnt_prsstnt_1; + +alter table person drop constraint fk_person_default_address_oid; +drop index ix_person_default_address_oid; + +alter table person_cache_email drop constraint fk_prsn_cch_ml_prsn_nf_prsn_d; +drop index ix_prsn_cch_ml_prsn_nf_prsn_d; + +alter table phones drop constraint fk_phones_person_id; +drop index ix_phones_person_id; + +alter table e_position drop constraint fk_e_position_contract_id; +drop index ix_e_position_contract_id; + +alter table pp_to_ww drop constraint fk_pp_to_ww_pp; +drop index ix_pp_to_ww_pp; + +alter table pp_to_ww drop constraint fk_pp_to_ww_wview; +drop index ix_pp_to_ww_wview; + +alter table question drop constraint fk_question_groupobjectid; +drop index ix_question_groupobjectid; + +alter table r_orders drop constraint fk_r_orders_customer; +drop index ix_r_orders_customer; + +alter table rel_master drop constraint fk_rel_master_detail_id; +drop index ix_rel_master_detail_id; + +alter table resourcefile drop constraint fk_rsrcfl_prntrsrcfld; +drop index ix_rsrcfl_prntrsrcfld; + +alter table mt_role drop constraint fk_mt_role_tenant_id; +drop index ix_mt_role_tenant_id; + +alter table mt_role_permission drop constraint fk_mt_role_permission_mt_role; +drop index ix_mt_role_permission_mt_role; + +alter table mt_role_permission drop constraint fk_mt_rl_prmssn_mt_prmssn; +drop index ix_mt_rl_prmssn_mt_prmssn; + +alter table root_bean drop constraint fk_rt_bn_rfrncng_bn_d; +drop index ix_rt_bn_rfrncng_bn_d; + +alter table f_second drop constraint fk_f_second_first; + +alter table section drop constraint fk_section_article_id; +drop index ix_section_article_id; + +alter table self_parent drop constraint fk_self_parent_parent_id; +drop index ix_self_parent_parent_id; + +alter table self_ref_customer drop constraint fk_slf_rf_cstmr_rfrrd_by_d; +drop index ix_slf_rf_cstmr_rfrrd_by_d; + +alter table self_ref_example drop constraint fk_self_ref_example_parent_id; +drop index ix_self_ref_example_parent_id; + +alter table e_save_test_b drop constraint fk_e_save_test_b_sibling_a_id; + +alter table site drop constraint fk_site_parent_id; +drop index ix_site_parent_id; + +alter table site drop constraint fk_site_data_container_id; + +alter table site drop constraint fk_site_site_address_id; + +alter table source_base drop constraint fk_source_base_target_id; +drop index ix_source_base_target_id; + +alter table stockforecast drop constraint fk_stckfrcst_nnr_rprt_d; +drop index ix_stckfrcst_nnr_rprt_d; + +alter table sub_section drop constraint fk_sub_section_section_id; +drop index ix_sub_section_section_id; + +alter table tevent_many drop constraint fk_tevent_many_event_id; +drop index ix_tevent_many_event_id; + +alter table tevent_one drop constraint fk_tevent_one_event_id; + +alter table t_detail_with_other_namexxxyy drop constraint fk_t_dtl_wth_thr_nmxxxyy_ms_1; +drop index ix_t_dtl_wth_thr_nmxxxyy_ms_1; + +alter table ttruck_holder drop constraint fk_ttrck_hldr_trck_plt_n; +drop index ix_ttrck_hldr_trck_plt_n; + +alter table ttruck_holder drop constraint fk_ttruck_holder_basic_id; +drop index ix_ttruck_holder_basic_id; + +alter table ttruck_holder_item drop constraint fk_ttrck_hldr_tm_wnr_d; +drop index ix_ttrck_hldr_tm_wnr_d; + +alter table twheel drop constraint fk_twheel_owner_plate_no; +drop index ix_twheel_owner_plate_no; + +alter table tire drop constraint fk_tire_wheel; + +alter table tree_entity drop constraint fk_tree_entity_parent_id; +drop index ix_tree_entity_parent_id; + +alter table trip drop constraint fk_trip_vehicle_driver_id; +drop index ix_trip_vehicle_driver_id; + +alter table trip drop constraint fk_trip_address_id; +drop index ix_trip_address_id; + +alter table "type" drop constraint fk_type_sub_type_id; +drop index ix_type_sub_type_id; + +alter table usib_child drop constraint fk_usib_child_parent_id; +drop index ix_usib_child_parent_id; + +alter table usib_child_sibling drop constraint fk_usb_chld_sblng_chld_d; + +alter table ut_detail drop constraint fk_ut_detail_utmaster_id; +drop index ix_ut_detail_utmaster_id; + +alter table uutwo drop constraint fk_uutwo_master_id; +drop index ix_uutwo_master_id; + +alter table oto_user drop constraint fk_oto_user_account_id; + +alter table c_user drop constraint fk_c_user_group_id; +drop index ix_c_user_group_id; + +alter table em_user_role drop constraint fk_em_user_role_user_id; +drop index ix_em_user_role_user_id; + +alter table em_user_role drop constraint fk_em_user_role_role_id; +drop index ix_em_user_role_role_id; + +alter table vehicle drop constraint fk_vehicle_lease_id; +drop index ix_vehicle_lease_id; + +alter table vehicle drop constraint fk_vehicle_car_ref_id; +drop index ix_vehicle_car_ref_id; + +alter table vehicle drop constraint fk_vehicle_truck_ref_id; +drop index ix_vehicle_truck_ref_id; + +alter table vehicle_driver drop constraint fk_vehicle_driver_vehicle_id; +drop index ix_vehicle_driver_vehicle_id; + +alter table vehicle_driver drop constraint fk_vehicle_driver_address_id; +drop index ix_vehicle_driver_address_id; + +alter table warehouses drop constraint fk_warehouses_officezoneid; +drop index ix_warehouses_officezoneid; + +alter table warehousesshippingzones drop constraint fk_wrhssshppngzns_wrhss; +drop index ix_wrhssshppngzns_wrhss; + +alter table warehousesshippingzones drop constraint fk_wrhssshppngzns_zns; +drop index ix_wrhssshppngzns_zns; + +alter table sa_wheel drop constraint fk_sa_wheel_tire; +drop index ix_sa_wheel_tire; + +alter table sa_wheel drop constraint fk_sa_wheel_car; +drop index ix_sa_wheel_car; + +alter table g_who_props_otm drop constraint fk_g_wh_prps_tm_wh_crtd_d; +drop index ix_g_wh_prps_tm_wh_crtd_d; + +alter table g_who_props_otm drop constraint fk_g_wh_prps_tm_wh_mdfd_d; +drop index ix_g_wh_prps_tm_wh_mdfd_d; + +alter table with_zero drop constraint fk_with_zero_parent_id; +drop index ix_with_zero_parent_id; + +drop table asimple_bean cascade constraints purge; + +drop table bar cascade constraints purge; + +drop table block cascade constraints purge; + +drop table oto_account cascade constraints purge; + +drop table acl cascade constraints purge; + +drop table acl_container_relation cascade constraints purge; + +drop table addr cascade constraints purge; + +drop table address cascade constraints purge; + +drop table o_address cascade constraints purge; + +drop table album cascade constraints purge; + +drop table animal cascade constraints purge; + +drop table animal_shelter cascade constraints purge; + +drop table article cascade constraints purge; + +drop table attribute cascade constraints purge; + +drop table attribute_holder cascade constraints purge; + +drop table audit_log cascade constraints purge; + +drop table bbookmark cascade constraints purge; + +drop table bbookmark_org cascade constraints purge; + +drop table bbookmark_user cascade constraints purge; + +drop table bsimple_with_gen cascade constraints purge; + +drop table bsite cascade constraints purge; + +drop table bsite_user_a cascade constraints purge; + +drop table bsite_user_b cascade constraints purge; + +drop table bsite_user_c cascade constraints purge; + +drop table bsite_user_d cascade constraints purge; + +drop table bsite_user_e cascade constraints purge; + +drop table buser cascade constraints purge; + +drop table bwith_qident cascade constraints purge; + +drop table basic_draftable_bean cascade constraints purge; + +drop table basic_draftable_bean_draft cascade constraints purge; + +drop table basic_joda_entity cascade constraints purge; + +drop table bean_with_time_zone cascade constraints purge; + +drop table drel_booking cascade constraints purge; +drop sequence drel_booking_seq; + +drop table bw_bean cascade constraints purge; + +drop table cepcategory cascade constraints purge; + +drop table cepproduct cascade constraints purge; + +drop table cepproduct_category cascade constraints purge; + +drop table ciaddress cascade constraints purge; + +drop table cicustomer_parent cascade constraints purge; + +drop table cistreet_parent cascade constraints purge; + +drop table cinh_ref cascade constraints purge; + +drop table cinh_root cascade constraints purge; + +drop table ckey_assoc cascade constraints purge; + +drop table ckey_detail cascade constraints purge; + +drop table ckey_parent cascade constraints purge; + +drop table coone cascade constraints purge; + +drop table coone_many cascade constraints purge; + +drop table coroot cascade constraints purge; + +drop table calculation_result cascade constraints purge; + +drop table cao_bean cascade constraints purge; + +drop table sp_car_car cascade constraints purge; +drop sequence sp_car_car_seq; + +drop table sp_car_car_wheels cascade constraints purge; + +drop table sp_car_car_doors cascade constraints purge; + +drop table sa_car cascade constraints purge; +drop sequence sa_car_seq; + +drop table car_accessory cascade constraints purge; + +drop table car_fuse cascade constraints purge; + +drop table category cascade constraints purge; + +drop table e_save_test_d cascade constraints purge; + +drop table child_person cascade constraints purge; + +drop table cke_client cascade constraints purge; + +drop table cke_user cascade constraints purge; + +drop table class_super cascade constraints purge; + +drop table class_super_monkey cascade constraints purge; + +drop table configuration cascade constraints purge; + +drop table configurations cascade constraints purge; + +drop table contact cascade constraints purge; + +drop table contact_group cascade constraints purge; + +drop table contact_note cascade constraints purge; + +drop table contract cascade constraints purge; + +drop table contract_costs cascade constraints purge; + +drop table c_conversation cascade constraints purge; + +drop table o_country cascade constraints purge; + +drop table cover cascade constraints purge; + +drop table o_customer cascade constraints purge; + +drop table dcredit cascade constraints purge; + +drop table dcredit_drol cascade constraints purge; + +drop table dexh_entity cascade constraints purge; + +drop table dint_parent cascade constraints purge; + +drop table dmachine cascade constraints purge; + +drop table d_machine_aux_use cascade constraints purge; + +drop table d_machine_stats cascade constraints purge; + +drop table d_machine_use cascade constraints purge; + +drop table dorg cascade constraints purge; + +drop table dperson cascade constraints purge; + +drop table drol cascade constraints purge; + +drop table drot cascade constraints purge; + +drop table drot_drol cascade constraints purge; + +drop table rawinherit_data cascade constraints purge; + +drop table data_container cascade constraints purge; + +drop table dc_detail cascade constraints purge; + +drop table dc_master cascade constraints purge; + +drop table dfk_cascade cascade constraints purge; + +drop table dfk_cascade_one cascade constraints purge; + +drop table dfk_none cascade constraints purge; + +drop table dfk_none_via_join cascade constraints purge; + +drop table dfk_none_via_mto_m cascade constraints purge; + +drop table dfk_none_via_mto_m_dfk_one cascade constraints purge; + +drop table dfk_one cascade constraints purge; + +drop table dfk_set_null cascade constraints purge; + +drop table doc cascade constraints purge; + +drop table doc_link cascade constraints purge; + +drop table doc_link_draft cascade constraints purge; + +drop table doc_draft cascade constraints purge; + +drop table document cascade constraints purge; + +drop table document_draft cascade constraints purge; + +drop table document_media cascade constraints purge; + +drop table document_media_draft cascade constraints purge; + +drop table sp_car_door cascade constraints purge; +drop sequence sp_car_door_seq; + +drop table earray_bean cascade constraints purge; + +drop table earray_set_bean cascade constraints purge; + +drop table e_basic cascade constraints purge; + +drop table ebasic_change_log cascade constraints purge; + +drop table ebasic_clob cascade constraints purge; + +drop table ebasic_clob_fetch_eager cascade constraints purge; + +drop table ebasic_clob_no_ver cascade constraints purge; + +drop table e_basicenc cascade constraints purge; + +drop table e_basicenc_bin cascade constraints purge; + +drop table e_basicenc_client cascade constraints purge; + +drop table e_basicenc_relate cascade constraints purge; + +drop table e_basic_enum_id cascade constraints purge; + +drop table e_basic_eni cascade constraints purge; + +drop table ebasic_hstore cascade constraints purge; + +drop table ebasic_json_jackson cascade constraints purge; + +drop table ebasic_json_jackson2 cascade constraints purge; + +drop table ebasic_json_list cascade constraints purge; + +drop table ebasic_json_map cascade constraints purge; + +drop table ebasic_json_map_blob cascade constraints purge; + +drop table ebasic_json_map_clob cascade constraints purge; + +drop table ebasic_json_map_detail cascade constraints purge; + +drop table ebasic_json_map_json_b cascade constraints purge; + +drop table ebasic_json_map_varchar cascade constraints purge; + +drop table ebasic_json_node cascade constraints purge; + +drop table ebasic_json_node_blob cascade constraints purge; + +drop table ebasic_json_node_json_b cascade constraints purge; + +drop table ebasic_json_node_varchar cascade constraints purge; + +drop table ebasic_json_unmapped cascade constraints purge; + +drop table e_basic_ndc cascade constraints purge; + +drop table ebasic_no_sdchild cascade constraints purge; + +drop table ebasic_sdchild cascade constraints purge; + +drop table ebasic_soft_delete cascade constraints purge; + +drop table e_basicver cascade constraints purge; + +drop table e_basic_withlife cascade constraints purge; + +drop table e_basic_with_ex cascade constraints purge; + +drop table e_basicverucon cascade constraints purge; + +drop table ecache_child cascade constraints purge; + +drop table ecache_root cascade constraints purge; + +drop table e_col_ab cascade constraints purge; + +drop table ecustom_id cascade constraints purge; + +drop table edefault_prop cascade constraints purge; + +drop table eemb_inner cascade constraints purge; + +drop table eemb_outer cascade constraints purge; + +drop table efile2_no_fk cascade constraints purge; + +drop table efile_no_fk cascade constraints purge; + +drop table efile_no_fk_euser_no_fk cascade constraints purge; + +drop table efile_no_fk_euser_no_fk_soft_d cascade constraints purge; + +drop table egen_props cascade constraints purge; + +drop table eid_uid_bean cascade constraints purge; + +drop table einvoice cascade constraints purge; + +drop table e_main cascade constraints purge; + +drop table enull_collection cascade constraints purge; + +drop table enull_collection_detail cascade constraints purge; + +drop table eopt_one_a cascade constraints purge; + +drop table eopt_one_b cascade constraints purge; + +drop table eopt_one_c cascade constraints purge; + +drop table eper_addr cascade constraints purge; + +drop table eperson cascade constraints purge; + +drop table e_person_online cascade constraints purge; + +drop table esimple cascade constraints purge; + +drop table esoft_del_book cascade constraints purge; + +drop table esoft_del_book_esoft_del_user cascade constraints purge; + +drop table esoft_del_down cascade constraints purge; + +drop table esoft_del_mid cascade constraints purge; + +drop table esoft_del_one_a cascade constraints purge; + +drop table esoft_del_one_b cascade constraints purge; + +drop table esoft_del_role cascade constraints purge; + +drop table esoft_del_role_esoft_del_user cascade constraints purge; + +drop table esoft_del_top cascade constraints purge; + +drop table esoft_del_up cascade constraints purge; + +drop table esoft_del_user cascade constraints purge; + +drop table esoft_del_user_esoft_del_role cascade constraints purge; + +drop table esome_convert_type cascade constraints purge; + +drop table esome_type cascade constraints purge; + +drop table etrans_many cascade constraints purge; + +drop table rawinherit_uncle cascade constraints purge; + +drop table euser_no_fk cascade constraints purge; + +drop table euser_no_fk_soft_del cascade constraints purge; + +drop table evanilla_collection cascade constraints purge; + +drop table evanilla_collection_detail cascade constraints purge; + +drop table ewho_props cascade constraints purge; + +drop table e_withinet cascade constraints purge; + +drop table ec_enum_person cascade constraints purge; + +drop table ec_enum_person_tags cascade constraints purge; + +drop table ec_person cascade constraints purge; + +drop table ec_person_phone cascade constraints purge; + +drop table ec_top cascade constraints purge; + +drop table ec_top_ecs_person cascade constraints purge; + +drop table ecbl_person cascade constraints purge; + +drop table ecbl_person_phone_numbers cascade constraints purge; + +drop table ecbm_person cascade constraints purge; + +drop table ecbm_person_phone_numbers cascade constraints purge; + +drop table ecm_person cascade constraints purge; + +drop table ecm_person_phone_numbers cascade constraints purge; + +drop table ecmc_person cascade constraints purge; + +drop table ecmc_person_phone_numbers cascade constraints purge; + +drop table ecs_person cascade constraints purge; + +drop table ecs_person_phone cascade constraints purge; + +drop table ecsm_child cascade constraints purge; + +drop table ecsm_values cascade constraints purge; + +drop table ecsm_one cascade constraints purge; + +drop table ecsm_parent cascade constraints purge; + +drop table ecsm_two cascade constraints purge; + +drop table td_child cascade constraints purge; + +drop table td_parent cascade constraints purge; + +drop table element_bean cascade constraints purge; + +drop table empl cascade constraints purge; + +drop table esd_detail cascade constraints purge; + +drop table esd_master cascade constraints purge; + +drop table feature_desc cascade constraints purge; + +drop table f_first cascade constraints purge; + +drop table foo cascade constraints purge; + +drop table gen_key_identity cascade constraints purge; + +drop table gen_key_sequence cascade constraints purge; +drop sequence SEQ_NAME; + +drop table grand_parent_person cascade constraints purge; + +drop table survey_group cascade constraints purge; + +drop table c_group cascade constraints purge; + +drop table he_doc cascade constraints purge; + +drop table hx_link cascade constraints purge; + +drop table hx_link_doc cascade constraints purge; + +drop table hi_doc cascade constraints purge; + +drop table hi_link cascade constraints purge; + +drop table hi_link_doc cascade constraints purge; + +drop table hi_tone cascade constraints purge; + +drop table hi_tthree cascade constraints purge; + +drop table hi_ttwo cascade constraints purge; + +drop table hsd_setting cascade constraints purge; + +drop table hsd_user cascade constraints purge; + +drop table iaf_segment cascade constraints purge; + +drop table iaf_segment_status cascade constraints purge; + +drop table imrelated cascade constraints purge; + +drop table imroot cascade constraints purge; + +drop table ixresource cascade constraints purge; + +drop table info_company cascade constraints purge; + +drop table info_contact cascade constraints purge; + +drop table info_customer cascade constraints purge; + +drop table inner_report cascade constraints purge; + +drop table drel_invoice cascade constraints purge; +drop sequence drel_invoice_seq; + +drop table item cascade constraints purge; + +drop table monkey cascade constraints purge; + +drop table mkeygroup cascade constraints purge; + +drop table mkeygroup_monkey cascade constraints purge; + +drop table trainer cascade constraints purge; + +drop table trainer_monkey cascade constraints purge; + +drop table troop cascade constraints purge; + +drop table troop_monkey cascade constraints purge; + +drop table l2_cldf_reset_bean cascade constraints purge; + +drop table l2_cldf_reset_bean_child cascade constraints purge; + +drop table level1 cascade constraints purge; + +drop table level1_level4 cascade constraints purge; + +drop table level1_level2 cascade constraints purge; + +drop table level2 cascade constraints purge; + +drop table level2_level3 cascade constraints purge; + +drop table level3 cascade constraints purge; + +drop table level4 cascade constraints purge; + +drop table link cascade constraints purge; + +drop table link_draft cascade constraints purge; + +drop table la_attr_value cascade constraints purge; + +drop table la_attr_value_attribute cascade constraints purge; + +drop table looney cascade constraints purge; + +drop table maddress cascade constraints purge; + +drop table mcontact cascade constraints purge; + +drop table mcontact_message cascade constraints purge; + +drop table mcustomer cascade constraints purge; + +drop table mgroup cascade constraints purge; + +drop table mmachine cascade constraints purge; + +drop table mmachine_mgroup cascade constraints purge; + +drop table mmedia cascade constraints purge; + +drop table non_updateprop cascade constraints purge; + +drop table mprinter cascade constraints purge; + +drop table mprinter_state cascade constraints purge; + +drop table mprofile cascade constraints purge; + +drop table mprotected_construct_bean cascade constraints purge; + +drop table mrole cascade constraints purge; + +drop table mrole_muser cascade constraints purge; + +drop table msome_other cascade constraints purge; + +drop table muser cascade constraints purge; + +drop table muser_type cascade constraints purge; + +drop table mail_box cascade constraints purge; + +drop table mail_user cascade constraints purge; + +drop table mail_user_inbox cascade constraints purge; + +drop table mail_user_outbox cascade constraints purge; + +drop table main_entity cascade constraints purge; + +drop table main_entity_relation cascade constraints purge; + +drop table map_super_actual cascade constraints purge; + +drop table c_message cascade constraints purge; + +drop table meter_address_data cascade constraints purge; + +drop table meter_contract_data cascade constraints purge; + +drop table meter_special_needs_client cascade constraints purge; + +drop table meter_special_needs_contact cascade constraints purge; + +drop table meter_version cascade constraints purge; + +drop table mnoc_role cascade constraints purge; + +drop table mnoc_user cascade constraints purge; + +drop table mnoc_user_mnoc_role cascade constraints purge; + +drop table mny_a cascade constraints purge; + +drop table mny_b cascade constraints purge; + +drop table mny_b_mny_c cascade constraints purge; + +drop table mny_c cascade constraints purge; + +drop table mny_topic cascade constraints purge; + +drop table subtopics cascade constraints purge; + +drop table mp_role cascade constraints purge; + +drop table mp_user cascade constraints purge; + +drop table ms_many_a cascade constraints purge; + +drop table ms_many_a_many_b cascade constraints purge; + +drop table ms_many_b cascade constraints purge; + +drop table ms_many_b_many_a cascade constraints purge; + +drop table my_lob_size cascade constraints purge; + +drop table my_lob_size_join_many cascade constraints purge; + +drop table noidbean cascade constraints purge; + +drop table o_bean_child cascade constraints purge; + +drop table ocached_app cascade constraints purge; + +drop table ocached_app_detail cascade constraints purge; + +drop table o_cached_bean cascade constraints purge; + +drop table o_cached_bean_country cascade constraints purge; + +drop table o_cached_bean_child cascade constraints purge; + +drop table o_cached_inherit cascade constraints purge; + +drop table o_cached_natkey cascade constraints purge; + +drop table o_cached_natkey3 cascade constraints purge; + +drop table ocached_nkey_uid cascade constraints purge; + +drop table ocar cascade constraints purge; + +drop table ocompany cascade constraints purge; + +drop table oengine cascade constraints purge; + +drop table ogear_box cascade constraints purge; + +drop table omvertex cascade constraints purge; + +drop table omvertex_other cascade constraints purge; + +drop table oroad_show_msg cascade constraints purge; + +drop table om_account_child_dbo cascade constraints purge; + +drop table om_account_dbo cascade constraints purge; + +drop table om_basic_child cascade constraints purge; + +drop table om_basic_parent cascade constraints purge; + +drop table om_ordered_detail cascade constraints purge; + +drop table om_ordered_master cascade constraints purge; + +drop table only_id_entity cascade constraints purge; + +drop table o_order cascade constraints purge; + +drop table o_order_detail cascade constraints purge; + +drop table s_orders cascade constraints purge; + +drop table s_order_items cascade constraints purge; + +drop table or_order_ship cascade constraints purge; + +drop table organisation cascade constraints purge; + +drop table organization_node cascade constraints purge; + +drop table organization_tree_node cascade constraints purge; + +drop table orp_detail cascade constraints purge; + +drop table orp_detail2 cascade constraints purge; + +drop table orp_master cascade constraints purge; + +drop table orp_master2 cascade constraints purge; + +drop table oto_aone cascade constraints purge; + +drop table oto_atwo cascade constraints purge; + +drop table oto_bchild cascade constraints purge; + +drop table oto_bmaster cascade constraints purge; + +drop table oto_child cascade constraints purge; + +drop table oto_cust cascade constraints purge; + +drop table oto_cust_address cascade constraints purge; + +drop table oto_level_a cascade constraints purge; + +drop table oto_level_b cascade constraints purge; + +drop table oto_level_c cascade constraints purge; + +drop table oto_master cascade constraints purge; + +drop table oto_prime cascade constraints purge; + +drop table oto_prime_extra cascade constraints purge; + +drop table oto_sd_child cascade constraints purge; + +drop table oto_sd_master cascade constraints purge; + +drop table oto_th_many cascade constraints purge; + +drop table oto_th_one cascade constraints purge; + +drop table oto_th_top cascade constraints purge; + +drop table oto_ubprime cascade constraints purge; + +drop table oto_ubprime_extra cascade constraints purge; + +drop table oto_uprime cascade constraints purge; + +drop table oto_uprime_extra cascade constraints purge; + +drop table oto_user_model cascade constraints purge; + +drop table oto_user_model_optional cascade constraints purge; + +drop table pfile cascade constraints purge; + +drop table pfile_content cascade constraints purge; + +drop table paggview cascade constraints purge; + +drop table pallet_location cascade constraints purge; + +drop table parcel cascade constraints purge; + +drop table parcel_location cascade constraints purge; + +drop table rawinherit_parent cascade constraints purge; + +drop table rawinherit_parent_rawinherit_d cascade constraints purge; + +drop table e_save_test_c cascade constraints purge; + +drop table parent_person cascade constraints purge; + +drop table c_participation cascade constraints purge; + +drop table password_store_model cascade constraints purge; + +drop table pcf_calendar cascade constraints purge; + +drop table pcf_city cascade constraints purge; + +drop table pcf_country cascade constraints purge; + +drop table pcf_event cascade constraints purge; + +drop table pcf_person cascade constraints purge; + +drop table mt_permission cascade constraints purge; + +drop table persistent_file cascade constraints purge; + +drop table persistent_file_content cascade constraints purge; + +drop table person cascade constraints purge; + +drop table persons cascade constraints purge; + +drop table person_cache_email cascade constraints purge; + +drop table person_cache_info cascade constraints purge; + +drop table phones cascade constraints purge; + +drop table e_position cascade constraints purge; + +drop table primary_revision cascade constraints purge; + +drop table o_product cascade constraints purge; + +drop table pp cascade constraints purge; + +drop table pp_to_ww cascade constraints purge; + +drop table question cascade constraints purge; + +drop table rcustomer cascade constraints purge; + +drop table r_orders cascade constraints purge; + +drop table referencing_bean cascade constraints purge; + +drop table region cascade constraints purge; + +drop table rel_detail cascade constraints purge; + +drop table rel_master cascade constraints purge; + +drop table resourcefile cascade constraints purge; + +drop table mt_role cascade constraints purge; + +drop table mt_role_permission cascade constraints purge; + +drop table em_role cascade constraints purge; + +drop table root_bean cascade constraints purge; + +drop table f_second cascade constraints purge; + +drop table section cascade constraints purge; + +drop table self_parent cascade constraints purge; + +drop table self_ref_customer cascade constraints purge; + +drop table self_ref_example cascade constraints purge; + +drop table e_save_test_a cascade constraints purge; + +drop table e_save_test_b cascade constraints purge; + +drop table site cascade constraints purge; + +drop table site_address cascade constraints purge; + +drop table some_enum_bean cascade constraints purge; + +drop table some_file_bean cascade constraints purge; + +drop table some_new_types_bean cascade constraints purge; + +drop table some_period_bean cascade constraints purge; + +drop table source_base cascade constraints purge; + +drop table stockforecast cascade constraints purge; + +drop table sub_section cascade constraints purge; + +drop table sub_type cascade constraints purge; + +drop table survey cascade constraints purge; + +drop table tbytes_only cascade constraints purge; + +drop table tcar cascade constraints purge; + +drop table tevent cascade constraints purge; + +drop table tevent_many cascade constraints purge; + +drop table tevent_one cascade constraints purge; + +drop table tint_root cascade constraints purge; + +drop table tjoda_entity cascade constraints purge; + +drop table t_mapsuper1 cascade constraints purge; + +drop table t_oneb cascade constraints purge; + +drop table t_detail_with_other_namexxxyy cascade constraints purge; +drop sequence t_atable_detail_seq; + +drop table t_atable_thatisrelatively cascade constraints purge; +drop sequence t_atable_master_seq; + +drop table ttruck_holder cascade constraints purge; + +drop table ttruck_holder_item cascade constraints purge; + +drop table tuuid_entity cascade constraints purge; + +drop table twheel cascade constraints purge; + +drop table twith_pre_insert cascade constraints purge; + +drop table target_base cascade constraints purge; + +drop table mt_tenant cascade constraints purge; + +drop table test_annotation_base_entity cascade constraints purge; + +drop table tire cascade constraints purge; +drop sequence tire_seq; + +drop table sa_tire cascade constraints purge; +drop sequence sa_tire_seq; + +drop table tree_entity cascade constraints purge; + +drop table trip cascade constraints purge; + +drop table truck_ref cascade constraints purge; + +drop table tune cascade constraints purge; + +drop table "type" cascade constraints purge; + +drop table tz_bean cascade constraints purge; + +drop table usib_child cascade constraints purge; + +drop table usib_child_sibling cascade constraints purge; + +drop table usib_parent cascade constraints purge; + +drop table ut_detail cascade constraints purge; + +drop table ut_master cascade constraints purge; + +drop table uuone cascade constraints purge; + +drop table uutwo cascade constraints purge; + +drop table oto_user cascade constraints purge; + +drop table c_user cascade constraints purge; + +drop table tx_user cascade constraints purge; + +drop table g_user cascade constraints purge; + +drop table em_user cascade constraints purge; + +drop table user_interest_live cascade constraints purge; + +drop table em_user_role cascade constraints purge; + +drop table vehicle cascade constraints purge; + +drop table vehicle_driver cascade constraints purge; + +drop table vehicle_lease cascade constraints purge; + +drop table warehouses cascade constraints purge; + +drop table warehousesshippingzones cascade constraints purge; + +drop table wheel cascade constraints purge; +drop sequence wheel_seq; + +drop table sa_wheel cascade constraints purge; +drop sequence sa_wheel_seq; + +drop table sp_car_wheel cascade constraints purge; +drop sequence sp_car_wheel_seq; + +drop table g_who_props_otm cascade constraints purge; + +drop table with_zero cascade constraints purge; + +drop table parent cascade constraints purge; + +drop table wview cascade constraints purge; + +drop table zones cascade constraints purge; + +drop index ix_cntct_lst_nm_frst_nm; +drop index ix_e_basic_name; +drop index ix_efile2_no_fk_owner_id; +drop index ix_ecsm_values_host_id; +drop index ix_organization_node_kind; +drop index ano_3; diff --git a/ebean-core/src/test/ddl-review/pg-create-all.sql b/ebean-core/src/test/ddl-review/pg-create-all.sql new file mode 100644 index 000000000..5b4bc24dd --- /dev/null +++ b/ebean-core/src/test/ddl-review/pg-create-all.sql @@ -0,0 +1,5236 @@ +-- Generated by ebean unknown at 2020-08-24T21:02:32.420817Z +create table asimple_bean ( + id bigint generated by default as identity not null, + name varchar(255), + constraint pk_asimple_bean primary key (id) +); + +create table bar ( + bar_type varchar(31) not null, + bar_id integer generated by default as identity not null, + foo_id integer not null, + version integer not null, + constraint pk_bar primary key (bar_id) +); + +create table block ( + case_type integer not null, + id bigint generated by default as identity not null, + name varchar(255), + version bigint not null, + notes varchar(255), + constraint pk_block primary key (id) +); + +create table oto_account ( + id bigint generated by default as identity not null, + name varchar(255), + version bigint not null, + when_created timestamptz not null, + when_modified timestamptz not null, + constraint pk_oto_account primary key (id) +); + +create table acl ( + id bigint generated by default as identity not null, + name varchar(255), + constraint pk_acl primary key (id) +); + +create table acl_container_relation ( + id bigint generated by default as identity not null, + container_id bigint not null, + acl_entry_id bigint not null, + constraint pk_acl_container_relation primary key (id) +); + +create table addr ( + id bigint generated by default as identity not null, + employee_id bigint, + name varchar(255), + address_line1 varchar(255), + address_line2 varchar(255), + city varchar(255), + version bigint not null, + constraint pk_addr primary key (id) +); + +create table address ( + oid bigint generated by default as identity not null, + street varchar(255), + version integer not null, + constraint pk_address primary key (oid) +); + +create table o_address ( + id integer generated by default as identity not null, + line_1 varchar(100), + line_2 varchar(100), + city varchar(100), + cretime timestamptz, + country_code varchar(2), + updtime timestamptz not null, + constraint pk_o_address primary key (id) +); + +create table album ( + id bigint generated by default as identity not null, + name varchar(255), + cover_id bigint, + deleted boolean default false not null, + created_at timestamptz not null, + last_update timestamptz not null, + constraint uq_album_cover_id unique (cover_id), + constraint pk_album primary key (id) +); + +create table animal ( + species varchar(255) not null, + id bigint generated by default as identity not null, + shelter_id bigint, + version bigint not null, + name varchar(255), + registration_number varchar(255), + date_of_birth date, + dog_size varchar(255), + constraint pk_animal primary key (id) +); + +create table animal_shelter ( + id bigint generated by default as identity not null, + name varchar(255), + version bigint not null, + constraint pk_animal_shelter primary key (id) +); + +create table article ( + id integer generated by default as identity not null, + name varchar(255), + author varchar(255), + cretime timestamptz not null, + updtime timestamptz not null, + version bigint not null, + constraint pk_article primary key (id) +); + +create table attribute ( + option_type integer not null, + id integer generated by default as identity not null, + attribute_holder_id integer, + cretime timestamptz not null, + updtime timestamptz not null, + version bigint not null, + constraint pk_attribute primary key (id) +); + +create table attribute_holder ( + id integer generated by default as identity not null, + cretime timestamptz not null, + updtime timestamptz not null, + version bigint not null, + constraint pk_attribute_holder primary key (id) +); + +create table audit_log ( + id bigint generated by default as identity (start with 1000 cache 100) not null, + description varchar(255), + modified_description varchar(255), + constraint pk_audit_log primary key (id) +); + +create table bbookmark ( + id integer generated by default as identity not null, + bookmark_reference varchar(255), + user_id integer, + constraint pk_bbookmark primary key (id) +); + +create table bbookmark_org ( + id integer generated by default as identity not null, + name varchar(255), + constraint pk_bbookmark_org primary key (id) +); + +create table bbookmark_user ( + id integer generated by default as identity not null, + name varchar(255), + password varchar(255), + email_address varchar(255), + country varchar(255), + org_id integer, + constraint pk_bbookmark_user primary key (id) +); + +create table bsimple_with_gen ( + id integer generated by default as identity not null, + name varchar(255), + constraint pk_bsimple_with_gen primary key (id) +); + +create table bsite ( + id uuid not null, + name varchar(255), + constraint pk_bsite primary key (id) +); + +create table bsite_user_a ( + site_id uuid not null, + user_id uuid not null, + access_level integer, + version bigint not null, + constraint ck_bsite_user_a_access_level check ( access_level in (0,1,2)), + constraint pk_bsite_user_a primary key (site_id,user_id) +); + +create table bsite_user_b ( + site uuid not null, + usr uuid not null, + access_level integer, + constraint ck_bsite_user_b_access_level check ( access_level in (0,1,2)), + constraint pk_bsite_user_b primary key (site,usr) +); + +create table bsite_user_c ( + site_uid uuid not null, + user_uid uuid not null, + access_level integer, + constraint ck_bsite_user_c_access_level check ( access_level in (0,1,2)), + constraint pk_bsite_user_c primary key (site_uid,user_uid) +); + +create table bsite_user_d ( + site_id uuid not null, + user_id uuid not null, + access_level integer, + version bigint not null, + constraint ck_bsite_user_d_access_level check ( access_level in (0,1,2)) +); + +create table bsite_user_e ( + site_id uuid not null, + user_id uuid not null, + access_level integer, + constraint ck_bsite_user_e_access_level check ( access_level in (0,1,2)) +); + +create table buser ( + id uuid not null, + name varchar(255), + constraint pk_buser primary key (id) +); + +create table bwith_qident ( + id integer generated by default as identity not null, + "Name" varchar(191), + "CODE" varchar(255), + last_updated timestamptz not null, + constraint uq_bwith_qident_name unique ("Name"), + constraint pk_bwith_qident primary key (id) +); + +create table basic_draftable_bean ( + id bigint generated by default as identity not null, + name varchar(255), + version bigint not null, + when_created timestamptz not null, + when_modified timestamptz not null, + constraint pk_basic_draftable_bean primary key (id) +); + +create table basic_draftable_bean_draft ( + id bigint generated by default as identity not null, + name varchar(255), + version bigint not null, + when_created timestamptz not null, + when_modified timestamptz not null, + constraint pk_basic_draftable_bean_draft primary key (id) +); + +create table basic_joda_entity ( + id bigint generated by default as identity not null, + name varchar(255), + period varchar(50), + local_date date, + created timestamptz not null, + updated timestamptz not null, + version timestamptz not null, + constraint pk_basic_joda_entity primary key (id) +); + +create table bean_with_time_zone ( + id bigint generated by default as identity not null, + name varchar(255), + timezone varchar(20), + constraint pk_bean_with_time_zone primary key (id) +); + +create table drel_booking ( + id bigint not null, + booking_uid bigint, + agent_invoice bigint, + client_invoice bigint, + version integer not null, + constraint uq_drel_booking_booking_uid unique (booking_uid), + constraint uq_drel_booking_agent_invoice unique (agent_invoice), + constraint uq_drel_booking_client_invoice unique (client_invoice), + constraint pk_drel_booking primary key (id) +); +create sequence drel_booking_seq increment by 1; + +create table bw_bean ( + id bigint generated by default as identity not null, + name varchar(255), + flags integer not null, + version bigint not null, + constraint pk_bw_bean primary key (id) +); + +create table cepcategory ( + id bigint generated by default as identity not null, + name varchar(255), + version bigint not null, + constraint pk_cepcategory primary key (id) +); + +create table cepproduct ( + id bigint generated by default as identity not null, + name varchar(255), + version bigint not null, + constraint pk_cepproduct primary key (id) +); + +create table cepproduct_category ( + customer_id bigint not null, + address_id bigint not null, + category_id bigint not null, + product_id bigint not null, + priority integer +); + +create table ciaddress ( + id bigint generated by default as identity not null, + street_id bigint, + constraint pk_ciaddress primary key (id) +); + +create table cicustomer_parent ( + dtype integer not null, + id bigint generated by default as identity not null, + address_id bigint, + notes varchar(255), + constraint pk_cicustomer_parent primary key (id) +); + +create table cistreet_parent ( + dtype integer not null, + id bigint generated by default as identity not null, + name varchar(255), + num varchar(255), + constraint pk_cistreet_parent primary key (id) +); + +create table cinh_ref ( + id integer generated by default as identity not null, + ref_id integer, + cretime timestamptz not null, + updtime timestamptz not null, + version bigint not null, + constraint pk_cinh_ref primary key (id) +); + +create table cinh_root ( + dtype varchar(3) not null, + id integer generated by default as identity not null, + license_number varchar(255), + cretime timestamptz not null, + updtime timestamptz not null, + version bigint not null, + driver varchar(255), + notes varchar(255), + action varchar(255), + constraint pk_cinh_root primary key (id) +); + +create table ckey_assoc ( + id integer generated by default as identity not null, + assoc_one varchar(255), + constraint pk_ckey_assoc primary key (id) +); + +create table ckey_detail ( + id integer generated by default as identity not null, + something varchar(255), + one_key integer, + two_key varchar(127), + constraint pk_ckey_detail primary key (id) +); + +create table ckey_parent ( + one_key integer not null, + two_key varchar(127) not null, + name varchar(255), + assoc_id integer, + version integer not null, + constraint pk_ckey_parent primary key (one_key,two_key) +); + +create table coone ( + id bigint generated by default as identity not null, + name varchar(255), + constraint pk_coone primary key (id) +); + +create table coone_many ( + id bigint generated by default as identity not null, + coone_id bigint not null, + name varchar(255), + deleted boolean default false not null, + constraint pk_coone_many primary key (id) +); + +create table coroot ( + id bigint generated by default as identity not null, + name varchar(255), + one_id bigint, + constraint uq_coroot_one_id unique (one_id), + constraint pk_coroot primary key (id) +); + +create table calculation_result ( + id integer generated by default as identity not null, + charge float not null, + product_configuration_id integer, + group_configuration_id integer, + constraint pk_calculation_result primary key (id) +); + +create table cao_bean ( + x_cust_id integer not null, + x_type_id integer not null, + description varchar(255), + version bigint not null, + constraint pk_cao_bean primary key (x_cust_id,x_type_id) +); + +create table sp_car_car ( + id bigint not null, + name varchar(255), + version integer not null, + constraint pk_sp_car_car primary key (id) +); +create sequence sp_car_car_seq increment by 1; + +create table sp_car_car_wheels ( + car bigint not null, + wheel bigint not null, + constraint pk_sp_car_car_wheels primary key (car,wheel) +); + +create table sp_car_car_doors ( + car bigint not null, + door bigint not null, + constraint pk_sp_car_car_doors primary key (car,door) +); + +create table sa_car ( + id bigint not null, + brand varchar(255), + sold integer not null, + version integer not null, + constraint pk_sa_car primary key (id) +); +create sequence sa_car_seq increment by 1; + +create table car_accessory ( + id integer generated by default as identity not null, + name varchar(255), + fuse_id bigint not null, + car_id integer, + cretime timestamptz not null, + updtime timestamptz not null, + version bigint not null, + constraint pk_car_accessory primary key (id) +); + +create table car_fuse ( + id bigint generated by default as identity not null, + location_code varchar(255), + constraint pk_car_fuse primary key (id) +); + +create table category ( + id bigint generated by default as identity not null, + name varchar(255), + surveyobjectid bigint, + sequence_number integer not null, + constraint pk_category primary key (id) +); + +create table e_save_test_d ( + id bigint generated by default as identity not null, + parent_id bigint, + test_property boolean default false not null, + version bigint not null, + constraint uq_e_save_test_d_parent_id unique (parent_id), + constraint pk_e_save_test_d primary key (id) +); + +create table child_person ( + identifier integer generated by default as identity not null, + name varchar(255), + age integer, + some_bean_id integer, + parent_identifier integer, + family_name varchar(255), + address varchar(255), + constraint pk_child_person primary key (identifier) +); + +create table cke_client ( + cod_cpny integer not null, + cod_client varchar(100) not null, + username varchar(100) not null, + notes varchar(255), + constraint pk_cke_client primary key (cod_cpny,cod_client) +); + +create table cke_user ( + username varchar(100) not null, + cod_cpny integer not null, + name varchar(255), + constraint pk_cke_user primary key (username,cod_cpny) +); + +create table class_super ( + dtype varchar(31) not null, + sid bigint generated by default as identity not null, + constraint pk_class_super primary key (sid) +); + +create table class_super_monkey ( + class_super_sid bigint not null, + monkey_mid bigint not null, + constraint uq_class_super_monkey_mid unique (monkey_mid), + constraint pk_class_super_monkey primary key (class_super_sid,monkey_mid) +); + +create table configuration ( + type varchar(21) not null, + id integer generated by default as identity not null, + name varchar(255), + configurations_id integer, + group_name varchar(255), + product_name varchar(255), + constraint pk_configuration primary key (id) +); + +create table configurations ( + id integer generated by default as identity not null, + name varchar(255), + constraint pk_configurations primary key (id) +); + +create table contact ( + id integer generated by default as identity not null, + first_name varchar(127), + last_name varchar(127), + phone varchar(255), + mobile varchar(255), + email varchar(255), + is_member boolean default false not null, + customer_id integer not null, + group_id integer, + cretime timestamptz not null, + updtime timestamptz not null, + constraint pk_contact primary key (id) +); + +create table contact_group ( + id integer generated by default as identity not null, + name varchar(255), + cretime timestamptz not null, + updtime timestamptz not null, + version bigint not null, + constraint pk_contact_group primary key (id) +); + +create table contact_note ( + id integer generated by default as identity not null, + contact_id integer, + title varchar(255), + note text, + cretime timestamptz not null, + updtime timestamptz not null, + version bigint not null, + constraint pk_contact_note primary key (id) +); + +create table contract ( + id bigint generated by default as identity not null, + name varchar(255), + constraint pk_contract primary key (id) +); + +create table contract_costs ( + id bigint generated by default as identity not null, + status varchar(255), + position_id bigint not null, + constraint pk_contract_costs primary key (id) +); + +create table c_conversation ( + id bigint generated by default as identity not null, + title varchar(255), + isopen boolean default false not null, + group_id bigint, + version bigint not null, + when_created timestamptz not null, + when_modified timestamptz not null, + constraint pk_c_conversation primary key (id) +); + +create table o_country ( + code varchar(2) not null, + name varchar(60), + constraint pk_o_country primary key (code) +); + +create table cover ( + id bigint generated by default as identity not null, + s3_url varchar(255), + deleted boolean default false not null, + constraint pk_cover primary key (id) +); + +create table o_customer ( + id integer generated by default as identity not null, + status varchar(1), + name varchar(40) not null, + smallnote varchar(100), + anniversary date, + billing_address_id integer, + shipping_address_id integer, + cretime timestamptz not null, + updtime timestamptz not null, + version bigint not null, + constraint ck_o_customer_status check ( status in ('N','A','I')), + constraint pk_o_customer primary key (id) +); +comment on table o_customer is 'Holds external customers'; +comment on column o_customer.status is 'status of the customer'; +comment on column o_customer.smallnote is 'Short notes regarding the customer'; +comment on column o_customer.anniversary is 'Join date of the customer'; + +create table dcredit ( + id bigint generated by default as identity not null, + credit varchar(255), + constraint pk_dcredit primary key (id) +); + +create table dcredit_drol ( + dcredit_id bigint not null, + drol_id bigint not null, + constraint pk_dcredit_drol primary key (dcredit_id,drol_id) +); + +create table dexh_entity ( + oid bigint generated by default as identity not null, + exhange varchar(255), + an_enum_type varchar(255), + last_updated timestamptz not null, + constraint pk_dexh_entity primary key (oid) +); + +create table dint_parent ( + type integer not null, + id bigint generated by default as identity not null, + val integer, + more varchar(255), + constraint pk_dint_parent primary key (id) +); + +create table dmachine ( + id bigint generated by default as identity not null, + name varchar(255), + organisation_id bigint, + version bigint not null, + constraint pk_dmachine primary key (id) +); + +create table d_machine_aux_use ( + id bigint generated by default as identity not null, + machine_id bigint not null, + name varchar(255), + edate date, + use_secs bigint not null, + fuel decimal(16,3), + version bigint not null, + constraint pk_d_machine_aux_use primary key (id) +); + +create table d_machine_stats ( + id bigint generated by default as identity not null, + machine_id bigint not null, + edate date, + total_kms bigint not null, + hours bigint not null, + rate decimal(16,3), + cost decimal(16,3), + version bigint not null, + constraint pk_d_machine_stats primary key (id) +); + +create table d_machine_use ( + id bigint generated by default as identity not null, + machine_id bigint not null, + edate date, + distance_kms bigint not null, + time_secs bigint not null, + fuel decimal(9,3), + version bigint not null, + constraint pk_d_machine_use primary key (id) +); + +create table dorg ( + id bigint generated by default as identity not null, + name varchar(255), + version bigint not null, + constraint pk_dorg primary key (id) +); + +create table dperson ( + id bigint generated by default as identity not null, + first_name varchar(255), + last_name varchar(255), + salary decimal(16,3), + constraint pk_dperson primary key (id) +); + +create table drol ( + id bigint generated by default as identity not null, + name varchar(255), + constraint pk_drol primary key (id) +); + +create table drot ( + id bigint generated by default as identity not null, + name varchar(255), + constraint pk_drot primary key (id) +); + +create table drot_drol ( + drot_id bigint not null, + drol_id bigint not null, + constraint pk_drot_drol primary key (drot_id,drol_id) +); + +create table rawinherit_data ( + id bigint generated by default as identity not null, + val integer, + constraint pk_rawinherit_data primary key (id) +); + +create table data_container ( + id uuid not null, + content varchar(255), + constraint pk_data_container primary key (id) +); + +create table dc_detail ( + id bigint generated by default as identity not null, + master_id bigint, + description varchar(255), + version bigint not null, + constraint pk_dc_detail primary key (id) +); + +create table dc_master ( + id bigint generated by default as identity not null, + name varchar(255), + version bigint not null, + constraint pk_dc_master primary key (id) +); + +create table defaults_model ( + id integer generated by default as identity not null, + constraint pk_defaults_model primary key (id) +); + +create table defaults_model_draft ( + id integer generated by default as identity not null, + constraint pk_defaults_model_draft primary key (id) +); + +create table dfk_cascade ( + id bigint generated by default as identity not null, + name varchar(255), + one_id bigint, + constraint pk_dfk_cascade primary key (id) +); + +create table dfk_cascade_one ( + id bigint generated by default as identity not null, + name varchar(255), + constraint pk_dfk_cascade_one primary key (id) +); + +create table dfk_none ( + id bigint generated by default as identity not null, + name varchar(255), + one_id bigint, + constraint pk_dfk_none primary key (id) +); + +create table dfk_none_via_join ( + id bigint generated by default as identity not null, + name varchar(255), + one_id bigint, + constraint pk_dfk_none_via_join primary key (id) +); + +create table dfk_none_via_mto_m ( + id bigint generated by default as identity not null, + name varchar(255), + constraint pk_dfk_none_via_mto_m primary key (id) +); + +create table dfk_none_via_mto_m_dfk_one ( + dfk_none_via_mto_m_id bigint not null, + dfk_one_id bigint not null, + constraint pk_dfk_none_via_mto_m_dfk_one primary key (dfk_none_via_mto_m_id,dfk_one_id) +); + +create table dfk_one ( + id bigint generated by default as identity not null, + name varchar(255), + constraint pk_dfk_one primary key (id) +); + +create table dfk_set_null ( + id bigint generated by default as identity not null, + name varchar(255), + one_id bigint, + constraint pk_dfk_set_null primary key (id) +); + +create table doc ( + id bigint generated by default as identity not null, + name varchar(255), + version bigint not null, + when_created timestamptz not null, + when_modified timestamptz not null, + constraint pk_doc primary key (id) +); + +create table doc_link ( + doc_id bigint not null, + link_id bigint not null, + constraint pk_doc_link primary key (doc_id,link_id) +); + +create table doc_link_draft ( + doc_id bigint not null, + link_id bigint not null, + constraint pk_doc_link_draft primary key (doc_id,link_id) +); + +create table doc_draft ( + id bigint generated by default as identity not null, + name varchar(255), + version bigint not null, + when_created timestamptz not null, + when_modified timestamptz not null, + constraint pk_doc_draft primary key (id) +); + +create table document ( + id bigint generated by default as identity not null, + title varchar(127), + body varchar(255), + organisation_id bigint, + version bigint not null, + when_created timestamptz not null, + when_modified timestamptz not null, + constraint uq_document_title unique (title), + constraint pk_document primary key (id) +); + +create table document_draft ( + id bigint generated by default as identity not null, + title varchar(127), + body varchar(255), + when_publish timestamptz, + organisation_id bigint, + version bigint not null, + when_created timestamptz not null, + when_modified timestamptz not null, + constraint uq_document_draft_title unique (title), + constraint pk_document_draft primary key (id) +); + +create table document_media ( + id bigint generated by default as identity not null, + document_id bigint, + name varchar(255), + description varchar(255), + version bigint not null, + when_created timestamptz not null, + when_modified timestamptz not null, + constraint pk_document_media primary key (id) +); + +create table document_media_draft ( + id bigint generated by default as identity not null, + document_id bigint, + name varchar(255), + description varchar(255), + version bigint not null, + when_created timestamptz not null, + when_modified timestamptz not null, + constraint pk_document_media_draft primary key (id) +); + +create table sp_car_door ( + id bigint not null, + name varchar(255), + version integer not null, + constraint pk_sp_car_door primary key (id) +); +create sequence sp_car_door_seq increment by 1; + +create table earray_bean ( + id bigint generated by default as identity not null, + foo integer, + name varchar(255), + phone_numbers varchar[], + uids uuid[] not null, + other_ids bigint[], + doubs float[], + statuses integer[], + vc_enums varchar[], + int_enums integer[], + status2 integer[], + version bigint not null, + constraint ck_earray_bean_foo check ( foo in (100,101,102)), + constraint pk_earray_bean primary key (id) +); + +create table earray_set_bean ( + id bigint generated by default as identity not null, + name varchar(255), + phone_numbers varchar[], + uids uuid[], + other_ids bigint[], + doubs float[], + version bigint not null, + constraint pk_earray_set_bean primary key (id) +); + +create table e_basic ( + id integer generated by default as identity not null, + status varchar(1), + name varchar(127), + description varchar(255), + some_date timestamptz, + constraint ck_e_basic_status check ( status in ('N','A','I')), + constraint pk_e_basic primary key (id) +); + +create table ebasic_change_log ( + id bigint generated by default as identity not null, + name varchar(20), + short_description varchar(50), + long_description varchar(100), + who_created varchar(255) not null, + who_modified varchar(255) not null, + when_created timestamptz not null, + when_modified timestamptz not null, + version bigint not null, + constraint pk_ebasic_change_log primary key (id) +); + +create table ebasic_clob ( + id bigint generated by default as identity not null, + name varchar(255), + title varchar(255), + description text, + last_update timestamptz not null, + constraint pk_ebasic_clob primary key (id) +); + +create table ebasic_clob_fetch_eager ( + id bigint generated by default as identity not null, + name varchar(255), + title varchar(255), + description text, + last_update timestamptz not null, + constraint pk_ebasic_clob_fetch_eager primary key (id) +); + +create table ebasic_clob_no_ver ( + id bigint generated by default as identity not null, + name varchar(255), + description text, + constraint pk_ebasic_clob_no_ver primary key (id) +); + +create table e_basicenc ( + id integer generated by default as identity not null, + name varchar(255), + description bytea, + dob bytea, + status bytea, + last_update timestamptz, + constraint pk_e_basicenc primary key (id) +); + +create table e_basicenc_bin ( + id integer generated by default as identity not null, + name varchar(255), + description varchar(255), + data bytea, + some_time bytea, + last_update timestamptz not null, + constraint pk_e_basicenc_bin primary key (id) +); + +create table e_basicenc_client ( + id bigint generated by default as identity not null, + name varchar(255), + description bytea, + dob bytea, + status bytea, + version bigint not null, + constraint pk_e_basicenc_client primary key (id) +); + +create table e_basicenc_relate ( + id bigint generated by default as identity not null, + name varchar(255), + other_id integer, + constraint pk_e_basicenc_relate primary key (id) +); + +create table e_basic_enum_id ( + status varchar(1) not null, + name varchar(255), + description varchar(255), + constraint ck_e_basic_enum_id_status check ( status in ('N','A','I')), + constraint pk_e_basic_enum_id primary key (status) +); + +create table e_basic_eni ( + id integer generated by default as identity not null, + status integer, + name varchar(255), + description varchar(255), + some_date timestamptz, + constraint ck_e_basic_eni_status check ( status in (1,2,3)), + constraint pk_e_basic_eni primary key (id) +); + +create table ebasic_hstore ( + id bigint generated by default as identity not null, + name varchar(255), + map hstore, + version bigint not null, + constraint pk_ebasic_hstore primary key (id) +); + +create table ebasic_json_jackson ( + id bigint generated by default as identity not null, + name varchar(255), + value_set json, + value_list jsonb, + value_map json, + plain_value json, + version bigint not null, + constraint pk_ebasic_json_jackson primary key (id) +); + +create table ebasic_json_jackson2 ( + id bigint generated by default as identity not null, + name varchar(255), + value_set json, + value_list jsonb, + value_map json, + plain_value json, + version bigint not null, + constraint pk_ebasic_json_jackson2 primary key (id) +); + +create table ebasic_json_list ( + id bigint generated by default as identity not null, + name varchar(255), + bean_set json, + bean_list jsonb, + bean_map json, + plain_bean json, + flags json, + tags varchar(100), + version bigint not null, + constraint pk_ebasic_json_list primary key (id) +); + +create table ebasic_json_map ( + id bigint generated by default as identity not null, + name varchar(255), + content json, + version bigint not null, + constraint pk_ebasic_json_map primary key (id) +); + +create table ebasic_json_map_blob ( + id bigint generated by default as identity not null, + name varchar(255), + content bytea, + version bigint not null, + constraint pk_ebasic_json_map_blob primary key (id) +); + +create table ebasic_json_map_clob ( + id bigint generated by default as identity not null, + name varchar(255), + content text, + version bigint not null, + constraint pk_ebasic_json_map_clob primary key (id) +); + +create table ebasic_json_map_detail ( + id bigint generated by default as identity not null, + owner_id bigint, + name varchar(255), + content json, + version bigint not null, + constraint pk_ebasic_json_map_detail primary key (id) +); + +create table ebasic_json_map_json_b ( + id bigint generated by default as identity not null, + name varchar(255), + content jsonb, + version bigint not null, + constraint pk_ebasic_json_map_json_b primary key (id) +); + +create table ebasic_json_map_varchar ( + id bigint generated by default as identity not null, + name varchar(255), + content varchar(3000), + version bigint not null, + constraint pk_ebasic_json_map_varchar primary key (id) +); + +create table ebasic_json_node ( + id bigint generated by default as identity not null, + name varchar(255), + content json, + version bigint not null, + constraint pk_ebasic_json_node primary key (id) +); + +create table ebasic_json_node_blob ( + id bigint generated by default as identity not null, + name varchar(255), + content bytea, + version bigint not null, + constraint pk_ebasic_json_node_blob primary key (id) +); + +create table ebasic_json_node_json_b ( + id bigint generated by default as identity not null, + name varchar(255), + content jsonb, + version bigint not null, + constraint pk_ebasic_json_node_json_b primary key (id) +); + +create table ebasic_json_node_varchar ( + id bigint generated by default as identity not null, + name varchar(255), + content varchar(1000), + version bigint not null, + constraint pk_ebasic_json_node_varchar primary key (id) +); + +create table ebasic_json_unmapped ( + id bigint generated by default as identity not null, + name varchar(255), + version bigint not null, + constraint pk_ebasic_json_unmapped primary key (id) +); + +create table e_basic_ndc ( + id integer generated by default as identity not null, + name varchar(255), + constraint pk_e_basic_ndc primary key (id) +); + +create table ebasic_no_sdchild ( + id bigint generated by default as identity not null, + owner_id bigint not null, + child_name varchar(255), + amount bigint not null, + version bigint not null, + constraint pk_ebasic_no_sdchild primary key (id) +); + +create table ebasic_sdchild ( + id bigint generated by default as identity not null, + owner_id bigint not null, + child_name varchar(255), + amount bigint not null, + version bigint not null, + deleted boolean default false not null, + constraint pk_ebasic_sdchild primary key (id) +); + +create table ebasic_soft_delete ( + id bigint generated by default as identity not null, + name varchar(255), + description varchar(255), + version bigint not null, + deleted boolean default false not null, + constraint pk_ebasic_soft_delete primary key (id) +); + +create table e_basicver ( + id integer generated by default as identity not null, + name varchar(255), + description varchar(255), + other varchar(255), + last_update timestamptz not null, + constraint pk_e_basicver primary key (id) +); + +create table e_basic_withlife ( + id bigint generated by default as identity not null, + name varchar(255), + other varchar(255), + deleted boolean default false not null, + version bigint not null, + constraint pk_e_basic_withlife primary key (id) +); + +create table e_basic_with_ex ( + id bigint generated by default as identity not null, + deleted boolean default false not null, + version bigint not null, + constraint pk_e_basic_with_ex primary key (id) +); + +create table e_basicverucon ( + id integer generated by default as identity not null, + name varchar(127), + other varchar(127), + other_one varchar(127), + description varchar(255), + last_update timestamptz not null, + constraint uq_e_basicverucon_name unique (name), + constraint uq_e_basicverucon_other_other_one unique (other,other_one), + constraint pk_e_basicverucon primary key (id) +); + +create table ecache_child ( + id uuid not null, + name varchar(100), + root_id uuid not null, + constraint pk_ecache_child primary key (id) +); + +create table ecache_root ( + id uuid not null, + name varchar(100), + constraint pk_ecache_root primary key (id) +); + +create table e_col_ab ( + id bigint generated by default as identity not null, + column_a varchar(255), + column_b varchar(255), + constraint pk_e_col_ab primary key (id) +); + +create table ecustom_id ( + id varchar(127) not null, + name varchar(255), + constraint pk_ecustom_id primary key (id) +); + +create table edefault_prop ( + id integer generated by default as identity not null, + e_simple_usertypeid integer, + name varchar(255), + constraint uq_edefault_prop_e_simple_usertypeid unique (e_simple_usertypeid), + constraint pk_edefault_prop primary key (id) +); + +create table eemb_inner ( + id integer generated by default as identity not null, + nome_inner varchar(255), + outer_id integer, + update_count integer not null, + constraint pk_eemb_inner primary key (id) +); + +create table eemb_outer ( + id integer generated by default as identity not null, + nome_outer varchar(255), + date1 timestamptz, + date2 timestamptz, + update_count integer not null, + constraint pk_eemb_outer primary key (id) +); + +create table efile2_no_fk ( + file_name varchar(64) not null, + owner_id integer not null, + constraint pk_efile2_no_fk primary key (file_name) +); + +create table efile_no_fk ( + file_name varchar(64) not null, + owner_user_id integer, + owner_soft_del_user_id integer, + constraint pk_efile_no_fk primary key (file_name) +); + +create table efile_no_fk_euser_no_fk ( + efile_no_fk_file_name varchar(64) not null, + euser_no_fk_user_id integer not null, + constraint pk_efile_no_fk_euser_no_fk primary key (efile_no_fk_file_name,euser_no_fk_user_id) +); + +create table efile_no_fk_euser_no_fk_soft_del ( + efile_no_fk_file_name varchar(64) not null, + euser_no_fk_soft_del_user_id integer not null, + constraint pk_efile_no_fk_euser_no_fk_soft_del primary key (efile_no_fk_file_name,euser_no_fk_soft_del_user_id) +); + +create table egen_props ( + id bigint generated by default as identity not null, + name varchar(255), + version bigint not null, + when_created timestamptz not null, + when_modified timestamptz not null, + ts_created timestamptz not null, + ts_updated timestamptz not null, + ldt_created timestamptz not null, + ldt_updated timestamptz not null, + odt_created timestamptz not null, + odt_updated timestamptz not null, + zdt_created timestamptz not null, + zdt_updated timestamptz not null, + instant_created timestamptz not null, + instant_updated timestamptz not null, + long_created bigint not null, + long_updated bigint not null, + constraint pk_egen_props primary key (id) +); + +create table eid_uid_bean ( + id bigint generated by default as identity not null, + uuid uuid not null, + name varchar(255), + constraint uq_eid_uid_bean_uuid unique (uuid), + constraint pk_eid_uid_bean primary key (id) +); + +create table einvoice ( + id bigint generated by default as identity not null, + invoice_date timestamptz, + state integer, + person_id bigint, + ship_street varchar(255), + ship_suburb varchar(255), + ship_city varchar(255), + ship_status varchar(3), + bill_street varchar(255), + bill_suburb varchar(255), + bill_city varchar(255), + bill_status varchar(3), + version bigint not null, + constraint ck_einvoice_state check ( state in (0,1,2)), + constraint ck_einvoice_ship_status check ( ship_status in ('ONE','TWO')), + constraint ck_einvoice_bill_status check ( bill_status in ('ONE','TWO')), + constraint pk_einvoice primary key (id) +); + +create table e_main ( + id integer generated by default as identity not null, + name varchar(255), + description varchar(255), + version bigint not null, + constraint pk_e_main primary key (id) +); + +create table enull_collection ( + id integer generated by default as identity not null, + name varchar(255), + constraint pk_enull_collection primary key (id) +); + +create table enull_collection_detail ( + id integer generated by default as identity not null, + enull_collection_id integer not null, + something varchar(255), + constraint pk_enull_collection_detail primary key (id) +); + +create table eopt_one_a ( + id integer generated by default as identity not null, + name_for_a varchar(255), + b_id integer, + cretime timestamptz not null, + updtime timestamptz not null, + version bigint not null, + constraint pk_eopt_one_a primary key (id) +); + +create table eopt_one_b ( + id integer generated by default as identity not null, + name_for_b varchar(255), + c_id integer not null, + cretime timestamptz not null, + updtime timestamptz not null, + version bigint not null, + constraint pk_eopt_one_b primary key (id) +); + +create table eopt_one_c ( + id integer generated by default as identity not null, + name_for_c varchar(255), + cretime timestamptz not null, + updtime timestamptz not null, + version bigint not null, + constraint pk_eopt_one_c primary key (id) +); + +create table eper_addr ( + id bigint generated by default as identity not null, + name varchar(255), + ma_street varchar(255), + ma_suburb varchar(255), + ma_city varchar(255), + ma_country_code varchar(2), + version bigint not null, + constraint pk_eper_addr primary key (id) +); + +create table eperson ( + id bigint generated by default as identity not null, + name varchar(255), + notes varchar(255), + street varchar(255), + suburb varchar(255), + addr_city varchar(255), + addr_status varchar(3), + version bigint not null, + constraint ck_eperson_addr_status check ( addr_status in ('ONE','TWO')), + constraint pk_eperson primary key (id) +); + +create table e_person_online ( + id bigint generated by default as identity not null, + email varchar(127), + online_status boolean default false not null, + when_updated timestamptz not null, + constraint uq_e_person_online_email unique (email), + constraint pk_e_person_online primary key (id) +); + +create table esimple ( + usertypeid integer generated by default as identity not null, + name varchar(255), + constraint pk_esimple primary key (usertypeid) +); + +create table esoft_del_book ( + id bigint generated by default as identity not null, + book_title varchar(255), + lend_by_id bigint, + version bigint not null, + deleted boolean default false not null, + constraint pk_esoft_del_book primary key (id) +); + +create table esoft_del_book_esoft_del_user ( + esoft_del_book_id bigint not null, + esoft_del_user_id bigint not null, + constraint pk_esoft_del_book_esoft_del_user primary key (esoft_del_book_id,esoft_del_user_id) +); + +create table esoft_del_down ( + id bigint generated by default as identity not null, + esoft_del_mid_id bigint not null, + down varchar(255), + version bigint not null, + deleted boolean default false not null, + constraint pk_esoft_del_down primary key (id) +); + +create table esoft_del_mid ( + id bigint generated by default as identity not null, + top_id bigint, + mid varchar(255), + up_id bigint, + version bigint not null, + deleted boolean default false not null, + constraint pk_esoft_del_mid primary key (id) +); + +create table esoft_del_one_a ( + id bigint generated by default as identity not null, + name varchar(255), + oneb_id bigint, + deleted boolean default false not null, + version bigint not null, + constraint uq_esoft_del_one_a_oneb_id unique (oneb_id), + constraint pk_esoft_del_one_a primary key (id) +); + +create table esoft_del_one_b ( + id bigint generated by default as identity not null, + name varchar(255), + version bigint not null, + constraint pk_esoft_del_one_b primary key (id) +); + +create table esoft_del_role ( + id bigint generated by default as identity not null, + role_name varchar(255), + version bigint not null, + deleted boolean default false not null, + constraint pk_esoft_del_role primary key (id) +); + +create table esoft_del_role_esoft_del_user ( + esoft_del_role_id bigint not null, + esoft_del_user_id bigint not null, + constraint pk_esoft_del_role_esoft_del_user primary key (esoft_del_role_id,esoft_del_user_id) +); + +create table esoft_del_top ( + id bigint generated by default as identity not null, + name varchar(255), + version bigint not null, + deleted boolean default false not null, + constraint pk_esoft_del_top primary key (id) +); + +create table esoft_del_up ( + id bigint generated by default as identity not null, + up varchar(255), + version bigint not null, + deleted boolean default false not null, + constraint pk_esoft_del_up primary key (id) +); + +create table esoft_del_user ( + id bigint generated by default as identity not null, + user_name varchar(255), + version bigint not null, + deleted boolean default false not null, + constraint pk_esoft_del_user primary key (id) +); + +create table esoft_del_user_esoft_del_role ( + esoft_del_user_id bigint not null, + esoft_del_role_id bigint not null, + constraint pk_esoft_del_user_esoft_del_role primary key (esoft_del_user_id,esoft_del_role_id) +); + +create table esome_convert_type ( + id bigint generated by default as identity not null, + name varchar(255), + money decimal(16,3), + constraint pk_esome_convert_type primary key (id) +); + +create table esome_type ( + id integer generated by default as identity not null, + currency varchar(3), + locale varchar(20), + time_zone varchar(20), + constraint pk_esome_type primary key (id) +); + +create table etrans_many ( + id integer generated by default as identity not null, + name varchar(255), + constraint pk_etrans_many primary key (id) +); + +create table rawinherit_uncle ( + id integer generated by default as identity not null, + name varchar(255), + parent_id bigint not null, + version bigint not null, + constraint pk_rawinherit_uncle primary key (id) +); + +create table euser_no_fk ( + user_id integer generated by default as identity not null, + user_name varchar(255), + constraint pk_euser_no_fk primary key (user_id) +); + +create table euser_no_fk_soft_del ( + user_id integer generated by default as identity not null, + user_name varchar(255), + constraint pk_euser_no_fk_soft_del primary key (user_id) +); + +create table evanilla_collection ( + id integer generated by default as identity not null, + name varchar(255), + constraint pk_evanilla_collection primary key (id) +); + +create table evanilla_collection_detail ( + id integer generated by default as identity not null, + evanilla_collection_id integer not null, + something varchar(255), + constraint pk_evanilla_collection_detail primary key (id) +); + +create table ewho_props ( + id bigint generated by default as identity not null, + name varchar(255), + version bigint not null, + when_created timestamptz not null, + when_modified timestamptz not null, + who_created varchar(255) not null, + who_modified varchar(255) not null, + constraint pk_ewho_props primary key (id) +); + +create table e_withinet ( + id bigint generated by default as identity not null, + name varchar(255), + inet_address inet, + inet2 inet, + cidr cidr, + version bigint not null, + constraint pk_e_withinet primary key (id) +); + +create table ec_enum_person ( + id bigint generated by default as identity not null, + name varchar(255), + version bigint not null, + constraint pk_ec_enum_person primary key (id) +); + +create table ec_enum_person_tags ( + ec_enum_person_id bigint not null, + value varchar(5) not null, + constraint ck_ec_enum_person_tags_value check ( value in ('RED','BLUE','GREEN')) +); + +create table ec_person ( + id bigint generated by default as identity not null, + name varchar(255), + version bigint not null, + constraint pk_ec_person primary key (id) +); + +create table ec_person_phone ( + owner_id bigint not null, + phone varchar(255) not null +); + +create table ec_top ( + id bigint generated by default as identity not null, + name varchar(255), + person_id bigint, + version bigint not null, + constraint pk_ec_top primary key (id) +); + +create table ec_top_ecs_person ( + ec_top_id bigint not null, + ecs_person_id bigint not null, + constraint pk_ec_top_ecs_person primary key (ec_top_id,ecs_person_id) +); + +create table ecbl_person ( + id bigint generated by default as identity not null, + name varchar(255), + version bigint not null, + constraint pk_ecbl_person primary key (id) +); + +create table ecbl_person_phone_numbers ( + person_id bigint not null, + country_code varchar(2), + area varchar(6), + phnum varchar(20) +); + +create table ecbm_person ( + id bigint generated by default as identity not null, + name varchar(255), + version bigint not null, + constraint pk_ecbm_person primary key (id) +); + +create table ecbm_person_phone_numbers ( + person_id bigint not null, + mkey varchar(255) not null, + country_code varchar(2), + area varchar(6), + phnum varchar(20) +); + +create table ecm_person ( + id bigint generated by default as identity not null, + name varchar(255), + version bigint not null, + constraint pk_ecm_person primary key (id) +); + +create table ecm_person_phone_numbers ( + ecm_person_id bigint not null, + type varchar(4) not null, + phnum varchar(10) not null +); + +create table ecmc_person ( + id bigint generated by default as identity not null, + name varchar(255), + version bigint not null, + constraint pk_ecmc_person primary key (id) +); + +create table ecmc_person_phone_numbers ( + ecmc_person_id bigint not null, + type varchar(4) not null, + value text not null +); + +create table ecs_person ( + id bigint generated by default as identity not null, + name varchar(255), + version bigint not null, + constraint pk_ecs_person primary key (id) +); + +create table ecs_person_phone ( + ecs_person_id bigint not null, + phone varchar(255) not null +); + +create table ecsm_child ( + one_id uuid not null, + ecsm_parent_id bigint not null, + name varchar(255), + version bigint not null, + constraint pk_ecsm_child primary key (one_id) +); + +create table ecsm_values ( + host_id uuid not null, + value varchar(255) not null +); + +create table ecsm_one ( + one_id uuid not null, + name varchar(255), + version bigint not null, + constraint pk_ecsm_one primary key (one_id) +); + +create table ecsm_parent ( + id bigint generated by default as identity not null, + name varchar(255), + version bigint not null, + constraint pk_ecsm_parent primary key (id) +); + +create table ecsm_two ( + id uuid not null, + name varchar(255), + version bigint not null, + constraint pk_ecsm_two primary key (id) +); + +create table td_child ( + child_id integer generated by default as identity not null, + child_name varchar(255), + parent_id integer not null, + constraint pk_td_child primary key (child_id) +); + +create table td_parent ( + parent_type varchar(31) not null, + parent_id integer generated by default as identity not null, + parent_name varchar(255), + extended_name varchar(255), + constraint pk_td_parent primary key (parent_id) +); + +create table element_bean ( + id bigint generated by default as identity not null, + complex_bean_id uuid not null, + value varchar(255) not null, + constraint pk_element_bean primary key (id) +); + +create table empl ( + id bigint generated by default as identity not null, + name varchar(255), + age integer, + default_address_id bigint, + constraint pk_empl primary key (id) +); + +create table esd_detail ( + id bigint generated by default as identity not null, + name varchar(255), + master_id bigint not null, + version bigint not null, + deleted boolean default false not null, + constraint pk_esd_detail primary key (id) +); + +create table esd_master ( + id bigint generated by default as identity not null, + name varchar(255), + version bigint not null, + deleted boolean default false not null, + constraint pk_esd_master primary key (id) +); + +create table feature_desc ( + id integer generated by default as identity not null, + name varchar(255), + description varchar(255), + constraint pk_feature_desc primary key (id) +); + +create table f_first ( + id bigint generated by default as identity not null, + name varchar(255), + constraint pk_f_first primary key (id) +); + +create table foo ( + foo_id integer generated by default as identity not null, + important_text varchar(255), + version integer not null, + constraint pk_foo primary key (foo_id) +); + +create table gen_key_identity ( + id bigint generated by default as identity not null, + description varchar(255), + constraint pk_gen_key_identity primary key (id) +); + +create table gen_key_sequence ( + id bigint not null, + description varchar(255), + constraint pk_gen_key_sequence primary key (id) +); +create sequence SEQ_NAME increment by 1; + +create table grand_parent_person ( + identifier integer generated by default as identity not null, + name varchar(255), + age integer, + some_bean_id integer, + family_name varchar(255), + address varchar(255), + constraint pk_grand_parent_person primary key (identifier) +); + +create table survey_group ( + id bigint generated by default as identity not null, + name varchar(255), + categoryobjectid bigint, + sequence_number integer not null, + constraint pk_survey_group primary key (id) +); + +create table c_group ( + id bigint generated by default as identity not null, + inactive boolean default false not null, + name varchar(255), + version bigint not null, + when_created timestamptz not null, + when_modified timestamptz not null, + constraint pk_c_group primary key (id) +); + +create table he_doc ( + id bigint generated by default as identity not null, + name varchar(255), + version bigint not null, + when_created timestamptz not null, + when_modified timestamptz not null, + constraint pk_he_doc primary key (id) +); + +create table hx_link ( + id bigint generated by default as identity not null, + name varchar(255), + location varchar(255), + comments varchar(255), + version bigint not null, + when_created timestamptz not null, + when_modified timestamptz not null, + deleted boolean default false not null, + constraint pk_hx_link primary key (id) +); + +create table hx_link_doc ( + hx_link_id bigint not null, + he_doc_id bigint not null, + constraint pk_hx_link_doc primary key (hx_link_id,he_doc_id) +); + +create table hi_doc ( + id bigint generated by default as identity not null, + name varchar(255), + version bigint not null, + when_created timestamptz not null, + when_modified timestamptz not null, + constraint pk_hi_doc primary key (id) +); + +create table hi_link ( + id bigint generated by default as identity not null, + name varchar(255), + location varchar(255), + comments varchar(255), + version bigint not null, + when_created timestamptz not null, + when_modified timestamptz not null, + constraint pk_hi_link primary key (id) +); + +create table hi_link_doc ( + hi_link_id bigint not null, + hi_doc_id bigint not null, + constraint pk_hi_link_doc primary key (hi_link_id,hi_doc_id) +); + +create table hi_tone ( + id bigint generated by default as identity not null, + name varchar(255), + comments varchar(255), + version bigint not null, + when_created timestamptz not null, + when_modified timestamptz not null, + constraint pk_hi_tone primary key (id) +); + +create table hi_tthree ( + id bigint generated by default as identity not null, + hi_ttwo_id bigint not null, + three varchar(255), + version bigint not null, + when_created timestamptz not null, + when_modified timestamptz not null, + constraint pk_hi_tthree primary key (id) +); + +create table hi_ttwo ( + id bigint generated by default as identity not null, + hi_tone_id bigint not null, + two varchar(255), + version bigint not null, + when_created timestamptz not null, + when_modified timestamptz not null, + constraint pk_hi_ttwo primary key (id) +); + +create table hsd_setting ( + id bigint generated by default as identity not null, + code varchar(255), + content varchar(255), + user_id bigint, + version bigint not null, + when_created timestamptz not null, + when_modified timestamptz not null, + deleted boolean default false not null, + constraint uq_hsd_setting_user_id unique (user_id), + constraint pk_hsd_setting primary key (id) +); + +create table hsd_user ( + id bigint generated by default as identity not null, + name varchar(255), + version bigint not null, + when_created timestamptz not null, + when_modified timestamptz not null, + deleted boolean default false not null, + constraint pk_hsd_user primary key (id) +); + +create table iaf_segment ( + ptype varchar(31) not null, + id bigint generated by default as identity not null, + segment_id_zat bigint not null, + status_id bigint not null, + constraint pk_iaf_segment primary key (id) +); + +create table iaf_segment_status ( + id bigint generated by default as identity not null, + name varchar(255), + constraint pk_iaf_segment_status primary key (id) +); + +create table imrelated ( + id bigint generated by default as identity not null, + name varchar(255), + owner_id bigint not null, + constraint pk_imrelated primary key (id) +); + +create table imroot ( + dtype varchar(31) not null, + id bigint generated by default as identity not null, + name varchar(255), + title varchar(255), + when_title timestamptz, + constraint pk_imroot primary key (id) +); + +create table ixresource ( + dtype varchar(255), + id uuid not null, + name varchar(255), + constraint pk_ixresource primary key (id) +); + +create table info_company ( + id bigint generated by default as identity not null, + name varchar(255), + version bigint not null, + constraint pk_info_company primary key (id) +); + +create table info_contact ( + id bigint generated by default as identity not null, + name varchar(255), + company_id bigint not null, + version bigint not null, + constraint pk_info_contact primary key (id) +); + +create table info_customer ( + id bigint generated by default as identity not null, + name varchar(255), + company_id bigint, + version bigint not null, + constraint uq_info_customer_company_id unique (company_id), + constraint pk_info_customer primary key (id) +); + +create table inner_report ( + id bigint generated by default as identity not null, + name varchar(255), + forecast_id bigint, + constraint uq_inner_report_forecast_id unique (forecast_id), + constraint pk_inner_report primary key (id) +); + +create table drel_invoice ( + id bigint not null, + booking bigint, + version integer not null, + constraint pk_drel_invoice primary key (id) +); +create sequence drel_invoice_seq increment by 1; + +create table item ( + customer integer not null, + itemnumber varchar(127) not null, + description varchar(255), + units varchar(255), + type integer not null, + region integer not null, + date_modified timestamptz, + date_created timestamptz, + modified_by varchar(255), + created_by varchar(255), + version bigint not null, + constraint pk_item primary key (customer,itemnumber) +); + +create table monkey ( + mid bigint generated by default as identity not null, + name varchar(255), + food_preference varchar(255), + version bigint not null, + constraint pk_monkey primary key (mid) +); + +create table mkeygroup ( + pid bigint generated by default as identity not null, + name varchar(255), + version bigint not null, + constraint pk_mkeygroup primary key (pid) +); + +create table mkeygroup_monkey ( + mkeygroup_pid bigint not null, + monkey_mid bigint not null, + constraint uq_mkeygroup_monkey_mid unique (monkey_mid), + constraint pk_mkeygroup_monkey primary key (mkeygroup_pid,monkey_mid) +); + +create table trainer ( + tid bigint generated by default as identity not null, + name varchar(255), + version bigint not null, + constraint pk_trainer primary key (tid) +); + +create table trainer_monkey ( + trainer_tid bigint not null, + monkey_mid bigint not null, + constraint uq_trainer_monkey_mid unique (monkey_mid), + constraint pk_trainer_monkey primary key (trainer_tid,monkey_mid) +); + +create table troop ( + pid bigint generated by default as identity not null, + name varchar(255), + version bigint not null, + constraint pk_troop primary key (pid) +); + +create table troop_monkey ( + troop_pid bigint not null, + monkey_mid bigint not null, + constraint uq_troop_monkey_mid unique (monkey_mid), + constraint pk_troop_monkey primary key (troop_pid,monkey_mid) +); + +create table l2_cldf_reset_bean ( + id bigint generated by default as identity not null, + name varchar(255), + constraint pk_l2_cldf_reset_bean primary key (id) +); + +create table l2_cldf_reset_bean_child ( + id bigint generated by default as identity not null, + parent_id bigint, + constraint pk_l2_cldf_reset_bean_child primary key (id) +); + +create table level1 ( + id bigint generated by default as identity not null, + name varchar(255), + constraint pk_level1 primary key (id) +); + +create table level1_level4 ( + level1_id bigint not null, + level4_id bigint not null, + constraint pk_level1_level4 primary key (level1_id,level4_id) +); + +create table level1_level2 ( + level1_id bigint not null, + level2_id bigint not null, + constraint pk_level1_level2 primary key (level1_id,level2_id) +); + +create table level2 ( + id bigint generated by default as identity not null, + name varchar(255), + constraint pk_level2 primary key (id) +); + +create table level2_level3 ( + level2_id bigint not null, + level3_id bigint not null, + constraint pk_level2_level3 primary key (level2_id,level3_id) +); + +create table level3 ( + id bigint generated by default as identity not null, + name varchar(255), + constraint pk_level3 primary key (id) +); + +create table level4 ( + id bigint generated by default as identity not null, + name varchar(255), + constraint pk_level4 primary key (id) +); + +create table link ( + id bigint generated by default as identity not null, + name varchar(255), + location varchar(255), + when_publish timestamptz, + link_comment varchar(255), + version bigint not null, + when_created timestamptz not null, + when_modified timestamptz not null, + deleted boolean default false not null, + constraint pk_link primary key (id) +); + +create table link_draft ( + id bigint generated by default as identity not null, + name varchar(255), + location varchar(255), + when_publish timestamptz, + link_comment varchar(255), + dirty boolean default false not null, + version bigint not null, + when_created timestamptz not null, + when_modified timestamptz not null, + deleted boolean default false not null, + constraint pk_link_draft primary key (id) +); + +create table la_attr_value ( + id integer generated by default as identity not null, + name varchar(255), + cretime timestamptz not null, + updtime timestamptz not null, + version bigint not null, + constraint pk_la_attr_value primary key (id) +); + +create table la_attr_value_attribute ( + la_attr_value_id integer not null, + attribute_id integer not null, + constraint pk_la_attr_value_attribute primary key (la_attr_value_id,attribute_id) +); + +create table looney ( + id bigint generated by default as identity not null, + tune_id bigint, + name varchar(255), + constraint pk_looney primary key (id) +); + +create table maddress ( + id uuid not null, + street varchar(255), + city varchar(255), + version bigint not null, + constraint pk_maddress primary key (id) +); + +create table mcontact ( + id uuid not null, + email varchar(255), + first_name varchar(255), + last_name varchar(255), + customer_id uuid, + version bigint not null, + constraint pk_mcontact primary key (id) +); + +create table mcontact_message ( + id uuid not null, + title varchar(255), + subject varchar(255), + notes varchar(255), + contact_id uuid not null, + version bigint not null, + constraint pk_mcontact_message primary key (id) +); + +create table mcustomer ( + id uuid not null, + name varchar(255), + notes varchar(255), + shipping_address_id uuid, + billing_address_id uuid, + version bigint not null, + constraint pk_mcustomer primary key (id) +); + +create table mgroup ( + id bigint generated by default as identity not null, + name varchar(255), + constraint pk_mgroup primary key (id) +); + +create table mmachine ( + id bigint generated by default as identity not null, + name varchar(255), + version bigint not null, + constraint pk_mmachine primary key (id) +); + +create table mmachine_mgroup ( + mmachine_id bigint not null, + mgroup_id bigint not null, + constraint pk_mmachine_mgroup primary key (mmachine_id,mgroup_id) +); + +create table mmedia ( + type varchar(31) not null, + id bigint generated by default as identity not null, + url varchar(255), + note varchar(255), + constraint pk_mmedia primary key (id) +); + +create table non_updateprop ( + id integer generated by default as identity not null, + non_enum varchar(5), + name varchar(255), + note varchar(255), + constraint ck_non_updateprop_non_enum check ( non_enum in ('BEGIN','END')), + constraint pk_non_updateprop primary key (id) +); + +create table mprinter ( + id bigint generated by default as identity not null, + name varchar(255), + flags bigint not null, + current_state_id bigint, + last_swap_cyan_id bigint, + last_swap_magenta_id bigint, + last_swap_yellow_id bigint, + last_swap_black_id bigint, + version bigint not null, + constraint uq_mprinter_last_swap_cyan_id unique (last_swap_cyan_id), + constraint uq_mprinter_last_swap_magenta_id unique (last_swap_magenta_id), + constraint uq_mprinter_last_swap_yellow_id unique (last_swap_yellow_id), + constraint uq_mprinter_last_swap_black_id unique (last_swap_black_id), + constraint pk_mprinter primary key (id) +); + +create table mprinter_state ( + id bigint generated by default as identity not null, + flags bigint not null, + printer_id bigint, + version bigint not null, + constraint pk_mprinter_state primary key (id) +); + +create table mprofile ( + id bigint generated by default as identity not null, + picture_id bigint, + name varchar(255), + constraint pk_mprofile primary key (id) +); + +create table mprotected_construct_bean ( + id bigint generated by default as identity not null, + name varchar(255), + constraint pk_mprotected_construct_bean primary key (id) +); + +create table mrole ( + roleid integer generated by default as identity not null, + role_name varchar(255), + constraint pk_mrole primary key (roleid) +); + +create table mrole_muser ( + mrole_roleid integer not null, + muser_userid integer not null, + constraint pk_mrole_muser primary key (mrole_roleid,muser_userid) +); + +create table msome_other ( + id bigint generated by default as identity not null, + name varchar(255), + constraint pk_msome_other primary key (id) +); + +create table muser ( + userid integer generated by default as identity not null, + user_name varchar(255), + user_type_id integer, + constraint pk_muser primary key (userid) +); + +create table muser_type ( + id integer generated by default as identity not null, + name varchar(255), + constraint pk_muser_type primary key (id) +); + +create table mail_box ( + id bigint generated by default as identity not null, + name varchar(255), + version bigint not null, + constraint pk_mail_box primary key (id) +); + +create table mail_user ( + id bigint generated by default as identity not null, + name varchar(255), + version bigint not null, + constraint pk_mail_user primary key (id) +); + +create table mail_user_inbox ( + mail_user_id bigint not null, + mail_box_id bigint not null, + constraint pk_mail_user_inbox primary key (mail_user_id,mail_box_id) +); + +create table mail_user_outbox ( + mail_user_id bigint not null, + mail_box_id bigint not null, + constraint pk_mail_user_outbox primary key (mail_user_id,mail_box_id) +); + +create table main_entity ( + id varchar(255) not null, + attr1 varchar(255), + attr2 varchar(255), + constraint pk_main_entity primary key (id) +); + +create table main_entity_relation ( + id uuid not null, + id1 varchar(255), + id2 varchar(255), + attr1 varchar(255), + constraint pk_main_entity_relation primary key (id) +); + +create table map_super_actual ( + id bigint generated by default as identity not null, + name varchar(255), + when_created timestamptz not null, + when_updated timestamptz not null, + constraint pk_map_super_actual primary key (id) +); + +create table c_message ( + id bigint generated by default as identity not null, + title varchar(255), + body varchar(255), + conversation_id bigint, + user_id bigint, + version bigint not null, + when_created timestamptz not null, + when_modified timestamptz not null, + constraint pk_c_message primary key (id) +); + +create table meter_address_data ( + id uuid not null, + street varchar(255) not null, + constraint pk_meter_address_data primary key (id) +); + +create table meter_contract_data ( + id uuid not null, + special_needs_client_id uuid not null, + constraint uq_meter_contract_data_special_needs_client_id unique (special_needs_client_id), + constraint pk_meter_contract_data primary key (id) +); + +create table meter_special_needs_client ( + id uuid not null, + name varchar(255), + primary_id uuid, + constraint uq_meter_special_needs_client_primary_id unique (primary_id), + constraint pk_meter_special_needs_client primary key (id) +); + +create table meter_special_needs_contact ( + id uuid not null, + name varchar(255), + constraint pk_meter_special_needs_contact primary key (id) +); + +create table meter_version ( + id uuid not null, + address_data_id uuid, + contract_data_id uuid not null, + constraint uq_meter_version_address_data_id unique (address_data_id), + constraint uq_meter_version_contract_data_id unique (contract_data_id), + constraint pk_meter_version primary key (id) +); + +create table mnoc_role ( + role_id integer generated by default as identity not null, + role_name varchar(255), + version integer not null, + constraint pk_mnoc_role primary key (role_id) +); + +create table mnoc_user ( + user_id integer generated by default as identity not null, + user_name varchar(255), + version integer not null, + constraint pk_mnoc_user primary key (user_id) +); + +create table mnoc_user_mnoc_role ( + mnoc_user_user_id integer not null, + mnoc_role_role_id integer not null, + constraint pk_mnoc_user_mnoc_role primary key (mnoc_user_user_id,mnoc_role_role_id) +); + +create table mny_a ( + id bigint generated by default as identity not null, + name varchar(255), + version bigint not null, + when_created timestamptz not null, + when_modified timestamptz not null, + constraint pk_mny_a primary key (id) +); + +create table mny_b ( + id bigint generated by default as identity not null, + name varchar(255), + a_id bigint, + version bigint not null, + when_created timestamptz not null, + when_modified timestamptz not null, + constraint pk_mny_b primary key (id) +); + +create table mny_b_mny_c ( + mny_b_id bigint not null, + mny_c_id bigint not null, + constraint pk_mny_b_mny_c primary key (mny_b_id,mny_c_id) +); + +create table mny_c ( + id bigint generated by default as identity not null, + name varchar(255), + version bigint not null, + when_created timestamptz not null, + when_modified timestamptz not null, + constraint pk_mny_c primary key (id) +); + +create table mny_topic ( + id bigint generated by default as identity not null, + name varchar(255), + version bigint not null, + constraint pk_mny_topic primary key (id) +); + +create table subtopics ( + topic bigint not null, + subtopic bigint not null, + constraint pk_subtopics primary key (topic,subtopic) +); + +create table mp_role ( + id bigint generated by default as identity not null, + mp_user_id bigint not null, + code varchar(255), + organization_id bigint, + constraint pk_mp_role primary key (id) +); + +create table mp_user ( + id bigint generated by default as identity not null, + name varchar(255), + constraint pk_mp_user primary key (id) +); + +create table ms_many_a ( + aid bigint generated by default as identity not null, + name varchar(255), + ms_many_a_many_b boolean default false not null, + ms_many_b boolean default false not null, + deleted boolean default false not null, + constraint pk_ms_many_a primary key (aid) +); + +create table ms_many_a_many_b ( + ms_many_a_aid bigint not null, + ms_many_b_bid bigint not null, + constraint pk_ms_many_a_many_b primary key (ms_many_a_aid,ms_many_b_bid) +); + +create table ms_many_b ( + bid bigint generated by default as identity not null, + name varchar(255), + deleted boolean default false not null, + constraint pk_ms_many_b primary key (bid) +); + +create table ms_many_b_many_a ( + ms_many_b_bid bigint not null, + ms_many_a_aid bigint not null, + constraint pk_ms_many_b_many_a primary key (ms_many_b_bid,ms_many_a_aid) +); + +create table my_lob_size ( + id integer generated by default as identity not null, + name varchar(255), + my_count integer not null, + my_lob text, + constraint pk_my_lob_size primary key (id) +); + +create table my_lob_size_join_many ( + id integer generated by default as identity not null, + something varchar(255), + other varchar(255), + parent_id integer, + constraint pk_my_lob_size_join_many primary key (id) +); + +create table noidbean ( + name varchar(255), + subject varchar(255), + when_created timestamptz not null +); + +create table o_bean_child ( + id bigint generated by default as identity not null, + cached_bean_id bigint, + constraint pk_o_bean_child primary key (id) +); + +create table ocached_app ( + id bigint generated by default as identity not null, + app_name varchar(255), + version bigint not null, + constraint uq_ocached_app_app_name unique (app_name), + constraint pk_ocached_app primary key (id) +); + +create table ocached_app_detail ( + id bigint generated by default as identity not null, + app_id bigint not null, + detail varchar(255), + version bigint not null, + constraint uq_ocached_app_detail_app_id_detail unique (app_id,detail), + constraint pk_ocached_app_detail primary key (id) +); + +create table o_cached_bean ( + id bigint generated by default as identity not null, + name varchar(255), + constraint pk_o_cached_bean primary key (id) +); + +create table o_cached_bean_country ( + o_cached_bean_id bigint not null, + o_country_code varchar(2) not null, + constraint pk_o_cached_bean_country primary key (o_cached_bean_id,o_country_code) +); + +create table o_cached_bean_child ( + id bigint generated by default as identity not null, + cached_bean_id bigint, + constraint pk_o_cached_bean_child primary key (id) +); + +create table o_cached_inherit ( + dtype varchar(31) not null, + id bigint generated by default as identity not null, + name varchar(255), + child_adata varchar(255), + child_bdata varchar(255), + constraint pk_o_cached_inherit primary key (id) +); + +create table o_cached_natkey ( + id bigint generated by default as identity not null, + store varchar(255), + sku varchar(255), + description varchar(255), + constraint pk_o_cached_natkey primary key (id) +); + +create table o_cached_natkey3 ( + id bigint generated by default as identity not null, + store varchar(255), + code integer not null, + sku varchar(255), + description varchar(255), + constraint pk_o_cached_natkey3 primary key (id) +); + +create table ocached_nkey_uid ( + id bigint generated by default as identity not null, + cid uuid, + other varchar(255), + version bigint not null, + constraint pk_ocached_nkey_uid primary key (id) +); + +create table ocar ( + id integer generated by default as identity not null, + vin varchar(255), + name varchar(255), + cretime timestamptz not null, + updtime timestamptz not null, + version bigint not null, + constraint pk_ocar primary key (id) +); + +create table ocompany ( + id integer generated by default as identity not null, + corp_id varchar(50), + cretime timestamptz not null, + updtime timestamptz not null, + version bigint not null, + constraint uq_ocompany_corp_id unique (corp_id), + constraint pk_ocompany primary key (id) +); + +create table oengine ( + engine_id uuid not null, + short_desc varchar(255), + car_id integer, + version integer not null, + constraint uq_oengine_car_id unique (car_id), + constraint pk_oengine primary key (engine_id) +); + +create table ogear_box ( + id uuid not null, + box_desc varchar(255), + box_size integer, + car_id integer, + version integer not null, + constraint uq_ogear_box_car_id unique (car_id), + constraint pk_ogear_box primary key (id) +); + +create table omvertex ( + id uuid not null, + constraint pk_omvertex primary key (id) +); + +create table omvertex_other ( + id uuid not null, + omvertex_id uuid not null, + name varchar(255), + constraint pk_omvertex_other primary key (id) +); + +create table oroad_show_msg ( + id integer generated by default as identity not null, + company_id integer not null, + cretime timestamptz not null, + updtime timestamptz not null, + version bigint not null, + constraint uq_oroad_show_msg_company_id unique (company_id), + constraint pk_oroad_show_msg primary key (id) +); + +create table om_account_child_dbo ( + id bigint generated by default as identity not null, + description varchar(255), + banana_rama_id bigint, + constraint pk_om_account_child_dbo primary key (id) +); + +create table om_account_dbo ( + id bigint generated by default as identity not null, + name varchar(255), + constraint pk_om_account_dbo primary key (id) +); + +create table om_basic_child ( + id bigint generated by default as identity not null, + name varchar(255), + parent_id bigint, + version bigint not null, + constraint pk_om_basic_child primary key (id) +); + +create table om_basic_parent ( + id bigint generated by default as identity not null, + name varchar(255), + version bigint not null, + constraint pk_om_basic_parent primary key (id) +); + +create table om_ordered_detail ( + id bigint generated by default as identity not null, + name varchar(255), + master_id bigint, + version bigint not null, + sort_order integer, + constraint pk_om_ordered_detail primary key (id) +); + +create table om_ordered_master ( + id bigint generated by default as identity not null, + name varchar(255), + version bigint not null, + constraint pk_om_ordered_master primary key (id) +); + +create table oml_bar ( + id bigint generated by default as identity not null, + constraint pk_oml_bar primary key (id) +); + +create table oml_baz ( + id bigint generated by default as identity not null, + foo_id bigint not null, + constraint pk_oml_baz primary key (id) +); + +create table oml_foo ( + id bigint generated by default as identity not null, + bar_id bigint not null, + constraint pk_oml_foo primary key (id) +); + +create table only_id_entity ( + id bigint generated by default as identity not null, + constraint pk_only_id_entity primary key (id) +); + +create table o_order ( + id integer generated by default as identity not null, + status integer, + order_date date, + ship_date date, + kcustomer_id integer not null, + cretime timestamptz not null, + updtime timestamptz not null, + constraint ck_o_order_status check ( status in (0,1,2,3)), + constraint pk_o_order primary key (id) +); + +create table o_order_detail ( + id integer generated by default as identity not null, + order_id integer not null, + order_qty integer, + ship_qty integer, + unit_price float, + product_id integer, + cretime timestamptz, + updtime timestamptz not null, + constraint pk_o_order_detail primary key (id) +); + +create table s_orders ( + uuid varchar(40) not null, + constraint pk_s_orders primary key (uuid) +); + +create table s_order_items ( + uuid varchar(40) not null, + product_variant_uuid varchar(255), + order_uuid varchar(40), + quantity integer not null, + amount decimal(16,3), + constraint pk_s_order_items primary key (uuid) +); + +create table order_master ( + id bigint generated by default as identity not null, + constraint pk_order_master primary key (id) +); + +create table order_master_inheritance ( + id integer generated by default as identity not null, + constraint pk_order_master_inheritance primary key (id) +); + +create table order_referenced_parent ( + type varchar(31) not null, + id bigint generated by default as identity not null, + name varchar(255), + child_name varchar(255), + master_id bigint, + sort_order integer, + constraint pk_order_referenced_parent primary key (id) +); + +create table or_order_ship ( + id integer generated by default as identity not null, + order_id integer, + ship_time timestamptz, + cretime timestamptz not null, + updtime timestamptz not null, + version bigint not null, + constraint pk_or_order_ship primary key (id) +); + +create table order_toy ( + id integer generated by default as identity not null, + title varchar(255), + child_id bigint, + sort_order integer, + constraint pk_order_toy primary key (id) +); + +create table ordered_parent ( + dtype varchar(31) not null, + id integer generated by default as identity not null, + order_master_inheritance_id integer not null, + common_name varchar(255), + sort_order integer, + ordered_aname varchar(255), + ordered_bname varchar(255), + constraint pk_ordered_parent primary key (id) +); + +create table organisation ( + id bigint generated by default as identity not null, + name varchar(255), + version bigint not null, + when_created timestamptz not null, + when_modified timestamptz not null, + constraint pk_organisation primary key (id) +); + +create table organization_node ( + kind varchar(31) not null, + id bigint generated by default as identity not null, + parent_tree_node_id bigint not null, + title varchar(255), + constraint uq_organization_node_parent_tree_node_id unique (parent_tree_node_id), + constraint pk_organization_node primary key (id) +); + +create table organization_tree_node ( + id bigint generated by default as identity not null, + name varchar(255), + constraint pk_organization_tree_node primary key (id) +); + +create table orp_detail ( + id varchar(100) not null, + detail varchar(255), + master_id varchar(100), + version bigint not null, + constraint pk_orp_detail primary key (id) +); + +create table orp_detail2 ( + id varchar(100) not null, + orp_master2_id varchar(100) not null, + detail varchar(255), + master_id varchar(255), + version bigint not null, + constraint pk_orp_detail2 primary key (id) +); + +create table orp_master ( + id varchar(100) not null, + name varchar(255), + version bigint not null, + constraint pk_orp_master primary key (id) +); + +create table orp_master2 ( + id varchar(100) not null, + name varchar(255), + version bigint not null, + constraint pk_orp_master2 primary key (id) +); + +create table oto_aone ( + id varchar(100) not null, + description varchar(255), + constraint pk_oto_aone primary key (id) +); + +create table oto_atwo ( + id varchar(100) not null, + description varchar(255), + aone_id varchar(100), + constraint uq_oto_atwo_aone_id unique (aone_id), + constraint pk_oto_atwo primary key (id) +); + +create table oto_bchild ( + master_id bigint generated by default as identity not null, + child varchar(255), + constraint pk_oto_bchild primary key (master_id) +); + +create table oto_bmaster ( + id bigint generated by default as identity not null, + name varchar(255), + constraint pk_oto_bmaster primary key (id) +); + +create table oto_child ( + id integer generated by default as identity not null, + name varchar(255), + master_id bigint, + constraint uq_oto_child_master_id unique (master_id), + constraint pk_oto_child primary key (id) +); + +create table oto_cust ( + cid bigint generated by default as identity not null, + name varchar(255), + version bigint not null, + constraint pk_oto_cust primary key (cid) +); + +create table oto_cust_address ( + aid bigint generated by default as identity not null, + line1 varchar(255), + line2 varchar(255), + line3 varchar(255), + customer_cid bigint, + version bigint not null, + constraint uq_oto_cust_address_customer_cid unique (customer_cid), + constraint pk_oto_cust_address primary key (aid) +); + +create table oto_level_a ( + id bigint generated by default as identity not null, + name varchar(255), + b_id bigint, + constraint uq_oto_level_a_b_id unique (b_id), + constraint pk_oto_level_a primary key (id) +); + +create table oto_level_b ( + id bigint generated by default as identity not null, + name varchar(255), + c_id bigint, + constraint uq_oto_level_b_c_id unique (c_id), + constraint pk_oto_level_b primary key (id) +); + +create table oto_level_c ( + id bigint generated by default as identity not null, + name varchar(255), + constraint pk_oto_level_c primary key (id) +); + +create table oto_master ( + id bigint generated by default as identity not null, + name varchar(255), + constraint pk_oto_master primary key (id) +); + +create table oto_prime ( + pid bigint generated by default as identity not null, + name varchar(255), + version bigint not null, + constraint pk_oto_prime primary key (pid) +); + +create table oto_prime_extra ( + eid bigint generated by default as identity not null, + extra varchar(255), + version bigint not null, + constraint pk_oto_prime_extra primary key (eid) +); + +create table oto_sd_child ( + id bigint generated by default as identity not null, + child varchar(255), + master_id bigint, + deleted boolean default false not null, + version bigint not null, + constraint uq_oto_sd_child_master_id unique (master_id), + constraint pk_oto_sd_child primary key (id) +); + +create table oto_sd_master ( + id bigint generated by default as identity not null, + name varchar(255), + version bigint not null, + constraint pk_oto_sd_master primary key (id) +); + +create table oto_th_many ( + id bigint generated by default as identity not null, + oto_th_top_id bigint not null, + many varchar(255), + version bigint not null, + when_created timestamptz not null, + when_modified timestamptz not null, + constraint pk_oto_th_many primary key (id) +); + +create table oto_th_one ( + id bigint generated by default as identity not null, + one boolean default false not null, + many_id bigint, + version bigint not null, + when_created timestamptz not null, + when_modified timestamptz not null, + constraint uq_oto_th_one_many_id unique (many_id), + constraint pk_oto_th_one primary key (id) +); + +create table oto_th_top ( + id bigint generated by default as identity not null, + topp varchar(255), + version bigint not null, + when_created timestamptz not null, + when_modified timestamptz not null, + constraint pk_oto_th_top primary key (id) +); + +create table oto_ubprime ( + pid uuid not null, + name varchar(255), + version bigint not null, + constraint pk_oto_ubprime primary key (pid) +); + +create table oto_ubprime_extra ( + eid uuid not null, + extra varchar(255), + version bigint not null, + constraint pk_oto_ubprime_extra primary key (eid) +); + +create table oto_uprime ( + pid uuid not null, + name varchar(255), + version bigint not null, + constraint pk_oto_uprime primary key (pid) +); + +create table oto_uprime_extra ( + eid uuid not null, + extra varchar(255), + version bigint not null, + constraint pk_oto_uprime_extra primary key (eid) +); + +create table oto_user_model ( + id bigint generated by default as identity not null, + name varchar(255), + user_optional_id bigint, + version bigint not null, + when_created timestamptz not null, + when_modified timestamptz not null, + constraint uq_oto_user_model_user_optional_id unique (user_optional_id), + constraint pk_oto_user_model primary key (id) +); + +create table oto_user_model_optional ( + id bigint generated by default as identity not null, + optional varchar(255), + version bigint not null, + when_created timestamptz not null, + when_modified timestamptz not null, + constraint pk_oto_user_model_optional primary key (id) +); + +create table pfile ( + id integer generated by default as identity not null, + name varchar(255), + file_content_id integer, + file_content2_id integer, + cretime timestamptz not null, + updtime timestamptz not null, + version bigint not null, + constraint uq_pfile_file_content_id unique (file_content_id), + constraint uq_pfile_file_content2_id unique (file_content2_id), + constraint pk_pfile primary key (id) +); + +create table pfile_content ( + id integer generated by default as identity not null, + content bytea, + cretime timestamptz not null, + updtime timestamptz not null, + version bigint not null, + constraint pk_pfile_content primary key (id) +); + +create table paggview ( + pview_id uuid, + amount integer not null, + constraint uq_paggview_pview_id unique (pview_id) +); + +create table pallet_location ( + type varchar(31) not null, + id integer generated by default as identity not null, + zone_sid integer not null, + attribute varchar(255), + constraint pk_pallet_location primary key (id) +); + +create table parcel ( + parcelid bigint generated by default as identity not null, + description varchar(255), + constraint pk_parcel primary key (parcelid) +); + +create table parcel_location ( + parcellocid bigint generated by default as identity not null, + location varchar(255), + parcelid bigint, + constraint uq_parcel_location_parcelid unique (parcelid), + constraint pk_parcel_location primary key (parcellocid) +); + +create table rawinherit_parent ( + type varchar(31) not null, + id bigint generated by default as identity not null, + val integer, + more varchar(255), + constraint pk_rawinherit_parent primary key (id) +); + +create table rawinherit_parent_rawinherit_data ( + rawinherit_parent_id bigint not null, + rawinherit_data_id bigint not null, + constraint pk_rawinherit_parent_rawinherit_data primary key (rawinherit_parent_id,rawinherit_data_id) +); + +create table e_save_test_c ( + id bigint generated by default as identity not null, + version bigint not null, + constraint pk_e_save_test_c primary key (id) +); + +create table parent_person ( + identifier integer generated by default as identity not null, + name varchar(255), + age integer, + some_bean_id integer, + parent_identifier integer, + family_name varchar(255), + address varchar(255), + constraint pk_parent_person primary key (identifier) +); + +create table c_participation ( + id bigint generated by default as identity not null, + rating integer, + type integer, + conversation_id bigint not null, + user_id bigint not null, + version bigint not null, + when_created timestamptz not null, + when_modified timestamptz not null, + constraint ck_c_participation_type check ( type in (0,1)), + constraint pk_c_participation primary key (id) +); + +create table password_store_model ( + id bigint generated by default as identity not null, + enc1 varchar(30), + enc2 varchar(40), + enc3 text, + enc4 bytea, + enc5 bytea, + enc6 bytea, + version bigint not null, + when_created timestamptz not null, + when_modified timestamptz not null, + constraint pk_password_store_model primary key (id) +); + +create table pcf_calendar ( + id bigint generated by default as identity not null, + pcf_person_id bigint not null, + version bigint not null, + constraint pk_pcf_calendar primary key (id) +); + +create table pcf_city ( + id bigint generated by default as identity not null, + pcf_country_id bigint not null, + name varchar(255), + mayor_id bigint not null, + vice_mayor_id bigint not null, + version bigint not null, + constraint uq_pcf_city_mayor_id unique (mayor_id), + constraint uq_pcf_city_vice_mayor_id unique (vice_mayor_id), + constraint pk_pcf_city primary key (id) +); + +create table pcf_country ( + id bigint generated by default as identity not null, + version bigint not null, + constraint pk_pcf_country primary key (id) +); + +create table pcf_event ( + id bigint generated by default as identity not null, + pcf_calendar_id bigint not null, + name varchar(255), + version bigint not null, + constraint pk_pcf_event primary key (id) +); + +create table pcf_person ( + id bigint generated by default as identity not null, + name varchar(255), + version bigint not null, + constraint pk_pcf_person primary key (id) +); + +create table mt_permission ( + id uuid not null, + name varchar(255), + constraint pk_mt_permission primary key (id) +); + +create table persistent_file ( + id integer generated by default as identity not null, + name varchar(255), + cretime timestamptz not null, + updtime timestamptz not null, + version bigint not null, + constraint pk_persistent_file primary key (id) +); + +create table persistent_file_content ( + id integer generated by default as identity not null, + persistent_file_id integer, + content bytea, + cretime timestamptz not null, + updtime timestamptz not null, + version bigint not null, + constraint uq_persistent_file_content_persistent_file_id unique (persistent_file_id), + constraint pk_persistent_file_content primary key (id) +); + +create table person ( + oid bigint generated by default as identity not null, + default_address_oid bigint, + version integer not null, + constraint pk_person primary key (oid) +); + +create table persons ( + id bigint generated by default as identity (start with 1000 increment by 40) not null, + surname varchar(64) not null, + name varchar(64) not null, + constraint pk_persons primary key (id) +); + +create table person_cache_email ( + id varchar(128) not null, + person_info_person_id varchar(128), + email varchar(255), + constraint pk_person_cache_email primary key (id) +); + +create table person_cache_info ( + person_id varchar(128) not null, + name varchar(255), + constraint pk_person_cache_info primary key (person_id) +); + +create table phones ( + id bigint generated by default as identity not null, + phone_number varchar(7) not null, + person_id bigint not null, + constraint uq_phones_phone_number unique (phone_number), + constraint pk_phones primary key (id) +); + +create table e_position ( + id bigint generated by default as identity not null, + name varchar(255), + contract_id bigint not null, + constraint pk_e_position primary key (id) +); + +create table primary_revision ( + id bigint not null, + revision integer not null, + name varchar(255), + version bigint not null, + constraint pk_primary_revision primary key (id,revision) +); + +create table o_product ( + id integer generated by default as identity not null, + sku varchar(20), + name varchar(255), + cretime timestamptz not null, + updtime timestamptz not null, + constraint pk_o_product primary key (id) +); + +create table pp ( + id uuid not null, + name varchar(255), + value varchar(100) not null, + constraint pk_pp primary key (id) +); + +create table pp_to_ww ( + pp_id uuid not null, + ww_id uuid not null, + constraint pk_pp_to_ww primary key (pp_id,ww_id) +); + +create table question ( + id bigint generated by default as identity not null, + name varchar(255), + groupobjectid bigint, + sequence_number integer not null, + constraint pk_question primary key (id) +); + +create table rcustomer ( + company varchar(127) not null, + name varchar(127) not null, + description varchar(255), + constraint pk_rcustomer primary key (company,name) +); + +create table r_orders ( + company varchar(127) not null, + order_number integer not null, + customername varchar(127), + item varchar(255), + constraint pk_r_orders primary key (company,order_number) +); + +create table referenced_defaults_model ( + id integer generated by default as identity not null, + defaults_model_id integer not null, + name varchar(255), + constraint pk_referenced_defaults_model primary key (id) +); + +create table referenced_defaults_model_draft ( + id integer generated by default as identity not null, + defaults_model_id integer not null, + name varchar(255), + constraint pk_referenced_defaults_model_draft primary key (id) +); + +create table referencing_bean ( + id uuid not null, + constraint pk_referencing_bean primary key (id) +); + +create table region ( + customer integer not null, + type integer not null, + description varchar(255), + version bigint not null, + constraint pk_region primary key (customer,type) +); + +create table rel_detail ( + id bigint generated by default as identity not null, + name varchar(255), + version integer not null, + constraint pk_rel_detail primary key (id) +); + +create table rel_master ( + id bigint generated by default as identity not null, + name varchar(255), + detail_id bigint, + version integer not null, + constraint pk_rel_master primary key (id) +); + +create table resourcefile ( + id varchar(64) not null, + parentresourcefileid varchar(64), + name varchar(128) not null, + constraint pk_resourcefile primary key (id) +); + +create table mt_role ( + id uuid not null, + name varchar(50), + tenant_id uuid, + version bigint not null, + constraint pk_mt_role primary key (id) +); + +create table mt_role_permission ( + mt_role_id uuid not null, + mt_permission_id uuid not null, + constraint pk_mt_role_permission primary key (mt_role_id,mt_permission_id) +); + +create table em_role ( + id bigint generated by default as identity not null, + name varchar(255), + constraint pk_em_role primary key (id) +); + +create table root_bean ( + dtype varchar(31) not null, + id uuid not null, + referencing_bean_id uuid not null, + value varchar(255), + constraint pk_root_bean primary key (id) +); + +create table f_second ( + id bigint generated by default as identity not null, + mod_name varchar(255), + first bigint, + title varchar(255), + constraint uq_f_second_first unique (first), + constraint pk_f_second primary key (id) +); + +create table section ( + id integer generated by default as identity not null, + article_id integer, + type integer, + content text, + cretime timestamptz not null, + updtime timestamptz not null, + version bigint not null, + constraint ck_section_type check ( type in (0,1)), + constraint pk_section primary key (id) +); + +create table self_parent ( + id bigint generated by default as identity not null, + name varchar(255), + parent_id bigint, + version bigint not null, + constraint pk_self_parent primary key (id) +); + +create table self_ref_customer ( + id bigint generated by default as identity not null, + name varchar(255), + referred_by_id bigint, + constraint pk_self_ref_customer primary key (id) +); + +create table self_ref_example ( + id bigint generated by default as identity not null, + name varchar(255) not null, + parent_id bigint, + constraint pk_self_ref_example primary key (id) +); + +create table e_save_test_a ( + id bigint generated by default as identity not null, + version bigint not null, + constraint pk_e_save_test_a primary key (id) +); + +create table e_save_test_b ( + id bigint generated by default as identity not null, + sibling_a_id bigint, + test_property boolean default false not null, + version bigint not null, + constraint uq_e_save_test_b_sibling_a_id unique (sibling_a_id), + constraint pk_e_save_test_b primary key (id) +); + +create table site ( + id uuid not null, + name varchar(255), + parent_id uuid, + data_container_id uuid, + site_address_id uuid, + constraint uq_site_data_container_id unique (data_container_id), + constraint uq_site_site_address_id unique (site_address_id), + constraint pk_site primary key (id) +); + +create table site_address ( + id uuid not null, + street varchar(255), + city varchar(255), + zip_code varchar(255), + constraint pk_site_address primary key (id) +); + +create table some_enum_bean ( + id bigint generated by default as identity not null, + some_enum integer, + name varchar(255), + constraint ck_some_enum_bean_some_enum check ( some_enum in (0,1)), + constraint pk_some_enum_bean primary key (id) +); + +create table some_file_bean ( + id bigint generated by default as identity not null, + name varchar(255), + content bytea, + version bigint not null, + constraint pk_some_file_bean primary key (id) +); + +create table some_new_types_bean ( + id bigint generated by default as identity not null, + dow integer, + mth integer, + yr integer, + yr_mth date, + month_day date, + sql_date date, + sql_time time, + local_date date, + local_date_time timestamptz, + offset_date_time timestamptz, + zoned_date_time timestamptz, + local_time time, + instant timestamptz, + zone_id varchar(60), + zone_offset varchar(60), + path varchar(255), + period varchar(20), + duration bigint, + version bigint not null, + constraint ck_some_new_types_bean_dow check ( dow in (1,2,3,4,5,6,7)), + constraint ck_some_new_types_bean_mth check ( mth in (1,2,3,4,5,6,7,8,9,10,11,12)), + constraint pk_some_new_types_bean primary key (id) +); + +create table some_period_bean ( + id bigint generated by default as identity not null, + anniversary date, + version bigint not null, + constraint pk_some_period_bean primary key (id) +); + +create table source_base ( + dtype varchar(31) not null, + id uuid not null, + name varchar(255), + pos integer not null, + target_id uuid, + constraint pk_source_base primary key (id) +); + +create table stockforecast ( + type varchar(31) not null, + id bigint generated by default as identity not null, + inner_report_id bigint, + constraint pk_stockforecast primary key (id) +); + +create table sub_section ( + id integer generated by default as identity not null, + section_id integer, + title varchar(255), + cretime timestamptz not null, + updtime timestamptz not null, + version bigint not null, + constraint pk_sub_section primary key (id) +); + +create table sub_type ( + sub_type_id integer generated by default as identity not null, + description varchar(255), + version bigint not null, + constraint pk_sub_type primary key (sub_type_id) +); + +create table survey ( + id bigint generated by default as identity not null, + name varchar(255), + constraint pk_survey primary key (id) +); + +create table tbytes_only ( + id integer generated by default as identity not null, + content bytea, + constraint pk_tbytes_only primary key (id) +); + +create table tcar ( + type varchar(31) not null, + plate_no varchar(32) not null, + truckload bigint, + constraint pk_tcar primary key (plate_no) +); + +create table tevent ( + id bigint generated by default as identity not null, + name varchar(255), + version bigint not null, + constraint pk_tevent primary key (id) +); + +create table tevent_many ( + id bigint generated by default as identity not null, + description varchar(255), + event_id bigint, + units integer not null, + amount float not null, + version bigint not null, + constraint pk_tevent_many primary key (id) +); + +create table tevent_one ( + id bigint generated by default as identity not null, + name varchar(255), + status integer, + event_id bigint, + version bigint not null, + constraint ck_tevent_one_status check ( status in (0,1)), + constraint uq_tevent_one_event_id unique (event_id), + constraint pk_tevent_one primary key (id) +); + +create table tint_root ( + my_type integer not null, + id integer generated by default as identity not null, + name varchar(255), + child_property varchar(255), + constraint pk_tint_root primary key (id) +); + +create table tjoda_entity ( + id integer generated by default as identity not null, + local_time time, + constraint pk_tjoda_entity primary key (id) +); + +create table t_mapsuper1 ( + id integer generated by default as identity not null, + something varchar(255), + name varchar(255), + version integer not null, + constraint pk_t_mapsuper1 primary key (id) +); + +create table t_oneb ( + id integer generated by default as identity not null, + name varchar(255), + description varchar(255), + active boolean default false not null, + constraint pk_t_oneb primary key (id) +); + +create table t_detail_with_other_namexxxyy ( + id integer not null, + name varchar(255), + description varchar(255), + some_unique_value varchar(127), + active boolean default false not null, + master_id integer, + constraint uq_t_detail_with_other_namexxxyy_some_unique_value unique (some_unique_value), + constraint pk_t_detail_with_other_namexxxyy primary key (id) +); +create sequence t_atable_detail_seq increment by 1; + +create table t_atable_thatisrelatively ( + id integer not null, + name varchar(255), + description varchar(255), + active boolean default false not null, + constraint pk_t_atable_thatisrelatively primary key (id) +); +create sequence t_atable_master_seq increment by 1; + +create table ttruck_holder ( + id bigint generated by default as identity not null, + name varchar(255), + truck_plate_no varchar(32) not null, + basic_id integer, + version bigint not null, + constraint pk_ttruck_holder primary key (id) +); + +create table ttruck_holder_item ( + id bigint generated by default as identity not null, + some_uid uuid, + foo varchar(255), + owner_id bigint not null, + constraint pk_ttruck_holder_item primary key (id) +); + +create table tuuid_entity ( + id uuid not null, + name varchar(255), + constraint pk_tuuid_entity primary key (id) +); + +create table twheel ( + id bigint generated by default as identity not null, + owner_plate_no varchar(32) not null, + constraint pk_twheel primary key (id) +); + +create table twith_pre_insert ( + id integer generated by default as identity not null, + name varchar(255) not null, + title varchar(255), + constraint pk_twith_pre_insert primary key (id) +); + +create table target_base ( + dtype varchar(31) not null, + id uuid not null, + name varchar(255), + constraint pk_target_base primary key (id) +); + +create table mt_tenant ( + id uuid not null, + name varchar(255), + version bigint not null, + constraint pk_mt_tenant primary key (id) +); + +create table test_annotation_base_entity ( + direct varchar(255), + meta varchar(255), + mixed varchar(255), + constraint_annotation varchar(40), + null1 varchar(255) not null, + null2 varchar(255), + null3 varchar(255) +); + +create table tire ( + id bigint not null, + wheel bigint, + version integer not null, + constraint uq_tire_wheel unique (wheel), + constraint pk_tire primary key (id) +); +create sequence tire_seq increment by 1; + +create table sa_tire ( + id bigint not null, + version integer not null, + constraint pk_sa_tire primary key (id) +); +create sequence sa_tire_seq increment by 1; + +create table tree_entity ( + id integer generated by default as identity not null, + text varchar(255), + parent_id integer, + constraint pk_tree_entity primary key (id) +); + +create table trip ( + id integer generated by default as identity not null, + vehicle_driver_id integer, + destination varchar(255), + address_id integer, + star_date timestamptz, + cretime timestamptz not null, + updtime timestamptz not null, + version bigint not null, + constraint pk_trip primary key (id) +); + +create table truck_ref ( + id integer generated by default as identity not null, + something varchar(255), + constraint pk_truck_ref primary key (id) +); + +create table tune ( + id bigint generated by default as identity not null, + name varchar(255), + constraint pk_tune primary key (id) +); + +create table "type" ( + customer integer not null, + type integer not null, + description varchar(255), + sub_type_id integer, + version bigint not null, + constraint pk_type primary key (customer,type) +); + +create table tz_bean ( + id bigint generated by default as identity not null, + moda varchar(255), + ts timestamptz, + tstz timestamptz, + constraint pk_tz_bean primary key (id) +); + +create table usib_child ( + id uuid not null, + parent_id bigint, + deleted boolean default false not null, + constraint pk_usib_child primary key (id) +); + +create table usib_child_sibling ( + id bigint generated by default as identity not null, + child_id uuid, + deleted boolean default false not null, + constraint uq_usib_child_sibling_child_id unique (child_id), + constraint pk_usib_child_sibling primary key (id) +); + +create table usib_parent ( + id bigint generated by default as identity not null, + deleted boolean default false not null, + constraint pk_usib_parent primary key (id) +); + +create table ut_detail ( + id integer generated by default as identity not null, + utmaster_id integer not null, + name varchar(255), + qty integer, + amount float, + version integer not null, + constraint pk_ut_detail primary key (id) +); + +create table ut_master ( + id integer generated by default as identity not null, + name varchar(255), + description varchar(255), + event_date date, + version integer not null, + constraint pk_ut_master primary key (id) +); + +create table uuone ( + id uuid not null, + name varchar(255), + description varchar(255), + version bigint not null, + constraint pk_uuone primary key (id) +); + +create table uutwo ( + id uuid not null, + name varchar(255), + notes varchar(255), + master_id uuid, + version bigint not null, + constraint pk_uutwo primary key (id) +); + +create table oto_user ( + id bigint generated by default as identity not null, + name varchar(255), + account_id bigint not null, + version bigint not null, + when_created timestamptz not null, + when_modified timestamptz not null, + constraint uq_oto_user_account_id unique (account_id), + constraint pk_oto_user primary key (id) +); + +create table c_user ( + id bigint generated by default as identity not null, + inactive boolean default false not null, + name varchar(255), + email varchar(255), + password_hash varchar(255), + group_id bigint, + version bigint not null, + when_created timestamptz not null, + when_modified timestamptz not null, + constraint pk_c_user primary key (id) +); + +create table tx_user ( + id bigint generated by default as identity not null, + name varchar(255), + constraint pk_tx_user primary key (id) +); + +create table g_user ( + id bigint generated by default as identity not null, + username varchar(255), + version bigint not null, + constraint pk_g_user primary key (id) +); + +create table em_user ( + id bigint generated by default as identity not null, + name varchar(255), + constraint pk_em_user primary key (id) +); + +create table user_interest_live ( + user_id bigint not null, + live_id bigint not null, + created_at timestamptz not null, + constraint pk_user_interest_live primary key (user_id,live_id) +); + +create table em_user_role ( + user_id bigint not null, + role_id bigint not null, + constraint pk_em_user_role primary key (user_id,role_id) +); + +create table vehicle ( + dtype varchar(3) not null, + id integer generated by default as identity not null, + license_number varchar(255), + registration_date timestamptz, + lease_id bigint, + cretime timestamptz not null, + updtime timestamptz not null, + version bigint not null, + siz varchar(3), + driver varchar(255), + car_ref_id integer, + notes varchar(255), + truck_ref_id integer, + capacity float, + constraint ck_vehicle_siz check ( siz in ('S','M','L','H')), + constraint pk_vehicle primary key (id) +); + +create table vehicle_driver ( + id integer generated by default as identity not null, + name varchar(255), + vehicle_id integer, + address_id integer, + license_issued_on timestamptz, + cretime timestamptz not null, + updtime timestamptz not null, + version bigint not null, + constraint pk_vehicle_driver primary key (id) +); + +create table vehicle_lease ( + dtype varchar(31) not null, + id bigint generated by default as identity not null, + name varchar(255), + active_start date, + active_end date, + version bigint not null, + bond decimal(16,3), + min_duration integer not null, + day_rate decimal(16,3), + max_days integer, + constraint pk_vehicle_lease primary key (id) +); + +create table version_child ( + id integer generated by default as identity not null, + name varchar(255), + parent_id integer, + version integer not null, + position integer, + constraint pk_version_child primary key (id) +); + +create table version_parent ( + id integer generated by default as identity not null, + name varchar(255), + version integer not null, + constraint pk_version_parent primary key (id) +); + +create table version_toy ( + id integer generated by default as identity not null, + name varchar(255), + child_id integer, + version integer not null, + position integer, + constraint pk_version_toy primary key (id) +); + +create table warehouses ( + id integer generated by default as identity not null, + officezoneid integer, + constraint pk_warehouses primary key (id) +); + +create table warehousesshippingzones ( + warehouseid integer not null, + shippingzoneid integer not null, + constraint pk_warehousesshippingzones primary key (warehouseid,shippingzoneid) +); + +create table wheel ( + id bigint not null, + version integer not null, + constraint pk_wheel primary key (id) +); +create sequence wheel_seq increment by 1; + +create table sa_wheel ( + id bigint not null, + tire bigint, + car bigint, + version integer not null, + constraint pk_sa_wheel primary key (id) +); +create sequence sa_wheel_seq increment by 1; + +create table sp_car_wheel ( + id bigint not null, + name varchar(255), + version integer not null, + constraint pk_sp_car_wheel primary key (id) +); +create sequence sp_car_wheel_seq increment by 1; + +create table g_who_props_otm ( + id bigint generated by default as identity not null, + name varchar(255), + version bigint not null, + when_created timestamptz not null, + when_modified timestamptz not null, + who_created_id bigint, + who_modified_id bigint, + constraint pk_g_who_props_otm primary key (id) +); + +create table with_zero ( + id bigint generated by default as identity not null, + name varchar(255), + parent_id integer, + lang varchar(2) default 'en' not null, + version bigint not null, + constraint pk_with_zero primary key (id) +); + +create table parent ( + id integer generated by default as identity not null, + name varchar(255), + constraint pk_parent primary key (id) +); + +create table wview ( + id uuid not null, + name varchar(127) not null, + constraint uq_wview_name unique (name), + constraint pk_wview primary key (id) +); + +create table zones ( + type varchar(31) not null, + id integer generated by default as identity not null, + attribute varchar(255), + constraint pk_zones primary key (id) +); + +create index ix_contact_last_name_first_name on contact (last_name,first_name); +create index ix_e_basic_name on e_basic (name); +create index ix_efile2_no_fk_owner_id on efile2_no_fk (owner_id); +create index ix_ecsm_values_host_id on ecsm_values (host_id); +create index ix_order_referenced_parent_type on order_referenced_parent (type); +create index ix_organization_node_kind on organization_node (kind); +create unique index concurrently ix_t_detail_with_other_namexxxyy_lowername on t_detail_with_other_namexxxyy (lower(name)); +create index ix_t_detail_with_other_namexxxyy_defn on t_detail_with_other_namexxxyy using hash (lower(name)) where lower(name) like 'r%'; +create index ano_3 on test_annotation_base_entity (direct); +create index ano_1 on test_annotation_base_entity (direct); +create index ano_2 on test_annotation_base_entity (direct); +create index ix_bar_foo_id on bar (foo_id); +alter table bar add constraint fk_bar_foo_id foreign key (foo_id) references foo (foo_id) on delete restrict on update restrict; + +create index ix_acl_container_relation_container_id on acl_container_relation (container_id); +alter table acl_container_relation add constraint fk_acl_container_relation_container_id foreign key (container_id) references contract (id) on delete restrict on update restrict; + +create index ix_acl_container_relation_acl_entry_id on acl_container_relation (acl_entry_id); +alter table acl_container_relation add constraint fk_acl_container_relation_acl_entry_id foreign key (acl_entry_id) references acl (id) on delete restrict on update restrict; + +create index ix_addr_employee_id on addr (employee_id); +alter table addr add constraint fk_addr_employee_id foreign key (employee_id) references empl (id) on delete restrict on update restrict; + +create index ix_o_address_country_code on o_address (country_code); +alter table o_address add constraint fk_o_address_country_code foreign key (country_code) references o_country (code) on delete restrict on update restrict; + +alter table album add constraint fk_album_cover_id foreign key (cover_id) references cover (id) on delete restrict on update restrict; + +create index ix_animal_shelter_id on animal (shelter_id); +alter table animal add constraint fk_animal_shelter_id foreign key (shelter_id) references animal_shelter (id) on delete restrict on update restrict; + +create index ix_attribute_attribute_holder_id on attribute (attribute_holder_id); +alter table attribute add constraint fk_attribute_attribute_holder_id foreign key (attribute_holder_id) references attribute_holder (id) on delete restrict on update restrict; + +create index ix_bbookmark_user_id on bbookmark (user_id); +alter table bbookmark add constraint fk_bbookmark_user_id foreign key (user_id) references bbookmark_user (id) on delete restrict on update restrict; + +create index ix_bbookmark_user_org_id on bbookmark_user (org_id); +alter table bbookmark_user add constraint fk_bbookmark_user_org_id foreign key (org_id) references bbookmark_org (id) on delete restrict on update restrict; + +create index ix_bsite_user_a_site_id on bsite_user_a (site_id); +alter table bsite_user_a add constraint fk_bsite_user_a_site_id foreign key (site_id) references bsite (id) on delete restrict on update restrict; + +create index ix_bsite_user_a_user_id on bsite_user_a (user_id); +alter table bsite_user_a add constraint fk_bsite_user_a_user_id foreign key (user_id) references buser (id) on delete restrict on update restrict; + +create index ix_bsite_user_b_site on bsite_user_b (site); +alter table bsite_user_b add constraint fk_bsite_user_b_site foreign key (site) references bsite (id) on delete restrict on update restrict; + +create index ix_bsite_user_b_usr on bsite_user_b (usr); +alter table bsite_user_b add constraint fk_bsite_user_b_usr foreign key (usr) references buser (id) on delete restrict on update restrict; + +create index ix_bsite_user_c_site_uid on bsite_user_c (site_uid); +alter table bsite_user_c add constraint fk_bsite_user_c_site_uid foreign key (site_uid) references bsite (id) on delete restrict on update restrict; + +create index ix_bsite_user_c_user_uid on bsite_user_c (user_uid); +alter table bsite_user_c add constraint fk_bsite_user_c_user_uid foreign key (user_uid) references buser (id) on delete restrict on update restrict; + +create index ix_bsite_user_e_site_id on bsite_user_e (site_id); +alter table bsite_user_e add constraint fk_bsite_user_e_site_id foreign key (site_id) references bsite (id) on delete restrict on update restrict; + +create index ix_bsite_user_e_user_id on bsite_user_e (user_id); +alter table bsite_user_e add constraint fk_bsite_user_e_user_id foreign key (user_id) references buser (id) on delete restrict on update restrict; + +alter table basic_draftable_bean add constraint fk_basic_draftable_bean_id foreign key (id) references basic_draftable_bean_draft (id) on delete restrict on update restrict; + +alter table drel_booking add constraint fk_drel_booking_agent_invoice foreign key (agent_invoice) references drel_invoice (id) on delete restrict on update restrict; + +alter table drel_booking add constraint fk_drel_booking_client_invoice foreign key (client_invoice) references drel_invoice (id) on delete restrict on update restrict; + +create index ix_cepproduct_category_category_id on cepproduct_category (category_id); +alter table cepproduct_category add constraint fk_cepproduct_category_category_id foreign key (category_id) references cepcategory (id) on delete restrict on update restrict; + +create index ix_cepproduct_category_product_id on cepproduct_category (product_id); +alter table cepproduct_category add constraint fk_cepproduct_category_product_id foreign key (product_id) references cepproduct (id) on delete restrict on update restrict; + +create index ix_ciaddress_street_id on ciaddress (street_id); +alter table ciaddress add constraint fk_ciaddress_street_id foreign key (street_id) references cistreet_parent (id) on delete restrict on update restrict; + +create index ix_cicustomer_parent_address_id on cicustomer_parent (address_id); +alter table cicustomer_parent add constraint fk_cicustomer_parent_address_id foreign key (address_id) references ciaddress (id) on delete restrict on update restrict; + +create index ix_cinh_ref_ref_id on cinh_ref (ref_id); +alter table cinh_ref add constraint fk_cinh_ref_ref_id foreign key (ref_id) references cinh_root (id) on delete restrict on update restrict; + +create index ix_ckey_detail_parent on ckey_detail (one_key,two_key); +alter table ckey_detail add constraint fk_ckey_detail_parent foreign key (one_key,two_key) references ckey_parent (one_key,two_key) on delete restrict on update restrict; + +create index ix_ckey_parent_assoc_id on ckey_parent (assoc_id); +alter table ckey_parent add constraint fk_ckey_parent_assoc_id foreign key (assoc_id) references ckey_assoc (id) on delete restrict on update restrict; + +create index ix_coone_many_coone_id on coone_many (coone_id); +alter table coone_many add constraint fk_coone_many_coone_id foreign key (coone_id) references coone (id) on delete restrict on update restrict; + +alter table coroot add constraint fk_coroot_one_id foreign key (one_id) references coone (id) on delete restrict on update restrict; + +create index ix_calculation_result_product_configuration_id on calculation_result (product_configuration_id); +alter table calculation_result add constraint fk_calculation_result_product_configuration_id foreign key (product_configuration_id) references configuration (id) on delete restrict on update restrict; + +create index ix_calculation_result_group_configuration_id on calculation_result (group_configuration_id); +alter table calculation_result add constraint fk_calculation_result_group_configuration_id foreign key (group_configuration_id) references configuration (id) on delete restrict on update restrict; + +create index ix_sp_car_car_wheels_sp_car_car on sp_car_car_wheels (car); +alter table sp_car_car_wheels add constraint fk_sp_car_car_wheels_sp_car_car foreign key (car) references sp_car_car (id) on delete restrict on update restrict; + +create index ix_sp_car_car_wheels_sp_car_wheel on sp_car_car_wheels (wheel); +alter table sp_car_car_wheels add constraint fk_sp_car_car_wheels_sp_car_wheel foreign key (wheel) references sp_car_wheel (id) on delete restrict on update restrict; + +create index ix_sp_car_car_doors_sp_car_car on sp_car_car_doors (car); +alter table sp_car_car_doors add constraint fk_sp_car_car_doors_sp_car_car foreign key (car) references sp_car_car (id) on delete restrict on update restrict; + +create index ix_sp_car_car_doors_sp_car_door on sp_car_car_doors (door); +alter table sp_car_car_doors add constraint fk_sp_car_car_doors_sp_car_door foreign key (door) references sp_car_door (id) on delete restrict on update restrict; + +create index ix_car_accessory_fuse_id on car_accessory (fuse_id); +alter table car_accessory add constraint fk_car_accessory_fuse_id foreign key (fuse_id) references car_fuse (id) on delete restrict on update restrict; + +create index ix_car_accessory_car_id on car_accessory (car_id); +alter table car_accessory add constraint fk_car_accessory_car_id foreign key (car_id) references vehicle (id) on delete restrict on update restrict; + +create index ix_category_surveyobjectid on category (surveyobjectid); +alter table category add constraint fk_category_surveyobjectid foreign key (surveyobjectid) references survey (id) on delete restrict on update restrict; + +alter table e_save_test_d add constraint fk_e_save_test_d_parent_id foreign key (parent_id) references e_save_test_c (id) on delete restrict on update restrict; + +create index ix_child_person_some_bean_id on child_person (some_bean_id); +alter table child_person add constraint fk_child_person_some_bean_id foreign key (some_bean_id) references e_basic (id) on delete restrict on update restrict; + +create index ix_child_person_parent_identifier on child_person (parent_identifier); +alter table child_person add constraint fk_child_person_parent_identifier foreign key (parent_identifier) references parent_person (identifier) on delete restrict on update restrict; + +create index ix_cke_client_user on cke_client (username,cod_cpny); +alter table cke_client add constraint fk_cke_client_user foreign key (username,cod_cpny) references cke_user (username,cod_cpny) on delete restrict on update restrict; + +alter table class_super_monkey add constraint fk_class_super_monkey_class_super foreign key (class_super_sid) references class_super (sid) on delete restrict on update restrict; + +alter table class_super_monkey add constraint fk_class_super_monkey_monkey foreign key (monkey_mid) references monkey (mid) on delete restrict on update restrict; + +create index ix_configuration_configurations_id on configuration (configurations_id); +alter table configuration add constraint fk_configuration_configurations_id foreign key (configurations_id) references configurations (id) on delete restrict on update restrict; + +create index ix_contact_customer_id on contact (customer_id); +alter table contact add constraint fk_contact_customer_id foreign key (customer_id) references o_customer (id) on delete restrict on update restrict; + +create index ix_contact_group_id on contact (group_id); +alter table contact add constraint fk_contact_group_id foreign key (group_id) references contact_group (id) on delete restrict on update restrict; + +create index ix_contact_note_contact_id on contact_note (contact_id); +alter table contact_note add constraint fk_contact_note_contact_id foreign key (contact_id) references contact (id) on delete restrict on update restrict; + +create index ix_contract_costs_position_id on contract_costs (position_id); +alter table contract_costs add constraint fk_contract_costs_position_id foreign key (position_id) references e_position (id) on delete restrict on update restrict; + +create index ix_c_conversation_group_id on c_conversation (group_id); +alter table c_conversation add constraint fk_c_conversation_group_id foreign key (group_id) references c_group (id) on delete restrict on update restrict; + +create index ix_o_customer_billing_address_id on o_customer (billing_address_id); +alter table o_customer add constraint fk_o_customer_billing_address_id foreign key (billing_address_id) references o_address (id) on delete restrict on update restrict; + +create index ix_o_customer_shipping_address_id on o_customer (shipping_address_id); +alter table o_customer add constraint fk_o_customer_shipping_address_id foreign key (shipping_address_id) references o_address (id) on delete restrict on update restrict; + +create index ix_dcredit_drol_dcredit on dcredit_drol (dcredit_id); +alter table dcredit_drol add constraint fk_dcredit_drol_dcredit foreign key (dcredit_id) references dcredit (id) on delete restrict on update restrict; + +create index ix_dcredit_drol_drol on dcredit_drol (drol_id); +alter table dcredit_drol add constraint fk_dcredit_drol_drol foreign key (drol_id) references drol (id) on delete restrict on update restrict; + +create index ix_dmachine_organisation_id on dmachine (organisation_id); +alter table dmachine add constraint fk_dmachine_organisation_id foreign key (organisation_id) references dorg (id) on delete restrict on update restrict; + +create index ix_d_machine_aux_use_machine_id on d_machine_aux_use (machine_id); +alter table d_machine_aux_use add constraint fk_d_machine_aux_use_machine_id foreign key (machine_id) references dmachine (id) on delete restrict on update restrict; + +create index ix_d_machine_stats_machine_id on d_machine_stats (machine_id); +alter table d_machine_stats add constraint fk_d_machine_stats_machine_id foreign key (machine_id) references dmachine (id) on delete restrict on update restrict; + +create index ix_d_machine_use_machine_id on d_machine_use (machine_id); +alter table d_machine_use add constraint fk_d_machine_use_machine_id foreign key (machine_id) references dmachine (id) on delete restrict on update restrict; + +create index ix_drot_drol_drot on drot_drol (drot_id); +alter table drot_drol add constraint fk_drot_drol_drot foreign key (drot_id) references drot (id) on delete restrict on update restrict; + +create index ix_drot_drol_drol on drot_drol (drol_id); +alter table drot_drol add constraint fk_drot_drol_drol foreign key (drol_id) references drol (id) on delete restrict on update restrict; + +create index ix_dc_detail_master_id on dc_detail (master_id); +alter table dc_detail add constraint fk_dc_detail_master_id foreign key (master_id) references dc_master (id) on delete restrict on update restrict; + +alter table defaults_model add constraint fk_defaults_model_id foreign key (id) references defaults_model_draft (id) on delete restrict on update restrict; + +create index ix_dfk_cascade_one_id on dfk_cascade (one_id); +alter table dfk_cascade add constraint fk_dfk_cascade_one_id foreign key (one_id) references dfk_cascade_one (id) on delete cascade on update cascade; + +create index ix_dfk_set_null_one_id on dfk_set_null (one_id); +alter table dfk_set_null add constraint fk_dfk_set_null_one_id foreign key (one_id) references dfk_one (id) on delete set null on update set null; + +alter table doc add constraint fk_doc_id foreign key (id) references doc_draft (id) on delete restrict on update restrict; + +create index ix_doc_link_doc on doc_link (doc_id); +alter table doc_link add constraint fk_doc_link_doc foreign key (doc_id) references doc (id) on delete restrict on update restrict; + +create index ix_doc_link_link on doc_link (link_id); +alter table doc_link add constraint fk_doc_link_link foreign key (link_id) references link (id) on delete restrict on update restrict; + +alter table document add constraint fk_document_id foreign key (id) references document_draft (id) on delete restrict on update restrict; + +create index ix_document_organisation_id on document (organisation_id); +alter table document add constraint fk_document_organisation_id foreign key (organisation_id) references organisation (id) on delete restrict on update restrict; + +create index ix_document_draft_organisation_id on document_draft (organisation_id); +alter table document_draft add constraint fk_document_draft_organisation_id foreign key (organisation_id) references organisation (id) on delete restrict on update restrict; + +create index ix_document_media_document_id on document_media (document_id); +alter table document_media add constraint fk_document_media_document_id foreign key (document_id) references document (id) on delete restrict on update restrict; + +create index ix_document_media_draft_document_id on document_media_draft (document_id); +alter table document_media_draft add constraint fk_document_media_draft_document_id foreign key (document_id) references document_draft (id) on delete restrict on update restrict; + +create index ix_e_basicenc_relate_other_id on e_basicenc_relate (other_id); +alter table e_basicenc_relate add constraint fk_e_basicenc_relate_other_id foreign key (other_id) references e_basicenc (id) on delete restrict on update restrict; + +create index ix_ebasic_json_map_detail_owner_id on ebasic_json_map_detail (owner_id); +alter table ebasic_json_map_detail add constraint fk_ebasic_json_map_detail_owner_id foreign key (owner_id) references ebasic_json_map (id) on delete restrict on update restrict; + +create index ix_ebasic_no_sdchild_owner_id on ebasic_no_sdchild (owner_id); +alter table ebasic_no_sdchild add constraint fk_ebasic_no_sdchild_owner_id foreign key (owner_id) references ebasic_soft_delete (id) on delete restrict on update restrict; + +create index ix_ebasic_sdchild_owner_id on ebasic_sdchild (owner_id); +alter table ebasic_sdchild add constraint fk_ebasic_sdchild_owner_id foreign key (owner_id) references ebasic_soft_delete (id) on delete restrict on update restrict; + +create index ix_ecache_child_root_id on ecache_child (root_id); +alter table ecache_child add constraint fk_ecache_child_root_id foreign key (root_id) references ecache_root (id) on delete restrict on update restrict; + +alter table edefault_prop add constraint fk_edefault_prop_e_simple_usertypeid foreign key (e_simple_usertypeid) references esimple (usertypeid) on delete restrict on update restrict; + +create index ix_eemb_inner_outer_id on eemb_inner (outer_id); +alter table eemb_inner add constraint fk_eemb_inner_outer_id foreign key (outer_id) references eemb_outer (id) on delete restrict on update restrict; + +create index ix_einvoice_person_id on einvoice (person_id); +alter table einvoice add constraint fk_einvoice_person_id foreign key (person_id) references eperson (id) on delete restrict on update restrict; + +create index ix_enull_collection_detail_enull_collection_id on enull_collection_detail (enull_collection_id); +alter table enull_collection_detail add constraint fk_enull_collection_detail_enull_collection_id foreign key (enull_collection_id) references enull_collection (id) on delete restrict on update restrict; + +create index ix_eopt_one_a_b_id on eopt_one_a (b_id); +alter table eopt_one_a add constraint fk_eopt_one_a_b_id foreign key (b_id) references eopt_one_b (id) on delete restrict on update restrict; + +create index ix_eopt_one_b_c_id on eopt_one_b (c_id); +alter table eopt_one_b add constraint fk_eopt_one_b_c_id foreign key (c_id) references eopt_one_c (id) on delete restrict on update restrict; + +create index ix_eper_addr_ma_country_code on eper_addr (ma_country_code); +alter table eper_addr add constraint fk_eper_addr_ma_country_code foreign key (ma_country_code) references o_country (code) on delete restrict on update restrict; + +create index ix_esoft_del_book_lend_by_id on esoft_del_book (lend_by_id); +alter table esoft_del_book add constraint fk_esoft_del_book_lend_by_id foreign key (lend_by_id) references esoft_del_user (id) on delete restrict on update restrict; + +create index ix_esoft_del_book_esoft_del_user_esoft_del_book on esoft_del_book_esoft_del_user (esoft_del_book_id); +alter table esoft_del_book_esoft_del_user add constraint fk_esoft_del_book_esoft_del_user_esoft_del_book foreign key (esoft_del_book_id) references esoft_del_book (id) on delete restrict on update restrict; + +create index ix_esoft_del_book_esoft_del_user_esoft_del_user on esoft_del_book_esoft_del_user (esoft_del_user_id); +alter table esoft_del_book_esoft_del_user add constraint fk_esoft_del_book_esoft_del_user_esoft_del_user foreign key (esoft_del_user_id) references esoft_del_user (id) on delete restrict on update restrict; + +create index ix_esoft_del_down_esoft_del_mid_id on esoft_del_down (esoft_del_mid_id); +alter table esoft_del_down add constraint fk_esoft_del_down_esoft_del_mid_id foreign key (esoft_del_mid_id) references esoft_del_mid (id) on delete restrict on update restrict; + +create index ix_esoft_del_mid_top_id on esoft_del_mid (top_id); +alter table esoft_del_mid add constraint fk_esoft_del_mid_top_id foreign key (top_id) references esoft_del_top (id) on delete restrict on update restrict; + +create index ix_esoft_del_mid_up_id on esoft_del_mid (up_id); +alter table esoft_del_mid add constraint fk_esoft_del_mid_up_id foreign key (up_id) references esoft_del_up (id) on delete restrict on update restrict; + +alter table esoft_del_one_a add constraint fk_esoft_del_one_a_oneb_id foreign key (oneb_id) references esoft_del_one_b (id) on delete restrict on update restrict; + +create index ix_esoft_del_role_esoft_del_user_esoft_del_role on esoft_del_role_esoft_del_user (esoft_del_role_id); +alter table esoft_del_role_esoft_del_user add constraint fk_esoft_del_role_esoft_del_user_esoft_del_role foreign key (esoft_del_role_id) references esoft_del_role (id) on delete restrict on update restrict; + +create index ix_esoft_del_role_esoft_del_user_esoft_del_user on esoft_del_role_esoft_del_user (esoft_del_user_id); +alter table esoft_del_role_esoft_del_user add constraint fk_esoft_del_role_esoft_del_user_esoft_del_user foreign key (esoft_del_user_id) references esoft_del_user (id) on delete restrict on update restrict; + +create index ix_esoft_del_user_esoft_del_role_esoft_del_user on esoft_del_user_esoft_del_role (esoft_del_user_id); +alter table esoft_del_user_esoft_del_role add constraint fk_esoft_del_user_esoft_del_role_esoft_del_user foreign key (esoft_del_user_id) references esoft_del_user (id) on delete restrict on update restrict; + +create index ix_esoft_del_user_esoft_del_role_esoft_del_role on esoft_del_user_esoft_del_role (esoft_del_role_id); +alter table esoft_del_user_esoft_del_role add constraint fk_esoft_del_user_esoft_del_role_esoft_del_role foreign key (esoft_del_role_id) references esoft_del_role (id) on delete restrict on update restrict; + +create index ix_rawinherit_uncle_parent_id on rawinherit_uncle (parent_id); +alter table rawinherit_uncle add constraint fk_rawinherit_uncle_parent_id foreign key (parent_id) references rawinherit_parent (id) on delete restrict on update restrict; + +create index ix_evanilla_collection_detail_evanilla_collection_id on evanilla_collection_detail (evanilla_collection_id); +alter table evanilla_collection_detail add constraint fk_evanilla_collection_detail_evanilla_collection_id foreign key (evanilla_collection_id) references evanilla_collection (id) on delete restrict on update restrict; + +create index ix_ec_enum_person_tags_ec_enum_person_id on ec_enum_person_tags (ec_enum_person_id); +alter table ec_enum_person_tags add constraint fk_ec_enum_person_tags_ec_enum_person_id foreign key (ec_enum_person_id) references ec_enum_person (id) on delete restrict on update restrict; + +create index ix_ec_person_phone_owner_id on ec_person_phone (owner_id); +alter table ec_person_phone add constraint fk_ec_person_phone_owner_id foreign key (owner_id) references ec_person (id) on delete restrict on update restrict; + +create index ix_ec_top_person_id on ec_top (person_id); +alter table ec_top add constraint fk_ec_top_person_id foreign key (person_id) references ecs_person (id) on delete restrict on update restrict; + +create index ix_ec_top_ecs_person_ec_top on ec_top_ecs_person (ec_top_id); +alter table ec_top_ecs_person add constraint fk_ec_top_ecs_person_ec_top foreign key (ec_top_id) references ec_top (id) on delete restrict on update restrict; + +create index ix_ec_top_ecs_person_ecs_person on ec_top_ecs_person (ecs_person_id); +alter table ec_top_ecs_person add constraint fk_ec_top_ecs_person_ecs_person foreign key (ecs_person_id) references ecs_person (id) on delete restrict on update restrict; + +create index ix_ecbl_person_phone_numbers_person_id on ecbl_person_phone_numbers (person_id); +alter table ecbl_person_phone_numbers add constraint fk_ecbl_person_phone_numbers_person_id foreign key (person_id) references ecbl_person (id) on delete restrict on update restrict; + +create index ix_ecbm_person_phone_numbers_person_id on ecbm_person_phone_numbers (person_id); +alter table ecbm_person_phone_numbers add constraint fk_ecbm_person_phone_numbers_person_id foreign key (person_id) references ecbm_person (id) on delete restrict on update restrict; + +create index ix_ecm_person_phone_numbers_ecm_person_id on ecm_person_phone_numbers (ecm_person_id); +alter table ecm_person_phone_numbers add constraint fk_ecm_person_phone_numbers_ecm_person_id foreign key (ecm_person_id) references ecm_person (id) on delete restrict on update restrict; + +create index ix_ecmc_person_phone_numbers_ecmc_person_id on ecmc_person_phone_numbers (ecmc_person_id); +alter table ecmc_person_phone_numbers add constraint fk_ecmc_person_phone_numbers_ecmc_person_id foreign key (ecmc_person_id) references ecmc_person (id) on delete restrict on update restrict; + +create index ix_ecs_person_phone_ecs_person_id on ecs_person_phone (ecs_person_id); +alter table ecs_person_phone add constraint fk_ecs_person_phone_ecs_person_id foreign key (ecs_person_id) references ecs_person (id) on delete restrict on update restrict; + +create index ix_ecsm_child_ecsm_parent_id on ecsm_child (ecsm_parent_id); +alter table ecsm_child add constraint fk_ecsm_child_ecsm_parent_id foreign key (ecsm_parent_id) references ecsm_parent (id) on delete restrict on update restrict; + +create index ix_td_child_parent_id on td_child (parent_id); +alter table td_child add constraint fk_td_child_parent_id foreign key (parent_id) references td_parent (parent_id) on delete restrict on update restrict; + +create index ix_element_bean_complex_bean_id on element_bean (complex_bean_id); +alter table element_bean add constraint fk_element_bean_complex_bean_id foreign key (complex_bean_id) references root_bean (id) on delete restrict on update restrict; + +create index ix_empl_default_address_id on empl (default_address_id); +alter table empl add constraint fk_empl_default_address_id foreign key (default_address_id) references addr (id) on delete restrict on update restrict; + +create index ix_esd_detail_master_id on esd_detail (master_id); +alter table esd_detail add constraint fk_esd_detail_master_id foreign key (master_id) references esd_master (id) on delete restrict on update restrict; + +create index ix_grand_parent_person_some_bean_id on grand_parent_person (some_bean_id); +alter table grand_parent_person add constraint fk_grand_parent_person_some_bean_id foreign key (some_bean_id) references e_basic (id) on delete restrict on update restrict; + +create index ix_survey_group_categoryobjectid on survey_group (categoryobjectid); +alter table survey_group add constraint fk_survey_group_categoryobjectid foreign key (categoryobjectid) references category (id) on delete restrict on update restrict; + +create index ix_hx_link_doc_hx_link on hx_link_doc (hx_link_id); +alter table hx_link_doc add constraint fk_hx_link_doc_hx_link foreign key (hx_link_id) references hx_link (id) on delete restrict on update restrict; + +create index ix_hx_link_doc_he_doc on hx_link_doc (he_doc_id); +alter table hx_link_doc add constraint fk_hx_link_doc_he_doc foreign key (he_doc_id) references he_doc (id) on delete restrict on update restrict; + +create index ix_hi_link_doc_hi_link on hi_link_doc (hi_link_id); +alter table hi_link_doc add constraint fk_hi_link_doc_hi_link foreign key (hi_link_id) references hi_link (id) on delete restrict on update restrict; + +create index ix_hi_link_doc_hi_doc on hi_link_doc (hi_doc_id); +alter table hi_link_doc add constraint fk_hi_link_doc_hi_doc foreign key (hi_doc_id) references hi_doc (id) on delete restrict on update restrict; + +create index ix_hi_tthree_hi_ttwo_id on hi_tthree (hi_ttwo_id); +alter table hi_tthree add constraint fk_hi_tthree_hi_ttwo_id foreign key (hi_ttwo_id) references hi_ttwo (id) on delete restrict on update restrict; + +create index ix_hi_ttwo_hi_tone_id on hi_ttwo (hi_tone_id); +alter table hi_ttwo add constraint fk_hi_ttwo_hi_tone_id foreign key (hi_tone_id) references hi_tone (id) on delete restrict on update restrict; + +alter table hsd_setting add constraint fk_hsd_setting_user_id foreign key (user_id) references hsd_user (id) on delete restrict on update restrict; + +create index ix_iaf_segment_status_id on iaf_segment (status_id); +alter table iaf_segment add constraint fk_iaf_segment_status_id foreign key (status_id) references iaf_segment_status (id) on delete restrict on update restrict; + +create index ix_imrelated_owner_id on imrelated (owner_id); +alter table imrelated add constraint fk_imrelated_owner_id foreign key (owner_id) references imroot (id) on delete restrict on update restrict; + +create index ix_info_contact_company_id on info_contact (company_id); +alter table info_contact add constraint fk_info_contact_company_id foreign key (company_id) references info_company (id) on delete restrict on update restrict; + +alter table info_customer add constraint fk_info_customer_company_id foreign key (company_id) references info_company (id) on delete restrict on update restrict; + +alter table inner_report add constraint fk_inner_report_forecast_id foreign key (forecast_id) references stockforecast (id) on delete restrict on update restrict; + +create index ix_drel_invoice_booking on drel_invoice (booking); +alter table drel_invoice add constraint fk_drel_invoice_booking foreign key (booking) references drel_booking (id) on delete restrict on update restrict; + +create index ix_item_etype on item (customer,type); +alter table item add constraint fk_item_etype foreign key (customer,type) references "type" (customer,type) on delete restrict on update restrict; + +create index ix_item_eregion on item (customer,region); +alter table item add constraint fk_item_eregion foreign key (customer,region) references region (customer,type) on delete restrict on update restrict; + +alter table mkeygroup_monkey add constraint fk_mkeygroup_monkey_mkeygroup foreign key (mkeygroup_pid) references mkeygroup (pid) on delete restrict on update restrict; + +alter table mkeygroup_monkey add constraint fk_mkeygroup_monkey_monkey foreign key (monkey_mid) references monkey (mid) on delete restrict on update restrict; + +alter table trainer_monkey add constraint fk_trainer_monkey_trainer foreign key (trainer_tid) references trainer (tid) on delete restrict on update restrict; + +alter table trainer_monkey add constraint fk_trainer_monkey_monkey foreign key (monkey_mid) references monkey (mid) on delete restrict on update restrict; + +alter table troop_monkey add constraint fk_troop_monkey_troop foreign key (troop_pid) references troop (pid) on delete restrict on update restrict; + +alter table troop_monkey add constraint fk_troop_monkey_monkey foreign key (monkey_mid) references monkey (mid) on delete restrict on update restrict; + +create index ix_l2_cldf_reset_bean_child_parent_id on l2_cldf_reset_bean_child (parent_id); +alter table l2_cldf_reset_bean_child add constraint fk_l2_cldf_reset_bean_child_parent_id foreign key (parent_id) references l2_cldf_reset_bean (id) on delete restrict on update restrict; + +create index ix_level1_level4_level1 on level1_level4 (level1_id); +alter table level1_level4 add constraint fk_level1_level4_level1 foreign key (level1_id) references level1 (id) on delete restrict on update restrict; + +create index ix_level1_level4_level4 on level1_level4 (level4_id); +alter table level1_level4 add constraint fk_level1_level4_level4 foreign key (level4_id) references level4 (id) on delete restrict on update restrict; + +create index ix_level1_level2_level1 on level1_level2 (level1_id); +alter table level1_level2 add constraint fk_level1_level2_level1 foreign key (level1_id) references level1 (id) on delete restrict on update restrict; + +create index ix_level1_level2_level2 on level1_level2 (level2_id); +alter table level1_level2 add constraint fk_level1_level2_level2 foreign key (level2_id) references level2 (id) on delete restrict on update restrict; + +create index ix_level2_level3_level2 on level2_level3 (level2_id); +alter table level2_level3 add constraint fk_level2_level3_level2 foreign key (level2_id) references level2 (id) on delete restrict on update restrict; + +create index ix_level2_level3_level3 on level2_level3 (level3_id); +alter table level2_level3 add constraint fk_level2_level3_level3 foreign key (level3_id) references level3 (id) on delete restrict on update restrict; + +alter table link add constraint fk_link_id foreign key (id) references link_draft (id) on delete restrict on update restrict; + +create index ix_la_attr_value_attribute_la_attr_value on la_attr_value_attribute (la_attr_value_id); +alter table la_attr_value_attribute add constraint fk_la_attr_value_attribute_la_attr_value foreign key (la_attr_value_id) references la_attr_value (id) on delete restrict on update restrict; + +create index ix_la_attr_value_attribute_attribute on la_attr_value_attribute (attribute_id); +alter table la_attr_value_attribute add constraint fk_la_attr_value_attribute_attribute foreign key (attribute_id) references attribute (id) on delete restrict on update restrict; + +create index ix_looney_tune_id on looney (tune_id); +alter table looney add constraint fk_looney_tune_id foreign key (tune_id) references tune (id) on delete restrict on update restrict; + +create index ix_mcontact_customer_id on mcontact (customer_id); +alter table mcontact add constraint fk_mcontact_customer_id foreign key (customer_id) references mcustomer (id) on delete restrict on update restrict; + +create index ix_mcontact_message_contact_id on mcontact_message (contact_id); +alter table mcontact_message add constraint fk_mcontact_message_contact_id foreign key (contact_id) references mcontact (id) on delete restrict on update restrict; + +create index ix_mcustomer_shipping_address_id on mcustomer (shipping_address_id); +alter table mcustomer add constraint fk_mcustomer_shipping_address_id foreign key (shipping_address_id) references maddress (id) on delete restrict on update restrict; + +create index ix_mcustomer_billing_address_id on mcustomer (billing_address_id); +alter table mcustomer add constraint fk_mcustomer_billing_address_id foreign key (billing_address_id) references maddress (id) on delete restrict on update restrict; + +create index ix_mmachine_mgroup_mmachine on mmachine_mgroup (mmachine_id); +alter table mmachine_mgroup add constraint fk_mmachine_mgroup_mmachine foreign key (mmachine_id) references mmachine (id) on delete restrict on update restrict; + +create index ix_mmachine_mgroup_mgroup on mmachine_mgroup (mgroup_id); +alter table mmachine_mgroup add constraint fk_mmachine_mgroup_mgroup foreign key (mgroup_id) references mgroup (id) on delete restrict on update restrict; + +create index ix_mprinter_current_state_id on mprinter (current_state_id); +alter table mprinter add constraint fk_mprinter_current_state_id foreign key (current_state_id) references mprinter_state (id) on delete restrict on update restrict; + +alter table mprinter add constraint fk_mprinter_last_swap_cyan_id foreign key (last_swap_cyan_id) references mprinter_state (id) on delete restrict on update restrict; + +alter table mprinter add constraint fk_mprinter_last_swap_magenta_id foreign key (last_swap_magenta_id) references mprinter_state (id) on delete restrict on update restrict; + +alter table mprinter add constraint fk_mprinter_last_swap_yellow_id foreign key (last_swap_yellow_id) references mprinter_state (id) on delete restrict on update restrict; + +alter table mprinter add constraint fk_mprinter_last_swap_black_id foreign key (last_swap_black_id) references mprinter_state (id) on delete restrict on update restrict; + +create index ix_mprinter_state_printer_id on mprinter_state (printer_id); +alter table mprinter_state add constraint fk_mprinter_state_printer_id foreign key (printer_id) references mprinter (id) on delete restrict on update restrict; + +create index ix_mprofile_picture_id on mprofile (picture_id); +alter table mprofile add constraint fk_mprofile_picture_id foreign key (picture_id) references mmedia (id) on delete restrict on update restrict; + +create index ix_mrole_muser_mrole on mrole_muser (mrole_roleid); +alter table mrole_muser add constraint fk_mrole_muser_mrole foreign key (mrole_roleid) references mrole (roleid) on delete restrict on update restrict; + +create index ix_mrole_muser_muser on mrole_muser (muser_userid); +alter table mrole_muser add constraint fk_mrole_muser_muser foreign key (muser_userid) references muser (userid) on delete restrict on update restrict; + +create index ix_muser_user_type_id on muser (user_type_id); +alter table muser add constraint fk_muser_user_type_id foreign key (user_type_id) references muser_type (id) on delete restrict on update restrict; + +create index ix_mail_user_inbox_mail_user on mail_user_inbox (mail_user_id); +alter table mail_user_inbox add constraint fk_mail_user_inbox_mail_user foreign key (mail_user_id) references mail_user (id) on delete restrict on update restrict; + +create index ix_mail_user_inbox_mail_box on mail_user_inbox (mail_box_id); +alter table mail_user_inbox add constraint fk_mail_user_inbox_mail_box foreign key (mail_box_id) references mail_box (id) on delete restrict on update restrict; + +create index ix_mail_user_outbox_mail_user on mail_user_outbox (mail_user_id); +alter table mail_user_outbox add constraint fk_mail_user_outbox_mail_user foreign key (mail_user_id) references mail_user (id) on delete restrict on update restrict; + +create index ix_mail_user_outbox_mail_box on mail_user_outbox (mail_box_id); +alter table mail_user_outbox add constraint fk_mail_user_outbox_mail_box foreign key (mail_box_id) references mail_box (id) on delete restrict on update restrict; + +create index ix_c_message_conversation_id on c_message (conversation_id); +alter table c_message add constraint fk_c_message_conversation_id foreign key (conversation_id) references c_conversation (id) on delete restrict on update restrict; + +create index ix_c_message_user_id on c_message (user_id); +alter table c_message add constraint fk_c_message_user_id foreign key (user_id) references c_user (id) on delete restrict on update restrict; + +alter table meter_contract_data add constraint fk_meter_contract_data_special_needs_client_id foreign key (special_needs_client_id) references meter_special_needs_client (id) on delete restrict on update restrict; + +alter table meter_special_needs_client add constraint fk_meter_special_needs_client_primary_id foreign key (primary_id) references meter_special_needs_contact (id) on delete restrict on update restrict; + +alter table meter_version add constraint fk_meter_version_address_data_id foreign key (address_data_id) references meter_address_data (id) on delete restrict on update restrict; + +alter table meter_version add constraint fk_meter_version_contract_data_id foreign key (contract_data_id) references meter_contract_data (id) on delete restrict on update restrict; + +create index ix_mnoc_user_mnoc_role_mnoc_user on mnoc_user_mnoc_role (mnoc_user_user_id); +alter table mnoc_user_mnoc_role add constraint fk_mnoc_user_mnoc_role_mnoc_user foreign key (mnoc_user_user_id) references mnoc_user (user_id) on delete restrict on update restrict; + +create index ix_mnoc_user_mnoc_role_mnoc_role on mnoc_user_mnoc_role (mnoc_role_role_id); +alter table mnoc_user_mnoc_role add constraint fk_mnoc_user_mnoc_role_mnoc_role foreign key (mnoc_role_role_id) references mnoc_role (role_id) on delete restrict on update restrict; + +create index ix_mny_b_a_id on mny_b (a_id); +alter table mny_b add constraint fk_mny_b_a_id foreign key (a_id) references mny_a (id) on delete restrict on update restrict; + +create index ix_mny_b_mny_c_mny_b on mny_b_mny_c (mny_b_id); +alter table mny_b_mny_c add constraint fk_mny_b_mny_c_mny_b foreign key (mny_b_id) references mny_b (id) on delete restrict on update restrict; + +create index ix_mny_b_mny_c_mny_c on mny_b_mny_c (mny_c_id); +alter table mny_b_mny_c add constraint fk_mny_b_mny_c_mny_c foreign key (mny_c_id) references mny_c (id) on delete restrict on update restrict; + +create index ix_subtopics_mny_topic_1 on subtopics (topic); +alter table subtopics add constraint fk_subtopics_mny_topic_1 foreign key (topic) references mny_topic (id) on delete restrict on update restrict; + +create index ix_subtopics_mny_topic_2 on subtopics (subtopic); +alter table subtopics add constraint fk_subtopics_mny_topic_2 foreign key (subtopic) references mny_topic (id) on delete restrict on update restrict; + +create index ix_mp_role_mp_user_id on mp_role (mp_user_id); +alter table mp_role add constraint fk_mp_role_mp_user_id foreign key (mp_user_id) references mp_user (id) on delete restrict on update restrict; + +create index ix_ms_many_a_many_b_ms_many_a on ms_many_a_many_b (ms_many_a_aid); +alter table ms_many_a_many_b add constraint fk_ms_many_a_many_b_ms_many_a foreign key (ms_many_a_aid) references ms_many_a (aid) on delete restrict on update restrict; + +create index ix_ms_many_a_many_b_ms_many_b on ms_many_a_many_b (ms_many_b_bid); +alter table ms_many_a_many_b add constraint fk_ms_many_a_many_b_ms_many_b foreign key (ms_many_b_bid) references ms_many_b (bid) on delete restrict on update restrict; + +create index ix_ms_many_b_many_a_ms_many_b on ms_many_b_many_a (ms_many_b_bid); +alter table ms_many_b_many_a add constraint fk_ms_many_b_many_a_ms_many_b foreign key (ms_many_b_bid) references ms_many_b (bid) on delete restrict on update restrict; + +create index ix_ms_many_b_many_a_ms_many_a on ms_many_b_many_a (ms_many_a_aid); +alter table ms_many_b_many_a add constraint fk_ms_many_b_many_a_ms_many_a foreign key (ms_many_a_aid) references ms_many_a (aid) on delete restrict on update restrict; + +create index ix_my_lob_size_join_many_parent_id on my_lob_size_join_many (parent_id); +alter table my_lob_size_join_many add constraint fk_my_lob_size_join_many_parent_id foreign key (parent_id) references my_lob_size (id) on delete restrict on update restrict; + +create index ix_o_bean_child_cached_bean_id on o_bean_child (cached_bean_id); +alter table o_bean_child add constraint fk_o_bean_child_cached_bean_id foreign key (cached_bean_id) references o_cached_bean (id) on delete restrict on update restrict; + +create index ix_ocached_app_detail_app_id on ocached_app_detail (app_id); +alter table ocached_app_detail add constraint fk_ocached_app_detail_app_id foreign key (app_id) references ocached_app (id) on delete restrict on update restrict; + +create index ix_o_cached_bean_country_o_cached_bean on o_cached_bean_country (o_cached_bean_id); +alter table o_cached_bean_country add constraint fk_o_cached_bean_country_o_cached_bean foreign key (o_cached_bean_id) references o_cached_bean (id) on delete restrict on update restrict; + +create index ix_o_cached_bean_country_o_country on o_cached_bean_country (o_country_code); +alter table o_cached_bean_country add constraint fk_o_cached_bean_country_o_country foreign key (o_country_code) references o_country (code) on delete restrict on update restrict; + +create index ix_o_cached_bean_child_cached_bean_id on o_cached_bean_child (cached_bean_id); +alter table o_cached_bean_child add constraint fk_o_cached_bean_child_cached_bean_id foreign key (cached_bean_id) references o_cached_bean (id) on delete restrict on update restrict; + +alter table oengine add constraint fk_oengine_car_id foreign key (car_id) references ocar (id) on delete restrict on update restrict; + +alter table ogear_box add constraint fk_ogear_box_car_id foreign key (car_id) references ocar (id) on delete restrict on update restrict; + +create index ix_omvertex_other_omvertex_id on omvertex_other (omvertex_id); +alter table omvertex_other add constraint fk_omvertex_other_omvertex_id foreign key (omvertex_id) references omvertex (id) on delete restrict on update restrict; + +alter table oroad_show_msg add constraint fk_oroad_show_msg_company_id foreign key (company_id) references ocompany (id) on delete restrict on update restrict; + +create index ix_om_account_child_dbo_banana_rama_id on om_account_child_dbo (banana_rama_id); +alter table om_account_child_dbo add constraint fk_om_account_child_dbo_banana_rama_id foreign key (banana_rama_id) references om_account_dbo (id) on delete restrict on update restrict; + +create index ix_om_basic_child_parent_id on om_basic_child (parent_id); +alter table om_basic_child add constraint fk_om_basic_child_parent_id foreign key (parent_id) references om_basic_parent (id) on delete restrict on update restrict; + +create index ix_om_ordered_detail_master_id on om_ordered_detail (master_id); +alter table om_ordered_detail add constraint fk_om_ordered_detail_master_id foreign key (master_id) references om_ordered_master (id) on delete restrict on update restrict; + +create index ix_oml_baz_foo_id on oml_baz (foo_id); +alter table oml_baz add constraint fk_oml_baz_foo_id foreign key (foo_id) references oml_foo (id) on delete restrict on update restrict; + +create index ix_oml_foo_bar_id on oml_foo (bar_id); +alter table oml_foo add constraint fk_oml_foo_bar_id foreign key (bar_id) references oml_bar (id) on delete restrict on update restrict; + +create index ix_o_order_kcustomer_id on o_order (kcustomer_id); +alter table o_order add constraint fk_o_order_kcustomer_id foreign key (kcustomer_id) references o_customer (id) on delete restrict on update restrict; + +create index ix_o_order_detail_order_id on o_order_detail (order_id); +alter table o_order_detail add constraint fk_o_order_detail_order_id foreign key (order_id) references o_order (id) on delete restrict on update restrict; + +create index ix_o_order_detail_product_id on o_order_detail (product_id); +alter table o_order_detail add constraint fk_o_order_detail_product_id foreign key (product_id) references o_product (id) on delete restrict on update restrict; + +create index ix_s_order_items_order_uuid on s_order_items (order_uuid); +alter table s_order_items add constraint fk_s_order_items_order_uuid foreign key (order_uuid) references s_orders (uuid) on delete restrict on update restrict; + +create index ix_order_referenced_parent_master_id on order_referenced_parent (master_id); +alter table order_referenced_parent add constraint fk_order_referenced_parent_master_id foreign key (master_id) references order_master (id) on delete restrict on update restrict; + +create index ix_or_order_ship_order_id on or_order_ship (order_id); +alter table or_order_ship add constraint fk_or_order_ship_order_id foreign key (order_id) references o_order (id) on delete restrict on update restrict; + +create index ix_order_toy_child_id on order_toy (child_id); +alter table order_toy add constraint fk_order_toy_child_id foreign key (child_id) references order_referenced_parent (id) on delete restrict on update restrict; + +create index ix_ordered_parent_order_master_inheritance_id on ordered_parent (order_master_inheritance_id); +alter table ordered_parent add constraint fk_ordered_parent_order_master_inheritance_id foreign key (order_master_inheritance_id) references order_master_inheritance (id) on delete restrict on update restrict; + +alter table organization_node add constraint fk_organization_node_parent_tree_node_id foreign key (parent_tree_node_id) references organization_tree_node (id) on delete restrict on update restrict; + +create index ix_orp_detail_master_id on orp_detail (master_id); +alter table orp_detail add constraint fk_orp_detail_master_id foreign key (master_id) references orp_master (id) on delete restrict on update restrict; + +create index ix_orp_detail2_orp_master2_id on orp_detail2 (orp_master2_id); +alter table orp_detail2 add constraint fk_orp_detail2_orp_master2_id foreign key (orp_master2_id) references orp_master2 (id) on delete restrict on update restrict; + +alter table oto_atwo add constraint fk_oto_atwo_aone_id foreign key (aone_id) references oto_aone (id) on delete restrict on update restrict; + +alter table oto_bchild add constraint fk_oto_bchild_master_id foreign key (master_id) references oto_bmaster (id) on delete restrict on update restrict; + +alter table oto_child add constraint fk_oto_child_master_id foreign key (master_id) references oto_master (id) on delete restrict on update restrict; + +alter table oto_cust_address add constraint fk_oto_cust_address_customer_cid foreign key (customer_cid) references oto_cust (cid) on delete restrict on update restrict; + +alter table oto_level_a add constraint fk_oto_level_a_b_id foreign key (b_id) references oto_level_b (id) on delete restrict on update restrict; + +alter table oto_level_b add constraint fk_oto_level_b_c_id foreign key (c_id) references oto_level_c (id) on delete restrict on update restrict; + +alter table oto_prime_extra add constraint fk_oto_prime_extra_eid foreign key (eid) references oto_prime (pid) on delete restrict on update restrict; + +alter table oto_sd_child add constraint fk_oto_sd_child_master_id foreign key (master_id) references oto_sd_master (id) on delete restrict on update restrict; + +create index ix_oto_th_many_oto_th_top_id on oto_th_many (oto_th_top_id); +alter table oto_th_many add constraint fk_oto_th_many_oto_th_top_id foreign key (oto_th_top_id) references oto_th_top (id) on delete restrict on update restrict; + +alter table oto_th_one add constraint fk_oto_th_one_many_id foreign key (many_id) references oto_th_many (id) on delete restrict on update restrict; + +alter table oto_ubprime_extra add constraint fk_oto_ubprime_extra_eid foreign key (eid) references oto_ubprime (pid) on delete restrict on update restrict; + +alter table oto_user_model add constraint fk_oto_user_model_user_optional_id foreign key (user_optional_id) references oto_user_model_optional (id) on delete restrict on update restrict; + +alter table pfile add constraint fk_pfile_file_content_id foreign key (file_content_id) references pfile_content (id) on delete restrict on update restrict; + +alter table pfile add constraint fk_pfile_file_content2_id foreign key (file_content2_id) references pfile_content (id) on delete restrict on update restrict; + +alter table paggview add constraint fk_paggview_pview_id foreign key (pview_id) references pp (id) on delete restrict on update restrict; + +create index ix_pallet_location_zone_sid on pallet_location (zone_sid); +alter table pallet_location add constraint fk_pallet_location_zone_sid foreign key (zone_sid) references zones (id) on delete restrict on update restrict; + +alter table parcel_location add constraint fk_parcel_location_parcelid foreign key (parcelid) references parcel (parcelid) on delete restrict on update restrict; + +create index ix_rawinherit_parent_rawinherit_data_rawinherit_parent on rawinherit_parent_rawinherit_data (rawinherit_parent_id); +alter table rawinherit_parent_rawinherit_data add constraint fk_rawinherit_parent_rawinherit_data_rawinherit_parent foreign key (rawinherit_parent_id) references rawinherit_parent (id) on delete restrict on update restrict; + +create index ix_rawinherit_parent_rawinherit_data_rawinherit_data on rawinherit_parent_rawinherit_data (rawinherit_data_id); +alter table rawinherit_parent_rawinherit_data add constraint fk_rawinherit_parent_rawinherit_data_rawinherit_data foreign key (rawinherit_data_id) references rawinherit_data (id) on delete restrict on update restrict; + +create index ix_parent_person_some_bean_id on parent_person (some_bean_id); +alter table parent_person add constraint fk_parent_person_some_bean_id foreign key (some_bean_id) references e_basic (id) on delete restrict on update restrict; + +create index ix_parent_person_parent_identifier on parent_person (parent_identifier); +alter table parent_person add constraint fk_parent_person_parent_identifier foreign key (parent_identifier) references grand_parent_person (identifier) on delete restrict on update restrict; + +create index ix_c_participation_conversation_id on c_participation (conversation_id); +alter table c_participation add constraint fk_c_participation_conversation_id foreign key (conversation_id) references c_conversation (id) on delete restrict on update restrict; + +create index ix_c_participation_user_id on c_participation (user_id); +alter table c_participation add constraint fk_c_participation_user_id foreign key (user_id) references c_user (id) on delete restrict on update restrict; + +create index ix_pcf_calendar_pcf_person_id on pcf_calendar (pcf_person_id); +alter table pcf_calendar add constraint fk_pcf_calendar_pcf_person_id foreign key (pcf_person_id) references pcf_person (id) on delete restrict on update restrict; + +create index ix_pcf_city_pcf_country_id on pcf_city (pcf_country_id); +alter table pcf_city add constraint fk_pcf_city_pcf_country_id foreign key (pcf_country_id) references pcf_country (id) on delete restrict on update restrict; + +alter table pcf_city add constraint fk_pcf_city_mayor_id foreign key (mayor_id) references pcf_person (id) on delete restrict on update restrict; + +alter table pcf_city add constraint fk_pcf_city_vice_mayor_id foreign key (vice_mayor_id) references pcf_person (id) on delete restrict on update restrict; + +create index ix_pcf_event_pcf_calendar_id on pcf_event (pcf_calendar_id); +alter table pcf_event add constraint fk_pcf_event_pcf_calendar_id foreign key (pcf_calendar_id) references pcf_calendar (id) on delete restrict on update restrict; + +alter table persistent_file_content add constraint fk_persistent_file_content_persistent_file_id foreign key (persistent_file_id) references persistent_file (id) on delete restrict on update restrict; + +create index ix_person_default_address_oid on person (default_address_oid); +alter table person add constraint fk_person_default_address_oid foreign key (default_address_oid) references address (oid) on delete restrict on update restrict; + +create index ix_person_cache_email_person_info_person_id on person_cache_email (person_info_person_id); +alter table person_cache_email add constraint fk_person_cache_email_person_info_person_id foreign key (person_info_person_id) references person_cache_info (person_id) on delete restrict on update restrict; + +create index ix_phones_person_id on phones (person_id); +alter table phones add constraint fk_phones_person_id foreign key (person_id) references persons (id) on delete restrict on update restrict; + +create index ix_e_position_contract_id on e_position (contract_id); +alter table e_position add constraint fk_e_position_contract_id foreign key (contract_id) references contract (id) on delete restrict on update restrict; + +create index ix_pp_to_ww_pp on pp_to_ww (pp_id); +alter table pp_to_ww add constraint fk_pp_to_ww_pp foreign key (pp_id) references pp (id) on delete restrict on update restrict; + +create index ix_pp_to_ww_wview on pp_to_ww (ww_id); +alter table pp_to_ww add constraint fk_pp_to_ww_wview foreign key (ww_id) references wview (id) on delete restrict on update restrict; + +create index ix_question_groupobjectid on question (groupobjectid); +alter table question add constraint fk_question_groupobjectid foreign key (groupobjectid) references survey_group (id) on delete restrict on update restrict; + +create index ix_r_orders_customer on r_orders (company,customername); +alter table r_orders add constraint fk_r_orders_customer foreign key (company,customername) references rcustomer (company,name) on delete restrict on update restrict; + +alter table referenced_defaults_model add constraint fk_referenced_defaults_model_id foreign key (id) references referenced_defaults_model_draft (id) on delete restrict on update restrict; + +create index ix_referenced_defaults_model_defaults_model_id on referenced_defaults_model (defaults_model_id); +alter table referenced_defaults_model add constraint fk_referenced_defaults_model_defaults_model_id foreign key (defaults_model_id) references defaults_model (id) on delete restrict on update restrict; + +create index ix_referenced_defaults_model_draft_defaults_model_id on referenced_defaults_model_draft (defaults_model_id); +alter table referenced_defaults_model_draft add constraint fk_referenced_defaults_model_draft_defaults_model_id foreign key (defaults_model_id) references defaults_model_draft (id) on delete restrict on update restrict; + +create index ix_rel_master_detail_id on rel_master (detail_id); +alter table rel_master add constraint fk_rel_master_detail_id foreign key (detail_id) references rel_detail (id) on delete restrict on update restrict; + +create index ix_resourcefile_parentresourcefileid on resourcefile (parentresourcefileid); +alter table resourcefile add constraint fk_resourcefile_parentresourcefileid foreign key (parentresourcefileid) references resourcefile (id) on delete restrict on update restrict; + +create index ix_mt_role_tenant_id on mt_role (tenant_id); +alter table mt_role add constraint fk_mt_role_tenant_id foreign key (tenant_id) references mt_tenant (id) on delete restrict on update restrict; + +create index ix_mt_role_permission_mt_role on mt_role_permission (mt_role_id); +alter table mt_role_permission add constraint fk_mt_role_permission_mt_role foreign key (mt_role_id) references mt_role (id) on delete restrict on update restrict; + +create index ix_mt_role_permission_mt_permission on mt_role_permission (mt_permission_id); +alter table mt_role_permission add constraint fk_mt_role_permission_mt_permission foreign key (mt_permission_id) references mt_permission (id) on delete restrict on update restrict; + +create index ix_root_bean_referencing_bean_id on root_bean (referencing_bean_id); +alter table root_bean add constraint fk_root_bean_referencing_bean_id foreign key (referencing_bean_id) references referencing_bean (id) on delete restrict on update restrict; + +alter table f_second add constraint fk_f_second_first foreign key (first) references f_first (id) on delete restrict on update restrict; + +create index ix_section_article_id on section (article_id); +alter table section add constraint fk_section_article_id foreign key (article_id) references article (id) on delete restrict on update restrict; + +create index ix_self_parent_parent_id on self_parent (parent_id); +alter table self_parent add constraint fk_self_parent_parent_id foreign key (parent_id) references self_parent (id) on delete restrict on update restrict; + +create index ix_self_ref_customer_referred_by_id on self_ref_customer (referred_by_id); +alter table self_ref_customer add constraint fk_self_ref_customer_referred_by_id foreign key (referred_by_id) references self_ref_customer (id) on delete restrict on update restrict; + +create index ix_self_ref_example_parent_id on self_ref_example (parent_id); +alter table self_ref_example add constraint fk_self_ref_example_parent_id foreign key (parent_id) references self_ref_example (id) on delete restrict on update restrict; + +alter table e_save_test_b add constraint fk_e_save_test_b_sibling_a_id foreign key (sibling_a_id) references e_save_test_a (id) on delete restrict on update restrict; + +create index ix_site_parent_id on site (parent_id); +alter table site add constraint fk_site_parent_id foreign key (parent_id) references site (id) on delete restrict on update restrict; + +alter table site add constraint fk_site_data_container_id foreign key (data_container_id) references data_container (id) on delete restrict on update restrict; + +alter table site add constraint fk_site_site_address_id foreign key (site_address_id) references site_address (id) on delete restrict on update restrict; + +create index ix_source_base_target_id on source_base (target_id); +alter table source_base add constraint fk_source_base_target_id foreign key (target_id) references target_base (id) on delete restrict on update restrict; + +create index ix_stockforecast_inner_report_id on stockforecast (inner_report_id); +alter table stockforecast add constraint fk_stockforecast_inner_report_id foreign key (inner_report_id) references inner_report (id) on delete restrict on update restrict; + +create index ix_sub_section_section_id on sub_section (section_id); +alter table sub_section add constraint fk_sub_section_section_id foreign key (section_id) references section (id) on delete restrict on update restrict; + +create index ix_tevent_many_event_id on tevent_many (event_id); +alter table tevent_many add constraint fk_tevent_many_event_id foreign key (event_id) references tevent_one (id) on delete restrict on update restrict; + +alter table tevent_one add constraint fk_tevent_one_event_id foreign key (event_id) references tevent (id) on delete restrict on update restrict; + +create index ix_t_detail_with_other_namexxxyy_master_id on t_detail_with_other_namexxxyy (master_id); +alter table t_detail_with_other_namexxxyy add constraint fk_t_detail_with_other_namexxxyy_master_id foreign key (master_id) references t_atable_thatisrelatively (id) on delete restrict on update restrict; + +create index ix_ttruck_holder_truck_plate_no on ttruck_holder (truck_plate_no); +alter table ttruck_holder add constraint fk_ttruck_holder_truck_plate_no foreign key (truck_plate_no) references tcar (plate_no) on delete restrict on update restrict; + +create index ix_ttruck_holder_basic_id on ttruck_holder (basic_id); +alter table ttruck_holder add constraint fk_ttruck_holder_basic_id foreign key (basic_id) references e_basic (id) on delete restrict on update restrict; + +create index ix_ttruck_holder_item_owner_id on ttruck_holder_item (owner_id); +alter table ttruck_holder_item add constraint fk_ttruck_holder_item_owner_id foreign key (owner_id) references ttruck_holder (id) on delete restrict on update restrict; + +create index ix_twheel_owner_plate_no on twheel (owner_plate_no); +alter table twheel add constraint fk_twheel_owner_plate_no foreign key (owner_plate_no) references tcar (plate_no) on delete restrict on update restrict; + +alter table tire add constraint fk_tire_wheel foreign key (wheel) references wheel (id) on delete restrict on update restrict; + +create index ix_tree_entity_parent_id on tree_entity (parent_id); +alter table tree_entity add constraint fk_tree_entity_parent_id foreign key (parent_id) references tree_entity (id) on delete restrict on update restrict; + +create index ix_trip_vehicle_driver_id on trip (vehicle_driver_id); +alter table trip add constraint fk_trip_vehicle_driver_id foreign key (vehicle_driver_id) references vehicle_driver (id) on delete restrict on update restrict; + +create index ix_trip_address_id on trip (address_id); +alter table trip add constraint fk_trip_address_id foreign key (address_id) references o_address (id) on delete restrict on update restrict; + +create index ix_type_sub_type_id on "type" (sub_type_id); +alter table "type" add constraint fk_type_sub_type_id foreign key (sub_type_id) references sub_type (sub_type_id) on delete restrict on update restrict; + +create index ix_usib_child_parent_id on usib_child (parent_id); +alter table usib_child add constraint fk_usib_child_parent_id foreign key (parent_id) references usib_parent (id) on delete restrict on update restrict; + +alter table usib_child_sibling add constraint fk_usib_child_sibling_child_id foreign key (child_id) references usib_child (id) on delete restrict on update restrict; + +create index ix_ut_detail_utmaster_id on ut_detail (utmaster_id); +alter table ut_detail add constraint fk_ut_detail_utmaster_id foreign key (utmaster_id) references ut_master (id) on delete restrict on update restrict; + +create index ix_uutwo_master_id on uutwo (master_id); +alter table uutwo add constraint fk_uutwo_master_id foreign key (master_id) references uuone (id) on delete restrict on update restrict; + +alter table oto_user add constraint fk_oto_user_account_id foreign key (account_id) references oto_account (id) on delete restrict on update restrict; + +create index ix_c_user_group_id on c_user (group_id); +alter table c_user add constraint fk_c_user_group_id foreign key (group_id) references c_group (id) on delete restrict on update restrict; + +create index ix_em_user_role_user_id on em_user_role (user_id); +alter table em_user_role add constraint fk_em_user_role_user_id foreign key (user_id) references em_user (id) on delete restrict on update restrict; + +create index ix_em_user_role_role_id on em_user_role (role_id); +alter table em_user_role add constraint fk_em_user_role_role_id foreign key (role_id) references em_role (id) on delete restrict on update restrict; + +create index ix_vehicle_lease_id on vehicle (lease_id); +alter table vehicle add constraint fk_vehicle_lease_id foreign key (lease_id) references vehicle_lease (id) on delete restrict on update restrict; + +create index ix_vehicle_car_ref_id on vehicle (car_ref_id); +alter table vehicle add constraint fk_vehicle_car_ref_id foreign key (car_ref_id) references truck_ref (id) on delete restrict on update restrict; + +create index ix_vehicle_truck_ref_id on vehicle (truck_ref_id); +alter table vehicle add constraint fk_vehicle_truck_ref_id foreign key (truck_ref_id) references truck_ref (id) on delete restrict on update restrict; + +create index ix_vehicle_driver_vehicle_id on vehicle_driver (vehicle_id); +alter table vehicle_driver add constraint fk_vehicle_driver_vehicle_id foreign key (vehicle_id) references vehicle (id) on delete restrict on update restrict; + +create index ix_vehicle_driver_address_id on vehicle_driver (address_id); +alter table vehicle_driver add constraint fk_vehicle_driver_address_id foreign key (address_id) references o_address (id) on delete restrict on update restrict; + +create index ix_version_child_parent_id on version_child (parent_id); +alter table version_child add constraint fk_version_child_parent_id foreign key (parent_id) references version_parent (id) on delete restrict on update restrict; + +create index ix_version_toy_child_id on version_toy (child_id); +alter table version_toy add constraint fk_version_toy_child_id foreign key (child_id) references version_child (id) on delete restrict on update restrict; + +create index ix_warehouses_officezoneid on warehouses (officezoneid); +alter table warehouses add constraint fk_warehouses_officezoneid foreign key (officezoneid) references zones (id) on delete restrict on update restrict; + +create index ix_warehousesshippingzones_warehouses on warehousesshippingzones (warehouseid); +alter table warehousesshippingzones add constraint fk_warehousesshippingzones_warehouses foreign key (warehouseid) references warehouses (id) on delete restrict on update restrict; + +create index ix_warehousesshippingzones_zones on warehousesshippingzones (shippingzoneid); +alter table warehousesshippingzones add constraint fk_warehousesshippingzones_zones foreign key (shippingzoneid) references zones (id) on delete restrict on update restrict; + +create index ix_sa_wheel_tire on sa_wheel (tire); +alter table sa_wheel add constraint fk_sa_wheel_tire foreign key (tire) references sa_tire (id) on delete restrict on update restrict; + +create index ix_sa_wheel_car on sa_wheel (car); +alter table sa_wheel add constraint fk_sa_wheel_car foreign key (car) references sa_car (id) on delete restrict on update restrict; + +create index ix_g_who_props_otm_who_created_id on g_who_props_otm (who_created_id); +alter table g_who_props_otm add constraint fk_g_who_props_otm_who_created_id foreign key (who_created_id) references g_user (id) on delete restrict on update restrict; + +create index ix_g_who_props_otm_who_modified_id on g_who_props_otm (who_modified_id); +alter table g_who_props_otm add constraint fk_g_who_props_otm_who_modified_id foreign key (who_modified_id) references g_user (id) on delete restrict on update restrict; + +create index ix_with_zero_parent_id on with_zero (parent_id); +alter table with_zero add constraint fk_with_zero_parent_id foreign key (parent_id) references parent (id) on delete restrict on update restrict; + +alter table hx_link add column sys_period tstzrange not null default tstzrange(current_timestamp, null); +update hx_link set sys_period = tstzrange(when_created, null); +create table hx_link_history(like hx_link); +create view hx_link_with_history as select * from hx_link union all select * from hx_link_history; + +alter table hi_link add column sys_period tstzrange not null default tstzrange(current_timestamp, null); +update hi_link set sys_period = tstzrange(when_created, null); +create table hi_link_history(like hi_link); +create view hi_link_with_history as select * from hi_link union all select * from hi_link_history; + +alter table hi_link_doc add column sys_period tstzrange not null default tstzrange(current_timestamp, null); +create table hi_link_doc_history(like hi_link_doc); +create view hi_link_doc_with_history as select * from hi_link_doc union all select * from hi_link_doc_history; + +alter table hi_tone add column sys_period tstzrange not null default tstzrange(current_timestamp, null); +update hi_tone set sys_period = tstzrange(when_created, null); +create table hi_tone_history(like hi_tone); +create view hi_tone_with_history as select * from hi_tone union all select * from hi_tone_history; + +alter table hi_tthree add column sys_period tstzrange not null default tstzrange(current_timestamp, null); +update hi_tthree set sys_period = tstzrange(when_created, null); +create table hi_tthree_history(like hi_tthree); +create view hi_tthree_with_history as select * from hi_tthree union all select * from hi_tthree_history; + +alter table hi_ttwo add column sys_period tstzrange not null default tstzrange(current_timestamp, null); +update hi_ttwo set sys_period = tstzrange(when_created, null); +create table hi_ttwo_history(like hi_ttwo); +create view hi_ttwo_with_history as select * from hi_ttwo union all select * from hi_ttwo_history; + +alter table hsd_setting add column sys_period tstzrange not null default tstzrange(current_timestamp, null); +update hsd_setting set sys_period = tstzrange(when_created, null); +create table hsd_setting_history(like hsd_setting); +create view hsd_setting_with_history as select * from hsd_setting union all select * from hsd_setting_history; + +alter table hsd_user add column sys_period tstzrange not null default tstzrange(current_timestamp, null); +update hsd_user set sys_period = tstzrange(when_created, null); +create table hsd_user_history(like hsd_user); +create view hsd_user_with_history as select * from hsd_user union all select * from hsd_user_history; + +alter table link add column sys_period tstzrange not null default tstzrange(current_timestamp, null); +update link set sys_period = tstzrange(when_created, null); +create table link_history(like link); +create view link_with_history as select * from link union all select * from link_history; + +alter table c_user add column sys_period tstzrange not null default tstzrange(current_timestamp, null); +update c_user set sys_period = tstzrange(when_created, null); +create table c_user_history(like c_user); +create view c_user_with_history as select * from c_user union all select * from c_user_history; + +create or replace function hx_link_history_version() returns trigger as $$ +declare + lowerTs timestamptz; + upperTs timestamptz; +begin + lowerTs = lower(OLD.sys_period); + upperTs = greatest(lowerTs + '1 microsecond',current_timestamp); + if (TG_OP = 'UPDATE') then + insert into hx_link_history (sys_period,id, name, location, comments, version, when_created, when_modified, deleted) values (tstzrange(lowerTs,upperTs), OLD.id, OLD.name, OLD.location, OLD.comments, OLD.version, OLD.when_created, OLD.when_modified, OLD.deleted); + NEW.sys_period = tstzrange(upperTs,null); + return new; + elsif (TG_OP = 'DELETE') then + insert into hx_link_history (sys_period,id, name, location, comments, version, when_created, when_modified, deleted) values (tstzrange(lowerTs,upperTs), OLD.id, OLD.name, OLD.location, OLD.comments, OLD.version, OLD.when_created, OLD.when_modified, OLD.deleted); + return old; + end if; +end; +$$ LANGUAGE plpgsql; + +create trigger hx_link_history_upd + before update or delete on hx_link + for each row execute procedure hx_link_history_version(); + +create or replace function hi_link_history_version() returns trigger as $$ +declare + lowerTs timestamptz; + upperTs timestamptz; +begin + lowerTs = lower(OLD.sys_period); + upperTs = greatest(lowerTs + '1 microsecond',current_timestamp); + if (TG_OP = 'UPDATE') then + insert into hi_link_history (sys_period,id, name, location, comments, version, when_created, when_modified) values (tstzrange(lowerTs,upperTs), OLD.id, OLD.name, OLD.location, OLD.comments, OLD.version, OLD.when_created, OLD.when_modified); + NEW.sys_period = tstzrange(upperTs,null); + return new; + elsif (TG_OP = 'DELETE') then + insert into hi_link_history (sys_period,id, name, location, comments, version, when_created, when_modified) values (tstzrange(lowerTs,upperTs), OLD.id, OLD.name, OLD.location, OLD.comments, OLD.version, OLD.when_created, OLD.when_modified); + return old; + end if; +end; +$$ LANGUAGE plpgsql; + +create trigger hi_link_history_upd + before update or delete on hi_link + for each row execute procedure hi_link_history_version(); + +create or replace function hi_link_doc_history_version() returns trigger as $$ +declare + lowerTs timestamptz; + upperTs timestamptz; +begin + lowerTs = lower(OLD.sys_period); + upperTs = greatest(lowerTs + '1 microsecond',current_timestamp); + if (TG_OP = 'UPDATE') then + insert into hi_link_doc_history (sys_period,hi_link_id, hi_doc_id) values (tstzrange(lowerTs,upperTs), OLD.hi_link_id, OLD.hi_doc_id); + NEW.sys_period = tstzrange(upperTs,null); + return new; + elsif (TG_OP = 'DELETE') then + insert into hi_link_doc_history (sys_period,hi_link_id, hi_doc_id) values (tstzrange(lowerTs,upperTs), OLD.hi_link_id, OLD.hi_doc_id); + return old; + end if; +end; +$$ LANGUAGE plpgsql; + +create trigger hi_link_doc_history_upd + before update or delete on hi_link_doc + for each row execute procedure hi_link_doc_history_version(); + +create or replace function hi_tone_history_version() returns trigger as $$ +declare + lowerTs timestamptz; + upperTs timestamptz; +begin + lowerTs = lower(OLD.sys_period); + upperTs = greatest(lowerTs + '1 microsecond',current_timestamp); + if (TG_OP = 'UPDATE') then + insert into hi_tone_history (sys_period,id, name, comments, version, when_created, when_modified) values (tstzrange(lowerTs,upperTs), OLD.id, OLD.name, OLD.comments, OLD.version, OLD.when_created, OLD.when_modified); + NEW.sys_period = tstzrange(upperTs,null); + return new; + elsif (TG_OP = 'DELETE') then + insert into hi_tone_history (sys_period,id, name, comments, version, when_created, when_modified) values (tstzrange(lowerTs,upperTs), OLD.id, OLD.name, OLD.comments, OLD.version, OLD.when_created, OLD.when_modified); + return old; + end if; +end; +$$ LANGUAGE plpgsql; + +create trigger hi_tone_history_upd + before update or delete on hi_tone + for each row execute procedure hi_tone_history_version(); + +create or replace function hi_tthree_history_version() returns trigger as $$ +declare + lowerTs timestamptz; + upperTs timestamptz; +begin + lowerTs = lower(OLD.sys_period); + upperTs = greatest(lowerTs + '1 microsecond',current_timestamp); + if (TG_OP = 'UPDATE') then + insert into hi_tthree_history (sys_period,id, hi_ttwo_id, three, version, when_created, when_modified) values (tstzrange(lowerTs,upperTs), OLD.id, OLD.hi_ttwo_id, OLD.three, OLD.version, OLD.when_created, OLD.when_modified); + NEW.sys_period = tstzrange(upperTs,null); + return new; + elsif (TG_OP = 'DELETE') then + insert into hi_tthree_history (sys_period,id, hi_ttwo_id, three, version, when_created, when_modified) values (tstzrange(lowerTs,upperTs), OLD.id, OLD.hi_ttwo_id, OLD.three, OLD.version, OLD.when_created, OLD.when_modified); + return old; + end if; +end; +$$ LANGUAGE plpgsql; + +create trigger hi_tthree_history_upd + before update or delete on hi_tthree + for each row execute procedure hi_tthree_history_version(); + +create or replace function hi_ttwo_history_version() returns trigger as $$ +declare + lowerTs timestamptz; + upperTs timestamptz; +begin + lowerTs = lower(OLD.sys_period); + upperTs = greatest(lowerTs + '1 microsecond',current_timestamp); + if (TG_OP = 'UPDATE') then + insert into hi_ttwo_history (sys_period,id, hi_tone_id, two, version, when_created, when_modified) values (tstzrange(lowerTs,upperTs), OLD.id, OLD.hi_tone_id, OLD.two, OLD.version, OLD.when_created, OLD.when_modified); + NEW.sys_period = tstzrange(upperTs,null); + return new; + elsif (TG_OP = 'DELETE') then + insert into hi_ttwo_history (sys_period,id, hi_tone_id, two, version, when_created, when_modified) values (tstzrange(lowerTs,upperTs), OLD.id, OLD.hi_tone_id, OLD.two, OLD.version, OLD.when_created, OLD.when_modified); + return old; + end if; +end; +$$ LANGUAGE plpgsql; + +create trigger hi_ttwo_history_upd + before update or delete on hi_ttwo + for each row execute procedure hi_ttwo_history_version(); + +create or replace function hsd_setting_history_version() returns trigger as $$ +declare + lowerTs timestamptz; + upperTs timestamptz; +begin + lowerTs = lower(OLD.sys_period); + upperTs = greatest(lowerTs + '1 microsecond',current_timestamp); + if (TG_OP = 'UPDATE') then + insert into hsd_setting_history (sys_period,id, code, content, user_id, version, when_created, when_modified, deleted) values (tstzrange(lowerTs,upperTs), OLD.id, OLD.code, OLD.content, OLD.user_id, OLD.version, OLD.when_created, OLD.when_modified, OLD.deleted); + NEW.sys_period = tstzrange(upperTs,null); + return new; + elsif (TG_OP = 'DELETE') then + insert into hsd_setting_history (sys_period,id, code, content, user_id, version, when_created, when_modified, deleted) values (tstzrange(lowerTs,upperTs), OLD.id, OLD.code, OLD.content, OLD.user_id, OLD.version, OLD.when_created, OLD.when_modified, OLD.deleted); + return old; + end if; +end; +$$ LANGUAGE plpgsql; + +create trigger hsd_setting_history_upd + before update or delete on hsd_setting + for each row execute procedure hsd_setting_history_version(); + +create or replace function hsd_user_history_version() returns trigger as $$ +declare + lowerTs timestamptz; + upperTs timestamptz; +begin + lowerTs = lower(OLD.sys_period); + upperTs = greatest(lowerTs + '1 microsecond',current_timestamp); + if (TG_OP = 'UPDATE') then + insert into hsd_user_history (sys_period,id, name, version, when_created, when_modified, deleted) values (tstzrange(lowerTs,upperTs), OLD.id, OLD.name, OLD.version, OLD.when_created, OLD.when_modified, OLD.deleted); + NEW.sys_period = tstzrange(upperTs,null); + return new; + elsif (TG_OP = 'DELETE') then + insert into hsd_user_history (sys_period,id, name, version, when_created, when_modified, deleted) values (tstzrange(lowerTs,upperTs), OLD.id, OLD.name, OLD.version, OLD.when_created, OLD.when_modified, OLD.deleted); + return old; + end if; +end; +$$ LANGUAGE plpgsql; + +create trigger hsd_user_history_upd + before update or delete on hsd_user + for each row execute procedure hsd_user_history_version(); + +create or replace function link_history_version() returns trigger as $$ +declare + lowerTs timestamptz; + upperTs timestamptz; +begin + lowerTs = lower(OLD.sys_period); + upperTs = greatest(lowerTs + '1 microsecond',current_timestamp); + if (TG_OP = 'UPDATE') then + insert into link_history (sys_period,id, name, location, when_publish, link_comment, version, when_created, when_modified, deleted) values (tstzrange(lowerTs,upperTs), OLD.id, OLD.name, OLD.location, OLD.when_publish, OLD.link_comment, OLD.version, OLD.when_created, OLD.when_modified, OLD.deleted); + NEW.sys_period = tstzrange(upperTs,null); + return new; + elsif (TG_OP = 'DELETE') then + insert into link_history (sys_period,id, name, location, when_publish, link_comment, version, when_created, when_modified, deleted) values (tstzrange(lowerTs,upperTs), OLD.id, OLD.name, OLD.location, OLD.when_publish, OLD.link_comment, OLD.version, OLD.when_created, OLD.when_modified, OLD.deleted); + return old; + end if; +end; +$$ LANGUAGE plpgsql; + +create trigger link_history_upd + before update or delete on link + for each row execute procedure link_history_version(); + +create or replace function c_user_history_version() returns trigger as $$ +declare + lowerTs timestamptz; + upperTs timestamptz; +begin + lowerTs = lower(OLD.sys_period); + upperTs = greatest(lowerTs + '1 microsecond',current_timestamp); + if (TG_OP = 'UPDATE') then + insert into c_user_history (sys_period,id, inactive, name, email, group_id, version, when_created, when_modified) values (tstzrange(lowerTs,upperTs), OLD.id, OLD.inactive, OLD.name, OLD.email, OLD.group_id, OLD.version, OLD.when_created, OLD.when_modified); + NEW.sys_period = tstzrange(upperTs,null); + return new; + elsif (TG_OP = 'DELETE') then + insert into c_user_history (sys_period,id, inactive, name, email, group_id, version, when_created, when_modified) values (tstzrange(lowerTs,upperTs), OLD.id, OLD.inactive, OLD.name, OLD.email, OLD.group_id, OLD.version, OLD.when_created, OLD.when_modified); + return old; + end if; +end; +$$ LANGUAGE plpgsql; + +create trigger c_user_history_upd + before update or delete on c_user + for each row execute procedure c_user_history_version(); + diff --git a/ebean-core/src/test/ddl-review/pg-drop-all.sql b/ebean-core/src/test/ddl-review/pg-drop-all.sql new file mode 100644 index 000000000..e3fbd4432 --- /dev/null +++ b/ebean-core/src/test/ddl-review/pg-drop-all.sql @@ -0,0 +1,1957 @@ +-- Generated by ebean unknown at 2020-08-24T21:02:32.420817Z +alter table if exists bar drop constraint if exists fk_bar_foo_id; +drop index if exists ix_bar_foo_id; + +alter table if exists acl_container_relation drop constraint if exists fk_acl_container_relation_container_id; +drop index if exists ix_acl_container_relation_container_id; + +alter table if exists acl_container_relation drop constraint if exists fk_acl_container_relation_acl_entry_id; +drop index if exists ix_acl_container_relation_acl_entry_id; + +alter table if exists addr drop constraint if exists fk_addr_employee_id; +drop index if exists ix_addr_employee_id; + +alter table if exists o_address drop constraint if exists fk_o_address_country_code; +drop index if exists ix_o_address_country_code; + +alter table if exists album drop constraint if exists fk_album_cover_id; + +alter table if exists animal drop constraint if exists fk_animal_shelter_id; +drop index if exists ix_animal_shelter_id; + +alter table if exists attribute drop constraint if exists fk_attribute_attribute_holder_id; +drop index if exists ix_attribute_attribute_holder_id; + +alter table if exists bbookmark drop constraint if exists fk_bbookmark_user_id; +drop index if exists ix_bbookmark_user_id; + +alter table if exists bbookmark_user drop constraint if exists fk_bbookmark_user_org_id; +drop index if exists ix_bbookmark_user_org_id; + +alter table if exists bsite_user_a drop constraint if exists fk_bsite_user_a_site_id; +drop index if exists ix_bsite_user_a_site_id; + +alter table if exists bsite_user_a drop constraint if exists fk_bsite_user_a_user_id; +drop index if exists ix_bsite_user_a_user_id; + +alter table if exists bsite_user_b drop constraint if exists fk_bsite_user_b_site; +drop index if exists ix_bsite_user_b_site; + +alter table if exists bsite_user_b drop constraint if exists fk_bsite_user_b_usr; +drop index if exists ix_bsite_user_b_usr; + +alter table if exists bsite_user_c drop constraint if exists fk_bsite_user_c_site_uid; +drop index if exists ix_bsite_user_c_site_uid; + +alter table if exists bsite_user_c drop constraint if exists fk_bsite_user_c_user_uid; +drop index if exists ix_bsite_user_c_user_uid; + +alter table if exists bsite_user_e drop constraint if exists fk_bsite_user_e_site_id; +drop index if exists ix_bsite_user_e_site_id; + +alter table if exists bsite_user_e drop constraint if exists fk_bsite_user_e_user_id; +drop index if exists ix_bsite_user_e_user_id; + +alter table if exists basic_draftable_bean drop constraint if exists fk_basic_draftable_bean_id; + +alter table if exists drel_booking drop constraint if exists fk_drel_booking_agent_invoice; + +alter table if exists drel_booking drop constraint if exists fk_drel_booking_client_invoice; + +alter table if exists cepproduct_category drop constraint if exists fk_cepproduct_category_category_id; +drop index if exists ix_cepproduct_category_category_id; + +alter table if exists cepproduct_category drop constraint if exists fk_cepproduct_category_product_id; +drop index if exists ix_cepproduct_category_product_id; + +alter table if exists ciaddress drop constraint if exists fk_ciaddress_street_id; +drop index if exists ix_ciaddress_street_id; + +alter table if exists cicustomer_parent drop constraint if exists fk_cicustomer_parent_address_id; +drop index if exists ix_cicustomer_parent_address_id; + +alter table if exists cinh_ref drop constraint if exists fk_cinh_ref_ref_id; +drop index if exists ix_cinh_ref_ref_id; + +alter table if exists ckey_detail drop constraint if exists fk_ckey_detail_parent; +drop index if exists ix_ckey_detail_parent; + +alter table if exists ckey_parent drop constraint if exists fk_ckey_parent_assoc_id; +drop index if exists ix_ckey_parent_assoc_id; + +alter table if exists coone_many drop constraint if exists fk_coone_many_coone_id; +drop index if exists ix_coone_many_coone_id; + +alter table if exists coroot drop constraint if exists fk_coroot_one_id; + +alter table if exists calculation_result drop constraint if exists fk_calculation_result_product_configuration_id; +drop index if exists ix_calculation_result_product_configuration_id; + +alter table if exists calculation_result drop constraint if exists fk_calculation_result_group_configuration_id; +drop index if exists ix_calculation_result_group_configuration_id; + +alter table if exists sp_car_car_wheels drop constraint if exists fk_sp_car_car_wheels_sp_car_car; +drop index if exists ix_sp_car_car_wheels_sp_car_car; + +alter table if exists sp_car_car_wheels drop constraint if exists fk_sp_car_car_wheels_sp_car_wheel; +drop index if exists ix_sp_car_car_wheels_sp_car_wheel; + +alter table if exists sp_car_car_doors drop constraint if exists fk_sp_car_car_doors_sp_car_car; +drop index if exists ix_sp_car_car_doors_sp_car_car; + +alter table if exists sp_car_car_doors drop constraint if exists fk_sp_car_car_doors_sp_car_door; +drop index if exists ix_sp_car_car_doors_sp_car_door; + +alter table if exists car_accessory drop constraint if exists fk_car_accessory_fuse_id; +drop index if exists ix_car_accessory_fuse_id; + +alter table if exists car_accessory drop constraint if exists fk_car_accessory_car_id; +drop index if exists ix_car_accessory_car_id; + +alter table if exists category drop constraint if exists fk_category_surveyobjectid; +drop index if exists ix_category_surveyobjectid; + +alter table if exists e_save_test_d drop constraint if exists fk_e_save_test_d_parent_id; + +alter table if exists child_person drop constraint if exists fk_child_person_some_bean_id; +drop index if exists ix_child_person_some_bean_id; + +alter table if exists child_person drop constraint if exists fk_child_person_parent_identifier; +drop index if exists ix_child_person_parent_identifier; + +alter table if exists cke_client drop constraint if exists fk_cke_client_user; +drop index if exists ix_cke_client_user; + +alter table if exists class_super_monkey drop constraint if exists fk_class_super_monkey_class_super; + +alter table if exists class_super_monkey drop constraint if exists fk_class_super_monkey_monkey; + +alter table if exists configuration drop constraint if exists fk_configuration_configurations_id; +drop index if exists ix_configuration_configurations_id; + +alter table if exists contact drop constraint if exists fk_contact_customer_id; +drop index if exists ix_contact_customer_id; + +alter table if exists contact drop constraint if exists fk_contact_group_id; +drop index if exists ix_contact_group_id; + +alter table if exists contact_note drop constraint if exists fk_contact_note_contact_id; +drop index if exists ix_contact_note_contact_id; + +alter table if exists contract_costs drop constraint if exists fk_contract_costs_position_id; +drop index if exists ix_contract_costs_position_id; + +alter table if exists c_conversation drop constraint if exists fk_c_conversation_group_id; +drop index if exists ix_c_conversation_group_id; + +alter table if exists o_customer drop constraint if exists fk_o_customer_billing_address_id; +drop index if exists ix_o_customer_billing_address_id; + +alter table if exists o_customer drop constraint if exists fk_o_customer_shipping_address_id; +drop index if exists ix_o_customer_shipping_address_id; + +alter table if exists dcredit_drol drop constraint if exists fk_dcredit_drol_dcredit; +drop index if exists ix_dcredit_drol_dcredit; + +alter table if exists dcredit_drol drop constraint if exists fk_dcredit_drol_drol; +drop index if exists ix_dcredit_drol_drol; + +alter table if exists dmachine drop constraint if exists fk_dmachine_organisation_id; +drop index if exists ix_dmachine_organisation_id; + +alter table if exists d_machine_aux_use drop constraint if exists fk_d_machine_aux_use_machine_id; +drop index if exists ix_d_machine_aux_use_machine_id; + +alter table if exists d_machine_stats drop constraint if exists fk_d_machine_stats_machine_id; +drop index if exists ix_d_machine_stats_machine_id; + +alter table if exists d_machine_use drop constraint if exists fk_d_machine_use_machine_id; +drop index if exists ix_d_machine_use_machine_id; + +alter table if exists drot_drol drop constraint if exists fk_drot_drol_drot; +drop index if exists ix_drot_drol_drot; + +alter table if exists drot_drol drop constraint if exists fk_drot_drol_drol; +drop index if exists ix_drot_drol_drol; + +alter table if exists dc_detail drop constraint if exists fk_dc_detail_master_id; +drop index if exists ix_dc_detail_master_id; + +alter table if exists defaults_model drop constraint if exists fk_defaults_model_id; + +alter table if exists dfk_cascade drop constraint if exists fk_dfk_cascade_one_id; +drop index if exists ix_dfk_cascade_one_id; + +alter table if exists dfk_set_null drop constraint if exists fk_dfk_set_null_one_id; +drop index if exists ix_dfk_set_null_one_id; + +alter table if exists doc drop constraint if exists fk_doc_id; + +alter table if exists doc_link drop constraint if exists fk_doc_link_doc; +drop index if exists ix_doc_link_doc; + +alter table if exists doc_link drop constraint if exists fk_doc_link_link; +drop index if exists ix_doc_link_link; + +alter table if exists document drop constraint if exists fk_document_id; + +alter table if exists document drop constraint if exists fk_document_organisation_id; +drop index if exists ix_document_organisation_id; + +alter table if exists document_draft drop constraint if exists fk_document_draft_organisation_id; +drop index if exists ix_document_draft_organisation_id; + +alter table if exists document_media drop constraint if exists fk_document_media_document_id; +drop index if exists ix_document_media_document_id; + +alter table if exists document_media_draft drop constraint if exists fk_document_media_draft_document_id; +drop index if exists ix_document_media_draft_document_id; + +alter table if exists e_basicenc_relate drop constraint if exists fk_e_basicenc_relate_other_id; +drop index if exists ix_e_basicenc_relate_other_id; + +alter table if exists ebasic_json_map_detail drop constraint if exists fk_ebasic_json_map_detail_owner_id; +drop index if exists ix_ebasic_json_map_detail_owner_id; + +alter table if exists ebasic_no_sdchild drop constraint if exists fk_ebasic_no_sdchild_owner_id; +drop index if exists ix_ebasic_no_sdchild_owner_id; + +alter table if exists ebasic_sdchild drop constraint if exists fk_ebasic_sdchild_owner_id; +drop index if exists ix_ebasic_sdchild_owner_id; + +alter table if exists ecache_child drop constraint if exists fk_ecache_child_root_id; +drop index if exists ix_ecache_child_root_id; + +alter table if exists edefault_prop drop constraint if exists fk_edefault_prop_e_simple_usertypeid; + +alter table if exists eemb_inner drop constraint if exists fk_eemb_inner_outer_id; +drop index if exists ix_eemb_inner_outer_id; + +alter table if exists einvoice drop constraint if exists fk_einvoice_person_id; +drop index if exists ix_einvoice_person_id; + +alter table if exists enull_collection_detail drop constraint if exists fk_enull_collection_detail_enull_collection_id; +drop index if exists ix_enull_collection_detail_enull_collection_id; + +alter table if exists eopt_one_a drop constraint if exists fk_eopt_one_a_b_id; +drop index if exists ix_eopt_one_a_b_id; + +alter table if exists eopt_one_b drop constraint if exists fk_eopt_one_b_c_id; +drop index if exists ix_eopt_one_b_c_id; + +alter table if exists eper_addr drop constraint if exists fk_eper_addr_ma_country_code; +drop index if exists ix_eper_addr_ma_country_code; + +alter table if exists esoft_del_book drop constraint if exists fk_esoft_del_book_lend_by_id; +drop index if exists ix_esoft_del_book_lend_by_id; + +alter table if exists esoft_del_book_esoft_del_user drop constraint if exists fk_esoft_del_book_esoft_del_user_esoft_del_book; +drop index if exists ix_esoft_del_book_esoft_del_user_esoft_del_book; + +alter table if exists esoft_del_book_esoft_del_user drop constraint if exists fk_esoft_del_book_esoft_del_user_esoft_del_user; +drop index if exists ix_esoft_del_book_esoft_del_user_esoft_del_user; + +alter table if exists esoft_del_down drop constraint if exists fk_esoft_del_down_esoft_del_mid_id; +drop index if exists ix_esoft_del_down_esoft_del_mid_id; + +alter table if exists esoft_del_mid drop constraint if exists fk_esoft_del_mid_top_id; +drop index if exists ix_esoft_del_mid_top_id; + +alter table if exists esoft_del_mid drop constraint if exists fk_esoft_del_mid_up_id; +drop index if exists ix_esoft_del_mid_up_id; + +alter table if exists esoft_del_one_a drop constraint if exists fk_esoft_del_one_a_oneb_id; + +alter table if exists esoft_del_role_esoft_del_user drop constraint if exists fk_esoft_del_role_esoft_del_user_esoft_del_role; +drop index if exists ix_esoft_del_role_esoft_del_user_esoft_del_role; + +alter table if exists esoft_del_role_esoft_del_user drop constraint if exists fk_esoft_del_role_esoft_del_user_esoft_del_user; +drop index if exists ix_esoft_del_role_esoft_del_user_esoft_del_user; + +alter table if exists esoft_del_user_esoft_del_role drop constraint if exists fk_esoft_del_user_esoft_del_role_esoft_del_user; +drop index if exists ix_esoft_del_user_esoft_del_role_esoft_del_user; + +alter table if exists esoft_del_user_esoft_del_role drop constraint if exists fk_esoft_del_user_esoft_del_role_esoft_del_role; +drop index if exists ix_esoft_del_user_esoft_del_role_esoft_del_role; + +alter table if exists rawinherit_uncle drop constraint if exists fk_rawinherit_uncle_parent_id; +drop index if exists ix_rawinherit_uncle_parent_id; + +alter table if exists evanilla_collection_detail drop constraint if exists fk_evanilla_collection_detail_evanilla_collection_id; +drop index if exists ix_evanilla_collection_detail_evanilla_collection_id; + +alter table if exists ec_enum_person_tags drop constraint if exists fk_ec_enum_person_tags_ec_enum_person_id; +drop index if exists ix_ec_enum_person_tags_ec_enum_person_id; + +alter table if exists ec_person_phone drop constraint if exists fk_ec_person_phone_owner_id; +drop index if exists ix_ec_person_phone_owner_id; + +alter table if exists ec_top drop constraint if exists fk_ec_top_person_id; +drop index if exists ix_ec_top_person_id; + +alter table if exists ec_top_ecs_person drop constraint if exists fk_ec_top_ecs_person_ec_top; +drop index if exists ix_ec_top_ecs_person_ec_top; + +alter table if exists ec_top_ecs_person drop constraint if exists fk_ec_top_ecs_person_ecs_person; +drop index if exists ix_ec_top_ecs_person_ecs_person; + +alter table if exists ecbl_person_phone_numbers drop constraint if exists fk_ecbl_person_phone_numbers_person_id; +drop index if exists ix_ecbl_person_phone_numbers_person_id; + +alter table if exists ecbm_person_phone_numbers drop constraint if exists fk_ecbm_person_phone_numbers_person_id; +drop index if exists ix_ecbm_person_phone_numbers_person_id; + +alter table if exists ecm_person_phone_numbers drop constraint if exists fk_ecm_person_phone_numbers_ecm_person_id; +drop index if exists ix_ecm_person_phone_numbers_ecm_person_id; + +alter table if exists ecmc_person_phone_numbers drop constraint if exists fk_ecmc_person_phone_numbers_ecmc_person_id; +drop index if exists ix_ecmc_person_phone_numbers_ecmc_person_id; + +alter table if exists ecs_person_phone drop constraint if exists fk_ecs_person_phone_ecs_person_id; +drop index if exists ix_ecs_person_phone_ecs_person_id; + +alter table if exists ecsm_child drop constraint if exists fk_ecsm_child_ecsm_parent_id; +drop index if exists ix_ecsm_child_ecsm_parent_id; + +alter table if exists td_child drop constraint if exists fk_td_child_parent_id; +drop index if exists ix_td_child_parent_id; + +alter table if exists element_bean drop constraint if exists fk_element_bean_complex_bean_id; +drop index if exists ix_element_bean_complex_bean_id; + +alter table if exists empl drop constraint if exists fk_empl_default_address_id; +drop index if exists ix_empl_default_address_id; + +alter table if exists esd_detail drop constraint if exists fk_esd_detail_master_id; +drop index if exists ix_esd_detail_master_id; + +alter table if exists grand_parent_person drop constraint if exists fk_grand_parent_person_some_bean_id; +drop index if exists ix_grand_parent_person_some_bean_id; + +alter table if exists survey_group drop constraint if exists fk_survey_group_categoryobjectid; +drop index if exists ix_survey_group_categoryobjectid; + +alter table if exists hx_link_doc drop constraint if exists fk_hx_link_doc_hx_link; +drop index if exists ix_hx_link_doc_hx_link; + +alter table if exists hx_link_doc drop constraint if exists fk_hx_link_doc_he_doc; +drop index if exists ix_hx_link_doc_he_doc; + +alter table if exists hi_link_doc drop constraint if exists fk_hi_link_doc_hi_link; +drop index if exists ix_hi_link_doc_hi_link; + +alter table if exists hi_link_doc drop constraint if exists fk_hi_link_doc_hi_doc; +drop index if exists ix_hi_link_doc_hi_doc; + +alter table if exists hi_tthree drop constraint if exists fk_hi_tthree_hi_ttwo_id; +drop index if exists ix_hi_tthree_hi_ttwo_id; + +alter table if exists hi_ttwo drop constraint if exists fk_hi_ttwo_hi_tone_id; +drop index if exists ix_hi_ttwo_hi_tone_id; + +alter table if exists hsd_setting drop constraint if exists fk_hsd_setting_user_id; + +alter table if exists iaf_segment drop constraint if exists fk_iaf_segment_status_id; +drop index if exists ix_iaf_segment_status_id; + +alter table if exists imrelated drop constraint if exists fk_imrelated_owner_id; +drop index if exists ix_imrelated_owner_id; + +alter table if exists info_contact drop constraint if exists fk_info_contact_company_id; +drop index if exists ix_info_contact_company_id; + +alter table if exists info_customer drop constraint if exists fk_info_customer_company_id; + +alter table if exists inner_report drop constraint if exists fk_inner_report_forecast_id; + +alter table if exists drel_invoice drop constraint if exists fk_drel_invoice_booking; +drop index if exists ix_drel_invoice_booking; + +alter table if exists item drop constraint if exists fk_item_etype; +drop index if exists ix_item_etype; + +alter table if exists item drop constraint if exists fk_item_eregion; +drop index if exists ix_item_eregion; + +alter table if exists mkeygroup_monkey drop constraint if exists fk_mkeygroup_monkey_mkeygroup; + +alter table if exists mkeygroup_monkey drop constraint if exists fk_mkeygroup_monkey_monkey; + +alter table if exists trainer_monkey drop constraint if exists fk_trainer_monkey_trainer; + +alter table if exists trainer_monkey drop constraint if exists fk_trainer_monkey_monkey; + +alter table if exists troop_monkey drop constraint if exists fk_troop_monkey_troop; + +alter table if exists troop_monkey drop constraint if exists fk_troop_monkey_monkey; + +alter table if exists l2_cldf_reset_bean_child drop constraint if exists fk_l2_cldf_reset_bean_child_parent_id; +drop index if exists ix_l2_cldf_reset_bean_child_parent_id; + +alter table if exists level1_level4 drop constraint if exists fk_level1_level4_level1; +drop index if exists ix_level1_level4_level1; + +alter table if exists level1_level4 drop constraint if exists fk_level1_level4_level4; +drop index if exists ix_level1_level4_level4; + +alter table if exists level1_level2 drop constraint if exists fk_level1_level2_level1; +drop index if exists ix_level1_level2_level1; + +alter table if exists level1_level2 drop constraint if exists fk_level1_level2_level2; +drop index if exists ix_level1_level2_level2; + +alter table if exists level2_level3 drop constraint if exists fk_level2_level3_level2; +drop index if exists ix_level2_level3_level2; + +alter table if exists level2_level3 drop constraint if exists fk_level2_level3_level3; +drop index if exists ix_level2_level3_level3; + +alter table if exists link drop constraint if exists fk_link_id; + +alter table if exists la_attr_value_attribute drop constraint if exists fk_la_attr_value_attribute_la_attr_value; +drop index if exists ix_la_attr_value_attribute_la_attr_value; + +alter table if exists la_attr_value_attribute drop constraint if exists fk_la_attr_value_attribute_attribute; +drop index if exists ix_la_attr_value_attribute_attribute; + +alter table if exists looney drop constraint if exists fk_looney_tune_id; +drop index if exists ix_looney_tune_id; + +alter table if exists mcontact drop constraint if exists fk_mcontact_customer_id; +drop index if exists ix_mcontact_customer_id; + +alter table if exists mcontact_message drop constraint if exists fk_mcontact_message_contact_id; +drop index if exists ix_mcontact_message_contact_id; + +alter table if exists mcustomer drop constraint if exists fk_mcustomer_shipping_address_id; +drop index if exists ix_mcustomer_shipping_address_id; + +alter table if exists mcustomer drop constraint if exists fk_mcustomer_billing_address_id; +drop index if exists ix_mcustomer_billing_address_id; + +alter table if exists mmachine_mgroup drop constraint if exists fk_mmachine_mgroup_mmachine; +drop index if exists ix_mmachine_mgroup_mmachine; + +alter table if exists mmachine_mgroup drop constraint if exists fk_mmachine_mgroup_mgroup; +drop index if exists ix_mmachine_mgroup_mgroup; + +alter table if exists mprinter drop constraint if exists fk_mprinter_current_state_id; +drop index if exists ix_mprinter_current_state_id; + +alter table if exists mprinter drop constraint if exists fk_mprinter_last_swap_cyan_id; + +alter table if exists mprinter drop constraint if exists fk_mprinter_last_swap_magenta_id; + +alter table if exists mprinter drop constraint if exists fk_mprinter_last_swap_yellow_id; + +alter table if exists mprinter drop constraint if exists fk_mprinter_last_swap_black_id; + +alter table if exists mprinter_state drop constraint if exists fk_mprinter_state_printer_id; +drop index if exists ix_mprinter_state_printer_id; + +alter table if exists mprofile drop constraint if exists fk_mprofile_picture_id; +drop index if exists ix_mprofile_picture_id; + +alter table if exists mrole_muser drop constraint if exists fk_mrole_muser_mrole; +drop index if exists ix_mrole_muser_mrole; + +alter table if exists mrole_muser drop constraint if exists fk_mrole_muser_muser; +drop index if exists ix_mrole_muser_muser; + +alter table if exists muser drop constraint if exists fk_muser_user_type_id; +drop index if exists ix_muser_user_type_id; + +alter table if exists mail_user_inbox drop constraint if exists fk_mail_user_inbox_mail_user; +drop index if exists ix_mail_user_inbox_mail_user; + +alter table if exists mail_user_inbox drop constraint if exists fk_mail_user_inbox_mail_box; +drop index if exists ix_mail_user_inbox_mail_box; + +alter table if exists mail_user_outbox drop constraint if exists fk_mail_user_outbox_mail_user; +drop index if exists ix_mail_user_outbox_mail_user; + +alter table if exists mail_user_outbox drop constraint if exists fk_mail_user_outbox_mail_box; +drop index if exists ix_mail_user_outbox_mail_box; + +alter table if exists c_message drop constraint if exists fk_c_message_conversation_id; +drop index if exists ix_c_message_conversation_id; + +alter table if exists c_message drop constraint if exists fk_c_message_user_id; +drop index if exists ix_c_message_user_id; + +alter table if exists meter_contract_data drop constraint if exists fk_meter_contract_data_special_needs_client_id; + +alter table if exists meter_special_needs_client drop constraint if exists fk_meter_special_needs_client_primary_id; + +alter table if exists meter_version drop constraint if exists fk_meter_version_address_data_id; + +alter table if exists meter_version drop constraint if exists fk_meter_version_contract_data_id; + +alter table if exists mnoc_user_mnoc_role drop constraint if exists fk_mnoc_user_mnoc_role_mnoc_user; +drop index if exists ix_mnoc_user_mnoc_role_mnoc_user; + +alter table if exists mnoc_user_mnoc_role drop constraint if exists fk_mnoc_user_mnoc_role_mnoc_role; +drop index if exists ix_mnoc_user_mnoc_role_mnoc_role; + +alter table if exists mny_b drop constraint if exists fk_mny_b_a_id; +drop index if exists ix_mny_b_a_id; + +alter table if exists mny_b_mny_c drop constraint if exists fk_mny_b_mny_c_mny_b; +drop index if exists ix_mny_b_mny_c_mny_b; + +alter table if exists mny_b_mny_c drop constraint if exists fk_mny_b_mny_c_mny_c; +drop index if exists ix_mny_b_mny_c_mny_c; + +alter table if exists subtopics drop constraint if exists fk_subtopics_mny_topic_1; +drop index if exists ix_subtopics_mny_topic_1; + +alter table if exists subtopics drop constraint if exists fk_subtopics_mny_topic_2; +drop index if exists ix_subtopics_mny_topic_2; + +alter table if exists mp_role drop constraint if exists fk_mp_role_mp_user_id; +drop index if exists ix_mp_role_mp_user_id; + +alter table if exists ms_many_a_many_b drop constraint if exists fk_ms_many_a_many_b_ms_many_a; +drop index if exists ix_ms_many_a_many_b_ms_many_a; + +alter table if exists ms_many_a_many_b drop constraint if exists fk_ms_many_a_many_b_ms_many_b; +drop index if exists ix_ms_many_a_many_b_ms_many_b; + +alter table if exists ms_many_b_many_a drop constraint if exists fk_ms_many_b_many_a_ms_many_b; +drop index if exists ix_ms_many_b_many_a_ms_many_b; + +alter table if exists ms_many_b_many_a drop constraint if exists fk_ms_many_b_many_a_ms_many_a; +drop index if exists ix_ms_many_b_many_a_ms_many_a; + +alter table if exists my_lob_size_join_many drop constraint if exists fk_my_lob_size_join_many_parent_id; +drop index if exists ix_my_lob_size_join_many_parent_id; + +alter table if exists o_bean_child drop constraint if exists fk_o_bean_child_cached_bean_id; +drop index if exists ix_o_bean_child_cached_bean_id; + +alter table if exists ocached_app_detail drop constraint if exists fk_ocached_app_detail_app_id; +drop index if exists ix_ocached_app_detail_app_id; + +alter table if exists o_cached_bean_country drop constraint if exists fk_o_cached_bean_country_o_cached_bean; +drop index if exists ix_o_cached_bean_country_o_cached_bean; + +alter table if exists o_cached_bean_country drop constraint if exists fk_o_cached_bean_country_o_country; +drop index if exists ix_o_cached_bean_country_o_country; + +alter table if exists o_cached_bean_child drop constraint if exists fk_o_cached_bean_child_cached_bean_id; +drop index if exists ix_o_cached_bean_child_cached_bean_id; + +alter table if exists oengine drop constraint if exists fk_oengine_car_id; + +alter table if exists ogear_box drop constraint if exists fk_ogear_box_car_id; + +alter table if exists omvertex_other drop constraint if exists fk_omvertex_other_omvertex_id; +drop index if exists ix_omvertex_other_omvertex_id; + +alter table if exists oroad_show_msg drop constraint if exists fk_oroad_show_msg_company_id; + +alter table if exists om_account_child_dbo drop constraint if exists fk_om_account_child_dbo_banana_rama_id; +drop index if exists ix_om_account_child_dbo_banana_rama_id; + +alter table if exists om_basic_child drop constraint if exists fk_om_basic_child_parent_id; +drop index if exists ix_om_basic_child_parent_id; + +alter table if exists om_ordered_detail drop constraint if exists fk_om_ordered_detail_master_id; +drop index if exists ix_om_ordered_detail_master_id; + +alter table if exists oml_baz drop constraint if exists fk_oml_baz_foo_id; +drop index if exists ix_oml_baz_foo_id; + +alter table if exists oml_foo drop constraint if exists fk_oml_foo_bar_id; +drop index if exists ix_oml_foo_bar_id; + +alter table if exists o_order drop constraint if exists fk_o_order_kcustomer_id; +drop index if exists ix_o_order_kcustomer_id; + +alter table if exists o_order_detail drop constraint if exists fk_o_order_detail_order_id; +drop index if exists ix_o_order_detail_order_id; + +alter table if exists o_order_detail drop constraint if exists fk_o_order_detail_product_id; +drop index if exists ix_o_order_detail_product_id; + +alter table if exists s_order_items drop constraint if exists fk_s_order_items_order_uuid; +drop index if exists ix_s_order_items_order_uuid; + +alter table if exists order_referenced_parent drop constraint if exists fk_order_referenced_parent_master_id; +drop index if exists ix_order_referenced_parent_master_id; + +alter table if exists or_order_ship drop constraint if exists fk_or_order_ship_order_id; +drop index if exists ix_or_order_ship_order_id; + +alter table if exists order_toy drop constraint if exists fk_order_toy_child_id; +drop index if exists ix_order_toy_child_id; + +alter table if exists ordered_parent drop constraint if exists fk_ordered_parent_order_master_inheritance_id; +drop index if exists ix_ordered_parent_order_master_inheritance_id; + +alter table if exists organization_node drop constraint if exists fk_organization_node_parent_tree_node_id; + +alter table if exists orp_detail drop constraint if exists fk_orp_detail_master_id; +drop index if exists ix_orp_detail_master_id; + +alter table if exists orp_detail2 drop constraint if exists fk_orp_detail2_orp_master2_id; +drop index if exists ix_orp_detail2_orp_master2_id; + +alter table if exists oto_atwo drop constraint if exists fk_oto_atwo_aone_id; + +alter table if exists oto_bchild drop constraint if exists fk_oto_bchild_master_id; + +alter table if exists oto_child drop constraint if exists fk_oto_child_master_id; + +alter table if exists oto_cust_address drop constraint if exists fk_oto_cust_address_customer_cid; + +alter table if exists oto_level_a drop constraint if exists fk_oto_level_a_b_id; + +alter table if exists oto_level_b drop constraint if exists fk_oto_level_b_c_id; + +alter table if exists oto_prime_extra drop constraint if exists fk_oto_prime_extra_eid; + +alter table if exists oto_sd_child drop constraint if exists fk_oto_sd_child_master_id; + +alter table if exists oto_th_many drop constraint if exists fk_oto_th_many_oto_th_top_id; +drop index if exists ix_oto_th_many_oto_th_top_id; + +alter table if exists oto_th_one drop constraint if exists fk_oto_th_one_many_id; + +alter table if exists oto_ubprime_extra drop constraint if exists fk_oto_ubprime_extra_eid; + +alter table if exists oto_user_model drop constraint if exists fk_oto_user_model_user_optional_id; + +alter table if exists pfile drop constraint if exists fk_pfile_file_content_id; + +alter table if exists pfile drop constraint if exists fk_pfile_file_content2_id; + +alter table if exists paggview drop constraint if exists fk_paggview_pview_id; + +alter table if exists pallet_location drop constraint if exists fk_pallet_location_zone_sid; +drop index if exists ix_pallet_location_zone_sid; + +alter table if exists parcel_location drop constraint if exists fk_parcel_location_parcelid; + +alter table if exists rawinherit_parent_rawinherit_data drop constraint if exists fk_rawinherit_parent_rawinherit_data_rawinherit_parent; +drop index if exists ix_rawinherit_parent_rawinherit_data_rawinherit_parent; + +alter table if exists rawinherit_parent_rawinherit_data drop constraint if exists fk_rawinherit_parent_rawinherit_data_rawinherit_data; +drop index if exists ix_rawinherit_parent_rawinherit_data_rawinherit_data; + +alter table if exists parent_person drop constraint if exists fk_parent_person_some_bean_id; +drop index if exists ix_parent_person_some_bean_id; + +alter table if exists parent_person drop constraint if exists fk_parent_person_parent_identifier; +drop index if exists ix_parent_person_parent_identifier; + +alter table if exists c_participation drop constraint if exists fk_c_participation_conversation_id; +drop index if exists ix_c_participation_conversation_id; + +alter table if exists c_participation drop constraint if exists fk_c_participation_user_id; +drop index if exists ix_c_participation_user_id; + +alter table if exists pcf_calendar drop constraint if exists fk_pcf_calendar_pcf_person_id; +drop index if exists ix_pcf_calendar_pcf_person_id; + +alter table if exists pcf_city drop constraint if exists fk_pcf_city_pcf_country_id; +drop index if exists ix_pcf_city_pcf_country_id; + +alter table if exists pcf_city drop constraint if exists fk_pcf_city_mayor_id; + +alter table if exists pcf_city drop constraint if exists fk_pcf_city_vice_mayor_id; + +alter table if exists pcf_event drop constraint if exists fk_pcf_event_pcf_calendar_id; +drop index if exists ix_pcf_event_pcf_calendar_id; + +alter table if exists persistent_file_content drop constraint if exists fk_persistent_file_content_persistent_file_id; + +alter table if exists person drop constraint if exists fk_person_default_address_oid; +drop index if exists ix_person_default_address_oid; + +alter table if exists person_cache_email drop constraint if exists fk_person_cache_email_person_info_person_id; +drop index if exists ix_person_cache_email_person_info_person_id; + +alter table if exists phones drop constraint if exists fk_phones_person_id; +drop index if exists ix_phones_person_id; + +alter table if exists e_position drop constraint if exists fk_e_position_contract_id; +drop index if exists ix_e_position_contract_id; + +alter table if exists pp_to_ww drop constraint if exists fk_pp_to_ww_pp; +drop index if exists ix_pp_to_ww_pp; + +alter table if exists pp_to_ww drop constraint if exists fk_pp_to_ww_wview; +drop index if exists ix_pp_to_ww_wview; + +alter table if exists question drop constraint if exists fk_question_groupobjectid; +drop index if exists ix_question_groupobjectid; + +alter table if exists r_orders drop constraint if exists fk_r_orders_customer; +drop index if exists ix_r_orders_customer; + +alter table if exists referenced_defaults_model drop constraint if exists fk_referenced_defaults_model_id; + +alter table if exists referenced_defaults_model drop constraint if exists fk_referenced_defaults_model_defaults_model_id; +drop index if exists ix_referenced_defaults_model_defaults_model_id; + +alter table if exists referenced_defaults_model_draft drop constraint if exists fk_referenced_defaults_model_draft_defaults_model_id; +drop index if exists ix_referenced_defaults_model_draft_defaults_model_id; + +alter table if exists rel_master drop constraint if exists fk_rel_master_detail_id; +drop index if exists ix_rel_master_detail_id; + +alter table if exists resourcefile drop constraint if exists fk_resourcefile_parentresourcefileid; +drop index if exists ix_resourcefile_parentresourcefileid; + +alter table if exists mt_role drop constraint if exists fk_mt_role_tenant_id; +drop index if exists ix_mt_role_tenant_id; + +alter table if exists mt_role_permission drop constraint if exists fk_mt_role_permission_mt_role; +drop index if exists ix_mt_role_permission_mt_role; + +alter table if exists mt_role_permission drop constraint if exists fk_mt_role_permission_mt_permission; +drop index if exists ix_mt_role_permission_mt_permission; + +alter table if exists root_bean drop constraint if exists fk_root_bean_referencing_bean_id; +drop index if exists ix_root_bean_referencing_bean_id; + +alter table if exists f_second drop constraint if exists fk_f_second_first; + +alter table if exists section drop constraint if exists fk_section_article_id; +drop index if exists ix_section_article_id; + +alter table if exists self_parent drop constraint if exists fk_self_parent_parent_id; +drop index if exists ix_self_parent_parent_id; + +alter table if exists self_ref_customer drop constraint if exists fk_self_ref_customer_referred_by_id; +drop index if exists ix_self_ref_customer_referred_by_id; + +alter table if exists self_ref_example drop constraint if exists fk_self_ref_example_parent_id; +drop index if exists ix_self_ref_example_parent_id; + +alter table if exists e_save_test_b drop constraint if exists fk_e_save_test_b_sibling_a_id; + +alter table if exists site drop constraint if exists fk_site_parent_id; +drop index if exists ix_site_parent_id; + +alter table if exists site drop constraint if exists fk_site_data_container_id; + +alter table if exists site drop constraint if exists fk_site_site_address_id; + +alter table if exists source_base drop constraint if exists fk_source_base_target_id; +drop index if exists ix_source_base_target_id; + +alter table if exists stockforecast drop constraint if exists fk_stockforecast_inner_report_id; +drop index if exists ix_stockforecast_inner_report_id; + +alter table if exists sub_section drop constraint if exists fk_sub_section_section_id; +drop index if exists ix_sub_section_section_id; + +alter table if exists tevent_many drop constraint if exists fk_tevent_many_event_id; +drop index if exists ix_tevent_many_event_id; + +alter table if exists tevent_one drop constraint if exists fk_tevent_one_event_id; + +alter table if exists t_detail_with_other_namexxxyy drop constraint if exists fk_t_detail_with_other_namexxxyy_master_id; +drop index if exists ix_t_detail_with_other_namexxxyy_master_id; + +alter table if exists ttruck_holder drop constraint if exists fk_ttruck_holder_truck_plate_no; +drop index if exists ix_ttruck_holder_truck_plate_no; + +alter table if exists ttruck_holder drop constraint if exists fk_ttruck_holder_basic_id; +drop index if exists ix_ttruck_holder_basic_id; + +alter table if exists ttruck_holder_item drop constraint if exists fk_ttruck_holder_item_owner_id; +drop index if exists ix_ttruck_holder_item_owner_id; + +alter table if exists twheel drop constraint if exists fk_twheel_owner_plate_no; +drop index if exists ix_twheel_owner_plate_no; + +alter table if exists tire drop constraint if exists fk_tire_wheel; + +alter table if exists tree_entity drop constraint if exists fk_tree_entity_parent_id; +drop index if exists ix_tree_entity_parent_id; + +alter table if exists trip drop constraint if exists fk_trip_vehicle_driver_id; +drop index if exists ix_trip_vehicle_driver_id; + +alter table if exists trip drop constraint if exists fk_trip_address_id; +drop index if exists ix_trip_address_id; + +alter table if exists "type" drop constraint if exists fk_type_sub_type_id; +drop index if exists ix_type_sub_type_id; + +alter table if exists usib_child drop constraint if exists fk_usib_child_parent_id; +drop index if exists ix_usib_child_parent_id; + +alter table if exists usib_child_sibling drop constraint if exists fk_usib_child_sibling_child_id; + +alter table if exists ut_detail drop constraint if exists fk_ut_detail_utmaster_id; +drop index if exists ix_ut_detail_utmaster_id; + +alter table if exists uutwo drop constraint if exists fk_uutwo_master_id; +drop index if exists ix_uutwo_master_id; + +alter table if exists oto_user drop constraint if exists fk_oto_user_account_id; + +alter table if exists c_user drop constraint if exists fk_c_user_group_id; +drop index if exists ix_c_user_group_id; + +alter table if exists em_user_role drop constraint if exists fk_em_user_role_user_id; +drop index if exists ix_em_user_role_user_id; + +alter table if exists em_user_role drop constraint if exists fk_em_user_role_role_id; +drop index if exists ix_em_user_role_role_id; + +alter table if exists vehicle drop constraint if exists fk_vehicle_lease_id; +drop index if exists ix_vehicle_lease_id; + +alter table if exists vehicle drop constraint if exists fk_vehicle_car_ref_id; +drop index if exists ix_vehicle_car_ref_id; + +alter table if exists vehicle drop constraint if exists fk_vehicle_truck_ref_id; +drop index if exists ix_vehicle_truck_ref_id; + +alter table if exists vehicle_driver drop constraint if exists fk_vehicle_driver_vehicle_id; +drop index if exists ix_vehicle_driver_vehicle_id; + +alter table if exists vehicle_driver drop constraint if exists fk_vehicle_driver_address_id; +drop index if exists ix_vehicle_driver_address_id; + +alter table if exists version_child drop constraint if exists fk_version_child_parent_id; +drop index if exists ix_version_child_parent_id; + +alter table if exists version_toy drop constraint if exists fk_version_toy_child_id; +drop index if exists ix_version_toy_child_id; + +alter table if exists warehouses drop constraint if exists fk_warehouses_officezoneid; +drop index if exists ix_warehouses_officezoneid; + +alter table if exists warehousesshippingzones drop constraint if exists fk_warehousesshippingzones_warehouses; +drop index if exists ix_warehousesshippingzones_warehouses; + +alter table if exists warehousesshippingzones drop constraint if exists fk_warehousesshippingzones_zones; +drop index if exists ix_warehousesshippingzones_zones; + +alter table if exists sa_wheel drop constraint if exists fk_sa_wheel_tire; +drop index if exists ix_sa_wheel_tire; + +alter table if exists sa_wheel drop constraint if exists fk_sa_wheel_car; +drop index if exists ix_sa_wheel_car; + +alter table if exists g_who_props_otm drop constraint if exists fk_g_who_props_otm_who_created_id; +drop index if exists ix_g_who_props_otm_who_created_id; + +alter table if exists g_who_props_otm drop constraint if exists fk_g_who_props_otm_who_modified_id; +drop index if exists ix_g_who_props_otm_who_modified_id; + +alter table if exists with_zero drop constraint if exists fk_with_zero_parent_id; +drop index if exists ix_with_zero_parent_id; + +drop table if exists asimple_bean cascade; + +drop table if exists bar cascade; + +drop table if exists block cascade; + +drop table if exists oto_account cascade; + +drop table if exists acl cascade; + +drop table if exists acl_container_relation cascade; + +drop table if exists addr cascade; + +drop table if exists address cascade; + +drop table if exists o_address cascade; + +drop table if exists album cascade; + +drop table if exists animal cascade; + +drop table if exists animal_shelter cascade; + +drop table if exists article cascade; + +drop table if exists attribute cascade; + +drop table if exists attribute_holder cascade; + +drop table if exists audit_log cascade; + +drop table if exists bbookmark cascade; + +drop table if exists bbookmark_org cascade; + +drop table if exists bbookmark_user cascade; + +drop table if exists bsimple_with_gen cascade; + +drop table if exists bsite cascade; + +drop table if exists bsite_user_a cascade; + +drop table if exists bsite_user_b cascade; + +drop table if exists bsite_user_c cascade; + +drop table if exists bsite_user_d cascade; + +drop table if exists bsite_user_e cascade; + +drop table if exists buser cascade; + +drop table if exists bwith_qident cascade; + +drop table if exists basic_draftable_bean cascade; + +drop table if exists basic_draftable_bean_draft cascade; + +drop table if exists basic_joda_entity cascade; + +drop table if exists bean_with_time_zone cascade; + +drop table if exists drel_booking cascade; +drop sequence if exists drel_booking_seq; + +drop table if exists bw_bean cascade; + +drop table if exists cepcategory cascade; + +drop table if exists cepproduct cascade; + +drop table if exists cepproduct_category cascade; + +drop table if exists ciaddress cascade; + +drop table if exists cicustomer_parent cascade; + +drop table if exists cistreet_parent cascade; + +drop table if exists cinh_ref cascade; + +drop table if exists cinh_root cascade; + +drop table if exists ckey_assoc cascade; + +drop table if exists ckey_detail cascade; + +drop table if exists ckey_parent cascade; + +drop table if exists coone cascade; + +drop table if exists coone_many cascade; + +drop table if exists coroot cascade; + +drop table if exists calculation_result cascade; + +drop table if exists cao_bean cascade; + +drop table if exists sp_car_car cascade; +drop sequence if exists sp_car_car_seq; + +drop table if exists sp_car_car_wheels cascade; + +drop table if exists sp_car_car_doors cascade; + +drop table if exists sa_car cascade; +drop sequence if exists sa_car_seq; + +drop table if exists car_accessory cascade; + +drop table if exists car_fuse cascade; + +drop table if exists category cascade; + +drop table if exists e_save_test_d cascade; + +drop table if exists child_person cascade; + +drop table if exists cke_client cascade; + +drop table if exists cke_user cascade; + +drop table if exists class_super cascade; + +drop table if exists class_super_monkey cascade; + +drop table if exists configuration cascade; + +drop table if exists configurations cascade; + +drop table if exists contact cascade; + +drop table if exists contact_group cascade; + +drop table if exists contact_note cascade; + +drop table if exists contract cascade; + +drop table if exists contract_costs cascade; + +drop table if exists c_conversation cascade; + +drop table if exists o_country cascade; + +drop table if exists cover cascade; + +drop table if exists o_customer cascade; + +drop table if exists dcredit cascade; + +drop table if exists dcredit_drol cascade; + +drop table if exists dexh_entity cascade; + +drop table if exists dint_parent cascade; + +drop table if exists dmachine cascade; + +drop table if exists d_machine_aux_use cascade; + +drop table if exists d_machine_stats cascade; + +drop table if exists d_machine_use cascade; + +drop table if exists dorg cascade; + +drop table if exists dperson cascade; + +drop table if exists drol cascade; + +drop table if exists drot cascade; + +drop table if exists drot_drol cascade; + +drop table if exists rawinherit_data cascade; + +drop table if exists data_container cascade; + +drop table if exists dc_detail cascade; + +drop table if exists dc_master cascade; + +drop table if exists defaults_model cascade; + +drop table if exists defaults_model_draft cascade; + +drop table if exists dfk_cascade cascade; + +drop table if exists dfk_cascade_one cascade; + +drop table if exists dfk_none cascade; + +drop table if exists dfk_none_via_join cascade; + +drop table if exists dfk_none_via_mto_m cascade; + +drop table if exists dfk_none_via_mto_m_dfk_one cascade; + +drop table if exists dfk_one cascade; + +drop table if exists dfk_set_null cascade; + +drop table if exists doc cascade; + +drop table if exists doc_link cascade; + +drop table if exists doc_link_draft cascade; + +drop table if exists doc_draft cascade; + +drop table if exists document cascade; + +drop table if exists document_draft cascade; + +drop table if exists document_media cascade; + +drop table if exists document_media_draft cascade; + +drop table if exists sp_car_door cascade; +drop sequence if exists sp_car_door_seq; + +drop table if exists earray_bean cascade; + +drop table if exists earray_set_bean cascade; + +drop table if exists e_basic cascade; + +drop table if exists ebasic_change_log cascade; + +drop table if exists ebasic_clob cascade; + +drop table if exists ebasic_clob_fetch_eager cascade; + +drop table if exists ebasic_clob_no_ver cascade; + +drop table if exists e_basicenc cascade; + +drop table if exists e_basicenc_bin cascade; + +drop table if exists e_basicenc_client cascade; + +drop table if exists e_basicenc_relate cascade; + +drop table if exists e_basic_enum_id cascade; + +drop table if exists e_basic_eni cascade; + +drop table if exists ebasic_hstore cascade; + +drop table if exists ebasic_json_jackson cascade; + +drop table if exists ebasic_json_jackson2 cascade; + +drop table if exists ebasic_json_list cascade; + +drop table if exists ebasic_json_map cascade; + +drop table if exists ebasic_json_map_blob cascade; + +drop table if exists ebasic_json_map_clob cascade; + +drop table if exists ebasic_json_map_detail cascade; + +drop table if exists ebasic_json_map_json_b cascade; + +drop table if exists ebasic_json_map_varchar cascade; + +drop table if exists ebasic_json_node cascade; + +drop table if exists ebasic_json_node_blob cascade; + +drop table if exists ebasic_json_node_json_b cascade; + +drop table if exists ebasic_json_node_varchar cascade; + +drop table if exists ebasic_json_unmapped cascade; + +drop table if exists e_basic_ndc cascade; + +drop table if exists ebasic_no_sdchild cascade; + +drop table if exists ebasic_sdchild cascade; + +drop table if exists ebasic_soft_delete cascade; + +drop table if exists e_basicver cascade; + +drop table if exists e_basic_withlife cascade; + +drop table if exists e_basic_with_ex cascade; + +drop table if exists e_basicverucon cascade; + +drop table if exists ecache_child cascade; + +drop table if exists ecache_root cascade; + +drop table if exists e_col_ab cascade; + +drop table if exists ecustom_id cascade; + +drop table if exists edefault_prop cascade; + +drop table if exists eemb_inner cascade; + +drop table if exists eemb_outer cascade; + +drop table if exists efile2_no_fk cascade; + +drop table if exists efile_no_fk cascade; + +drop table if exists efile_no_fk_euser_no_fk cascade; + +drop table if exists efile_no_fk_euser_no_fk_soft_del cascade; + +drop table if exists egen_props cascade; + +drop table if exists eid_uid_bean cascade; + +drop table if exists einvoice cascade; + +drop table if exists e_main cascade; + +drop table if exists enull_collection cascade; + +drop table if exists enull_collection_detail cascade; + +drop table if exists eopt_one_a cascade; + +drop table if exists eopt_one_b cascade; + +drop table if exists eopt_one_c cascade; + +drop table if exists eper_addr cascade; + +drop table if exists eperson cascade; + +drop table if exists e_person_online cascade; + +drop table if exists esimple cascade; + +drop table if exists esoft_del_book cascade; + +drop table if exists esoft_del_book_esoft_del_user cascade; + +drop table if exists esoft_del_down cascade; + +drop table if exists esoft_del_mid cascade; + +drop table if exists esoft_del_one_a cascade; + +drop table if exists esoft_del_one_b cascade; + +drop table if exists esoft_del_role cascade; + +drop table if exists esoft_del_role_esoft_del_user cascade; + +drop table if exists esoft_del_top cascade; + +drop table if exists esoft_del_up cascade; + +drop table if exists esoft_del_user cascade; + +drop table if exists esoft_del_user_esoft_del_role cascade; + +drop table if exists esome_convert_type cascade; + +drop table if exists esome_type cascade; + +drop table if exists etrans_many cascade; + +drop table if exists rawinherit_uncle cascade; + +drop table if exists euser_no_fk cascade; + +drop table if exists euser_no_fk_soft_del cascade; + +drop table if exists evanilla_collection cascade; + +drop table if exists evanilla_collection_detail cascade; + +drop table if exists ewho_props cascade; + +drop table if exists e_withinet cascade; + +drop table if exists ec_enum_person cascade; + +drop table if exists ec_enum_person_tags cascade; + +drop table if exists ec_person cascade; + +drop table if exists ec_person_phone cascade; + +drop table if exists ec_top cascade; + +drop table if exists ec_top_ecs_person cascade; + +drop table if exists ecbl_person cascade; + +drop table if exists ecbl_person_phone_numbers cascade; + +drop table if exists ecbm_person cascade; + +drop table if exists ecbm_person_phone_numbers cascade; + +drop table if exists ecm_person cascade; + +drop table if exists ecm_person_phone_numbers cascade; + +drop table if exists ecmc_person cascade; + +drop table if exists ecmc_person_phone_numbers cascade; + +drop table if exists ecs_person cascade; + +drop table if exists ecs_person_phone cascade; + +drop table if exists ecsm_child cascade; + +drop table if exists ecsm_values cascade; + +drop table if exists ecsm_one cascade; + +drop table if exists ecsm_parent cascade; + +drop table if exists ecsm_two cascade; + +drop table if exists td_child cascade; + +drop table if exists td_parent cascade; + +drop table if exists element_bean cascade; + +drop table if exists empl cascade; + +drop table if exists esd_detail cascade; + +drop table if exists esd_master cascade; + +drop table if exists feature_desc cascade; + +drop table if exists f_first cascade; + +drop table if exists foo cascade; + +drop table if exists gen_key_identity cascade; + +drop table if exists gen_key_sequence cascade; +drop sequence if exists SEQ_NAME; + +drop table if exists grand_parent_person cascade; + +drop table if exists survey_group cascade; + +drop table if exists c_group cascade; + +drop table if exists he_doc cascade; + +drop trigger if exists hx_link_history_upd on hx_link cascade; +drop function if exists hx_link_history_version(); + +drop view hx_link_with_history; +alter table hx_link drop column sys_period; +drop table hx_link_history; + +drop table if exists hx_link cascade; + +drop table if exists hx_link_doc cascade; + +drop table if exists hi_doc cascade; + +drop trigger if exists hi_link_history_upd on hi_link cascade; +drop function if exists hi_link_history_version(); + +drop view hi_link_with_history; +alter table hi_link drop column sys_period; +drop table hi_link_history; + +drop table if exists hi_link cascade; + +drop trigger if exists hi_link_doc_history_upd on hi_link_doc cascade; +drop function if exists hi_link_doc_history_version(); + +drop view hi_link_doc_with_history; +alter table hi_link_doc drop column sys_period; +drop table hi_link_doc_history; + +drop table if exists hi_link_doc cascade; + +drop trigger if exists hi_tone_history_upd on hi_tone cascade; +drop function if exists hi_tone_history_version(); + +drop view hi_tone_with_history; +alter table hi_tone drop column sys_period; +drop table hi_tone_history; + +drop table if exists hi_tone cascade; + +drop trigger if exists hi_tthree_history_upd on hi_tthree cascade; +drop function if exists hi_tthree_history_version(); + +drop view hi_tthree_with_history; +alter table hi_tthree drop column sys_period; +drop table hi_tthree_history; + +drop table if exists hi_tthree cascade; + +drop trigger if exists hi_ttwo_history_upd on hi_ttwo cascade; +drop function if exists hi_ttwo_history_version(); + +drop view hi_ttwo_with_history; +alter table hi_ttwo drop column sys_period; +drop table hi_ttwo_history; + +drop table if exists hi_ttwo cascade; + +drop trigger if exists hsd_setting_history_upd on hsd_setting cascade; +drop function if exists hsd_setting_history_version(); + +drop view hsd_setting_with_history; +alter table hsd_setting drop column sys_period; +drop table hsd_setting_history; + +drop table if exists hsd_setting cascade; + +drop trigger if exists hsd_user_history_upd on hsd_user cascade; +drop function if exists hsd_user_history_version(); + +drop view hsd_user_with_history; +alter table hsd_user drop column sys_period; +drop table hsd_user_history; + +drop table if exists hsd_user cascade; + +drop table if exists iaf_segment cascade; + +drop table if exists iaf_segment_status cascade; + +drop table if exists imrelated cascade; + +drop table if exists imroot cascade; + +drop table if exists ixresource cascade; + +drop table if exists info_company cascade; + +drop table if exists info_contact cascade; + +drop table if exists info_customer cascade; + +drop table if exists inner_report cascade; + +drop table if exists drel_invoice cascade; +drop sequence if exists drel_invoice_seq; + +drop table if exists item cascade; + +drop table if exists monkey cascade; + +drop table if exists mkeygroup cascade; + +drop table if exists mkeygroup_monkey cascade; + +drop table if exists trainer cascade; + +drop table if exists trainer_monkey cascade; + +drop table if exists troop cascade; + +drop table if exists troop_monkey cascade; + +drop table if exists l2_cldf_reset_bean cascade; + +drop table if exists l2_cldf_reset_bean_child cascade; + +drop table if exists level1 cascade; + +drop table if exists level1_level4 cascade; + +drop table if exists level1_level2 cascade; + +drop table if exists level2 cascade; + +drop table if exists level2_level3 cascade; + +drop table if exists level3 cascade; + +drop table if exists level4 cascade; + +drop trigger if exists link_history_upd on link cascade; +drop function if exists link_history_version(); + +drop view link_with_history; +alter table link drop column sys_period; +drop table link_history; + +drop table if exists link cascade; + +drop table if exists link_draft cascade; + +drop table if exists la_attr_value cascade; + +drop table if exists la_attr_value_attribute cascade; + +drop table if exists looney cascade; + +drop table if exists maddress cascade; + +drop table if exists mcontact cascade; + +drop table if exists mcontact_message cascade; + +drop table if exists mcustomer cascade; + +drop table if exists mgroup cascade; + +drop table if exists mmachine cascade; + +drop table if exists mmachine_mgroup cascade; + +drop table if exists mmedia cascade; + +drop table if exists non_updateprop cascade; + +drop table if exists mprinter cascade; + +drop table if exists mprinter_state cascade; + +drop table if exists mprofile cascade; + +drop table if exists mprotected_construct_bean cascade; + +drop table if exists mrole cascade; + +drop table if exists mrole_muser cascade; + +drop table if exists msome_other cascade; + +drop table if exists muser cascade; + +drop table if exists muser_type cascade; + +drop table if exists mail_box cascade; + +drop table if exists mail_user cascade; + +drop table if exists mail_user_inbox cascade; + +drop table if exists mail_user_outbox cascade; + +drop table if exists main_entity cascade; + +drop table if exists main_entity_relation cascade; + +drop table if exists map_super_actual cascade; + +drop table if exists c_message cascade; + +drop table if exists meter_address_data cascade; + +drop table if exists meter_contract_data cascade; + +drop table if exists meter_special_needs_client cascade; + +drop table if exists meter_special_needs_contact cascade; + +drop table if exists meter_version cascade; + +drop table if exists mnoc_role cascade; + +drop table if exists mnoc_user cascade; + +drop table if exists mnoc_user_mnoc_role cascade; + +drop table if exists mny_a cascade; + +drop table if exists mny_b cascade; + +drop table if exists mny_b_mny_c cascade; + +drop table if exists mny_c cascade; + +drop table if exists mny_topic cascade; + +drop table if exists subtopics cascade; + +drop table if exists mp_role cascade; + +drop table if exists mp_user cascade; + +drop table if exists ms_many_a cascade; + +drop table if exists ms_many_a_many_b cascade; + +drop table if exists ms_many_b cascade; + +drop table if exists ms_many_b_many_a cascade; + +drop table if exists my_lob_size cascade; + +drop table if exists my_lob_size_join_many cascade; + +drop table if exists noidbean cascade; + +drop table if exists o_bean_child cascade; + +drop table if exists ocached_app cascade; + +drop table if exists ocached_app_detail cascade; + +drop table if exists o_cached_bean cascade; + +drop table if exists o_cached_bean_country cascade; + +drop table if exists o_cached_bean_child cascade; + +drop table if exists o_cached_inherit cascade; + +drop table if exists o_cached_natkey cascade; + +drop table if exists o_cached_natkey3 cascade; + +drop table if exists ocached_nkey_uid cascade; + +drop table if exists ocar cascade; + +drop table if exists ocompany cascade; + +drop table if exists oengine cascade; + +drop table if exists ogear_box cascade; + +drop table if exists omvertex cascade; + +drop table if exists omvertex_other cascade; + +drop table if exists oroad_show_msg cascade; + +drop table if exists om_account_child_dbo cascade; + +drop table if exists om_account_dbo cascade; + +drop table if exists om_basic_child cascade; + +drop table if exists om_basic_parent cascade; + +drop table if exists om_ordered_detail cascade; + +drop table if exists om_ordered_master cascade; + +drop table if exists oml_bar cascade; + +drop table if exists oml_baz cascade; + +drop table if exists oml_foo cascade; + +drop table if exists only_id_entity cascade; + +drop table if exists o_order cascade; + +drop table if exists o_order_detail cascade; + +drop table if exists s_orders cascade; + +drop table if exists s_order_items cascade; + +drop table if exists order_master cascade; + +drop table if exists order_master_inheritance cascade; + +drop table if exists order_referenced_parent cascade; + +drop table if exists or_order_ship cascade; + +drop table if exists order_toy cascade; + +drop table if exists ordered_parent cascade; + +drop table if exists organisation cascade; + +drop table if exists organization_node cascade; + +drop table if exists organization_tree_node cascade; + +drop table if exists orp_detail cascade; + +drop table if exists orp_detail2 cascade; + +drop table if exists orp_master cascade; + +drop table if exists orp_master2 cascade; + +drop table if exists oto_aone cascade; + +drop table if exists oto_atwo cascade; + +drop table if exists oto_bchild cascade; + +drop table if exists oto_bmaster cascade; + +drop table if exists oto_child cascade; + +drop table if exists oto_cust cascade; + +drop table if exists oto_cust_address cascade; + +drop table if exists oto_level_a cascade; + +drop table if exists oto_level_b cascade; + +drop table if exists oto_level_c cascade; + +drop table if exists oto_master cascade; + +drop table if exists oto_prime cascade; + +drop table if exists oto_prime_extra cascade; + +drop table if exists oto_sd_child cascade; + +drop table if exists oto_sd_master cascade; + +drop table if exists oto_th_many cascade; + +drop table if exists oto_th_one cascade; + +drop table if exists oto_th_top cascade; + +drop table if exists oto_ubprime cascade; + +drop table if exists oto_ubprime_extra cascade; + +drop table if exists oto_uprime cascade; + +drop table if exists oto_uprime_extra cascade; + +drop table if exists oto_user_model cascade; + +drop table if exists oto_user_model_optional cascade; + +drop table if exists pfile cascade; + +drop table if exists pfile_content cascade; + +drop table if exists paggview cascade; + +drop table if exists pallet_location cascade; + +drop table if exists parcel cascade; + +drop table if exists parcel_location cascade; + +drop table if exists rawinherit_parent cascade; + +drop table if exists rawinherit_parent_rawinherit_data cascade; + +drop table if exists e_save_test_c cascade; + +drop table if exists parent_person cascade; + +drop table if exists c_participation cascade; + +drop table if exists password_store_model cascade; + +drop table if exists pcf_calendar cascade; + +drop table if exists pcf_city cascade; + +drop table if exists pcf_country cascade; + +drop table if exists pcf_event cascade; + +drop table if exists pcf_person cascade; + +drop table if exists mt_permission cascade; + +drop table if exists persistent_file cascade; + +drop table if exists persistent_file_content cascade; + +drop table if exists person cascade; + +drop table if exists persons cascade; + +drop table if exists person_cache_email cascade; + +drop table if exists person_cache_info cascade; + +drop table if exists phones cascade; + +drop table if exists e_position cascade; + +drop table if exists primary_revision cascade; + +drop table if exists o_product cascade; + +drop table if exists pp cascade; + +drop table if exists pp_to_ww cascade; + +drop table if exists question cascade; + +drop table if exists rcustomer cascade; + +drop table if exists r_orders cascade; + +drop table if exists referenced_defaults_model cascade; + +drop table if exists referenced_defaults_model_draft cascade; + +drop table if exists referencing_bean cascade; + +drop table if exists region cascade; + +drop table if exists rel_detail cascade; + +drop table if exists rel_master cascade; + +drop table if exists resourcefile cascade; + +drop table if exists mt_role cascade; + +drop table if exists mt_role_permission cascade; + +drop table if exists em_role cascade; + +drop table if exists root_bean cascade; + +drop table if exists f_second cascade; + +drop table if exists section cascade; + +drop table if exists self_parent cascade; + +drop table if exists self_ref_customer cascade; + +drop table if exists self_ref_example cascade; + +drop table if exists e_save_test_a cascade; + +drop table if exists e_save_test_b cascade; + +drop table if exists site cascade; + +drop table if exists site_address cascade; + +drop table if exists some_enum_bean cascade; + +drop table if exists some_file_bean cascade; + +drop table if exists some_new_types_bean cascade; + +drop table if exists some_period_bean cascade; + +drop table if exists source_base cascade; + +drop table if exists stockforecast cascade; + +drop table if exists sub_section cascade; + +drop table if exists sub_type cascade; + +drop table if exists survey cascade; + +drop table if exists tbytes_only cascade; + +drop table if exists tcar cascade; + +drop table if exists tevent cascade; + +drop table if exists tevent_many cascade; + +drop table if exists tevent_one cascade; + +drop table if exists tint_root cascade; + +drop table if exists tjoda_entity cascade; + +drop table if exists t_mapsuper1 cascade; + +drop table if exists t_oneb cascade; + +drop table if exists t_detail_with_other_namexxxyy cascade; +drop sequence if exists t_atable_detail_seq; + +drop table if exists t_atable_thatisrelatively cascade; +drop sequence if exists t_atable_master_seq; + +drop table if exists ttruck_holder cascade; + +drop table if exists ttruck_holder_item cascade; + +drop table if exists tuuid_entity cascade; + +drop table if exists twheel cascade; + +drop table if exists twith_pre_insert cascade; + +drop table if exists target_base cascade; + +drop table if exists mt_tenant cascade; + +drop table if exists test_annotation_base_entity cascade; + +drop table if exists tire cascade; +drop sequence if exists tire_seq; + +drop table if exists sa_tire cascade; +drop sequence if exists sa_tire_seq; + +drop table if exists tree_entity cascade; + +drop table if exists trip cascade; + +drop table if exists truck_ref cascade; + +drop table if exists tune cascade; + +drop table if exists "type" cascade; + +drop table if exists tz_bean cascade; + +drop table if exists usib_child cascade; + +drop table if exists usib_child_sibling cascade; + +drop table if exists usib_parent cascade; + +drop table if exists ut_detail cascade; + +drop table if exists ut_master cascade; + +drop table if exists uuone cascade; + +drop table if exists uutwo cascade; + +drop table if exists oto_user cascade; + +drop trigger if exists c_user_history_upd on c_user cascade; +drop function if exists c_user_history_version(); + +drop view c_user_with_history; +alter table c_user drop column sys_period; +drop table c_user_history; + +drop table if exists c_user cascade; + +drop table if exists tx_user cascade; + +drop table if exists g_user cascade; + +drop table if exists em_user cascade; + +drop table if exists user_interest_live cascade; + +drop table if exists em_user_role cascade; + +drop table if exists vehicle cascade; + +drop table if exists vehicle_driver cascade; + +drop table if exists vehicle_lease cascade; + +drop table if exists version_child cascade; + +drop table if exists version_parent cascade; + +drop table if exists version_toy cascade; + +drop table if exists warehouses cascade; + +drop table if exists warehousesshippingzones cascade; + +drop table if exists wheel cascade; +drop sequence if exists wheel_seq; + +drop table if exists sa_wheel cascade; +drop sequence if exists sa_wheel_seq; + +drop table if exists sp_car_wheel cascade; +drop sequence if exists sp_car_wheel_seq; + +drop table if exists g_who_props_otm cascade; + +drop table if exists with_zero cascade; + +drop table if exists parent cascade; + +drop table if exists wview cascade; + +drop table if exists zones cascade; + +drop index if exists ix_contact_last_name_first_name; +drop index if exists ix_e_basic_name; +drop index if exists ix_efile2_no_fk_owner_id; +drop index if exists ix_ecsm_values_host_id; +drop index if exists ix_order_referenced_parent_type; +drop index if exists ix_organization_node_kind; +drop index concurrently if exists ix_t_detail_with_other_namexxxyy_lowername; +drop index if exists ix_t_detail_with_other_namexxxyy_defn; +drop index if exists ano_3; +drop index if exists ano_1; +drop index if exists ano_2; diff --git a/ebean-core/src/test/ddl-review/sqlserver-create-all.sql b/ebean-core/src/test/ddl-review/sqlserver-create-all.sql new file mode 100644 index 000000000..40e48e28e --- /dev/null +++ b/ebean-core/src/test/ddl-review/sqlserver-create-all.sql @@ -0,0 +1,5308 @@ +-- Generated by ebean unknown at 2020-03-04T08:21:26.827349Z +-- init script create procs +-- Initial script to create stored procedures etc for sqlserver platform + +-- create table-value-parameters +if not exists (select name from sys.types where name = 'ebean_bigint_tvp') create type ebean_bigint_tvp as table (c1 bigint) +GO +if not exists (select name from sys.types where name = 'ebean_float_tvp') create type ebean_float_tvp as table (c1 float) +GO +if not exists (select name from sys.types where name = 'ebean_bit_tvp') create type ebean_bit_tvp as table (c1 bit) +GO +if not exists (select name from sys.types where name = 'ebean_date_tvp') create type ebean_date_tvp as table (c1 date) +GO +if not exists (select name from sys.types where name = 'ebean_time_tvp') create type ebean_time_tvp as table (c1 time) +GO +if not exists (select name from sys.types where name = 'ebean_uniqueidentifier_tvp') create type ebean_uniqueidentifier_tvp as table (c1 uniqueidentifier) +GO +if not exists (select name from sys.types where name = 'ebean_nvarchar_tvp') create type ebean_nvarchar_tvp as table (c1 nvarchar(max)) +GO + +-- +-- PROCEDURE: usp_ebean_drop_indices TABLE, COLUMN +-- deletes all indices referring to TABLE.COLUMN +-- +CREATE OR ALTER PROCEDURE usp_ebean_drop_indices @tableName nvarchar(255), @columnName nvarchar(255) +AS SET NOCOUNT ON +declare @sql nvarchar(1000) +declare @indexName nvarchar(255) +BEGIN + DECLARE index_cursor CURSOR FOR SELECT i.name from sys.indexes i + join sys.index_columns ic on ic.object_id = i.object_id and ic.index_id = i.index_id + join sys.columns c on c.object_id = ic.object_id and c.column_id = ic.column_id + where i.object_id = OBJECT_ID(@tableName) AND c.name = @columnName; + OPEN index_cursor + FETCH NEXT FROM index_cursor INTO @indexName + WHILE @@FETCH_STATUS = 0 + BEGIN + set @sql = 'drop index ' + @indexName + ' on ' + @tableName; + EXECUTE(@sql); + + FETCH NEXT FROM index_cursor INTO @indexName + END; + CLOSE index_cursor; + DEALLOCATE index_cursor; +END +GO + +-- +-- PROCEDURE: usp_ebean_drop_default_constraint TABLE, COLUMN +-- deletes the default constraint, which has a random name +-- +CREATE OR ALTER PROCEDURE usp_ebean_drop_default_constraint @tableName nvarchar(255), @columnName nvarchar(255) +AS SET NOCOUNT ON +declare @tmp nvarchar(1000) +BEGIN + select @tmp = t1.name from sys.default_constraints t1 + join sys.columns t2 on t1.object_id = t2.default_object_id + where t1.parent_object_id = OBJECT_ID(@tableName) and t2.name = @columnName; + + if @tmp is not null EXEC('alter table ' + @tableName +' drop constraint ' + @tmp); +END +GO + +-- +-- PROCEDURE: usp_ebean_drop_constraints TABLE, COLUMN +-- deletes constraints and foreign keys refering to TABLE.COLUMN +-- +CREATE OR ALTER PROCEDURE usp_ebean_drop_constraints @tableName nvarchar(255), @columnName nvarchar(255) +AS SET NOCOUNT ON +declare @sql nvarchar(1000) +declare @constraintName nvarchar(255) +BEGIN + DECLARE name_cursor CURSOR FOR + SELECT cc.name from sys.check_constraints cc + join sys.columns c on c.object_id = cc.parent_object_id and c.column_id = cc.parent_column_id + where parent_object_id = OBJECT_ID(@tableName) AND c.name = @columnName + UNION SELECT fk.name from sys.foreign_keys fk + join sys.foreign_key_columns fkc on fkc.constraint_object_id = fk.object_id + and fkc.parent_object_id = fk.parent_object_id + join sys.columns c on c.object_id = fkc.parent_object_id and c.column_id = fkc.parent_column_id + where fkc.parent_object_id = OBJECT_ID(@tableName) AND c.name = @columnName; + + OPEN name_cursor + FETCH NEXT FROM name_cursor INTO @constraintName + WHILE @@FETCH_STATUS = 0 + BEGIN + set @sql = 'alter table ' + @tableName + ' drop constraint ' + @constraintName; + EXECUTE(@sql); + + FETCH NEXT FROM name_cursor INTO @constraintName + END; + CLOSE name_cursor; + DEALLOCATE name_cursor; +END +GO + +-- +-- PROCEDURE: usp_ebean_drop_column TABLE, COLUMN +-- deletes the column annd ensures that all indices and constraints are dropped first +-- +CREATE OR ALTER PROCEDURE usp_ebean_drop_column @tableName nvarchar(255), @columnName nvarchar(255) +AS SET NOCOUNT ON +declare @sql nvarchar(1000) +BEGIN + EXEC usp_ebean_drop_indices @tableName, @columnName; + EXEC usp_ebean_drop_default_constraint @tableName, @columnName; + EXEC usp_ebean_drop_constraints @tableName, @columnName; + + set @sql = 'alter table ' + @tableName + ' drop column ' + @columnName; + EXECUTE(@sql); +END +GO +create table asimple_bean ( + id numeric(19) not null, + name nvarchar(255), + constraint pk_asimple_bean primary key (id) +); +create sequence asimple_bean_seq as bigint start with 1 increment by 50; + +create table bar ( + bar_type nvarchar(31) not null, + bar_id integer not null, + foo_id integer not null, + version integer not null, + constraint pk_bar primary key (bar_id) +); +create sequence bar_seq as bigint start with 1 increment by 50; + +create table block ( + case_type integer not null, + id numeric(19) not null, + name nvarchar(255), + version numeric(19) not null, + notes nvarchar(255), + constraint pk_block primary key (id) +); +create sequence block_seq as bigint start with 1 increment by 50; + +create table oto_account ( + id numeric(19) not null, + name nvarchar(255), + version numeric(19) not null, + when_created datetime2 not null, + when_modified datetime2 not null, + constraint pk_oto_account primary key (id) +); +create sequence oto_account_seq as bigint start with 1 increment by 50; + +create table acl ( + id numeric(19) not null, + name nvarchar(255), + constraint pk_acl primary key (id) +); +create sequence acl_seq as bigint start with 1 increment by 50; + +create table acl_container_relation ( + id numeric(19) not null, + container_id numeric(19) not null, + acl_entry_id numeric(19) not null, + constraint pk_acl_container_relation primary key (id) +); +create sequence acl_container_relation_seq as bigint start with 1 increment by 50; + +create table addr ( + id numeric(19) not null, + employee_id numeric(19), + name nvarchar(255), + address_line1 nvarchar(255), + address_line2 nvarchar(255), + city nvarchar(255), + version numeric(19) not null, + constraint pk_addr primary key (id) +); +create sequence addr_seq as bigint start with 1 increment by 50; + +create table address ( + oid numeric(19) not null, + street nvarchar(255), + version integer not null, + constraint pk_address primary key (oid) +); +create sequence address_seq as bigint start with 1 increment by 50; + +create table o_address ( + id integer not null, + line_1 nvarchar(100), + line_2 nvarchar(100), + city nvarchar(100), + cretime datetime2, + country_code nvarchar(2), + updtime datetime2 not null, + constraint pk_o_address primary key (id) +); +create sequence o_address_seq as bigint start with 1 increment by 50; + +create table album ( + id numeric(19) not null, + name nvarchar(255), + cover_id numeric(19), + deleted integer default 0 not null, + created_at datetime2 not null, + last_update datetime2 not null, + constraint pk_album primary key (id) +); +create unique nonclustered index uq_album_cover_id on album(cover_id) where cover_id is not null; +create sequence album_seq as bigint start with 1 increment by 50; + +create table animal ( + species nvarchar(255) not null, + id numeric(19) not null, + shelter_id numeric(19), + version numeric(19) not null, + name nvarchar(255), + registration_number nvarchar(255), + date_of_birth date, + dog_size nvarchar(255), + constraint pk_animal primary key (id) +); +create sequence animal_seq as bigint start with 1 increment by 50; + +create table animal_shelter ( + id numeric(19) not null, + name nvarchar(255), + version numeric(19) not null, + constraint pk_animal_shelter primary key (id) +); +create sequence animal_shelter_seq as bigint start with 1 increment by 50; + +create table article ( + id integer not null, + name nvarchar(255), + author nvarchar(255), + cretime datetime2 not null, + updtime datetime2 not null, + version numeric(19) not null, + constraint pk_article primary key (id) +); +create sequence article_seq as bigint start with 1 increment by 50; + +create table attribute ( + option_type integer not null, + id integer not null, + attribute_holder_id integer, + cretime datetime2 not null, + updtime datetime2 not null, + version numeric(19) not null, + constraint pk_attribute primary key (id) +); +create sequence attribute_seq as bigint start with 1 increment by 50; + +create table attribute_holder ( + id integer not null, + cretime datetime2 not null, + updtime datetime2 not null, + version numeric(19) not null, + constraint pk_attribute_holder primary key (id) +); +create sequence attribute_holder_seq as bigint start with 1 increment by 50; + +create table audit_log ( + id numeric(19) not null, + description nvarchar(255), + modified_description nvarchar(255), + constraint pk_audit_log primary key (id) +); +create sequence audit_log_seq as bigint start with 1000 increment by 50 cache 50; + +create table bbookmark ( + id integer not null, + bookmark_reference nvarchar(255), + user_id integer, + constraint pk_bbookmark primary key (id) +); +create sequence bbookmark_seq as bigint start with 1 increment by 50; + +create table bbookmark_org ( + id integer not null, + name nvarchar(255), + constraint pk_bbookmark_org primary key (id) +); +create sequence bbookmark_org_seq as bigint start with 1 increment by 50; + +create table bbookmark_user ( + id integer not null, + name nvarchar(255), + password nvarchar(255), + email_address nvarchar(255), + country nvarchar(255), + org_id integer, + constraint pk_bbookmark_user primary key (id) +); +create sequence bbookmark_user_seq as bigint start with 1 increment by 50; + +create table bsimple_with_gen ( + id integer not null, + name nvarchar(255), + constraint pk_bsimple_with_gen primary key (id) +); +create sequence bsimple_with_gen_seq as bigint start with 1 increment by 50; + +create table bsite ( + id uniqueidentifier not null, + name nvarchar(255), + constraint pk_bsite primary key (id) +); + +create table bsite_user_a ( + site_id uniqueidentifier not null, + user_id uniqueidentifier not null, + access_level integer, + version numeric(19) not null, + constraint ck_bsite_user_a_access_level check ( access_level in (0,1,2)), + constraint pk_bsite_user_a primary key (site_id,user_id) +); + +create table bsite_user_b ( + site uniqueidentifier not null, + usr uniqueidentifier not null, + access_level integer, + constraint ck_bsite_user_b_access_level check ( access_level in (0,1,2)), + constraint pk_bsite_user_b primary key (site,usr) +); + +create table bsite_user_c ( + site_uid uniqueidentifier not null, + user_uid uniqueidentifier not null, + access_level integer, + constraint ck_bsite_user_c_access_level check ( access_level in (0,1,2)), + constraint pk_bsite_user_c primary key (site_uid,user_uid) +); + +create table bsite_user_d ( + site_id uniqueidentifier not null, + user_id uniqueidentifier not null, + access_level integer, + version numeric(19) not null, + constraint ck_bsite_user_d_access_level check ( access_level in (0,1,2)) +); + +create table bsite_user_e ( + site_id uniqueidentifier not null, + user_id uniqueidentifier not null, + access_level integer, + constraint ck_bsite_user_e_access_level check ( access_level in (0,1,2)) +); + +create table buser ( + id uniqueidentifier not null, + name nvarchar(255), + constraint pk_buser primary key (id) +); + +create table bwith_qident ( + id integer not null, + [Name] nvarchar(191), + [CODE] nvarchar(255), + last_updated datetime2 not null, + constraint pk_bwith_qident primary key (id) +); +create unique nonclustered index uq_bwith_qident_name on bwith_qident([Name]) where [Name] is not null; +create sequence bwith_qident_seq as bigint start with 1 increment by 50; + +create table basic_draftable_bean ( + id numeric(19) not null, + name nvarchar(255), + version numeric(19) not null, + when_created datetime2 not null, + when_modified datetime2 not null, + constraint pk_basic_draftable_bean primary key (id) +); +create sequence basic_draftable_bean_seq as bigint start with 1 increment by 50; + +create table basic_draftable_bean_draft ( + id numeric(19) not null, + name nvarchar(255), + version numeric(19) not null, + when_created datetime2 not null, + when_modified datetime2 not null, + constraint pk_basic_draftable_bean_draft primary key (id) +); +create sequence basic_draftable_bean_draft_seq as bigint start with 1 increment by 50; + +create table basic_joda_entity ( + id numeric(19) not null, + name nvarchar(255), + period nvarchar(50), + local_date date, + created datetime2 not null, + updated datetime2 not null, + version datetime2 not null, + constraint pk_basic_joda_entity primary key (id) +); +create sequence basic_joda_entity_seq as bigint start with 1 increment by 50; + +create table bean_with_time_zone ( + id numeric(19) not null, + name nvarchar(255), + timezone nvarchar(20), + constraint pk_bean_with_time_zone primary key (id) +); +create sequence bean_with_time_zone_seq as bigint start with 1 increment by 50; + +create table drel_booking ( + id numeric(19) not null, + booking_uid numeric(19), + agent_invoice numeric(19), + client_invoice numeric(19), + version integer not null, + constraint pk_drel_booking primary key (id) +); +create unique nonclustered index uq_drel_booking_booking_uid on drel_booking(booking_uid) where booking_uid is not null; +create unique nonclustered index uq_drel_booking_agent_invoice on drel_booking(agent_invoice) where agent_invoice is not null; +create unique nonclustered index uq_drel_booking_client_invoice on drel_booking(client_invoice) where client_invoice is not null; +create sequence drel_booking_seq as bigint start with 1 increment by 50; + +create table bw_bean ( + id numeric(19) not null, + name nvarchar(255), + flags integer not null, + version numeric(19) not null, + constraint pk_bw_bean primary key (id) +); +create sequence bw_bean_seq as bigint start with 1 increment by 50; + +create table cepcategory ( + id numeric(19) not null, + name nvarchar(255), + version numeric(19) not null, + constraint pk_cepcategory primary key (id) +); +create sequence cepcategory_seq as bigint start with 1 increment by 50; + +create table cepproduct ( + id numeric(19) not null, + name nvarchar(255), + version numeric(19) not null, + constraint pk_cepproduct primary key (id) +); +create sequence cepproduct_seq as bigint start with 1 increment by 50; + +create table cepproduct_category ( + customer_id numeric(19) not null, + address_id numeric(19) not null, + category_id numeric(19) not null, + product_id numeric(19) not null, + priority integer +); + +create table cinh_ref ( + id integer not null, + ref_id integer, + cretime datetime2 not null, + updtime datetime2 not null, + version numeric(19) not null, + constraint pk_cinh_ref primary key (id) +); +create sequence cinh_ref_seq as bigint start with 1 increment by 50; + +create table cinh_root ( + dtype nvarchar(3) not null, + id integer not null, + license_number nvarchar(255), + cretime datetime2 not null, + updtime datetime2 not null, + version numeric(19) not null, + driver nvarchar(255), + notes nvarchar(255), + action nvarchar(255), + constraint pk_cinh_root primary key (id) +); +create sequence cinh_root_seq as bigint start with 1 increment by 50; + +create table ckey_assoc ( + id integer not null, + assoc_one nvarchar(255), + constraint pk_ckey_assoc primary key (id) +); +create sequence ckey_assoc_seq as bigint start with 1 increment by 50; + +create table ckey_detail ( + id integer not null, + something nvarchar(255), + one_key integer, + two_key nvarchar(127), + constraint pk_ckey_detail primary key (id) +); +create sequence ckey_detail_seq as bigint start with 1 increment by 50; + +create table ckey_parent ( + one_key integer not null, + two_key nvarchar(127) not null, + name nvarchar(255), + assoc_id integer, + version integer not null, + constraint pk_ckey_parent primary key (one_key,two_key) +); + +create table coone ( + id numeric(19) not null, + name nvarchar(255), + constraint pk_coone primary key (id) +); +create sequence coone_seq as bigint start with 1 increment by 50; + +create table coone_many ( + id numeric(19) not null, + coone_id numeric(19) not null, + name nvarchar(255), + deleted integer default 0 not null, + constraint pk_coone_many primary key (id) +); +create sequence coone_many_seq as bigint start with 1 increment by 50; + +create table coroot ( + id numeric(19) not null, + name nvarchar(255), + one_id numeric(19), + constraint pk_coroot primary key (id) +); +create unique nonclustered index uq_coroot_one_id on coroot(one_id) where one_id is not null; +create sequence coroot_seq as bigint start with 1 increment by 50; + +create table calculation_result ( + id integer not null, + charge float(32) not null, + product_configuration_id integer, + group_configuration_id integer, + constraint pk_calculation_result primary key (id) +); +create sequence calculation_result_seq as bigint start with 1 increment by 50; + +create table cao_bean ( + x_cust_id integer not null, + x_type_id integer not null, + description nvarchar(255), + version numeric(19) not null, + constraint pk_cao_bean primary key (x_cust_id,x_type_id) +); + +create table sp_car_car ( + id numeric(19) not null, + name nvarchar(255), + version integer not null, + constraint pk_sp_car_car primary key (id) +); +create sequence sp_car_car_seq as bigint start with 1 increment by 50; + +create table sp_car_car_wheels ( + car numeric(19) not null, + wheel numeric(19) not null, + constraint pk_sp_car_car_wheels primary key (car,wheel) +); + +create table sp_car_car_doors ( + car numeric(19) not null, + door numeric(19) not null, + constraint pk_sp_car_car_doors primary key (car,door) +); + +create table sa_car ( + id numeric(19) not null, + brand nvarchar(255), + sold integer not null, + version integer not null, + constraint pk_sa_car primary key (id) +); +create sequence sa_car_seq as bigint start with 1 increment by 50; + +create table car_accessory ( + id integer not null, + name nvarchar(255), + fuse_id numeric(19) not null, + car_id integer, + cretime datetime2 not null, + updtime datetime2 not null, + version numeric(19) not null, + constraint pk_car_accessory primary key (id) +); +create sequence car_accessory_seq as bigint start with 1 increment by 50; + +create table car_fuse ( + id numeric(19) not null, + location_code nvarchar(255), + constraint pk_car_fuse primary key (id) +); +create sequence car_fuse_seq as bigint start with 1 increment by 50; + +create table category ( + id numeric(19) not null, + name nvarchar(255), + surveyobjectid numeric(19), + sequence_number integer not null, + constraint pk_category primary key (id) +); +create sequence category_seq as bigint start with 1 increment by 50; + +create table e_save_test_d ( + id numeric(19) not null, + parent_id numeric(19), + test_property integer default 0 not null, + version numeric(19) not null, + constraint pk_e_save_test_d primary key (id) +); +create unique nonclustered index uq_e_save_test_d_parent_id on e_save_test_d(parent_id) where parent_id is not null; +create sequence e_save_test_d_seq as bigint start with 1 increment by 50; + +create table child_person ( + identifier integer not null, + name nvarchar(255), + age integer, + some_bean_id integer, + parent_identifier integer, + family_name nvarchar(255), + address nvarchar(255), + constraint pk_child_person primary key (identifier) +); +create sequence child_person_seq as bigint start with 1 increment by 50; + +create table cke_client ( + cod_cpny integer not null, + cod_client nvarchar(100) not null, + username nvarchar(100) not null, + notes nvarchar(255), + constraint pk_cke_client primary key (cod_cpny,cod_client) +); + +create table cke_user ( + username nvarchar(100) not null, + cod_cpny integer not null, + name nvarchar(255), + constraint pk_cke_user primary key (username,cod_cpny) +); + +create table class_super ( + dtype nvarchar(31) not null, + sid numeric(19) not null, + constraint pk_class_super primary key (sid) +); +create sequence class_super_seq as bigint start with 1 increment by 50; + +create table class_super_monkey ( + class_super_sid numeric(19) not null, + monkey_mid numeric(19) not null, + constraint uq_class_super_monkey_mid unique (monkey_mid), + constraint pk_class_super_monkey primary key (class_super_sid,monkey_mid) +); + +create table configuration ( + type nvarchar(21) not null, + id integer not null, + name nvarchar(255), + configurations_id integer, + group_name nvarchar(255), + product_name nvarchar(255), + constraint pk_configuration primary key (id) +); +create sequence configuration_seq as bigint start with 1 increment by 50; + +create table configurations ( + id integer not null, + name nvarchar(255), + constraint pk_configurations primary key (id) +); +create sequence configurations_seq as bigint start with 1 increment by 50; + +create table contact ( + id integer not null, + first_name nvarchar(127), + last_name nvarchar(127), + phone nvarchar(255), + mobile nvarchar(255), + email nvarchar(255), + is_member integer default 0 not null, + customer_id integer not null, + group_id integer, + cretime datetime2 not null, + updtime datetime2 not null, + constraint pk_contact primary key (id) +); +create sequence contact_seq as bigint start with 1 increment by 50; + +create table contact_group ( + id integer not null, + name nvarchar(255), + cretime datetime2 not null, + updtime datetime2 not null, + version numeric(19) not null, + constraint pk_contact_group primary key (id) +); +create sequence contact_group_seq as bigint start with 1 increment by 50; + +create table contact_note ( + id integer not null, + contact_id integer, + title nvarchar(255), + note nvarchar(max), + cretime datetime2 not null, + updtime datetime2 not null, + version numeric(19) not null, + constraint pk_contact_note primary key (id) +); +create sequence contact_note_seq as bigint start with 1 increment by 50; + +create table contract ( + id numeric(19) not null, + name nvarchar(255), + constraint pk_contract primary key (id) +); +create sequence contract_seq as bigint start with 1 increment by 50; + +create table contract_costs ( + id numeric(19) not null, + status nvarchar(255), + position_id numeric(19) not null, + constraint pk_contract_costs primary key (id) +); +create sequence contract_costs_seq as bigint start with 1 increment by 50; + +create table c_conversation ( + id numeric(19) not null, + title nvarchar(255), + isopen integer default 0 not null, + group_id numeric(19), + version numeric(19) not null, + when_created datetime2 not null, + when_modified datetime2 not null, + constraint pk_c_conversation primary key (id) +); +create sequence c_conversation_seq as bigint start with 1 increment by 50; + +create table o_country ( + code nvarchar(2) not null, + name nvarchar(60), + constraint pk_o_country primary key (code) +); + +create table cover ( + id numeric(19) not null, + s3_url nvarchar(255), + deleted integer default 0 not null, + constraint pk_cover primary key (id) +); +create sequence cover_seq as bigint start with 1 increment by 50; + +create table o_customer ( + id integer not null, + status nvarchar(1), + name nvarchar(40) not null, + smallnote nvarchar(100), + anniversary date, + billing_address_id integer, + shipping_address_id integer, + cretime datetime2 not null, + updtime datetime2 not null, + version numeric(19) not null, + constraint ck_o_customer_status check ( status in ('N','A','I')), + constraint pk_o_customer primary key (id) +); +create sequence o_customer_seq as bigint start with 1 increment by 50; + +create table dcredit ( + id numeric(19) not null, + credit nvarchar(255), + constraint pk_dcredit primary key (id) +); +create sequence dcredit_seq as bigint start with 1 increment by 50; + +create table dcredit_drol ( + dcredit_id numeric(19) not null, + drol_id numeric(19) not null, + constraint pk_dcredit_drol primary key (dcredit_id,drol_id) +); + +create table dexh_entity ( + oid numeric(19) not null, + exhange nvarchar(255), + an_enum_type nvarchar(255), + last_updated datetime2 not null, + constraint pk_dexh_entity primary key (oid) +); +create sequence dexh_entity_seq as bigint start with 1 increment by 50; + +create table dint_parent ( + type integer not null, + id numeric(19) not null, + val integer, + more nvarchar(255), + constraint pk_dint_parent primary key (id) +); +create sequence dint_parent_seq as bigint start with 1 increment by 50; + +create table dmachine ( + id numeric(19) not null, + name nvarchar(255), + organisation_id numeric(19), + version numeric(19) not null, + constraint pk_dmachine primary key (id) +); +create sequence dmachine_seq as bigint start with 1 increment by 50; + +create table d_machine_aux_use ( + id numeric(19) not null, + machine_id numeric(19) not null, + name nvarchar(255), + edate date, + use_secs numeric(19) not null, + fuel numeric(28), + version numeric(19) not null, + constraint pk_d_machine_aux_use primary key (id) +); +create sequence d_machine_aux_use_seq as bigint start with 1 increment by 50; + +create table d_machine_stats ( + id numeric(19) not null, + machine_id numeric(19) not null, + edate date, + total_kms numeric(19) not null, + hours numeric(19) not null, + rate numeric(28), + cost numeric(28), + version numeric(19) not null, + constraint pk_d_machine_stats primary key (id) +); +create sequence d_machine_stats_seq as bigint start with 1 increment by 50; + +create table d_machine_use ( + id numeric(19) not null, + machine_id numeric(19) not null, + edate date, + distance_kms numeric(19) not null, + time_secs numeric(19) not null, + fuel numeric(28), + version numeric(19) not null, + constraint pk_d_machine_use primary key (id) +); +create sequence d_machine_use_seq as bigint start with 1 increment by 50; + +create table dorg ( + id numeric(19) not null, + name nvarchar(255), + version numeric(19) not null, + constraint pk_dorg primary key (id) +); +create sequence dorg_seq as bigint start with 1 increment by 50; + +create table dperson ( + id numeric(19) not null, + first_name nvarchar(255), + last_name nvarchar(255), + salary numeric(28), + constraint pk_dperson primary key (id) +); +create sequence dperson_seq as bigint start with 1 increment by 50; + +create table drol ( + id numeric(19) not null, + name nvarchar(255), + constraint pk_drol primary key (id) +); +create sequence drol_seq as bigint start with 1 increment by 50; + +create table drot ( + id numeric(19) not null, + name nvarchar(255), + constraint pk_drot primary key (id) +); +create sequence drot_seq as bigint start with 1 increment by 50; + +create table drot_drol ( + drot_id numeric(19) not null, + drol_id numeric(19) not null, + constraint pk_drot_drol primary key (drot_id,drol_id) +); + +create table rawinherit_data ( + id numeric(19) not null, + val integer, + constraint pk_rawinherit_data primary key (id) +); +create sequence rawinherit_data_seq as bigint start with 1 increment by 50; + +create table data_container ( + id uniqueidentifier not null, + content nvarchar(255), + constraint pk_data_container primary key (id) +); + +create table dc_detail ( + id numeric(19) not null, + master_id numeric(19), + description nvarchar(255), + version numeric(19) not null, + constraint pk_dc_detail primary key (id) +); +create sequence dc_detail_seq as bigint start with 1 increment by 50; + +create table dc_master ( + id numeric(19) not null, + name nvarchar(255), + version numeric(19) not null, + constraint pk_dc_master primary key (id) +); +create sequence dc_master_seq as bigint start with 1 increment by 50; + +create table dfk_cascade ( + id numeric(19) not null, + name nvarchar(255), + one_id numeric(19), + constraint pk_dfk_cascade primary key (id) +); +create sequence dfk_cascade_seq as bigint start with 1 increment by 50; + +create table dfk_cascade_one ( + id numeric(19) not null, + name nvarchar(255), + constraint pk_dfk_cascade_one primary key (id) +); +create sequence dfk_cascade_one_seq as bigint start with 1 increment by 50; + +create table dfk_none ( + id numeric(19) not null, + name nvarchar(255), + one_id numeric(19), + constraint pk_dfk_none primary key (id) +); +create sequence dfk_none_seq as bigint start with 1 increment by 50; + +create table dfk_none_via_join ( + id numeric(19) not null, + name nvarchar(255), + one_id numeric(19), + constraint pk_dfk_none_via_join primary key (id) +); +create sequence dfk_none_via_join_seq as bigint start with 1 increment by 50; + +create table dfk_none_via_mto_m ( + id numeric(19) not null, + name nvarchar(255), + constraint pk_dfk_none_via_mto_m primary key (id) +); +create sequence dfk_none_via_mto_m_seq as bigint start with 1 increment by 50; + +create table dfk_none_via_mto_m_dfk_one ( + dfk_none_via_mto_m_id numeric(19) not null, + dfk_one_id numeric(19) not null, + constraint pk_dfk_none_via_mto_m_dfk_one primary key (dfk_none_via_mto_m_id,dfk_one_id) +); + +create table dfk_one ( + id numeric(19) not null, + name nvarchar(255), + constraint pk_dfk_one primary key (id) +); +create sequence dfk_one_seq as bigint start with 1 increment by 50; + +create table dfk_set_null ( + id numeric(19) not null, + name nvarchar(255), + one_id numeric(19), + constraint pk_dfk_set_null primary key (id) +); +create sequence dfk_set_null_seq as bigint start with 1 increment by 50; + +create table doc ( + id numeric(19) not null, + name nvarchar(255), + version numeric(19) not null, + when_created datetime2 not null, + when_modified datetime2 not null, + constraint pk_doc primary key (id) +); +create sequence doc_seq as bigint start with 1 increment by 50; + +create table doc_link ( + doc_id numeric(19) not null, + link_id numeric(19) not null, + constraint pk_doc_link primary key (doc_id,link_id) +); + +create table doc_link_draft ( + doc_id numeric(19) not null, + link_id numeric(19) not null, + constraint pk_doc_link_draft primary key (doc_id,link_id) +); + +create table doc_draft ( + id numeric(19) not null, + name nvarchar(255), + version numeric(19) not null, + when_created datetime2 not null, + when_modified datetime2 not null, + constraint pk_doc_draft primary key (id) +); +create sequence doc_draft_seq as bigint start with 1 increment by 50; + +create table document ( + id numeric(19) not null, + title nvarchar(127), + body nvarchar(255), + organisation_id numeric(19), + version numeric(19) not null, + when_created datetime2 not null, + when_modified datetime2 not null, + constraint pk_document primary key (id) +); +create unique nonclustered index uq_document_title on document(title) where title is not null; +create sequence document_seq as bigint start with 1 increment by 50; + +create table document_draft ( + id numeric(19) not null, + title nvarchar(127), + body nvarchar(255), + when_publish datetime2, + organisation_id numeric(19), + version numeric(19) not null, + when_created datetime2 not null, + when_modified datetime2 not null, + constraint pk_document_draft primary key (id) +); +create unique nonclustered index uq_document_draft_title on document_draft(title) where title is not null; +create sequence document_draft_seq as bigint start with 1 increment by 50; + +create table document_media ( + id numeric(19) not null, + document_id numeric(19), + name nvarchar(255), + description nvarchar(255), + version numeric(19) not null, + when_created datetime2 not null, + when_modified datetime2 not null, + constraint pk_document_media primary key (id) +); +create sequence document_media_seq as bigint start with 1 increment by 50; + +create table document_media_draft ( + id numeric(19) not null, + document_id numeric(19), + name nvarchar(255), + description nvarchar(255), + version numeric(19) not null, + when_created datetime2 not null, + when_modified datetime2 not null, + constraint pk_document_media_draft primary key (id) +); +create sequence document_media_draft_seq as bigint start with 1 increment by 50; + +create table sp_car_door ( + id numeric(19) not null, + name nvarchar(255), + version integer not null, + constraint pk_sp_car_door primary key (id) +); +create sequence sp_car_door_seq as bigint start with 1 increment by 50; + +create table earray_bean ( + id numeric(19) not null, + foo integer, + name nvarchar(255), + phone_numbers varchar(300), + uids varchar(1000) not null, + other_ids varchar(1000), + doubs varchar(1000), + statuses varchar(1000), + vc_enums varchar(1000), + int_enums varchar(1000), + status2 varchar(1000), + version numeric(19) not null, + constraint ck_earray_bean_foo check ( foo in (100,101,102)), + constraint pk_earray_bean primary key (id) +); +create sequence earray_bean_seq as bigint start with 1 increment by 50; + +create table earray_set_bean ( + id numeric(19) not null, + name nvarchar(255), + phone_numbers varchar(300), + uids varchar(1000), + other_ids varchar(1000), + doubs varchar(1000), + version numeric(19) not null, + constraint pk_earray_set_bean primary key (id) +); +create sequence earray_set_bean_seq as bigint start with 1 increment by 50; + +create table e_basic ( + id integer not null, + status nvarchar(1), + name nvarchar(127), + description nvarchar(255), + some_date datetime2, + constraint ck_e_basic_status check ( status in ('N','A','I')), + constraint pk_e_basic primary key (id) +); +create sequence e_basic_seq as bigint start with 1 increment by 50; + +create table ebasic_change_log ( + id numeric(19) not null, + name nvarchar(20), + short_description nvarchar(50), + long_description nvarchar(100), + who_created nvarchar(255) not null, + who_modified nvarchar(255) not null, + when_created datetime2 not null, + when_modified datetime2 not null, + version numeric(19) not null, + constraint pk_ebasic_change_log primary key (id) +); +create sequence ebasic_change_log_seq as bigint start with 1 increment by 50; + +create table ebasic_clob ( + id numeric(19) not null, + name nvarchar(255), + title nvarchar(255), + description nvarchar(max), + last_update datetime2 not null, + constraint pk_ebasic_clob primary key (id) +); +create sequence ebasic_clob_seq as bigint start with 1 increment by 50; + +create table ebasic_clob_fetch_eager ( + id numeric(19) not null, + name nvarchar(255), + title nvarchar(255), + description nvarchar(max), + last_update datetime2 not null, + constraint pk_ebasic_clob_fetch_eager primary key (id) +); +create sequence ebasic_clob_fetch_eager_seq as bigint start with 1 increment by 50; + +create table ebasic_clob_no_ver ( + id numeric(19) not null, + name nvarchar(255), + description nvarchar(max), + constraint pk_ebasic_clob_no_ver primary key (id) +); +create sequence ebasic_clob_no_ver_seq as bigint start with 1 increment by 50; + +create table e_basicenc ( + id integer not null, + name nvarchar(255), + description varbinary(80), + dob varbinary(20), + status varbinary(20), + last_update datetime2, + constraint pk_e_basicenc primary key (id) +); +create sequence e_basicenc_seq as bigint start with 1 increment by 50; + +create table e_basicenc_bin ( + id integer not null, + name nvarchar(255), + description nvarchar(255), + data image, + some_time varbinary(255), + last_update datetime2 not null, + constraint pk_e_basicenc_bin primary key (id) +); +create sequence e_basicenc_bin_seq as bigint start with 1 increment by 50; + +create table e_basicenc_client ( + id numeric(19) not null, + name nvarchar(255), + description varbinary(80), + dob varbinary(20), + status varbinary(20), + version numeric(19) not null, + constraint pk_e_basicenc_client primary key (id) +); +create sequence e_basicenc_client_seq as bigint start with 1 increment by 50; + +create table e_basicenc_relate ( + id numeric(19) not null, + name nvarchar(255), + other_id integer, + constraint pk_e_basicenc_relate primary key (id) +); +create sequence e_basicenc_relate_seq as bigint start with 1 increment by 50; + +create table e_basic_enum_id ( + status nvarchar(1) not null, + name nvarchar(255), + description nvarchar(255), + constraint ck_e_basic_enum_id_status check ( status in ('N','A','I')), + constraint pk_e_basic_enum_id primary key (status) +); + +create table e_basic_eni ( + id integer not null, + status integer, + name nvarchar(255), + description nvarchar(255), + some_date datetime2, + constraint ck_e_basic_eni_status check ( status in (1,2,3)), + constraint pk_e_basic_eni primary key (id) +); +create sequence e_basic_eni_seq as bigint start with 1 increment by 50; + +create table ebasic_hstore ( + id numeric(19) not null, + name nvarchar(255), + map nvarchar(800), + version numeric(19) not null, + constraint pk_ebasic_hstore primary key (id) +); +create sequence ebasic_hstore_seq as bigint start with 1 increment by 50; + +create table ebasic_json_jackson ( + id numeric(19) not null, + name nvarchar(255), + value_set nvarchar(700), + value_list nvarchar(max), + value_map nvarchar(700), + plain_value nvarchar(500), + version numeric(19) not null, + constraint pk_ebasic_json_jackson primary key (id) +); +create sequence ebasic_json_jackson_seq as bigint start with 1 increment by 50; + +create table ebasic_json_jackson2 ( + id numeric(19) not null, + name nvarchar(255), + value_set nvarchar(700), + value_list nvarchar(max), + value_map nvarchar(700), + plain_value nvarchar(500), + version numeric(19) not null, + constraint pk_ebasic_json_jackson2 primary key (id) +); +create sequence ebasic_json_jackson2_seq as bigint start with 1 increment by 50; + +create table ebasic_json_list ( + id numeric(19) not null, + name nvarchar(255), + bean_set nvarchar(700), + bean_list nvarchar(max), + bean_map nvarchar(700), + plain_bean nvarchar(500), + flags nvarchar(50), + tags nvarchar(100), + version numeric(19) not null, + constraint pk_ebasic_json_list primary key (id) +); +create sequence ebasic_json_list_seq as bigint start with 1 increment by 50; + +create table ebasic_json_map ( + id numeric(19) not null, + name nvarchar(255), + content nvarchar(max), + version numeric(19) not null, + constraint pk_ebasic_json_map primary key (id) +); +create sequence ebasic_json_map_seq as bigint start with 1 increment by 50; + +create table ebasic_json_map_blob ( + id numeric(19) not null, + name nvarchar(255), + content image, + version numeric(19) not null, + constraint pk_ebasic_json_map_blob primary key (id) +); +create sequence ebasic_json_map_blob_seq as bigint start with 1 increment by 50; + +create table ebasic_json_map_clob ( + id numeric(19) not null, + name nvarchar(255), + content nvarchar(max), + version numeric(19) not null, + constraint pk_ebasic_json_map_clob primary key (id) +); +create sequence ebasic_json_map_clob_seq as bigint start with 1 increment by 50; + +create table ebasic_json_map_detail ( + id numeric(19) not null, + owner_id numeric(19), + name nvarchar(255), + content nvarchar(max), + version numeric(19) not null, + constraint pk_ebasic_json_map_detail primary key (id) +); +create sequence ebasic_json_map_detail_seq as bigint start with 1 increment by 50; + +create table ebasic_json_map_json_b ( + id numeric(19) not null, + name nvarchar(255), + content nvarchar(max), + version numeric(19) not null, + constraint pk_ebasic_json_map_json_b primary key (id) +); +create sequence ebasic_json_map_json_b_seq as bigint start with 1 increment by 50; + +create table ebasic_json_map_varchar ( + id numeric(19) not null, + name nvarchar(255), + content nvarchar(3000), + version numeric(19) not null, + constraint pk_ebasic_json_map_varchar primary key (id) +); +create sequence ebasic_json_map_varchar_seq as bigint start with 1 increment by 50; + +create table ebasic_json_node ( + id numeric(19) not null, + name nvarchar(255), + content nvarchar(max), + version numeric(19) not null, + constraint pk_ebasic_json_node primary key (id) +); +create sequence ebasic_json_node_seq as bigint start with 1 increment by 50; + +create table ebasic_json_node_blob ( + id numeric(19) not null, + name nvarchar(255), + content image, + version numeric(19) not null, + constraint pk_ebasic_json_node_blob primary key (id) +); +create sequence ebasic_json_node_blob_seq as bigint start with 1 increment by 50; + +create table ebasic_json_node_json_b ( + id numeric(19) not null, + name nvarchar(255), + content nvarchar(max), + version numeric(19) not null, + constraint pk_ebasic_json_node_json_b primary key (id) +); +create sequence ebasic_json_node_json_b_seq as bigint start with 1 increment by 50; + +create table ebasic_json_node_varchar ( + id numeric(19) not null, + name nvarchar(255), + content nvarchar(1000), + version numeric(19) not null, + constraint pk_ebasic_json_node_varchar primary key (id) +); +create sequence ebasic_json_node_varchar_seq as bigint start with 1 increment by 50; + +create table ebasic_json_unmapped ( + id numeric(19) not null, + name nvarchar(255), + version numeric(19) not null, + constraint pk_ebasic_json_unmapped primary key (id) +); +create sequence ebasic_json_unmapped_seq as bigint start with 1 increment by 50; + +create table e_basic_ndc ( + id integer not null, + name nvarchar(255), + constraint pk_e_basic_ndc primary key (id) +); +create sequence e_basic_ndc_seq as bigint start with 1 increment by 50; + +create table ebasic_no_sdchild ( + id numeric(19) not null, + owner_id numeric(19) not null, + child_name nvarchar(255), + amount numeric(19) not null, + version numeric(19) not null, + constraint pk_ebasic_no_sdchild primary key (id) +); +create sequence ebasic_no_sdchild_seq as bigint start with 1 increment by 50; + +create table ebasic_sdchild ( + id numeric(19) not null, + owner_id numeric(19) not null, + child_name nvarchar(255), + amount numeric(19) not null, + version numeric(19) not null, + deleted integer default 0 not null, + constraint pk_ebasic_sdchild primary key (id) +); +create sequence ebasic_sdchild_seq as bigint start with 1 increment by 50; + +create table ebasic_soft_delete ( + id numeric(19) not null, + name nvarchar(255), + description nvarchar(255), + version numeric(19) not null, + deleted integer default 0 not null, + constraint pk_ebasic_soft_delete primary key (id) +); +create sequence ebasic_soft_delete_seq as bigint start with 1 increment by 50; + +create table e_basicver ( + id integer not null, + name nvarchar(255), + description nvarchar(255), + other nvarchar(255), + last_update datetime2 not null, + constraint pk_e_basicver primary key (id) +); +create sequence e_basicver_seq as bigint start with 1 increment by 50; + +create table e_basic_withlife ( + id numeric(19) not null, + name nvarchar(255), + other nvarchar(255), + deleted integer default 0 not null, + version numeric(19) not null, + constraint pk_e_basic_withlife primary key (id) +); +create sequence e_basic_withlife_seq as bigint start with 1 increment by 50; + +create table e_basic_with_ex ( + id numeric(19) not null, + deleted integer default 0 not null, + version numeric(19) not null, + constraint pk_e_basic_with_ex primary key (id) +); +create sequence e_basic_with_ex_seq as bigint start with 1 increment by 50; + +create table e_basicverucon ( + id integer not null, + name nvarchar(127), + other nvarchar(127), + other_one nvarchar(127), + description nvarchar(255), + last_update datetime2 not null, + constraint pk_e_basicverucon primary key (id) +); +create unique nonclustered index uq_e_basicverucon_name on e_basicverucon(name) where name is not null; +create unique nonclustered index uq_e_basicverucon_other_other_one on e_basicverucon(other,other_one) where other is not null and other_one is not null; +create sequence e_basicverucon_seq as bigint start with 1 increment by 50; + +create table ecache_child ( + id uniqueidentifier not null, + name nvarchar(100), + root_id uniqueidentifier not null, + constraint pk_ecache_child primary key (id) +); + +create table ecache_root ( + id uniqueidentifier not null, + name nvarchar(100), + constraint pk_ecache_root primary key (id) +); + +create table e_col_ab ( + id numeric(19) not null, + column_a nvarchar(255), + column_b nvarchar(255), + constraint pk_e_col_ab primary key (id) +); +create sequence e_col_ab_seq as bigint start with 1 increment by 50; + +create table ecustom_id ( + id nvarchar(127) not null, + name nvarchar(255), + constraint pk_ecustom_id primary key (id) +); + +create table edefault_prop ( + id integer not null, + e_simple_usertypeid integer, + name nvarchar(255), + constraint pk_edefault_prop primary key (id) +); +create unique nonclustered index uq_edefault_prop_e_simple_usertypeid on edefault_prop(e_simple_usertypeid) where e_simple_usertypeid is not null; +create sequence edefault_prop_seq as bigint start with 1 increment by 50; + +create table eemb_inner ( + id integer not null, + nome_inner nvarchar(255), + outer_id integer, + update_count integer not null, + constraint pk_eemb_inner primary key (id) +); +create sequence eemb_inner_seq as bigint start with 1 increment by 50; + +create table eemb_outer ( + id integer not null, + nome_outer nvarchar(255), + date1 datetime2, + date2 datetime2, + update_count integer not null, + constraint pk_eemb_outer primary key (id) +); +create sequence eemb_outer_seq as bigint start with 1 increment by 50; + +create table efile2_no_fk ( + file_name nvarchar(64) not null, + owner_id integer not null, + constraint pk_efile2_no_fk primary key (file_name) +); + +create table efile_no_fk ( + file_name nvarchar(64) not null, + owner_user_id integer, + owner_soft_del_user_id integer, + constraint pk_efile_no_fk primary key (file_name) +); + +create table efile_no_fk_euser_no_fk ( + efile_no_fk_file_name nvarchar(64) not null, + euser_no_fk_user_id integer not null, + constraint pk_efile_no_fk_euser_no_fk primary key (efile_no_fk_file_name,euser_no_fk_user_id) +); + +create table efile_no_fk_euser_no_fk_soft_del ( + efile_no_fk_file_name nvarchar(64) not null, + euser_no_fk_soft_del_user_id integer not null, + constraint pk_efile_no_fk_euser_no_fk_soft_del primary key (efile_no_fk_file_name,euser_no_fk_soft_del_user_id) +); + +create table egen_props ( + id numeric(19) not null, + name nvarchar(255), + version numeric(19) not null, + when_created datetime2 not null, + when_modified datetime2 not null, + ts_created datetime2 not null, + ts_updated datetime2 not null, + ldt_created datetime2 not null, + ldt_updated datetime2 not null, + odt_created datetime2 not null, + odt_updated datetime2 not null, + zdt_created datetime2 not null, + zdt_updated datetime2 not null, + instant_created datetime2 not null, + instant_updated datetime2 not null, + long_created numeric(19) not null, + long_updated numeric(19) not null, + constraint pk_egen_props primary key (id) +); +create sequence egen_props_seq as bigint start with 1 increment by 50; + +create table eid_uid_bean ( + id numeric(19) not null, + uuid uniqueidentifier not null, + name nvarchar(255), + constraint uq_eid_uid_bean_uuid unique (uuid), + constraint pk_eid_uid_bean primary key (id) +); +create sequence eid_uid_bean_seq as bigint start with 1 increment by 50; + +create table einvoice ( + id numeric(19) not null, + invoice_date datetime2, + state integer, + person_id numeric(19), + ship_street nvarchar(255), + ship_suburb nvarchar(255), + ship_city nvarchar(255), + ship_status nvarchar(3), + bill_street nvarchar(255), + bill_suburb nvarchar(255), + bill_city nvarchar(255), + bill_status nvarchar(3), + version numeric(19) not null, + constraint ck_einvoice_state check ( state in (0,1,2)), + constraint ck_einvoice_ship_status check ( ship_status in ('ONE','TWO')), + constraint ck_einvoice_bill_status check ( bill_status in ('ONE','TWO')), + constraint pk_einvoice primary key (id) +); +create sequence einvoice_seq as bigint start with 1 increment by 50; + +create table e_main ( + id integer not null, + name nvarchar(255), + description nvarchar(255), + version numeric(19) not null, + constraint pk_e_main primary key (id) +); +create sequence e_main_seq as bigint start with 1 increment by 50; + +create table enull_collection ( + id integer not null, + name nvarchar(255), + constraint pk_enull_collection primary key (id) +); +create sequence enull_collection_seq as bigint start with 1 increment by 50; + +create table enull_collection_detail ( + id integer not null, + enull_collection_id integer not null, + something nvarchar(255), + constraint pk_enull_collection_detail primary key (id) +); +create sequence enull_collection_detail_seq as bigint start with 1 increment by 50; + +create table eopt_one_a ( + id integer not null, + name_for_a nvarchar(255), + b_id integer, + cretime datetime2 not null, + updtime datetime2 not null, + version numeric(19) not null, + constraint pk_eopt_one_a primary key (id) +); +create sequence eopt_one_a_seq as bigint start with 1 increment by 50; + +create table eopt_one_b ( + id integer not null, + name_for_b nvarchar(255), + c_id integer not null, + cretime datetime2 not null, + updtime datetime2 not null, + version numeric(19) not null, + constraint pk_eopt_one_b primary key (id) +); +create sequence eopt_one_b_seq as bigint start with 1 increment by 50; + +create table eopt_one_c ( + id integer not null, + name_for_c nvarchar(255), + cretime datetime2 not null, + updtime datetime2 not null, + version numeric(19) not null, + constraint pk_eopt_one_c primary key (id) +); +create sequence eopt_one_c_seq as bigint start with 1 increment by 50; + +create table eper_addr ( + id numeric(19) not null, + name nvarchar(255), + ma_street nvarchar(255), + ma_suburb nvarchar(255), + ma_city nvarchar(255), + ma_country_code nvarchar(2), + version numeric(19) not null, + constraint pk_eper_addr primary key (id) +); +create sequence eper_addr_seq as bigint start with 1 increment by 50; + +create table eperson ( + id numeric(19) not null, + name nvarchar(255), + notes nvarchar(255), + street nvarchar(255), + suburb nvarchar(255), + addr_city nvarchar(255), + addr_status nvarchar(3), + version numeric(19) not null, + constraint ck_eperson_addr_status check ( addr_status in ('ONE','TWO')), + constraint pk_eperson primary key (id) +); +create sequence eperson_seq as bigint start with 1 increment by 50; + +create table e_person_online ( + id numeric(19) not null, + email nvarchar(127), + online_status integer default 0 not null, + when_updated datetime2 not null, + constraint pk_e_person_online primary key (id) +); +create unique nonclustered index uq_e_person_online_email on e_person_online(email) where email is not null; +create sequence e_person_online_seq as bigint start with 1 increment by 50; + +create table esimple ( + usertypeid integer identity(1,1) not null, + name nvarchar(255), + constraint pk_esimple primary key (usertypeid) +); + +create table esoft_del_book ( + id numeric(19) not null, + book_title nvarchar(255), + lend_by_id numeric(19), + version numeric(19) not null, + deleted integer default 0 not null, + constraint pk_esoft_del_book primary key (id) +); +create sequence esoft_del_book_seq as bigint start with 1 increment by 50; + +create table esoft_del_book_esoft_del_user ( + esoft_del_book_id numeric(19) not null, + esoft_del_user_id numeric(19) not null, + constraint pk_esoft_del_book_esoft_del_user primary key (esoft_del_book_id,esoft_del_user_id) +); + +create table esoft_del_down ( + id numeric(19) not null, + esoft_del_mid_id numeric(19) not null, + down nvarchar(255), + version numeric(19) not null, + deleted integer default 0 not null, + constraint pk_esoft_del_down primary key (id) +); +create sequence esoft_del_down_seq as bigint start with 1 increment by 50; + +create table esoft_del_mid ( + id numeric(19) not null, + top_id numeric(19), + mid nvarchar(255), + up_id numeric(19), + version numeric(19) not null, + deleted integer default 0 not null, + constraint pk_esoft_del_mid primary key (id) +); +create sequence esoft_del_mid_seq as bigint start with 1 increment by 50; + +create table esoft_del_one_a ( + id numeric(19) not null, + name nvarchar(255), + oneb_id numeric(19), + deleted integer default 0 not null, + version numeric(19) not null, + constraint pk_esoft_del_one_a primary key (id) +); +create unique nonclustered index uq_esoft_del_one_a_oneb_id on esoft_del_one_a(oneb_id) where oneb_id is not null; +create sequence esoft_del_one_a_seq as bigint start with 1 increment by 50; + +create table esoft_del_one_b ( + id numeric(19) not null, + name nvarchar(255), + version numeric(19) not null, + constraint pk_esoft_del_one_b primary key (id) +); +create sequence esoft_del_one_b_seq as bigint start with 1 increment by 50; + +create table esoft_del_role ( + id numeric(19) not null, + role_name nvarchar(255), + version numeric(19) not null, + deleted integer default 0 not null, + constraint pk_esoft_del_role primary key (id) +); +create sequence esoft_del_role_seq as bigint start with 1 increment by 50; + +create table esoft_del_role_esoft_del_user ( + esoft_del_role_id numeric(19) not null, + esoft_del_user_id numeric(19) not null, + constraint pk_esoft_del_role_esoft_del_user primary key (esoft_del_role_id,esoft_del_user_id) +); + +create table esoft_del_top ( + id numeric(19) not null, + name nvarchar(255), + version numeric(19) not null, + deleted integer default 0 not null, + constraint pk_esoft_del_top primary key (id) +); +create sequence esoft_del_top_seq as bigint start with 1 increment by 50; + +create table esoft_del_up ( + id numeric(19) not null, + up nvarchar(255), + version numeric(19) not null, + deleted integer default 0 not null, + constraint pk_esoft_del_up primary key (id) +); +create sequence esoft_del_up_seq as bigint start with 1 increment by 50; + +create table esoft_del_user ( + id numeric(19) not null, + user_name nvarchar(255), + version numeric(19) not null, + deleted integer default 0 not null, + constraint pk_esoft_del_user primary key (id) +); +create sequence esoft_del_user_seq as bigint start with 1 increment by 50; + +create table esoft_del_user_esoft_del_role ( + esoft_del_user_id numeric(19) not null, + esoft_del_role_id numeric(19) not null, + constraint pk_esoft_del_user_esoft_del_role primary key (esoft_del_user_id,esoft_del_role_id) +); + +create table esome_convert_type ( + id numeric(19) not null, + name nvarchar(255), + money numeric(28), + constraint pk_esome_convert_type primary key (id) +); +create sequence esome_convert_type_seq as bigint start with 1 increment by 50; + +create table esome_type ( + id integer not null, + currency nvarchar(3), + locale nvarchar(20), + time_zone nvarchar(20), + constraint pk_esome_type primary key (id) +); +create sequence esome_type_seq as bigint start with 1 increment by 50; + +create table etrans_many ( + id integer not null, + name nvarchar(255), + constraint pk_etrans_many primary key (id) +); +create sequence etrans_many_seq as bigint start with 1 increment by 50; + +create table rawinherit_uncle ( + id integer not null, + name nvarchar(255), + parent_id numeric(19) not null, + version numeric(19) not null, + constraint pk_rawinherit_uncle primary key (id) +); +create sequence rawinherit_uncle_seq as bigint start with 1 increment by 50; + +create table euser_no_fk ( + user_id integer not null, + user_name nvarchar(255), + constraint pk_euser_no_fk primary key (user_id) +); +create sequence euser_no_fk_seq as bigint start with 1 increment by 50; + +create table euser_no_fk_soft_del ( + user_id integer not null, + user_name nvarchar(255), + constraint pk_euser_no_fk_soft_del primary key (user_id) +); +create sequence euser_no_fk_soft_del_seq as bigint start with 1 increment by 50; + +create table evanilla_collection ( + id integer not null, + name nvarchar(255), + constraint pk_evanilla_collection primary key (id) +); +create sequence evanilla_collection_seq as bigint start with 1 increment by 50; + +create table evanilla_collection_detail ( + id integer not null, + evanilla_collection_id integer not null, + something nvarchar(255), + constraint pk_evanilla_collection_detail primary key (id) +); +create sequence evanilla_collection_detail_seq as bigint start with 1 increment by 50; + +create table ewho_props ( + id numeric(19) not null, + name nvarchar(255), + version numeric(19) not null, + when_created datetime2 not null, + when_modified datetime2 not null, + who_created nvarchar(255) not null, + who_modified nvarchar(255) not null, + constraint pk_ewho_props primary key (id) +); +create sequence ewho_props_seq as bigint start with 1 increment by 50; + +create table e_withinet ( + id numeric(19) not null, + name nvarchar(255), + inet_address nvarchar(50), + inet2 nvarchar(255), + cidr varchar(50), + version numeric(19) not null, + constraint pk_e_withinet primary key (id) +); +create sequence e_withinet_seq as bigint start with 1 increment by 50; + +create table ec_enum_person ( + id numeric(19) not null, + name nvarchar(255), + version numeric(19) not null, + constraint pk_ec_enum_person primary key (id) +); +create sequence ec_enum_person_seq as bigint start with 1 increment by 50; + +create table ec_enum_person_tags ( + ec_enum_person_id numeric(19) not null, + value nvarchar(5) not null, + constraint ck_ec_enum_person_tags_value check ( value in ('RED','BLUE','GREEN')) +); + +create table ec_person ( + id numeric(19) not null, + name nvarchar(255), + version numeric(19) not null, + constraint pk_ec_person primary key (id) +); +create sequence ec_person_seq as bigint start with 1 increment by 50; + +create table ec_person_phone ( + owner_id numeric(19) not null, + phone nvarchar(255) not null +); + +create table ec_top ( + id numeric(19) not null, + name nvarchar(255), + person_id numeric(19), + version numeric(19) not null, + constraint pk_ec_top primary key (id) +); +create sequence ec_top_seq as bigint start with 1 increment by 50; + +create table ec_top_ecs_person ( + ec_top_id numeric(19) not null, + ecs_person_id numeric(19) not null, + constraint pk_ec_top_ecs_person primary key (ec_top_id,ecs_person_id) +); + +create table ecbl_person ( + id numeric(19) not null, + name nvarchar(255), + version numeric(19) not null, + constraint pk_ecbl_person primary key (id) +); +create sequence ecbl_person_seq as bigint start with 1 increment by 50; + +create table ecbl_person_phone_numbers ( + person_id numeric(19) not null, + country_code nvarchar(2), + area nvarchar(6), + phnum nvarchar(20) +); + +create table ecbm_person ( + id numeric(19) not null, + name nvarchar(255), + version numeric(19) not null, + constraint pk_ecbm_person primary key (id) +); +create sequence ecbm_person_seq as bigint start with 1 increment by 50; + +create table ecbm_person_phone_numbers ( + person_id numeric(19) not null, + mkey nvarchar(255) not null, + country_code nvarchar(2), + area nvarchar(6), + phnum nvarchar(20) +); + +create table ecm_person ( + id numeric(19) not null, + name nvarchar(255), + version numeric(19) not null, + constraint pk_ecm_person primary key (id) +); +create sequence ecm_person_seq as bigint start with 1 increment by 50; + +create table ecm_person_phone_numbers ( + ecm_person_id numeric(19) not null, + type nvarchar(4) not null, + phnum nvarchar(10) not null +); + +create table ecmc_person ( + id numeric(19) not null, + name nvarchar(255), + version numeric(19) not null, + constraint pk_ecmc_person primary key (id) +); +create sequence ecmc_person_seq as bigint start with 1 increment by 50; + +create table ecmc_person_phone_numbers ( + ecmc_person_id numeric(19) not null, + type nvarchar(4) not null, + value nvarchar(max) not null +); + +create table ecs_person ( + id numeric(19) not null, + name nvarchar(255), + version numeric(19) not null, + constraint pk_ecs_person primary key (id) +); +create sequence ecs_person_seq as bigint start with 1 increment by 50; + +create table ecs_person_phone ( + ecs_person_id numeric(19) not null, + phone nvarchar(255) not null +); + +create table ecsm_child ( + one_id uniqueidentifier not null, + ecsm_parent_id numeric(19) not null, + name nvarchar(255), + version numeric(19) not null, + constraint pk_ecsm_child primary key (one_id) +); + +create table ecsm_values ( + host_id uniqueidentifier not null, + value nvarchar(255) not null +); + +create table ecsm_one ( + one_id uniqueidentifier not null, + name nvarchar(255), + version numeric(19) not null, + constraint pk_ecsm_one primary key (one_id) +); + +create table ecsm_parent ( + id numeric(19) not null, + name nvarchar(255), + version numeric(19) not null, + constraint pk_ecsm_parent primary key (id) +); +create sequence ecsm_parent_seq as bigint start with 1 increment by 50; + +create table ecsm_two ( + id uniqueidentifier not null, + name nvarchar(255), + version numeric(19) not null, + constraint pk_ecsm_two primary key (id) +); + +create table td_child ( + child_id integer not null, + child_name nvarchar(255), + parent_id integer not null, + constraint pk_td_child primary key (child_id) +); +create sequence td_child_seq as bigint start with 1 increment by 50; + +create table td_parent ( + parent_type nvarchar(31) not null, + parent_id integer not null, + parent_name nvarchar(255), + extended_name nvarchar(255), + constraint pk_td_parent primary key (parent_id) +); +create sequence td_parent_seq as bigint start with 1 increment by 50; + +create table element_bean ( + id numeric(19) not null, + complex_bean_id uniqueidentifier not null, + value nvarchar(255) not null, + constraint pk_element_bean primary key (id) +); +create sequence element_bean_seq as bigint start with 1 increment by 50; + +create table empl ( + id numeric(19) not null, + name nvarchar(255), + age integer, + default_address_id numeric(19), + constraint pk_empl primary key (id) +); +create sequence empl_seq as bigint start with 1 increment by 50; + +create table esd_detail ( + id numeric(19) not null, + name nvarchar(255), + master_id numeric(19) not null, + version numeric(19) not null, + deleted integer default 0 not null, + constraint pk_esd_detail primary key (id) +); +create sequence esd_detail_seq as bigint start with 1 increment by 50; + +create table esd_master ( + id numeric(19) not null, + name nvarchar(255), + version numeric(19) not null, + deleted integer default 0 not null, + constraint pk_esd_master primary key (id) +); +create sequence esd_master_seq as bigint start with 1 increment by 50; + +create table feature_desc ( + id integer not null, + name nvarchar(255), + description nvarchar(255), + constraint pk_feature_desc primary key (id) +); +create sequence feature_desc_seq as bigint start with 1 increment by 50; + +create table f_first ( + id numeric(19) not null, + name nvarchar(255), + constraint pk_f_first primary key (id) +); +create sequence f_first_seq as bigint start with 1 increment by 50; + +create table foo ( + foo_id integer not null, + important_text nvarchar(255), + version integer not null, + constraint pk_foo primary key (foo_id) +); +create sequence foo_seq as bigint start with 1 increment by 50; + +create table gen_key_identity ( + id numeric(19) identity(1,1) not null, + description nvarchar(255), + constraint pk_gen_key_identity primary key (id) +); + +create table gen_key_sequence ( + id numeric(19) not null, + description nvarchar(255), + constraint pk_gen_key_sequence primary key (id) +); +create sequence gen_key_sequence_seq as bigint start with 1 increment by 50; + +create table gen_key_table ( + id numeric(19) not null, + description nvarchar(255), + constraint pk_gen_key_table primary key (id) +); +create sequence gen_key_table_seq as bigint start with 1 increment by 50; + +create table grand_parent_person ( + identifier integer not null, + name nvarchar(255), + age integer, + some_bean_id integer, + family_name nvarchar(255), + address nvarchar(255), + constraint pk_grand_parent_person primary key (identifier) +); +create sequence grand_parent_person_seq as bigint start with 1 increment by 50; + +create table survey_group ( + id numeric(19) not null, + name nvarchar(255), + categoryobjectid numeric(19), + sequence_number integer not null, + constraint pk_survey_group primary key (id) +); +create sequence survey_group_seq as bigint start with 1 increment by 50; + +create table c_group ( + id numeric(19) not null, + inactive integer default 0 not null, + name nvarchar(255), + version numeric(19) not null, + when_created datetime2 not null, + when_modified datetime2 not null, + constraint pk_c_group primary key (id) +); +create sequence c_group_seq as bigint start with 1 increment by 50; + +create table he_doc ( + id numeric(19) not null, + name nvarchar(255), + version numeric(19) not null, + when_created datetime2 not null, + when_modified datetime2 not null, + constraint pk_he_doc primary key (id) +); +create sequence he_doc_seq as bigint start with 1 increment by 50; + +create table hx_link ( + id numeric(19) not null, + name nvarchar(255), + location nvarchar(255), + comments nvarchar(255), + version numeric(19) not null, + when_created datetime2 not null, + when_modified datetime2 not null, + deleted integer default 0 not null, + constraint pk_hx_link primary key (id) +); +create sequence hx_link_seq as bigint start with 1 increment by 50; + +create table hx_link_doc ( + hx_link_id numeric(19) not null, + he_doc_id numeric(19) not null, + constraint pk_hx_link_doc primary key (hx_link_id,he_doc_id) +); + +create table hi_doc ( + id numeric(19) not null, + name nvarchar(255), + version numeric(19) not null, + when_created datetime2 not null, + when_modified datetime2 not null, + constraint pk_hi_doc primary key (id) +); +create sequence hi_doc_seq as bigint start with 1 increment by 50; + +create table hi_link ( + id numeric(19) not null, + name nvarchar(255), + location nvarchar(255), + comments nvarchar(255), + version numeric(19) not null, + when_created datetime2 not null, + when_modified datetime2 not null, + constraint pk_hi_link primary key (id) +); +create sequence hi_link_seq as bigint start with 1 increment by 50; + +create table hi_link_doc ( + hi_link_id numeric(19) not null, + hi_doc_id numeric(19) not null, + constraint pk_hi_link_doc primary key (hi_link_id,hi_doc_id) +); + +create table hi_tone ( + id numeric(19) not null, + name nvarchar(255), + comments nvarchar(255), + version numeric(19) not null, + when_created datetime2 not null, + when_modified datetime2 not null, + constraint pk_hi_tone primary key (id) +); +create sequence hi_tone_seq as bigint start with 1 increment by 50; + +create table hi_tthree ( + id numeric(19) not null, + hi_ttwo_id numeric(19) not null, + three nvarchar(255), + version numeric(19) not null, + when_created datetime2 not null, + when_modified datetime2 not null, + constraint pk_hi_tthree primary key (id) +); +create sequence hi_tthree_seq as bigint start with 1 increment by 50; + +create table hi_ttwo ( + id numeric(19) not null, + hi_tone_id numeric(19) not null, + two nvarchar(255), + version numeric(19) not null, + when_created datetime2 not null, + when_modified datetime2 not null, + constraint pk_hi_ttwo primary key (id) +); +create sequence hi_ttwo_seq as bigint start with 1 increment by 50; + +create table hsd_setting ( + id numeric(19) not null, + code nvarchar(255), + content nvarchar(255), + user_id numeric(19), + version numeric(19) not null, + when_created datetime2 not null, + when_modified datetime2 not null, + deleted integer default 0 not null, + constraint pk_hsd_setting primary key (id) +); +create unique nonclustered index uq_hsd_setting_user_id on hsd_setting(user_id) where user_id is not null; +create sequence hsd_setting_seq as bigint start with 1 increment by 50; + +create table hsd_user ( + id numeric(19) not null, + name nvarchar(255), + version numeric(19) not null, + when_created datetime2 not null, + when_modified datetime2 not null, + deleted integer default 0 not null, + constraint pk_hsd_user primary key (id) +); +create sequence hsd_user_seq as bigint start with 1 increment by 50; + +create table iaf_segment ( + ptype nvarchar(31) not null, + id numeric(19) not null, + segment_id_zat numeric(19) not null, + status_id numeric(19) not null, + constraint pk_iaf_segment primary key (id) +); +create sequence iaf_segment_seq as bigint start with 1 increment by 50; + +create table iaf_segment_status ( + id numeric(19) not null, + name nvarchar(255), + constraint pk_iaf_segment_status primary key (id) +); +create sequence iaf_segment_status_seq as bigint start with 1 increment by 50; + +create table imrelated ( + id numeric(19) not null, + name nvarchar(255), + owner_id numeric(19) not null, + constraint pk_imrelated primary key (id) +); +create sequence imrelated_seq as bigint start with 1 increment by 50; + +create table imroot ( + dtype nvarchar(31) not null, + id numeric(19) not null, + name nvarchar(255), + title nvarchar(255), + when_title datetime2, + constraint pk_imroot primary key (id) +); +create sequence imroot_seq as bigint start with 1 increment by 50; + +create table ixresource ( + dtype nvarchar(255), + id uniqueidentifier not null, + name nvarchar(255), + constraint pk_ixresource primary key (id) +); + +create table info_company ( + id numeric(19) not null, + name nvarchar(255), + version numeric(19) not null, + constraint pk_info_company primary key (id) +); +create sequence info_company_seq as bigint start with 1 increment by 50; + +create table info_contact ( + id numeric(19) not null, + name nvarchar(255), + company_id numeric(19) not null, + version numeric(19) not null, + constraint pk_info_contact primary key (id) +); +create sequence info_contact_seq as bigint start with 1 increment by 50; + +create table info_customer ( + id numeric(19) not null, + name nvarchar(255), + company_id numeric(19), + version numeric(19) not null, + constraint pk_info_customer primary key (id) +); +create unique nonclustered index uq_info_customer_company_id on info_customer(company_id) where company_id is not null; +create sequence info_customer_seq as bigint start with 1 increment by 50; + +create table inner_report ( + id numeric(19) not null, + name nvarchar(255), + forecast_id numeric(19), + constraint pk_inner_report primary key (id) +); +create unique nonclustered index uq_inner_report_forecast_id on inner_report(forecast_id) where forecast_id is not null; +create sequence inner_report_seq as bigint start with 1 increment by 50; + +create table drel_invoice ( + id numeric(19) not null, + booking numeric(19), + version integer not null, + constraint pk_drel_invoice primary key (id) +); +create sequence drel_invoice_seq as bigint start with 1 increment by 50; + +create table item ( + customer integer not null, + itemnumber nvarchar(127) not null, + description nvarchar(255), + units nvarchar(255), + type integer not null, + region integer not null, + date_modified datetime2, + date_created datetime2, + modified_by nvarchar(255), + created_by nvarchar(255), + version numeric(19) not null, + constraint pk_item primary key (customer,itemnumber) +); + +create table monkey ( + mid numeric(19) not null, + name nvarchar(255), + food_preference nvarchar(255), + version numeric(19) not null, + constraint pk_monkey primary key (mid) +); +create sequence monkey_seq as bigint start with 1 increment by 50; + +create table mkeygroup ( + pid numeric(19) not null, + name nvarchar(255), + version numeric(19) not null, + constraint pk_mkeygroup primary key (pid) +); +create sequence mkeygroup_seq as bigint start with 1 increment by 50; + +create table mkeygroup_monkey ( + mkeygroup_pid numeric(19) not null, + monkey_mid numeric(19) not null, + constraint uq_mkeygroup_monkey_mid unique (monkey_mid), + constraint pk_mkeygroup_monkey primary key (mkeygroup_pid,monkey_mid) +); + +create table trainer ( + tid numeric(19) not null, + name nvarchar(255), + version numeric(19) not null, + constraint pk_trainer primary key (tid) +); +create sequence trainer_seq as bigint start with 1 increment by 50; + +create table trainer_monkey ( + trainer_tid numeric(19) not null, + monkey_mid numeric(19) not null, + constraint uq_trainer_monkey_mid unique (monkey_mid), + constraint pk_trainer_monkey primary key (trainer_tid,monkey_mid) +); + +create table troop ( + pid numeric(19) not null, + name nvarchar(255), + version numeric(19) not null, + constraint pk_troop primary key (pid) +); +create sequence troop_seq as bigint start with 1 increment by 50; + +create table troop_monkey ( + troop_pid numeric(19) not null, + monkey_mid numeric(19) not null, + constraint uq_troop_monkey_mid unique (monkey_mid), + constraint pk_troop_monkey primary key (troop_pid,monkey_mid) +); + +create table l2_cldf_reset_bean ( + id numeric(19) not null, + name nvarchar(255), + constraint pk_l2_cldf_reset_bean primary key (id) +); +create sequence l2_cldf_reset_bean_seq as bigint start with 1 increment by 50; + +create table l2_cldf_reset_bean_child ( + id numeric(19) not null, + parent_id numeric(19), + constraint pk_l2_cldf_reset_bean_child primary key (id) +); +create sequence l2_cldf_reset_bean_child_seq as bigint start with 1 increment by 50; + +create table level1 ( + id numeric(19) not null, + name nvarchar(255), + constraint pk_level1 primary key (id) +); +create sequence level1_seq as bigint start with 1 increment by 50; + +create table level1_level4 ( + level1_id numeric(19) not null, + level4_id numeric(19) not null, + constraint pk_level1_level4 primary key (level1_id,level4_id) +); + +create table level1_level2 ( + level1_id numeric(19) not null, + level2_id numeric(19) not null, + constraint pk_level1_level2 primary key (level1_id,level2_id) +); + +create table level2 ( + id numeric(19) not null, + name nvarchar(255), + constraint pk_level2 primary key (id) +); +create sequence level2_seq as bigint start with 1 increment by 50; + +create table level2_level3 ( + level2_id numeric(19) not null, + level3_id numeric(19) not null, + constraint pk_level2_level3 primary key (level2_id,level3_id) +); + +create table level3 ( + id numeric(19) not null, + name nvarchar(255), + constraint pk_level3 primary key (id) +); +create sequence level3_seq as bigint start with 1 increment by 50; + +create table level4 ( + id numeric(19) not null, + name nvarchar(255), + constraint pk_level4 primary key (id) +); +create sequence level4_seq as bigint start with 1 increment by 50; + +create table link ( + id numeric(19) not null, + name nvarchar(255), + location nvarchar(255), + when_publish datetime2, + link_comment nvarchar(255), + version numeric(19) not null, + when_created datetime2 not null, + when_modified datetime2 not null, + deleted integer default 0 not null, + constraint pk_link primary key (id) +); +create sequence link_seq as bigint start with 1 increment by 50; + +create table link_draft ( + id numeric(19) not null, + name nvarchar(255), + location nvarchar(255), + when_publish datetime2, + link_comment nvarchar(255), + dirty integer default 0 not null, + version numeric(19) not null, + when_created datetime2 not null, + when_modified datetime2 not null, + deleted integer default 0 not null, + constraint pk_link_draft primary key (id) +); +create sequence link_draft_seq as bigint start with 1 increment by 50; + +create table la_attr_value ( + id integer not null, + name nvarchar(255), + cretime datetime2 not null, + updtime datetime2 not null, + version numeric(19) not null, + constraint pk_la_attr_value primary key (id) +); +create sequence la_attr_value_seq as bigint start with 1 increment by 50; + +create table la_attr_value_attribute ( + la_attr_value_id integer not null, + attribute_id integer not null, + constraint pk_la_attr_value_attribute primary key (la_attr_value_id,attribute_id) +); + +create table looney ( + id numeric(19) not null, + tune_id numeric(19), + name nvarchar(255), + constraint pk_looney primary key (id) +); +create sequence looney_seq as bigint start with 1 increment by 50; + +create table maddress ( + id uniqueidentifier not null, + street nvarchar(255), + city nvarchar(255), + version numeric(19) not null, + constraint pk_maddress primary key (id) +); + +create table mcontact ( + id uniqueidentifier not null, + email nvarchar(255), + first_name nvarchar(255), + last_name nvarchar(255), + customer_id uniqueidentifier, + version numeric(19) not null, + constraint pk_mcontact primary key (id) +); + +create table mcontact_message ( + id uniqueidentifier not null, + title nvarchar(255), + subject nvarchar(255), + notes nvarchar(255), + contact_id uniqueidentifier not null, + version numeric(19) not null, + constraint pk_mcontact_message primary key (id) +); + +create table mcustomer ( + id uniqueidentifier not null, + name nvarchar(255), + notes nvarchar(255), + shipping_address_id uniqueidentifier, + billing_address_id uniqueidentifier, + version numeric(19) not null, + constraint pk_mcustomer primary key (id) +); + +create table mgroup ( + id numeric(19) not null, + name nvarchar(255), + constraint pk_mgroup primary key (id) +); +create sequence mgroup_seq as bigint start with 1 increment by 50; + +create table mmachine ( + id numeric(19) not null, + name nvarchar(255), + version numeric(19) not null, + constraint pk_mmachine primary key (id) +); +create sequence mmachine_seq as bigint start with 1 increment by 50; + +create table mmachine_mgroup ( + mmachine_id numeric(19) not null, + mgroup_id numeric(19) not null, + constraint pk_mmachine_mgroup primary key (mmachine_id,mgroup_id) +); + +create table mmedia ( + type nvarchar(31) not null, + id numeric(19) not null, + url nvarchar(255), + note nvarchar(255), + constraint pk_mmedia primary key (id) +); +create sequence mmedia_seq as bigint start with 1 increment by 50; + +create table non_updateprop ( + id integer not null, + non_enum nvarchar(5), + name nvarchar(255), + note nvarchar(255), + constraint ck_non_updateprop_non_enum check ( non_enum in ('BEGIN','END')), + constraint pk_non_updateprop primary key (id) +); +create sequence non_updateprop_seq as bigint start with 1 increment by 50; + +create table mprinter ( + id numeric(19) not null, + name nvarchar(255), + flags numeric(19) not null, + current_state_id numeric(19), + last_swap_cyan_id numeric(19), + last_swap_magenta_id numeric(19), + last_swap_yellow_id numeric(19), + last_swap_black_id numeric(19), + version numeric(19) not null, + constraint pk_mprinter primary key (id) +); +create unique nonclustered index uq_mprinter_last_swap_cyan_id on mprinter(last_swap_cyan_id) where last_swap_cyan_id is not null; +create unique nonclustered index uq_mprinter_last_swap_magenta_id on mprinter(last_swap_magenta_id) where last_swap_magenta_id is not null; +create unique nonclustered index uq_mprinter_last_swap_yellow_id on mprinter(last_swap_yellow_id) where last_swap_yellow_id is not null; +create unique nonclustered index uq_mprinter_last_swap_black_id on mprinter(last_swap_black_id) where last_swap_black_id is not null; +create sequence mprinter_seq as bigint start with 1 increment by 50; + +create table mprinter_state ( + id numeric(19) not null, + flags numeric(19) not null, + printer_id numeric(19), + version numeric(19) not null, + constraint pk_mprinter_state primary key (id) +); +create sequence mprinter_state_seq as bigint start with 1 increment by 50; + +create table mprofile ( + id numeric(19) not null, + picture_id numeric(19), + name nvarchar(255), + constraint pk_mprofile primary key (id) +); +create sequence mprofile_seq as bigint start with 1 increment by 50; + +create table mprotected_construct_bean ( + id numeric(19) not null, + name nvarchar(255), + constraint pk_mprotected_construct_bean primary key (id) +); +create sequence mprotected_construct_bean_seq as bigint start with 1 increment by 50; + +create table mrole ( + roleid integer not null, + role_name nvarchar(255), + constraint pk_mrole primary key (roleid) +); +create sequence mrole_seq as bigint start with 1 increment by 50; + +create table mrole_muser ( + mrole_roleid integer not null, + muser_userid integer not null, + constraint pk_mrole_muser primary key (mrole_roleid,muser_userid) +); + +create table msome_other ( + id numeric(19) not null, + name nvarchar(255), + constraint pk_msome_other primary key (id) +); +create sequence msome_other_seq as bigint start with 1 increment by 50; + +create table muser ( + userid integer not null, + user_name nvarchar(255), + user_type_id integer, + constraint pk_muser primary key (userid) +); +create sequence muser_seq as bigint start with 1 increment by 50; + +create table muser_type ( + id integer not null, + name nvarchar(255), + constraint pk_muser_type primary key (id) +); +create sequence muser_type_seq as bigint start with 1 increment by 50; + +create table mail_box ( + id numeric(19) not null, + name nvarchar(255), + version numeric(19) not null, + constraint pk_mail_box primary key (id) +); +create sequence mail_box_seq as bigint start with 1 increment by 50; + +create table mail_user ( + id numeric(19) not null, + name nvarchar(255), + version numeric(19) not null, + constraint pk_mail_user primary key (id) +); +create sequence mail_user_seq as bigint start with 1 increment by 50; + +create table mail_user_inbox ( + mail_user_id numeric(19) not null, + mail_box_id numeric(19) not null, + constraint pk_mail_user_inbox primary key (mail_user_id,mail_box_id) +); + +create table mail_user_outbox ( + mail_user_id numeric(19) not null, + mail_box_id numeric(19) not null, + constraint pk_mail_user_outbox primary key (mail_user_id,mail_box_id) +); + +create table main_entity ( + id nvarchar(255) not null, + attr1 nvarchar(255), + attr2 nvarchar(255), + constraint pk_main_entity primary key (id) +); + +create table main_entity_relation ( + id uniqueidentifier not null, + id1 nvarchar(255), + id2 nvarchar(255), + attr1 nvarchar(255), + constraint pk_main_entity_relation primary key (id) +); + +create table map_super_actual ( + id numeric(19) not null, + name nvarchar(255), + when_created datetime2 not null, + when_updated datetime2 not null, + constraint pk_map_super_actual primary key (id) +); +create sequence map_super_actual_seq as bigint start with 1 increment by 50; + +create table c_message ( + id numeric(19) not null, + title nvarchar(255), + body nvarchar(255), + conversation_id numeric(19), + user_id numeric(19), + version numeric(19) not null, + when_created datetime2 not null, + when_modified datetime2 not null, + constraint pk_c_message primary key (id) +); +create sequence c_message_seq as bigint start with 1 increment by 50; + +create table meter_address_data ( + id uniqueidentifier not null, + street nvarchar(255) not null, + constraint pk_meter_address_data primary key (id) +); + +create table meter_contract_data ( + id uniqueidentifier not null, + special_needs_client_id uniqueidentifier not null, + constraint uq_meter_contract_data_special_needs_client_id unique (special_needs_client_id), + constraint pk_meter_contract_data primary key (id) +); + +create table meter_special_needs_client ( + id uniqueidentifier not null, + name nvarchar(255), + primary_id uniqueidentifier, + constraint pk_meter_special_needs_client primary key (id) +); +create unique nonclustered index uq_meter_special_needs_client_primary_id on meter_special_needs_client(primary_id) where primary_id is not null; + +create table meter_special_needs_contact ( + id uniqueidentifier not null, + name nvarchar(255), + constraint pk_meter_special_needs_contact primary key (id) +); + +create table meter_version ( + id uniqueidentifier not null, + address_data_id uniqueidentifier, + contract_data_id uniqueidentifier not null, + constraint uq_meter_version_contract_data_id unique (contract_data_id), + constraint pk_meter_version primary key (id) +); +create unique nonclustered index uq_meter_version_address_data_id on meter_version(address_data_id) where address_data_id is not null; + +create table mnoc_role ( + role_id integer not null, + role_name nvarchar(255), + version integer not null, + constraint pk_mnoc_role primary key (role_id) +); +create sequence mnoc_role_seq as bigint start with 1 increment by 50; + +create table mnoc_user ( + user_id integer not null, + user_name nvarchar(255), + version integer not null, + constraint pk_mnoc_user primary key (user_id) +); +create sequence mnoc_user_seq as bigint start with 1 increment by 50; + +create table mnoc_user_mnoc_role ( + mnoc_user_user_id integer not null, + mnoc_role_role_id integer not null, + constraint pk_mnoc_user_mnoc_role primary key (mnoc_user_user_id,mnoc_role_role_id) +); + +create table mny_a ( + id numeric(19) not null, + name nvarchar(255), + version numeric(19) not null, + when_created datetime2 not null, + when_modified datetime2 not null, + constraint pk_mny_a primary key (id) +); +create sequence mny_a_seq as bigint start with 1 increment by 50; + +create table mny_b ( + id numeric(19) not null, + name nvarchar(255), + a_id numeric(19), + version numeric(19) not null, + when_created datetime2 not null, + when_modified datetime2 not null, + constraint pk_mny_b primary key (id) +); +create sequence mny_b_seq as bigint start with 1 increment by 50; + +create table mny_b_mny_c ( + mny_b_id numeric(19) not null, + mny_c_id numeric(19) not null, + constraint pk_mny_b_mny_c primary key (mny_b_id,mny_c_id) +); + +create table mny_c ( + id numeric(19) not null, + name nvarchar(255), + version numeric(19) not null, + when_created datetime2 not null, + when_modified datetime2 not null, + constraint pk_mny_c primary key (id) +); +create sequence mny_c_seq as bigint start with 1 increment by 50; + +create table mny_topic ( + id numeric(19) not null, + name nvarchar(255), + version numeric(19) not null, + constraint pk_mny_topic primary key (id) +); +create sequence mny_topic_seq as bigint start with 1 increment by 50; + +create table subtopics ( + topic numeric(19) not null, + subtopic numeric(19) not null, + constraint pk_subtopics primary key (topic,subtopic) +); + +create table mp_role ( + id numeric(19) not null, + mp_user_id numeric(19) not null, + code nvarchar(255), + organization_id numeric(19), + constraint pk_mp_role primary key (id) +); +create sequence mp_role_seq as bigint start with 1 increment by 50; + +create table mp_user ( + id numeric(19) not null, + name nvarchar(255), + constraint pk_mp_user primary key (id) +); +create sequence mp_user_seq as bigint start with 1 increment by 50; + +create table ms_many_a ( + aid numeric(19) not null, + name nvarchar(255), + ms_many_a_many_b integer default 0 not null, + ms_many_b integer default 0 not null, + deleted integer default 0 not null, + constraint pk_ms_many_a primary key (aid) +); +create sequence ms_many_a_seq as bigint start with 1 increment by 50; + +create table ms_many_a_many_b ( + ms_many_a_aid numeric(19) not null, + ms_many_b_bid numeric(19) not null, + constraint pk_ms_many_a_many_b primary key (ms_many_a_aid,ms_many_b_bid) +); + +create table ms_many_b ( + bid numeric(19) not null, + name nvarchar(255), + deleted integer default 0 not null, + constraint pk_ms_many_b primary key (bid) +); +create sequence ms_many_b_seq as bigint start with 1 increment by 50; + +create table ms_many_b_many_a ( + ms_many_b_bid numeric(19) not null, + ms_many_a_aid numeric(19) not null, + constraint pk_ms_many_b_many_a primary key (ms_many_b_bid,ms_many_a_aid) +); + +create table my_lob_size ( + id integer not null, + name nvarchar(255), + my_count integer not null, + my_lob nvarchar(max), + constraint pk_my_lob_size primary key (id) +); +create sequence my_lob_size_seq as bigint start with 1 increment by 50; + +create table my_lob_size_join_many ( + id integer not null, + something nvarchar(255), + other nvarchar(255), + parent_id integer, + constraint pk_my_lob_size_join_many primary key (id) +); +create sequence my_lob_size_join_many_seq as bigint start with 1 increment by 50; + +create table noidbean ( + name nvarchar(255), + subject nvarchar(255), + when_created datetime2 not null +); + +create table o_bean_child ( + id numeric(19) not null, + cached_bean_id numeric(19), + constraint pk_o_bean_child primary key (id) +); +create sequence o_bean_child_seq as bigint start with 1 increment by 50; + +create table ocached_app ( + id numeric(19) not null, + app_name nvarchar(255), + version numeric(19) not null, + constraint pk_ocached_app primary key (id) +); +create unique nonclustered index uq_ocached_app_app_name on ocached_app(app_name) where app_name is not null; +create sequence ocached_app_seq as bigint start with 1 increment by 50; + +create table ocached_app_detail ( + id numeric(19) not null, + app_id numeric(19) not null, + detail nvarchar(255), + version numeric(19) not null, + constraint pk_ocached_app_detail primary key (id) +); +create unique nonclustered index uq_ocached_app_detail_app_id_detail on ocached_app_detail(app_id,detail) where detail is not null; +create sequence ocached_app_detail_seq as bigint start with 1 increment by 50; + +create table o_cached_bean ( + id numeric(19) not null, + name nvarchar(255), + constraint pk_o_cached_bean primary key (id) +); +create sequence o_cached_bean_seq as bigint start with 1 increment by 50; + +create table o_cached_bean_country ( + o_cached_bean_id numeric(19) not null, + o_country_code nvarchar(2) not null, + constraint pk_o_cached_bean_country primary key (o_cached_bean_id,o_country_code) +); + +create table o_cached_bean_child ( + id numeric(19) not null, + cached_bean_id numeric(19), + constraint pk_o_cached_bean_child primary key (id) +); +create sequence o_cached_bean_child_seq as bigint start with 1 increment by 50; + +create table o_cached_inherit ( + dtype nvarchar(31) not null, + id numeric(19) not null, + name nvarchar(255), + child_adata nvarchar(255), + child_bdata nvarchar(255), + constraint pk_o_cached_inherit primary key (id) +); +create sequence o_cached_inherit_seq as bigint start with 1 increment by 50; + +create table o_cached_natkey ( + id numeric(19) not null, + store nvarchar(255), + sku nvarchar(255), + description nvarchar(255), + constraint pk_o_cached_natkey primary key (id) +); +create sequence o_cached_natkey_seq as bigint start with 1 increment by 50; + +create table o_cached_natkey3 ( + id numeric(19) not null, + store nvarchar(255), + code integer not null, + sku nvarchar(255), + description nvarchar(255), + constraint pk_o_cached_natkey3 primary key (id) +); +create sequence o_cached_natkey3_seq as bigint start with 1 increment by 50; + +create table ocached_nkey_uid ( + id numeric(19) not null, + cid uniqueidentifier, + other nvarchar(255), + version numeric(19) not null, + constraint pk_ocached_nkey_uid primary key (id) +); +create sequence ocached_nkey_uid_seq as bigint start with 1 increment by 50; + +create table ocar ( + id integer not null, + vin nvarchar(255), + name nvarchar(255), + cretime datetime2 not null, + updtime datetime2 not null, + version numeric(19) not null, + constraint pk_ocar primary key (id) +); +create sequence ocar_seq as bigint start with 1 increment by 50; + +create table ocompany ( + id integer not null, + corp_id nvarchar(50), + cretime datetime2 not null, + updtime datetime2 not null, + version numeric(19) not null, + constraint pk_ocompany primary key (id) +); +create unique nonclustered index uq_ocompany_corp_id on ocompany(corp_id) where corp_id is not null; +create sequence ocompany_seq as bigint start with 1 increment by 50; + +create table oengine ( + engine_id uniqueidentifier not null, + short_desc nvarchar(255), + car_id integer, + version integer not null, + constraint pk_oengine primary key (engine_id) +); +create unique nonclustered index uq_oengine_car_id on oengine(car_id) where car_id is not null; + +create table ogear_box ( + id uniqueidentifier not null, + box_desc nvarchar(255), + box_size integer, + car_id integer, + version integer not null, + constraint pk_ogear_box primary key (id) +); +create unique nonclustered index uq_ogear_box_car_id on ogear_box(car_id) where car_id is not null; + +create table omvertex ( + id uniqueidentifier not null, + constraint pk_omvertex primary key (id) +); + +create table omvertex_other ( + id uniqueidentifier not null, + omvertex_id uniqueidentifier not null, + name nvarchar(255), + constraint pk_omvertex_other primary key (id) +); + +create table oroad_show_msg ( + id integer not null, + company_id integer not null, + cretime datetime2 not null, + updtime datetime2 not null, + version numeric(19) not null, + constraint uq_oroad_show_msg_company_id unique (company_id), + constraint pk_oroad_show_msg primary key (id) +); +create sequence oroad_show_msg_seq as bigint start with 1 increment by 50; + +create table om_account_child_dbo ( + id numeric(19) not null, + description nvarchar(255), + banana_rama_id numeric(19), + constraint pk_om_account_child_dbo primary key (id) +); +create sequence om_account_child_dbo_seq as bigint start with 1 increment by 50; + +create table om_account_dbo ( + id numeric(19) not null, + name nvarchar(255), + constraint pk_om_account_dbo primary key (id) +); +create sequence om_account_dbo_seq as bigint start with 1 increment by 50; + +create table om_basic_child ( + id numeric(19) not null, + name nvarchar(255), + parent_id numeric(19), + version numeric(19) not null, + constraint pk_om_basic_child primary key (id) +); +create sequence om_basic_child_seq as bigint start with 1 increment by 50; + +create table om_basic_parent ( + id numeric(19) not null, + name nvarchar(255), + version numeric(19) not null, + constraint pk_om_basic_parent primary key (id) +); +create sequence om_basic_parent_seq as bigint start with 1 increment by 50; + +create table om_ordered_detail ( + id numeric(19) not null, + name nvarchar(255), + master_id numeric(19), + version numeric(19) not null, + sort_order integer, + constraint pk_om_ordered_detail primary key (id) +); +create sequence om_ordered_detail_seq as bigint start with 1 increment by 50; + +create table om_ordered_master ( + id numeric(19) not null, + name nvarchar(255), + version numeric(19) not null, + constraint pk_om_ordered_master primary key (id) +); +create sequence om_ordered_master_seq as bigint start with 1 increment by 50; + +create table only_id_entity ( + id numeric(19) not null, + constraint pk_only_id_entity primary key (id) +); +create sequence only_id_entity_seq as bigint start with 1 increment by 50; + +create table o_order ( + id integer not null, + status integer, + order_date date, + ship_date date, + kcustomer_id integer not null, + cretime datetime2 not null, + updtime datetime2 not null, + constraint ck_o_order_status check ( status in (0,1,2,3)), + constraint pk_o_order primary key (id) +); +create sequence o_order_seq as bigint start with 1 increment by 50; + +create table o_order_detail ( + id integer not null, + order_id integer not null, + order_qty integer, + ship_qty integer, + unit_price float(32), + product_id integer, + cretime datetime2, + updtime datetime2 not null, + constraint pk_o_order_detail primary key (id) +); +create sequence o_order_detail_seq as bigint start with 1 increment by 50; + +create table s_orders ( + uuid nvarchar(40) not null, + constraint pk_s_orders primary key (uuid) +); + +create table s_order_items ( + uuid nvarchar(40) not null, + product_variant_uuid nvarchar(255), + order_uuid nvarchar(40), + quantity integer not null, + amount numeric(28), + constraint pk_s_order_items primary key (uuid) +); + +create table or_order_ship ( + id integer not null, + order_id integer, + ship_time datetime2, + cretime datetime2 not null, + updtime datetime2 not null, + version numeric(19) not null, + constraint pk_or_order_ship primary key (id) +); +create sequence or_order_ship_seq as bigint start with 1 increment by 50; + +create table organisation ( + id numeric(19) not null, + name nvarchar(255), + version numeric(19) not null, + when_created datetime2 not null, + when_modified datetime2 not null, + constraint pk_organisation primary key (id) +); +create sequence organisation_seq as bigint start with 1 increment by 50; + +create table organization_node ( + kind nvarchar(31) not null, + id numeric(19) not null, + parent_tree_node_id numeric(19) not null, + title nvarchar(255), + constraint uq_organization_node_parent_tree_node_id unique (parent_tree_node_id), + constraint pk_organization_node primary key (id) +); +create sequence organization_node_seq as bigint start with 1 increment by 50; + +create table organization_tree_node ( + id numeric(19) not null, + name nvarchar(255), + constraint pk_organization_tree_node primary key (id) +); +create sequence organization_tree_node_seq as bigint start with 1 increment by 50; + +create table orp_detail ( + id nvarchar(100) not null, + detail nvarchar(255), + master_id nvarchar(100), + version numeric(19) not null, + constraint pk_orp_detail primary key (id) +); + +create table orp_detail2 ( + id nvarchar(100) not null, + orp_master2_id nvarchar(100) not null, + detail nvarchar(255), + master_id nvarchar(255), + version numeric(19) not null, + constraint pk_orp_detail2 primary key (id) +); + +create table orp_master ( + id nvarchar(100) not null, + name nvarchar(255), + version numeric(19) not null, + constraint pk_orp_master primary key (id) +); + +create table orp_master2 ( + id nvarchar(100) not null, + name nvarchar(255), + version numeric(19) not null, + constraint pk_orp_master2 primary key (id) +); + +create table oto_aone ( + id nvarchar(100) not null, + description nvarchar(255), + constraint pk_oto_aone primary key (id) +); + +create table oto_atwo ( + id nvarchar(100) not null, + description nvarchar(255), + aone_id nvarchar(100), + constraint pk_oto_atwo primary key (id) +); +create unique nonclustered index uq_oto_atwo_aone_id on oto_atwo(aone_id) where aone_id is not null; + +create table oto_bchild ( + master_id numeric(19) not null, + child nvarchar(255), + constraint pk_oto_bchild primary key (master_id) +); +create sequence oto_bchild_seq as bigint start with 1 increment by 50; + +create table oto_bmaster ( + id numeric(19) not null, + name nvarchar(255), + constraint pk_oto_bmaster primary key (id) +); +create sequence oto_bmaster_seq as bigint start with 1 increment by 50; + +create table oto_child ( + id integer not null, + name nvarchar(255), + master_id numeric(19), + constraint pk_oto_child primary key (id) +); +create unique nonclustered index uq_oto_child_master_id on oto_child(master_id) where master_id is not null; +create sequence oto_child_seq as bigint start with 1 increment by 50; + +create table oto_cust ( + cid numeric(19) not null, + name nvarchar(255), + version numeric(19) not null, + constraint pk_oto_cust primary key (cid) +); +create sequence oto_cust_seq as bigint start with 1 increment by 50; + +create table oto_cust_address ( + aid numeric(19) not null, + line1 nvarchar(255), + line2 nvarchar(255), + line3 nvarchar(255), + customer_cid numeric(19), + version numeric(19) not null, + constraint pk_oto_cust_address primary key (aid) +); +create unique nonclustered index uq_oto_cust_address_customer_cid on oto_cust_address(customer_cid) where customer_cid is not null; +create sequence oto_cust_address_seq as bigint start with 1 increment by 50; + +create table oto_level_a ( + id numeric(19) not null, + name nvarchar(255), + b_id numeric(19), + constraint pk_oto_level_a primary key (id) +); +create unique nonclustered index uq_oto_level_a_b_id on oto_level_a(b_id) where b_id is not null; +create sequence oto_level_a_seq as bigint start with 1 increment by 50; + +create table oto_level_b ( + id numeric(19) not null, + name nvarchar(255), + c_id numeric(19), + constraint pk_oto_level_b primary key (id) +); +create unique nonclustered index uq_oto_level_b_c_id on oto_level_b(c_id) where c_id is not null; +create sequence oto_level_b_seq as bigint start with 1 increment by 50; + +create table oto_level_c ( + id numeric(19) not null, + name nvarchar(255), + constraint pk_oto_level_c primary key (id) +); +create sequence oto_level_c_seq as bigint start with 1 increment by 50; + +create table oto_master ( + id numeric(19) not null, + name nvarchar(255), + constraint pk_oto_master primary key (id) +); +create sequence oto_master_seq as bigint start with 1 increment by 50; + +create table oto_prime ( + pid numeric(19) not null, + name nvarchar(255), + version numeric(19) not null, + constraint pk_oto_prime primary key (pid) +); +create sequence oto_prime_seq as bigint start with 1 increment by 50; + +create table oto_prime_extra ( + eid numeric(19) not null, + extra nvarchar(255), + version numeric(19) not null, + constraint pk_oto_prime_extra primary key (eid) +); +create sequence oto_prime_extra_seq as bigint start with 1 increment by 50; + +create table oto_sd_child ( + id numeric(19) not null, + child nvarchar(255), + master_id numeric(19), + deleted integer default 0 not null, + version numeric(19) not null, + constraint pk_oto_sd_child primary key (id) +); +create unique nonclustered index uq_oto_sd_child_master_id on oto_sd_child(master_id) where master_id is not null; +create sequence oto_sd_child_seq as bigint start with 1 increment by 50; + +create table oto_sd_master ( + id numeric(19) not null, + name nvarchar(255), + version numeric(19) not null, + constraint pk_oto_sd_master primary key (id) +); +create sequence oto_sd_master_seq as bigint start with 1 increment by 50; + +create table oto_th_many ( + id numeric(19) not null, + oto_th_top_id numeric(19) not null, + many nvarchar(255), + version numeric(19) not null, + when_created datetime2 not null, + when_modified datetime2 not null, + constraint pk_oto_th_many primary key (id) +); +create sequence oto_th_many_seq as bigint start with 1 increment by 50; + +create table oto_th_one ( + id numeric(19) not null, + one integer default 0 not null, + many_id numeric(19), + version numeric(19) not null, + when_created datetime2 not null, + when_modified datetime2 not null, + constraint pk_oto_th_one primary key (id) +); +create unique nonclustered index uq_oto_th_one_many_id on oto_th_one(many_id) where many_id is not null; +create sequence oto_th_one_seq as bigint start with 1 increment by 50; + +create table oto_th_top ( + id numeric(19) not null, + topp nvarchar(255), + version numeric(19) not null, + when_created datetime2 not null, + when_modified datetime2 not null, + constraint pk_oto_th_top primary key (id) +); +create sequence oto_th_top_seq as bigint start with 1 increment by 50; + +create table oto_ubprime ( + pid uniqueidentifier not null, + name nvarchar(255), + version numeric(19) not null, + constraint pk_oto_ubprime primary key (pid) +); + +create table oto_ubprime_extra ( + eid uniqueidentifier not null, + extra nvarchar(255), + version numeric(19) not null, + constraint pk_oto_ubprime_extra primary key (eid) +); + +create table oto_uprime ( + pid uniqueidentifier not null, + name nvarchar(255), + version numeric(19) not null, + constraint pk_oto_uprime primary key (pid) +); + +create table oto_uprime_extra ( + eid uniqueidentifier not null, + extra nvarchar(255), + version numeric(19) not null, + constraint pk_oto_uprime_extra primary key (eid) +); + +create table oto_user_model ( + id numeric(19) not null, + name nvarchar(255), + user_optional_id numeric(19), + version numeric(19) not null, + when_created datetime2 not null, + when_modified datetime2 not null, + constraint pk_oto_user_model primary key (id) +); +create unique nonclustered index uq_oto_user_model_user_optional_id on oto_user_model(user_optional_id) where user_optional_id is not null; +create sequence oto_user_model_seq as bigint start with 1 increment by 50; + +create table oto_user_model_optional ( + id numeric(19) not null, + optional nvarchar(255), + version numeric(19) not null, + when_created datetime2 not null, + when_modified datetime2 not null, + constraint pk_oto_user_model_optional primary key (id) +); +create sequence oto_user_model_optional_seq as bigint start with 1 increment by 50; + +create table pfile ( + id integer not null, + name nvarchar(255), + file_content_id integer, + file_content2_id integer, + cretime datetime2 not null, + updtime datetime2 not null, + version numeric(19) not null, + constraint pk_pfile primary key (id) +); +create unique nonclustered index uq_pfile_file_content_id on pfile(file_content_id) where file_content_id is not null; +create unique nonclustered index uq_pfile_file_content2_id on pfile(file_content2_id) where file_content2_id is not null; +create sequence pfile_seq as bigint start with 1 increment by 50; + +create table pfile_content ( + id integer not null, + content image, + cretime datetime2 not null, + updtime datetime2 not null, + version numeric(19) not null, + constraint pk_pfile_content primary key (id) +); +create sequence pfile_content_seq as bigint start with 1 increment by 50; + +create table paggview ( + pview_id uniqueidentifier, + amount integer not null +); +create unique nonclustered index uq_paggview_pview_id on paggview(pview_id) where pview_id is not null; + +create table pallet_location ( + type nvarchar(31) not null, + id integer not null, + zone_sid integer not null, + attribute nvarchar(255), + constraint pk_pallet_location primary key (id) +); +create sequence pallet_location_seq as bigint start with 1 increment by 50; + +create table parcel ( + parcelid numeric(19) not null, + description nvarchar(255), + constraint pk_parcel primary key (parcelid) +); +create sequence parcel_seq as bigint start with 1 increment by 50; + +create table parcel_location ( + parcellocid numeric(19) not null, + location nvarchar(255), + parcelid numeric(19), + constraint pk_parcel_location primary key (parcellocid) +); +create unique nonclustered index uq_parcel_location_parcelid on parcel_location(parcelid) where parcelid is not null; +create sequence parcel_location_seq as bigint start with 1 increment by 50; + +create table rawinherit_parent ( + type nvarchar(31) not null, + id numeric(19) not null, + val integer, + more nvarchar(255), + constraint pk_rawinherit_parent primary key (id) +); +create sequence rawinherit_parent_seq as bigint start with 1 increment by 50; + +create table rawinherit_parent_rawinherit_data ( + rawinherit_parent_id numeric(19) not null, + rawinherit_data_id numeric(19) not null, + constraint pk_rawinherit_parent_rawinherit_data primary key (rawinherit_parent_id,rawinherit_data_id) +); + +create table e_save_test_c ( + id numeric(19) not null, + version numeric(19) not null, + constraint pk_e_save_test_c primary key (id) +); +create sequence e_save_test_c_seq as bigint start with 1 increment by 50; + +create table parent_person ( + identifier integer not null, + name nvarchar(255), + age integer, + some_bean_id integer, + parent_identifier integer, + family_name nvarchar(255), + address nvarchar(255), + constraint pk_parent_person primary key (identifier) +); +create sequence parent_person_seq as bigint start with 1 increment by 50; + +create table c_participation ( + id numeric(19) not null, + rating integer, + type integer, + conversation_id numeric(19) not null, + user_id numeric(19) not null, + version numeric(19) not null, + when_created datetime2 not null, + when_modified datetime2 not null, + constraint ck_c_participation_type check ( type in (0,1)), + constraint pk_c_participation primary key (id) +); +create sequence c_participation_seq as bigint start with 1 increment by 50; + +create table password_store_model ( + id numeric(19) not null, + enc1 nvarchar(30), + enc2 nvarchar(40), + enc3 nvarchar(max), + enc4 varbinary(30), + enc5 varbinary(40), + enc6 image, + version numeric(19) not null, + when_created datetime2 not null, + when_modified datetime2 not null, + constraint pk_password_store_model primary key (id) +); +create sequence password_store_model_seq as bigint start with 1 increment by 50; + +create table pcf_calendar ( + id numeric(19) not null, + pcf_person_id numeric(19) not null, + version numeric(19) not null, + constraint pk_pcf_calendar primary key (id) +); +create sequence pcf_calendar_seq as bigint start with 1 increment by 50; + +create table pcf_city ( + id numeric(19) not null, + pcf_country_id numeric(19) not null, + name nvarchar(255), + mayor_id numeric(19) not null, + vice_mayor_id numeric(19) not null, + version numeric(19) not null, + constraint uq_pcf_city_mayor_id unique (mayor_id), + constraint uq_pcf_city_vice_mayor_id unique (vice_mayor_id), + constraint pk_pcf_city primary key (id) +); +create sequence pcf_city_seq as bigint start with 1 increment by 50; + +create table pcf_country ( + id numeric(19) not null, + version numeric(19) not null, + constraint pk_pcf_country primary key (id) +); +create sequence pcf_country_seq as bigint start with 1 increment by 50; + +create table pcf_event ( + id numeric(19) not null, + pcf_calendar_id numeric(19) not null, + name nvarchar(255), + version numeric(19) not null, + constraint pk_pcf_event primary key (id) +); +create sequence pcf_event_seq as bigint start with 1 increment by 50; + +create table pcf_person ( + id numeric(19) not null, + name nvarchar(255), + version numeric(19) not null, + constraint pk_pcf_person primary key (id) +); +create sequence pcf_person_seq as bigint start with 1 increment by 50; + +create table mt_permission ( + id uniqueidentifier not null, + name nvarchar(255), + constraint pk_mt_permission primary key (id) +); + +create table persistent_file ( + id integer not null, + name nvarchar(255), + cretime datetime2 not null, + updtime datetime2 not null, + version numeric(19) not null, + constraint pk_persistent_file primary key (id) +); +create sequence persistent_file_seq as bigint start with 1 increment by 50; + +create table persistent_file_content ( + id integer not null, + persistent_file_id integer, + content image, + cretime datetime2 not null, + updtime datetime2 not null, + version numeric(19) not null, + constraint pk_persistent_file_content primary key (id) +); +create unique nonclustered index uq_persistent_file_content_persistent_file_id on persistent_file_content(persistent_file_id) where persistent_file_id is not null; +create sequence persistent_file_content_seq as bigint start with 1 increment by 50; + +create table person ( + oid numeric(19) not null, + default_address_oid numeric(19), + version integer not null, + constraint pk_person primary key (oid) +); +create sequence person_seq as bigint start with 1 increment by 50; + +create table persons ( + id numeric(19) not null, + surname nvarchar(64) not null, + name nvarchar(64) not null, + constraint pk_persons primary key (id) +); +create sequence PERSONS_seq as bigint start with 1000 increment by 40; + +create table person_cache_email ( + id nvarchar(128) not null, + person_info_person_id nvarchar(128), + email nvarchar(255), + constraint pk_person_cache_email primary key (id) +); + +create table person_cache_info ( + person_id nvarchar(128) not null, + name nvarchar(255), + constraint pk_person_cache_info primary key (person_id) +); + +create table phones ( + id numeric(19) not null, + phone_number nvarchar(7) not null, + person_id numeric(19) not null, + constraint uq_phones_phone_number unique (phone_number), + constraint pk_phones primary key (id) +); +create sequence PHONES_seq as bigint start with 1 increment by 50; + +create table e_position ( + id numeric(19) not null, + name nvarchar(255), + contract_id numeric(19) not null, + constraint pk_e_position primary key (id) +); +create sequence e_position_seq as bigint start with 1 increment by 50; + +create table primary_revision ( + id numeric(19) not null, + revision integer not null, + name nvarchar(255), + version numeric(19) not null, + constraint pk_primary_revision primary key (id,revision) +); + +create table o_product ( + id integer not null, + sku nvarchar(20), + name nvarchar(255), + cretime datetime2 not null, + updtime datetime2 not null, + constraint pk_o_product primary key (id) +); +create sequence o_product_seq as bigint start with 1 increment by 50; + +create table pp ( + id uniqueidentifier not null, + name nvarchar(255), + value nvarchar(100) not null, + constraint pk_pp primary key (id) +); + +create table pp_to_ww ( + pp_id uniqueidentifier not null, + ww_id uniqueidentifier not null, + constraint pk_pp_to_ww primary key (pp_id,ww_id) +); + +create table question ( + id numeric(19) not null, + name nvarchar(255), + groupobjectid numeric(19), + sequence_number integer not null, + constraint pk_question primary key (id) +); +create sequence question_seq as bigint start with 1 increment by 50; + +create table rcustomer ( + company nvarchar(127) not null, + name nvarchar(127) not null, + description nvarchar(255), + constraint pk_rcustomer primary key (company,name) +); + +create table r_orders ( + company nvarchar(127) not null, + order_number integer not null, + customername nvarchar(127), + item nvarchar(255), + constraint pk_r_orders primary key (company,order_number) +); + +create table referencing_bean ( + id uniqueidentifier not null, + constraint pk_referencing_bean primary key (id) +); + +create table region ( + customer integer not null, + type integer not null, + description nvarchar(255), + version numeric(19) not null, + constraint pk_region primary key (customer,type) +); + +create table rel_detail ( + id numeric(19) not null, + name nvarchar(255), + version integer not null, + constraint pk_rel_detail primary key (id) +); +create sequence rel_detail_seq as bigint start with 1 increment by 50; + +create table rel_master ( + id numeric(19) not null, + name nvarchar(255), + detail_id numeric(19), + version integer not null, + constraint pk_rel_master primary key (id) +); +create sequence rel_master_seq as bigint start with 1 increment by 50; + +create table resourcefile ( + id nvarchar(64) not null, + parentresourcefileid nvarchar(64), + name nvarchar(128) not null, + constraint pk_resourcefile primary key (id) +); + +create table mt_role ( + id uniqueidentifier not null, + name nvarchar(50), + tenant_id uniqueidentifier, + version numeric(19) not null, + constraint pk_mt_role primary key (id) +); + +create table mt_role_permission ( + mt_role_id uniqueidentifier not null, + mt_permission_id uniqueidentifier not null, + constraint pk_mt_role_permission primary key (mt_role_id,mt_permission_id) +); + +create table em_role ( + id numeric(19) not null, + name nvarchar(255), + constraint pk_em_role primary key (id) +); +create sequence em_role_seq as bigint start with 1 increment by 50; + +create table root_bean ( + dtype nvarchar(31) not null, + id uniqueidentifier not null, + referencing_bean_id uniqueidentifier not null, + value nvarchar(255), + constraint pk_root_bean primary key (id) +); + +create table f_second ( + id numeric(19) not null, + mod_name nvarchar(255), + first numeric(19), + title nvarchar(255), + constraint pk_f_second primary key (id) +); +create unique nonclustered index uq_f_second_first on f_second(first) where first is not null; +create sequence f_second_seq as bigint start with 1 increment by 50; + +create table section ( + id integer not null, + article_id integer, + type integer, + content nvarchar(max), + cretime datetime2 not null, + updtime datetime2 not null, + version numeric(19) not null, + constraint ck_section_type check ( type in (0,1)), + constraint pk_section primary key (id) +); +create sequence section_seq as bigint start with 1 increment by 50; + +create table self_parent ( + id numeric(19) not null, + name nvarchar(255), + parent_id numeric(19), + version numeric(19) not null, + constraint pk_self_parent primary key (id) +); +create sequence self_parent_seq as bigint start with 1 increment by 50; + +create table self_ref_customer ( + id numeric(19) not null, + name nvarchar(255), + referred_by_id numeric(19), + constraint pk_self_ref_customer primary key (id) +); +create sequence self_ref_customer_seq as bigint start with 1 increment by 50; + +create table self_ref_example ( + id numeric(19) not null, + name nvarchar(255) not null, + parent_id numeric(19), + constraint pk_self_ref_example primary key (id) +); +create sequence self_ref_example_seq as bigint start with 1 increment by 50; + +create table e_save_test_a ( + id numeric(19) not null, + version numeric(19) not null, + constraint pk_e_save_test_a primary key (id) +); +create sequence e_save_test_a_seq as bigint start with 1 increment by 50; + +create table e_save_test_b ( + id numeric(19) not null, + sibling_a_id numeric(19), + test_property integer default 0 not null, + version numeric(19) not null, + constraint pk_e_save_test_b primary key (id) +); +create unique nonclustered index uq_e_save_test_b_sibling_a_id on e_save_test_b(sibling_a_id) where sibling_a_id is not null; +create sequence e_save_test_b_seq as bigint start with 1 increment by 50; + +create table site ( + id uniqueidentifier not null, + name nvarchar(255), + parent_id uniqueidentifier, + data_container_id uniqueidentifier, + site_address_id uniqueidentifier, + constraint pk_site primary key (id) +); +create unique nonclustered index uq_site_data_container_id on site(data_container_id) where data_container_id is not null; +create unique nonclustered index uq_site_site_address_id on site(site_address_id) where site_address_id is not null; + +create table site_address ( + id uniqueidentifier not null, + street nvarchar(255), + city nvarchar(255), + zip_code nvarchar(255), + constraint pk_site_address primary key (id) +); + +create table some_enum_bean ( + id numeric(19) not null, + some_enum integer, + name nvarchar(255), + constraint ck_some_enum_bean_some_enum check ( some_enum in (0,1)), + constraint pk_some_enum_bean primary key (id) +); +create sequence some_enum_bean_seq as bigint start with 1 increment by 50; + +create table some_file_bean ( + id numeric(19) not null, + name nvarchar(255), + content image, + version numeric(19) not null, + constraint pk_some_file_bean primary key (id) +); +create sequence some_file_bean_seq as bigint start with 1 increment by 50; + +create table some_new_types_bean ( + id numeric(19) not null, + dow integer, + mth integer, + yr integer, + yr_mth date, + month_day date, + sql_date date, + sql_time time, + local_date date, + local_date_time datetime2, + offset_date_time datetime2, + zoned_date_time datetime2, + local_time time, + instant datetime2, + zone_id nvarchar(60), + zone_offset nvarchar(60), + path nvarchar(255), + period nvarchar(20), + duration numeric(19), + version numeric(19) not null, + constraint ck_some_new_types_bean_dow check ( dow in (1,2,3,4,5,6,7)), + constraint ck_some_new_types_bean_mth check ( mth in (1,2,3,4,5,6,7,8,9,10,11,12)), + constraint pk_some_new_types_bean primary key (id) +); +create sequence some_new_types_bean_seq as bigint start with 1 increment by 50; + +create table some_period_bean ( + id numeric(19) not null, + anniversary date, + version numeric(19) not null, + constraint pk_some_period_bean primary key (id) +); +create sequence some_period_bean_seq as bigint start with 1 increment by 50; + +create table source_base ( + dtype nvarchar(31) not null, + id uniqueidentifier not null, + name nvarchar(255), + pos integer not null, + target_id uniqueidentifier, + constraint pk_source_base primary key (id) +); + +create table stockforecast ( + type nvarchar(31) not null, + id numeric(19) not null, + inner_report_id numeric(19), + constraint pk_stockforecast primary key (id) +); +create sequence stockforecast_seq as bigint start with 1 increment by 50; + +create table sub_section ( + id integer not null, + section_id integer, + title nvarchar(255), + cretime datetime2 not null, + updtime datetime2 not null, + version numeric(19) not null, + constraint pk_sub_section primary key (id) +); +create sequence sub_section_seq as bigint start with 1 increment by 50; + +create table sub_type ( + sub_type_id integer not null, + description nvarchar(255), + version numeric(19) not null, + constraint pk_sub_type primary key (sub_type_id) +); +create sequence sub_type_seq as bigint start with 1 increment by 50; + +create table survey ( + id numeric(19) not null, + name nvarchar(255), + constraint pk_survey primary key (id) +); +create sequence survey_seq as bigint start with 1 increment by 50; + +create table tbytes_only ( + id integer not null, + content image, + constraint pk_tbytes_only primary key (id) +); +create sequence tbytes_only_seq as bigint start with 1 increment by 50; + +create table tcar ( + type nvarchar(31) not null, + plate_no nvarchar(32) not null, + truckload numeric(19), + constraint pk_tcar primary key (plate_no) +); + +create table tevent ( + id numeric(19) not null, + name nvarchar(255), + version numeric(19) not null, + constraint pk_tevent primary key (id) +); +create sequence tevent_seq as bigint start with 1 increment by 50; + +create table tevent_many ( + id numeric(19) not null, + description nvarchar(255), + event_id numeric(19), + units integer not null, + amount float(32) not null, + version numeric(19) not null, + constraint pk_tevent_many primary key (id) +); +create sequence tevent_many_seq as bigint start with 1 increment by 50; + +create table tevent_one ( + id numeric(19) not null, + name nvarchar(255), + status integer, + event_id numeric(19), + version numeric(19) not null, + constraint ck_tevent_one_status check ( status in (0,1)), + constraint pk_tevent_one primary key (id) +); +create unique nonclustered index uq_tevent_one_event_id on tevent_one(event_id) where event_id is not null; +create sequence tevent_one_seq as bigint start with 1 increment by 50; + +create table tint_root ( + my_type integer not null, + id integer not null, + name nvarchar(255), + child_property nvarchar(255), + constraint pk_tint_root primary key (id) +); +create sequence tint_root_seq as bigint start with 1 increment by 50; + +create table tjoda_entity ( + id integer not null, + local_time time, + constraint pk_tjoda_entity primary key (id) +); +create sequence tjoda_entity_seq as bigint start with 1 increment by 50; + +create table t_mapsuper1 ( + id integer not null, + something nvarchar(255), + name nvarchar(255), + version integer not null, + constraint pk_t_mapsuper1 primary key (id) +); +create sequence t_mapsuper1_seq as bigint start with 1 increment by 50; + +create table t_oneb ( + id integer not null, + name nvarchar(255), + description nvarchar(255), + active integer default 0 not null, + constraint pk_t_oneb primary key (id) +); +create sequence t_oneb_seq as bigint start with 1 increment by 50; + +create table t_detail_with_other_namexxxyy ( + id integer not null, + name nvarchar(255), + description nvarchar(255), + some_unique_value nvarchar(127), + active integer default 0 not null, + master_id integer, + constraint pk_t_detail_with_other_namexxxyy primary key (id) +); +create unique nonclustered index uq_t_detail_with_other_namexxxyy_some_unique_value on t_detail_with_other_namexxxyy(some_unique_value) where some_unique_value is not null; +create sequence t_detail_with_other_namexxxyy_seq as bigint start with 1 increment by 50; + +create table t_atable_thatisrelatively ( + id integer not null, + name nvarchar(255), + description nvarchar(255), + active integer default 0 not null, + constraint pk_t_atable_thatisrelatively primary key (id) +); +create sequence t_atable_thatisrelatively_seq as bigint start with 1 increment by 50; + +create table ttruck_holder ( + id numeric(19) not null, + name nvarchar(255), + truck_plate_no nvarchar(32) not null, + basic_id integer, + version numeric(19) not null, + constraint pk_ttruck_holder primary key (id) +); +create sequence ttruck_holder_seq as bigint start with 1 increment by 50; + +create table ttruck_holder_item ( + id numeric(19) not null, + some_uid uniqueidentifier, + foo nvarchar(255), + owner_id numeric(19) not null, + constraint pk_ttruck_holder_item primary key (id) +); +create sequence ttruck_holder_item_seq as bigint start with 1 increment by 50; + +create table tuuid_entity ( + id uniqueidentifier not null, + name nvarchar(255), + constraint pk_tuuid_entity primary key (id) +); + +create table twheel ( + id numeric(19) not null, + owner_plate_no nvarchar(32) not null, + constraint pk_twheel primary key (id) +); +create sequence twheel_seq as bigint start with 1 increment by 50; + +create table twith_pre_insert ( + id integer not null, + name nvarchar(255) not null, + title nvarchar(255), + constraint pk_twith_pre_insert primary key (id) +); +create sequence twith_pre_insert_seq as bigint start with 1 increment by 50; + +create table target_base ( + dtype nvarchar(31) not null, + id uniqueidentifier not null, + name nvarchar(255), + constraint pk_target_base primary key (id) +); + +create table mt_tenant ( + id uniqueidentifier not null, + name nvarchar(255), + version numeric(19) not null, + constraint pk_mt_tenant primary key (id) +); + +create table test_annotation_base_entity ( + direct nvarchar(255), + meta nvarchar(255), + mixed nvarchar(255), + constraint_annotation nvarchar(40), + null1 nvarchar(255) not null, + null2 nvarchar(255), + null3 nvarchar(255) +); + +create table tire ( + id numeric(19) not null, + wheel numeric(19), + version integer not null, + constraint pk_tire primary key (id) +); +create unique nonclustered index uq_tire_wheel on tire(wheel) where wheel is not null; +create sequence tire_seq as bigint start with 1 increment by 50; + +create table sa_tire ( + id numeric(19) not null, + version integer not null, + constraint pk_sa_tire primary key (id) +); +create sequence sa_tire_seq as bigint start with 1 increment by 50; + +create table tree_entity ( + id integer not null, + text nvarchar(255), + parent_id integer, + constraint pk_tree_entity primary key (id) +); +create sequence tree_entity_seq as bigint start with 1 increment by 50; + +create table trip ( + id integer not null, + vehicle_driver_id integer, + destination nvarchar(255), + address_id integer, + star_date datetime2, + cretime datetime2 not null, + updtime datetime2 not null, + version numeric(19) not null, + constraint pk_trip primary key (id) +); +create sequence trip_seq as bigint start with 1 increment by 50; + +create table truck_ref ( + id integer not null, + something nvarchar(255), + constraint pk_truck_ref primary key (id) +); +create sequence truck_ref_seq as bigint start with 1 increment by 50; + +create table tune ( + id numeric(19) not null, + name nvarchar(255), + constraint pk_tune primary key (id) +); +create sequence tune_seq as bigint start with 1 increment by 50; + +create table [type] ( + customer integer not null, + type integer not null, + description nvarchar(255), + sub_type_id integer, + version numeric(19) not null, + constraint pk_type primary key (customer,type) +); + +create table tz_bean ( + id numeric(19) not null, + moda nvarchar(255), + ts datetime2, + tstz datetime2, + constraint pk_tz_bean primary key (id) +); +create sequence tz_bean_seq as bigint start with 1 increment by 50; + +create table usib_child ( + id uniqueidentifier not null, + parent_id numeric(19), + deleted integer default 0 not null, + constraint pk_usib_child primary key (id) +); + +create table usib_child_sibling ( + id numeric(19) not null, + child_id uniqueidentifier, + deleted integer default 0 not null, + constraint pk_usib_child_sibling primary key (id) +); +create unique nonclustered index uq_usib_child_sibling_child_id on usib_child_sibling(child_id) where child_id is not null; +create sequence usib_child_sibling_seq as bigint start with 1 increment by 50; + +create table usib_parent ( + id numeric(19) not null, + deleted integer default 0 not null, + constraint pk_usib_parent primary key (id) +); +create sequence usib_parent_seq as bigint start with 1 increment by 50; + +create table ut_detail ( + id integer not null, + utmaster_id integer not null, + name nvarchar(255), + qty integer, + amount float(32), + version integer not null, + constraint pk_ut_detail primary key (id) +); +create sequence ut_detail_seq as bigint start with 1 increment by 50; + +create table ut_master ( + id integer not null, + name nvarchar(255), + description nvarchar(255), + event_date date, + version integer not null, + constraint pk_ut_master primary key (id) +); +create sequence ut_master_seq as bigint start with 1 increment by 50; + +create table uuone ( + id uniqueidentifier not null, + name nvarchar(255), + description nvarchar(255), + version numeric(19) not null, + constraint pk_uuone primary key (id) +); + +create table uutwo ( + id uniqueidentifier not null, + name nvarchar(255), + notes nvarchar(255), + master_id uniqueidentifier, + version numeric(19) not null, + constraint pk_uutwo primary key (id) +); + +create table oto_user ( + id numeric(19) not null, + name nvarchar(255), + account_id numeric(19) not null, + version numeric(19) not null, + when_created datetime2 not null, + when_modified datetime2 not null, + constraint uq_oto_user_account_id unique (account_id), + constraint pk_oto_user primary key (id) +); +create sequence oto_user_seq as bigint start with 1 increment by 50; + +create table c_user ( + id numeric(19) not null, + inactive integer default 0 not null, + name nvarchar(255), + email nvarchar(255), + password_hash nvarchar(255), + group_id numeric(19), + version numeric(19) not null, + when_created datetime2 not null, + when_modified datetime2 not null, + constraint pk_c_user primary key (id) +); +create sequence c_user_seq as bigint start with 1 increment by 50; + +create table tx_user ( + id numeric(19) not null, + name nvarchar(255), + constraint pk_tx_user primary key (id) +); +create sequence tx_user_seq as bigint start with 1 increment by 50; + +create table g_user ( + id numeric(19) not null, + username nvarchar(255), + version numeric(19) not null, + constraint pk_g_user primary key (id) +); +create sequence g_user_seq as bigint start with 1 increment by 50; + +create table em_user ( + id numeric(19) not null, + name nvarchar(255), + constraint pk_em_user primary key (id) +); +create sequence em_user_seq as bigint start with 1 increment by 50; + +create table user_interest_live ( + user_id numeric(19) not null, + live_id numeric(19) not null, + created_at datetime2 not null, + constraint pk_user_interest_live primary key (user_id,live_id) +); + +create table em_user_role ( + user_id numeric(19) not null, + role_id numeric(19) not null, + constraint pk_em_user_role primary key (user_id,role_id) +); + +create table vehicle ( + dtype nvarchar(3) not null, + id integer not null, + license_number nvarchar(255), + registration_date datetime2, + lease_id numeric(19), + cretime datetime2 not null, + updtime datetime2 not null, + version numeric(19) not null, + siz nvarchar(3), + driver nvarchar(255), + car_ref_id integer, + notes nvarchar(255), + truck_ref_id integer, + capacity float(32), + constraint ck_vehicle_siz check ( siz in ('S','M','L','H')), + constraint pk_vehicle primary key (id) +); +create sequence vehicle_seq as bigint start with 1 increment by 50; + +create table vehicle_driver ( + id integer not null, + name nvarchar(255), + vehicle_id integer, + address_id integer, + license_issued_on datetime2, + cretime datetime2 not null, + updtime datetime2 not null, + version numeric(19) not null, + constraint pk_vehicle_driver primary key (id) +); +create sequence vehicle_driver_seq as bigint start with 1 increment by 50; + +create table vehicle_lease ( + dtype nvarchar(31) not null, + id numeric(19) not null, + name nvarchar(255), + active_start date, + active_end date, + version numeric(19) not null, + bond numeric(28), + min_duration integer not null, + day_rate numeric(28), + max_days integer, + constraint pk_vehicle_lease primary key (id) +); +create sequence vehicle_lease_seq as bigint start with 1 increment by 50; + +create table warehouses ( + id integer not null, + officezoneid integer, + constraint pk_warehouses primary key (id) +); +create sequence warehouses_seq as bigint start with 1 increment by 50; + +create table warehousesshippingzones ( + warehouseid integer not null, + shippingzoneid integer not null, + constraint pk_warehousesshippingzones primary key (warehouseid,shippingzoneid) +); + +create table wheel ( + id numeric(19) not null, + version integer not null, + constraint pk_wheel primary key (id) +); +create sequence wheel_seq as bigint start with 1 increment by 50; + +create table sa_wheel ( + id numeric(19) not null, + tire numeric(19), + car numeric(19), + version integer not null, + constraint pk_sa_wheel primary key (id) +); +create sequence sa_wheel_seq as bigint start with 1 increment by 50; + +create table sp_car_wheel ( + id numeric(19) not null, + name nvarchar(255), + version integer not null, + constraint pk_sp_car_wheel primary key (id) +); +create sequence sp_car_wheel_seq as bigint start with 1 increment by 50; + +create table g_who_props_otm ( + id numeric(19) not null, + name nvarchar(255), + version numeric(19) not null, + when_created datetime2 not null, + when_modified datetime2 not null, + who_created_id numeric(19), + who_modified_id numeric(19), + constraint pk_g_who_props_otm primary key (id) +); +create sequence g_who_props_otm_seq as bigint start with 1 increment by 50; + +create table with_zero ( + id numeric(19) not null, + name nvarchar(255), + parent_id integer, + lang nvarchar(2) default 'en' not null, + version numeric(19) not null, + constraint pk_with_zero primary key (id) +); +create sequence with_zero_seq as bigint start with 1 increment by 50; + +create table parent ( + id integer not null, + name nvarchar(255), + constraint pk_parent primary key (id) +); +create sequence parent_seq as bigint start with 1 increment by 50; + +create table wview ( + id uniqueidentifier not null, + name nvarchar(127) not null, + constraint uq_wview_name unique (name), + constraint pk_wview primary key (id) +); + +create table zones ( + type nvarchar(31) not null, + id integer not null, + attribute nvarchar(255), + constraint pk_zones primary key (id) +); +create sequence zones_seq as bigint start with 1 increment by 50; + +create index ix_contact_last_name_first_name on contact (last_name,first_name); +create index ix_e_basic_name on e_basic (name); +create index ix_efile2_no_fk_owner_id on efile2_no_fk (owner_id); +create index ix_ecsm_values_host_id on ecsm_values (host_id); +create index ix_organization_node_kind on organization_node (kind); +create index ix_bar_foo_id on bar (foo_id); +alter table bar add constraint fk_bar_foo_id foreign key (foo_id) references foo (foo_id); + +create index ix_acl_container_relation_container_id on acl_container_relation (container_id); +alter table acl_container_relation add constraint fk_acl_container_relation_container_id foreign key (container_id) references contract (id); + +create index ix_acl_container_relation_acl_entry_id on acl_container_relation (acl_entry_id); +alter table acl_container_relation add constraint fk_acl_container_relation_acl_entry_id foreign key (acl_entry_id) references acl (id); + +create index ix_addr_employee_id on addr (employee_id); +alter table addr add constraint fk_addr_employee_id foreign key (employee_id) references empl (id); + +create index ix_o_address_country_code on o_address (country_code); +alter table o_address add constraint fk_o_address_country_code foreign key (country_code) references o_country (code); + +alter table album add constraint fk_album_cover_id foreign key (cover_id) references cover (id); + +create index ix_animal_shelter_id on animal (shelter_id); +alter table animal add constraint fk_animal_shelter_id foreign key (shelter_id) references animal_shelter (id); + +create index ix_attribute_attribute_holder_id on attribute (attribute_holder_id); +alter table attribute add constraint fk_attribute_attribute_holder_id foreign key (attribute_holder_id) references attribute_holder (id); + +create index ix_bbookmark_user_id on bbookmark (user_id); +alter table bbookmark add constraint fk_bbookmark_user_id foreign key (user_id) references bbookmark_user (id); + +create index ix_bbookmark_user_org_id on bbookmark_user (org_id); +alter table bbookmark_user add constraint fk_bbookmark_user_org_id foreign key (org_id) references bbookmark_org (id); + +create index ix_bsite_user_a_site_id on bsite_user_a (site_id); +alter table bsite_user_a add constraint fk_bsite_user_a_site_id foreign key (site_id) references bsite (id); + +create index ix_bsite_user_a_user_id on bsite_user_a (user_id); +alter table bsite_user_a add constraint fk_bsite_user_a_user_id foreign key (user_id) references buser (id); + +create index ix_bsite_user_b_site on bsite_user_b (site); +alter table bsite_user_b add constraint fk_bsite_user_b_site foreign key (site) references bsite (id); + +create index ix_bsite_user_b_usr on bsite_user_b (usr); +alter table bsite_user_b add constraint fk_bsite_user_b_usr foreign key (usr) references buser (id); + +create index ix_bsite_user_c_site_uid on bsite_user_c (site_uid); +alter table bsite_user_c add constraint fk_bsite_user_c_site_uid foreign key (site_uid) references bsite (id); + +create index ix_bsite_user_c_user_uid on bsite_user_c (user_uid); +alter table bsite_user_c add constraint fk_bsite_user_c_user_uid foreign key (user_uid) references buser (id); + +create index ix_bsite_user_e_site_id on bsite_user_e (site_id); +alter table bsite_user_e add constraint fk_bsite_user_e_site_id foreign key (site_id) references bsite (id); + +create index ix_bsite_user_e_user_id on bsite_user_e (user_id); +alter table bsite_user_e add constraint fk_bsite_user_e_user_id foreign key (user_id) references buser (id); + +alter table basic_draftable_bean add constraint fk_basic_draftable_bean_id foreign key (id) references basic_draftable_bean_draft (id); + +alter table drel_booking add constraint fk_drel_booking_agent_invoice foreign key (agent_invoice) references drel_invoice (id); + +alter table drel_booking add constraint fk_drel_booking_client_invoice foreign key (client_invoice) references drel_invoice (id); + +create index ix_cepproduct_category_category_id on cepproduct_category (category_id); +alter table cepproduct_category add constraint fk_cepproduct_category_category_id foreign key (category_id) references cepcategory (id); + +create index ix_cepproduct_category_product_id on cepproduct_category (product_id); +alter table cepproduct_category add constraint fk_cepproduct_category_product_id foreign key (product_id) references cepproduct (id); + +create index ix_cinh_ref_ref_id on cinh_ref (ref_id); +alter table cinh_ref add constraint fk_cinh_ref_ref_id foreign key (ref_id) references cinh_root (id); + +create index ix_ckey_detail_parent on ckey_detail (one_key,two_key); +alter table ckey_detail add constraint fk_ckey_detail_parent foreign key (one_key,two_key) references ckey_parent (one_key,two_key); + +create index ix_ckey_parent_assoc_id on ckey_parent (assoc_id); +alter table ckey_parent add constraint fk_ckey_parent_assoc_id foreign key (assoc_id) references ckey_assoc (id); + +create index ix_coone_many_coone_id on coone_many (coone_id); +alter table coone_many add constraint fk_coone_many_coone_id foreign key (coone_id) references coone (id); + +alter table coroot add constraint fk_coroot_one_id foreign key (one_id) references coone (id); + +create index ix_calculation_result_product_configuration_id on calculation_result (product_configuration_id); +alter table calculation_result add constraint fk_calculation_result_product_configuration_id foreign key (product_configuration_id) references configuration (id); + +create index ix_calculation_result_group_configuration_id on calculation_result (group_configuration_id); +alter table calculation_result add constraint fk_calculation_result_group_configuration_id foreign key (group_configuration_id) references configuration (id); + +create index ix_sp_car_car_wheels_sp_car_car on sp_car_car_wheels (car); +alter table sp_car_car_wheels add constraint fk_sp_car_car_wheels_sp_car_car foreign key (car) references sp_car_car (id); + +create index ix_sp_car_car_wheels_sp_car_wheel on sp_car_car_wheels (wheel); +alter table sp_car_car_wheels add constraint fk_sp_car_car_wheels_sp_car_wheel foreign key (wheel) references sp_car_wheel (id); + +create index ix_sp_car_car_doors_sp_car_car on sp_car_car_doors (car); +alter table sp_car_car_doors add constraint fk_sp_car_car_doors_sp_car_car foreign key (car) references sp_car_car (id); + +create index ix_sp_car_car_doors_sp_car_door on sp_car_car_doors (door); +alter table sp_car_car_doors add constraint fk_sp_car_car_doors_sp_car_door foreign key (door) references sp_car_door (id); + +create index ix_car_accessory_fuse_id on car_accessory (fuse_id); +alter table car_accessory add constraint fk_car_accessory_fuse_id foreign key (fuse_id) references car_fuse (id); + +create index ix_car_accessory_car_id on car_accessory (car_id); +alter table car_accessory add constraint fk_car_accessory_car_id foreign key (car_id) references vehicle (id); + +create index ix_category_surveyobjectid on category (surveyobjectid); +alter table category add constraint fk_category_surveyobjectid foreign key (surveyobjectid) references survey (id); + +alter table e_save_test_d add constraint fk_e_save_test_d_parent_id foreign key (parent_id) references e_save_test_c (id); + +create index ix_child_person_some_bean_id on child_person (some_bean_id); +alter table child_person add constraint fk_child_person_some_bean_id foreign key (some_bean_id) references e_basic (id); + +create index ix_child_person_parent_identifier on child_person (parent_identifier); +alter table child_person add constraint fk_child_person_parent_identifier foreign key (parent_identifier) references parent_person (identifier); + +create index ix_cke_client_user on cke_client (username,cod_cpny); +alter table cke_client add constraint fk_cke_client_user foreign key (username,cod_cpny) references cke_user (username,cod_cpny); + +alter table class_super_monkey add constraint fk_class_super_monkey_class_super foreign key (class_super_sid) references class_super (sid); + +alter table class_super_monkey add constraint fk_class_super_monkey_monkey foreign key (monkey_mid) references monkey (mid); + +create index ix_configuration_configurations_id on configuration (configurations_id); +alter table configuration add constraint fk_configuration_configurations_id foreign key (configurations_id) references configurations (id); + +create index ix_contact_customer_id on contact (customer_id); +alter table contact add constraint fk_contact_customer_id foreign key (customer_id) references o_customer (id); + +create index ix_contact_group_id on contact (group_id); +alter table contact add constraint fk_contact_group_id foreign key (group_id) references contact_group (id); + +create index ix_contact_note_contact_id on contact_note (contact_id); +alter table contact_note add constraint fk_contact_note_contact_id foreign key (contact_id) references contact (id); + +create index ix_contract_costs_position_id on contract_costs (position_id); +alter table contract_costs add constraint fk_contract_costs_position_id foreign key (position_id) references e_position (id); + +create index ix_c_conversation_group_id on c_conversation (group_id); +alter table c_conversation add constraint fk_c_conversation_group_id foreign key (group_id) references c_group (id); + +create index ix_o_customer_billing_address_id on o_customer (billing_address_id); +alter table o_customer add constraint fk_o_customer_billing_address_id foreign key (billing_address_id) references o_address (id); + +create index ix_o_customer_shipping_address_id on o_customer (shipping_address_id); +alter table o_customer add constraint fk_o_customer_shipping_address_id foreign key (shipping_address_id) references o_address (id); + +create index ix_dcredit_drol_dcredit on dcredit_drol (dcredit_id); +alter table dcredit_drol add constraint fk_dcredit_drol_dcredit foreign key (dcredit_id) references dcredit (id); + +create index ix_dcredit_drol_drol on dcredit_drol (drol_id); +alter table dcredit_drol add constraint fk_dcredit_drol_drol foreign key (drol_id) references drol (id); + +create index ix_dmachine_organisation_id on dmachine (organisation_id); +alter table dmachine add constraint fk_dmachine_organisation_id foreign key (organisation_id) references dorg (id); + +create index ix_d_machine_aux_use_machine_id on d_machine_aux_use (machine_id); +alter table d_machine_aux_use add constraint fk_d_machine_aux_use_machine_id foreign key (machine_id) references dmachine (id); + +create index ix_d_machine_stats_machine_id on d_machine_stats (machine_id); +alter table d_machine_stats add constraint fk_d_machine_stats_machine_id foreign key (machine_id) references dmachine (id); + +create index ix_d_machine_use_machine_id on d_machine_use (machine_id); +alter table d_machine_use add constraint fk_d_machine_use_machine_id foreign key (machine_id) references dmachine (id); + +create index ix_drot_drol_drot on drot_drol (drot_id); +alter table drot_drol add constraint fk_drot_drol_drot foreign key (drot_id) references drot (id); + +create index ix_drot_drol_drol on drot_drol (drol_id); +alter table drot_drol add constraint fk_drot_drol_drol foreign key (drol_id) references drol (id); + +create index ix_dc_detail_master_id on dc_detail (master_id); +alter table dc_detail add constraint fk_dc_detail_master_id foreign key (master_id) references dc_master (id); + +create index ix_dfk_cascade_one_id on dfk_cascade (one_id); +alter table dfk_cascade add constraint fk_dfk_cascade_one_id foreign key (one_id) references dfk_cascade_one (id) on delete cascade on update cascade; + +create index ix_dfk_set_null_one_id on dfk_set_null (one_id); +alter table dfk_set_null add constraint fk_dfk_set_null_one_id foreign key (one_id) references dfk_one (id) on delete set null on update set null; + +alter table doc add constraint fk_doc_id foreign key (id) references doc_draft (id); + +create index ix_doc_link_doc on doc_link (doc_id); +alter table doc_link add constraint fk_doc_link_doc foreign key (doc_id) references doc (id); + +create index ix_doc_link_link on doc_link (link_id); +alter table doc_link add constraint fk_doc_link_link foreign key (link_id) references link (id); + +alter table document add constraint fk_document_id foreign key (id) references document_draft (id); + +create index ix_document_organisation_id on document (organisation_id); +alter table document add constraint fk_document_organisation_id foreign key (organisation_id) references organisation (id); + +create index ix_document_draft_organisation_id on document_draft (organisation_id); +alter table document_draft add constraint fk_document_draft_organisation_id foreign key (organisation_id) references organisation (id); + +create index ix_document_media_document_id on document_media (document_id); +alter table document_media add constraint fk_document_media_document_id foreign key (document_id) references document (id); + +create index ix_document_media_draft_document_id on document_media_draft (document_id); +alter table document_media_draft add constraint fk_document_media_draft_document_id foreign key (document_id) references document_draft (id); + +create index ix_e_basicenc_relate_other_id on e_basicenc_relate (other_id); +alter table e_basicenc_relate add constraint fk_e_basicenc_relate_other_id foreign key (other_id) references e_basicenc (id); + +create index ix_ebasic_json_map_detail_owner_id on ebasic_json_map_detail (owner_id); +alter table ebasic_json_map_detail add constraint fk_ebasic_json_map_detail_owner_id foreign key (owner_id) references ebasic_json_map (id); + +create index ix_ebasic_no_sdchild_owner_id on ebasic_no_sdchild (owner_id); +alter table ebasic_no_sdchild add constraint fk_ebasic_no_sdchild_owner_id foreign key (owner_id) references ebasic_soft_delete (id); + +create index ix_ebasic_sdchild_owner_id on ebasic_sdchild (owner_id); +alter table ebasic_sdchild add constraint fk_ebasic_sdchild_owner_id foreign key (owner_id) references ebasic_soft_delete (id); + +create index ix_ecache_child_root_id on ecache_child (root_id); +alter table ecache_child add constraint fk_ecache_child_root_id foreign key (root_id) references ecache_root (id); + +alter table edefault_prop add constraint fk_edefault_prop_e_simple_usertypeid foreign key (e_simple_usertypeid) references esimple (usertypeid); + +create index ix_eemb_inner_outer_id on eemb_inner (outer_id); +alter table eemb_inner add constraint fk_eemb_inner_outer_id foreign key (outer_id) references eemb_outer (id); + +create index ix_einvoice_person_id on einvoice (person_id); +alter table einvoice add constraint fk_einvoice_person_id foreign key (person_id) references eperson (id); + +create index ix_enull_collection_detail_enull_collection_id on enull_collection_detail (enull_collection_id); +alter table enull_collection_detail add constraint fk_enull_collection_detail_enull_collection_id foreign key (enull_collection_id) references enull_collection (id); + +create index ix_eopt_one_a_b_id on eopt_one_a (b_id); +alter table eopt_one_a add constraint fk_eopt_one_a_b_id foreign key (b_id) references eopt_one_b (id); + +create index ix_eopt_one_b_c_id on eopt_one_b (c_id); +alter table eopt_one_b add constraint fk_eopt_one_b_c_id foreign key (c_id) references eopt_one_c (id); + +create index ix_eper_addr_ma_country_code on eper_addr (ma_country_code); +alter table eper_addr add constraint fk_eper_addr_ma_country_code foreign key (ma_country_code) references o_country (code); + +create index ix_esoft_del_book_lend_by_id on esoft_del_book (lend_by_id); +alter table esoft_del_book add constraint fk_esoft_del_book_lend_by_id foreign key (lend_by_id) references esoft_del_user (id); + +create index ix_esoft_del_book_esoft_del_user_esoft_del_book on esoft_del_book_esoft_del_user (esoft_del_book_id); +alter table esoft_del_book_esoft_del_user add constraint fk_esoft_del_book_esoft_del_user_esoft_del_book foreign key (esoft_del_book_id) references esoft_del_book (id); + +create index ix_esoft_del_book_esoft_del_user_esoft_del_user on esoft_del_book_esoft_del_user (esoft_del_user_id); +alter table esoft_del_book_esoft_del_user add constraint fk_esoft_del_book_esoft_del_user_esoft_del_user foreign key (esoft_del_user_id) references esoft_del_user (id); + +create index ix_esoft_del_down_esoft_del_mid_id on esoft_del_down (esoft_del_mid_id); +alter table esoft_del_down add constraint fk_esoft_del_down_esoft_del_mid_id foreign key (esoft_del_mid_id) references esoft_del_mid (id); + +create index ix_esoft_del_mid_top_id on esoft_del_mid (top_id); +alter table esoft_del_mid add constraint fk_esoft_del_mid_top_id foreign key (top_id) references esoft_del_top (id); + +create index ix_esoft_del_mid_up_id on esoft_del_mid (up_id); +alter table esoft_del_mid add constraint fk_esoft_del_mid_up_id foreign key (up_id) references esoft_del_up (id); + +alter table esoft_del_one_a add constraint fk_esoft_del_one_a_oneb_id foreign key (oneb_id) references esoft_del_one_b (id); + +create index ix_esoft_del_role_esoft_del_user_esoft_del_role on esoft_del_role_esoft_del_user (esoft_del_role_id); +alter table esoft_del_role_esoft_del_user add constraint fk_esoft_del_role_esoft_del_user_esoft_del_role foreign key (esoft_del_role_id) references esoft_del_role (id); + +create index ix_esoft_del_role_esoft_del_user_esoft_del_user on esoft_del_role_esoft_del_user (esoft_del_user_id); +alter table esoft_del_role_esoft_del_user add constraint fk_esoft_del_role_esoft_del_user_esoft_del_user foreign key (esoft_del_user_id) references esoft_del_user (id); + +create index ix_esoft_del_user_esoft_del_role_esoft_del_user on esoft_del_user_esoft_del_role (esoft_del_user_id); +alter table esoft_del_user_esoft_del_role add constraint fk_esoft_del_user_esoft_del_role_esoft_del_user foreign key (esoft_del_user_id) references esoft_del_user (id); + +create index ix_esoft_del_user_esoft_del_role_esoft_del_role on esoft_del_user_esoft_del_role (esoft_del_role_id); +alter table esoft_del_user_esoft_del_role add constraint fk_esoft_del_user_esoft_del_role_esoft_del_role foreign key (esoft_del_role_id) references esoft_del_role (id); + +create index ix_rawinherit_uncle_parent_id on rawinherit_uncle (parent_id); +alter table rawinherit_uncle add constraint fk_rawinherit_uncle_parent_id foreign key (parent_id) references rawinherit_parent (id); + +create index ix_evanilla_collection_detail_evanilla_collection_id on evanilla_collection_detail (evanilla_collection_id); +alter table evanilla_collection_detail add constraint fk_evanilla_collection_detail_evanilla_collection_id foreign key (evanilla_collection_id) references evanilla_collection (id); + +create index ix_ec_enum_person_tags_ec_enum_person_id on ec_enum_person_tags (ec_enum_person_id); +alter table ec_enum_person_tags add constraint fk_ec_enum_person_tags_ec_enum_person_id foreign key (ec_enum_person_id) references ec_enum_person (id); + +create index ix_ec_person_phone_owner_id on ec_person_phone (owner_id); +alter table ec_person_phone add constraint fk_ec_person_phone_owner_id foreign key (owner_id) references ec_person (id); + +create index ix_ec_top_person_id on ec_top (person_id); +alter table ec_top add constraint fk_ec_top_person_id foreign key (person_id) references ecs_person (id); + +create index ix_ec_top_ecs_person_ec_top on ec_top_ecs_person (ec_top_id); +alter table ec_top_ecs_person add constraint fk_ec_top_ecs_person_ec_top foreign key (ec_top_id) references ec_top (id); + +create index ix_ec_top_ecs_person_ecs_person on ec_top_ecs_person (ecs_person_id); +alter table ec_top_ecs_person add constraint fk_ec_top_ecs_person_ecs_person foreign key (ecs_person_id) references ecs_person (id); + +create index ix_ecbl_person_phone_numbers_person_id on ecbl_person_phone_numbers (person_id); +alter table ecbl_person_phone_numbers add constraint fk_ecbl_person_phone_numbers_person_id foreign key (person_id) references ecbl_person (id); + +create index ix_ecbm_person_phone_numbers_person_id on ecbm_person_phone_numbers (person_id); +alter table ecbm_person_phone_numbers add constraint fk_ecbm_person_phone_numbers_person_id foreign key (person_id) references ecbm_person (id); + +create index ix_ecm_person_phone_numbers_ecm_person_id on ecm_person_phone_numbers (ecm_person_id); +alter table ecm_person_phone_numbers add constraint fk_ecm_person_phone_numbers_ecm_person_id foreign key (ecm_person_id) references ecm_person (id); + +create index ix_ecmc_person_phone_numbers_ecmc_person_id on ecmc_person_phone_numbers (ecmc_person_id); +alter table ecmc_person_phone_numbers add constraint fk_ecmc_person_phone_numbers_ecmc_person_id foreign key (ecmc_person_id) references ecmc_person (id); + +create index ix_ecs_person_phone_ecs_person_id on ecs_person_phone (ecs_person_id); +alter table ecs_person_phone add constraint fk_ecs_person_phone_ecs_person_id foreign key (ecs_person_id) references ecs_person (id); + +create index ix_ecsm_child_ecsm_parent_id on ecsm_child (ecsm_parent_id); +alter table ecsm_child add constraint fk_ecsm_child_ecsm_parent_id foreign key (ecsm_parent_id) references ecsm_parent (id); + +create index ix_td_child_parent_id on td_child (parent_id); +alter table td_child add constraint fk_td_child_parent_id foreign key (parent_id) references td_parent (parent_id); + +create index ix_element_bean_complex_bean_id on element_bean (complex_bean_id); +alter table element_bean add constraint fk_element_bean_complex_bean_id foreign key (complex_bean_id) references root_bean (id); + +create index ix_empl_default_address_id on empl (default_address_id); +alter table empl add constraint fk_empl_default_address_id foreign key (default_address_id) references addr (id); + +create index ix_esd_detail_master_id on esd_detail (master_id); +alter table esd_detail add constraint fk_esd_detail_master_id foreign key (master_id) references esd_master (id); + +create index ix_grand_parent_person_some_bean_id on grand_parent_person (some_bean_id); +alter table grand_parent_person add constraint fk_grand_parent_person_some_bean_id foreign key (some_bean_id) references e_basic (id); + +create index ix_survey_group_categoryobjectid on survey_group (categoryobjectid); +alter table survey_group add constraint fk_survey_group_categoryobjectid foreign key (categoryobjectid) references category (id); + +create index ix_hx_link_doc_hx_link on hx_link_doc (hx_link_id); +alter table hx_link_doc add constraint fk_hx_link_doc_hx_link foreign key (hx_link_id) references hx_link (id); + +create index ix_hx_link_doc_he_doc on hx_link_doc (he_doc_id); +alter table hx_link_doc add constraint fk_hx_link_doc_he_doc foreign key (he_doc_id) references he_doc (id); + +create index ix_hi_link_doc_hi_link on hi_link_doc (hi_link_id); +alter table hi_link_doc add constraint fk_hi_link_doc_hi_link foreign key (hi_link_id) references hi_link (id); + +create index ix_hi_link_doc_hi_doc on hi_link_doc (hi_doc_id); +alter table hi_link_doc add constraint fk_hi_link_doc_hi_doc foreign key (hi_doc_id) references hi_doc (id); + +create index ix_hi_tthree_hi_ttwo_id on hi_tthree (hi_ttwo_id); +alter table hi_tthree add constraint fk_hi_tthree_hi_ttwo_id foreign key (hi_ttwo_id) references hi_ttwo (id); + +create index ix_hi_ttwo_hi_tone_id on hi_ttwo (hi_tone_id); +alter table hi_ttwo add constraint fk_hi_ttwo_hi_tone_id foreign key (hi_tone_id) references hi_tone (id); + +alter table hsd_setting add constraint fk_hsd_setting_user_id foreign key (user_id) references hsd_user (id); + +create index ix_iaf_segment_status_id on iaf_segment (status_id); +alter table iaf_segment add constraint fk_iaf_segment_status_id foreign key (status_id) references iaf_segment_status (id); + +create index ix_imrelated_owner_id on imrelated (owner_id); +alter table imrelated add constraint fk_imrelated_owner_id foreign key (owner_id) references imroot (id); + +create index ix_info_contact_company_id on info_contact (company_id); +alter table info_contact add constraint fk_info_contact_company_id foreign key (company_id) references info_company (id); + +alter table info_customer add constraint fk_info_customer_company_id foreign key (company_id) references info_company (id); + +alter table inner_report add constraint fk_inner_report_forecast_id foreign key (forecast_id) references stockforecast (id); + +create index ix_drel_invoice_booking on drel_invoice (booking); +alter table drel_invoice add constraint fk_drel_invoice_booking foreign key (booking) references drel_booking (id); + +create index ix_item_etype on item (customer,type); +alter table item add constraint fk_item_etype foreign key (customer,type) references [type] (customer,type); + +create index ix_item_eregion on item (customer,region); +alter table item add constraint fk_item_eregion foreign key (customer,region) references region (customer,type); + +alter table mkeygroup_monkey add constraint fk_mkeygroup_monkey_mkeygroup foreign key (mkeygroup_pid) references mkeygroup (pid); + +alter table mkeygroup_monkey add constraint fk_mkeygroup_monkey_monkey foreign key (monkey_mid) references monkey (mid); + +alter table trainer_monkey add constraint fk_trainer_monkey_trainer foreign key (trainer_tid) references trainer (tid); + +alter table trainer_monkey add constraint fk_trainer_monkey_monkey foreign key (monkey_mid) references monkey (mid); + +alter table troop_monkey add constraint fk_troop_monkey_troop foreign key (troop_pid) references troop (pid); + +alter table troop_monkey add constraint fk_troop_monkey_monkey foreign key (monkey_mid) references monkey (mid); + +create index ix_l2_cldf_reset_bean_child_parent_id on l2_cldf_reset_bean_child (parent_id); +alter table l2_cldf_reset_bean_child add constraint fk_l2_cldf_reset_bean_child_parent_id foreign key (parent_id) references l2_cldf_reset_bean (id); + +create index ix_level1_level4_level1 on level1_level4 (level1_id); +alter table level1_level4 add constraint fk_level1_level4_level1 foreign key (level1_id) references level1 (id); + +create index ix_level1_level4_level4 on level1_level4 (level4_id); +alter table level1_level4 add constraint fk_level1_level4_level4 foreign key (level4_id) references level4 (id); + +create index ix_level1_level2_level1 on level1_level2 (level1_id); +alter table level1_level2 add constraint fk_level1_level2_level1 foreign key (level1_id) references level1 (id); + +create index ix_level1_level2_level2 on level1_level2 (level2_id); +alter table level1_level2 add constraint fk_level1_level2_level2 foreign key (level2_id) references level2 (id); + +create index ix_level2_level3_level2 on level2_level3 (level2_id); +alter table level2_level3 add constraint fk_level2_level3_level2 foreign key (level2_id) references level2 (id); + +create index ix_level2_level3_level3 on level2_level3 (level3_id); +alter table level2_level3 add constraint fk_level2_level3_level3 foreign key (level3_id) references level3 (id); + +alter table link add constraint fk_link_id foreign key (id) references link_draft (id); + +create index ix_la_attr_value_attribute_la_attr_value on la_attr_value_attribute (la_attr_value_id); +alter table la_attr_value_attribute add constraint fk_la_attr_value_attribute_la_attr_value foreign key (la_attr_value_id) references la_attr_value (id); + +create index ix_la_attr_value_attribute_attribute on la_attr_value_attribute (attribute_id); +alter table la_attr_value_attribute add constraint fk_la_attr_value_attribute_attribute foreign key (attribute_id) references attribute (id); + +create index ix_looney_tune_id on looney (tune_id); +alter table looney add constraint fk_looney_tune_id foreign key (tune_id) references tune (id); + +create index ix_mcontact_customer_id on mcontact (customer_id); +alter table mcontact add constraint fk_mcontact_customer_id foreign key (customer_id) references mcustomer (id); + +create index ix_mcontact_message_contact_id on mcontact_message (contact_id); +alter table mcontact_message add constraint fk_mcontact_message_contact_id foreign key (contact_id) references mcontact (id); + +create index ix_mcustomer_shipping_address_id on mcustomer (shipping_address_id); +alter table mcustomer add constraint fk_mcustomer_shipping_address_id foreign key (shipping_address_id) references maddress (id); + +create index ix_mcustomer_billing_address_id on mcustomer (billing_address_id); +alter table mcustomer add constraint fk_mcustomer_billing_address_id foreign key (billing_address_id) references maddress (id); + +create index ix_mmachine_mgroup_mmachine on mmachine_mgroup (mmachine_id); +alter table mmachine_mgroup add constraint fk_mmachine_mgroup_mmachine foreign key (mmachine_id) references mmachine (id); + +create index ix_mmachine_mgroup_mgroup on mmachine_mgroup (mgroup_id); +alter table mmachine_mgroup add constraint fk_mmachine_mgroup_mgroup foreign key (mgroup_id) references mgroup (id); + +create index ix_mprinter_current_state_id on mprinter (current_state_id); +alter table mprinter add constraint fk_mprinter_current_state_id foreign key (current_state_id) references mprinter_state (id); + +alter table mprinter add constraint fk_mprinter_last_swap_cyan_id foreign key (last_swap_cyan_id) references mprinter_state (id); + +alter table mprinter add constraint fk_mprinter_last_swap_magenta_id foreign key (last_swap_magenta_id) references mprinter_state (id); + +alter table mprinter add constraint fk_mprinter_last_swap_yellow_id foreign key (last_swap_yellow_id) references mprinter_state (id); + +alter table mprinter add constraint fk_mprinter_last_swap_black_id foreign key (last_swap_black_id) references mprinter_state (id); + +create index ix_mprinter_state_printer_id on mprinter_state (printer_id); +alter table mprinter_state add constraint fk_mprinter_state_printer_id foreign key (printer_id) references mprinter (id); + +create index ix_mprofile_picture_id on mprofile (picture_id); +alter table mprofile add constraint fk_mprofile_picture_id foreign key (picture_id) references mmedia (id); + +create index ix_mrole_muser_mrole on mrole_muser (mrole_roleid); +alter table mrole_muser add constraint fk_mrole_muser_mrole foreign key (mrole_roleid) references mrole (roleid); + +create index ix_mrole_muser_muser on mrole_muser (muser_userid); +alter table mrole_muser add constraint fk_mrole_muser_muser foreign key (muser_userid) references muser (userid); + +create index ix_muser_user_type_id on muser (user_type_id); +alter table muser add constraint fk_muser_user_type_id foreign key (user_type_id) references muser_type (id); + +create index ix_mail_user_inbox_mail_user on mail_user_inbox (mail_user_id); +alter table mail_user_inbox add constraint fk_mail_user_inbox_mail_user foreign key (mail_user_id) references mail_user (id); + +create index ix_mail_user_inbox_mail_box on mail_user_inbox (mail_box_id); +alter table mail_user_inbox add constraint fk_mail_user_inbox_mail_box foreign key (mail_box_id) references mail_box (id); + +create index ix_mail_user_outbox_mail_user on mail_user_outbox (mail_user_id); +alter table mail_user_outbox add constraint fk_mail_user_outbox_mail_user foreign key (mail_user_id) references mail_user (id); + +create index ix_mail_user_outbox_mail_box on mail_user_outbox (mail_box_id); +alter table mail_user_outbox add constraint fk_mail_user_outbox_mail_box foreign key (mail_box_id) references mail_box (id); + +create index ix_c_message_conversation_id on c_message (conversation_id); +alter table c_message add constraint fk_c_message_conversation_id foreign key (conversation_id) references c_conversation (id); + +create index ix_c_message_user_id on c_message (user_id); +alter table c_message add constraint fk_c_message_user_id foreign key (user_id) references c_user (id); + +alter table meter_contract_data add constraint fk_meter_contract_data_special_needs_client_id foreign key (special_needs_client_id) references meter_special_needs_client (id); + +alter table meter_special_needs_client add constraint fk_meter_special_needs_client_primary_id foreign key (primary_id) references meter_special_needs_contact (id); + +alter table meter_version add constraint fk_meter_version_address_data_id foreign key (address_data_id) references meter_address_data (id); + +alter table meter_version add constraint fk_meter_version_contract_data_id foreign key (contract_data_id) references meter_contract_data (id); + +create index ix_mnoc_user_mnoc_role_mnoc_user on mnoc_user_mnoc_role (mnoc_user_user_id); +alter table mnoc_user_mnoc_role add constraint fk_mnoc_user_mnoc_role_mnoc_user foreign key (mnoc_user_user_id) references mnoc_user (user_id); + +create index ix_mnoc_user_mnoc_role_mnoc_role on mnoc_user_mnoc_role (mnoc_role_role_id); +alter table mnoc_user_mnoc_role add constraint fk_mnoc_user_mnoc_role_mnoc_role foreign key (mnoc_role_role_id) references mnoc_role (role_id); + +create index ix_mny_b_a_id on mny_b (a_id); +alter table mny_b add constraint fk_mny_b_a_id foreign key (a_id) references mny_a (id); + +create index ix_mny_b_mny_c_mny_b on mny_b_mny_c (mny_b_id); +alter table mny_b_mny_c add constraint fk_mny_b_mny_c_mny_b foreign key (mny_b_id) references mny_b (id); + +create index ix_mny_b_mny_c_mny_c on mny_b_mny_c (mny_c_id); +alter table mny_b_mny_c add constraint fk_mny_b_mny_c_mny_c foreign key (mny_c_id) references mny_c (id); + +create index ix_subtopics_mny_topic_1 on subtopics (topic); +alter table subtopics add constraint fk_subtopics_mny_topic_1 foreign key (topic) references mny_topic (id); + +create index ix_subtopics_mny_topic_2 on subtopics (subtopic); +alter table subtopics add constraint fk_subtopics_mny_topic_2 foreign key (subtopic) references mny_topic (id); + +create index ix_mp_role_mp_user_id on mp_role (mp_user_id); +alter table mp_role add constraint fk_mp_role_mp_user_id foreign key (mp_user_id) references mp_user (id); + +create index ix_ms_many_a_many_b_ms_many_a on ms_many_a_many_b (ms_many_a_aid); +alter table ms_many_a_many_b add constraint fk_ms_many_a_many_b_ms_many_a foreign key (ms_many_a_aid) references ms_many_a (aid); + +create index ix_ms_many_a_many_b_ms_many_b on ms_many_a_many_b (ms_many_b_bid); +alter table ms_many_a_many_b add constraint fk_ms_many_a_many_b_ms_many_b foreign key (ms_many_b_bid) references ms_many_b (bid); + +create index ix_ms_many_b_many_a_ms_many_b on ms_many_b_many_a (ms_many_b_bid); +alter table ms_many_b_many_a add constraint fk_ms_many_b_many_a_ms_many_b foreign key (ms_many_b_bid) references ms_many_b (bid); + +create index ix_ms_many_b_many_a_ms_many_a on ms_many_b_many_a (ms_many_a_aid); +alter table ms_many_b_many_a add constraint fk_ms_many_b_many_a_ms_many_a foreign key (ms_many_a_aid) references ms_many_a (aid); + +create index ix_my_lob_size_join_many_parent_id on my_lob_size_join_many (parent_id); +alter table my_lob_size_join_many add constraint fk_my_lob_size_join_many_parent_id foreign key (parent_id) references my_lob_size (id); + +create index ix_o_bean_child_cached_bean_id on o_bean_child (cached_bean_id); +alter table o_bean_child add constraint fk_o_bean_child_cached_bean_id foreign key (cached_bean_id) references o_cached_bean (id); + +create index ix_ocached_app_detail_app_id on ocached_app_detail (app_id); +alter table ocached_app_detail add constraint fk_ocached_app_detail_app_id foreign key (app_id) references ocached_app (id); + +create index ix_o_cached_bean_country_o_cached_bean on o_cached_bean_country (o_cached_bean_id); +alter table o_cached_bean_country add constraint fk_o_cached_bean_country_o_cached_bean foreign key (o_cached_bean_id) references o_cached_bean (id); + +create index ix_o_cached_bean_country_o_country on o_cached_bean_country (o_country_code); +alter table o_cached_bean_country add constraint fk_o_cached_bean_country_o_country foreign key (o_country_code) references o_country (code); + +create index ix_o_cached_bean_child_cached_bean_id on o_cached_bean_child (cached_bean_id); +alter table o_cached_bean_child add constraint fk_o_cached_bean_child_cached_bean_id foreign key (cached_bean_id) references o_cached_bean (id); + +alter table oengine add constraint fk_oengine_car_id foreign key (car_id) references ocar (id); + +alter table ogear_box add constraint fk_ogear_box_car_id foreign key (car_id) references ocar (id); + +create index ix_omvertex_other_omvertex_id on omvertex_other (omvertex_id); +alter table omvertex_other add constraint fk_omvertex_other_omvertex_id foreign key (omvertex_id) references omvertex (id); + +alter table oroad_show_msg add constraint fk_oroad_show_msg_company_id foreign key (company_id) references ocompany (id); + +create index ix_om_account_child_dbo_banana_rama_id on om_account_child_dbo (banana_rama_id); +alter table om_account_child_dbo add constraint fk_om_account_child_dbo_banana_rama_id foreign key (banana_rama_id) references om_account_dbo (id); + +create index ix_om_basic_child_parent_id on om_basic_child (parent_id); +alter table om_basic_child add constraint fk_om_basic_child_parent_id foreign key (parent_id) references om_basic_parent (id); + +create index ix_om_ordered_detail_master_id on om_ordered_detail (master_id); +alter table om_ordered_detail add constraint fk_om_ordered_detail_master_id foreign key (master_id) references om_ordered_master (id); + +create index ix_o_order_kcustomer_id on o_order (kcustomer_id); +alter table o_order add constraint fk_o_order_kcustomer_id foreign key (kcustomer_id) references o_customer (id); + +create index ix_o_order_detail_order_id on o_order_detail (order_id); +alter table o_order_detail add constraint fk_o_order_detail_order_id foreign key (order_id) references o_order (id); + +create index ix_o_order_detail_product_id on o_order_detail (product_id); +alter table o_order_detail add constraint fk_o_order_detail_product_id foreign key (product_id) references o_product (id); + +create index ix_s_order_items_order_uuid on s_order_items (order_uuid); +alter table s_order_items add constraint fk_s_order_items_order_uuid foreign key (order_uuid) references s_orders (uuid); + +create index ix_or_order_ship_order_id on or_order_ship (order_id); +alter table or_order_ship add constraint fk_or_order_ship_order_id foreign key (order_id) references o_order (id); + +alter table organization_node add constraint fk_organization_node_parent_tree_node_id foreign key (parent_tree_node_id) references organization_tree_node (id); + +create index ix_orp_detail_master_id on orp_detail (master_id); +alter table orp_detail add constraint fk_orp_detail_master_id foreign key (master_id) references orp_master (id); + +create index ix_orp_detail2_orp_master2_id on orp_detail2 (orp_master2_id); +alter table orp_detail2 add constraint fk_orp_detail2_orp_master2_id foreign key (orp_master2_id) references orp_master2 (id); + +alter table oto_atwo add constraint fk_oto_atwo_aone_id foreign key (aone_id) references oto_aone (id); + +alter table oto_bchild add constraint fk_oto_bchild_master_id foreign key (master_id) references oto_bmaster (id); + +alter table oto_child add constraint fk_oto_child_master_id foreign key (master_id) references oto_master (id); + +alter table oto_cust_address add constraint fk_oto_cust_address_customer_cid foreign key (customer_cid) references oto_cust (cid); + +alter table oto_level_a add constraint fk_oto_level_a_b_id foreign key (b_id) references oto_level_b (id); + +alter table oto_level_b add constraint fk_oto_level_b_c_id foreign key (c_id) references oto_level_c (id); + +alter table oto_prime_extra add constraint fk_oto_prime_extra_eid foreign key (eid) references oto_prime (pid); + +alter table oto_sd_child add constraint fk_oto_sd_child_master_id foreign key (master_id) references oto_sd_master (id); + +create index ix_oto_th_many_oto_th_top_id on oto_th_many (oto_th_top_id); +alter table oto_th_many add constraint fk_oto_th_many_oto_th_top_id foreign key (oto_th_top_id) references oto_th_top (id); + +alter table oto_th_one add constraint fk_oto_th_one_many_id foreign key (many_id) references oto_th_many (id); + +alter table oto_ubprime_extra add constraint fk_oto_ubprime_extra_eid foreign key (eid) references oto_ubprime (pid); + +alter table oto_user_model add constraint fk_oto_user_model_user_optional_id foreign key (user_optional_id) references oto_user_model_optional (id); + +alter table pfile add constraint fk_pfile_file_content_id foreign key (file_content_id) references pfile_content (id); + +alter table pfile add constraint fk_pfile_file_content2_id foreign key (file_content2_id) references pfile_content (id); + +alter table paggview add constraint fk_paggview_pview_id foreign key (pview_id) references pp (id); + +create index ix_pallet_location_zone_sid on pallet_location (zone_sid); +alter table pallet_location add constraint fk_pallet_location_zone_sid foreign key (zone_sid) references zones (id); + +alter table parcel_location add constraint fk_parcel_location_parcelid foreign key (parcelid) references parcel (parcelid); + +create index ix_rawinherit_parent_rawinherit_data_rawinherit_parent on rawinherit_parent_rawinherit_data (rawinherit_parent_id); +alter table rawinherit_parent_rawinherit_data add constraint fk_rawinherit_parent_rawinherit_data_rawinherit_parent foreign key (rawinherit_parent_id) references rawinherit_parent (id); + +create index ix_rawinherit_parent_rawinherit_data_rawinherit_data on rawinherit_parent_rawinherit_data (rawinherit_data_id); +alter table rawinherit_parent_rawinherit_data add constraint fk_rawinherit_parent_rawinherit_data_rawinherit_data foreign key (rawinherit_data_id) references rawinherit_data (id); + +create index ix_parent_person_some_bean_id on parent_person (some_bean_id); +alter table parent_person add constraint fk_parent_person_some_bean_id foreign key (some_bean_id) references e_basic (id); + +create index ix_parent_person_parent_identifier on parent_person (parent_identifier); +alter table parent_person add constraint fk_parent_person_parent_identifier foreign key (parent_identifier) references grand_parent_person (identifier); + +create index ix_c_participation_conversation_id on c_participation (conversation_id); +alter table c_participation add constraint fk_c_participation_conversation_id foreign key (conversation_id) references c_conversation (id); + +create index ix_c_participation_user_id on c_participation (user_id); +alter table c_participation add constraint fk_c_participation_user_id foreign key (user_id) references c_user (id); + +create index ix_pcf_calendar_pcf_person_id on pcf_calendar (pcf_person_id); +alter table pcf_calendar add constraint fk_pcf_calendar_pcf_person_id foreign key (pcf_person_id) references pcf_person (id); + +create index ix_pcf_city_pcf_country_id on pcf_city (pcf_country_id); +alter table pcf_city add constraint fk_pcf_city_pcf_country_id foreign key (pcf_country_id) references pcf_country (id); + +alter table pcf_city add constraint fk_pcf_city_mayor_id foreign key (mayor_id) references pcf_person (id); + +alter table pcf_city add constraint fk_pcf_city_vice_mayor_id foreign key (vice_mayor_id) references pcf_person (id); + +create index ix_pcf_event_pcf_calendar_id on pcf_event (pcf_calendar_id); +alter table pcf_event add constraint fk_pcf_event_pcf_calendar_id foreign key (pcf_calendar_id) references pcf_calendar (id); + +alter table persistent_file_content add constraint fk_persistent_file_content_persistent_file_id foreign key (persistent_file_id) references persistent_file (id); + +create index ix_person_default_address_oid on person (default_address_oid); +alter table person add constraint fk_person_default_address_oid foreign key (default_address_oid) references address (oid); + +create index ix_person_cache_email_person_info_person_id on person_cache_email (person_info_person_id); +alter table person_cache_email add constraint fk_person_cache_email_person_info_person_id foreign key (person_info_person_id) references person_cache_info (person_id); + +create index ix_phones_person_id on phones (person_id); +alter table phones add constraint fk_phones_person_id foreign key (person_id) references persons (id); + +create index ix_e_position_contract_id on e_position (contract_id); +alter table e_position add constraint fk_e_position_contract_id foreign key (contract_id) references contract (id); + +create index ix_pp_to_ww_pp on pp_to_ww (pp_id); +alter table pp_to_ww add constraint fk_pp_to_ww_pp foreign key (pp_id) references pp (id); + +create index ix_pp_to_ww_wview on pp_to_ww (ww_id); +alter table pp_to_ww add constraint fk_pp_to_ww_wview foreign key (ww_id) references wview (id); + +create index ix_question_groupobjectid on question (groupobjectid); +alter table question add constraint fk_question_groupobjectid foreign key (groupobjectid) references survey_group (id); + +create index ix_r_orders_customer on r_orders (company,customername); +alter table r_orders add constraint fk_r_orders_customer foreign key (company,customername) references rcustomer (company,name); + +create index ix_rel_master_detail_id on rel_master (detail_id); +alter table rel_master add constraint fk_rel_master_detail_id foreign key (detail_id) references rel_detail (id); + +create index ix_resourcefile_parentresourcefileid on resourcefile (parentresourcefileid); +alter table resourcefile add constraint fk_resourcefile_parentresourcefileid foreign key (parentresourcefileid) references resourcefile (id); + +create index ix_mt_role_tenant_id on mt_role (tenant_id); +alter table mt_role add constraint fk_mt_role_tenant_id foreign key (tenant_id) references mt_tenant (id); + +create index ix_mt_role_permission_mt_role on mt_role_permission (mt_role_id); +alter table mt_role_permission add constraint fk_mt_role_permission_mt_role foreign key (mt_role_id) references mt_role (id); + +create index ix_mt_role_permission_mt_permission on mt_role_permission (mt_permission_id); +alter table mt_role_permission add constraint fk_mt_role_permission_mt_permission foreign key (mt_permission_id) references mt_permission (id); + +create index ix_root_bean_referencing_bean_id on root_bean (referencing_bean_id); +alter table root_bean add constraint fk_root_bean_referencing_bean_id foreign key (referencing_bean_id) references referencing_bean (id); + +alter table f_second add constraint fk_f_second_first foreign key (first) references f_first (id); + +create index ix_section_article_id on section (article_id); +alter table section add constraint fk_section_article_id foreign key (article_id) references article (id); + +create index ix_self_parent_parent_id on self_parent (parent_id); +alter table self_parent add constraint fk_self_parent_parent_id foreign key (parent_id) references self_parent (id); + +create index ix_self_ref_customer_referred_by_id on self_ref_customer (referred_by_id); +alter table self_ref_customer add constraint fk_self_ref_customer_referred_by_id foreign key (referred_by_id) references self_ref_customer (id); + +create index ix_self_ref_example_parent_id on self_ref_example (parent_id); +alter table self_ref_example add constraint fk_self_ref_example_parent_id foreign key (parent_id) references self_ref_example (id); + +alter table e_save_test_b add constraint fk_e_save_test_b_sibling_a_id foreign key (sibling_a_id) references e_save_test_a (id); + +create index ix_site_parent_id on site (parent_id); +alter table site add constraint fk_site_parent_id foreign key (parent_id) references site (id); + +alter table site add constraint fk_site_data_container_id foreign key (data_container_id) references data_container (id); + +alter table site add constraint fk_site_site_address_id foreign key (site_address_id) references site_address (id); + +create index ix_source_base_target_id on source_base (target_id); +alter table source_base add constraint fk_source_base_target_id foreign key (target_id) references target_base (id); + +create index ix_stockforecast_inner_report_id on stockforecast (inner_report_id); +alter table stockforecast add constraint fk_stockforecast_inner_report_id foreign key (inner_report_id) references inner_report (id); + +create index ix_sub_section_section_id on sub_section (section_id); +alter table sub_section add constraint fk_sub_section_section_id foreign key (section_id) references section (id); + +create index ix_tevent_many_event_id on tevent_many (event_id); +alter table tevent_many add constraint fk_tevent_many_event_id foreign key (event_id) references tevent_one (id); + +alter table tevent_one add constraint fk_tevent_one_event_id foreign key (event_id) references tevent (id); + +create index ix_t_detail_with_other_namexxxyy_master_id on t_detail_with_other_namexxxyy (master_id); +alter table t_detail_with_other_namexxxyy add constraint fk_t_detail_with_other_namexxxyy_master_id foreign key (master_id) references t_atable_thatisrelatively (id); + +create index ix_ttruck_holder_truck_plate_no on ttruck_holder (truck_plate_no); +alter table ttruck_holder add constraint fk_ttruck_holder_truck_plate_no foreign key (truck_plate_no) references tcar (plate_no); + +create index ix_ttruck_holder_basic_id on ttruck_holder (basic_id); +alter table ttruck_holder add constraint fk_ttruck_holder_basic_id foreign key (basic_id) references e_basic (id); + +create index ix_ttruck_holder_item_owner_id on ttruck_holder_item (owner_id); +alter table ttruck_holder_item add constraint fk_ttruck_holder_item_owner_id foreign key (owner_id) references ttruck_holder (id); + +create index ix_twheel_owner_plate_no on twheel (owner_plate_no); +alter table twheel add constraint fk_twheel_owner_plate_no foreign key (owner_plate_no) references tcar (plate_no); + +alter table tire add constraint fk_tire_wheel foreign key (wheel) references wheel (id); + +create index ix_tree_entity_parent_id on tree_entity (parent_id); +alter table tree_entity add constraint fk_tree_entity_parent_id foreign key (parent_id) references tree_entity (id); + +create index ix_trip_vehicle_driver_id on trip (vehicle_driver_id); +alter table trip add constraint fk_trip_vehicle_driver_id foreign key (vehicle_driver_id) references vehicle_driver (id); + +create index ix_trip_address_id on trip (address_id); +alter table trip add constraint fk_trip_address_id foreign key (address_id) references o_address (id); + +create index ix_type_sub_type_id on [type] (sub_type_id); +alter table [type] add constraint fk_type_sub_type_id foreign key (sub_type_id) references sub_type (sub_type_id); + +create index ix_usib_child_parent_id on usib_child (parent_id); +alter table usib_child add constraint fk_usib_child_parent_id foreign key (parent_id) references usib_parent (id); + +alter table usib_child_sibling add constraint fk_usib_child_sibling_child_id foreign key (child_id) references usib_child (id); + +create index ix_ut_detail_utmaster_id on ut_detail (utmaster_id); +alter table ut_detail add constraint fk_ut_detail_utmaster_id foreign key (utmaster_id) references ut_master (id); + +create index ix_uutwo_master_id on uutwo (master_id); +alter table uutwo add constraint fk_uutwo_master_id foreign key (master_id) references uuone (id); + +alter table oto_user add constraint fk_oto_user_account_id foreign key (account_id) references oto_account (id); + +create index ix_c_user_group_id on c_user (group_id); +alter table c_user add constraint fk_c_user_group_id foreign key (group_id) references c_group (id); + +create index ix_em_user_role_user_id on em_user_role (user_id); +alter table em_user_role add constraint fk_em_user_role_user_id foreign key (user_id) references em_user (id); + +create index ix_em_user_role_role_id on em_user_role (role_id); +alter table em_user_role add constraint fk_em_user_role_role_id foreign key (role_id) references em_role (id); + +create index ix_vehicle_lease_id on vehicle (lease_id); +alter table vehicle add constraint fk_vehicle_lease_id foreign key (lease_id) references vehicle_lease (id); + +create index ix_vehicle_car_ref_id on vehicle (car_ref_id); +alter table vehicle add constraint fk_vehicle_car_ref_id foreign key (car_ref_id) references truck_ref (id); + +create index ix_vehicle_truck_ref_id on vehicle (truck_ref_id); +alter table vehicle add constraint fk_vehicle_truck_ref_id foreign key (truck_ref_id) references truck_ref (id); + +create index ix_vehicle_driver_vehicle_id on vehicle_driver (vehicle_id); +alter table vehicle_driver add constraint fk_vehicle_driver_vehicle_id foreign key (vehicle_id) references vehicle (id); + +create index ix_vehicle_driver_address_id on vehicle_driver (address_id); +alter table vehicle_driver add constraint fk_vehicle_driver_address_id foreign key (address_id) references o_address (id); + +create index ix_warehouses_officezoneid on warehouses (officezoneid); +alter table warehouses add constraint fk_warehouses_officezoneid foreign key (officezoneid) references zones (id); + +create index ix_warehousesshippingzones_warehouses on warehousesshippingzones (warehouseid); +alter table warehousesshippingzones add constraint fk_warehousesshippingzones_warehouses foreign key (warehouseid) references warehouses (id); + +create index ix_warehousesshippingzones_zones on warehousesshippingzones (shippingzoneid); +alter table warehousesshippingzones add constraint fk_warehousesshippingzones_zones foreign key (shippingzoneid) references zones (id); + +create index ix_sa_wheel_tire on sa_wheel (tire); +alter table sa_wheel add constraint fk_sa_wheel_tire foreign key (tire) references sa_tire (id); + +create index ix_sa_wheel_car on sa_wheel (car); +alter table sa_wheel add constraint fk_sa_wheel_car foreign key (car) references sa_car (id); + +create index ix_g_who_props_otm_who_created_id on g_who_props_otm (who_created_id); +alter table g_who_props_otm add constraint fk_g_who_props_otm_who_created_id foreign key (who_created_id) references g_user (id); + +create index ix_g_who_props_otm_who_modified_id on g_who_props_otm (who_modified_id); +alter table g_who_props_otm add constraint fk_g_who_props_otm_who_modified_id foreign key (who_modified_id) references g_user (id); + +create index ix_with_zero_parent_id on with_zero (parent_id); +alter table with_zero add constraint fk_with_zero_parent_id foreign key (parent_id) references parent (id); + +alter table hx_link + add sys_periodFrom datetime2 GENERATED ALWAYS AS ROW START NOT NULL DEFAULT SYSUTCDATETIME(), + sys_periodTo datetime2 GENERATED ALWAYS AS ROW END NOT NULL DEFAULT '9999-12-31T23:59:59.9999999', +period for system_time (sys_periodFrom, sys_periodTo); +alter table hx_link set (system_versioning = on (history_table=dbo.hx_link_history)); +alter table hi_link + add sys_periodFrom datetime2 GENERATED ALWAYS AS ROW START NOT NULL DEFAULT SYSUTCDATETIME(), + sys_periodTo datetime2 GENERATED ALWAYS AS ROW END NOT NULL DEFAULT '9999-12-31T23:59:59.9999999', +period for system_time (sys_periodFrom, sys_periodTo); +alter table hi_link set (system_versioning = on (history_table=dbo.hi_link_history)); +alter table hi_link_doc + add sys_periodFrom datetime2 GENERATED ALWAYS AS ROW START NOT NULL DEFAULT SYSUTCDATETIME(), + sys_periodTo datetime2 GENERATED ALWAYS AS ROW END NOT NULL DEFAULT '9999-12-31T23:59:59.9999999', +period for system_time (sys_periodFrom, sys_periodTo); +alter table hi_link_doc set (system_versioning = on (history_table=dbo.hi_link_doc_history)); +alter table hi_tone + add sys_periodFrom datetime2 GENERATED ALWAYS AS ROW START NOT NULL DEFAULT SYSUTCDATETIME(), + sys_periodTo datetime2 GENERATED ALWAYS AS ROW END NOT NULL DEFAULT '9999-12-31T23:59:59.9999999', +period for system_time (sys_periodFrom, sys_periodTo); +alter table hi_tone set (system_versioning = on (history_table=dbo.hi_tone_history)); +alter table hi_tthree + add sys_periodFrom datetime2 GENERATED ALWAYS AS ROW START NOT NULL DEFAULT SYSUTCDATETIME(), + sys_periodTo datetime2 GENERATED ALWAYS AS ROW END NOT NULL DEFAULT '9999-12-31T23:59:59.9999999', +period for system_time (sys_periodFrom, sys_periodTo); +alter table hi_tthree set (system_versioning = on (history_table=dbo.hi_tthree_history)); +alter table hi_ttwo + add sys_periodFrom datetime2 GENERATED ALWAYS AS ROW START NOT NULL DEFAULT SYSUTCDATETIME(), + sys_periodTo datetime2 GENERATED ALWAYS AS ROW END NOT NULL DEFAULT '9999-12-31T23:59:59.9999999', +period for system_time (sys_periodFrom, sys_periodTo); +alter table hi_ttwo set (system_versioning = on (history_table=dbo.hi_ttwo_history)); +alter table hsd_setting + add sys_periodFrom datetime2 GENERATED ALWAYS AS ROW START NOT NULL DEFAULT SYSUTCDATETIME(), + sys_periodTo datetime2 GENERATED ALWAYS AS ROW END NOT NULL DEFAULT '9999-12-31T23:59:59.9999999', +period for system_time (sys_periodFrom, sys_periodTo); +alter table hsd_setting set (system_versioning = on (history_table=dbo.hsd_setting_history)); +alter table hsd_user + add sys_periodFrom datetime2 GENERATED ALWAYS AS ROW START NOT NULL DEFAULT SYSUTCDATETIME(), + sys_periodTo datetime2 GENERATED ALWAYS AS ROW END NOT NULL DEFAULT '9999-12-31T23:59:59.9999999', +period for system_time (sys_periodFrom, sys_periodTo); +alter table hsd_user set (system_versioning = on (history_table=dbo.hsd_user_history)); +alter table link + add sys_periodFrom datetime2 GENERATED ALWAYS AS ROW START NOT NULL DEFAULT SYSUTCDATETIME(), + sys_periodTo datetime2 GENERATED ALWAYS AS ROW END NOT NULL DEFAULT '9999-12-31T23:59:59.9999999', +period for system_time (sys_periodFrom, sys_periodTo); +alter table link set (system_versioning = on (history_table=dbo.link_history)); +alter table c_user + add sys_periodFrom datetime2 GENERATED ALWAYS AS ROW START NOT NULL DEFAULT SYSUTCDATETIME(), + sys_periodTo datetime2 GENERATED ALWAYS AS ROW END NOT NULL DEFAULT '9999-12-31T23:59:59.9999999', +period for system_time (sys_periodFrom, sys_periodTo); +alter table c_user set (system_versioning = on (history_table=dbo.c_user_history)); diff --git a/ebean-core/src/test/ddl-review/sqlserver-drop-all.sql b/ebean-core/src/test/ddl-review/sqlserver-drop-all.sql new file mode 100644 index 000000000..867ef2963 --- /dev/null +++ b/ebean-core/src/test/ddl-review/sqlserver-drop-all.sql @@ -0,0 +1,2234 @@ +-- Generated by ebean unknown at 2020-03-04T08:21:26.827349Z +IF OBJECT_ID('fk_bar_foo_id', 'F') IS NOT NULL alter table bar drop constraint fk_bar_foo_id; +IF EXISTS (SELECT name FROM sys.indexes WHERE object_id = OBJECT_ID('bar','U') AND name = 'ix_bar_foo_id') drop index ix_bar_foo_id ON bar; + +IF OBJECT_ID('fk_acl_container_relation_container_id', 'F') IS NOT NULL alter table acl_container_relation drop constraint fk_acl_container_relation_container_id; +IF EXISTS (SELECT name FROM sys.indexes WHERE object_id = OBJECT_ID('acl_container_relation','U') AND name = 'ix_acl_container_relation_container_id') drop index ix_acl_container_relation_container_id ON acl_container_relation; + +IF OBJECT_ID('fk_acl_container_relation_acl_entry_id', 'F') IS NOT NULL alter table acl_container_relation drop constraint fk_acl_container_relation_acl_entry_id; +IF EXISTS (SELECT name FROM sys.indexes WHERE object_id = OBJECT_ID('acl_container_relation','U') AND name = 'ix_acl_container_relation_acl_entry_id') drop index ix_acl_container_relation_acl_entry_id ON acl_container_relation; + +IF OBJECT_ID('fk_addr_employee_id', 'F') IS NOT NULL alter table addr drop constraint fk_addr_employee_id; +IF EXISTS (SELECT name FROM sys.indexes WHERE object_id = OBJECT_ID('addr','U') AND name = 'ix_addr_employee_id') drop index ix_addr_employee_id ON addr; + +IF OBJECT_ID('fk_o_address_country_code', 'F') IS NOT NULL alter table o_address drop constraint fk_o_address_country_code; +IF EXISTS (SELECT name FROM sys.indexes WHERE object_id = OBJECT_ID('o_address','U') AND name = 'ix_o_address_country_code') drop index ix_o_address_country_code ON o_address; + +IF EXISTS (SELECT name FROM sys.indexes WHERE object_id = OBJECT_ID('album','U') AND name = 'uq_album_cover_id') drop index uq_album_cover_id ON album; +IF OBJECT_ID('fk_album_cover_id', 'F') IS NOT NULL alter table album drop constraint fk_album_cover_id; + +IF OBJECT_ID('fk_animal_shelter_id', 'F') IS NOT NULL alter table animal drop constraint fk_animal_shelter_id; +IF EXISTS (SELECT name FROM sys.indexes WHERE object_id = OBJECT_ID('animal','U') AND name = 'ix_animal_shelter_id') drop index ix_animal_shelter_id ON animal; + +IF OBJECT_ID('fk_attribute_attribute_holder_id', 'F') IS NOT NULL alter table attribute drop constraint fk_attribute_attribute_holder_id; +IF EXISTS (SELECT name FROM sys.indexes WHERE object_id = OBJECT_ID('attribute','U') AND name = 'ix_attribute_attribute_holder_id') drop index ix_attribute_attribute_holder_id ON attribute; + +IF OBJECT_ID('fk_bbookmark_user_id', 'F') IS NOT NULL alter table bbookmark drop constraint fk_bbookmark_user_id; +IF EXISTS (SELECT name FROM sys.indexes WHERE object_id = OBJECT_ID('bbookmark','U') AND name = 'ix_bbookmark_user_id') drop index ix_bbookmark_user_id ON bbookmark; + +IF OBJECT_ID('fk_bbookmark_user_org_id', 'F') IS NOT NULL alter table bbookmark_user drop constraint fk_bbookmark_user_org_id; +IF EXISTS (SELECT name FROM sys.indexes WHERE object_id = OBJECT_ID('bbookmark_user','U') AND name = 'ix_bbookmark_user_org_id') drop index ix_bbookmark_user_org_id ON bbookmark_user; + +IF OBJECT_ID('fk_bsite_user_a_site_id', 'F') IS NOT NULL alter table bsite_user_a drop constraint fk_bsite_user_a_site_id; +IF EXISTS (SELECT name FROM sys.indexes WHERE object_id = OBJECT_ID('bsite_user_a','U') AND name = 'ix_bsite_user_a_site_id') drop index ix_bsite_user_a_site_id ON bsite_user_a; + +IF OBJECT_ID('fk_bsite_user_a_user_id', 'F') IS NOT NULL alter table bsite_user_a drop constraint fk_bsite_user_a_user_id; +IF EXISTS (SELECT name FROM sys.indexes WHERE object_id = OBJECT_ID('bsite_user_a','U') AND name = 'ix_bsite_user_a_user_id') drop index ix_bsite_user_a_user_id ON bsite_user_a; + +IF OBJECT_ID('fk_bsite_user_b_site', 'F') IS NOT NULL alter table bsite_user_b drop constraint fk_bsite_user_b_site; +IF EXISTS (SELECT name FROM sys.indexes WHERE object_id = OBJECT_ID('bsite_user_b','U') AND name = 'ix_bsite_user_b_site') drop index ix_bsite_user_b_site ON bsite_user_b; + +IF OBJECT_ID('fk_bsite_user_b_usr', 'F') IS NOT NULL alter table bsite_user_b drop constraint fk_bsite_user_b_usr; +IF EXISTS (SELECT name FROM sys.indexes WHERE object_id = OBJECT_ID('bsite_user_b','U') AND name = 'ix_bsite_user_b_usr') drop index ix_bsite_user_b_usr ON bsite_user_b; + +IF OBJECT_ID('fk_bsite_user_c_site_uid', 'F') IS NOT NULL alter table bsite_user_c drop constraint fk_bsite_user_c_site_uid; +IF EXISTS (SELECT name FROM sys.indexes WHERE object_id = OBJECT_ID('bsite_user_c','U') AND name = 'ix_bsite_user_c_site_uid') drop index ix_bsite_user_c_site_uid ON bsite_user_c; + +IF OBJECT_ID('fk_bsite_user_c_user_uid', 'F') IS NOT NULL alter table bsite_user_c drop constraint fk_bsite_user_c_user_uid; +IF EXISTS (SELECT name FROM sys.indexes WHERE object_id = OBJECT_ID('bsite_user_c','U') AND name = 'ix_bsite_user_c_user_uid') drop index ix_bsite_user_c_user_uid ON bsite_user_c; + +IF OBJECT_ID('fk_bsite_user_e_site_id', 'F') IS NOT NULL alter table bsite_user_e drop constraint fk_bsite_user_e_site_id; +IF EXISTS (SELECT name FROM sys.indexes WHERE object_id = OBJECT_ID('bsite_user_e','U') AND name = 'ix_bsite_user_e_site_id') drop index ix_bsite_user_e_site_id ON bsite_user_e; + +IF OBJECT_ID('fk_bsite_user_e_user_id', 'F') IS NOT NULL alter table bsite_user_e drop constraint fk_bsite_user_e_user_id; +IF EXISTS (SELECT name FROM sys.indexes WHERE object_id = OBJECT_ID('bsite_user_e','U') AND name = 'ix_bsite_user_e_user_id') drop index ix_bsite_user_e_user_id ON bsite_user_e; + +IF EXISTS (SELECT name FROM sys.indexes WHERE object_id = OBJECT_ID('bwith_qident','U') AND name = 'uq_bwith_qident_name') drop index uq_bwith_qident_name ON bwith_qident; +IF OBJECT_ID('fk_basic_draftable_bean_id', 'F') IS NOT NULL alter table basic_draftable_bean drop constraint fk_basic_draftable_bean_id; + +IF EXISTS (SELECT name FROM sys.indexes WHERE object_id = OBJECT_ID('drel_booking','U') AND name = 'uq_drel_booking_booking_uid') drop index uq_drel_booking_booking_uid ON drel_booking; +IF EXISTS (SELECT name FROM sys.indexes WHERE object_id = OBJECT_ID('drel_booking','U') AND name = 'uq_drel_booking_agent_invoice') drop index uq_drel_booking_agent_invoice ON drel_booking; +IF EXISTS (SELECT name FROM sys.indexes WHERE object_id = OBJECT_ID('drel_booking','U') AND name = 'uq_drel_booking_client_invoice') drop index uq_drel_booking_client_invoice ON drel_booking; +IF OBJECT_ID('fk_drel_booking_agent_invoice', 'F') IS NOT NULL alter table drel_booking drop constraint fk_drel_booking_agent_invoice; + +IF OBJECT_ID('fk_drel_booking_client_invoice', 'F') IS NOT NULL alter table drel_booking drop constraint fk_drel_booking_client_invoice; + +IF OBJECT_ID('fk_cepproduct_category_category_id', 'F') IS NOT NULL alter table cepproduct_category drop constraint fk_cepproduct_category_category_id; +IF EXISTS (SELECT name FROM sys.indexes WHERE object_id = OBJECT_ID('cepproduct_category','U') AND name = 'ix_cepproduct_category_category_id') drop index ix_cepproduct_category_category_id ON cepproduct_category; + +IF OBJECT_ID('fk_cepproduct_category_product_id', 'F') IS NOT NULL alter table cepproduct_category drop constraint fk_cepproduct_category_product_id; +IF EXISTS (SELECT name FROM sys.indexes WHERE object_id = OBJECT_ID('cepproduct_category','U') AND name = 'ix_cepproduct_category_product_id') drop index ix_cepproduct_category_product_id ON cepproduct_category; + +IF OBJECT_ID('fk_cinh_ref_ref_id', 'F') IS NOT NULL alter table cinh_ref drop constraint fk_cinh_ref_ref_id; +IF EXISTS (SELECT name FROM sys.indexes WHERE object_id = OBJECT_ID('cinh_ref','U') AND name = 'ix_cinh_ref_ref_id') drop index ix_cinh_ref_ref_id ON cinh_ref; + +IF OBJECT_ID('fk_ckey_detail_parent', 'F') IS NOT NULL alter table ckey_detail drop constraint fk_ckey_detail_parent; +IF EXISTS (SELECT name FROM sys.indexes WHERE object_id = OBJECT_ID('ckey_detail','U') AND name = 'ix_ckey_detail_parent') drop index ix_ckey_detail_parent ON ckey_detail; + +IF OBJECT_ID('fk_ckey_parent_assoc_id', 'F') IS NOT NULL alter table ckey_parent drop constraint fk_ckey_parent_assoc_id; +IF EXISTS (SELECT name FROM sys.indexes WHERE object_id = OBJECT_ID('ckey_parent','U') AND name = 'ix_ckey_parent_assoc_id') drop index ix_ckey_parent_assoc_id ON ckey_parent; + +IF OBJECT_ID('fk_coone_many_coone_id', 'F') IS NOT NULL alter table coone_many drop constraint fk_coone_many_coone_id; +IF EXISTS (SELECT name FROM sys.indexes WHERE object_id = OBJECT_ID('coone_many','U') AND name = 'ix_coone_many_coone_id') drop index ix_coone_many_coone_id ON coone_many; + +IF EXISTS (SELECT name FROM sys.indexes WHERE object_id = OBJECT_ID('coroot','U') AND name = 'uq_coroot_one_id') drop index uq_coroot_one_id ON coroot; +IF OBJECT_ID('fk_coroot_one_id', 'F') IS NOT NULL alter table coroot drop constraint fk_coroot_one_id; + +IF OBJECT_ID('fk_calculation_result_product_configuration_id', 'F') IS NOT NULL alter table calculation_result drop constraint fk_calculation_result_product_configuration_id; +IF EXISTS (SELECT name FROM sys.indexes WHERE object_id = OBJECT_ID('calculation_result','U') AND name = 'ix_calculation_result_product_configuration_id') drop index ix_calculation_result_product_configuration_id ON calculation_result; + +IF OBJECT_ID('fk_calculation_result_group_configuration_id', 'F') IS NOT NULL alter table calculation_result drop constraint fk_calculation_result_group_configuration_id; +IF EXISTS (SELECT name FROM sys.indexes WHERE object_id = OBJECT_ID('calculation_result','U') AND name = 'ix_calculation_result_group_configuration_id') drop index ix_calculation_result_group_configuration_id ON calculation_result; + +IF OBJECT_ID('fk_sp_car_car_wheels_sp_car_car', 'F') IS NOT NULL alter table sp_car_car_wheels drop constraint fk_sp_car_car_wheels_sp_car_car; +IF EXISTS (SELECT name FROM sys.indexes WHERE object_id = OBJECT_ID('sp_car_car_wheels','U') AND name = 'ix_sp_car_car_wheels_sp_car_car') drop index ix_sp_car_car_wheels_sp_car_car ON sp_car_car_wheels; + +IF OBJECT_ID('fk_sp_car_car_wheels_sp_car_wheel', 'F') IS NOT NULL alter table sp_car_car_wheels drop constraint fk_sp_car_car_wheels_sp_car_wheel; +IF EXISTS (SELECT name FROM sys.indexes WHERE object_id = OBJECT_ID('sp_car_car_wheels','U') AND name = 'ix_sp_car_car_wheels_sp_car_wheel') drop index ix_sp_car_car_wheels_sp_car_wheel ON sp_car_car_wheels; + +IF OBJECT_ID('fk_sp_car_car_doors_sp_car_car', 'F') IS NOT NULL alter table sp_car_car_doors drop constraint fk_sp_car_car_doors_sp_car_car; +IF EXISTS (SELECT name FROM sys.indexes WHERE object_id = OBJECT_ID('sp_car_car_doors','U') AND name = 'ix_sp_car_car_doors_sp_car_car') drop index ix_sp_car_car_doors_sp_car_car ON sp_car_car_doors; + +IF OBJECT_ID('fk_sp_car_car_doors_sp_car_door', 'F') IS NOT NULL alter table sp_car_car_doors drop constraint fk_sp_car_car_doors_sp_car_door; +IF EXISTS (SELECT name FROM sys.indexes WHERE object_id = OBJECT_ID('sp_car_car_doors','U') AND name = 'ix_sp_car_car_doors_sp_car_door') drop index ix_sp_car_car_doors_sp_car_door ON sp_car_car_doors; + +IF OBJECT_ID('fk_car_accessory_fuse_id', 'F') IS NOT NULL alter table car_accessory drop constraint fk_car_accessory_fuse_id; +IF EXISTS (SELECT name FROM sys.indexes WHERE object_id = OBJECT_ID('car_accessory','U') AND name = 'ix_car_accessory_fuse_id') drop index ix_car_accessory_fuse_id ON car_accessory; + +IF OBJECT_ID('fk_car_accessory_car_id', 'F') IS NOT NULL alter table car_accessory drop constraint fk_car_accessory_car_id; +IF EXISTS (SELECT name FROM sys.indexes WHERE object_id = OBJECT_ID('car_accessory','U') AND name = 'ix_car_accessory_car_id') drop index ix_car_accessory_car_id ON car_accessory; + +IF OBJECT_ID('fk_category_surveyobjectid', 'F') IS NOT NULL alter table category drop constraint fk_category_surveyobjectid; +IF EXISTS (SELECT name FROM sys.indexes WHERE object_id = OBJECT_ID('category','U') AND name = 'ix_category_surveyobjectid') drop index ix_category_surveyobjectid ON category; + +IF EXISTS (SELECT name FROM sys.indexes WHERE object_id = OBJECT_ID('e_save_test_d','U') AND name = 'uq_e_save_test_d_parent_id') drop index uq_e_save_test_d_parent_id ON e_save_test_d; +IF OBJECT_ID('fk_e_save_test_d_parent_id', 'F') IS NOT NULL alter table e_save_test_d drop constraint fk_e_save_test_d_parent_id; + +IF OBJECT_ID('fk_child_person_some_bean_id', 'F') IS NOT NULL alter table child_person drop constraint fk_child_person_some_bean_id; +IF EXISTS (SELECT name FROM sys.indexes WHERE object_id = OBJECT_ID('child_person','U') AND name = 'ix_child_person_some_bean_id') drop index ix_child_person_some_bean_id ON child_person; + +IF OBJECT_ID('fk_child_person_parent_identifier', 'F') IS NOT NULL alter table child_person drop constraint fk_child_person_parent_identifier; +IF EXISTS (SELECT name FROM sys.indexes WHERE object_id = OBJECT_ID('child_person','U') AND name = 'ix_child_person_parent_identifier') drop index ix_child_person_parent_identifier ON child_person; + +IF OBJECT_ID('fk_cke_client_user', 'F') IS NOT NULL alter table cke_client drop constraint fk_cke_client_user; +IF EXISTS (SELECT name FROM sys.indexes WHERE object_id = OBJECT_ID('cke_client','U') AND name = 'ix_cke_client_user') drop index ix_cke_client_user ON cke_client; + +IF OBJECT_ID('fk_class_super_monkey_class_super', 'F') IS NOT NULL alter table class_super_monkey drop constraint fk_class_super_monkey_class_super; + +IF OBJECT_ID('fk_class_super_monkey_monkey', 'F') IS NOT NULL alter table class_super_monkey drop constraint fk_class_super_monkey_monkey; + +IF OBJECT_ID('fk_configuration_configurations_id', 'F') IS NOT NULL alter table configuration drop constraint fk_configuration_configurations_id; +IF EXISTS (SELECT name FROM sys.indexes WHERE object_id = OBJECT_ID('configuration','U') AND name = 'ix_configuration_configurations_id') drop index ix_configuration_configurations_id ON configuration; + +IF OBJECT_ID('fk_contact_customer_id', 'F') IS NOT NULL alter table contact drop constraint fk_contact_customer_id; +IF EXISTS (SELECT name FROM sys.indexes WHERE object_id = OBJECT_ID('contact','U') AND name = 'ix_contact_customer_id') drop index ix_contact_customer_id ON contact; + +IF OBJECT_ID('fk_contact_group_id', 'F') IS NOT NULL alter table contact drop constraint fk_contact_group_id; +IF EXISTS (SELECT name FROM sys.indexes WHERE object_id = OBJECT_ID('contact','U') AND name = 'ix_contact_group_id') drop index ix_contact_group_id ON contact; + +IF OBJECT_ID('fk_contact_note_contact_id', 'F') IS NOT NULL alter table contact_note drop constraint fk_contact_note_contact_id; +IF EXISTS (SELECT name FROM sys.indexes WHERE object_id = OBJECT_ID('contact_note','U') AND name = 'ix_contact_note_contact_id') drop index ix_contact_note_contact_id ON contact_note; + +IF OBJECT_ID('fk_contract_costs_position_id', 'F') IS NOT NULL alter table contract_costs drop constraint fk_contract_costs_position_id; +IF EXISTS (SELECT name FROM sys.indexes WHERE object_id = OBJECT_ID('contract_costs','U') AND name = 'ix_contract_costs_position_id') drop index ix_contract_costs_position_id ON contract_costs; + +IF OBJECT_ID('fk_c_conversation_group_id', 'F') IS NOT NULL alter table c_conversation drop constraint fk_c_conversation_group_id; +IF EXISTS (SELECT name FROM sys.indexes WHERE object_id = OBJECT_ID('c_conversation','U') AND name = 'ix_c_conversation_group_id') drop index ix_c_conversation_group_id ON c_conversation; + +IF OBJECT_ID('fk_o_customer_billing_address_id', 'F') IS NOT NULL alter table o_customer drop constraint fk_o_customer_billing_address_id; +IF EXISTS (SELECT name FROM sys.indexes WHERE object_id = OBJECT_ID('o_customer','U') AND name = 'ix_o_customer_billing_address_id') drop index ix_o_customer_billing_address_id ON o_customer; + +IF OBJECT_ID('fk_o_customer_shipping_address_id', 'F') IS NOT NULL alter table o_customer drop constraint fk_o_customer_shipping_address_id; +IF EXISTS (SELECT name FROM sys.indexes WHERE object_id = OBJECT_ID('o_customer','U') AND name = 'ix_o_customer_shipping_address_id') drop index ix_o_customer_shipping_address_id ON o_customer; + +IF OBJECT_ID('fk_dcredit_drol_dcredit', 'F') IS NOT NULL alter table dcredit_drol drop constraint fk_dcredit_drol_dcredit; +IF EXISTS (SELECT name FROM sys.indexes WHERE object_id = OBJECT_ID('dcredit_drol','U') AND name = 'ix_dcredit_drol_dcredit') drop index ix_dcredit_drol_dcredit ON dcredit_drol; + +IF OBJECT_ID('fk_dcredit_drol_drol', 'F') IS NOT NULL alter table dcredit_drol drop constraint fk_dcredit_drol_drol; +IF EXISTS (SELECT name FROM sys.indexes WHERE object_id = OBJECT_ID('dcredit_drol','U') AND name = 'ix_dcredit_drol_drol') drop index ix_dcredit_drol_drol ON dcredit_drol; + +IF OBJECT_ID('fk_dmachine_organisation_id', 'F') IS NOT NULL alter table dmachine drop constraint fk_dmachine_organisation_id; +IF EXISTS (SELECT name FROM sys.indexes WHERE object_id = OBJECT_ID('dmachine','U') AND name = 'ix_dmachine_organisation_id') drop index ix_dmachine_organisation_id ON dmachine; + +IF OBJECT_ID('fk_d_machine_aux_use_machine_id', 'F') IS NOT NULL alter table d_machine_aux_use drop constraint fk_d_machine_aux_use_machine_id; +IF EXISTS (SELECT name FROM sys.indexes WHERE object_id = OBJECT_ID('d_machine_aux_use','U') AND name = 'ix_d_machine_aux_use_machine_id') drop index ix_d_machine_aux_use_machine_id ON d_machine_aux_use; + +IF OBJECT_ID('fk_d_machine_stats_machine_id', 'F') IS NOT NULL alter table d_machine_stats drop constraint fk_d_machine_stats_machine_id; +IF EXISTS (SELECT name FROM sys.indexes WHERE object_id = OBJECT_ID('d_machine_stats','U') AND name = 'ix_d_machine_stats_machine_id') drop index ix_d_machine_stats_machine_id ON d_machine_stats; + +IF OBJECT_ID('fk_d_machine_use_machine_id', 'F') IS NOT NULL alter table d_machine_use drop constraint fk_d_machine_use_machine_id; +IF EXISTS (SELECT name FROM sys.indexes WHERE object_id = OBJECT_ID('d_machine_use','U') AND name = 'ix_d_machine_use_machine_id') drop index ix_d_machine_use_machine_id ON d_machine_use; + +IF OBJECT_ID('fk_drot_drol_drot', 'F') IS NOT NULL alter table drot_drol drop constraint fk_drot_drol_drot; +IF EXISTS (SELECT name FROM sys.indexes WHERE object_id = OBJECT_ID('drot_drol','U') AND name = 'ix_drot_drol_drot') drop index ix_drot_drol_drot ON drot_drol; + +IF OBJECT_ID('fk_drot_drol_drol', 'F') IS NOT NULL alter table drot_drol drop constraint fk_drot_drol_drol; +IF EXISTS (SELECT name FROM sys.indexes WHERE object_id = OBJECT_ID('drot_drol','U') AND name = 'ix_drot_drol_drol') drop index ix_drot_drol_drol ON drot_drol; + +IF OBJECT_ID('fk_dc_detail_master_id', 'F') IS NOT NULL alter table dc_detail drop constraint fk_dc_detail_master_id; +IF EXISTS (SELECT name FROM sys.indexes WHERE object_id = OBJECT_ID('dc_detail','U') AND name = 'ix_dc_detail_master_id') drop index ix_dc_detail_master_id ON dc_detail; + +IF OBJECT_ID('fk_dfk_cascade_one_id', 'F') IS NOT NULL alter table dfk_cascade drop constraint fk_dfk_cascade_one_id; +IF EXISTS (SELECT name FROM sys.indexes WHERE object_id = OBJECT_ID('dfk_cascade','U') AND name = 'ix_dfk_cascade_one_id') drop index ix_dfk_cascade_one_id ON dfk_cascade; + +IF OBJECT_ID('fk_dfk_set_null_one_id', 'F') IS NOT NULL alter table dfk_set_null drop constraint fk_dfk_set_null_one_id; +IF EXISTS (SELECT name FROM sys.indexes WHERE object_id = OBJECT_ID('dfk_set_null','U') AND name = 'ix_dfk_set_null_one_id') drop index ix_dfk_set_null_one_id ON dfk_set_null; + +IF OBJECT_ID('fk_doc_id', 'F') IS NOT NULL alter table doc drop constraint fk_doc_id; + +IF OBJECT_ID('fk_doc_link_doc', 'F') IS NOT NULL alter table doc_link drop constraint fk_doc_link_doc; +IF EXISTS (SELECT name FROM sys.indexes WHERE object_id = OBJECT_ID('doc_link','U') AND name = 'ix_doc_link_doc') drop index ix_doc_link_doc ON doc_link; + +IF OBJECT_ID('fk_doc_link_link', 'F') IS NOT NULL alter table doc_link drop constraint fk_doc_link_link; +IF EXISTS (SELECT name FROM sys.indexes WHERE object_id = OBJECT_ID('doc_link','U') AND name = 'ix_doc_link_link') drop index ix_doc_link_link ON doc_link; + +IF EXISTS (SELECT name FROM sys.indexes WHERE object_id = OBJECT_ID('document','U') AND name = 'uq_document_title') drop index uq_document_title ON document; +IF OBJECT_ID('fk_document_id', 'F') IS NOT NULL alter table document drop constraint fk_document_id; + +IF OBJECT_ID('fk_document_organisation_id', 'F') IS NOT NULL alter table document drop constraint fk_document_organisation_id; +IF EXISTS (SELECT name FROM sys.indexes WHERE object_id = OBJECT_ID('document','U') AND name = 'ix_document_organisation_id') drop index ix_document_organisation_id ON document; + +IF EXISTS (SELECT name FROM sys.indexes WHERE object_id = OBJECT_ID('document_draft','U') AND name = 'uq_document_draft_title') drop index uq_document_draft_title ON document_draft; +IF OBJECT_ID('fk_document_draft_organisation_id', 'F') IS NOT NULL alter table document_draft drop constraint fk_document_draft_organisation_id; +IF EXISTS (SELECT name FROM sys.indexes WHERE object_id = OBJECT_ID('document_draft','U') AND name = 'ix_document_draft_organisation_id') drop index ix_document_draft_organisation_id ON document_draft; + +IF OBJECT_ID('fk_document_media_document_id', 'F') IS NOT NULL alter table document_media drop constraint fk_document_media_document_id; +IF EXISTS (SELECT name FROM sys.indexes WHERE object_id = OBJECT_ID('document_media','U') AND name = 'ix_document_media_document_id') drop index ix_document_media_document_id ON document_media; + +IF OBJECT_ID('fk_document_media_draft_document_id', 'F') IS NOT NULL alter table document_media_draft drop constraint fk_document_media_draft_document_id; +IF EXISTS (SELECT name FROM sys.indexes WHERE object_id = OBJECT_ID('document_media_draft','U') AND name = 'ix_document_media_draft_document_id') drop index ix_document_media_draft_document_id ON document_media_draft; + +IF OBJECT_ID('fk_e_basicenc_relate_other_id', 'F') IS NOT NULL alter table e_basicenc_relate drop constraint fk_e_basicenc_relate_other_id; +IF EXISTS (SELECT name FROM sys.indexes WHERE object_id = OBJECT_ID('e_basicenc_relate','U') AND name = 'ix_e_basicenc_relate_other_id') drop index ix_e_basicenc_relate_other_id ON e_basicenc_relate; + +IF OBJECT_ID('fk_ebasic_json_map_detail_owner_id', 'F') IS NOT NULL alter table ebasic_json_map_detail drop constraint fk_ebasic_json_map_detail_owner_id; +IF EXISTS (SELECT name FROM sys.indexes WHERE object_id = OBJECT_ID('ebasic_json_map_detail','U') AND name = 'ix_ebasic_json_map_detail_owner_id') drop index ix_ebasic_json_map_detail_owner_id ON ebasic_json_map_detail; + +IF OBJECT_ID('fk_ebasic_no_sdchild_owner_id', 'F') IS NOT NULL alter table ebasic_no_sdchild drop constraint fk_ebasic_no_sdchild_owner_id; +IF EXISTS (SELECT name FROM sys.indexes WHERE object_id = OBJECT_ID('ebasic_no_sdchild','U') AND name = 'ix_ebasic_no_sdchild_owner_id') drop index ix_ebasic_no_sdchild_owner_id ON ebasic_no_sdchild; + +IF OBJECT_ID('fk_ebasic_sdchild_owner_id', 'F') IS NOT NULL alter table ebasic_sdchild drop constraint fk_ebasic_sdchild_owner_id; +IF EXISTS (SELECT name FROM sys.indexes WHERE object_id = OBJECT_ID('ebasic_sdchild','U') AND name = 'ix_ebasic_sdchild_owner_id') drop index ix_ebasic_sdchild_owner_id ON ebasic_sdchild; + +IF EXISTS (SELECT name FROM sys.indexes WHERE object_id = OBJECT_ID('e_basicverucon','U') AND name = 'uq_e_basicverucon_name') drop index uq_e_basicverucon_name ON e_basicverucon; +IF EXISTS (SELECT name FROM sys.indexes WHERE object_id = OBJECT_ID('e_basicverucon','U') AND name = 'uq_e_basicverucon_other_other_one') drop index uq_e_basicverucon_other_other_one ON e_basicverucon; +IF OBJECT_ID('fk_ecache_child_root_id', 'F') IS NOT NULL alter table ecache_child drop constraint fk_ecache_child_root_id; +IF EXISTS (SELECT name FROM sys.indexes WHERE object_id = OBJECT_ID('ecache_child','U') AND name = 'ix_ecache_child_root_id') drop index ix_ecache_child_root_id ON ecache_child; + +IF EXISTS (SELECT name FROM sys.indexes WHERE object_id = OBJECT_ID('edefault_prop','U') AND name = 'uq_edefault_prop_e_simple_usertypeid') drop index uq_edefault_prop_e_simple_usertypeid ON edefault_prop; +IF OBJECT_ID('fk_edefault_prop_e_simple_usertypeid', 'F') IS NOT NULL alter table edefault_prop drop constraint fk_edefault_prop_e_simple_usertypeid; + +IF OBJECT_ID('fk_eemb_inner_outer_id', 'F') IS NOT NULL alter table eemb_inner drop constraint fk_eemb_inner_outer_id; +IF EXISTS (SELECT name FROM sys.indexes WHERE object_id = OBJECT_ID('eemb_inner','U') AND name = 'ix_eemb_inner_outer_id') drop index ix_eemb_inner_outer_id ON eemb_inner; + +IF OBJECT_ID('fk_einvoice_person_id', 'F') IS NOT NULL alter table einvoice drop constraint fk_einvoice_person_id; +IF EXISTS (SELECT name FROM sys.indexes WHERE object_id = OBJECT_ID('einvoice','U') AND name = 'ix_einvoice_person_id') drop index ix_einvoice_person_id ON einvoice; + +IF OBJECT_ID('fk_enull_collection_detail_enull_collection_id', 'F') IS NOT NULL alter table enull_collection_detail drop constraint fk_enull_collection_detail_enull_collection_id; +IF EXISTS (SELECT name FROM sys.indexes WHERE object_id = OBJECT_ID('enull_collection_detail','U') AND name = 'ix_enull_collection_detail_enull_collection_id') drop index ix_enull_collection_detail_enull_collection_id ON enull_collection_detail; + +IF OBJECT_ID('fk_eopt_one_a_b_id', 'F') IS NOT NULL alter table eopt_one_a drop constraint fk_eopt_one_a_b_id; +IF EXISTS (SELECT name FROM sys.indexes WHERE object_id = OBJECT_ID('eopt_one_a','U') AND name = 'ix_eopt_one_a_b_id') drop index ix_eopt_one_a_b_id ON eopt_one_a; + +IF OBJECT_ID('fk_eopt_one_b_c_id', 'F') IS NOT NULL alter table eopt_one_b drop constraint fk_eopt_one_b_c_id; +IF EXISTS (SELECT name FROM sys.indexes WHERE object_id = OBJECT_ID('eopt_one_b','U') AND name = 'ix_eopt_one_b_c_id') drop index ix_eopt_one_b_c_id ON eopt_one_b; + +IF OBJECT_ID('fk_eper_addr_ma_country_code', 'F') IS NOT NULL alter table eper_addr drop constraint fk_eper_addr_ma_country_code; +IF EXISTS (SELECT name FROM sys.indexes WHERE object_id = OBJECT_ID('eper_addr','U') AND name = 'ix_eper_addr_ma_country_code') drop index ix_eper_addr_ma_country_code ON eper_addr; + +IF EXISTS (SELECT name FROM sys.indexes WHERE object_id = OBJECT_ID('e_person_online','U') AND name = 'uq_e_person_online_email') drop index uq_e_person_online_email ON e_person_online; +IF OBJECT_ID('fk_esoft_del_book_lend_by_id', 'F') IS NOT NULL alter table esoft_del_book drop constraint fk_esoft_del_book_lend_by_id; +IF EXISTS (SELECT name FROM sys.indexes WHERE object_id = OBJECT_ID('esoft_del_book','U') AND name = 'ix_esoft_del_book_lend_by_id') drop index ix_esoft_del_book_lend_by_id ON esoft_del_book; + +IF OBJECT_ID('fk_esoft_del_book_esoft_del_user_esoft_del_book', 'F') IS NOT NULL alter table esoft_del_book_esoft_del_user drop constraint fk_esoft_del_book_esoft_del_user_esoft_del_book; +IF EXISTS (SELECT name FROM sys.indexes WHERE object_id = OBJECT_ID('esoft_del_book_esoft_del_user','U') AND name = 'ix_esoft_del_book_esoft_del_user_esoft_del_book') drop index ix_esoft_del_book_esoft_del_user_esoft_del_book ON esoft_del_book_esoft_del_user; + +IF OBJECT_ID('fk_esoft_del_book_esoft_del_user_esoft_del_user', 'F') IS NOT NULL alter table esoft_del_book_esoft_del_user drop constraint fk_esoft_del_book_esoft_del_user_esoft_del_user; +IF EXISTS (SELECT name FROM sys.indexes WHERE object_id = OBJECT_ID('esoft_del_book_esoft_del_user','U') AND name = 'ix_esoft_del_book_esoft_del_user_esoft_del_user') drop index ix_esoft_del_book_esoft_del_user_esoft_del_user ON esoft_del_book_esoft_del_user; + +IF OBJECT_ID('fk_esoft_del_down_esoft_del_mid_id', 'F') IS NOT NULL alter table esoft_del_down drop constraint fk_esoft_del_down_esoft_del_mid_id; +IF EXISTS (SELECT name FROM sys.indexes WHERE object_id = OBJECT_ID('esoft_del_down','U') AND name = 'ix_esoft_del_down_esoft_del_mid_id') drop index ix_esoft_del_down_esoft_del_mid_id ON esoft_del_down; + +IF OBJECT_ID('fk_esoft_del_mid_top_id', 'F') IS NOT NULL alter table esoft_del_mid drop constraint fk_esoft_del_mid_top_id; +IF EXISTS (SELECT name FROM sys.indexes WHERE object_id = OBJECT_ID('esoft_del_mid','U') AND name = 'ix_esoft_del_mid_top_id') drop index ix_esoft_del_mid_top_id ON esoft_del_mid; + +IF OBJECT_ID('fk_esoft_del_mid_up_id', 'F') IS NOT NULL alter table esoft_del_mid drop constraint fk_esoft_del_mid_up_id; +IF EXISTS (SELECT name FROM sys.indexes WHERE object_id = OBJECT_ID('esoft_del_mid','U') AND name = 'ix_esoft_del_mid_up_id') drop index ix_esoft_del_mid_up_id ON esoft_del_mid; + +IF EXISTS (SELECT name FROM sys.indexes WHERE object_id = OBJECT_ID('esoft_del_one_a','U') AND name = 'uq_esoft_del_one_a_oneb_id') drop index uq_esoft_del_one_a_oneb_id ON esoft_del_one_a; +IF OBJECT_ID('fk_esoft_del_one_a_oneb_id', 'F') IS NOT NULL alter table esoft_del_one_a drop constraint fk_esoft_del_one_a_oneb_id; + +IF OBJECT_ID('fk_esoft_del_role_esoft_del_user_esoft_del_role', 'F') IS NOT NULL alter table esoft_del_role_esoft_del_user drop constraint fk_esoft_del_role_esoft_del_user_esoft_del_role; +IF EXISTS (SELECT name FROM sys.indexes WHERE object_id = OBJECT_ID('esoft_del_role_esoft_del_user','U') AND name = 'ix_esoft_del_role_esoft_del_user_esoft_del_role') drop index ix_esoft_del_role_esoft_del_user_esoft_del_role ON esoft_del_role_esoft_del_user; + +IF OBJECT_ID('fk_esoft_del_role_esoft_del_user_esoft_del_user', 'F') IS NOT NULL alter table esoft_del_role_esoft_del_user drop constraint fk_esoft_del_role_esoft_del_user_esoft_del_user; +IF EXISTS (SELECT name FROM sys.indexes WHERE object_id = OBJECT_ID('esoft_del_role_esoft_del_user','U') AND name = 'ix_esoft_del_role_esoft_del_user_esoft_del_user') drop index ix_esoft_del_role_esoft_del_user_esoft_del_user ON esoft_del_role_esoft_del_user; + +IF OBJECT_ID('fk_esoft_del_user_esoft_del_role_esoft_del_user', 'F') IS NOT NULL alter table esoft_del_user_esoft_del_role drop constraint fk_esoft_del_user_esoft_del_role_esoft_del_user; +IF EXISTS (SELECT name FROM sys.indexes WHERE object_id = OBJECT_ID('esoft_del_user_esoft_del_role','U') AND name = 'ix_esoft_del_user_esoft_del_role_esoft_del_user') drop index ix_esoft_del_user_esoft_del_role_esoft_del_user ON esoft_del_user_esoft_del_role; + +IF OBJECT_ID('fk_esoft_del_user_esoft_del_role_esoft_del_role', 'F') IS NOT NULL alter table esoft_del_user_esoft_del_role drop constraint fk_esoft_del_user_esoft_del_role_esoft_del_role; +IF EXISTS (SELECT name FROM sys.indexes WHERE object_id = OBJECT_ID('esoft_del_user_esoft_del_role','U') AND name = 'ix_esoft_del_user_esoft_del_role_esoft_del_role') drop index ix_esoft_del_user_esoft_del_role_esoft_del_role ON esoft_del_user_esoft_del_role; + +IF OBJECT_ID('fk_rawinherit_uncle_parent_id', 'F') IS NOT NULL alter table rawinherit_uncle drop constraint fk_rawinherit_uncle_parent_id; +IF EXISTS (SELECT name FROM sys.indexes WHERE object_id = OBJECT_ID('rawinherit_uncle','U') AND name = 'ix_rawinherit_uncle_parent_id') drop index ix_rawinherit_uncle_parent_id ON rawinherit_uncle; + +IF OBJECT_ID('fk_evanilla_collection_detail_evanilla_collection_id', 'F') IS NOT NULL alter table evanilla_collection_detail drop constraint fk_evanilla_collection_detail_evanilla_collection_id; +IF EXISTS (SELECT name FROM sys.indexes WHERE object_id = OBJECT_ID('evanilla_collection_detail','U') AND name = 'ix_evanilla_collection_detail_evanilla_collection_id') drop index ix_evanilla_collection_detail_evanilla_collection_id ON evanilla_collection_detail; + +IF OBJECT_ID('fk_ec_enum_person_tags_ec_enum_person_id', 'F') IS NOT NULL alter table ec_enum_person_tags drop constraint fk_ec_enum_person_tags_ec_enum_person_id; +IF EXISTS (SELECT name FROM sys.indexes WHERE object_id = OBJECT_ID('ec_enum_person_tags','U') AND name = 'ix_ec_enum_person_tags_ec_enum_person_id') drop index ix_ec_enum_person_tags_ec_enum_person_id ON ec_enum_person_tags; + +IF OBJECT_ID('fk_ec_person_phone_owner_id', 'F') IS NOT NULL alter table ec_person_phone drop constraint fk_ec_person_phone_owner_id; +IF EXISTS (SELECT name FROM sys.indexes WHERE object_id = OBJECT_ID('ec_person_phone','U') AND name = 'ix_ec_person_phone_owner_id') drop index ix_ec_person_phone_owner_id ON ec_person_phone; + +IF OBJECT_ID('fk_ec_top_person_id', 'F') IS NOT NULL alter table ec_top drop constraint fk_ec_top_person_id; +IF EXISTS (SELECT name FROM sys.indexes WHERE object_id = OBJECT_ID('ec_top','U') AND name = 'ix_ec_top_person_id') drop index ix_ec_top_person_id ON ec_top; + +IF OBJECT_ID('fk_ec_top_ecs_person_ec_top', 'F') IS NOT NULL alter table ec_top_ecs_person drop constraint fk_ec_top_ecs_person_ec_top; +IF EXISTS (SELECT name FROM sys.indexes WHERE object_id = OBJECT_ID('ec_top_ecs_person','U') AND name = 'ix_ec_top_ecs_person_ec_top') drop index ix_ec_top_ecs_person_ec_top ON ec_top_ecs_person; + +IF OBJECT_ID('fk_ec_top_ecs_person_ecs_person', 'F') IS NOT NULL alter table ec_top_ecs_person drop constraint fk_ec_top_ecs_person_ecs_person; +IF EXISTS (SELECT name FROM sys.indexes WHERE object_id = OBJECT_ID('ec_top_ecs_person','U') AND name = 'ix_ec_top_ecs_person_ecs_person') drop index ix_ec_top_ecs_person_ecs_person ON ec_top_ecs_person; + +IF OBJECT_ID('fk_ecbl_person_phone_numbers_person_id', 'F') IS NOT NULL alter table ecbl_person_phone_numbers drop constraint fk_ecbl_person_phone_numbers_person_id; +IF EXISTS (SELECT name FROM sys.indexes WHERE object_id = OBJECT_ID('ecbl_person_phone_numbers','U') AND name = 'ix_ecbl_person_phone_numbers_person_id') drop index ix_ecbl_person_phone_numbers_person_id ON ecbl_person_phone_numbers; + +IF OBJECT_ID('fk_ecbm_person_phone_numbers_person_id', 'F') IS NOT NULL alter table ecbm_person_phone_numbers drop constraint fk_ecbm_person_phone_numbers_person_id; +IF EXISTS (SELECT name FROM sys.indexes WHERE object_id = OBJECT_ID('ecbm_person_phone_numbers','U') AND name = 'ix_ecbm_person_phone_numbers_person_id') drop index ix_ecbm_person_phone_numbers_person_id ON ecbm_person_phone_numbers; + +IF OBJECT_ID('fk_ecm_person_phone_numbers_ecm_person_id', 'F') IS NOT NULL alter table ecm_person_phone_numbers drop constraint fk_ecm_person_phone_numbers_ecm_person_id; +IF EXISTS (SELECT name FROM sys.indexes WHERE object_id = OBJECT_ID('ecm_person_phone_numbers','U') AND name = 'ix_ecm_person_phone_numbers_ecm_person_id') drop index ix_ecm_person_phone_numbers_ecm_person_id ON ecm_person_phone_numbers; + +IF OBJECT_ID('fk_ecmc_person_phone_numbers_ecmc_person_id', 'F') IS NOT NULL alter table ecmc_person_phone_numbers drop constraint fk_ecmc_person_phone_numbers_ecmc_person_id; +IF EXISTS (SELECT name FROM sys.indexes WHERE object_id = OBJECT_ID('ecmc_person_phone_numbers','U') AND name = 'ix_ecmc_person_phone_numbers_ecmc_person_id') drop index ix_ecmc_person_phone_numbers_ecmc_person_id ON ecmc_person_phone_numbers; + +IF OBJECT_ID('fk_ecs_person_phone_ecs_person_id', 'F') IS NOT NULL alter table ecs_person_phone drop constraint fk_ecs_person_phone_ecs_person_id; +IF EXISTS (SELECT name FROM sys.indexes WHERE object_id = OBJECT_ID('ecs_person_phone','U') AND name = 'ix_ecs_person_phone_ecs_person_id') drop index ix_ecs_person_phone_ecs_person_id ON ecs_person_phone; + +IF OBJECT_ID('fk_ecsm_child_ecsm_parent_id', 'F') IS NOT NULL alter table ecsm_child drop constraint fk_ecsm_child_ecsm_parent_id; +IF EXISTS (SELECT name FROM sys.indexes WHERE object_id = OBJECT_ID('ecsm_child','U') AND name = 'ix_ecsm_child_ecsm_parent_id') drop index ix_ecsm_child_ecsm_parent_id ON ecsm_child; + +IF OBJECT_ID('fk_td_child_parent_id', 'F') IS NOT NULL alter table td_child drop constraint fk_td_child_parent_id; +IF EXISTS (SELECT name FROM sys.indexes WHERE object_id = OBJECT_ID('td_child','U') AND name = 'ix_td_child_parent_id') drop index ix_td_child_parent_id ON td_child; + +IF OBJECT_ID('fk_element_bean_complex_bean_id', 'F') IS NOT NULL alter table element_bean drop constraint fk_element_bean_complex_bean_id; +IF EXISTS (SELECT name FROM sys.indexes WHERE object_id = OBJECT_ID('element_bean','U') AND name = 'ix_element_bean_complex_bean_id') drop index ix_element_bean_complex_bean_id ON element_bean; + +IF OBJECT_ID('fk_empl_default_address_id', 'F') IS NOT NULL alter table empl drop constraint fk_empl_default_address_id; +IF EXISTS (SELECT name FROM sys.indexes WHERE object_id = OBJECT_ID('empl','U') AND name = 'ix_empl_default_address_id') drop index ix_empl_default_address_id ON empl; + +IF OBJECT_ID('fk_esd_detail_master_id', 'F') IS NOT NULL alter table esd_detail drop constraint fk_esd_detail_master_id; +IF EXISTS (SELECT name FROM sys.indexes WHERE object_id = OBJECT_ID('esd_detail','U') AND name = 'ix_esd_detail_master_id') drop index ix_esd_detail_master_id ON esd_detail; + +IF OBJECT_ID('fk_grand_parent_person_some_bean_id', 'F') IS NOT NULL alter table grand_parent_person drop constraint fk_grand_parent_person_some_bean_id; +IF EXISTS (SELECT name FROM sys.indexes WHERE object_id = OBJECT_ID('grand_parent_person','U') AND name = 'ix_grand_parent_person_some_bean_id') drop index ix_grand_parent_person_some_bean_id ON grand_parent_person; + +IF OBJECT_ID('fk_survey_group_categoryobjectid', 'F') IS NOT NULL alter table survey_group drop constraint fk_survey_group_categoryobjectid; +IF EXISTS (SELECT name FROM sys.indexes WHERE object_id = OBJECT_ID('survey_group','U') AND name = 'ix_survey_group_categoryobjectid') drop index ix_survey_group_categoryobjectid ON survey_group; + +IF OBJECT_ID('fk_hx_link_doc_hx_link', 'F') IS NOT NULL alter table hx_link_doc drop constraint fk_hx_link_doc_hx_link; +IF EXISTS (SELECT name FROM sys.indexes WHERE object_id = OBJECT_ID('hx_link_doc','U') AND name = 'ix_hx_link_doc_hx_link') drop index ix_hx_link_doc_hx_link ON hx_link_doc; + +IF OBJECT_ID('fk_hx_link_doc_he_doc', 'F') IS NOT NULL alter table hx_link_doc drop constraint fk_hx_link_doc_he_doc; +IF EXISTS (SELECT name FROM sys.indexes WHERE object_id = OBJECT_ID('hx_link_doc','U') AND name = 'ix_hx_link_doc_he_doc') drop index ix_hx_link_doc_he_doc ON hx_link_doc; + +IF OBJECT_ID('fk_hi_link_doc_hi_link', 'F') IS NOT NULL alter table hi_link_doc drop constraint fk_hi_link_doc_hi_link; +IF EXISTS (SELECT name FROM sys.indexes WHERE object_id = OBJECT_ID('hi_link_doc','U') AND name = 'ix_hi_link_doc_hi_link') drop index ix_hi_link_doc_hi_link ON hi_link_doc; + +IF OBJECT_ID('fk_hi_link_doc_hi_doc', 'F') IS NOT NULL alter table hi_link_doc drop constraint fk_hi_link_doc_hi_doc; +IF EXISTS (SELECT name FROM sys.indexes WHERE object_id = OBJECT_ID('hi_link_doc','U') AND name = 'ix_hi_link_doc_hi_doc') drop index ix_hi_link_doc_hi_doc ON hi_link_doc; + +IF OBJECT_ID('fk_hi_tthree_hi_ttwo_id', 'F') IS NOT NULL alter table hi_tthree drop constraint fk_hi_tthree_hi_ttwo_id; +IF EXISTS (SELECT name FROM sys.indexes WHERE object_id = OBJECT_ID('hi_tthree','U') AND name = 'ix_hi_tthree_hi_ttwo_id') drop index ix_hi_tthree_hi_ttwo_id ON hi_tthree; + +IF OBJECT_ID('fk_hi_ttwo_hi_tone_id', 'F') IS NOT NULL alter table hi_ttwo drop constraint fk_hi_ttwo_hi_tone_id; +IF EXISTS (SELECT name FROM sys.indexes WHERE object_id = OBJECT_ID('hi_ttwo','U') AND name = 'ix_hi_ttwo_hi_tone_id') drop index ix_hi_ttwo_hi_tone_id ON hi_ttwo; + +IF EXISTS (SELECT name FROM sys.indexes WHERE object_id = OBJECT_ID('hsd_setting','U') AND name = 'uq_hsd_setting_user_id') drop index uq_hsd_setting_user_id ON hsd_setting; +IF OBJECT_ID('fk_hsd_setting_user_id', 'F') IS NOT NULL alter table hsd_setting drop constraint fk_hsd_setting_user_id; + +IF OBJECT_ID('fk_iaf_segment_status_id', 'F') IS NOT NULL alter table iaf_segment drop constraint fk_iaf_segment_status_id; +IF EXISTS (SELECT name FROM sys.indexes WHERE object_id = OBJECT_ID('iaf_segment','U') AND name = 'ix_iaf_segment_status_id') drop index ix_iaf_segment_status_id ON iaf_segment; + +IF OBJECT_ID('fk_imrelated_owner_id', 'F') IS NOT NULL alter table imrelated drop constraint fk_imrelated_owner_id; +IF EXISTS (SELECT name FROM sys.indexes WHERE object_id = OBJECT_ID('imrelated','U') AND name = 'ix_imrelated_owner_id') drop index ix_imrelated_owner_id ON imrelated; + +IF OBJECT_ID('fk_info_contact_company_id', 'F') IS NOT NULL alter table info_contact drop constraint fk_info_contact_company_id; +IF EXISTS (SELECT name FROM sys.indexes WHERE object_id = OBJECT_ID('info_contact','U') AND name = 'ix_info_contact_company_id') drop index ix_info_contact_company_id ON info_contact; + +IF EXISTS (SELECT name FROM sys.indexes WHERE object_id = OBJECT_ID('info_customer','U') AND name = 'uq_info_customer_company_id') drop index uq_info_customer_company_id ON info_customer; +IF OBJECT_ID('fk_info_customer_company_id', 'F') IS NOT NULL alter table info_customer drop constraint fk_info_customer_company_id; + +IF EXISTS (SELECT name FROM sys.indexes WHERE object_id = OBJECT_ID('inner_report','U') AND name = 'uq_inner_report_forecast_id') drop index uq_inner_report_forecast_id ON inner_report; +IF OBJECT_ID('fk_inner_report_forecast_id', 'F') IS NOT NULL alter table inner_report drop constraint fk_inner_report_forecast_id; + +IF OBJECT_ID('fk_drel_invoice_booking', 'F') IS NOT NULL alter table drel_invoice drop constraint fk_drel_invoice_booking; +IF EXISTS (SELECT name FROM sys.indexes WHERE object_id = OBJECT_ID('drel_invoice','U') AND name = 'ix_drel_invoice_booking') drop index ix_drel_invoice_booking ON drel_invoice; + +IF OBJECT_ID('fk_item_etype', 'F') IS NOT NULL alter table item drop constraint fk_item_etype; +IF EXISTS (SELECT name FROM sys.indexes WHERE object_id = OBJECT_ID('item','U') AND name = 'ix_item_etype') drop index ix_item_etype ON item; + +IF OBJECT_ID('fk_item_eregion', 'F') IS NOT NULL alter table item drop constraint fk_item_eregion; +IF EXISTS (SELECT name FROM sys.indexes WHERE object_id = OBJECT_ID('item','U') AND name = 'ix_item_eregion') drop index ix_item_eregion ON item; + +IF OBJECT_ID('fk_mkeygroup_monkey_mkeygroup', 'F') IS NOT NULL alter table mkeygroup_monkey drop constraint fk_mkeygroup_monkey_mkeygroup; + +IF OBJECT_ID('fk_mkeygroup_monkey_monkey', 'F') IS NOT NULL alter table mkeygroup_monkey drop constraint fk_mkeygroup_monkey_monkey; + +IF OBJECT_ID('fk_trainer_monkey_trainer', 'F') IS NOT NULL alter table trainer_monkey drop constraint fk_trainer_monkey_trainer; + +IF OBJECT_ID('fk_trainer_monkey_monkey', 'F') IS NOT NULL alter table trainer_monkey drop constraint fk_trainer_monkey_monkey; + +IF OBJECT_ID('fk_troop_monkey_troop', 'F') IS NOT NULL alter table troop_monkey drop constraint fk_troop_monkey_troop; + +IF OBJECT_ID('fk_troop_monkey_monkey', 'F') IS NOT NULL alter table troop_monkey drop constraint fk_troop_monkey_monkey; + +IF OBJECT_ID('fk_l2_cldf_reset_bean_child_parent_id', 'F') IS NOT NULL alter table l2_cldf_reset_bean_child drop constraint fk_l2_cldf_reset_bean_child_parent_id; +IF EXISTS (SELECT name FROM sys.indexes WHERE object_id = OBJECT_ID('l2_cldf_reset_bean_child','U') AND name = 'ix_l2_cldf_reset_bean_child_parent_id') drop index ix_l2_cldf_reset_bean_child_parent_id ON l2_cldf_reset_bean_child; + +IF OBJECT_ID('fk_level1_level4_level1', 'F') IS NOT NULL alter table level1_level4 drop constraint fk_level1_level4_level1; +IF EXISTS (SELECT name FROM sys.indexes WHERE object_id = OBJECT_ID('level1_level4','U') AND name = 'ix_level1_level4_level1') drop index ix_level1_level4_level1 ON level1_level4; + +IF OBJECT_ID('fk_level1_level4_level4', 'F') IS NOT NULL alter table level1_level4 drop constraint fk_level1_level4_level4; +IF EXISTS (SELECT name FROM sys.indexes WHERE object_id = OBJECT_ID('level1_level4','U') AND name = 'ix_level1_level4_level4') drop index ix_level1_level4_level4 ON level1_level4; + +IF OBJECT_ID('fk_level1_level2_level1', 'F') IS NOT NULL alter table level1_level2 drop constraint fk_level1_level2_level1; +IF EXISTS (SELECT name FROM sys.indexes WHERE object_id = OBJECT_ID('level1_level2','U') AND name = 'ix_level1_level2_level1') drop index ix_level1_level2_level1 ON level1_level2; + +IF OBJECT_ID('fk_level1_level2_level2', 'F') IS NOT NULL alter table level1_level2 drop constraint fk_level1_level2_level2; +IF EXISTS (SELECT name FROM sys.indexes WHERE object_id = OBJECT_ID('level1_level2','U') AND name = 'ix_level1_level2_level2') drop index ix_level1_level2_level2 ON level1_level2; + +IF OBJECT_ID('fk_level2_level3_level2', 'F') IS NOT NULL alter table level2_level3 drop constraint fk_level2_level3_level2; +IF EXISTS (SELECT name FROM sys.indexes WHERE object_id = OBJECT_ID('level2_level3','U') AND name = 'ix_level2_level3_level2') drop index ix_level2_level3_level2 ON level2_level3; + +IF OBJECT_ID('fk_level2_level3_level3', 'F') IS NOT NULL alter table level2_level3 drop constraint fk_level2_level3_level3; +IF EXISTS (SELECT name FROM sys.indexes WHERE object_id = OBJECT_ID('level2_level3','U') AND name = 'ix_level2_level3_level3') drop index ix_level2_level3_level3 ON level2_level3; + +IF OBJECT_ID('fk_link_id', 'F') IS NOT NULL alter table link drop constraint fk_link_id; + +IF OBJECT_ID('fk_la_attr_value_attribute_la_attr_value', 'F') IS NOT NULL alter table la_attr_value_attribute drop constraint fk_la_attr_value_attribute_la_attr_value; +IF EXISTS (SELECT name FROM sys.indexes WHERE object_id = OBJECT_ID('la_attr_value_attribute','U') AND name = 'ix_la_attr_value_attribute_la_attr_value') drop index ix_la_attr_value_attribute_la_attr_value ON la_attr_value_attribute; + +IF OBJECT_ID('fk_la_attr_value_attribute_attribute', 'F') IS NOT NULL alter table la_attr_value_attribute drop constraint fk_la_attr_value_attribute_attribute; +IF EXISTS (SELECT name FROM sys.indexes WHERE object_id = OBJECT_ID('la_attr_value_attribute','U') AND name = 'ix_la_attr_value_attribute_attribute') drop index ix_la_attr_value_attribute_attribute ON la_attr_value_attribute; + +IF OBJECT_ID('fk_looney_tune_id', 'F') IS NOT NULL alter table looney drop constraint fk_looney_tune_id; +IF EXISTS (SELECT name FROM sys.indexes WHERE object_id = OBJECT_ID('looney','U') AND name = 'ix_looney_tune_id') drop index ix_looney_tune_id ON looney; + +IF OBJECT_ID('fk_mcontact_customer_id', 'F') IS NOT NULL alter table mcontact drop constraint fk_mcontact_customer_id; +IF EXISTS (SELECT name FROM sys.indexes WHERE object_id = OBJECT_ID('mcontact','U') AND name = 'ix_mcontact_customer_id') drop index ix_mcontact_customer_id ON mcontact; + +IF OBJECT_ID('fk_mcontact_message_contact_id', 'F') IS NOT NULL alter table mcontact_message drop constraint fk_mcontact_message_contact_id; +IF EXISTS (SELECT name FROM sys.indexes WHERE object_id = OBJECT_ID('mcontact_message','U') AND name = 'ix_mcontact_message_contact_id') drop index ix_mcontact_message_contact_id ON mcontact_message; + +IF OBJECT_ID('fk_mcustomer_shipping_address_id', 'F') IS NOT NULL alter table mcustomer drop constraint fk_mcustomer_shipping_address_id; +IF EXISTS (SELECT name FROM sys.indexes WHERE object_id = OBJECT_ID('mcustomer','U') AND name = 'ix_mcustomer_shipping_address_id') drop index ix_mcustomer_shipping_address_id ON mcustomer; + +IF OBJECT_ID('fk_mcustomer_billing_address_id', 'F') IS NOT NULL alter table mcustomer drop constraint fk_mcustomer_billing_address_id; +IF EXISTS (SELECT name FROM sys.indexes WHERE object_id = OBJECT_ID('mcustomer','U') AND name = 'ix_mcustomer_billing_address_id') drop index ix_mcustomer_billing_address_id ON mcustomer; + +IF OBJECT_ID('fk_mmachine_mgroup_mmachine', 'F') IS NOT NULL alter table mmachine_mgroup drop constraint fk_mmachine_mgroup_mmachine; +IF EXISTS (SELECT name FROM sys.indexes WHERE object_id = OBJECT_ID('mmachine_mgroup','U') AND name = 'ix_mmachine_mgroup_mmachine') drop index ix_mmachine_mgroup_mmachine ON mmachine_mgroup; + +IF OBJECT_ID('fk_mmachine_mgroup_mgroup', 'F') IS NOT NULL alter table mmachine_mgroup drop constraint fk_mmachine_mgroup_mgroup; +IF EXISTS (SELECT name FROM sys.indexes WHERE object_id = OBJECT_ID('mmachine_mgroup','U') AND name = 'ix_mmachine_mgroup_mgroup') drop index ix_mmachine_mgroup_mgroup ON mmachine_mgroup; + +IF EXISTS (SELECT name FROM sys.indexes WHERE object_id = OBJECT_ID('mprinter','U') AND name = 'uq_mprinter_last_swap_cyan_id') drop index uq_mprinter_last_swap_cyan_id ON mprinter; +IF EXISTS (SELECT name FROM sys.indexes WHERE object_id = OBJECT_ID('mprinter','U') AND name = 'uq_mprinter_last_swap_magenta_id') drop index uq_mprinter_last_swap_magenta_id ON mprinter; +IF EXISTS (SELECT name FROM sys.indexes WHERE object_id = OBJECT_ID('mprinter','U') AND name = 'uq_mprinter_last_swap_yellow_id') drop index uq_mprinter_last_swap_yellow_id ON mprinter; +IF EXISTS (SELECT name FROM sys.indexes WHERE object_id = OBJECT_ID('mprinter','U') AND name = 'uq_mprinter_last_swap_black_id') drop index uq_mprinter_last_swap_black_id ON mprinter; +IF OBJECT_ID('fk_mprinter_current_state_id', 'F') IS NOT NULL alter table mprinter drop constraint fk_mprinter_current_state_id; +IF EXISTS (SELECT name FROM sys.indexes WHERE object_id = OBJECT_ID('mprinter','U') AND name = 'ix_mprinter_current_state_id') drop index ix_mprinter_current_state_id ON mprinter; + +IF OBJECT_ID('fk_mprinter_last_swap_cyan_id', 'F') IS NOT NULL alter table mprinter drop constraint fk_mprinter_last_swap_cyan_id; + +IF OBJECT_ID('fk_mprinter_last_swap_magenta_id', 'F') IS NOT NULL alter table mprinter drop constraint fk_mprinter_last_swap_magenta_id; + +IF OBJECT_ID('fk_mprinter_last_swap_yellow_id', 'F') IS NOT NULL alter table mprinter drop constraint fk_mprinter_last_swap_yellow_id; + +IF OBJECT_ID('fk_mprinter_last_swap_black_id', 'F') IS NOT NULL alter table mprinter drop constraint fk_mprinter_last_swap_black_id; + +IF OBJECT_ID('fk_mprinter_state_printer_id', 'F') IS NOT NULL alter table mprinter_state drop constraint fk_mprinter_state_printer_id; +IF EXISTS (SELECT name FROM sys.indexes WHERE object_id = OBJECT_ID('mprinter_state','U') AND name = 'ix_mprinter_state_printer_id') drop index ix_mprinter_state_printer_id ON mprinter_state; + +IF OBJECT_ID('fk_mprofile_picture_id', 'F') IS NOT NULL alter table mprofile drop constraint fk_mprofile_picture_id; +IF EXISTS (SELECT name FROM sys.indexes WHERE object_id = OBJECT_ID('mprofile','U') AND name = 'ix_mprofile_picture_id') drop index ix_mprofile_picture_id ON mprofile; + +IF OBJECT_ID('fk_mrole_muser_mrole', 'F') IS NOT NULL alter table mrole_muser drop constraint fk_mrole_muser_mrole; +IF EXISTS (SELECT name FROM sys.indexes WHERE object_id = OBJECT_ID('mrole_muser','U') AND name = 'ix_mrole_muser_mrole') drop index ix_mrole_muser_mrole ON mrole_muser; + +IF OBJECT_ID('fk_mrole_muser_muser', 'F') IS NOT NULL alter table mrole_muser drop constraint fk_mrole_muser_muser; +IF EXISTS (SELECT name FROM sys.indexes WHERE object_id = OBJECT_ID('mrole_muser','U') AND name = 'ix_mrole_muser_muser') drop index ix_mrole_muser_muser ON mrole_muser; + +IF OBJECT_ID('fk_muser_user_type_id', 'F') IS NOT NULL alter table muser drop constraint fk_muser_user_type_id; +IF EXISTS (SELECT name FROM sys.indexes WHERE object_id = OBJECT_ID('muser','U') AND name = 'ix_muser_user_type_id') drop index ix_muser_user_type_id ON muser; + +IF OBJECT_ID('fk_mail_user_inbox_mail_user', 'F') IS NOT NULL alter table mail_user_inbox drop constraint fk_mail_user_inbox_mail_user; +IF EXISTS (SELECT name FROM sys.indexes WHERE object_id = OBJECT_ID('mail_user_inbox','U') AND name = 'ix_mail_user_inbox_mail_user') drop index ix_mail_user_inbox_mail_user ON mail_user_inbox; + +IF OBJECT_ID('fk_mail_user_inbox_mail_box', 'F') IS NOT NULL alter table mail_user_inbox drop constraint fk_mail_user_inbox_mail_box; +IF EXISTS (SELECT name FROM sys.indexes WHERE object_id = OBJECT_ID('mail_user_inbox','U') AND name = 'ix_mail_user_inbox_mail_box') drop index ix_mail_user_inbox_mail_box ON mail_user_inbox; + +IF OBJECT_ID('fk_mail_user_outbox_mail_user', 'F') IS NOT NULL alter table mail_user_outbox drop constraint fk_mail_user_outbox_mail_user; +IF EXISTS (SELECT name FROM sys.indexes WHERE object_id = OBJECT_ID('mail_user_outbox','U') AND name = 'ix_mail_user_outbox_mail_user') drop index ix_mail_user_outbox_mail_user ON mail_user_outbox; + +IF OBJECT_ID('fk_mail_user_outbox_mail_box', 'F') IS NOT NULL alter table mail_user_outbox drop constraint fk_mail_user_outbox_mail_box; +IF EXISTS (SELECT name FROM sys.indexes WHERE object_id = OBJECT_ID('mail_user_outbox','U') AND name = 'ix_mail_user_outbox_mail_box') drop index ix_mail_user_outbox_mail_box ON mail_user_outbox; + +IF OBJECT_ID('fk_c_message_conversation_id', 'F') IS NOT NULL alter table c_message drop constraint fk_c_message_conversation_id; +IF EXISTS (SELECT name FROM sys.indexes WHERE object_id = OBJECT_ID('c_message','U') AND name = 'ix_c_message_conversation_id') drop index ix_c_message_conversation_id ON c_message; + +IF OBJECT_ID('fk_c_message_user_id', 'F') IS NOT NULL alter table c_message drop constraint fk_c_message_user_id; +IF EXISTS (SELECT name FROM sys.indexes WHERE object_id = OBJECT_ID('c_message','U') AND name = 'ix_c_message_user_id') drop index ix_c_message_user_id ON c_message; + +IF OBJECT_ID('fk_meter_contract_data_special_needs_client_id', 'F') IS NOT NULL alter table meter_contract_data drop constraint fk_meter_contract_data_special_needs_client_id; + +IF EXISTS (SELECT name FROM sys.indexes WHERE object_id = OBJECT_ID('meter_special_needs_client','U') AND name = 'uq_meter_special_needs_client_primary_id') drop index uq_meter_special_needs_client_primary_id ON meter_special_needs_client; +IF OBJECT_ID('fk_meter_special_needs_client_primary_id', 'F') IS NOT NULL alter table meter_special_needs_client drop constraint fk_meter_special_needs_client_primary_id; + +IF EXISTS (SELECT name FROM sys.indexes WHERE object_id = OBJECT_ID('meter_version','U') AND name = 'uq_meter_version_address_data_id') drop index uq_meter_version_address_data_id ON meter_version; +IF OBJECT_ID('fk_meter_version_address_data_id', 'F') IS NOT NULL alter table meter_version drop constraint fk_meter_version_address_data_id; + +IF OBJECT_ID('fk_meter_version_contract_data_id', 'F') IS NOT NULL alter table meter_version drop constraint fk_meter_version_contract_data_id; + +IF OBJECT_ID('fk_mnoc_user_mnoc_role_mnoc_user', 'F') IS NOT NULL alter table mnoc_user_mnoc_role drop constraint fk_mnoc_user_mnoc_role_mnoc_user; +IF EXISTS (SELECT name FROM sys.indexes WHERE object_id = OBJECT_ID('mnoc_user_mnoc_role','U') AND name = 'ix_mnoc_user_mnoc_role_mnoc_user') drop index ix_mnoc_user_mnoc_role_mnoc_user ON mnoc_user_mnoc_role; + +IF OBJECT_ID('fk_mnoc_user_mnoc_role_mnoc_role', 'F') IS NOT NULL alter table mnoc_user_mnoc_role drop constraint fk_mnoc_user_mnoc_role_mnoc_role; +IF EXISTS (SELECT name FROM sys.indexes WHERE object_id = OBJECT_ID('mnoc_user_mnoc_role','U') AND name = 'ix_mnoc_user_mnoc_role_mnoc_role') drop index ix_mnoc_user_mnoc_role_mnoc_role ON mnoc_user_mnoc_role; + +IF OBJECT_ID('fk_mny_b_a_id', 'F') IS NOT NULL alter table mny_b drop constraint fk_mny_b_a_id; +IF EXISTS (SELECT name FROM sys.indexes WHERE object_id = OBJECT_ID('mny_b','U') AND name = 'ix_mny_b_a_id') drop index ix_mny_b_a_id ON mny_b; + +IF OBJECT_ID('fk_mny_b_mny_c_mny_b', 'F') IS NOT NULL alter table mny_b_mny_c drop constraint fk_mny_b_mny_c_mny_b; +IF EXISTS (SELECT name FROM sys.indexes WHERE object_id = OBJECT_ID('mny_b_mny_c','U') AND name = 'ix_mny_b_mny_c_mny_b') drop index ix_mny_b_mny_c_mny_b ON mny_b_mny_c; + +IF OBJECT_ID('fk_mny_b_mny_c_mny_c', 'F') IS NOT NULL alter table mny_b_mny_c drop constraint fk_mny_b_mny_c_mny_c; +IF EXISTS (SELECT name FROM sys.indexes WHERE object_id = OBJECT_ID('mny_b_mny_c','U') AND name = 'ix_mny_b_mny_c_mny_c') drop index ix_mny_b_mny_c_mny_c ON mny_b_mny_c; + +IF OBJECT_ID('fk_subtopics_mny_topic_1', 'F') IS NOT NULL alter table subtopics drop constraint fk_subtopics_mny_topic_1; +IF EXISTS (SELECT name FROM sys.indexes WHERE object_id = OBJECT_ID('subtopics','U') AND name = 'ix_subtopics_mny_topic_1') drop index ix_subtopics_mny_topic_1 ON subtopics; + +IF OBJECT_ID('fk_subtopics_mny_topic_2', 'F') IS NOT NULL alter table subtopics drop constraint fk_subtopics_mny_topic_2; +IF EXISTS (SELECT name FROM sys.indexes WHERE object_id = OBJECT_ID('subtopics','U') AND name = 'ix_subtopics_mny_topic_2') drop index ix_subtopics_mny_topic_2 ON subtopics; + +IF OBJECT_ID('fk_mp_role_mp_user_id', 'F') IS NOT NULL alter table mp_role drop constraint fk_mp_role_mp_user_id; +IF EXISTS (SELECT name FROM sys.indexes WHERE object_id = OBJECT_ID('mp_role','U') AND name = 'ix_mp_role_mp_user_id') drop index ix_mp_role_mp_user_id ON mp_role; + +IF OBJECT_ID('fk_ms_many_a_many_b_ms_many_a', 'F') IS NOT NULL alter table ms_many_a_many_b drop constraint fk_ms_many_a_many_b_ms_many_a; +IF EXISTS (SELECT name FROM sys.indexes WHERE object_id = OBJECT_ID('ms_many_a_many_b','U') AND name = 'ix_ms_many_a_many_b_ms_many_a') drop index ix_ms_many_a_many_b_ms_many_a ON ms_many_a_many_b; + +IF OBJECT_ID('fk_ms_many_a_many_b_ms_many_b', 'F') IS NOT NULL alter table ms_many_a_many_b drop constraint fk_ms_many_a_many_b_ms_many_b; +IF EXISTS (SELECT name FROM sys.indexes WHERE object_id = OBJECT_ID('ms_many_a_many_b','U') AND name = 'ix_ms_many_a_many_b_ms_many_b') drop index ix_ms_many_a_many_b_ms_many_b ON ms_many_a_many_b; + +IF OBJECT_ID('fk_ms_many_b_many_a_ms_many_b', 'F') IS NOT NULL alter table ms_many_b_many_a drop constraint fk_ms_many_b_many_a_ms_many_b; +IF EXISTS (SELECT name FROM sys.indexes WHERE object_id = OBJECT_ID('ms_many_b_many_a','U') AND name = 'ix_ms_many_b_many_a_ms_many_b') drop index ix_ms_many_b_many_a_ms_many_b ON ms_many_b_many_a; + +IF OBJECT_ID('fk_ms_many_b_many_a_ms_many_a', 'F') IS NOT NULL alter table ms_many_b_many_a drop constraint fk_ms_many_b_many_a_ms_many_a; +IF EXISTS (SELECT name FROM sys.indexes WHERE object_id = OBJECT_ID('ms_many_b_many_a','U') AND name = 'ix_ms_many_b_many_a_ms_many_a') drop index ix_ms_many_b_many_a_ms_many_a ON ms_many_b_many_a; + +IF OBJECT_ID('fk_my_lob_size_join_many_parent_id', 'F') IS NOT NULL alter table my_lob_size_join_many drop constraint fk_my_lob_size_join_many_parent_id; +IF EXISTS (SELECT name FROM sys.indexes WHERE object_id = OBJECT_ID('my_lob_size_join_many','U') AND name = 'ix_my_lob_size_join_many_parent_id') drop index ix_my_lob_size_join_many_parent_id ON my_lob_size_join_many; + +IF OBJECT_ID('fk_o_bean_child_cached_bean_id', 'F') IS NOT NULL alter table o_bean_child drop constraint fk_o_bean_child_cached_bean_id; +IF EXISTS (SELECT name FROM sys.indexes WHERE object_id = OBJECT_ID('o_bean_child','U') AND name = 'ix_o_bean_child_cached_bean_id') drop index ix_o_bean_child_cached_bean_id ON o_bean_child; + +IF EXISTS (SELECT name FROM sys.indexes WHERE object_id = OBJECT_ID('ocached_app','U') AND name = 'uq_ocached_app_app_name') drop index uq_ocached_app_app_name ON ocached_app; +IF EXISTS (SELECT name FROM sys.indexes WHERE object_id = OBJECT_ID('ocached_app_detail','U') AND name = 'uq_ocached_app_detail_app_id_detail') drop index uq_ocached_app_detail_app_id_detail ON ocached_app_detail; +IF OBJECT_ID('fk_ocached_app_detail_app_id', 'F') IS NOT NULL alter table ocached_app_detail drop constraint fk_ocached_app_detail_app_id; +IF EXISTS (SELECT name FROM sys.indexes WHERE object_id = OBJECT_ID('ocached_app_detail','U') AND name = 'ix_ocached_app_detail_app_id') drop index ix_ocached_app_detail_app_id ON ocached_app_detail; + +IF OBJECT_ID('fk_o_cached_bean_country_o_cached_bean', 'F') IS NOT NULL alter table o_cached_bean_country drop constraint fk_o_cached_bean_country_o_cached_bean; +IF EXISTS (SELECT name FROM sys.indexes WHERE object_id = OBJECT_ID('o_cached_bean_country','U') AND name = 'ix_o_cached_bean_country_o_cached_bean') drop index ix_o_cached_bean_country_o_cached_bean ON o_cached_bean_country; + +IF OBJECT_ID('fk_o_cached_bean_country_o_country', 'F') IS NOT NULL alter table o_cached_bean_country drop constraint fk_o_cached_bean_country_o_country; +IF EXISTS (SELECT name FROM sys.indexes WHERE object_id = OBJECT_ID('o_cached_bean_country','U') AND name = 'ix_o_cached_bean_country_o_country') drop index ix_o_cached_bean_country_o_country ON o_cached_bean_country; + +IF OBJECT_ID('fk_o_cached_bean_child_cached_bean_id', 'F') IS NOT NULL alter table o_cached_bean_child drop constraint fk_o_cached_bean_child_cached_bean_id; +IF EXISTS (SELECT name FROM sys.indexes WHERE object_id = OBJECT_ID('o_cached_bean_child','U') AND name = 'ix_o_cached_bean_child_cached_bean_id') drop index ix_o_cached_bean_child_cached_bean_id ON o_cached_bean_child; + +IF EXISTS (SELECT name FROM sys.indexes WHERE object_id = OBJECT_ID('ocompany','U') AND name = 'uq_ocompany_corp_id') drop index uq_ocompany_corp_id ON ocompany; +IF EXISTS (SELECT name FROM sys.indexes WHERE object_id = OBJECT_ID('oengine','U') AND name = 'uq_oengine_car_id') drop index uq_oengine_car_id ON oengine; +IF OBJECT_ID('fk_oengine_car_id', 'F') IS NOT NULL alter table oengine drop constraint fk_oengine_car_id; + +IF EXISTS (SELECT name FROM sys.indexes WHERE object_id = OBJECT_ID('ogear_box','U') AND name = 'uq_ogear_box_car_id') drop index uq_ogear_box_car_id ON ogear_box; +IF OBJECT_ID('fk_ogear_box_car_id', 'F') IS NOT NULL alter table ogear_box drop constraint fk_ogear_box_car_id; + +IF OBJECT_ID('fk_omvertex_other_omvertex_id', 'F') IS NOT NULL alter table omvertex_other drop constraint fk_omvertex_other_omvertex_id; +IF EXISTS (SELECT name FROM sys.indexes WHERE object_id = OBJECT_ID('omvertex_other','U') AND name = 'ix_omvertex_other_omvertex_id') drop index ix_omvertex_other_omvertex_id ON omvertex_other; + +IF OBJECT_ID('fk_oroad_show_msg_company_id', 'F') IS NOT NULL alter table oroad_show_msg drop constraint fk_oroad_show_msg_company_id; + +IF OBJECT_ID('fk_om_account_child_dbo_banana_rama_id', 'F') IS NOT NULL alter table om_account_child_dbo drop constraint fk_om_account_child_dbo_banana_rama_id; +IF EXISTS (SELECT name FROM sys.indexes WHERE object_id = OBJECT_ID('om_account_child_dbo','U') AND name = 'ix_om_account_child_dbo_banana_rama_id') drop index ix_om_account_child_dbo_banana_rama_id ON om_account_child_dbo; + +IF OBJECT_ID('fk_om_basic_child_parent_id', 'F') IS NOT NULL alter table om_basic_child drop constraint fk_om_basic_child_parent_id; +IF EXISTS (SELECT name FROM sys.indexes WHERE object_id = OBJECT_ID('om_basic_child','U') AND name = 'ix_om_basic_child_parent_id') drop index ix_om_basic_child_parent_id ON om_basic_child; + +IF OBJECT_ID('fk_om_ordered_detail_master_id', 'F') IS NOT NULL alter table om_ordered_detail drop constraint fk_om_ordered_detail_master_id; +IF EXISTS (SELECT name FROM sys.indexes WHERE object_id = OBJECT_ID('om_ordered_detail','U') AND name = 'ix_om_ordered_detail_master_id') drop index ix_om_ordered_detail_master_id ON om_ordered_detail; + +IF OBJECT_ID('fk_o_order_kcustomer_id', 'F') IS NOT NULL alter table o_order drop constraint fk_o_order_kcustomer_id; +IF EXISTS (SELECT name FROM sys.indexes WHERE object_id = OBJECT_ID('o_order','U') AND name = 'ix_o_order_kcustomer_id') drop index ix_o_order_kcustomer_id ON o_order; + +IF OBJECT_ID('fk_o_order_detail_order_id', 'F') IS NOT NULL alter table o_order_detail drop constraint fk_o_order_detail_order_id; +IF EXISTS (SELECT name FROM sys.indexes WHERE object_id = OBJECT_ID('o_order_detail','U') AND name = 'ix_o_order_detail_order_id') drop index ix_o_order_detail_order_id ON o_order_detail; + +IF OBJECT_ID('fk_o_order_detail_product_id', 'F') IS NOT NULL alter table o_order_detail drop constraint fk_o_order_detail_product_id; +IF EXISTS (SELECT name FROM sys.indexes WHERE object_id = OBJECT_ID('o_order_detail','U') AND name = 'ix_o_order_detail_product_id') drop index ix_o_order_detail_product_id ON o_order_detail; + +IF OBJECT_ID('fk_s_order_items_order_uuid', 'F') IS NOT NULL alter table s_order_items drop constraint fk_s_order_items_order_uuid; +IF EXISTS (SELECT name FROM sys.indexes WHERE object_id = OBJECT_ID('s_order_items','U') AND name = 'ix_s_order_items_order_uuid') drop index ix_s_order_items_order_uuid ON s_order_items; + +IF OBJECT_ID('fk_or_order_ship_order_id', 'F') IS NOT NULL alter table or_order_ship drop constraint fk_or_order_ship_order_id; +IF EXISTS (SELECT name FROM sys.indexes WHERE object_id = OBJECT_ID('or_order_ship','U') AND name = 'ix_or_order_ship_order_id') drop index ix_or_order_ship_order_id ON or_order_ship; + +IF OBJECT_ID('fk_organization_node_parent_tree_node_id', 'F') IS NOT NULL alter table organization_node drop constraint fk_organization_node_parent_tree_node_id; + +IF OBJECT_ID('fk_orp_detail_master_id', 'F') IS NOT NULL alter table orp_detail drop constraint fk_orp_detail_master_id; +IF EXISTS (SELECT name FROM sys.indexes WHERE object_id = OBJECT_ID('orp_detail','U') AND name = 'ix_orp_detail_master_id') drop index ix_orp_detail_master_id ON orp_detail; + +IF OBJECT_ID('fk_orp_detail2_orp_master2_id', 'F') IS NOT NULL alter table orp_detail2 drop constraint fk_orp_detail2_orp_master2_id; +IF EXISTS (SELECT name FROM sys.indexes WHERE object_id = OBJECT_ID('orp_detail2','U') AND name = 'ix_orp_detail2_orp_master2_id') drop index ix_orp_detail2_orp_master2_id ON orp_detail2; + +IF EXISTS (SELECT name FROM sys.indexes WHERE object_id = OBJECT_ID('oto_atwo','U') AND name = 'uq_oto_atwo_aone_id') drop index uq_oto_atwo_aone_id ON oto_atwo; +IF OBJECT_ID('fk_oto_atwo_aone_id', 'F') IS NOT NULL alter table oto_atwo drop constraint fk_oto_atwo_aone_id; + +IF OBJECT_ID('fk_oto_bchild_master_id', 'F') IS NOT NULL alter table oto_bchild drop constraint fk_oto_bchild_master_id; + +IF EXISTS (SELECT name FROM sys.indexes WHERE object_id = OBJECT_ID('oto_child','U') AND name = 'uq_oto_child_master_id') drop index uq_oto_child_master_id ON oto_child; +IF OBJECT_ID('fk_oto_child_master_id', 'F') IS NOT NULL alter table oto_child drop constraint fk_oto_child_master_id; + +IF EXISTS (SELECT name FROM sys.indexes WHERE object_id = OBJECT_ID('oto_cust_address','U') AND name = 'uq_oto_cust_address_customer_cid') drop index uq_oto_cust_address_customer_cid ON oto_cust_address; +IF OBJECT_ID('fk_oto_cust_address_customer_cid', 'F') IS NOT NULL alter table oto_cust_address drop constraint fk_oto_cust_address_customer_cid; + +IF EXISTS (SELECT name FROM sys.indexes WHERE object_id = OBJECT_ID('oto_level_a','U') AND name = 'uq_oto_level_a_b_id') drop index uq_oto_level_a_b_id ON oto_level_a; +IF OBJECT_ID('fk_oto_level_a_b_id', 'F') IS NOT NULL alter table oto_level_a drop constraint fk_oto_level_a_b_id; + +IF EXISTS (SELECT name FROM sys.indexes WHERE object_id = OBJECT_ID('oto_level_b','U') AND name = 'uq_oto_level_b_c_id') drop index uq_oto_level_b_c_id ON oto_level_b; +IF OBJECT_ID('fk_oto_level_b_c_id', 'F') IS NOT NULL alter table oto_level_b drop constraint fk_oto_level_b_c_id; + +IF OBJECT_ID('fk_oto_prime_extra_eid', 'F') IS NOT NULL alter table oto_prime_extra drop constraint fk_oto_prime_extra_eid; + +IF EXISTS (SELECT name FROM sys.indexes WHERE object_id = OBJECT_ID('oto_sd_child','U') AND name = 'uq_oto_sd_child_master_id') drop index uq_oto_sd_child_master_id ON oto_sd_child; +IF OBJECT_ID('fk_oto_sd_child_master_id', 'F') IS NOT NULL alter table oto_sd_child drop constraint fk_oto_sd_child_master_id; + +IF OBJECT_ID('fk_oto_th_many_oto_th_top_id', 'F') IS NOT NULL alter table oto_th_many drop constraint fk_oto_th_many_oto_th_top_id; +IF EXISTS (SELECT name FROM sys.indexes WHERE object_id = OBJECT_ID('oto_th_many','U') AND name = 'ix_oto_th_many_oto_th_top_id') drop index ix_oto_th_many_oto_th_top_id ON oto_th_many; + +IF EXISTS (SELECT name FROM sys.indexes WHERE object_id = OBJECT_ID('oto_th_one','U') AND name = 'uq_oto_th_one_many_id') drop index uq_oto_th_one_many_id ON oto_th_one; +IF OBJECT_ID('fk_oto_th_one_many_id', 'F') IS NOT NULL alter table oto_th_one drop constraint fk_oto_th_one_many_id; + +IF OBJECT_ID('fk_oto_ubprime_extra_eid', 'F') IS NOT NULL alter table oto_ubprime_extra drop constraint fk_oto_ubprime_extra_eid; + +IF EXISTS (SELECT name FROM sys.indexes WHERE object_id = OBJECT_ID('oto_user_model','U') AND name = 'uq_oto_user_model_user_optional_id') drop index uq_oto_user_model_user_optional_id ON oto_user_model; +IF OBJECT_ID('fk_oto_user_model_user_optional_id', 'F') IS NOT NULL alter table oto_user_model drop constraint fk_oto_user_model_user_optional_id; + +IF EXISTS (SELECT name FROM sys.indexes WHERE object_id = OBJECT_ID('pfile','U') AND name = 'uq_pfile_file_content_id') drop index uq_pfile_file_content_id ON pfile; +IF EXISTS (SELECT name FROM sys.indexes WHERE object_id = OBJECT_ID('pfile','U') AND name = 'uq_pfile_file_content2_id') drop index uq_pfile_file_content2_id ON pfile; +IF OBJECT_ID('fk_pfile_file_content_id', 'F') IS NOT NULL alter table pfile drop constraint fk_pfile_file_content_id; + +IF OBJECT_ID('fk_pfile_file_content2_id', 'F') IS NOT NULL alter table pfile drop constraint fk_pfile_file_content2_id; + +IF EXISTS (SELECT name FROM sys.indexes WHERE object_id = OBJECT_ID('paggview','U') AND name = 'uq_paggview_pview_id') drop index uq_paggview_pview_id ON paggview; +IF OBJECT_ID('fk_paggview_pview_id', 'F') IS NOT NULL alter table paggview drop constraint fk_paggview_pview_id; + +IF OBJECT_ID('fk_pallet_location_zone_sid', 'F') IS NOT NULL alter table pallet_location drop constraint fk_pallet_location_zone_sid; +IF EXISTS (SELECT name FROM sys.indexes WHERE object_id = OBJECT_ID('pallet_location','U') AND name = 'ix_pallet_location_zone_sid') drop index ix_pallet_location_zone_sid ON pallet_location; + +IF EXISTS (SELECT name FROM sys.indexes WHERE object_id = OBJECT_ID('parcel_location','U') AND name = 'uq_parcel_location_parcelid') drop index uq_parcel_location_parcelid ON parcel_location; +IF OBJECT_ID('fk_parcel_location_parcelid', 'F') IS NOT NULL alter table parcel_location drop constraint fk_parcel_location_parcelid; + +IF OBJECT_ID('fk_rawinherit_parent_rawinherit_data_rawinherit_parent', 'F') IS NOT NULL alter table rawinherit_parent_rawinherit_data drop constraint fk_rawinherit_parent_rawinherit_data_rawinherit_parent; +IF EXISTS (SELECT name FROM sys.indexes WHERE object_id = OBJECT_ID('rawinherit_parent_rawinherit_data','U') AND name = 'ix_rawinherit_parent_rawinherit_data_rawinherit_parent') drop index ix_rawinherit_parent_rawinherit_data_rawinherit_parent ON rawinherit_parent_rawinherit_data; + +IF OBJECT_ID('fk_rawinherit_parent_rawinherit_data_rawinherit_data', 'F') IS NOT NULL alter table rawinherit_parent_rawinherit_data drop constraint fk_rawinherit_parent_rawinherit_data_rawinherit_data; +IF EXISTS (SELECT name FROM sys.indexes WHERE object_id = OBJECT_ID('rawinherit_parent_rawinherit_data','U') AND name = 'ix_rawinherit_parent_rawinherit_data_rawinherit_data') drop index ix_rawinherit_parent_rawinherit_data_rawinherit_data ON rawinherit_parent_rawinherit_data; + +IF OBJECT_ID('fk_parent_person_some_bean_id', 'F') IS NOT NULL alter table parent_person drop constraint fk_parent_person_some_bean_id; +IF EXISTS (SELECT name FROM sys.indexes WHERE object_id = OBJECT_ID('parent_person','U') AND name = 'ix_parent_person_some_bean_id') drop index ix_parent_person_some_bean_id ON parent_person; + +IF OBJECT_ID('fk_parent_person_parent_identifier', 'F') IS NOT NULL alter table parent_person drop constraint fk_parent_person_parent_identifier; +IF EXISTS (SELECT name FROM sys.indexes WHERE object_id = OBJECT_ID('parent_person','U') AND name = 'ix_parent_person_parent_identifier') drop index ix_parent_person_parent_identifier ON parent_person; + +IF OBJECT_ID('fk_c_participation_conversation_id', 'F') IS NOT NULL alter table c_participation drop constraint fk_c_participation_conversation_id; +IF EXISTS (SELECT name FROM sys.indexes WHERE object_id = OBJECT_ID('c_participation','U') AND name = 'ix_c_participation_conversation_id') drop index ix_c_participation_conversation_id ON c_participation; + +IF OBJECT_ID('fk_c_participation_user_id', 'F') IS NOT NULL alter table c_participation drop constraint fk_c_participation_user_id; +IF EXISTS (SELECT name FROM sys.indexes WHERE object_id = OBJECT_ID('c_participation','U') AND name = 'ix_c_participation_user_id') drop index ix_c_participation_user_id ON c_participation; + +IF OBJECT_ID('fk_pcf_calendar_pcf_person_id', 'F') IS NOT NULL alter table pcf_calendar drop constraint fk_pcf_calendar_pcf_person_id; +IF EXISTS (SELECT name FROM sys.indexes WHERE object_id = OBJECT_ID('pcf_calendar','U') AND name = 'ix_pcf_calendar_pcf_person_id') drop index ix_pcf_calendar_pcf_person_id ON pcf_calendar; + +IF OBJECT_ID('fk_pcf_city_pcf_country_id', 'F') IS NOT NULL alter table pcf_city drop constraint fk_pcf_city_pcf_country_id; +IF EXISTS (SELECT name FROM sys.indexes WHERE object_id = OBJECT_ID('pcf_city','U') AND name = 'ix_pcf_city_pcf_country_id') drop index ix_pcf_city_pcf_country_id ON pcf_city; + +IF OBJECT_ID('fk_pcf_city_mayor_id', 'F') IS NOT NULL alter table pcf_city drop constraint fk_pcf_city_mayor_id; + +IF OBJECT_ID('fk_pcf_city_vice_mayor_id', 'F') IS NOT NULL alter table pcf_city drop constraint fk_pcf_city_vice_mayor_id; + +IF OBJECT_ID('fk_pcf_event_pcf_calendar_id', 'F') IS NOT NULL alter table pcf_event drop constraint fk_pcf_event_pcf_calendar_id; +IF EXISTS (SELECT name FROM sys.indexes WHERE object_id = OBJECT_ID('pcf_event','U') AND name = 'ix_pcf_event_pcf_calendar_id') drop index ix_pcf_event_pcf_calendar_id ON pcf_event; + +IF EXISTS (SELECT name FROM sys.indexes WHERE object_id = OBJECT_ID('persistent_file_content','U') AND name = 'uq_persistent_file_content_persistent_file_id') drop index uq_persistent_file_content_persistent_file_id ON persistent_file_content; +IF OBJECT_ID('fk_persistent_file_content_persistent_file_id', 'F') IS NOT NULL alter table persistent_file_content drop constraint fk_persistent_file_content_persistent_file_id; + +IF OBJECT_ID('fk_person_default_address_oid', 'F') IS NOT NULL alter table person drop constraint fk_person_default_address_oid; +IF EXISTS (SELECT name FROM sys.indexes WHERE object_id = OBJECT_ID('person','U') AND name = 'ix_person_default_address_oid') drop index ix_person_default_address_oid ON person; + +IF OBJECT_ID('fk_person_cache_email_person_info_person_id', 'F') IS NOT NULL alter table person_cache_email drop constraint fk_person_cache_email_person_info_person_id; +IF EXISTS (SELECT name FROM sys.indexes WHERE object_id = OBJECT_ID('person_cache_email','U') AND name = 'ix_person_cache_email_person_info_person_id') drop index ix_person_cache_email_person_info_person_id ON person_cache_email; + +IF OBJECT_ID('fk_phones_person_id', 'F') IS NOT NULL alter table phones drop constraint fk_phones_person_id; +IF EXISTS (SELECT name FROM sys.indexes WHERE object_id = OBJECT_ID('phones','U') AND name = 'ix_phones_person_id') drop index ix_phones_person_id ON phones; + +IF OBJECT_ID('fk_e_position_contract_id', 'F') IS NOT NULL alter table e_position drop constraint fk_e_position_contract_id; +IF EXISTS (SELECT name FROM sys.indexes WHERE object_id = OBJECT_ID('e_position','U') AND name = 'ix_e_position_contract_id') drop index ix_e_position_contract_id ON e_position; + +IF OBJECT_ID('fk_pp_to_ww_pp', 'F') IS NOT NULL alter table pp_to_ww drop constraint fk_pp_to_ww_pp; +IF EXISTS (SELECT name FROM sys.indexes WHERE object_id = OBJECT_ID('pp_to_ww','U') AND name = 'ix_pp_to_ww_pp') drop index ix_pp_to_ww_pp ON pp_to_ww; + +IF OBJECT_ID('fk_pp_to_ww_wview', 'F') IS NOT NULL alter table pp_to_ww drop constraint fk_pp_to_ww_wview; +IF EXISTS (SELECT name FROM sys.indexes WHERE object_id = OBJECT_ID('pp_to_ww','U') AND name = 'ix_pp_to_ww_wview') drop index ix_pp_to_ww_wview ON pp_to_ww; + +IF OBJECT_ID('fk_question_groupobjectid', 'F') IS NOT NULL alter table question drop constraint fk_question_groupobjectid; +IF EXISTS (SELECT name FROM sys.indexes WHERE object_id = OBJECT_ID('question','U') AND name = 'ix_question_groupobjectid') drop index ix_question_groupobjectid ON question; + +IF OBJECT_ID('fk_r_orders_customer', 'F') IS NOT NULL alter table r_orders drop constraint fk_r_orders_customer; +IF EXISTS (SELECT name FROM sys.indexes WHERE object_id = OBJECT_ID('r_orders','U') AND name = 'ix_r_orders_customer') drop index ix_r_orders_customer ON r_orders; + +IF OBJECT_ID('fk_rel_master_detail_id', 'F') IS NOT NULL alter table rel_master drop constraint fk_rel_master_detail_id; +IF EXISTS (SELECT name FROM sys.indexes WHERE object_id = OBJECT_ID('rel_master','U') AND name = 'ix_rel_master_detail_id') drop index ix_rel_master_detail_id ON rel_master; + +IF OBJECT_ID('fk_resourcefile_parentresourcefileid', 'F') IS NOT NULL alter table resourcefile drop constraint fk_resourcefile_parentresourcefileid; +IF EXISTS (SELECT name FROM sys.indexes WHERE object_id = OBJECT_ID('resourcefile','U') AND name = 'ix_resourcefile_parentresourcefileid') drop index ix_resourcefile_parentresourcefileid ON resourcefile; + +IF OBJECT_ID('fk_mt_role_tenant_id', 'F') IS NOT NULL alter table mt_role drop constraint fk_mt_role_tenant_id; +IF EXISTS (SELECT name FROM sys.indexes WHERE object_id = OBJECT_ID('mt_role','U') AND name = 'ix_mt_role_tenant_id') drop index ix_mt_role_tenant_id ON mt_role; + +IF OBJECT_ID('fk_mt_role_permission_mt_role', 'F') IS NOT NULL alter table mt_role_permission drop constraint fk_mt_role_permission_mt_role; +IF EXISTS (SELECT name FROM sys.indexes WHERE object_id = OBJECT_ID('mt_role_permission','U') AND name = 'ix_mt_role_permission_mt_role') drop index ix_mt_role_permission_mt_role ON mt_role_permission; + +IF OBJECT_ID('fk_mt_role_permission_mt_permission', 'F') IS NOT NULL alter table mt_role_permission drop constraint fk_mt_role_permission_mt_permission; +IF EXISTS (SELECT name FROM sys.indexes WHERE object_id = OBJECT_ID('mt_role_permission','U') AND name = 'ix_mt_role_permission_mt_permission') drop index ix_mt_role_permission_mt_permission ON mt_role_permission; + +IF OBJECT_ID('fk_root_bean_referencing_bean_id', 'F') IS NOT NULL alter table root_bean drop constraint fk_root_bean_referencing_bean_id; +IF EXISTS (SELECT name FROM sys.indexes WHERE object_id = OBJECT_ID('root_bean','U') AND name = 'ix_root_bean_referencing_bean_id') drop index ix_root_bean_referencing_bean_id ON root_bean; + +IF EXISTS (SELECT name FROM sys.indexes WHERE object_id = OBJECT_ID('f_second','U') AND name = 'uq_f_second_first') drop index uq_f_second_first ON f_second; +IF OBJECT_ID('fk_f_second_first', 'F') IS NOT NULL alter table f_second drop constraint fk_f_second_first; + +IF OBJECT_ID('fk_section_article_id', 'F') IS NOT NULL alter table section drop constraint fk_section_article_id; +IF EXISTS (SELECT name FROM sys.indexes WHERE object_id = OBJECT_ID('section','U') AND name = 'ix_section_article_id') drop index ix_section_article_id ON section; + +IF OBJECT_ID('fk_self_parent_parent_id', 'F') IS NOT NULL alter table self_parent drop constraint fk_self_parent_parent_id; +IF EXISTS (SELECT name FROM sys.indexes WHERE object_id = OBJECT_ID('self_parent','U') AND name = 'ix_self_parent_parent_id') drop index ix_self_parent_parent_id ON self_parent; + +IF OBJECT_ID('fk_self_ref_customer_referred_by_id', 'F') IS NOT NULL alter table self_ref_customer drop constraint fk_self_ref_customer_referred_by_id; +IF EXISTS (SELECT name FROM sys.indexes WHERE object_id = OBJECT_ID('self_ref_customer','U') AND name = 'ix_self_ref_customer_referred_by_id') drop index ix_self_ref_customer_referred_by_id ON self_ref_customer; + +IF OBJECT_ID('fk_self_ref_example_parent_id', 'F') IS NOT NULL alter table self_ref_example drop constraint fk_self_ref_example_parent_id; +IF EXISTS (SELECT name FROM sys.indexes WHERE object_id = OBJECT_ID('self_ref_example','U') AND name = 'ix_self_ref_example_parent_id') drop index ix_self_ref_example_parent_id ON self_ref_example; + +IF EXISTS (SELECT name FROM sys.indexes WHERE object_id = OBJECT_ID('e_save_test_b','U') AND name = 'uq_e_save_test_b_sibling_a_id') drop index uq_e_save_test_b_sibling_a_id ON e_save_test_b; +IF OBJECT_ID('fk_e_save_test_b_sibling_a_id', 'F') IS NOT NULL alter table e_save_test_b drop constraint fk_e_save_test_b_sibling_a_id; + +IF EXISTS (SELECT name FROM sys.indexes WHERE object_id = OBJECT_ID('site','U') AND name = 'uq_site_data_container_id') drop index uq_site_data_container_id ON site; +IF EXISTS (SELECT name FROM sys.indexes WHERE object_id = OBJECT_ID('site','U') AND name = 'uq_site_site_address_id') drop index uq_site_site_address_id ON site; +IF OBJECT_ID('fk_site_parent_id', 'F') IS NOT NULL alter table site drop constraint fk_site_parent_id; +IF EXISTS (SELECT name FROM sys.indexes WHERE object_id = OBJECT_ID('site','U') AND name = 'ix_site_parent_id') drop index ix_site_parent_id ON site; + +IF OBJECT_ID('fk_site_data_container_id', 'F') IS NOT NULL alter table site drop constraint fk_site_data_container_id; + +IF OBJECT_ID('fk_site_site_address_id', 'F') IS NOT NULL alter table site drop constraint fk_site_site_address_id; + +IF OBJECT_ID('fk_source_base_target_id', 'F') IS NOT NULL alter table source_base drop constraint fk_source_base_target_id; +IF EXISTS (SELECT name FROM sys.indexes WHERE object_id = OBJECT_ID('source_base','U') AND name = 'ix_source_base_target_id') drop index ix_source_base_target_id ON source_base; + +IF OBJECT_ID('fk_stockforecast_inner_report_id', 'F') IS NOT NULL alter table stockforecast drop constraint fk_stockforecast_inner_report_id; +IF EXISTS (SELECT name FROM sys.indexes WHERE object_id = OBJECT_ID('stockforecast','U') AND name = 'ix_stockforecast_inner_report_id') drop index ix_stockforecast_inner_report_id ON stockforecast; + +IF OBJECT_ID('fk_sub_section_section_id', 'F') IS NOT NULL alter table sub_section drop constraint fk_sub_section_section_id; +IF EXISTS (SELECT name FROM sys.indexes WHERE object_id = OBJECT_ID('sub_section','U') AND name = 'ix_sub_section_section_id') drop index ix_sub_section_section_id ON sub_section; + +IF OBJECT_ID('fk_tevent_many_event_id', 'F') IS NOT NULL alter table tevent_many drop constraint fk_tevent_many_event_id; +IF EXISTS (SELECT name FROM sys.indexes WHERE object_id = OBJECT_ID('tevent_many','U') AND name = 'ix_tevent_many_event_id') drop index ix_tevent_many_event_id ON tevent_many; + +IF EXISTS (SELECT name FROM sys.indexes WHERE object_id = OBJECT_ID('tevent_one','U') AND name = 'uq_tevent_one_event_id') drop index uq_tevent_one_event_id ON tevent_one; +IF OBJECT_ID('fk_tevent_one_event_id', 'F') IS NOT NULL alter table tevent_one drop constraint fk_tevent_one_event_id; + +IF EXISTS (SELECT name FROM sys.indexes WHERE object_id = OBJECT_ID('t_detail_with_other_namexxxyy','U') AND name = 'uq_t_detail_with_other_namexxxyy_some_unique_value') drop index uq_t_detail_with_other_namexxxyy_some_unique_value ON t_detail_with_other_namexxxyy; +IF OBJECT_ID('fk_t_detail_with_other_namexxxyy_master_id', 'F') IS NOT NULL alter table t_detail_with_other_namexxxyy drop constraint fk_t_detail_with_other_namexxxyy_master_id; +IF EXISTS (SELECT name FROM sys.indexes WHERE object_id = OBJECT_ID('t_detail_with_other_namexxxyy','U') AND name = 'ix_t_detail_with_other_namexxxyy_master_id') drop index ix_t_detail_with_other_namexxxyy_master_id ON t_detail_with_other_namexxxyy; + +IF OBJECT_ID('fk_ttruck_holder_truck_plate_no', 'F') IS NOT NULL alter table ttruck_holder drop constraint fk_ttruck_holder_truck_plate_no; +IF EXISTS (SELECT name FROM sys.indexes WHERE object_id = OBJECT_ID('ttruck_holder','U') AND name = 'ix_ttruck_holder_truck_plate_no') drop index ix_ttruck_holder_truck_plate_no ON ttruck_holder; + +IF OBJECT_ID('fk_ttruck_holder_basic_id', 'F') IS NOT NULL alter table ttruck_holder drop constraint fk_ttruck_holder_basic_id; +IF EXISTS (SELECT name FROM sys.indexes WHERE object_id = OBJECT_ID('ttruck_holder','U') AND name = 'ix_ttruck_holder_basic_id') drop index ix_ttruck_holder_basic_id ON ttruck_holder; + +IF OBJECT_ID('fk_ttruck_holder_item_owner_id', 'F') IS NOT NULL alter table ttruck_holder_item drop constraint fk_ttruck_holder_item_owner_id; +IF EXISTS (SELECT name FROM sys.indexes WHERE object_id = OBJECT_ID('ttruck_holder_item','U') AND name = 'ix_ttruck_holder_item_owner_id') drop index ix_ttruck_holder_item_owner_id ON ttruck_holder_item; + +IF OBJECT_ID('fk_twheel_owner_plate_no', 'F') IS NOT NULL alter table twheel drop constraint fk_twheel_owner_plate_no; +IF EXISTS (SELECT name FROM sys.indexes WHERE object_id = OBJECT_ID('twheel','U') AND name = 'ix_twheel_owner_plate_no') drop index ix_twheel_owner_plate_no ON twheel; + +IF EXISTS (SELECT name FROM sys.indexes WHERE object_id = OBJECT_ID('tire','U') AND name = 'uq_tire_wheel') drop index uq_tire_wheel ON tire; +IF OBJECT_ID('fk_tire_wheel', 'F') IS NOT NULL alter table tire drop constraint fk_tire_wheel; + +IF OBJECT_ID('fk_tree_entity_parent_id', 'F') IS NOT NULL alter table tree_entity drop constraint fk_tree_entity_parent_id; +IF EXISTS (SELECT name FROM sys.indexes WHERE object_id = OBJECT_ID('tree_entity','U') AND name = 'ix_tree_entity_parent_id') drop index ix_tree_entity_parent_id ON tree_entity; + +IF OBJECT_ID('fk_trip_vehicle_driver_id', 'F') IS NOT NULL alter table trip drop constraint fk_trip_vehicle_driver_id; +IF EXISTS (SELECT name FROM sys.indexes WHERE object_id = OBJECT_ID('trip','U') AND name = 'ix_trip_vehicle_driver_id') drop index ix_trip_vehicle_driver_id ON trip; + +IF OBJECT_ID('fk_trip_address_id', 'F') IS NOT NULL alter table trip drop constraint fk_trip_address_id; +IF EXISTS (SELECT name FROM sys.indexes WHERE object_id = OBJECT_ID('trip','U') AND name = 'ix_trip_address_id') drop index ix_trip_address_id ON trip; + +IF OBJECT_ID('fk_type_sub_type_id', 'F') IS NOT NULL alter table [type] drop constraint fk_type_sub_type_id; +IF EXISTS (SELECT name FROM sys.indexes WHERE object_id = OBJECT_ID('[type]','U') AND name = 'ix_type_sub_type_id') drop index ix_type_sub_type_id ON [type]; + +IF OBJECT_ID('fk_usib_child_parent_id', 'F') IS NOT NULL alter table usib_child drop constraint fk_usib_child_parent_id; +IF EXISTS (SELECT name FROM sys.indexes WHERE object_id = OBJECT_ID('usib_child','U') AND name = 'ix_usib_child_parent_id') drop index ix_usib_child_parent_id ON usib_child; + +IF EXISTS (SELECT name FROM sys.indexes WHERE object_id = OBJECT_ID('usib_child_sibling','U') AND name = 'uq_usib_child_sibling_child_id') drop index uq_usib_child_sibling_child_id ON usib_child_sibling; +IF OBJECT_ID('fk_usib_child_sibling_child_id', 'F') IS NOT NULL alter table usib_child_sibling drop constraint fk_usib_child_sibling_child_id; + +IF OBJECT_ID('fk_ut_detail_utmaster_id', 'F') IS NOT NULL alter table ut_detail drop constraint fk_ut_detail_utmaster_id; +IF EXISTS (SELECT name FROM sys.indexes WHERE object_id = OBJECT_ID('ut_detail','U') AND name = 'ix_ut_detail_utmaster_id') drop index ix_ut_detail_utmaster_id ON ut_detail; + +IF OBJECT_ID('fk_uutwo_master_id', 'F') IS NOT NULL alter table uutwo drop constraint fk_uutwo_master_id; +IF EXISTS (SELECT name FROM sys.indexes WHERE object_id = OBJECT_ID('uutwo','U') AND name = 'ix_uutwo_master_id') drop index ix_uutwo_master_id ON uutwo; + +IF OBJECT_ID('fk_oto_user_account_id', 'F') IS NOT NULL alter table oto_user drop constraint fk_oto_user_account_id; + +IF OBJECT_ID('fk_c_user_group_id', 'F') IS NOT NULL alter table c_user drop constraint fk_c_user_group_id; +IF EXISTS (SELECT name FROM sys.indexes WHERE object_id = OBJECT_ID('c_user','U') AND name = 'ix_c_user_group_id') drop index ix_c_user_group_id ON c_user; + +IF OBJECT_ID('fk_em_user_role_user_id', 'F') IS NOT NULL alter table em_user_role drop constraint fk_em_user_role_user_id; +IF EXISTS (SELECT name FROM sys.indexes WHERE object_id = OBJECT_ID('em_user_role','U') AND name = 'ix_em_user_role_user_id') drop index ix_em_user_role_user_id ON em_user_role; + +IF OBJECT_ID('fk_em_user_role_role_id', 'F') IS NOT NULL alter table em_user_role drop constraint fk_em_user_role_role_id; +IF EXISTS (SELECT name FROM sys.indexes WHERE object_id = OBJECT_ID('em_user_role','U') AND name = 'ix_em_user_role_role_id') drop index ix_em_user_role_role_id ON em_user_role; + +IF OBJECT_ID('fk_vehicle_lease_id', 'F') IS NOT NULL alter table vehicle drop constraint fk_vehicle_lease_id; +IF EXISTS (SELECT name FROM sys.indexes WHERE object_id = OBJECT_ID('vehicle','U') AND name = 'ix_vehicle_lease_id') drop index ix_vehicle_lease_id ON vehicle; + +IF OBJECT_ID('fk_vehicle_car_ref_id', 'F') IS NOT NULL alter table vehicle drop constraint fk_vehicle_car_ref_id; +IF EXISTS (SELECT name FROM sys.indexes WHERE object_id = OBJECT_ID('vehicle','U') AND name = 'ix_vehicle_car_ref_id') drop index ix_vehicle_car_ref_id ON vehicle; + +IF OBJECT_ID('fk_vehicle_truck_ref_id', 'F') IS NOT NULL alter table vehicle drop constraint fk_vehicle_truck_ref_id; +IF EXISTS (SELECT name FROM sys.indexes WHERE object_id = OBJECT_ID('vehicle','U') AND name = 'ix_vehicle_truck_ref_id') drop index ix_vehicle_truck_ref_id ON vehicle; + +IF OBJECT_ID('fk_vehicle_driver_vehicle_id', 'F') IS NOT NULL alter table vehicle_driver drop constraint fk_vehicle_driver_vehicle_id; +IF EXISTS (SELECT name FROM sys.indexes WHERE object_id = OBJECT_ID('vehicle_driver','U') AND name = 'ix_vehicle_driver_vehicle_id') drop index ix_vehicle_driver_vehicle_id ON vehicle_driver; + +IF OBJECT_ID('fk_vehicle_driver_address_id', 'F') IS NOT NULL alter table vehicle_driver drop constraint fk_vehicle_driver_address_id; +IF EXISTS (SELECT name FROM sys.indexes WHERE object_id = OBJECT_ID('vehicle_driver','U') AND name = 'ix_vehicle_driver_address_id') drop index ix_vehicle_driver_address_id ON vehicle_driver; + +IF OBJECT_ID('fk_warehouses_officezoneid', 'F') IS NOT NULL alter table warehouses drop constraint fk_warehouses_officezoneid; +IF EXISTS (SELECT name FROM sys.indexes WHERE object_id = OBJECT_ID('warehouses','U') AND name = 'ix_warehouses_officezoneid') drop index ix_warehouses_officezoneid ON warehouses; + +IF OBJECT_ID('fk_warehousesshippingzones_warehouses', 'F') IS NOT NULL alter table warehousesshippingzones drop constraint fk_warehousesshippingzones_warehouses; +IF EXISTS (SELECT name FROM sys.indexes WHERE object_id = OBJECT_ID('warehousesshippingzones','U') AND name = 'ix_warehousesshippingzones_warehouses') drop index ix_warehousesshippingzones_warehouses ON warehousesshippingzones; + +IF OBJECT_ID('fk_warehousesshippingzones_zones', 'F') IS NOT NULL alter table warehousesshippingzones drop constraint fk_warehousesshippingzones_zones; +IF EXISTS (SELECT name FROM sys.indexes WHERE object_id = OBJECT_ID('warehousesshippingzones','U') AND name = 'ix_warehousesshippingzones_zones') drop index ix_warehousesshippingzones_zones ON warehousesshippingzones; + +IF OBJECT_ID('fk_sa_wheel_tire', 'F') IS NOT NULL alter table sa_wheel drop constraint fk_sa_wheel_tire; +IF EXISTS (SELECT name FROM sys.indexes WHERE object_id = OBJECT_ID('sa_wheel','U') AND name = 'ix_sa_wheel_tire') drop index ix_sa_wheel_tire ON sa_wheel; + +IF OBJECT_ID('fk_sa_wheel_car', 'F') IS NOT NULL alter table sa_wheel drop constraint fk_sa_wheel_car; +IF EXISTS (SELECT name FROM sys.indexes WHERE object_id = OBJECT_ID('sa_wheel','U') AND name = 'ix_sa_wheel_car') drop index ix_sa_wheel_car ON sa_wheel; + +IF OBJECT_ID('fk_g_who_props_otm_who_created_id', 'F') IS NOT NULL alter table g_who_props_otm drop constraint fk_g_who_props_otm_who_created_id; +IF EXISTS (SELECT name FROM sys.indexes WHERE object_id = OBJECT_ID('g_who_props_otm','U') AND name = 'ix_g_who_props_otm_who_created_id') drop index ix_g_who_props_otm_who_created_id ON g_who_props_otm; + +IF OBJECT_ID('fk_g_who_props_otm_who_modified_id', 'F') IS NOT NULL alter table g_who_props_otm drop constraint fk_g_who_props_otm_who_modified_id; +IF EXISTS (SELECT name FROM sys.indexes WHERE object_id = OBJECT_ID('g_who_props_otm','U') AND name = 'ix_g_who_props_otm_who_modified_id') drop index ix_g_who_props_otm_who_modified_id ON g_who_props_otm; + +IF OBJECT_ID('fk_with_zero_parent_id', 'F') IS NOT NULL alter table with_zero drop constraint fk_with_zero_parent_id; +IF EXISTS (SELECT name FROM sys.indexes WHERE object_id = OBJECT_ID('with_zero','U') AND name = 'ix_with_zero_parent_id') drop index ix_with_zero_parent_id ON with_zero; + +if exists (select name from sys.types where name = 'ebean_bigint_tvp') drop type ebean_bigint_tvp; +if exists (select name from sys.types where name = 'ebean_float_tvp') drop type ebean_float_tvp; +if exists (select name from sys.types where name = 'ebean_bit_tvp') drop type ebean_bit_tvp; +if exists (select name from sys.types where name = 'ebean_date_tvp') drop type ebean_date_tvp; +if exists (select name from sys.types where name = 'ebean_time_tvp') drop type ebean_time_tvp; +if exists (select name from sys.types where name = 'ebean_uniqueidentifier_tvp') drop type ebean_uniqueidentifier_tvp; +if exists (select name from sys.types where name = 'ebean_nvarchar_tvp') drop type ebean_nvarchar_tvp; +IF OBJECT_ID('asimple_bean', 'U') IS NOT NULL drop table asimple_bean; +IF OBJECT_ID('asimple_bean_seq', 'SO') IS NOT NULL drop sequence asimple_bean_seq; + +IF OBJECT_ID('bar', 'U') IS NOT NULL drop table bar; +IF OBJECT_ID('bar_seq', 'SO') IS NOT NULL drop sequence bar_seq; + +IF OBJECT_ID('block', 'U') IS NOT NULL drop table block; +IF OBJECT_ID('block_seq', 'SO') IS NOT NULL drop sequence block_seq; + +IF OBJECT_ID('oto_account', 'U') IS NOT NULL drop table oto_account; +IF OBJECT_ID('oto_account_seq', 'SO') IS NOT NULL drop sequence oto_account_seq; + +IF OBJECT_ID('acl', 'U') IS NOT NULL drop table acl; +IF OBJECT_ID('acl_seq', 'SO') IS NOT NULL drop sequence acl_seq; + +IF OBJECT_ID('acl_container_relation', 'U') IS NOT NULL drop table acl_container_relation; +IF OBJECT_ID('acl_container_relation_seq', 'SO') IS NOT NULL drop sequence acl_container_relation_seq; + +IF OBJECT_ID('addr', 'U') IS NOT NULL drop table addr; +IF OBJECT_ID('addr_seq', 'SO') IS NOT NULL drop sequence addr_seq; + +IF OBJECT_ID('address', 'U') IS NOT NULL drop table address; +IF OBJECT_ID('address_seq', 'SO') IS NOT NULL drop sequence address_seq; + +IF OBJECT_ID('o_address', 'U') IS NOT NULL drop table o_address; +IF OBJECT_ID('o_address_seq', 'SO') IS NOT NULL drop sequence o_address_seq; + +IF OBJECT_ID('album', 'U') IS NOT NULL drop table album; +IF OBJECT_ID('album_seq', 'SO') IS NOT NULL drop sequence album_seq; + +IF OBJECT_ID('animal', 'U') IS NOT NULL drop table animal; +IF OBJECT_ID('animal_seq', 'SO') IS NOT NULL drop sequence animal_seq; + +IF OBJECT_ID('animal_shelter', 'U') IS NOT NULL drop table animal_shelter; +IF OBJECT_ID('animal_shelter_seq', 'SO') IS NOT NULL drop sequence animal_shelter_seq; + +IF OBJECT_ID('article', 'U') IS NOT NULL drop table article; +IF OBJECT_ID('article_seq', 'SO') IS NOT NULL drop sequence article_seq; + +IF OBJECT_ID('attribute', 'U') IS NOT NULL drop table attribute; +IF OBJECT_ID('attribute_seq', 'SO') IS NOT NULL drop sequence attribute_seq; + +IF OBJECT_ID('attribute_holder', 'U') IS NOT NULL drop table attribute_holder; +IF OBJECT_ID('attribute_holder_seq', 'SO') IS NOT NULL drop sequence attribute_holder_seq; + +IF OBJECT_ID('audit_log', 'U') IS NOT NULL drop table audit_log; +IF OBJECT_ID('audit_log_seq', 'SO') IS NOT NULL drop sequence audit_log_seq; + +IF OBJECT_ID('bbookmark', 'U') IS NOT NULL drop table bbookmark; +IF OBJECT_ID('bbookmark_seq', 'SO') IS NOT NULL drop sequence bbookmark_seq; + +IF OBJECT_ID('bbookmark_org', 'U') IS NOT NULL drop table bbookmark_org; +IF OBJECT_ID('bbookmark_org_seq', 'SO') IS NOT NULL drop sequence bbookmark_org_seq; + +IF OBJECT_ID('bbookmark_user', 'U') IS NOT NULL drop table bbookmark_user; +IF OBJECT_ID('bbookmark_user_seq', 'SO') IS NOT NULL drop sequence bbookmark_user_seq; + +IF OBJECT_ID('bsimple_with_gen', 'U') IS NOT NULL drop table bsimple_with_gen; +IF OBJECT_ID('bsimple_with_gen_seq', 'SO') IS NOT NULL drop sequence bsimple_with_gen_seq; + +IF OBJECT_ID('bsite', 'U') IS NOT NULL drop table bsite; + +IF OBJECT_ID('bsite_user_a', 'U') IS NOT NULL drop table bsite_user_a; + +IF OBJECT_ID('bsite_user_b', 'U') IS NOT NULL drop table bsite_user_b; + +IF OBJECT_ID('bsite_user_c', 'U') IS NOT NULL drop table bsite_user_c; + +IF OBJECT_ID('bsite_user_d', 'U') IS NOT NULL drop table bsite_user_d; + +IF OBJECT_ID('bsite_user_e', 'U') IS NOT NULL drop table bsite_user_e; + +IF OBJECT_ID('buser', 'U') IS NOT NULL drop table buser; + +IF OBJECT_ID('bwith_qident', 'U') IS NOT NULL drop table bwith_qident; +IF OBJECT_ID('bwith_qident_seq', 'SO') IS NOT NULL drop sequence bwith_qident_seq; + +IF OBJECT_ID('basic_draftable_bean', 'U') IS NOT NULL drop table basic_draftable_bean; +IF OBJECT_ID('basic_draftable_bean_seq', 'SO') IS NOT NULL drop sequence basic_draftable_bean_seq; + +IF OBJECT_ID('basic_draftable_bean_draft', 'U') IS NOT NULL drop table basic_draftable_bean_draft; +IF OBJECT_ID('basic_draftable_bean_draft_seq', 'SO') IS NOT NULL drop sequence basic_draftable_bean_draft_seq; + +IF OBJECT_ID('basic_joda_entity', 'U') IS NOT NULL drop table basic_joda_entity; +IF OBJECT_ID('basic_joda_entity_seq', 'SO') IS NOT NULL drop sequence basic_joda_entity_seq; + +IF OBJECT_ID('bean_with_time_zone', 'U') IS NOT NULL drop table bean_with_time_zone; +IF OBJECT_ID('bean_with_time_zone_seq', 'SO') IS NOT NULL drop sequence bean_with_time_zone_seq; + +IF OBJECT_ID('drel_booking', 'U') IS NOT NULL drop table drel_booking; +IF OBJECT_ID('drel_booking_seq', 'SO') IS NOT NULL drop sequence drel_booking_seq; + +IF OBJECT_ID('bw_bean', 'U') IS NOT NULL drop table bw_bean; +IF OBJECT_ID('bw_bean_seq', 'SO') IS NOT NULL drop sequence bw_bean_seq; + +IF OBJECT_ID('cepcategory', 'U') IS NOT NULL drop table cepcategory; +IF OBJECT_ID('cepcategory_seq', 'SO') IS NOT NULL drop sequence cepcategory_seq; + +IF OBJECT_ID('cepproduct', 'U') IS NOT NULL drop table cepproduct; +IF OBJECT_ID('cepproduct_seq', 'SO') IS NOT NULL drop sequence cepproduct_seq; + +IF OBJECT_ID('cepproduct_category', 'U') IS NOT NULL drop table cepproduct_category; + +IF OBJECT_ID('cinh_ref', 'U') IS NOT NULL drop table cinh_ref; +IF OBJECT_ID('cinh_ref_seq', 'SO') IS NOT NULL drop sequence cinh_ref_seq; + +IF OBJECT_ID('cinh_root', 'U') IS NOT NULL drop table cinh_root; +IF OBJECT_ID('cinh_root_seq', 'SO') IS NOT NULL drop sequence cinh_root_seq; + +IF OBJECT_ID('ckey_assoc', 'U') IS NOT NULL drop table ckey_assoc; +IF OBJECT_ID('ckey_assoc_seq', 'SO') IS NOT NULL drop sequence ckey_assoc_seq; + +IF OBJECT_ID('ckey_detail', 'U') IS NOT NULL drop table ckey_detail; +IF OBJECT_ID('ckey_detail_seq', 'SO') IS NOT NULL drop sequence ckey_detail_seq; + +IF OBJECT_ID('ckey_parent', 'U') IS NOT NULL drop table ckey_parent; + +IF OBJECT_ID('coone', 'U') IS NOT NULL drop table coone; +IF OBJECT_ID('coone_seq', 'SO') IS NOT NULL drop sequence coone_seq; + +IF OBJECT_ID('coone_many', 'U') IS NOT NULL drop table coone_many; +IF OBJECT_ID('coone_many_seq', 'SO') IS NOT NULL drop sequence coone_many_seq; + +IF OBJECT_ID('coroot', 'U') IS NOT NULL drop table coroot; +IF OBJECT_ID('coroot_seq', 'SO') IS NOT NULL drop sequence coroot_seq; + +IF OBJECT_ID('calculation_result', 'U') IS NOT NULL drop table calculation_result; +IF OBJECT_ID('calculation_result_seq', 'SO') IS NOT NULL drop sequence calculation_result_seq; + +IF OBJECT_ID('cao_bean', 'U') IS NOT NULL drop table cao_bean; + +IF OBJECT_ID('sp_car_car', 'U') IS NOT NULL drop table sp_car_car; +IF OBJECT_ID('sp_car_car_seq', 'SO') IS NOT NULL drop sequence sp_car_car_seq; + +IF OBJECT_ID('sp_car_car_wheels', 'U') IS NOT NULL drop table sp_car_car_wheels; + +IF OBJECT_ID('sp_car_car_doors', 'U') IS NOT NULL drop table sp_car_car_doors; + +IF OBJECT_ID('sa_car', 'U') IS NOT NULL drop table sa_car; +IF OBJECT_ID('sa_car_seq', 'SO') IS NOT NULL drop sequence sa_car_seq; + +IF OBJECT_ID('car_accessory', 'U') IS NOT NULL drop table car_accessory; +IF OBJECT_ID('car_accessory_seq', 'SO') IS NOT NULL drop sequence car_accessory_seq; + +IF OBJECT_ID('car_fuse', 'U') IS NOT NULL drop table car_fuse; +IF OBJECT_ID('car_fuse_seq', 'SO') IS NOT NULL drop sequence car_fuse_seq; + +IF OBJECT_ID('category', 'U') IS NOT NULL drop table category; +IF OBJECT_ID('category_seq', 'SO') IS NOT NULL drop sequence category_seq; + +IF OBJECT_ID('e_save_test_d', 'U') IS NOT NULL drop table e_save_test_d; +IF OBJECT_ID('e_save_test_d_seq', 'SO') IS NOT NULL drop sequence e_save_test_d_seq; + +IF OBJECT_ID('child_person', 'U') IS NOT NULL drop table child_person; +IF OBJECT_ID('child_person_seq', 'SO') IS NOT NULL drop sequence child_person_seq; + +IF OBJECT_ID('cke_client', 'U') IS NOT NULL drop table cke_client; + +IF OBJECT_ID('cke_user', 'U') IS NOT NULL drop table cke_user; + +IF OBJECT_ID('class_super', 'U') IS NOT NULL drop table class_super; +IF OBJECT_ID('class_super_seq', 'SO') IS NOT NULL drop sequence class_super_seq; + +IF OBJECT_ID('class_super_monkey', 'U') IS NOT NULL drop table class_super_monkey; + +IF OBJECT_ID('configuration', 'U') IS NOT NULL drop table configuration; +IF OBJECT_ID('configuration_seq', 'SO') IS NOT NULL drop sequence configuration_seq; + +IF OBJECT_ID('configurations', 'U') IS NOT NULL drop table configurations; +IF OBJECT_ID('configurations_seq', 'SO') IS NOT NULL drop sequence configurations_seq; + +IF OBJECT_ID('contact', 'U') IS NOT NULL drop table contact; +IF OBJECT_ID('contact_seq', 'SO') IS NOT NULL drop sequence contact_seq; + +IF OBJECT_ID('contact_group', 'U') IS NOT NULL drop table contact_group; +IF OBJECT_ID('contact_group_seq', 'SO') IS NOT NULL drop sequence contact_group_seq; + +IF OBJECT_ID('contact_note', 'U') IS NOT NULL drop table contact_note; +IF OBJECT_ID('contact_note_seq', 'SO') IS NOT NULL drop sequence contact_note_seq; + +IF OBJECT_ID('contract', 'U') IS NOT NULL drop table contract; +IF OBJECT_ID('contract_seq', 'SO') IS NOT NULL drop sequence contract_seq; + +IF OBJECT_ID('contract_costs', 'U') IS NOT NULL drop table contract_costs; +IF OBJECT_ID('contract_costs_seq', 'SO') IS NOT NULL drop sequence contract_costs_seq; + +IF OBJECT_ID('c_conversation', 'U') IS NOT NULL drop table c_conversation; +IF OBJECT_ID('c_conversation_seq', 'SO') IS NOT NULL drop sequence c_conversation_seq; + +IF OBJECT_ID('o_country', 'U') IS NOT NULL drop table o_country; + +IF OBJECT_ID('cover', 'U') IS NOT NULL drop table cover; +IF OBJECT_ID('cover_seq', 'SO') IS NOT NULL drop sequence cover_seq; + +IF OBJECT_ID('o_customer', 'U') IS NOT NULL drop table o_customer; +IF OBJECT_ID('o_customer_seq', 'SO') IS NOT NULL drop sequence o_customer_seq; + +IF OBJECT_ID('dcredit', 'U') IS NOT NULL drop table dcredit; +IF OBJECT_ID('dcredit_seq', 'SO') IS NOT NULL drop sequence dcredit_seq; + +IF OBJECT_ID('dcredit_drol', 'U') IS NOT NULL drop table dcredit_drol; + +IF OBJECT_ID('dexh_entity', 'U') IS NOT NULL drop table dexh_entity; +IF OBJECT_ID('dexh_entity_seq', 'SO') IS NOT NULL drop sequence dexh_entity_seq; + +IF OBJECT_ID('dint_parent', 'U') IS NOT NULL drop table dint_parent; +IF OBJECT_ID('dint_parent_seq', 'SO') IS NOT NULL drop sequence dint_parent_seq; + +IF OBJECT_ID('dmachine', 'U') IS NOT NULL drop table dmachine; +IF OBJECT_ID('dmachine_seq', 'SO') IS NOT NULL drop sequence dmachine_seq; + +IF OBJECT_ID('d_machine_aux_use', 'U') IS NOT NULL drop table d_machine_aux_use; +IF OBJECT_ID('d_machine_aux_use_seq', 'SO') IS NOT NULL drop sequence d_machine_aux_use_seq; + +IF OBJECT_ID('d_machine_stats', 'U') IS NOT NULL drop table d_machine_stats; +IF OBJECT_ID('d_machine_stats_seq', 'SO') IS NOT NULL drop sequence d_machine_stats_seq; + +IF OBJECT_ID('d_machine_use', 'U') IS NOT NULL drop table d_machine_use; +IF OBJECT_ID('d_machine_use_seq', 'SO') IS NOT NULL drop sequence d_machine_use_seq; + +IF OBJECT_ID('dorg', 'U') IS NOT NULL drop table dorg; +IF OBJECT_ID('dorg_seq', 'SO') IS NOT NULL drop sequence dorg_seq; + +IF OBJECT_ID('dperson', 'U') IS NOT NULL drop table dperson; +IF OBJECT_ID('dperson_seq', 'SO') IS NOT NULL drop sequence dperson_seq; + +IF OBJECT_ID('drol', 'U') IS NOT NULL drop table drol; +IF OBJECT_ID('drol_seq', 'SO') IS NOT NULL drop sequence drol_seq; + +IF OBJECT_ID('drot', 'U') IS NOT NULL drop table drot; +IF OBJECT_ID('drot_seq', 'SO') IS NOT NULL drop sequence drot_seq; + +IF OBJECT_ID('drot_drol', 'U') IS NOT NULL drop table drot_drol; + +IF OBJECT_ID('rawinherit_data', 'U') IS NOT NULL drop table rawinherit_data; +IF OBJECT_ID('rawinherit_data_seq', 'SO') IS NOT NULL drop sequence rawinherit_data_seq; + +IF OBJECT_ID('data_container', 'U') IS NOT NULL drop table data_container; + +IF OBJECT_ID('dc_detail', 'U') IS NOT NULL drop table dc_detail; +IF OBJECT_ID('dc_detail_seq', 'SO') IS NOT NULL drop sequence dc_detail_seq; + +IF OBJECT_ID('dc_master', 'U') IS NOT NULL drop table dc_master; +IF OBJECT_ID('dc_master_seq', 'SO') IS NOT NULL drop sequence dc_master_seq; + +IF OBJECT_ID('dfk_cascade', 'U') IS NOT NULL drop table dfk_cascade; +IF OBJECT_ID('dfk_cascade_seq', 'SO') IS NOT NULL drop sequence dfk_cascade_seq; + +IF OBJECT_ID('dfk_cascade_one', 'U') IS NOT NULL drop table dfk_cascade_one; +IF OBJECT_ID('dfk_cascade_one_seq', 'SO') IS NOT NULL drop sequence dfk_cascade_one_seq; + +IF OBJECT_ID('dfk_none', 'U') IS NOT NULL drop table dfk_none; +IF OBJECT_ID('dfk_none_seq', 'SO') IS NOT NULL drop sequence dfk_none_seq; + +IF OBJECT_ID('dfk_none_via_join', 'U') IS NOT NULL drop table dfk_none_via_join; +IF OBJECT_ID('dfk_none_via_join_seq', 'SO') IS NOT NULL drop sequence dfk_none_via_join_seq; + +IF OBJECT_ID('dfk_none_via_mto_m', 'U') IS NOT NULL drop table dfk_none_via_mto_m; +IF OBJECT_ID('dfk_none_via_mto_m_seq', 'SO') IS NOT NULL drop sequence dfk_none_via_mto_m_seq; + +IF OBJECT_ID('dfk_none_via_mto_m_dfk_one', 'U') IS NOT NULL drop table dfk_none_via_mto_m_dfk_one; + +IF OBJECT_ID('dfk_one', 'U') IS NOT NULL drop table dfk_one; +IF OBJECT_ID('dfk_one_seq', 'SO') IS NOT NULL drop sequence dfk_one_seq; + +IF OBJECT_ID('dfk_set_null', 'U') IS NOT NULL drop table dfk_set_null; +IF OBJECT_ID('dfk_set_null_seq', 'SO') IS NOT NULL drop sequence dfk_set_null_seq; + +IF OBJECT_ID('doc', 'U') IS NOT NULL drop table doc; +IF OBJECT_ID('doc_seq', 'SO') IS NOT NULL drop sequence doc_seq; + +IF OBJECT_ID('doc_link', 'U') IS NOT NULL drop table doc_link; + +IF OBJECT_ID('doc_link_draft', 'U') IS NOT NULL drop table doc_link_draft; + +IF OBJECT_ID('doc_draft', 'U') IS NOT NULL drop table doc_draft; +IF OBJECT_ID('doc_draft_seq', 'SO') IS NOT NULL drop sequence doc_draft_seq; + +IF OBJECT_ID('document', 'U') IS NOT NULL drop table document; +IF OBJECT_ID('document_seq', 'SO') IS NOT NULL drop sequence document_seq; + +IF OBJECT_ID('document_draft', 'U') IS NOT NULL drop table document_draft; +IF OBJECT_ID('document_draft_seq', 'SO') IS NOT NULL drop sequence document_draft_seq; + +IF OBJECT_ID('document_media', 'U') IS NOT NULL drop table document_media; +IF OBJECT_ID('document_media_seq', 'SO') IS NOT NULL drop sequence document_media_seq; + +IF OBJECT_ID('document_media_draft', 'U') IS NOT NULL drop table document_media_draft; +IF OBJECT_ID('document_media_draft_seq', 'SO') IS NOT NULL drop sequence document_media_draft_seq; + +IF OBJECT_ID('sp_car_door', 'U') IS NOT NULL drop table sp_car_door; +IF OBJECT_ID('sp_car_door_seq', 'SO') IS NOT NULL drop sequence sp_car_door_seq; + +IF OBJECT_ID('earray_bean', 'U') IS NOT NULL drop table earray_bean; +IF OBJECT_ID('earray_bean_seq', 'SO') IS NOT NULL drop sequence earray_bean_seq; + +IF OBJECT_ID('earray_set_bean', 'U') IS NOT NULL drop table earray_set_bean; +IF OBJECT_ID('earray_set_bean_seq', 'SO') IS NOT NULL drop sequence earray_set_bean_seq; + +IF OBJECT_ID('e_basic', 'U') IS NOT NULL drop table e_basic; +IF OBJECT_ID('e_basic_seq', 'SO') IS NOT NULL drop sequence e_basic_seq; + +IF OBJECT_ID('ebasic_change_log', 'U') IS NOT NULL drop table ebasic_change_log; +IF OBJECT_ID('ebasic_change_log_seq', 'SO') IS NOT NULL drop sequence ebasic_change_log_seq; + +IF OBJECT_ID('ebasic_clob', 'U') IS NOT NULL drop table ebasic_clob; +IF OBJECT_ID('ebasic_clob_seq', 'SO') IS NOT NULL drop sequence ebasic_clob_seq; + +IF OBJECT_ID('ebasic_clob_fetch_eager', 'U') IS NOT NULL drop table ebasic_clob_fetch_eager; +IF OBJECT_ID('ebasic_clob_fetch_eager_seq', 'SO') IS NOT NULL drop sequence ebasic_clob_fetch_eager_seq; + +IF OBJECT_ID('ebasic_clob_no_ver', 'U') IS NOT NULL drop table ebasic_clob_no_ver; +IF OBJECT_ID('ebasic_clob_no_ver_seq', 'SO') IS NOT NULL drop sequence ebasic_clob_no_ver_seq; + +IF OBJECT_ID('e_basicenc', 'U') IS NOT NULL drop table e_basicenc; +IF OBJECT_ID('e_basicenc_seq', 'SO') IS NOT NULL drop sequence e_basicenc_seq; + +IF OBJECT_ID('e_basicenc_bin', 'U') IS NOT NULL drop table e_basicenc_bin; +IF OBJECT_ID('e_basicenc_bin_seq', 'SO') IS NOT NULL drop sequence e_basicenc_bin_seq; + +IF OBJECT_ID('e_basicenc_client', 'U') IS NOT NULL drop table e_basicenc_client; +IF OBJECT_ID('e_basicenc_client_seq', 'SO') IS NOT NULL drop sequence e_basicenc_client_seq; + +IF OBJECT_ID('e_basicenc_relate', 'U') IS NOT NULL drop table e_basicenc_relate; +IF OBJECT_ID('e_basicenc_relate_seq', 'SO') IS NOT NULL drop sequence e_basicenc_relate_seq; + +IF OBJECT_ID('e_basic_enum_id', 'U') IS NOT NULL drop table e_basic_enum_id; + +IF OBJECT_ID('e_basic_eni', 'U') IS NOT NULL drop table e_basic_eni; +IF OBJECT_ID('e_basic_eni_seq', 'SO') IS NOT NULL drop sequence e_basic_eni_seq; + +IF OBJECT_ID('ebasic_hstore', 'U') IS NOT NULL drop table ebasic_hstore; +IF OBJECT_ID('ebasic_hstore_seq', 'SO') IS NOT NULL drop sequence ebasic_hstore_seq; + +IF OBJECT_ID('ebasic_json_jackson', 'U') IS NOT NULL drop table ebasic_json_jackson; +IF OBJECT_ID('ebasic_json_jackson_seq', 'SO') IS NOT NULL drop sequence ebasic_json_jackson_seq; + +IF OBJECT_ID('ebasic_json_jackson2', 'U') IS NOT NULL drop table ebasic_json_jackson2; +IF OBJECT_ID('ebasic_json_jackson2_seq', 'SO') IS NOT NULL drop sequence ebasic_json_jackson2_seq; + +IF OBJECT_ID('ebasic_json_list', 'U') IS NOT NULL drop table ebasic_json_list; +IF OBJECT_ID('ebasic_json_list_seq', 'SO') IS NOT NULL drop sequence ebasic_json_list_seq; + +IF OBJECT_ID('ebasic_json_map', 'U') IS NOT NULL drop table ebasic_json_map; +IF OBJECT_ID('ebasic_json_map_seq', 'SO') IS NOT NULL drop sequence ebasic_json_map_seq; + +IF OBJECT_ID('ebasic_json_map_blob', 'U') IS NOT NULL drop table ebasic_json_map_blob; +IF OBJECT_ID('ebasic_json_map_blob_seq', 'SO') IS NOT NULL drop sequence ebasic_json_map_blob_seq; + +IF OBJECT_ID('ebasic_json_map_clob', 'U') IS NOT NULL drop table ebasic_json_map_clob; +IF OBJECT_ID('ebasic_json_map_clob_seq', 'SO') IS NOT NULL drop sequence ebasic_json_map_clob_seq; + +IF OBJECT_ID('ebasic_json_map_detail', 'U') IS NOT NULL drop table ebasic_json_map_detail; +IF OBJECT_ID('ebasic_json_map_detail_seq', 'SO') IS NOT NULL drop sequence ebasic_json_map_detail_seq; + +IF OBJECT_ID('ebasic_json_map_json_b', 'U') IS NOT NULL drop table ebasic_json_map_json_b; +IF OBJECT_ID('ebasic_json_map_json_b_seq', 'SO') IS NOT NULL drop sequence ebasic_json_map_json_b_seq; + +IF OBJECT_ID('ebasic_json_map_varchar', 'U') IS NOT NULL drop table ebasic_json_map_varchar; +IF OBJECT_ID('ebasic_json_map_varchar_seq', 'SO') IS NOT NULL drop sequence ebasic_json_map_varchar_seq; + +IF OBJECT_ID('ebasic_json_node', 'U') IS NOT NULL drop table ebasic_json_node; +IF OBJECT_ID('ebasic_json_node_seq', 'SO') IS NOT NULL drop sequence ebasic_json_node_seq; + +IF OBJECT_ID('ebasic_json_node_blob', 'U') IS NOT NULL drop table ebasic_json_node_blob; +IF OBJECT_ID('ebasic_json_node_blob_seq', 'SO') IS NOT NULL drop sequence ebasic_json_node_blob_seq; + +IF OBJECT_ID('ebasic_json_node_json_b', 'U') IS NOT NULL drop table ebasic_json_node_json_b; +IF OBJECT_ID('ebasic_json_node_json_b_seq', 'SO') IS NOT NULL drop sequence ebasic_json_node_json_b_seq; + +IF OBJECT_ID('ebasic_json_node_varchar', 'U') IS NOT NULL drop table ebasic_json_node_varchar; +IF OBJECT_ID('ebasic_json_node_varchar_seq', 'SO') IS NOT NULL drop sequence ebasic_json_node_varchar_seq; + +IF OBJECT_ID('ebasic_json_unmapped', 'U') IS NOT NULL drop table ebasic_json_unmapped; +IF OBJECT_ID('ebasic_json_unmapped_seq', 'SO') IS NOT NULL drop sequence ebasic_json_unmapped_seq; + +IF OBJECT_ID('e_basic_ndc', 'U') IS NOT NULL drop table e_basic_ndc; +IF OBJECT_ID('e_basic_ndc_seq', 'SO') IS NOT NULL drop sequence e_basic_ndc_seq; + +IF OBJECT_ID('ebasic_no_sdchild', 'U') IS NOT NULL drop table ebasic_no_sdchild; +IF OBJECT_ID('ebasic_no_sdchild_seq', 'SO') IS NOT NULL drop sequence ebasic_no_sdchild_seq; + +IF OBJECT_ID('ebasic_sdchild', 'U') IS NOT NULL drop table ebasic_sdchild; +IF OBJECT_ID('ebasic_sdchild_seq', 'SO') IS NOT NULL drop sequence ebasic_sdchild_seq; + +IF OBJECT_ID('ebasic_soft_delete', 'U') IS NOT NULL drop table ebasic_soft_delete; +IF OBJECT_ID('ebasic_soft_delete_seq', 'SO') IS NOT NULL drop sequence ebasic_soft_delete_seq; + +IF OBJECT_ID('e_basicver', 'U') IS NOT NULL drop table e_basicver; +IF OBJECT_ID('e_basicver_seq', 'SO') IS NOT NULL drop sequence e_basicver_seq; + +IF OBJECT_ID('e_basic_withlife', 'U') IS NOT NULL drop table e_basic_withlife; +IF OBJECT_ID('e_basic_withlife_seq', 'SO') IS NOT NULL drop sequence e_basic_withlife_seq; + +IF OBJECT_ID('e_basic_with_ex', 'U') IS NOT NULL drop table e_basic_with_ex; +IF OBJECT_ID('e_basic_with_ex_seq', 'SO') IS NOT NULL drop sequence e_basic_with_ex_seq; + +IF OBJECT_ID('e_basicverucon', 'U') IS NOT NULL drop table e_basicverucon; +IF OBJECT_ID('e_basicverucon_seq', 'SO') IS NOT NULL drop sequence e_basicverucon_seq; + +IF OBJECT_ID('ecache_child', 'U') IS NOT NULL drop table ecache_child; + +IF OBJECT_ID('ecache_root', 'U') IS NOT NULL drop table ecache_root; + +IF OBJECT_ID('e_col_ab', 'U') IS NOT NULL drop table e_col_ab; +IF OBJECT_ID('e_col_ab_seq', 'SO') IS NOT NULL drop sequence e_col_ab_seq; + +IF OBJECT_ID('ecustom_id', 'U') IS NOT NULL drop table ecustom_id; + +IF OBJECT_ID('edefault_prop', 'U') IS NOT NULL drop table edefault_prop; +IF OBJECT_ID('edefault_prop_seq', 'SO') IS NOT NULL drop sequence edefault_prop_seq; + +IF OBJECT_ID('eemb_inner', 'U') IS NOT NULL drop table eemb_inner; +IF OBJECT_ID('eemb_inner_seq', 'SO') IS NOT NULL drop sequence eemb_inner_seq; + +IF OBJECT_ID('eemb_outer', 'U') IS NOT NULL drop table eemb_outer; +IF OBJECT_ID('eemb_outer_seq', 'SO') IS NOT NULL drop sequence eemb_outer_seq; + +IF OBJECT_ID('efile2_no_fk', 'U') IS NOT NULL drop table efile2_no_fk; + +IF OBJECT_ID('efile_no_fk', 'U') IS NOT NULL drop table efile_no_fk; + +IF OBJECT_ID('efile_no_fk_euser_no_fk', 'U') IS NOT NULL drop table efile_no_fk_euser_no_fk; + +IF OBJECT_ID('efile_no_fk_euser_no_fk_soft_del', 'U') IS NOT NULL drop table efile_no_fk_euser_no_fk_soft_del; + +IF OBJECT_ID('egen_props', 'U') IS NOT NULL drop table egen_props; +IF OBJECT_ID('egen_props_seq', 'SO') IS NOT NULL drop sequence egen_props_seq; + +IF OBJECT_ID('eid_uid_bean', 'U') IS NOT NULL drop table eid_uid_bean; +IF OBJECT_ID('eid_uid_bean_seq', 'SO') IS NOT NULL drop sequence eid_uid_bean_seq; + +IF OBJECT_ID('einvoice', 'U') IS NOT NULL drop table einvoice; +IF OBJECT_ID('einvoice_seq', 'SO') IS NOT NULL drop sequence einvoice_seq; + +IF OBJECT_ID('e_main', 'U') IS NOT NULL drop table e_main; +IF OBJECT_ID('e_main_seq', 'SO') IS NOT NULL drop sequence e_main_seq; + +IF OBJECT_ID('enull_collection', 'U') IS NOT NULL drop table enull_collection; +IF OBJECT_ID('enull_collection_seq', 'SO') IS NOT NULL drop sequence enull_collection_seq; + +IF OBJECT_ID('enull_collection_detail', 'U') IS NOT NULL drop table enull_collection_detail; +IF OBJECT_ID('enull_collection_detail_seq', 'SO') IS NOT NULL drop sequence enull_collection_detail_seq; + +IF OBJECT_ID('eopt_one_a', 'U') IS NOT NULL drop table eopt_one_a; +IF OBJECT_ID('eopt_one_a_seq', 'SO') IS NOT NULL drop sequence eopt_one_a_seq; + +IF OBJECT_ID('eopt_one_b', 'U') IS NOT NULL drop table eopt_one_b; +IF OBJECT_ID('eopt_one_b_seq', 'SO') IS NOT NULL drop sequence eopt_one_b_seq; + +IF OBJECT_ID('eopt_one_c', 'U') IS NOT NULL drop table eopt_one_c; +IF OBJECT_ID('eopt_one_c_seq', 'SO') IS NOT NULL drop sequence eopt_one_c_seq; + +IF OBJECT_ID('eper_addr', 'U') IS NOT NULL drop table eper_addr; +IF OBJECT_ID('eper_addr_seq', 'SO') IS NOT NULL drop sequence eper_addr_seq; + +IF OBJECT_ID('eperson', 'U') IS NOT NULL drop table eperson; +IF OBJECT_ID('eperson_seq', 'SO') IS NOT NULL drop sequence eperson_seq; + +IF OBJECT_ID('e_person_online', 'U') IS NOT NULL drop table e_person_online; +IF OBJECT_ID('e_person_online_seq', 'SO') IS NOT NULL drop sequence e_person_online_seq; + +IF OBJECT_ID('esimple', 'U') IS NOT NULL drop table esimple; + +IF OBJECT_ID('esoft_del_book', 'U') IS NOT NULL drop table esoft_del_book; +IF OBJECT_ID('esoft_del_book_seq', 'SO') IS NOT NULL drop sequence esoft_del_book_seq; + +IF OBJECT_ID('esoft_del_book_esoft_del_user', 'U') IS NOT NULL drop table esoft_del_book_esoft_del_user; + +IF OBJECT_ID('esoft_del_down', 'U') IS NOT NULL drop table esoft_del_down; +IF OBJECT_ID('esoft_del_down_seq', 'SO') IS NOT NULL drop sequence esoft_del_down_seq; + +IF OBJECT_ID('esoft_del_mid', 'U') IS NOT NULL drop table esoft_del_mid; +IF OBJECT_ID('esoft_del_mid_seq', 'SO') IS NOT NULL drop sequence esoft_del_mid_seq; + +IF OBJECT_ID('esoft_del_one_a', 'U') IS NOT NULL drop table esoft_del_one_a; +IF OBJECT_ID('esoft_del_one_a_seq', 'SO') IS NOT NULL drop sequence esoft_del_one_a_seq; + +IF OBJECT_ID('esoft_del_one_b', 'U') IS NOT NULL drop table esoft_del_one_b; +IF OBJECT_ID('esoft_del_one_b_seq', 'SO') IS NOT NULL drop sequence esoft_del_one_b_seq; + +IF OBJECT_ID('esoft_del_role', 'U') IS NOT NULL drop table esoft_del_role; +IF OBJECT_ID('esoft_del_role_seq', 'SO') IS NOT NULL drop sequence esoft_del_role_seq; + +IF OBJECT_ID('esoft_del_role_esoft_del_user', 'U') IS NOT NULL drop table esoft_del_role_esoft_del_user; + +IF OBJECT_ID('esoft_del_top', 'U') IS NOT NULL drop table esoft_del_top; +IF OBJECT_ID('esoft_del_top_seq', 'SO') IS NOT NULL drop sequence esoft_del_top_seq; + +IF OBJECT_ID('esoft_del_up', 'U') IS NOT NULL drop table esoft_del_up; +IF OBJECT_ID('esoft_del_up_seq', 'SO') IS NOT NULL drop sequence esoft_del_up_seq; + +IF OBJECT_ID('esoft_del_user', 'U') IS NOT NULL drop table esoft_del_user; +IF OBJECT_ID('esoft_del_user_seq', 'SO') IS NOT NULL drop sequence esoft_del_user_seq; + +IF OBJECT_ID('esoft_del_user_esoft_del_role', 'U') IS NOT NULL drop table esoft_del_user_esoft_del_role; + +IF OBJECT_ID('esome_convert_type', 'U') IS NOT NULL drop table esome_convert_type; +IF OBJECT_ID('esome_convert_type_seq', 'SO') IS NOT NULL drop sequence esome_convert_type_seq; + +IF OBJECT_ID('esome_type', 'U') IS NOT NULL drop table esome_type; +IF OBJECT_ID('esome_type_seq', 'SO') IS NOT NULL drop sequence esome_type_seq; + +IF OBJECT_ID('etrans_many', 'U') IS NOT NULL drop table etrans_many; +IF OBJECT_ID('etrans_many_seq', 'SO') IS NOT NULL drop sequence etrans_many_seq; + +IF OBJECT_ID('rawinherit_uncle', 'U') IS NOT NULL drop table rawinherit_uncle; +IF OBJECT_ID('rawinherit_uncle_seq', 'SO') IS NOT NULL drop sequence rawinherit_uncle_seq; + +IF OBJECT_ID('euser_no_fk', 'U') IS NOT NULL drop table euser_no_fk; +IF OBJECT_ID('euser_no_fk_seq', 'SO') IS NOT NULL drop sequence euser_no_fk_seq; + +IF OBJECT_ID('euser_no_fk_soft_del', 'U') IS NOT NULL drop table euser_no_fk_soft_del; +IF OBJECT_ID('euser_no_fk_soft_del_seq', 'SO') IS NOT NULL drop sequence euser_no_fk_soft_del_seq; + +IF OBJECT_ID('evanilla_collection', 'U') IS NOT NULL drop table evanilla_collection; +IF OBJECT_ID('evanilla_collection_seq', 'SO') IS NOT NULL drop sequence evanilla_collection_seq; + +IF OBJECT_ID('evanilla_collection_detail', 'U') IS NOT NULL drop table evanilla_collection_detail; +IF OBJECT_ID('evanilla_collection_detail_seq', 'SO') IS NOT NULL drop sequence evanilla_collection_detail_seq; + +IF OBJECT_ID('ewho_props', 'U') IS NOT NULL drop table ewho_props; +IF OBJECT_ID('ewho_props_seq', 'SO') IS NOT NULL drop sequence ewho_props_seq; + +IF OBJECT_ID('e_withinet', 'U') IS NOT NULL drop table e_withinet; +IF OBJECT_ID('e_withinet_seq', 'SO') IS NOT NULL drop sequence e_withinet_seq; + +IF OBJECT_ID('ec_enum_person', 'U') IS NOT NULL drop table ec_enum_person; +IF OBJECT_ID('ec_enum_person_seq', 'SO') IS NOT NULL drop sequence ec_enum_person_seq; + +IF OBJECT_ID('ec_enum_person_tags', 'U') IS NOT NULL drop table ec_enum_person_tags; + +IF OBJECT_ID('ec_person', 'U') IS NOT NULL drop table ec_person; +IF OBJECT_ID('ec_person_seq', 'SO') IS NOT NULL drop sequence ec_person_seq; + +IF OBJECT_ID('ec_person_phone', 'U') IS NOT NULL drop table ec_person_phone; + +IF OBJECT_ID('ec_top', 'U') IS NOT NULL drop table ec_top; +IF OBJECT_ID('ec_top_seq', 'SO') IS NOT NULL drop sequence ec_top_seq; + +IF OBJECT_ID('ec_top_ecs_person', 'U') IS NOT NULL drop table ec_top_ecs_person; + +IF OBJECT_ID('ecbl_person', 'U') IS NOT NULL drop table ecbl_person; +IF OBJECT_ID('ecbl_person_seq', 'SO') IS NOT NULL drop sequence ecbl_person_seq; + +IF OBJECT_ID('ecbl_person_phone_numbers', 'U') IS NOT NULL drop table ecbl_person_phone_numbers; + +IF OBJECT_ID('ecbm_person', 'U') IS NOT NULL drop table ecbm_person; +IF OBJECT_ID('ecbm_person_seq', 'SO') IS NOT NULL drop sequence ecbm_person_seq; + +IF OBJECT_ID('ecbm_person_phone_numbers', 'U') IS NOT NULL drop table ecbm_person_phone_numbers; + +IF OBJECT_ID('ecm_person', 'U') IS NOT NULL drop table ecm_person; +IF OBJECT_ID('ecm_person_seq', 'SO') IS NOT NULL drop sequence ecm_person_seq; + +IF OBJECT_ID('ecm_person_phone_numbers', 'U') IS NOT NULL drop table ecm_person_phone_numbers; + +IF OBJECT_ID('ecmc_person', 'U') IS NOT NULL drop table ecmc_person; +IF OBJECT_ID('ecmc_person_seq', 'SO') IS NOT NULL drop sequence ecmc_person_seq; + +IF OBJECT_ID('ecmc_person_phone_numbers', 'U') IS NOT NULL drop table ecmc_person_phone_numbers; + +IF OBJECT_ID('ecs_person', 'U') IS NOT NULL drop table ecs_person; +IF OBJECT_ID('ecs_person_seq', 'SO') IS NOT NULL drop sequence ecs_person_seq; + +IF OBJECT_ID('ecs_person_phone', 'U') IS NOT NULL drop table ecs_person_phone; + +IF OBJECT_ID('ecsm_child', 'U') IS NOT NULL drop table ecsm_child; + +IF OBJECT_ID('ecsm_values', 'U') IS NOT NULL drop table ecsm_values; + +IF OBJECT_ID('ecsm_one', 'U') IS NOT NULL drop table ecsm_one; + +IF OBJECT_ID('ecsm_parent', 'U') IS NOT NULL drop table ecsm_parent; +IF OBJECT_ID('ecsm_parent_seq', 'SO') IS NOT NULL drop sequence ecsm_parent_seq; + +IF OBJECT_ID('ecsm_two', 'U') IS NOT NULL drop table ecsm_two; + +IF OBJECT_ID('td_child', 'U') IS NOT NULL drop table td_child; +IF OBJECT_ID('td_child_seq', 'SO') IS NOT NULL drop sequence td_child_seq; + +IF OBJECT_ID('td_parent', 'U') IS NOT NULL drop table td_parent; +IF OBJECT_ID('td_parent_seq', 'SO') IS NOT NULL drop sequence td_parent_seq; + +IF OBJECT_ID('element_bean', 'U') IS NOT NULL drop table element_bean; +IF OBJECT_ID('element_bean_seq', 'SO') IS NOT NULL drop sequence element_bean_seq; + +IF OBJECT_ID('empl', 'U') IS NOT NULL drop table empl; +IF OBJECT_ID('empl_seq', 'SO') IS NOT NULL drop sequence empl_seq; + +IF OBJECT_ID('esd_detail', 'U') IS NOT NULL drop table esd_detail; +IF OBJECT_ID('esd_detail_seq', 'SO') IS NOT NULL drop sequence esd_detail_seq; + +IF OBJECT_ID('esd_master', 'U') IS NOT NULL drop table esd_master; +IF OBJECT_ID('esd_master_seq', 'SO') IS NOT NULL drop sequence esd_master_seq; + +IF OBJECT_ID('feature_desc', 'U') IS NOT NULL drop table feature_desc; +IF OBJECT_ID('feature_desc_seq', 'SO') IS NOT NULL drop sequence feature_desc_seq; + +IF OBJECT_ID('f_first', 'U') IS NOT NULL drop table f_first; +IF OBJECT_ID('f_first_seq', 'SO') IS NOT NULL drop sequence f_first_seq; + +IF OBJECT_ID('foo', 'U') IS NOT NULL drop table foo; +IF OBJECT_ID('foo_seq', 'SO') IS NOT NULL drop sequence foo_seq; + +IF OBJECT_ID('gen_key_identity', 'U') IS NOT NULL drop table gen_key_identity; + +IF OBJECT_ID('gen_key_sequence', 'U') IS NOT NULL drop table gen_key_sequence; +IF OBJECT_ID('gen_key_sequence_seq', 'SO') IS NOT NULL drop sequence gen_key_sequence_seq; + +IF OBJECT_ID('gen_key_table', 'U') IS NOT NULL drop table gen_key_table; +IF OBJECT_ID('gen_key_table_seq', 'SO') IS NOT NULL drop sequence gen_key_table_seq; + +IF OBJECT_ID('grand_parent_person', 'U') IS NOT NULL drop table grand_parent_person; +IF OBJECT_ID('grand_parent_person_seq', 'SO') IS NOT NULL drop sequence grand_parent_person_seq; + +IF OBJECT_ID('survey_group', 'U') IS NOT NULL drop table survey_group; +IF OBJECT_ID('survey_group_seq', 'SO') IS NOT NULL drop sequence survey_group_seq; + +IF OBJECT_ID('c_group', 'U') IS NOT NULL drop table c_group; +IF OBJECT_ID('c_group_seq', 'SO') IS NOT NULL drop sequence c_group_seq; + +IF OBJECT_ID('he_doc', 'U') IS NOT NULL drop table he_doc; +IF OBJECT_ID('he_doc_seq', 'SO') IS NOT NULL drop sequence he_doc_seq; + +IF OBJECT_ID('hx_link', 'U') IS NOT NULL alter table hx_link set (system_versioning = off); +IF OBJECT_ID('hx_link_history', 'U') IS NOT NULL drop table hx_link_history; +IF OBJECT_ID('hx_link', 'U') IS NOT NULL drop table hx_link; +IF OBJECT_ID('hx_link_seq', 'SO') IS NOT NULL drop sequence hx_link_seq; + +IF OBJECT_ID('hx_link_doc', 'U') IS NOT NULL drop table hx_link_doc; + +IF OBJECT_ID('hi_doc', 'U') IS NOT NULL drop table hi_doc; +IF OBJECT_ID('hi_doc_seq', 'SO') IS NOT NULL drop sequence hi_doc_seq; + +IF OBJECT_ID('hi_link', 'U') IS NOT NULL alter table hi_link set (system_versioning = off); +IF OBJECT_ID('hi_link_history', 'U') IS NOT NULL drop table hi_link_history; +IF OBJECT_ID('hi_link', 'U') IS NOT NULL drop table hi_link; +IF OBJECT_ID('hi_link_seq', 'SO') IS NOT NULL drop sequence hi_link_seq; + +IF OBJECT_ID('hi_link_doc', 'U') IS NOT NULL alter table hi_link_doc set (system_versioning = off); +IF OBJECT_ID('hi_link_doc_history', 'U') IS NOT NULL drop table hi_link_doc_history; +IF OBJECT_ID('hi_link_doc', 'U') IS NOT NULL drop table hi_link_doc; + +IF OBJECT_ID('hi_tone', 'U') IS NOT NULL alter table hi_tone set (system_versioning = off); +IF OBJECT_ID('hi_tone_history', 'U') IS NOT NULL drop table hi_tone_history; +IF OBJECT_ID('hi_tone', 'U') IS NOT NULL drop table hi_tone; +IF OBJECT_ID('hi_tone_seq', 'SO') IS NOT NULL drop sequence hi_tone_seq; + +IF OBJECT_ID('hi_tthree', 'U') IS NOT NULL alter table hi_tthree set (system_versioning = off); +IF OBJECT_ID('hi_tthree_history', 'U') IS NOT NULL drop table hi_tthree_history; +IF OBJECT_ID('hi_tthree', 'U') IS NOT NULL drop table hi_tthree; +IF OBJECT_ID('hi_tthree_seq', 'SO') IS NOT NULL drop sequence hi_tthree_seq; + +IF OBJECT_ID('hi_ttwo', 'U') IS NOT NULL alter table hi_ttwo set (system_versioning = off); +IF OBJECT_ID('hi_ttwo_history', 'U') IS NOT NULL drop table hi_ttwo_history; +IF OBJECT_ID('hi_ttwo', 'U') IS NOT NULL drop table hi_ttwo; +IF OBJECT_ID('hi_ttwo_seq', 'SO') IS NOT NULL drop sequence hi_ttwo_seq; + +IF OBJECT_ID('hsd_setting', 'U') IS NOT NULL alter table hsd_setting set (system_versioning = off); +IF OBJECT_ID('hsd_setting_history', 'U') IS NOT NULL drop table hsd_setting_history; +IF OBJECT_ID('hsd_setting', 'U') IS NOT NULL drop table hsd_setting; +IF OBJECT_ID('hsd_setting_seq', 'SO') IS NOT NULL drop sequence hsd_setting_seq; + +IF OBJECT_ID('hsd_user', 'U') IS NOT NULL alter table hsd_user set (system_versioning = off); +IF OBJECT_ID('hsd_user_history', 'U') IS NOT NULL drop table hsd_user_history; +IF OBJECT_ID('hsd_user', 'U') IS NOT NULL drop table hsd_user; +IF OBJECT_ID('hsd_user_seq', 'SO') IS NOT NULL drop sequence hsd_user_seq; + +IF OBJECT_ID('iaf_segment', 'U') IS NOT NULL drop table iaf_segment; +IF OBJECT_ID('iaf_segment_seq', 'SO') IS NOT NULL drop sequence iaf_segment_seq; + +IF OBJECT_ID('iaf_segment_status', 'U') IS NOT NULL drop table iaf_segment_status; +IF OBJECT_ID('iaf_segment_status_seq', 'SO') IS NOT NULL drop sequence iaf_segment_status_seq; + +IF OBJECT_ID('imrelated', 'U') IS NOT NULL drop table imrelated; +IF OBJECT_ID('imrelated_seq', 'SO') IS NOT NULL drop sequence imrelated_seq; + +IF OBJECT_ID('imroot', 'U') IS NOT NULL drop table imroot; +IF OBJECT_ID('imroot_seq', 'SO') IS NOT NULL drop sequence imroot_seq; + +IF OBJECT_ID('ixresource', 'U') IS NOT NULL drop table ixresource; + +IF OBJECT_ID('info_company', 'U') IS NOT NULL drop table info_company; +IF OBJECT_ID('info_company_seq', 'SO') IS NOT NULL drop sequence info_company_seq; + +IF OBJECT_ID('info_contact', 'U') IS NOT NULL drop table info_contact; +IF OBJECT_ID('info_contact_seq', 'SO') IS NOT NULL drop sequence info_contact_seq; + +IF OBJECT_ID('info_customer', 'U') IS NOT NULL drop table info_customer; +IF OBJECT_ID('info_customer_seq', 'SO') IS NOT NULL drop sequence info_customer_seq; + +IF OBJECT_ID('inner_report', 'U') IS NOT NULL drop table inner_report; +IF OBJECT_ID('inner_report_seq', 'SO') IS NOT NULL drop sequence inner_report_seq; + +IF OBJECT_ID('drel_invoice', 'U') IS NOT NULL drop table drel_invoice; +IF OBJECT_ID('drel_invoice_seq', 'SO') IS NOT NULL drop sequence drel_invoice_seq; + +IF OBJECT_ID('item', 'U') IS NOT NULL drop table item; + +IF OBJECT_ID('monkey', 'U') IS NOT NULL drop table monkey; +IF OBJECT_ID('monkey_seq', 'SO') IS NOT NULL drop sequence monkey_seq; + +IF OBJECT_ID('mkeygroup', 'U') IS NOT NULL drop table mkeygroup; +IF OBJECT_ID('mkeygroup_seq', 'SO') IS NOT NULL drop sequence mkeygroup_seq; + +IF OBJECT_ID('mkeygroup_monkey', 'U') IS NOT NULL drop table mkeygroup_monkey; + +IF OBJECT_ID('trainer', 'U') IS NOT NULL drop table trainer; +IF OBJECT_ID('trainer_seq', 'SO') IS NOT NULL drop sequence trainer_seq; + +IF OBJECT_ID('trainer_monkey', 'U') IS NOT NULL drop table trainer_monkey; + +IF OBJECT_ID('troop', 'U') IS NOT NULL drop table troop; +IF OBJECT_ID('troop_seq', 'SO') IS NOT NULL drop sequence troop_seq; + +IF OBJECT_ID('troop_monkey', 'U') IS NOT NULL drop table troop_monkey; + +IF OBJECT_ID('l2_cldf_reset_bean', 'U') IS NOT NULL drop table l2_cldf_reset_bean; +IF OBJECT_ID('l2_cldf_reset_bean_seq', 'SO') IS NOT NULL drop sequence l2_cldf_reset_bean_seq; + +IF OBJECT_ID('l2_cldf_reset_bean_child', 'U') IS NOT NULL drop table l2_cldf_reset_bean_child; +IF OBJECT_ID('l2_cldf_reset_bean_child_seq', 'SO') IS NOT NULL drop sequence l2_cldf_reset_bean_child_seq; + +IF OBJECT_ID('level1', 'U') IS NOT NULL drop table level1; +IF OBJECT_ID('level1_seq', 'SO') IS NOT NULL drop sequence level1_seq; + +IF OBJECT_ID('level1_level4', 'U') IS NOT NULL drop table level1_level4; + +IF OBJECT_ID('level1_level2', 'U') IS NOT NULL drop table level1_level2; + +IF OBJECT_ID('level2', 'U') IS NOT NULL drop table level2; +IF OBJECT_ID('level2_seq', 'SO') IS NOT NULL drop sequence level2_seq; + +IF OBJECT_ID('level2_level3', 'U') IS NOT NULL drop table level2_level3; + +IF OBJECT_ID('level3', 'U') IS NOT NULL drop table level3; +IF OBJECT_ID('level3_seq', 'SO') IS NOT NULL drop sequence level3_seq; + +IF OBJECT_ID('level4', 'U') IS NOT NULL drop table level4; +IF OBJECT_ID('level4_seq', 'SO') IS NOT NULL drop sequence level4_seq; + +IF OBJECT_ID('link', 'U') IS NOT NULL alter table link set (system_versioning = off); +IF OBJECT_ID('link_history', 'U') IS NOT NULL drop table link_history; +IF OBJECT_ID('link', 'U') IS NOT NULL drop table link; +IF OBJECT_ID('link_seq', 'SO') IS NOT NULL drop sequence link_seq; + +IF OBJECT_ID('link_draft', 'U') IS NOT NULL drop table link_draft; +IF OBJECT_ID('link_draft_seq', 'SO') IS NOT NULL drop sequence link_draft_seq; + +IF OBJECT_ID('la_attr_value', 'U') IS NOT NULL drop table la_attr_value; +IF OBJECT_ID('la_attr_value_seq', 'SO') IS NOT NULL drop sequence la_attr_value_seq; + +IF OBJECT_ID('la_attr_value_attribute', 'U') IS NOT NULL drop table la_attr_value_attribute; + +IF OBJECT_ID('looney', 'U') IS NOT NULL drop table looney; +IF OBJECT_ID('looney_seq', 'SO') IS NOT NULL drop sequence looney_seq; + +IF OBJECT_ID('maddress', 'U') IS NOT NULL drop table maddress; + +IF OBJECT_ID('mcontact', 'U') IS NOT NULL drop table mcontact; + +IF OBJECT_ID('mcontact_message', 'U') IS NOT NULL drop table mcontact_message; + +IF OBJECT_ID('mcustomer', 'U') IS NOT NULL drop table mcustomer; + +IF OBJECT_ID('mgroup', 'U') IS NOT NULL drop table mgroup; +IF OBJECT_ID('mgroup_seq', 'SO') IS NOT NULL drop sequence mgroup_seq; + +IF OBJECT_ID('mmachine', 'U') IS NOT NULL drop table mmachine; +IF OBJECT_ID('mmachine_seq', 'SO') IS NOT NULL drop sequence mmachine_seq; + +IF OBJECT_ID('mmachine_mgroup', 'U') IS NOT NULL drop table mmachine_mgroup; + +IF OBJECT_ID('mmedia', 'U') IS NOT NULL drop table mmedia; +IF OBJECT_ID('mmedia_seq', 'SO') IS NOT NULL drop sequence mmedia_seq; + +IF OBJECT_ID('non_updateprop', 'U') IS NOT NULL drop table non_updateprop; +IF OBJECT_ID('non_updateprop_seq', 'SO') IS NOT NULL drop sequence non_updateprop_seq; + +IF OBJECT_ID('mprinter', 'U') IS NOT NULL drop table mprinter; +IF OBJECT_ID('mprinter_seq', 'SO') IS NOT NULL drop sequence mprinter_seq; + +IF OBJECT_ID('mprinter_state', 'U') IS NOT NULL drop table mprinter_state; +IF OBJECT_ID('mprinter_state_seq', 'SO') IS NOT NULL drop sequence mprinter_state_seq; + +IF OBJECT_ID('mprofile', 'U') IS NOT NULL drop table mprofile; +IF OBJECT_ID('mprofile_seq', 'SO') IS NOT NULL drop sequence mprofile_seq; + +IF OBJECT_ID('mprotected_construct_bean', 'U') IS NOT NULL drop table mprotected_construct_bean; +IF OBJECT_ID('mprotected_construct_bean_seq', 'SO') IS NOT NULL drop sequence mprotected_construct_bean_seq; + +IF OBJECT_ID('mrole', 'U') IS NOT NULL drop table mrole; +IF OBJECT_ID('mrole_seq', 'SO') IS NOT NULL drop sequence mrole_seq; + +IF OBJECT_ID('mrole_muser', 'U') IS NOT NULL drop table mrole_muser; + +IF OBJECT_ID('msome_other', 'U') IS NOT NULL drop table msome_other; +IF OBJECT_ID('msome_other_seq', 'SO') IS NOT NULL drop sequence msome_other_seq; + +IF OBJECT_ID('muser', 'U') IS NOT NULL drop table muser; +IF OBJECT_ID('muser_seq', 'SO') IS NOT NULL drop sequence muser_seq; + +IF OBJECT_ID('muser_type', 'U') IS NOT NULL drop table muser_type; +IF OBJECT_ID('muser_type_seq', 'SO') IS NOT NULL drop sequence muser_type_seq; + +IF OBJECT_ID('mail_box', 'U') IS NOT NULL drop table mail_box; +IF OBJECT_ID('mail_box_seq', 'SO') IS NOT NULL drop sequence mail_box_seq; + +IF OBJECT_ID('mail_user', 'U') IS NOT NULL drop table mail_user; +IF OBJECT_ID('mail_user_seq', 'SO') IS NOT NULL drop sequence mail_user_seq; + +IF OBJECT_ID('mail_user_inbox', 'U') IS NOT NULL drop table mail_user_inbox; + +IF OBJECT_ID('mail_user_outbox', 'U') IS NOT NULL drop table mail_user_outbox; + +IF OBJECT_ID('main_entity', 'U') IS NOT NULL drop table main_entity; + +IF OBJECT_ID('main_entity_relation', 'U') IS NOT NULL drop table main_entity_relation; + +IF OBJECT_ID('map_super_actual', 'U') IS NOT NULL drop table map_super_actual; +IF OBJECT_ID('map_super_actual_seq', 'SO') IS NOT NULL drop sequence map_super_actual_seq; + +IF OBJECT_ID('c_message', 'U') IS NOT NULL drop table c_message; +IF OBJECT_ID('c_message_seq', 'SO') IS NOT NULL drop sequence c_message_seq; + +IF OBJECT_ID('meter_address_data', 'U') IS NOT NULL drop table meter_address_data; + +IF OBJECT_ID('meter_contract_data', 'U') IS NOT NULL drop table meter_contract_data; + +IF OBJECT_ID('meter_special_needs_client', 'U') IS NOT NULL drop table meter_special_needs_client; + +IF OBJECT_ID('meter_special_needs_contact', 'U') IS NOT NULL drop table meter_special_needs_contact; + +IF OBJECT_ID('meter_version', 'U') IS NOT NULL drop table meter_version; + +IF OBJECT_ID('mnoc_role', 'U') IS NOT NULL drop table mnoc_role; +IF OBJECT_ID('mnoc_role_seq', 'SO') IS NOT NULL drop sequence mnoc_role_seq; + +IF OBJECT_ID('mnoc_user', 'U') IS NOT NULL drop table mnoc_user; +IF OBJECT_ID('mnoc_user_seq', 'SO') IS NOT NULL drop sequence mnoc_user_seq; + +IF OBJECT_ID('mnoc_user_mnoc_role', 'U') IS NOT NULL drop table mnoc_user_mnoc_role; + +IF OBJECT_ID('mny_a', 'U') IS NOT NULL drop table mny_a; +IF OBJECT_ID('mny_a_seq', 'SO') IS NOT NULL drop sequence mny_a_seq; + +IF OBJECT_ID('mny_b', 'U') IS NOT NULL drop table mny_b; +IF OBJECT_ID('mny_b_seq', 'SO') IS NOT NULL drop sequence mny_b_seq; + +IF OBJECT_ID('mny_b_mny_c', 'U') IS NOT NULL drop table mny_b_mny_c; + +IF OBJECT_ID('mny_c', 'U') IS NOT NULL drop table mny_c; +IF OBJECT_ID('mny_c_seq', 'SO') IS NOT NULL drop sequence mny_c_seq; + +IF OBJECT_ID('mny_topic', 'U') IS NOT NULL drop table mny_topic; +IF OBJECT_ID('mny_topic_seq', 'SO') IS NOT NULL drop sequence mny_topic_seq; + +IF OBJECT_ID('subtopics', 'U') IS NOT NULL drop table subtopics; + +IF OBJECT_ID('mp_role', 'U') IS NOT NULL drop table mp_role; +IF OBJECT_ID('mp_role_seq', 'SO') IS NOT NULL drop sequence mp_role_seq; + +IF OBJECT_ID('mp_user', 'U') IS NOT NULL drop table mp_user; +IF OBJECT_ID('mp_user_seq', 'SO') IS NOT NULL drop sequence mp_user_seq; + +IF OBJECT_ID('ms_many_a', 'U') IS NOT NULL drop table ms_many_a; +IF OBJECT_ID('ms_many_a_seq', 'SO') IS NOT NULL drop sequence ms_many_a_seq; + +IF OBJECT_ID('ms_many_a_many_b', 'U') IS NOT NULL drop table ms_many_a_many_b; + +IF OBJECT_ID('ms_many_b', 'U') IS NOT NULL drop table ms_many_b; +IF OBJECT_ID('ms_many_b_seq', 'SO') IS NOT NULL drop sequence ms_many_b_seq; + +IF OBJECT_ID('ms_many_b_many_a', 'U') IS NOT NULL drop table ms_many_b_many_a; + +IF OBJECT_ID('my_lob_size', 'U') IS NOT NULL drop table my_lob_size; +IF OBJECT_ID('my_lob_size_seq', 'SO') IS NOT NULL drop sequence my_lob_size_seq; + +IF OBJECT_ID('my_lob_size_join_many', 'U') IS NOT NULL drop table my_lob_size_join_many; +IF OBJECT_ID('my_lob_size_join_many_seq', 'SO') IS NOT NULL drop sequence my_lob_size_join_many_seq; + +IF OBJECT_ID('noidbean', 'U') IS NOT NULL drop table noidbean; + +IF OBJECT_ID('o_bean_child', 'U') IS NOT NULL drop table o_bean_child; +IF OBJECT_ID('o_bean_child_seq', 'SO') IS NOT NULL drop sequence o_bean_child_seq; + +IF OBJECT_ID('ocached_app', 'U') IS NOT NULL drop table ocached_app; +IF OBJECT_ID('ocached_app_seq', 'SO') IS NOT NULL drop sequence ocached_app_seq; + +IF OBJECT_ID('ocached_app_detail', 'U') IS NOT NULL drop table ocached_app_detail; +IF OBJECT_ID('ocached_app_detail_seq', 'SO') IS NOT NULL drop sequence ocached_app_detail_seq; + +IF OBJECT_ID('o_cached_bean', 'U') IS NOT NULL drop table o_cached_bean; +IF OBJECT_ID('o_cached_bean_seq', 'SO') IS NOT NULL drop sequence o_cached_bean_seq; + +IF OBJECT_ID('o_cached_bean_country', 'U') IS NOT NULL drop table o_cached_bean_country; + +IF OBJECT_ID('o_cached_bean_child', 'U') IS NOT NULL drop table o_cached_bean_child; +IF OBJECT_ID('o_cached_bean_child_seq', 'SO') IS NOT NULL drop sequence o_cached_bean_child_seq; + +IF OBJECT_ID('o_cached_inherit', 'U') IS NOT NULL drop table o_cached_inherit; +IF OBJECT_ID('o_cached_inherit_seq', 'SO') IS NOT NULL drop sequence o_cached_inherit_seq; + +IF OBJECT_ID('o_cached_natkey', 'U') IS NOT NULL drop table o_cached_natkey; +IF OBJECT_ID('o_cached_natkey_seq', 'SO') IS NOT NULL drop sequence o_cached_natkey_seq; + +IF OBJECT_ID('o_cached_natkey3', 'U') IS NOT NULL drop table o_cached_natkey3; +IF OBJECT_ID('o_cached_natkey3_seq', 'SO') IS NOT NULL drop sequence o_cached_natkey3_seq; + +IF OBJECT_ID('ocached_nkey_uid', 'U') IS NOT NULL drop table ocached_nkey_uid; +IF OBJECT_ID('ocached_nkey_uid_seq', 'SO') IS NOT NULL drop sequence ocached_nkey_uid_seq; + +IF OBJECT_ID('ocar', 'U') IS NOT NULL drop table ocar; +IF OBJECT_ID('ocar_seq', 'SO') IS NOT NULL drop sequence ocar_seq; + +IF OBJECT_ID('ocompany', 'U') IS NOT NULL drop table ocompany; +IF OBJECT_ID('ocompany_seq', 'SO') IS NOT NULL drop sequence ocompany_seq; + +IF OBJECT_ID('oengine', 'U') IS NOT NULL drop table oengine; + +IF OBJECT_ID('ogear_box', 'U') IS NOT NULL drop table ogear_box; + +IF OBJECT_ID('omvertex', 'U') IS NOT NULL drop table omvertex; + +IF OBJECT_ID('omvertex_other', 'U') IS NOT NULL drop table omvertex_other; + +IF OBJECT_ID('oroad_show_msg', 'U') IS NOT NULL drop table oroad_show_msg; +IF OBJECT_ID('oroad_show_msg_seq', 'SO') IS NOT NULL drop sequence oroad_show_msg_seq; + +IF OBJECT_ID('om_account_child_dbo', 'U') IS NOT NULL drop table om_account_child_dbo; +IF OBJECT_ID('om_account_child_dbo_seq', 'SO') IS NOT NULL drop sequence om_account_child_dbo_seq; + +IF OBJECT_ID('om_account_dbo', 'U') IS NOT NULL drop table om_account_dbo; +IF OBJECT_ID('om_account_dbo_seq', 'SO') IS NOT NULL drop sequence om_account_dbo_seq; + +IF OBJECT_ID('om_basic_child', 'U') IS NOT NULL drop table om_basic_child; +IF OBJECT_ID('om_basic_child_seq', 'SO') IS NOT NULL drop sequence om_basic_child_seq; + +IF OBJECT_ID('om_basic_parent', 'U') IS NOT NULL drop table om_basic_parent; +IF OBJECT_ID('om_basic_parent_seq', 'SO') IS NOT NULL drop sequence om_basic_parent_seq; + +IF OBJECT_ID('om_ordered_detail', 'U') IS NOT NULL drop table om_ordered_detail; +IF OBJECT_ID('om_ordered_detail_seq', 'SO') IS NOT NULL drop sequence om_ordered_detail_seq; + +IF OBJECT_ID('om_ordered_master', 'U') IS NOT NULL drop table om_ordered_master; +IF OBJECT_ID('om_ordered_master_seq', 'SO') IS NOT NULL drop sequence om_ordered_master_seq; + +IF OBJECT_ID('only_id_entity', 'U') IS NOT NULL drop table only_id_entity; +IF OBJECT_ID('only_id_entity_seq', 'SO') IS NOT NULL drop sequence only_id_entity_seq; + +IF OBJECT_ID('o_order', 'U') IS NOT NULL drop table o_order; +IF OBJECT_ID('o_order_seq', 'SO') IS NOT NULL drop sequence o_order_seq; + +IF OBJECT_ID('o_order_detail', 'U') IS NOT NULL drop table o_order_detail; +IF OBJECT_ID('o_order_detail_seq', 'SO') IS NOT NULL drop sequence o_order_detail_seq; + +IF OBJECT_ID('s_orders', 'U') IS NOT NULL drop table s_orders; + +IF OBJECT_ID('s_order_items', 'U') IS NOT NULL drop table s_order_items; + +IF OBJECT_ID('or_order_ship', 'U') IS NOT NULL drop table or_order_ship; +IF OBJECT_ID('or_order_ship_seq', 'SO') IS NOT NULL drop sequence or_order_ship_seq; + +IF OBJECT_ID('organisation', 'U') IS NOT NULL drop table organisation; +IF OBJECT_ID('organisation_seq', 'SO') IS NOT NULL drop sequence organisation_seq; + +IF OBJECT_ID('organization_node', 'U') IS NOT NULL drop table organization_node; +IF OBJECT_ID('organization_node_seq', 'SO') IS NOT NULL drop sequence organization_node_seq; + +IF OBJECT_ID('organization_tree_node', 'U') IS NOT NULL drop table organization_tree_node; +IF OBJECT_ID('organization_tree_node_seq', 'SO') IS NOT NULL drop sequence organization_tree_node_seq; + +IF OBJECT_ID('orp_detail', 'U') IS NOT NULL drop table orp_detail; + +IF OBJECT_ID('orp_detail2', 'U') IS NOT NULL drop table orp_detail2; + +IF OBJECT_ID('orp_master', 'U') IS NOT NULL drop table orp_master; + +IF OBJECT_ID('orp_master2', 'U') IS NOT NULL drop table orp_master2; + +IF OBJECT_ID('oto_aone', 'U') IS NOT NULL drop table oto_aone; + +IF OBJECT_ID('oto_atwo', 'U') IS NOT NULL drop table oto_atwo; + +IF OBJECT_ID('oto_bchild', 'U') IS NOT NULL drop table oto_bchild; +IF OBJECT_ID('oto_bchild_seq', 'SO') IS NOT NULL drop sequence oto_bchild_seq; + +IF OBJECT_ID('oto_bmaster', 'U') IS NOT NULL drop table oto_bmaster; +IF OBJECT_ID('oto_bmaster_seq', 'SO') IS NOT NULL drop sequence oto_bmaster_seq; + +IF OBJECT_ID('oto_child', 'U') IS NOT NULL drop table oto_child; +IF OBJECT_ID('oto_child_seq', 'SO') IS NOT NULL drop sequence oto_child_seq; + +IF OBJECT_ID('oto_cust', 'U') IS NOT NULL drop table oto_cust; +IF OBJECT_ID('oto_cust_seq', 'SO') IS NOT NULL drop sequence oto_cust_seq; + +IF OBJECT_ID('oto_cust_address', 'U') IS NOT NULL drop table oto_cust_address; +IF OBJECT_ID('oto_cust_address_seq', 'SO') IS NOT NULL drop sequence oto_cust_address_seq; + +IF OBJECT_ID('oto_level_a', 'U') IS NOT NULL drop table oto_level_a; +IF OBJECT_ID('oto_level_a_seq', 'SO') IS NOT NULL drop sequence oto_level_a_seq; + +IF OBJECT_ID('oto_level_b', 'U') IS NOT NULL drop table oto_level_b; +IF OBJECT_ID('oto_level_b_seq', 'SO') IS NOT NULL drop sequence oto_level_b_seq; + +IF OBJECT_ID('oto_level_c', 'U') IS NOT NULL drop table oto_level_c; +IF OBJECT_ID('oto_level_c_seq', 'SO') IS NOT NULL drop sequence oto_level_c_seq; + +IF OBJECT_ID('oto_master', 'U') IS NOT NULL drop table oto_master; +IF OBJECT_ID('oto_master_seq', 'SO') IS NOT NULL drop sequence oto_master_seq; + +IF OBJECT_ID('oto_prime', 'U') IS NOT NULL drop table oto_prime; +IF OBJECT_ID('oto_prime_seq', 'SO') IS NOT NULL drop sequence oto_prime_seq; + +IF OBJECT_ID('oto_prime_extra', 'U') IS NOT NULL drop table oto_prime_extra; +IF OBJECT_ID('oto_prime_extra_seq', 'SO') IS NOT NULL drop sequence oto_prime_extra_seq; + +IF OBJECT_ID('oto_sd_child', 'U') IS NOT NULL drop table oto_sd_child; +IF OBJECT_ID('oto_sd_child_seq', 'SO') IS NOT NULL drop sequence oto_sd_child_seq; + +IF OBJECT_ID('oto_sd_master', 'U') IS NOT NULL drop table oto_sd_master; +IF OBJECT_ID('oto_sd_master_seq', 'SO') IS NOT NULL drop sequence oto_sd_master_seq; + +IF OBJECT_ID('oto_th_many', 'U') IS NOT NULL drop table oto_th_many; +IF OBJECT_ID('oto_th_many_seq', 'SO') IS NOT NULL drop sequence oto_th_many_seq; + +IF OBJECT_ID('oto_th_one', 'U') IS NOT NULL drop table oto_th_one; +IF OBJECT_ID('oto_th_one_seq', 'SO') IS NOT NULL drop sequence oto_th_one_seq; + +IF OBJECT_ID('oto_th_top', 'U') IS NOT NULL drop table oto_th_top; +IF OBJECT_ID('oto_th_top_seq', 'SO') IS NOT NULL drop sequence oto_th_top_seq; + +IF OBJECT_ID('oto_ubprime', 'U') IS NOT NULL drop table oto_ubprime; + +IF OBJECT_ID('oto_ubprime_extra', 'U') IS NOT NULL drop table oto_ubprime_extra; + +IF OBJECT_ID('oto_uprime', 'U') IS NOT NULL drop table oto_uprime; + +IF OBJECT_ID('oto_uprime_extra', 'U') IS NOT NULL drop table oto_uprime_extra; + +IF OBJECT_ID('oto_user_model', 'U') IS NOT NULL drop table oto_user_model; +IF OBJECT_ID('oto_user_model_seq', 'SO') IS NOT NULL drop sequence oto_user_model_seq; + +IF OBJECT_ID('oto_user_model_optional', 'U') IS NOT NULL drop table oto_user_model_optional; +IF OBJECT_ID('oto_user_model_optional_seq', 'SO') IS NOT NULL drop sequence oto_user_model_optional_seq; + +IF OBJECT_ID('pfile', 'U') IS NOT NULL drop table pfile; +IF OBJECT_ID('pfile_seq', 'SO') IS NOT NULL drop sequence pfile_seq; + +IF OBJECT_ID('pfile_content', 'U') IS NOT NULL drop table pfile_content; +IF OBJECT_ID('pfile_content_seq', 'SO') IS NOT NULL drop sequence pfile_content_seq; + +IF OBJECT_ID('paggview', 'U') IS NOT NULL drop table paggview; + +IF OBJECT_ID('pallet_location', 'U') IS NOT NULL drop table pallet_location; +IF OBJECT_ID('pallet_location_seq', 'SO') IS NOT NULL drop sequence pallet_location_seq; + +IF OBJECT_ID('parcel', 'U') IS NOT NULL drop table parcel; +IF OBJECT_ID('parcel_seq', 'SO') IS NOT NULL drop sequence parcel_seq; + +IF OBJECT_ID('parcel_location', 'U') IS NOT NULL drop table parcel_location; +IF OBJECT_ID('parcel_location_seq', 'SO') IS NOT NULL drop sequence parcel_location_seq; + +IF OBJECT_ID('rawinherit_parent', 'U') IS NOT NULL drop table rawinherit_parent; +IF OBJECT_ID('rawinherit_parent_seq', 'SO') IS NOT NULL drop sequence rawinherit_parent_seq; + +IF OBJECT_ID('rawinherit_parent_rawinherit_data', 'U') IS NOT NULL drop table rawinherit_parent_rawinherit_data; + +IF OBJECT_ID('e_save_test_c', 'U') IS NOT NULL drop table e_save_test_c; +IF OBJECT_ID('e_save_test_c_seq', 'SO') IS NOT NULL drop sequence e_save_test_c_seq; + +IF OBJECT_ID('parent_person', 'U') IS NOT NULL drop table parent_person; +IF OBJECT_ID('parent_person_seq', 'SO') IS NOT NULL drop sequence parent_person_seq; + +IF OBJECT_ID('c_participation', 'U') IS NOT NULL drop table c_participation; +IF OBJECT_ID('c_participation_seq', 'SO') IS NOT NULL drop sequence c_participation_seq; + +IF OBJECT_ID('password_store_model', 'U') IS NOT NULL drop table password_store_model; +IF OBJECT_ID('password_store_model_seq', 'SO') IS NOT NULL drop sequence password_store_model_seq; + +IF OBJECT_ID('pcf_calendar', 'U') IS NOT NULL drop table pcf_calendar; +IF OBJECT_ID('pcf_calendar_seq', 'SO') IS NOT NULL drop sequence pcf_calendar_seq; + +IF OBJECT_ID('pcf_city', 'U') IS NOT NULL drop table pcf_city; +IF OBJECT_ID('pcf_city_seq', 'SO') IS NOT NULL drop sequence pcf_city_seq; + +IF OBJECT_ID('pcf_country', 'U') IS NOT NULL drop table pcf_country; +IF OBJECT_ID('pcf_country_seq', 'SO') IS NOT NULL drop sequence pcf_country_seq; + +IF OBJECT_ID('pcf_event', 'U') IS NOT NULL drop table pcf_event; +IF OBJECT_ID('pcf_event_seq', 'SO') IS NOT NULL drop sequence pcf_event_seq; + +IF OBJECT_ID('pcf_person', 'U') IS NOT NULL drop table pcf_person; +IF OBJECT_ID('pcf_person_seq', 'SO') IS NOT NULL drop sequence pcf_person_seq; + +IF OBJECT_ID('mt_permission', 'U') IS NOT NULL drop table mt_permission; + +IF OBJECT_ID('persistent_file', 'U') IS NOT NULL drop table persistent_file; +IF OBJECT_ID('persistent_file_seq', 'SO') IS NOT NULL drop sequence persistent_file_seq; + +IF OBJECT_ID('persistent_file_content', 'U') IS NOT NULL drop table persistent_file_content; +IF OBJECT_ID('persistent_file_content_seq', 'SO') IS NOT NULL drop sequence persistent_file_content_seq; + +IF OBJECT_ID('person', 'U') IS NOT NULL drop table person; +IF OBJECT_ID('person_seq', 'SO') IS NOT NULL drop sequence person_seq; + +IF OBJECT_ID('persons', 'U') IS NOT NULL drop table persons; +IF OBJECT_ID('PERSONS_seq', 'SO') IS NOT NULL drop sequence PERSONS_seq; + +IF OBJECT_ID('person_cache_email', 'U') IS NOT NULL drop table person_cache_email; + +IF OBJECT_ID('person_cache_info', 'U') IS NOT NULL drop table person_cache_info; + +IF OBJECT_ID('phones', 'U') IS NOT NULL drop table phones; +IF OBJECT_ID('PHONES_seq', 'SO') IS NOT NULL drop sequence PHONES_seq; + +IF OBJECT_ID('e_position', 'U') IS NOT NULL drop table e_position; +IF OBJECT_ID('e_position_seq', 'SO') IS NOT NULL drop sequence e_position_seq; + +IF OBJECT_ID('primary_revision', 'U') IS NOT NULL drop table primary_revision; + +IF OBJECT_ID('o_product', 'U') IS NOT NULL drop table o_product; +IF OBJECT_ID('o_product_seq', 'SO') IS NOT NULL drop sequence o_product_seq; + +IF OBJECT_ID('pp', 'U') IS NOT NULL drop table pp; + +IF OBJECT_ID('pp_to_ww', 'U') IS NOT NULL drop table pp_to_ww; + +IF OBJECT_ID('question', 'U') IS NOT NULL drop table question; +IF OBJECT_ID('question_seq', 'SO') IS NOT NULL drop sequence question_seq; + +IF OBJECT_ID('rcustomer', 'U') IS NOT NULL drop table rcustomer; + +IF OBJECT_ID('r_orders', 'U') IS NOT NULL drop table r_orders; + +IF OBJECT_ID('referencing_bean', 'U') IS NOT NULL drop table referencing_bean; + +IF OBJECT_ID('region', 'U') IS NOT NULL drop table region; + +IF OBJECT_ID('rel_detail', 'U') IS NOT NULL drop table rel_detail; +IF OBJECT_ID('rel_detail_seq', 'SO') IS NOT NULL drop sequence rel_detail_seq; + +IF OBJECT_ID('rel_master', 'U') IS NOT NULL drop table rel_master; +IF OBJECT_ID('rel_master_seq', 'SO') IS NOT NULL drop sequence rel_master_seq; + +IF OBJECT_ID('resourcefile', 'U') IS NOT NULL drop table resourcefile; + +IF OBJECT_ID('mt_role', 'U') IS NOT NULL drop table mt_role; + +IF OBJECT_ID('mt_role_permission', 'U') IS NOT NULL drop table mt_role_permission; + +IF OBJECT_ID('em_role', 'U') IS NOT NULL drop table em_role; +IF OBJECT_ID('em_role_seq', 'SO') IS NOT NULL drop sequence em_role_seq; + +IF OBJECT_ID('root_bean', 'U') IS NOT NULL drop table root_bean; + +IF OBJECT_ID('f_second', 'U') IS NOT NULL drop table f_second; +IF OBJECT_ID('f_second_seq', 'SO') IS NOT NULL drop sequence f_second_seq; + +IF OBJECT_ID('section', 'U') IS NOT NULL drop table section; +IF OBJECT_ID('section_seq', 'SO') IS NOT NULL drop sequence section_seq; + +IF OBJECT_ID('self_parent', 'U') IS NOT NULL drop table self_parent; +IF OBJECT_ID('self_parent_seq', 'SO') IS NOT NULL drop sequence self_parent_seq; + +IF OBJECT_ID('self_ref_customer', 'U') IS NOT NULL drop table self_ref_customer; +IF OBJECT_ID('self_ref_customer_seq', 'SO') IS NOT NULL drop sequence self_ref_customer_seq; + +IF OBJECT_ID('self_ref_example', 'U') IS NOT NULL drop table self_ref_example; +IF OBJECT_ID('self_ref_example_seq', 'SO') IS NOT NULL drop sequence self_ref_example_seq; + +IF OBJECT_ID('e_save_test_a', 'U') IS NOT NULL drop table e_save_test_a; +IF OBJECT_ID('e_save_test_a_seq', 'SO') IS NOT NULL drop sequence e_save_test_a_seq; + +IF OBJECT_ID('e_save_test_b', 'U') IS NOT NULL drop table e_save_test_b; +IF OBJECT_ID('e_save_test_b_seq', 'SO') IS NOT NULL drop sequence e_save_test_b_seq; + +IF OBJECT_ID('site', 'U') IS NOT NULL drop table site; + +IF OBJECT_ID('site_address', 'U') IS NOT NULL drop table site_address; + +IF OBJECT_ID('some_enum_bean', 'U') IS NOT NULL drop table some_enum_bean; +IF OBJECT_ID('some_enum_bean_seq', 'SO') IS NOT NULL drop sequence some_enum_bean_seq; + +IF OBJECT_ID('some_file_bean', 'U') IS NOT NULL drop table some_file_bean; +IF OBJECT_ID('some_file_bean_seq', 'SO') IS NOT NULL drop sequence some_file_bean_seq; + +IF OBJECT_ID('some_new_types_bean', 'U') IS NOT NULL drop table some_new_types_bean; +IF OBJECT_ID('some_new_types_bean_seq', 'SO') IS NOT NULL drop sequence some_new_types_bean_seq; + +IF OBJECT_ID('some_period_bean', 'U') IS NOT NULL drop table some_period_bean; +IF OBJECT_ID('some_period_bean_seq', 'SO') IS NOT NULL drop sequence some_period_bean_seq; + +IF OBJECT_ID('source_base', 'U') IS NOT NULL drop table source_base; + +IF OBJECT_ID('stockforecast', 'U') IS NOT NULL drop table stockforecast; +IF OBJECT_ID('stockforecast_seq', 'SO') IS NOT NULL drop sequence stockforecast_seq; + +IF OBJECT_ID('sub_section', 'U') IS NOT NULL drop table sub_section; +IF OBJECT_ID('sub_section_seq', 'SO') IS NOT NULL drop sequence sub_section_seq; + +IF OBJECT_ID('sub_type', 'U') IS NOT NULL drop table sub_type; +IF OBJECT_ID('sub_type_seq', 'SO') IS NOT NULL drop sequence sub_type_seq; + +IF OBJECT_ID('survey', 'U') IS NOT NULL drop table survey; +IF OBJECT_ID('survey_seq', 'SO') IS NOT NULL drop sequence survey_seq; + +IF OBJECT_ID('tbytes_only', 'U') IS NOT NULL drop table tbytes_only; +IF OBJECT_ID('tbytes_only_seq', 'SO') IS NOT NULL drop sequence tbytes_only_seq; + +IF OBJECT_ID('tcar', 'U') IS NOT NULL drop table tcar; + +IF OBJECT_ID('tevent', 'U') IS NOT NULL drop table tevent; +IF OBJECT_ID('tevent_seq', 'SO') IS NOT NULL drop sequence tevent_seq; + +IF OBJECT_ID('tevent_many', 'U') IS NOT NULL drop table tevent_many; +IF OBJECT_ID('tevent_many_seq', 'SO') IS NOT NULL drop sequence tevent_many_seq; + +IF OBJECT_ID('tevent_one', 'U') IS NOT NULL drop table tevent_one; +IF OBJECT_ID('tevent_one_seq', 'SO') IS NOT NULL drop sequence tevent_one_seq; + +IF OBJECT_ID('tint_root', 'U') IS NOT NULL drop table tint_root; +IF OBJECT_ID('tint_root_seq', 'SO') IS NOT NULL drop sequence tint_root_seq; + +IF OBJECT_ID('tjoda_entity', 'U') IS NOT NULL drop table tjoda_entity; +IF OBJECT_ID('tjoda_entity_seq', 'SO') IS NOT NULL drop sequence tjoda_entity_seq; + +IF OBJECT_ID('t_mapsuper1', 'U') IS NOT NULL drop table t_mapsuper1; +IF OBJECT_ID('t_mapsuper1_seq', 'SO') IS NOT NULL drop sequence t_mapsuper1_seq; + +IF OBJECT_ID('t_oneb', 'U') IS NOT NULL drop table t_oneb; +IF OBJECT_ID('t_oneb_seq', 'SO') IS NOT NULL drop sequence t_oneb_seq; + +IF OBJECT_ID('t_detail_with_other_namexxxyy', 'U') IS NOT NULL drop table t_detail_with_other_namexxxyy; +IF OBJECT_ID('t_detail_with_other_namexxxyy_seq', 'SO') IS NOT NULL drop sequence t_detail_with_other_namexxxyy_seq; + +IF OBJECT_ID('t_atable_thatisrelatively', 'U') IS NOT NULL drop table t_atable_thatisrelatively; +IF OBJECT_ID('t_atable_thatisrelatively_seq', 'SO') IS NOT NULL drop sequence t_atable_thatisrelatively_seq; + +IF OBJECT_ID('ttruck_holder', 'U') IS NOT NULL drop table ttruck_holder; +IF OBJECT_ID('ttruck_holder_seq', 'SO') IS NOT NULL drop sequence ttruck_holder_seq; + +IF OBJECT_ID('ttruck_holder_item', 'U') IS NOT NULL drop table ttruck_holder_item; +IF OBJECT_ID('ttruck_holder_item_seq', 'SO') IS NOT NULL drop sequence ttruck_holder_item_seq; + +IF OBJECT_ID('tuuid_entity', 'U') IS NOT NULL drop table tuuid_entity; + +IF OBJECT_ID('twheel', 'U') IS NOT NULL drop table twheel; +IF OBJECT_ID('twheel_seq', 'SO') IS NOT NULL drop sequence twheel_seq; + +IF OBJECT_ID('twith_pre_insert', 'U') IS NOT NULL drop table twith_pre_insert; +IF OBJECT_ID('twith_pre_insert_seq', 'SO') IS NOT NULL drop sequence twith_pre_insert_seq; + +IF OBJECT_ID('target_base', 'U') IS NOT NULL drop table target_base; + +IF OBJECT_ID('mt_tenant', 'U') IS NOT NULL drop table mt_tenant; + +IF OBJECT_ID('test_annotation_base_entity', 'U') IS NOT NULL drop table test_annotation_base_entity; + +IF OBJECT_ID('tire', 'U') IS NOT NULL drop table tire; +IF OBJECT_ID('tire_seq', 'SO') IS NOT NULL drop sequence tire_seq; + +IF OBJECT_ID('sa_tire', 'U') IS NOT NULL drop table sa_tire; +IF OBJECT_ID('sa_tire_seq', 'SO') IS NOT NULL drop sequence sa_tire_seq; + +IF OBJECT_ID('tree_entity', 'U') IS NOT NULL drop table tree_entity; +IF OBJECT_ID('tree_entity_seq', 'SO') IS NOT NULL drop sequence tree_entity_seq; + +IF OBJECT_ID('trip', 'U') IS NOT NULL drop table trip; +IF OBJECT_ID('trip_seq', 'SO') IS NOT NULL drop sequence trip_seq; + +IF OBJECT_ID('truck_ref', 'U') IS NOT NULL drop table truck_ref; +IF OBJECT_ID('truck_ref_seq', 'SO') IS NOT NULL drop sequence truck_ref_seq; + +IF OBJECT_ID('tune', 'U') IS NOT NULL drop table tune; +IF OBJECT_ID('tune_seq', 'SO') IS NOT NULL drop sequence tune_seq; + +IF OBJECT_ID('[type]', 'U') IS NOT NULL drop table [type]; + +IF OBJECT_ID('tz_bean', 'U') IS NOT NULL drop table tz_bean; +IF OBJECT_ID('tz_bean_seq', 'SO') IS NOT NULL drop sequence tz_bean_seq; + +IF OBJECT_ID('usib_child', 'U') IS NOT NULL drop table usib_child; + +IF OBJECT_ID('usib_child_sibling', 'U') IS NOT NULL drop table usib_child_sibling; +IF OBJECT_ID('usib_child_sibling_seq', 'SO') IS NOT NULL drop sequence usib_child_sibling_seq; + +IF OBJECT_ID('usib_parent', 'U') IS NOT NULL drop table usib_parent; +IF OBJECT_ID('usib_parent_seq', 'SO') IS NOT NULL drop sequence usib_parent_seq; + +IF OBJECT_ID('ut_detail', 'U') IS NOT NULL drop table ut_detail; +IF OBJECT_ID('ut_detail_seq', 'SO') IS NOT NULL drop sequence ut_detail_seq; + +IF OBJECT_ID('ut_master', 'U') IS NOT NULL drop table ut_master; +IF OBJECT_ID('ut_master_seq', 'SO') IS NOT NULL drop sequence ut_master_seq; + +IF OBJECT_ID('uuone', 'U') IS NOT NULL drop table uuone; + +IF OBJECT_ID('uutwo', 'U') IS NOT NULL drop table uutwo; + +IF OBJECT_ID('oto_user', 'U') IS NOT NULL drop table oto_user; +IF OBJECT_ID('oto_user_seq', 'SO') IS NOT NULL drop sequence oto_user_seq; + +IF OBJECT_ID('c_user', 'U') IS NOT NULL alter table c_user set (system_versioning = off); +IF OBJECT_ID('c_user_history', 'U') IS NOT NULL drop table c_user_history; +IF OBJECT_ID('c_user', 'U') IS NOT NULL drop table c_user; +IF OBJECT_ID('c_user_seq', 'SO') IS NOT NULL drop sequence c_user_seq; + +IF OBJECT_ID('tx_user', 'U') IS NOT NULL drop table tx_user; +IF OBJECT_ID('tx_user_seq', 'SO') IS NOT NULL drop sequence tx_user_seq; + +IF OBJECT_ID('g_user', 'U') IS NOT NULL drop table g_user; +IF OBJECT_ID('g_user_seq', 'SO') IS NOT NULL drop sequence g_user_seq; + +IF OBJECT_ID('em_user', 'U') IS NOT NULL drop table em_user; +IF OBJECT_ID('em_user_seq', 'SO') IS NOT NULL drop sequence em_user_seq; + +IF OBJECT_ID('user_interest_live', 'U') IS NOT NULL drop table user_interest_live; + +IF OBJECT_ID('em_user_role', 'U') IS NOT NULL drop table em_user_role; + +IF OBJECT_ID('vehicle', 'U') IS NOT NULL drop table vehicle; +IF OBJECT_ID('vehicle_seq', 'SO') IS NOT NULL drop sequence vehicle_seq; + +IF OBJECT_ID('vehicle_driver', 'U') IS NOT NULL drop table vehicle_driver; +IF OBJECT_ID('vehicle_driver_seq', 'SO') IS NOT NULL drop sequence vehicle_driver_seq; + +IF OBJECT_ID('vehicle_lease', 'U') IS NOT NULL drop table vehicle_lease; +IF OBJECT_ID('vehicle_lease_seq', 'SO') IS NOT NULL drop sequence vehicle_lease_seq; + +IF OBJECT_ID('warehouses', 'U') IS NOT NULL drop table warehouses; +IF OBJECT_ID('warehouses_seq', 'SO') IS NOT NULL drop sequence warehouses_seq; + +IF OBJECT_ID('warehousesshippingzones', 'U') IS NOT NULL drop table warehousesshippingzones; + +IF OBJECT_ID('wheel', 'U') IS NOT NULL drop table wheel; +IF OBJECT_ID('wheel_seq', 'SO') IS NOT NULL drop sequence wheel_seq; + +IF OBJECT_ID('sa_wheel', 'U') IS NOT NULL drop table sa_wheel; +IF OBJECT_ID('sa_wheel_seq', 'SO') IS NOT NULL drop sequence sa_wheel_seq; + +IF OBJECT_ID('sp_car_wheel', 'U') IS NOT NULL drop table sp_car_wheel; +IF OBJECT_ID('sp_car_wheel_seq', 'SO') IS NOT NULL drop sequence sp_car_wheel_seq; + +IF OBJECT_ID('g_who_props_otm', 'U') IS NOT NULL drop table g_who_props_otm; +IF OBJECT_ID('g_who_props_otm_seq', 'SO') IS NOT NULL drop sequence g_who_props_otm_seq; + +IF OBJECT_ID('with_zero', 'U') IS NOT NULL drop table with_zero; +IF OBJECT_ID('with_zero_seq', 'SO') IS NOT NULL drop sequence with_zero_seq; + +IF OBJECT_ID('parent', 'U') IS NOT NULL drop table parent; +IF OBJECT_ID('parent_seq', 'SO') IS NOT NULL drop sequence parent_seq; + +IF OBJECT_ID('wview', 'U') IS NOT NULL drop table wview; + +IF OBJECT_ID('zones', 'U') IS NOT NULL drop table zones; +IF OBJECT_ID('zones_seq', 'SO') IS NOT NULL drop sequence zones_seq; + +IF EXISTS (SELECT name FROM sys.indexes WHERE object_id = OBJECT_ID('contact','U') AND name = 'ix_contact_last_name_first_name') drop index ix_contact_last_name_first_name ON contact; +IF EXISTS (SELECT name FROM sys.indexes WHERE object_id = OBJECT_ID('e_basic','U') AND name = 'ix_e_basic_name') drop index ix_e_basic_name ON e_basic; +IF EXISTS (SELECT name FROM sys.indexes WHERE object_id = OBJECT_ID('efile2_no_fk','U') AND name = 'ix_efile2_no_fk_owner_id') drop index ix_efile2_no_fk_owner_id ON efile2_no_fk; +IF EXISTS (SELECT name FROM sys.indexes WHERE object_id = OBJECT_ID('ecsm_values','U') AND name = 'ix_ecsm_values_host_id') drop index ix_ecsm_values_host_id ON ecsm_values; +IF EXISTS (SELECT name FROM sys.indexes WHERE object_id = OBJECT_ID('organization_node','U') AND name = 'ix_organization_node_kind') drop index ix_organization_node_kind ON organization_node; From 9a5d3498c16257833429e36cc5ddbb50bf2451a7 Mon Sep 17 00:00:00 2001 From: rob bygrave Date: Mon, 7 Dec 2020 23:00:02 +1300 Subject: [PATCH 021/447] #2125 - Bump ebean-test-docker dependency to 4.1 --- ebean-bom/pom.xml | 2 +- ebean-core/pom.xml | 2 +- ebean-test/pom.xml | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/ebean-bom/pom.xml b/ebean-bom/pom.xml index aea366e64..d58b37593 100644 --- a/ebean-bom/pom.xml +++ b/ebean-bom/pom.xml @@ -16,7 +16,7 @@ 1.0 1.0 12.2.0 - 4.0 + 4.1 7.0 12.6.0 12.6.0 diff --git a/ebean-core/pom.xml b/ebean-core/pom.xml index 4532869d3..1ea2b8632 100644 --- a/ebean-core/pom.xml +++ b/ebean-core/pom.xml @@ -202,7 +202,7 @@ io.ebean ebean-test-docker - 4.0 + 4.1 test diff --git a/ebean-test/pom.xml b/ebean-test/pom.xml index 657655d08..f46ee194d 100644 --- a/ebean-test/pom.xml +++ b/ebean-test/pom.xml @@ -63,7 +63,7 @@ io.ebean ebean-test-docker - 4.0 + 4.1 From a73e4f23ff1c88f8118e094c84639e85b25a2429 Mon Sep 17 00:00:00 2001 From: rob bygrave Date: Tue, 8 Dec 2020 15:41:59 +1300 Subject: [PATCH 022/447] Bump agent version in BOM --- ebean-bom/pom.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ebean-bom/pom.xml b/ebean-bom/pom.xml index d58b37593..23c2faa7d 100644 --- a/ebean-bom/pom.xml +++ b/ebean-bom/pom.xml @@ -18,8 +18,8 @@ 12.2.0 4.1 7.0 - 12.6.0 - 12.6.0 + 12.6.2 + 12.6.2 From f1b1cee2fd1d7972b3385433a50c596e807e05af Mon Sep 17 00:00:00 2001 From: rob bygrave Date: Tue, 8 Dec 2020 15:43:31 +1300 Subject: [PATCH 023/447] Bump enhancement tile --- ebean-autotune/pom.xml | 2 +- ebean-externalmapping-xml/pom.xml | 2 +- ebean-postgis/pom.xml | 2 +- ebean-querybean/pom.xml | 2 +- ebean-test/pom.xml | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/ebean-autotune/pom.xml b/ebean-autotune/pom.xml index 6ffe3cbce..aba209457 100644 --- a/ebean-autotune/pom.xml +++ b/ebean-autotune/pom.xml @@ -64,7 +64,7 @@ - io.ebean.tile:enhancement:12.5.0 + io.ebean.tile:enhancement:12.6.0 diff --git a/ebean-externalmapping-xml/pom.xml b/ebean-externalmapping-xml/pom.xml index c8a91d433..6976ddd4e 100644 --- a/ebean-externalmapping-xml/pom.xml +++ b/ebean-externalmapping-xml/pom.xml @@ -89,7 +89,7 @@ - io.ebean.tile:enhancement:12.5.0 + io.ebean.tile:enhancement:12.6.0 diff --git a/ebean-postgis/pom.xml b/ebean-postgis/pom.xml index 0ff0ced76..ddcc32484 100644 --- a/ebean-postgis/pom.xml +++ b/ebean-postgis/pom.xml @@ -106,7 +106,7 @@ true - io.ebean.tile:enhancement:12.5.0 + io.ebean.tile:enhancement:12.6.0 diff --git a/ebean-querybean/pom.xml b/ebean-querybean/pom.xml index c2a64271b..7ca147cd6 100644 --- a/ebean-querybean/pom.xml +++ b/ebean-querybean/pom.xml @@ -105,7 +105,7 @@ true - io.ebean.tile:enhancement:12.5.0 + io.ebean.tile:enhancement:12.6.0 diff --git a/ebean-test/pom.xml b/ebean-test/pom.xml index f46ee194d..9a90b6b9b 100644 --- a/ebean-test/pom.xml +++ b/ebean-test/pom.xml @@ -150,7 +150,7 @@ true - io.ebean.tile:enhancement:12.5.0 + io.ebean.tile:enhancement:12.6.0 From 373ef6d1eb3cd66b33ff45c0ef2accdd11070e0d Mon Sep 17 00:00:00 2001 From: rob bygrave Date: Tue, 8 Dec 2020 20:29:34 +1300 Subject: [PATCH 024/447] #2126 - Bump ebean-migration to 12.4.0 --- ebean-bom/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ebean-bom/pom.xml b/ebean-bom/pom.xml index 23c2faa7d..442b71980 100644 --- a/ebean-bom/pom.xml +++ b/ebean-bom/pom.xml @@ -15,7 +15,7 @@ 1.0 1.0 - 12.2.0 + 12.4.0 4.1 7.0 12.6.2 From 610f7db1cbfa42fd573488abeaade3034df2c109 Mon Sep 17 00:00:00 2001 From: rob bygrave Date: Tue, 8 Dec 2020 20:46:36 +1300 Subject: [PATCH 025/447] Bump test dependency kotlin version to 1.4.21 after issues downloading 1.4.10 from maven central? --- kotlin-querybean-generator/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kotlin-querybean-generator/pom.xml b/kotlin-querybean-generator/pom.xml index a5c53e5fa..f3e6b89bd 100644 --- a/kotlin-querybean-generator/pom.xml +++ b/kotlin-querybean-generator/pom.xml @@ -12,7 +12,7 @@ kotlin-querybean-generator - 1.4.10 + 1.4.21 From 01a3455ecb8c41e9056215ee6f34ff66a0cd4c20 Mon Sep 17 00:00:00 2001 From: rob bygrave Date: Tue, 8 Dec 2020 20:51:52 +1300 Subject: [PATCH 026/447] Bump test dependency for kotlin-querybean-generator release --- kotlin-querybean-generator/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kotlin-querybean-generator/pom.xml b/kotlin-querybean-generator/pom.xml index f3e6b89bd..4517e409c 100644 --- a/kotlin-querybean-generator/pom.xml +++ b/kotlin-querybean-generator/pom.xml @@ -106,7 +106,7 @@ io.ebean kotlin-querybean-generator - 12.6.2-SNAPSHOT + 12.6.1 From 0cd0741f1810aa7e4e540d4d021e58bb8954c083 Mon Sep 17 00:00:00 2001 From: rob bygrave Date: Wed, 9 Dec 2020 13:11:07 +1300 Subject: [PATCH 027/447] [maven-release-plugin] prepare release ebean-parent-12.6.2 --- ebean-api/pom.xml | 2 +- ebean-autotune/pom.xml | 6 +++--- ebean-bom/pom.xml | 24 ++++++++++++------------ ebean-core-type/pom.xml | 4 ++-- ebean-core/pom.xml | 10 +++++----- ebean-ddl-generator/pom.xml | 6 +++--- ebean-externalmapping-api/pom.xml | 2 +- ebean-externalmapping-xml/pom.xml | 10 +++++----- ebean-postgis/pom.xml | 6 +++--- ebean-querybean/pom.xml | 10 +++++----- ebean-test/pom.xml | 8 ++++---- ebean/pom.xml | 12 ++++++------ kotlin-querybean-generator/pom.xml | 8 ++++---- pom.xml | 4 ++-- querybean-generator/pom.xml | 2 +- 15 files changed, 57 insertions(+), 57 deletions(-) diff --git a/ebean-api/pom.xml b/ebean-api/pom.xml index 945d263f0..9227fc4fb 100644 --- a/ebean-api/pom.xml +++ b/ebean-api/pom.xml @@ -4,7 +4,7 @@ ebean-parent io.ebean - 12.6.2-SNAPSHOT + 12.6.2 ebean api diff --git a/ebean-autotune/pom.xml b/ebean-autotune/pom.xml index aba209457..aeba0bb8f 100644 --- a/ebean-autotune/pom.xml +++ b/ebean-autotune/pom.xml @@ -4,7 +4,7 @@ ebean-parent io.ebean - 12.6.2-SNAPSHOT + 12.6.2 @@ -14,7 +14,7 @@ scm:git:git@github.com:ebean-orm/ebean.git - HEAD + ebean-parent-12.6.2 ebean autotune @@ -26,7 +26,7 @@ io.ebean ebean-core - 12.6.2-SNAPSHOT + 12.6.2 provided diff --git a/ebean-bom/pom.xml b/ebean-bom/pom.xml index 442b71980..68449d0b9 100644 --- a/ebean-bom/pom.xml +++ b/ebean-bom/pom.xml @@ -4,7 +4,7 @@ ebean-parent io.ebean - 12.6.2-SNAPSHOT + 12.6.2 ebean bom @@ -81,69 +81,69 @@ io.ebean ebean - 12.6.2-SNAPSHOT + 12.6.2 io.ebean ebean-api - 12.6.2-SNAPSHOT + 12.6.2 io.ebean ebean-core - 12.6.2-SNAPSHOT + 12.6.2 io.ebean ebean-ddl-generator - 12.6.2-SNAPSHOT + 12.6.2 io.ebean ebean-externalmapping-api - 12.6.2-SNAPSHOT + 12.6.2 io.ebean ebean-externalmapping-xml - 12.6.2-SNAPSHOT + 12.6.2 io.ebean ebean-autotune - 12.6.2-SNAPSHOT + 12.6.2 io.ebean ebean-querybean - 12.6.2-SNAPSHOT + 12.6.2 io.ebean querybean-generator - 12.6.2-SNAPSHOT + 12.6.2 provided io.ebean kotlin-querybean-generator - 12.6.2-SNAPSHOT + 12.6.2 provided io.ebean ebean-test - 12.6.2-SNAPSHOT + 12.6.2 test diff --git a/ebean-core-type/pom.xml b/ebean-core-type/pom.xml index 6bf92485e..38ba7efe1 100644 --- a/ebean-core-type/pom.xml +++ b/ebean-core-type/pom.xml @@ -4,7 +4,7 @@ ebean-parent io.ebean - 12.6.2-SNAPSHOT + 12.6.2 ebean-core-type @@ -19,7 +19,7 @@ io.ebean ebean-api - 12.6.2-SNAPSHOT + 12.6.2 diff --git a/ebean-core/pom.xml b/ebean-core/pom.xml index 1ea2b8632..e804be3ec 100644 --- a/ebean-core/pom.xml +++ b/ebean-core/pom.xml @@ -3,7 +3,7 @@ ebean-parent io.ebean - 12.6.2-SNAPSHOT + 12.6.2 ebean-core @@ -15,7 +15,7 @@ scm:git:git@github.com:ebean-orm/ebean.git - HEAD + ebean-parent-12.6.2 @@ -92,19 +92,19 @@ io.ebean ebean-api - 12.6.2-SNAPSHOT + 12.6.2 io.ebean ebean-core-type - 12.6.2-SNAPSHOT + 12.6.2 io.ebean ebean-externalmapping-api - 12.6.2-SNAPSHOT + 12.6.2 diff --git a/ebean-ddl-generator/pom.xml b/ebean-ddl-generator/pom.xml index 90203208d..5699ef4dc 100644 --- a/ebean-ddl-generator/pom.xml +++ b/ebean-ddl-generator/pom.xml @@ -4,7 +4,7 @@ ebean-parent io.ebean - 12.6.2-SNAPSHOT + 12.6.2 ebean ddl generation @@ -29,14 +29,14 @@ io.ebean ebean-core-type - 12.6.2-SNAPSHOT + 12.6.2 provided io.ebean ebean-core - 12.6.2-SNAPSHOT + 12.6.2 provided diff --git a/ebean-externalmapping-api/pom.xml b/ebean-externalmapping-api/pom.xml index 9b08e0dbb..29a16cbbb 100644 --- a/ebean-externalmapping-api/pom.xml +++ b/ebean-externalmapping-api/pom.xml @@ -4,7 +4,7 @@ ebean-parent io.ebean - 12.6.2-SNAPSHOT + 12.6.2 ebean external mapping api diff --git a/ebean-externalmapping-xml/pom.xml b/ebean-externalmapping-xml/pom.xml index 6976ddd4e..f7d243fcc 100644 --- a/ebean-externalmapping-xml/pom.xml +++ b/ebean-externalmapping-xml/pom.xml @@ -4,7 +4,7 @@ ebean-parent io.ebean - 12.6.2-SNAPSHOT + 12.6.2 @@ -14,7 +14,7 @@ scm:git:git@github.com:ebean-orm/ebean.git - HEAD + ebean-parent-12.6.2 ebean external mapping xml @@ -33,7 +33,7 @@ io.ebean ebean-externalmapping-api - 12.6.2-SNAPSHOT + 12.6.2 @@ -59,14 +59,14 @@ io.ebean ebean-core - 12.6.2-SNAPSHOT + 12.6.2 test io.ebean ebean-ddl-generator - 12.6.2-SNAPSHOT + 12.6.2 test diff --git a/ebean-postgis/pom.xml b/ebean-postgis/pom.xml index ddcc32484..ad690a41b 100644 --- a/ebean-postgis/pom.xml +++ b/ebean-postgis/pom.xml @@ -4,7 +4,7 @@ ebean-parent io.ebean - 12.6.2-SNAPSHOT + 12.6.2 ebean postgis @@ -24,7 +24,7 @@ io.ebean ebean-core - 12.6.2-SNAPSHOT + 12.6.2 provided @@ -75,7 +75,7 @@ io.ebean ebean-test - 12.6.2-SNAPSHOT + 12.6.2 test diff --git a/ebean-querybean/pom.xml b/ebean-querybean/pom.xml index 7ca147cd6..9575aac26 100644 --- a/ebean-querybean/pom.xml +++ b/ebean-querybean/pom.xml @@ -4,7 +4,7 @@ ebean-parent io.ebean - 12.6.2-SNAPSHOT + 12.6.2 @@ -14,7 +14,7 @@ scm:git:git@github.com:ebean-orm/ebean.git - HEAD + ebean-parent-12.6.2 ebean querybean @@ -27,7 +27,7 @@ io.ebean ebean-core - 12.6.2-SNAPSHOT + 12.6.2 provided @@ -67,14 +67,14 @@ io.ebean ebean-ddl-generator - 12.6.2-SNAPSHOT + 12.6.2 test io.ebean querybean-generator - 12.6.2-SNAPSHOT + 12.6.2 test diff --git a/ebean-test/pom.xml b/ebean-test/pom.xml index 9a90b6b9b..cd9625639 100644 --- a/ebean-test/pom.xml +++ b/ebean-test/pom.xml @@ -4,7 +4,7 @@ ebean-parent io.ebean - 12.6.2-SNAPSHOT + 12.6.2 @@ -14,7 +14,7 @@ scm:git:git@github.com:ebean-orm/ebean.git - HEAD + ebean-parent-12.6.2 ebean test @@ -43,14 +43,14 @@ io.ebean ebean-core - 12.6.2-SNAPSHOT + 12.6.2 provided io.ebean ebean-ddl-generator - 12.6.2-SNAPSHOT + 12.6.2 diff --git a/ebean/pom.xml b/ebean/pom.xml index 64872ae20..569f3bf6c 100644 --- a/ebean/pom.xml +++ b/ebean/pom.xml @@ -4,7 +4,7 @@ ebean-parent io.ebean - 12.6.2-SNAPSHOT + 12.6.2 ebean composite @@ -22,34 +22,34 @@ io.ebean ebean-api - 12.6.2-SNAPSHOT + 12.6.2 io.ebean ebean-core - 12.6.2-SNAPSHOT + 12.6.2 io.ebean ebean-querybean - 12.6.2-SNAPSHOT + 12.6.2 io.ebean ebean-ddl-generator - 12.6.2-SNAPSHOT + 12.6.2 io.ebean ebean-autotune - 12.6.2-SNAPSHOT + 12.6.2 diff --git a/kotlin-querybean-generator/pom.xml b/kotlin-querybean-generator/pom.xml index 4517e409c..5ab2d78c2 100644 --- a/kotlin-querybean-generator/pom.xml +++ b/kotlin-querybean-generator/pom.xml @@ -4,7 +4,7 @@ ebean-parent io.ebean - 12.6.2-SNAPSHOT + 12.6.2 kotlin querybean generator @@ -29,7 +29,7 @@ io.ebean ebean-querybean - 12.6.2-SNAPSHOT + 12.6.2 test @@ -43,7 +43,7 @@ io.ebean ebean-core - 12.6.2-SNAPSHOT + 12.6.2 test @@ -64,7 +64,7 @@ io.ebean ebean-ddl-generator - 12.6.2-SNAPSHOT + 12.6.2 test diff --git a/pom.xml b/pom.xml index 967d6eb53..b342cf59f 100644 --- a/pom.xml +++ b/pom.xml @@ -9,7 +9,7 @@ io.ebean ebean-parent - 12.6.2-SNAPSHOT + 12.6.2 pom ebean parent @@ -18,7 +18,7 @@ scm:git:git@github.com:ebean-orm/ebean.git - HEAD + ebean-parent-12.6.2 diff --git a/querybean-generator/pom.xml b/querybean-generator/pom.xml index 936bc9c89..e473fdc4f 100644 --- a/querybean-generator/pom.xml +++ b/querybean-generator/pom.xml @@ -4,7 +4,7 @@ ebean-parent io.ebean - 12.6.2-SNAPSHOT + 12.6.2 querybean generator From 948619a125d77a8b6b25c9239aca5888ffd02db8 Mon Sep 17 00:00:00 2001 From: rob bygrave Date: Wed, 9 Dec 2020 13:11:19 +1300 Subject: [PATCH 028/447] [maven-release-plugin] prepare for next development iteration --- ebean-api/pom.xml | 2 +- ebean-autotune/pom.xml | 6 +++--- ebean-bom/pom.xml | 24 ++++++++++++------------ ebean-core-type/pom.xml | 4 ++-- ebean-core/pom.xml | 10 +++++----- ebean-ddl-generator/pom.xml | 6 +++--- ebean-externalmapping-api/pom.xml | 2 +- ebean-externalmapping-xml/pom.xml | 10 +++++----- ebean-postgis/pom.xml | 6 +++--- ebean-querybean/pom.xml | 10 +++++----- ebean-test/pom.xml | 8 ++++---- ebean/pom.xml | 12 ++++++------ kotlin-querybean-generator/pom.xml | 8 ++++---- pom.xml | 4 ++-- querybean-generator/pom.xml | 2 +- 15 files changed, 57 insertions(+), 57 deletions(-) diff --git a/ebean-api/pom.xml b/ebean-api/pom.xml index 9227fc4fb..eedf3c59b 100644 --- a/ebean-api/pom.xml +++ b/ebean-api/pom.xml @@ -4,7 +4,7 @@ ebean-parent io.ebean - 12.6.2 + 12.6.3-SNAPSHOT ebean api diff --git a/ebean-autotune/pom.xml b/ebean-autotune/pom.xml index aeba0bb8f..8a91fcfcf 100644 --- a/ebean-autotune/pom.xml +++ b/ebean-autotune/pom.xml @@ -4,7 +4,7 @@ ebean-parent io.ebean - 12.6.2 + 12.6.3-SNAPSHOT @@ -14,7 +14,7 @@ scm:git:git@github.com:ebean-orm/ebean.git - ebean-parent-12.6.2 + HEAD ebean autotune @@ -26,7 +26,7 @@ io.ebean ebean-core - 12.6.2 + 12.6.3-SNAPSHOT provided diff --git a/ebean-bom/pom.xml b/ebean-bom/pom.xml index 68449d0b9..36cdaebbe 100644 --- a/ebean-bom/pom.xml +++ b/ebean-bom/pom.xml @@ -4,7 +4,7 @@ ebean-parent io.ebean - 12.6.2 + 12.6.3-SNAPSHOT ebean bom @@ -81,69 +81,69 @@ io.ebean ebean - 12.6.2 + 12.6.3-SNAPSHOT io.ebean ebean-api - 12.6.2 + 12.6.3-SNAPSHOT io.ebean ebean-core - 12.6.2 + 12.6.3-SNAPSHOT io.ebean ebean-ddl-generator - 12.6.2 + 12.6.3-SNAPSHOT io.ebean ebean-externalmapping-api - 12.6.2 + 12.6.3-SNAPSHOT io.ebean ebean-externalmapping-xml - 12.6.2 + 12.6.3-SNAPSHOT io.ebean ebean-autotune - 12.6.2 + 12.6.3-SNAPSHOT io.ebean ebean-querybean - 12.6.2 + 12.6.3-SNAPSHOT io.ebean querybean-generator - 12.6.2 + 12.6.3-SNAPSHOT provided io.ebean kotlin-querybean-generator - 12.6.2 + 12.6.3-SNAPSHOT provided io.ebean ebean-test - 12.6.2 + 12.6.3-SNAPSHOT test diff --git a/ebean-core-type/pom.xml b/ebean-core-type/pom.xml index 38ba7efe1..0a36cb1df 100644 --- a/ebean-core-type/pom.xml +++ b/ebean-core-type/pom.xml @@ -4,7 +4,7 @@ ebean-parent io.ebean - 12.6.2 + 12.6.3-SNAPSHOT ebean-core-type @@ -19,7 +19,7 @@ io.ebean ebean-api - 12.6.2 + 12.6.3-SNAPSHOT diff --git a/ebean-core/pom.xml b/ebean-core/pom.xml index e804be3ec..16dd68ca8 100644 --- a/ebean-core/pom.xml +++ b/ebean-core/pom.xml @@ -3,7 +3,7 @@ ebean-parent io.ebean - 12.6.2 + 12.6.3-SNAPSHOT ebean-core @@ -15,7 +15,7 @@ scm:git:git@github.com:ebean-orm/ebean.git - ebean-parent-12.6.2 + HEAD @@ -92,19 +92,19 @@ io.ebean ebean-api - 12.6.2 + 12.6.3-SNAPSHOT io.ebean ebean-core-type - 12.6.2 + 12.6.3-SNAPSHOT io.ebean ebean-externalmapping-api - 12.6.2 + 12.6.3-SNAPSHOT diff --git a/ebean-ddl-generator/pom.xml b/ebean-ddl-generator/pom.xml index 5699ef4dc..2fba2592a 100644 --- a/ebean-ddl-generator/pom.xml +++ b/ebean-ddl-generator/pom.xml @@ -4,7 +4,7 @@ ebean-parent io.ebean - 12.6.2 + 12.6.3-SNAPSHOT ebean ddl generation @@ -29,14 +29,14 @@ io.ebean ebean-core-type - 12.6.2 + 12.6.3-SNAPSHOT provided io.ebean ebean-core - 12.6.2 + 12.6.3-SNAPSHOT provided diff --git a/ebean-externalmapping-api/pom.xml b/ebean-externalmapping-api/pom.xml index 29a16cbbb..39af134ba 100644 --- a/ebean-externalmapping-api/pom.xml +++ b/ebean-externalmapping-api/pom.xml @@ -4,7 +4,7 @@ ebean-parent io.ebean - 12.6.2 + 12.6.3-SNAPSHOT ebean external mapping api diff --git a/ebean-externalmapping-xml/pom.xml b/ebean-externalmapping-xml/pom.xml index f7d243fcc..eae430ad9 100644 --- a/ebean-externalmapping-xml/pom.xml +++ b/ebean-externalmapping-xml/pom.xml @@ -4,7 +4,7 @@ ebean-parent io.ebean - 12.6.2 + 12.6.3-SNAPSHOT @@ -14,7 +14,7 @@ scm:git:git@github.com:ebean-orm/ebean.git - ebean-parent-12.6.2 + HEAD ebean external mapping xml @@ -33,7 +33,7 @@ io.ebean ebean-externalmapping-api - 12.6.2 + 12.6.3-SNAPSHOT @@ -59,14 +59,14 @@ io.ebean ebean-core - 12.6.2 + 12.6.3-SNAPSHOT test io.ebean ebean-ddl-generator - 12.6.2 + 12.6.3-SNAPSHOT test diff --git a/ebean-postgis/pom.xml b/ebean-postgis/pom.xml index ad690a41b..a9342c4ad 100644 --- a/ebean-postgis/pom.xml +++ b/ebean-postgis/pom.xml @@ -4,7 +4,7 @@ ebean-parent io.ebean - 12.6.2 + 12.6.3-SNAPSHOT ebean postgis @@ -24,7 +24,7 @@ io.ebean ebean-core - 12.6.2 + 12.6.3-SNAPSHOT provided @@ -75,7 +75,7 @@ io.ebean ebean-test - 12.6.2 + 12.6.3-SNAPSHOT test diff --git a/ebean-querybean/pom.xml b/ebean-querybean/pom.xml index 9575aac26..d674ab88b 100644 --- a/ebean-querybean/pom.xml +++ b/ebean-querybean/pom.xml @@ -4,7 +4,7 @@ ebean-parent io.ebean - 12.6.2 + 12.6.3-SNAPSHOT @@ -14,7 +14,7 @@ scm:git:git@github.com:ebean-orm/ebean.git - ebean-parent-12.6.2 + HEAD ebean querybean @@ -27,7 +27,7 @@ io.ebean ebean-core - 12.6.2 + 12.6.3-SNAPSHOT provided @@ -67,14 +67,14 @@ io.ebean ebean-ddl-generator - 12.6.2 + 12.6.3-SNAPSHOT test io.ebean querybean-generator - 12.6.2 + 12.6.3-SNAPSHOT test diff --git a/ebean-test/pom.xml b/ebean-test/pom.xml index cd9625639..6fa3751dc 100644 --- a/ebean-test/pom.xml +++ b/ebean-test/pom.xml @@ -4,7 +4,7 @@ ebean-parent io.ebean - 12.6.2 + 12.6.3-SNAPSHOT @@ -14,7 +14,7 @@ scm:git:git@github.com:ebean-orm/ebean.git - ebean-parent-12.6.2 + HEAD ebean test @@ -43,14 +43,14 @@ io.ebean ebean-core - 12.6.2 + 12.6.3-SNAPSHOT provided io.ebean ebean-ddl-generator - 12.6.2 + 12.6.3-SNAPSHOT diff --git a/ebean/pom.xml b/ebean/pom.xml index 569f3bf6c..d1a1785ac 100644 --- a/ebean/pom.xml +++ b/ebean/pom.xml @@ -4,7 +4,7 @@ ebean-parent io.ebean - 12.6.2 + 12.6.3-SNAPSHOT ebean composite @@ -22,34 +22,34 @@ io.ebean ebean-api - 12.6.2 + 12.6.3-SNAPSHOT io.ebean ebean-core - 12.6.2 + 12.6.3-SNAPSHOT io.ebean ebean-querybean - 12.6.2 + 12.6.3-SNAPSHOT io.ebean ebean-ddl-generator - 12.6.2 + 12.6.3-SNAPSHOT io.ebean ebean-autotune - 12.6.2 + 12.6.3-SNAPSHOT diff --git a/kotlin-querybean-generator/pom.xml b/kotlin-querybean-generator/pom.xml index 5ab2d78c2..d9318b392 100644 --- a/kotlin-querybean-generator/pom.xml +++ b/kotlin-querybean-generator/pom.xml @@ -4,7 +4,7 @@ ebean-parent io.ebean - 12.6.2 + 12.6.3-SNAPSHOT kotlin querybean generator @@ -29,7 +29,7 @@ io.ebean ebean-querybean - 12.6.2 + 12.6.3-SNAPSHOT test @@ -43,7 +43,7 @@ io.ebean ebean-core - 12.6.2 + 12.6.3-SNAPSHOT test @@ -64,7 +64,7 @@ io.ebean ebean-ddl-generator - 12.6.2 + 12.6.3-SNAPSHOT test diff --git a/pom.xml b/pom.xml index b342cf59f..8fe431a0c 100644 --- a/pom.xml +++ b/pom.xml @@ -9,7 +9,7 @@ io.ebean ebean-parent - 12.6.2 + 12.6.3-SNAPSHOT pom ebean parent @@ -18,7 +18,7 @@ scm:git:git@github.com:ebean-orm/ebean.git - ebean-parent-12.6.2 + HEAD diff --git a/querybean-generator/pom.xml b/querybean-generator/pom.xml index e473fdc4f..f7a288d4a 100644 --- a/querybean-generator/pom.xml +++ b/querybean-generator/pom.xml @@ -4,7 +4,7 @@ ebean-parent io.ebean - 12.6.2 + 12.6.3-SNAPSHOT querybean generator From 48eac849302287d29011b9ee01dba9d641e9a85a Mon Sep 17 00:00:00 2001 From: rob bygrave Date: Mon, 14 Dec 2020 09:31:08 +1300 Subject: [PATCH 029/447] #2128 - Bump avaje-config dependency to 1.3 - Fix for - Repeated calls to Config.get() with no value, expect to return passed default value --- ebean-api/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ebean-api/pom.xml b/ebean-api/pom.xml index eedf3c59b..835ad6fd0 100644 --- a/ebean-api/pom.xml +++ b/ebean-api/pom.xml @@ -32,7 +32,7 @@ io.avaje avaje-config - 1.2 + 1.3 + + + + + + + + + + + + + + diff --git a/pom.xml b/pom.xml index 8fe431a0c..6350ca0af 100644 --- a/pom.xml +++ b/pom.xml @@ -82,6 +82,7 @@ kotlin-querybean-generator ebean-querybean ebean-postgis + ebean-redis From 3e7db2887fd17af7a5939ba46a119cf526cfa003 Mon Sep 17 00:00:00 2001 From: rob bygrave Date: Thu, 17 Dec 2020 14:38:54 +1300 Subject: [PATCH 033/447] Add ebean-redis as module --- ebean-redis/pom.xml | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/ebean-redis/pom.xml b/ebean-redis/pom.xml index 7c6578935..aa9174ea3 100644 --- a/ebean-redis/pom.xml +++ b/ebean-redis/pom.xml @@ -10,9 +10,8 @@ ebean-redis - ebean test - Testing support for Ebean - + ebean redis + Ebean Redis L2 Cache From e9081a176fb942e156a2b5dcf0f69e724944c270 Mon Sep 17 00:00:00 2001 From: rob bygrave Date: Fri, 18 Dec 2020 14:14:43 +1300 Subject: [PATCH 034/447] #2133 - Spring transactions not getting ChangeLog changeSet as part of postCommit() processing --- .../io/ebeaninternal/api/SpiTransaction.java | 11 +++++++++++ .../ebeaninternal/api/SpiTransactionProxy.java | 9 +++++++++ .../transaction/ImplicitReadOnlyTransaction.java | 10 ++++++++++ .../server/transaction/JdbcTransaction.java | 14 ++++++++++++-- .../server/transaction/JtaTransaction.java | 16 +++++++--------- .../transaction/JtaTransactionManager.java | 8 +++----- .../server/transaction/NoTransaction.java | 10 ++++++++++ 7 files changed, 62 insertions(+), 16 deletions(-) diff --git a/ebean-core/src/main/java/io/ebeaninternal/api/SpiTransaction.java b/ebean-core/src/main/java/io/ebeaninternal/api/SpiTransaction.java index 5e75831b5..0832a00b2 100644 --- a/ebean-core/src/main/java/io/ebeaninternal/api/SpiTransaction.java +++ b/ebean-core/src/main/java/io/ebeaninternal/api/SpiTransaction.java @@ -318,4 +318,15 @@ public interface SpiTransaction extends Transaction { * Return true if explicitly set to skip cache (ignores skipOnWrite). */ boolean isSkipCacheExplicit(); + + /** + * Fire post commit events and listeners. + */ + void postCommit(); + + /** + * Fire post rollback events and listeners. + */ + void postRollback(Throwable cause); + } diff --git a/ebean-core/src/main/java/io/ebeaninternal/api/SpiTransactionProxy.java b/ebean-core/src/main/java/io/ebeaninternal/api/SpiTransactionProxy.java index 897a32f44..d87b5c744 100644 --- a/ebean-core/src/main/java/io/ebeaninternal/api/SpiTransactionProxy.java +++ b/ebean-core/src/main/java/io/ebeaninternal/api/SpiTransactionProxy.java @@ -418,4 +418,13 @@ public abstract class SpiTransactionProxy implements SpiTransaction { transaction.flushBatchOnCollection(); } + @Override + public void postCommit() { + transaction.postCommit(); + } + + @Override + public void postRollback(Throwable cause) { + transaction.postRollback(cause); + } } diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/transaction/ImplicitReadOnlyTransaction.java b/ebean-core/src/main/java/io/ebeaninternal/server/transaction/ImplicitReadOnlyTransaction.java index 53d266964..b890b3b50 100644 --- a/ebean-core/src/main/java/io/ebeaninternal/server/transaction/ImplicitReadOnlyTransaction.java +++ b/ebean-core/src/main/java/io/ebeaninternal/server/transaction/ImplicitReadOnlyTransaction.java @@ -586,6 +586,16 @@ class ImplicitReadOnlyTransaction implements SpiTransaction, TxnProfileEventCode } } + @Override + public void postCommit() { + // do nothing + } + + @Override + public void postRollback(Throwable cause) { + // do nothing + } + /** * Return true if the transaction is active. */ diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/transaction/JdbcTransaction.java b/ebean-core/src/main/java/io/ebeaninternal/server/transaction/JdbcTransaction.java index 5f810dc17..1dbcfca67 100644 --- a/ebean-core/src/main/java/io/ebeaninternal/server/transaction/JdbcTransaction.java +++ b/ebean-core/src/main/java/io/ebeaninternal/server/transaction/JdbcTransaction.java @@ -985,6 +985,11 @@ class JdbcTransaction implements SpiTransaction, TxnProfileEventCodes { firePreCommit(); // only performCommit can throw an exception performCommit(); + postCommit(); + } + + @Override + public void postCommit() { firePostCommit(); notifyCommit(); } @@ -1132,11 +1137,16 @@ class JdbcTransaction implements SpiTransaction, TxnProfileEventCodes { } finally { // these will not throw an exception - firePostRollback(); - notifyRollback(cause); + postRollback(cause); } } + @Override + public void postRollback(Throwable cause) { + firePostRollback(); + notifyRollback(cause); + } + /** * If the transaction is active then perform rollback. */ diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/transaction/JtaTransaction.java b/ebean-core/src/main/java/io/ebeaninternal/server/transaction/JtaTransaction.java index 811d9d1d6..e0c33a193 100644 --- a/ebean-core/src/main/java/io/ebeaninternal/server/transaction/JtaTransaction.java +++ b/ebean-core/src/main/java/io/ebeaninternal/server/transaction/JtaTransaction.java @@ -13,9 +13,9 @@ public class JtaTransaction extends JdbcTransaction { private final UserTransaction userTransaction; - private boolean commmitted; + private final boolean newTransaction; - private boolean newTransaction; + private boolean committed; /** * Create the JtaTransaction. @@ -41,7 +41,6 @@ public class JtaTransaction extends JdbcTransaction { if (connection.getAutoCommit()) { connection.setAutoCommit(false); } - } catch (SQLException e) { throw new PersistenceException(e); } @@ -52,7 +51,7 @@ public class JtaTransaction extends JdbcTransaction { */ @Override public void commit() { - if (commmitted) { + if (committed) { throw new PersistenceException("This transaction has already been committed."); } try { @@ -60,14 +59,14 @@ public class JtaTransaction extends JdbcTransaction { if (newTransaction) { userTransaction.commit(); } - notifyCommit(); + postCommit(); } finally { close(); } } catch (Exception e) { throw new PersistenceException(e); } - commmitted = true; + committed = true; } @Override @@ -80,7 +79,7 @@ public class JtaTransaction extends JdbcTransaction { */ @Override public void rollback(Throwable e) { - if (!commmitted) { + if (!committed) { try { try { if (userTransaction != null) { @@ -90,7 +89,7 @@ public class JtaTransaction extends JdbcTransaction { userTransaction.setRollbackOnly(); } } - notifyRollback(e); + postRollback(e); } finally { closeConnection(); } @@ -98,7 +97,6 @@ public class JtaTransaction extends JdbcTransaction { throw new PersistenceException(ex); } } - } /** diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/transaction/JtaTransactionManager.java b/ebean-core/src/main/java/io/ebeaninternal/server/transaction/JtaTransactionManager.java index 3fbed7d84..6362926e8 100644 --- a/ebean-core/src/main/java/io/ebeaninternal/server/transaction/JtaTransactionManager.java +++ b/ebean-core/src/main/java/io/ebeaninternal/server/transaction/JtaTransactionManager.java @@ -190,19 +190,17 @@ public class JtaTransactionManager implements ExternalTransactionManager { @Override public void beforeCompletion() { - // Future note: for JPA2 locking we will - // have beforeCommit events to fire + transaction.flush(); } @Override public void afterCompletion(int status) { - switch (status) { case Status.STATUS_COMMITTED: if (logger.isDebugEnabled()) { logger.debug("Jta Txn [" + transaction.getId() + "] committed"); } - transactionManager.notifyOfCommit(transaction); + transaction.postCommit(); // Remove this transaction object as it is completed transactionManager.scope().clearExternal(); break; @@ -211,7 +209,7 @@ public class JtaTransactionManager implements ExternalTransactionManager { if (logger.isDebugEnabled()) { logger.debug("Jta Txn [" + transaction.getId() + "] rollback"); } - transactionManager.notifyOfRollback(transaction, null); + transaction.postRollback(null); // Remove this transaction object as it is completed transactionManager.scope().clearExternal(); break; diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/transaction/NoTransaction.java b/ebean-core/src/main/java/io/ebeaninternal/server/transaction/NoTransaction.java index 48476c14a..901b0faf0 100644 --- a/ebean-core/src/main/java/io/ebeaninternal/server/transaction/NoTransaction.java +++ b/ebean-core/src/main/java/io/ebeaninternal/server/transaction/NoTransaction.java @@ -88,6 +88,16 @@ class NoTransaction implements SpiTransaction { // do nothing } + @Override + public void postCommit() { + // do nothing + } + + @Override + public void postRollback(Throwable cause) { + // do nothing + } + @Override public String getLogPrefix() { return null; From 1bdc6d8f7f93c39610cef9d47e93f720d5a0a95a Mon Sep 17 00:00:00 2001 From: rob bygrave Date: Fri, 18 Dec 2020 14:54:44 +1300 Subject: [PATCH 035/447] #2134 - Modify ChangeLog to send the last set of changes Pre Commit (rather than post commit). Expose this for spring transactions. --- .../io/ebeaninternal/api/SpiTransaction.java | 5 +++ .../api/SpiTransactionProxy.java | 5 +++ .../ImplicitReadOnlyTransaction.java | 5 +++ .../server/transaction/JdbcTransaction.java | 13 +++++-- .../transaction/JtaTransactionManager.java | 2 +- .../server/transaction/NoTransaction.java | 5 +++ .../server/transaction/TChangeLogHolder.java | 21 +++++++--- .../org/tests/changelog/TestChangeLog.java | 38 ++++++++++++------- 8 files changed, 71 insertions(+), 23 deletions(-) diff --git a/ebean-core/src/main/java/io/ebeaninternal/api/SpiTransaction.java b/ebean-core/src/main/java/io/ebeaninternal/api/SpiTransaction.java index 0832a00b2..74faeccb0 100644 --- a/ebean-core/src/main/java/io/ebeaninternal/api/SpiTransaction.java +++ b/ebean-core/src/main/java/io/ebeaninternal/api/SpiTransaction.java @@ -319,6 +319,11 @@ public interface SpiTransaction extends Transaction { */ boolean isSkipCacheExplicit(); + /** + * Fire pre commit processing/listeners. + */ + void preCommit(); + /** * Fire post commit events and listeners. */ diff --git a/ebean-core/src/main/java/io/ebeaninternal/api/SpiTransactionProxy.java b/ebean-core/src/main/java/io/ebeaninternal/api/SpiTransactionProxy.java index d87b5c744..fe5351ddc 100644 --- a/ebean-core/src/main/java/io/ebeaninternal/api/SpiTransactionProxy.java +++ b/ebean-core/src/main/java/io/ebeaninternal/api/SpiTransactionProxy.java @@ -418,6 +418,11 @@ public abstract class SpiTransactionProxy implements SpiTransaction { transaction.flushBatchOnCollection(); } + @Override + public void preCommit() { + transaction.preCommit(); + } + @Override public void postCommit() { transaction.postCommit(); diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/transaction/ImplicitReadOnlyTransaction.java b/ebean-core/src/main/java/io/ebeaninternal/server/transaction/ImplicitReadOnlyTransaction.java index b890b3b50..79bf85335 100644 --- a/ebean-core/src/main/java/io/ebeaninternal/server/transaction/ImplicitReadOnlyTransaction.java +++ b/ebean-core/src/main/java/io/ebeaninternal/server/transaction/ImplicitReadOnlyTransaction.java @@ -586,6 +586,11 @@ class ImplicitReadOnlyTransaction implements SpiTransaction, TxnProfileEventCode } } + @Override + public void preCommit() { + // do nothing + } + @Override public void postCommit() { // do nothing diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/transaction/JdbcTransaction.java b/ebean-core/src/main/java/io/ebeaninternal/server/transaction/JdbcTransaction.java index 1dbcfca67..8c1897ff5 100644 --- a/ebean-core/src/main/java/io/ebeaninternal/server/transaction/JdbcTransaction.java +++ b/ebean-core/src/main/java/io/ebeaninternal/server/transaction/JdbcTransaction.java @@ -373,6 +373,9 @@ class JdbcTransaction implements SpiTransaction, TxnProfileEventCodes { private void firePreCommit() { withEachCallback(TransactionCallback::preCommit); + if (changeLogHolder != null) { + changeLogHolder.preCommit(); + } } private void firePostCommit() { @@ -981,9 +984,7 @@ class JdbcTransaction implements SpiTransaction, TxnProfileEventCodes { * Batch flush, jdbc commit, trigger registered TransactionCallbacks, notify l2 cache etc. */ private void flushCommitAndNotify() throws SQLException { - internalBatchFlush(); - firePreCommit(); - // only performCommit can throw an exception + preCommit(); performCommit(); postCommit(); } @@ -994,6 +995,12 @@ class JdbcTransaction implements SpiTransaction, TxnProfileEventCodes { notifyCommit(); } + @Override + public void preCommit() { + internalBatchFlush(); + firePreCommit(); + } + /** * Perform a commit, fire callbacks and notify l2 cache etc. *

diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/transaction/JtaTransactionManager.java b/ebean-core/src/main/java/io/ebeaninternal/server/transaction/JtaTransactionManager.java index 6362926e8..cc9e8cdc8 100644 --- a/ebean-core/src/main/java/io/ebeaninternal/server/transaction/JtaTransactionManager.java +++ b/ebean-core/src/main/java/io/ebeaninternal/server/transaction/JtaTransactionManager.java @@ -190,7 +190,7 @@ public class JtaTransactionManager implements ExternalTransactionManager { @Override public void beforeCompletion() { - transaction.flush(); + transaction.preCommit(); } @Override diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/transaction/NoTransaction.java b/ebean-core/src/main/java/io/ebeaninternal/server/transaction/NoTransaction.java index 901b0faf0..2ef3f2058 100644 --- a/ebean-core/src/main/java/io/ebeaninternal/server/transaction/NoTransaction.java +++ b/ebean-core/src/main/java/io/ebeaninternal/server/transaction/NoTransaction.java @@ -88,6 +88,11 @@ class NoTransaction implements SpiTransaction { // do nothing } + @Override + public void preCommit() { + // do nothing + } + @Override public void postCommit() { // do nothing diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/transaction/TChangeLogHolder.java b/ebean-core/src/main/java/io/ebeaninternal/server/transaction/TChangeLogHolder.java index b97a004ea..961247bd9 100644 --- a/ebean-core/src/main/java/io/ebeaninternal/server/transaction/TChangeLogHolder.java +++ b/ebean-core/src/main/java/io/ebeaninternal/server/transaction/TChangeLogHolder.java @@ -56,20 +56,31 @@ public class TChangeLogHolder { * Add a bean change to the change set. */ public void addBeanChange(BeanChange change) { - changes.addBeanChange(change); if (++count >= batchSize) { // we hit the batch size so send what we have knowing // that the transaction has not completed yet and // reset the changes and count - owner.sendChangeLog(changes); - changes = new ChangeSet(transactionId, ++batchId); - count = 0; + sendChanges(); } } + private void sendChanges() { + owner.sendChangeLog(changes); + changes = new ChangeSet(transactionId, ++batchId); + count = 0; + } + /** - * On post commit send the changes we have collected. + * Send the changes held prior to transaction commit. + */ + public void preCommit() { + sendChanges(); + } + + /** + * On post commit send the changes we have collected. This should be + * only the COMMITTED state and with all changes sent prior to commit. */ public void postCommit() { changes.setTxnState(TxnState.COMMITTED); diff --git a/ebean-core/src/test/java/org/tests/changelog/TestChangeLog.java b/ebean-core/src/test/java/org/tests/changelog/TestChangeLog.java index 7c1d3040c..2adbbfc4b 100644 --- a/ebean-core/src/test/java/org/tests/changelog/TestChangeLog.java +++ b/ebean-core/src/test/java/org/tests/changelog/TestChangeLog.java @@ -15,11 +15,15 @@ import io.ebean.event.changelog.ChangeLogPrepare; import io.ebean.event.changelog.ChangeLogRegister; import io.ebean.event.changelog.ChangeSet; import io.ebean.event.changelog.ChangeType; +import io.ebean.event.changelog.TxnState; import org.junit.After; import org.junit.Before; import org.junit.Test; import org.tests.model.basic.EBasicChangeLog; +import java.util.ArrayList; +import java.util.List; + import static org.assertj.core.api.Assertions.assertThat; import static org.junit.Assert.assertEquals; @@ -43,6 +47,13 @@ public class TestChangeLog extends BaseTestCase { server.shutdown(); } + private BeanChange firstChange() { + ChangeSet changeSet0 = changeLogListener.changes.get(0); + BeanChange change = changeSet0.getChanges().get(0); + changeLogListener.changes.clear(); + return change; + } + @Test public void test() { @@ -50,8 +61,13 @@ public class TestChangeLog extends BaseTestCase { bean.setName("logBean"); bean.setShortDescription("hello"); server.save(bean); - BeanChange change = changeLogListener.changes.getChanges().get(0); + final List allChanges = changeLogListener.changes; + assertThat(allChanges).hasSize(2); + assertThat(allChanges.get(0).getTxnState()).isEqualTo(TxnState.IN_PROGRESS); + assertThat(allChanges.get(1).getTxnState()).isEqualTo(TxnState.COMMITTED); + + BeanChange change = firstChange(); assertThat(change.getEvent()).isEqualTo(ChangeType.INSERT); assertThat(change.getData()) .contains("\"name\":\"logBean\"") @@ -61,8 +77,7 @@ public class TestChangeLog extends BaseTestCase { bean.setName("ChangedName"); server.save(bean); - change = changeLogListener.changes.getChanges().get(0); - + change = firstChange(); assertThat(change.getEvent()).isEqualTo(ChangeType.UPDATE); assertThat(change.getOldData()).contains("\"name\":\"logBean\""); assertThat(change.getData()).contains("\"name\":\"ChangedName\""); @@ -70,14 +85,11 @@ public class TestChangeLog extends BaseTestCase { server.delete(bean); - change = changeLogListener.changes.getChanges().get(0); - + change = firstChange(); assertThat(change.getEvent()).isEqualTo(ChangeType.DELETE); assertThat(change.getData()).isNull(); - } - @Test public void testWithNull() { @@ -85,7 +97,7 @@ public class TestChangeLog extends BaseTestCase { bean.setName(null); bean.setShortDescription("hello"); server.save(bean); - BeanChange change = changeLogListener.changes.getChanges().get(0); + BeanChange change = firstChange(); assertThat(change.getEvent()).isEqualTo(ChangeType.INSERT); assertThat(change.getData()) @@ -99,7 +111,7 @@ public class TestChangeLog extends BaseTestCase { bean.setShortDescription("hello"); server.save(bean); - change = changeLogListener.changes.getChanges().get(0); + change = firstChange(); assertThat(change.getEvent()).isEqualTo(ChangeType.UPDATE); assertThat(change.getOldData()) @@ -113,11 +125,10 @@ public class TestChangeLog extends BaseTestCase { server.delete(bean); - change = changeLogListener.changes.getChanges().get(0); + change = firstChange(); assertThat(change.getEvent()).isEqualTo(ChangeType.DELETE); assertThat(change.getData()).isNull(); - } private Database createServer() { @@ -153,16 +164,15 @@ public class TestChangeLog extends BaseTestCase { ObjectMapper objectMapper = new ObjectMapper(); - ChangeSet changes; + List changes = new ArrayList<>(); public TDChangeLogListener() { objectMapper.setSerializationInclusion(JsonInclude.Include.NON_NULL); } - @Override public void log(ChangeSet changes) { - this.changes = changes; + this.changes.add(changes); try { String json = objectMapper.writeValueAsString(changes); ChangeSet changes1 = objectMapper.readValue(json, ChangeSet.class); From a674d0d696d665d72b8edfec76bdece1b8410166 Mon Sep 17 00:00:00 2001 From: rob bygrave Date: Fri, 18 Dec 2020 15:03:53 +1300 Subject: [PATCH 036/447] [maven-release-plugin] prepare release ebean-parent-12.6.3 --- ebean-api/pom.xml | 2 +- ebean-autotune/pom.xml | 6 +++--- ebean-bom/pom.xml | 24 ++++++++++++------------ ebean-core-type/pom.xml | 4 ++-- ebean-core/pom.xml | 10 +++++----- ebean-ddl-generator/pom.xml | 6 +++--- ebean-externalmapping-api/pom.xml | 2 +- ebean-externalmapping-xml/pom.xml | 10 +++++----- ebean-postgis/pom.xml | 6 +++--- ebean-querybean/pom.xml | 10 +++++----- ebean-redis/pom.xml | 16 +++++++--------- ebean-test/pom.xml | 8 ++++---- ebean/pom.xml | 12 ++++++------ kotlin-querybean-generator/pom.xml | 8 ++++---- pom.xml | 4 ++-- querybean-generator/pom.xml | 2 +- 16 files changed, 64 insertions(+), 66 deletions(-) diff --git a/ebean-api/pom.xml b/ebean-api/pom.xml index 835ad6fd0..7c16a5fac 100644 --- a/ebean-api/pom.xml +++ b/ebean-api/pom.xml @@ -4,7 +4,7 @@ ebean-parent io.ebean - 12.6.3-SNAPSHOT + 12.6.3 ebean api diff --git a/ebean-autotune/pom.xml b/ebean-autotune/pom.xml index 8a91fcfcf..18bf3b8cd 100644 --- a/ebean-autotune/pom.xml +++ b/ebean-autotune/pom.xml @@ -4,7 +4,7 @@ ebean-parent io.ebean - 12.6.3-SNAPSHOT + 12.6.3 @@ -14,7 +14,7 @@ scm:git:git@github.com:ebean-orm/ebean.git - HEAD + ebean-parent-12.6.3 ebean autotune @@ -26,7 +26,7 @@ io.ebean ebean-core - 12.6.3-SNAPSHOT + 12.6.3 provided diff --git a/ebean-bom/pom.xml b/ebean-bom/pom.xml index 36cdaebbe..838745611 100644 --- a/ebean-bom/pom.xml +++ b/ebean-bom/pom.xml @@ -4,7 +4,7 @@ ebean-parent io.ebean - 12.6.3-SNAPSHOT + 12.6.3 ebean bom @@ -81,69 +81,69 @@ io.ebean ebean - 12.6.3-SNAPSHOT + 12.6.3 io.ebean ebean-api - 12.6.3-SNAPSHOT + 12.6.3 io.ebean ebean-core - 12.6.3-SNAPSHOT + 12.6.3 io.ebean ebean-ddl-generator - 12.6.3-SNAPSHOT + 12.6.3 io.ebean ebean-externalmapping-api - 12.6.3-SNAPSHOT + 12.6.3 io.ebean ebean-externalmapping-xml - 12.6.3-SNAPSHOT + 12.6.3 io.ebean ebean-autotune - 12.6.3-SNAPSHOT + 12.6.3 io.ebean ebean-querybean - 12.6.3-SNAPSHOT + 12.6.3 io.ebean querybean-generator - 12.6.3-SNAPSHOT + 12.6.3 provided io.ebean kotlin-querybean-generator - 12.6.3-SNAPSHOT + 12.6.3 provided io.ebean ebean-test - 12.6.3-SNAPSHOT + 12.6.3 test diff --git a/ebean-core-type/pom.xml b/ebean-core-type/pom.xml index 0a36cb1df..53fe5be9e 100644 --- a/ebean-core-type/pom.xml +++ b/ebean-core-type/pom.xml @@ -4,7 +4,7 @@ ebean-parent io.ebean - 12.6.3-SNAPSHOT + 12.6.3 ebean-core-type @@ -19,7 +19,7 @@ io.ebean ebean-api - 12.6.3-SNAPSHOT + 12.6.3 diff --git a/ebean-core/pom.xml b/ebean-core/pom.xml index 16dd68ca8..9c9d39984 100644 --- a/ebean-core/pom.xml +++ b/ebean-core/pom.xml @@ -3,7 +3,7 @@ ebean-parent io.ebean - 12.6.3-SNAPSHOT + 12.6.3 ebean-core @@ -15,7 +15,7 @@ scm:git:git@github.com:ebean-orm/ebean.git - HEAD + ebean-parent-12.6.3 @@ -92,19 +92,19 @@ io.ebean ebean-api - 12.6.3-SNAPSHOT + 12.6.3 io.ebean ebean-core-type - 12.6.3-SNAPSHOT + 12.6.3 io.ebean ebean-externalmapping-api - 12.6.3-SNAPSHOT + 12.6.3 diff --git a/ebean-ddl-generator/pom.xml b/ebean-ddl-generator/pom.xml index 2fba2592a..313d7cbdd 100644 --- a/ebean-ddl-generator/pom.xml +++ b/ebean-ddl-generator/pom.xml @@ -4,7 +4,7 @@ ebean-parent io.ebean - 12.6.3-SNAPSHOT + 12.6.3 ebean ddl generation @@ -29,14 +29,14 @@ io.ebean ebean-core-type - 12.6.3-SNAPSHOT + 12.6.3 provided io.ebean ebean-core - 12.6.3-SNAPSHOT + 12.6.3 provided diff --git a/ebean-externalmapping-api/pom.xml b/ebean-externalmapping-api/pom.xml index 39af134ba..6f3e1ad9c 100644 --- a/ebean-externalmapping-api/pom.xml +++ b/ebean-externalmapping-api/pom.xml @@ -4,7 +4,7 @@ ebean-parent io.ebean - 12.6.3-SNAPSHOT + 12.6.3 ebean external mapping api diff --git a/ebean-externalmapping-xml/pom.xml b/ebean-externalmapping-xml/pom.xml index eae430ad9..b80078e1c 100644 --- a/ebean-externalmapping-xml/pom.xml +++ b/ebean-externalmapping-xml/pom.xml @@ -4,7 +4,7 @@ ebean-parent io.ebean - 12.6.3-SNAPSHOT + 12.6.3 @@ -14,7 +14,7 @@ scm:git:git@github.com:ebean-orm/ebean.git - HEAD + ebean-parent-12.6.3 ebean external mapping xml @@ -33,7 +33,7 @@ io.ebean ebean-externalmapping-api - 12.6.3-SNAPSHOT + 12.6.3 @@ -59,14 +59,14 @@ io.ebean ebean-core - 12.6.3-SNAPSHOT + 12.6.3 test io.ebean ebean-ddl-generator - 12.6.3-SNAPSHOT + 12.6.3 test diff --git a/ebean-postgis/pom.xml b/ebean-postgis/pom.xml index a9342c4ad..d5d727cda 100644 --- a/ebean-postgis/pom.xml +++ b/ebean-postgis/pom.xml @@ -4,7 +4,7 @@ ebean-parent io.ebean - 12.6.3-SNAPSHOT + 12.6.3 ebean postgis @@ -24,7 +24,7 @@ io.ebean ebean-core - 12.6.3-SNAPSHOT + 12.6.3 provided @@ -75,7 +75,7 @@ io.ebean ebean-test - 12.6.3-SNAPSHOT + 12.6.3 test diff --git a/ebean-querybean/pom.xml b/ebean-querybean/pom.xml index d674ab88b..4eda1870c 100644 --- a/ebean-querybean/pom.xml +++ b/ebean-querybean/pom.xml @@ -4,7 +4,7 @@ ebean-parent io.ebean - 12.6.3-SNAPSHOT + 12.6.3 @@ -14,7 +14,7 @@ scm:git:git@github.com:ebean-orm/ebean.git - HEAD + ebean-parent-12.6.3 ebean querybean @@ -27,7 +27,7 @@ io.ebean ebean-core - 12.6.3-SNAPSHOT + 12.6.3 provided @@ -67,14 +67,14 @@ io.ebean ebean-ddl-generator - 12.6.3-SNAPSHOT + 12.6.3 test io.ebean querybean-generator - 12.6.3-SNAPSHOT + 12.6.3 test diff --git a/ebean-redis/pom.xml b/ebean-redis/pom.xml index aa9174ea3..c96f0323e 100644 --- a/ebean-redis/pom.xml +++ b/ebean-redis/pom.xml @@ -1,12 +1,10 @@ - + 4.0.0 ebean-parent io.ebean - 12.6.3-SNAPSHOT + 12.6.3 ebean-redis @@ -24,35 +22,35 @@ io.ebean ebean-api - 12.6.3-SNAPSHOT + 12.6.3 provided io.ebean ebean-core - 12.6.3-SNAPSHOT + 12.6.3 provided io.ebean ebean-querybean - 12.6.3-SNAPSHOT + 12.6.3 test io.ebean querybean-generator - 12.6.3-SNAPSHOT + 12.6.3 test io.ebean ebean-test - 12.6.3-SNAPSHOT + 12.6.3 test diff --git a/ebean-test/pom.xml b/ebean-test/pom.xml index 6fa3751dc..370540dbf 100644 --- a/ebean-test/pom.xml +++ b/ebean-test/pom.xml @@ -4,7 +4,7 @@ ebean-parent io.ebean - 12.6.3-SNAPSHOT + 12.6.3 @@ -14,7 +14,7 @@ scm:git:git@github.com:ebean-orm/ebean.git - HEAD + ebean-parent-12.6.3 ebean test @@ -43,14 +43,14 @@ io.ebean ebean-core - 12.6.3-SNAPSHOT + 12.6.3 provided io.ebean ebean-ddl-generator - 12.6.3-SNAPSHOT + 12.6.3 diff --git a/ebean/pom.xml b/ebean/pom.xml index d1a1785ac..fbbab1a37 100644 --- a/ebean/pom.xml +++ b/ebean/pom.xml @@ -4,7 +4,7 @@ ebean-parent io.ebean - 12.6.3-SNAPSHOT + 12.6.3 ebean composite @@ -22,34 +22,34 @@ io.ebean ebean-api - 12.6.3-SNAPSHOT + 12.6.3 io.ebean ebean-core - 12.6.3-SNAPSHOT + 12.6.3 io.ebean ebean-querybean - 12.6.3-SNAPSHOT + 12.6.3 io.ebean ebean-ddl-generator - 12.6.3-SNAPSHOT + 12.6.3 io.ebean ebean-autotune - 12.6.3-SNAPSHOT + 12.6.3 diff --git a/kotlin-querybean-generator/pom.xml b/kotlin-querybean-generator/pom.xml index d9318b392..8642e11d5 100644 --- a/kotlin-querybean-generator/pom.xml +++ b/kotlin-querybean-generator/pom.xml @@ -4,7 +4,7 @@ ebean-parent io.ebean - 12.6.3-SNAPSHOT + 12.6.3 kotlin querybean generator @@ -29,7 +29,7 @@ io.ebean ebean-querybean - 12.6.3-SNAPSHOT + 12.6.3 test @@ -43,7 +43,7 @@ io.ebean ebean-core - 12.6.3-SNAPSHOT + 12.6.3 test @@ -64,7 +64,7 @@ io.ebean ebean-ddl-generator - 12.6.3-SNAPSHOT + 12.6.3 test diff --git a/pom.xml b/pom.xml index 6350ca0af..202f9bb0b 100644 --- a/pom.xml +++ b/pom.xml @@ -9,7 +9,7 @@ io.ebean ebean-parent - 12.6.3-SNAPSHOT + 12.6.3 pom ebean parent @@ -18,7 +18,7 @@ scm:git:git@github.com:ebean-orm/ebean.git - HEAD + ebean-parent-12.6.3 diff --git a/querybean-generator/pom.xml b/querybean-generator/pom.xml index f7a288d4a..68e17bbb7 100644 --- a/querybean-generator/pom.xml +++ b/querybean-generator/pom.xml @@ -4,7 +4,7 @@ ebean-parent io.ebean - 12.6.3-SNAPSHOT + 12.6.3 querybean generator From 573e1b553cdc73490c33fbb0b5bcc5c5a52b8bf5 Mon Sep 17 00:00:00 2001 From: rob bygrave Date: Fri, 18 Dec 2020 15:04:05 +1300 Subject: [PATCH 037/447] [maven-release-plugin] prepare for next development iteration --- ebean-api/pom.xml | 2 +- ebean-autotune/pom.xml | 6 +++--- ebean-bom/pom.xml | 24 ++++++++++++------------ ebean-core-type/pom.xml | 4 ++-- ebean-core/pom.xml | 10 +++++----- ebean-ddl-generator/pom.xml | 6 +++--- ebean-externalmapping-api/pom.xml | 2 +- ebean-externalmapping-xml/pom.xml | 10 +++++----- ebean-postgis/pom.xml | 6 +++--- ebean-querybean/pom.xml | 10 +++++----- ebean-redis/pom.xml | 12 ++++++------ ebean-test/pom.xml | 8 ++++---- ebean/pom.xml | 12 ++++++------ kotlin-querybean-generator/pom.xml | 8 ++++---- pom.xml | 4 ++-- querybean-generator/pom.xml | 2 +- 16 files changed, 63 insertions(+), 63 deletions(-) diff --git a/ebean-api/pom.xml b/ebean-api/pom.xml index 7c16a5fac..8e64b12fc 100644 --- a/ebean-api/pom.xml +++ b/ebean-api/pom.xml @@ -4,7 +4,7 @@ ebean-parent io.ebean - 12.6.3 + 12.6.4-SNAPSHOT ebean api diff --git a/ebean-autotune/pom.xml b/ebean-autotune/pom.xml index 18bf3b8cd..95eac64ee 100644 --- a/ebean-autotune/pom.xml +++ b/ebean-autotune/pom.xml @@ -4,7 +4,7 @@ ebean-parent io.ebean - 12.6.3 + 12.6.4-SNAPSHOT @@ -14,7 +14,7 @@ scm:git:git@github.com:ebean-orm/ebean.git - ebean-parent-12.6.3 + HEAD ebean autotune @@ -26,7 +26,7 @@ io.ebean ebean-core - 12.6.3 + 12.6.4-SNAPSHOT provided diff --git a/ebean-bom/pom.xml b/ebean-bom/pom.xml index 838745611..8fc89b69c 100644 --- a/ebean-bom/pom.xml +++ b/ebean-bom/pom.xml @@ -4,7 +4,7 @@ ebean-parent io.ebean - 12.6.3 + 12.6.4-SNAPSHOT ebean bom @@ -81,69 +81,69 @@ io.ebean ebean - 12.6.3 + 12.6.4-SNAPSHOT io.ebean ebean-api - 12.6.3 + 12.6.4-SNAPSHOT io.ebean ebean-core - 12.6.3 + 12.6.4-SNAPSHOT io.ebean ebean-ddl-generator - 12.6.3 + 12.6.4-SNAPSHOT io.ebean ebean-externalmapping-api - 12.6.3 + 12.6.4-SNAPSHOT io.ebean ebean-externalmapping-xml - 12.6.3 + 12.6.4-SNAPSHOT io.ebean ebean-autotune - 12.6.3 + 12.6.4-SNAPSHOT io.ebean ebean-querybean - 12.6.3 + 12.6.4-SNAPSHOT io.ebean querybean-generator - 12.6.3 + 12.6.4-SNAPSHOT provided io.ebean kotlin-querybean-generator - 12.6.3 + 12.6.4-SNAPSHOT provided io.ebean ebean-test - 12.6.3 + 12.6.4-SNAPSHOT test diff --git a/ebean-core-type/pom.xml b/ebean-core-type/pom.xml index 53fe5be9e..94abe76e8 100644 --- a/ebean-core-type/pom.xml +++ b/ebean-core-type/pom.xml @@ -4,7 +4,7 @@ ebean-parent io.ebean - 12.6.3 + 12.6.4-SNAPSHOT ebean-core-type @@ -19,7 +19,7 @@ io.ebean ebean-api - 12.6.3 + 12.6.4-SNAPSHOT diff --git a/ebean-core/pom.xml b/ebean-core/pom.xml index 9c9d39984..94223d0cf 100644 --- a/ebean-core/pom.xml +++ b/ebean-core/pom.xml @@ -3,7 +3,7 @@ ebean-parent io.ebean - 12.6.3 + 12.6.4-SNAPSHOT ebean-core @@ -15,7 +15,7 @@ scm:git:git@github.com:ebean-orm/ebean.git - ebean-parent-12.6.3 + HEAD @@ -92,19 +92,19 @@ io.ebean ebean-api - 12.6.3 + 12.6.4-SNAPSHOT io.ebean ebean-core-type - 12.6.3 + 12.6.4-SNAPSHOT io.ebean ebean-externalmapping-api - 12.6.3 + 12.6.4-SNAPSHOT diff --git a/ebean-ddl-generator/pom.xml b/ebean-ddl-generator/pom.xml index 313d7cbdd..bee92b994 100644 --- a/ebean-ddl-generator/pom.xml +++ b/ebean-ddl-generator/pom.xml @@ -4,7 +4,7 @@ ebean-parent io.ebean - 12.6.3 + 12.6.4-SNAPSHOT ebean ddl generation @@ -29,14 +29,14 @@ io.ebean ebean-core-type - 12.6.3 + 12.6.4-SNAPSHOT provided io.ebean ebean-core - 12.6.3 + 12.6.4-SNAPSHOT provided diff --git a/ebean-externalmapping-api/pom.xml b/ebean-externalmapping-api/pom.xml index 6f3e1ad9c..08ffd9c8b 100644 --- a/ebean-externalmapping-api/pom.xml +++ b/ebean-externalmapping-api/pom.xml @@ -4,7 +4,7 @@ ebean-parent io.ebean - 12.6.3 + 12.6.4-SNAPSHOT ebean external mapping api diff --git a/ebean-externalmapping-xml/pom.xml b/ebean-externalmapping-xml/pom.xml index b80078e1c..107bde2dc 100644 --- a/ebean-externalmapping-xml/pom.xml +++ b/ebean-externalmapping-xml/pom.xml @@ -4,7 +4,7 @@ ebean-parent io.ebean - 12.6.3 + 12.6.4-SNAPSHOT @@ -14,7 +14,7 @@ scm:git:git@github.com:ebean-orm/ebean.git - ebean-parent-12.6.3 + HEAD ebean external mapping xml @@ -33,7 +33,7 @@ io.ebean ebean-externalmapping-api - 12.6.3 + 12.6.4-SNAPSHOT @@ -59,14 +59,14 @@ io.ebean ebean-core - 12.6.3 + 12.6.4-SNAPSHOT test io.ebean ebean-ddl-generator - 12.6.3 + 12.6.4-SNAPSHOT test diff --git a/ebean-postgis/pom.xml b/ebean-postgis/pom.xml index d5d727cda..cb4eb6f77 100644 --- a/ebean-postgis/pom.xml +++ b/ebean-postgis/pom.xml @@ -4,7 +4,7 @@ ebean-parent io.ebean - 12.6.3 + 12.6.4-SNAPSHOT ebean postgis @@ -24,7 +24,7 @@ io.ebean ebean-core - 12.6.3 + 12.6.4-SNAPSHOT provided @@ -75,7 +75,7 @@ io.ebean ebean-test - 12.6.3 + 12.6.4-SNAPSHOT test diff --git a/ebean-querybean/pom.xml b/ebean-querybean/pom.xml index 4eda1870c..8efe9330f 100644 --- a/ebean-querybean/pom.xml +++ b/ebean-querybean/pom.xml @@ -4,7 +4,7 @@ ebean-parent io.ebean - 12.6.3 + 12.6.4-SNAPSHOT @@ -14,7 +14,7 @@ scm:git:git@github.com:ebean-orm/ebean.git - ebean-parent-12.6.3 + HEAD ebean querybean @@ -27,7 +27,7 @@ io.ebean ebean-core - 12.6.3 + 12.6.4-SNAPSHOT provided @@ -67,14 +67,14 @@ io.ebean ebean-ddl-generator - 12.6.3 + 12.6.4-SNAPSHOT test io.ebean querybean-generator - 12.6.3 + 12.6.4-SNAPSHOT test diff --git a/ebean-redis/pom.xml b/ebean-redis/pom.xml index c96f0323e..95e79de19 100644 --- a/ebean-redis/pom.xml +++ b/ebean-redis/pom.xml @@ -4,7 +4,7 @@ ebean-parent io.ebean - 12.6.3 + 12.6.4-SNAPSHOT ebean-redis @@ -22,35 +22,35 @@ io.ebean ebean-api - 12.6.3 + 12.6.4-SNAPSHOT provided io.ebean ebean-core - 12.6.3 + 12.6.4-SNAPSHOT provided io.ebean ebean-querybean - 12.6.3 + 12.6.4-SNAPSHOT test io.ebean querybean-generator - 12.6.3 + 12.6.4-SNAPSHOT test io.ebean ebean-test - 12.6.3 + 12.6.4-SNAPSHOT test diff --git a/ebean-test/pom.xml b/ebean-test/pom.xml index 370540dbf..992aff7fa 100644 --- a/ebean-test/pom.xml +++ b/ebean-test/pom.xml @@ -4,7 +4,7 @@ ebean-parent io.ebean - 12.6.3 + 12.6.4-SNAPSHOT @@ -14,7 +14,7 @@ scm:git:git@github.com:ebean-orm/ebean.git - ebean-parent-12.6.3 + HEAD ebean test @@ -43,14 +43,14 @@ io.ebean ebean-core - 12.6.3 + 12.6.4-SNAPSHOT provided io.ebean ebean-ddl-generator - 12.6.3 + 12.6.4-SNAPSHOT diff --git a/ebean/pom.xml b/ebean/pom.xml index fbbab1a37..a7fc58de9 100644 --- a/ebean/pom.xml +++ b/ebean/pom.xml @@ -4,7 +4,7 @@ ebean-parent io.ebean - 12.6.3 + 12.6.4-SNAPSHOT ebean composite @@ -22,34 +22,34 @@ io.ebean ebean-api - 12.6.3 + 12.6.4-SNAPSHOT io.ebean ebean-core - 12.6.3 + 12.6.4-SNAPSHOT io.ebean ebean-querybean - 12.6.3 + 12.6.4-SNAPSHOT io.ebean ebean-ddl-generator - 12.6.3 + 12.6.4-SNAPSHOT io.ebean ebean-autotune - 12.6.3 + 12.6.4-SNAPSHOT diff --git a/kotlin-querybean-generator/pom.xml b/kotlin-querybean-generator/pom.xml index 8642e11d5..dca243195 100644 --- a/kotlin-querybean-generator/pom.xml +++ b/kotlin-querybean-generator/pom.xml @@ -4,7 +4,7 @@ ebean-parent io.ebean - 12.6.3 + 12.6.4-SNAPSHOT kotlin querybean generator @@ -29,7 +29,7 @@ io.ebean ebean-querybean - 12.6.3 + 12.6.4-SNAPSHOT test @@ -43,7 +43,7 @@ io.ebean ebean-core - 12.6.3 + 12.6.4-SNAPSHOT test @@ -64,7 +64,7 @@ io.ebean ebean-ddl-generator - 12.6.3 + 12.6.4-SNAPSHOT test diff --git a/pom.xml b/pom.xml index 202f9bb0b..df6bf9f04 100644 --- a/pom.xml +++ b/pom.xml @@ -9,7 +9,7 @@ io.ebean ebean-parent - 12.6.3 + 12.6.4-SNAPSHOT pom ebean parent @@ -18,7 +18,7 @@ scm:git:git@github.com:ebean-orm/ebean.git - ebean-parent-12.6.3 + HEAD diff --git a/querybean-generator/pom.xml b/querybean-generator/pom.xml index 68e17bbb7..9d6d04a55 100644 --- a/querybean-generator/pom.xml +++ b/querybean-generator/pom.xml @@ -4,7 +4,7 @@ ebean-parent io.ebean - 12.6.3 + 12.6.4-SNAPSHOT querybean generator From e98ff952bf8b2e62e261040e97f5b281925d1da1 Mon Sep 17 00:00:00 2001 From: rob bygrave Date: Mon, 21 Dec 2020 14:11:28 +1300 Subject: [PATCH 038/447] #2137 - Expected Transaction flush on SqlQuery and DtoQuery not occurring --- .../server/core/AbstractSqlQueryRequest.java | 6 +++ .../server/core/DtoQueryRequest.java | 3 ++ .../server/core/RelationalQueryRequest.java | 8 ++++ .../batchinsert/TestBatchInsertFlush.java | 37 +++++++++++++++++++ 4 files changed, 54 insertions(+) diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/core/AbstractSqlQueryRequest.java b/ebean-core/src/main/java/io/ebeaninternal/server/core/AbstractSqlQueryRequest.java index 606d51b40..a8a31d8d6 100644 --- a/ebean-core/src/main/java/io/ebeaninternal/server/core/AbstractSqlQueryRequest.java +++ b/ebean-core/src/main/java/io/ebeaninternal/server/core/AbstractSqlQueryRequest.java @@ -73,6 +73,12 @@ public abstract class AbstractSqlQueryRequest { } } + protected void flushJdbcBatchOnQuery() { + if (trans.isFlushOnQuery()) { + trans.flush(); + } + } + public EbeanServer getServer() { return server; } diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/core/DtoQueryRequest.java b/ebean-core/src/main/java/io/ebeaninternal/server/core/DtoQueryRequest.java index 24746bf2a..7f581ebc1 100644 --- a/ebean-core/src/main/java/io/ebeaninternal/server/core/DtoQueryRequest.java +++ b/ebean-core/src/main/java/io/ebeaninternal/server/core/DtoQueryRequest.java @@ -88,14 +88,17 @@ public final class DtoQueryRequest extends AbstractSqlQueryRequest { } public void findEach(Consumer consumer) { + flushJdbcBatchOnQuery(); queryEngine.findEach(this, consumer); } public void findEachWhile(Predicate consumer) { + flushJdbcBatchOnQuery(); queryEngine.findEachWhile(this, consumer); } public List findList() { + flushJdbcBatchOnQuery(); return queryEngine.findList(this); } diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/core/RelationalQueryRequest.java b/ebean-core/src/main/java/io/ebeaninternal/server/core/RelationalQueryRequest.java index a693cf15f..54f42ec87 100644 --- a/ebean-core/src/main/java/io/ebeaninternal/server/core/RelationalQueryRequest.java +++ b/ebean-core/src/main/java/io/ebeaninternal/server/core/RelationalQueryRequest.java @@ -56,35 +56,43 @@ public final class RelationalQueryRequest extends AbstractSqlQueryRequest { } boolean findEachRow(RowConsumer mapper) { + flushJdbcBatchOnQuery(); queryEngine.findEachRow(this, mapper); return true; } List findListMapper(RowMapper mapper) { + flushJdbcBatchOnQuery(); return queryEngine.findListMapper(this, mapper); } T findOneMapper(RowMapper mapper) { + flushJdbcBatchOnQuery(); return queryEngine.findOneMapper(this, mapper); } public List findSingleAttributeList(Class cls) { + flushJdbcBatchOnQuery(); return queryEngine.findSingleAttributeList(this, cls); } public T findSingleAttribute(Class cls) { + flushJdbcBatchOnQuery(); return queryEngine.findSingleAttribute(this, cls); } public void findEach(Consumer consumer) { + flushJdbcBatchOnQuery(); queryEngine.findEach(this, consumer); } public void findEachWhile(Predicate consumer) { + flushJdbcBatchOnQuery(); queryEngine.findEach(this, consumer); } public List findList() { + flushJdbcBatchOnQuery(); return queryEngine.findList(this); } diff --git a/ebean-core/src/test/java/org/tests/batchinsert/TestBatchInsertFlush.java b/ebean-core/src/test/java/org/tests/batchinsert/TestBatchInsertFlush.java index dc04e0b79..6e956510a 100644 --- a/ebean-core/src/test/java/org/tests/batchinsert/TestBatchInsertFlush.java +++ b/ebean-core/src/test/java/org/tests/batchinsert/TestBatchInsertFlush.java @@ -1,6 +1,8 @@ package org.tests.batchinsert; import io.ebean.BaseTestCase; +import io.ebean.DB; +import io.ebean.DtoQuery2Test; import io.ebean.Ebean; import io.ebean.EbeanServer; import io.ebean.Transaction; @@ -105,6 +107,41 @@ public class TestBatchInsertFlush extends BaseTestCase { assertSql(sql.get(0)).contains("select count(*)"); } + @Test + @Transactional(batchSize = 20) + public void transactional_flushOnSqlQuery() { + + LoggedSqlCollector.start(); + + DB.save(new EBasicVer("b1")); + DB.save(new EBasicVer("b2")); + + // trigger JDBC batch by default + DB.sqlQuery("select count(*) from e_basicver") + .mapToScalar(Integer.class) + .findOne(); + + List sql = LoggedSqlCollector.stop(); + assertSql(sql.get(0)).contains("insert into e_basicver"); + } + + @Test + @Transactional(batchSize = 20) + public void transactional_flushOnDtoQuery() { + + LoggedSqlCollector.start(); + + DB.save(new EBasicVer("b1")); + DB.save(new EBasicVer("b2")); + + // trigger JDBC batch by default + DB.findDto(DtoQuery2Test.DCust.class, "select id, name from o_customer") + .findList(); + + List sql = LoggedSqlCollector.stop(); + assertSql(sql.get(0)).contains("insert into e_basicver"); + } + @Test @Transactional(batch = PersistBatch.ALL) public void transactional_flushOnQuery() { From f22a3221040ccc80cff70dbef5fc435c7b5510c8 Mon Sep 17 00:00:00 2001 From: rob bygrave Date: Mon, 21 Dec 2020 14:18:13 +1300 Subject: [PATCH 039/447] No effective change - Refactor tidy AbstractSqlQueryRequest after #2137 - Rename trans to transaction - Tidy whitespace --- .../server/core/AbstractSqlQueryRequest.java | 38 ++++++------------- .../server/core/DtoQueryRequest.java | 2 +- .../server/core/RelationalQueryRequest.java | 9 +---- 3 files changed, 15 insertions(+), 34 deletions(-) diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/core/AbstractSqlQueryRequest.java b/ebean-core/src/main/java/io/ebeaninternal/server/core/AbstractSqlQueryRequest.java index a8a31d8d6..c12534146 100644 --- a/ebean-core/src/main/java/io/ebeaninternal/server/core/AbstractSqlQueryRequest.java +++ b/ebean-core/src/main/java/io/ebeaninternal/server/core/AbstractSqlQueryRequest.java @@ -27,7 +27,7 @@ public abstract class AbstractSqlQueryRequest { protected final SpiEbeanServer server; - protected SpiTransaction trans; + protected SpiTransaction transaction; private boolean createdTransaction; @@ -47,18 +47,18 @@ public abstract class AbstractSqlQueryRequest { AbstractSqlQueryRequest(SpiEbeanServer server, SpiSqlBinding query, Transaction t) { this.server = server; this.query = query; - this.trans = (SpiTransaction) t; + this.transaction = (SpiTransaction) t; } /** * Create a transaction if none currently exists. */ public void initTransIfRequired() { - if (trans == null) { - trans = server.currentServerTransaction(); - if (trans == null || !trans.isActive()) { + if (transaction == null) { + transaction = server.currentServerTransaction(); + if (transaction == null || !transaction.isActive()) { // create a local readOnly transaction - trans = server.createReadOnlyTransaction(null); + transaction = server.createReadOnlyTransaction(null); createdTransaction = true; } } @@ -69,26 +69,18 @@ public abstract class AbstractSqlQueryRequest { */ public void endTransIfRequired() { if (createdTransaction) { - trans.commit(); + transaction.commit(); } } protected void flushJdbcBatchOnQuery() { - if (trans.isFlushOnQuery()) { - trans.flush(); + if (transaction.isFlushOnQuery()) { + transaction.flush(); } } - public EbeanServer getServer() { - return server; - } - - public SpiTransaction getTransaction() { - return trans; - } - public boolean isLogSql() { - return trans.isLogSql(); + return transaction.isLogSql(); } /** @@ -126,7 +118,6 @@ public abstract class AbstractSqlQueryRequest { * Prepare the SQL taking into account named bind parameters. */ private void prepareSql() { - String sql = query.getQuery(); BindParams bindParams = query.getBindParams(); if (!bindParams.isEmpty()) { @@ -137,7 +128,6 @@ public abstract class AbstractSqlQueryRequest { } private String limitOffset(String sql) { - int firstRow = query.getFirstRow(); int maxRows = query.getMaxRows(); if (firstRow > 0 || maxRows > 0) { @@ -155,10 +145,8 @@ public abstract class AbstractSqlQueryRequest { } protected void executeAsSql(Binder binder) throws SQLException { - prepareSql(); - Connection conn = trans.getInternalConnection(); - + Connection conn = transaction.getInternalConnection(); pstmt = conn.prepareStatement(sql); if (query.getTimeout() > 0) { pstmt.setQueryTimeout(query.getTimeout()); @@ -166,14 +154,12 @@ public abstract class AbstractSqlQueryRequest { if (query.getBufferFetchSizeHint() > 0) { pstmt.setFetchSize(query.getBufferFetchSizeHint()); } - BindParams bindParams = query.getBindParams(); if (!bindParams.isEmpty()) { this.bindLog = binder.bind(bindParams, pstmt, conn); } - if (isLogSql()) { - trans.logSql(Str.add(TrimLogSql.trim(sql), "; --bind(", bindLog, ")")); + transaction.logSql(Str.add(TrimLogSql.trim(sql), "; --bind(", bindLog, ")")); } setResultSet(pstmt.executeQuery(), null); diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/core/DtoQueryRequest.java b/ebean-core/src/main/java/io/ebeaninternal/server/core/DtoQueryRequest.java index 7f581ebc1..0dd1857c3 100644 --- a/ebean-core/src/main/java/io/ebeaninternal/server/core/DtoQueryRequest.java +++ b/ebean-core/src/main/java/io/ebeaninternal/server/core/DtoQueryRequest.java @@ -50,7 +50,7 @@ public final class DtoQueryRequest extends AbstractSqlQueryRequest { ormQuery.setManualId(); // execute the underlying ORM query returning the ResultSet - SpiResultSet result = server.findResultSet(ormQuery, trans); + SpiResultSet result = server.findResultSet(ormQuery, transaction); this.pstmt = result.getStatement(); this.sql = ormQuery.getGeneratedSql(); setResultSet(result.getResultSet(), ormQuery.getQueryPlanKey()); diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/core/RelationalQueryRequest.java b/ebean-core/src/main/java/io/ebeaninternal/server/core/RelationalQueryRequest.java index 54f42ec87..7850139c7 100644 --- a/ebean-core/src/main/java/io/ebeaninternal/server/core/RelationalQueryRequest.java +++ b/ebean-core/src/main/java/io/ebeaninternal/server/core/RelationalQueryRequest.java @@ -100,9 +100,7 @@ public final class RelationalQueryRequest extends AbstractSqlQueryRequest { * Build the list of property names. */ private String[] getPropertyNames() throws SQLException { - ResultSetMetaData metaData = resultSet.getMetaData(); - int columnsPlusOne = metaData.getColumnCount() + 1; ArrayList propNames = new ArrayList<>(columnsPlusOne - 1); for (int i = 1; i < columnsPlusOne; i++) { @@ -115,9 +113,7 @@ public final class RelationalQueryRequest extends AbstractSqlQueryRequest { * Read and return the next SqlRow. */ public SqlRow createNewRow() throws SQLException { - rows++; - SqlRow sqlRow = queryEngine.createSqlRow(estimateCapacity); int index = 0; for (String propertyName : propertyNames) { @@ -129,9 +125,9 @@ public final class RelationalQueryRequest extends AbstractSqlQueryRequest { } public void logSummary() { - if (trans.isLogSummary()) { + if (transaction.isLogSummary()) { long micros = (System.nanoTime() - startNano) / 1000L; - trans.logSummary("SqlQuery rows[" + rows + "] micros[" + micros + "] bind[" + bindLog + "]"); + transaction.logSummary("SqlQuery rows[" + rows + "] micros[" + micros + "] bind[" + bindLog + "]"); } } @@ -144,7 +140,6 @@ public final class RelationalQueryRequest extends AbstractSqlQueryRequest { } public List mapList(RowMapper mapper) throws SQLException { - List list = new ArrayList<>(); while (next()) { list.add(mapper.map(resultSet, rows++)); From 400ae3cf4bbdf387d49fcbd58458e950e60c42a4 Mon Sep 17 00:00:00 2001 From: rob bygrave Date: Mon, 21 Dec 2020 14:58:04 +1300 Subject: [PATCH 040/447] #2138 - Mark Transaction.flushBatch() as deprecated - migrate to flush(); --- .../src/main/java/io/ebean/Transaction.java | 4 ++-- .../server/core/PersistRequestBean.java | 2 +- .../server/persist/MergeNodeAssocManyToMany.java | 4 ++-- .../server/query/DefaultOrmQueryEngine.java | 2 +- .../org/tests/insert/TestInsertDuplicateKey.java | 4 ++-- .../xtra/TestInsertBatchThenFlushThenUpdate.java | 2 +- .../tests/transaction/TestSqlServerBatch.java | 16 ++++++++-------- 7 files changed, 17 insertions(+), 17 deletions(-) diff --git a/ebean-api/src/main/java/io/ebean/Transaction.java b/ebean-api/src/main/java/io/ebean/Transaction.java index b2bce9abf..d4918e84e 100644 --- a/ebean-api/src/main/java/io/ebean/Transaction.java +++ b/ebean-api/src/main/java/io/ebean/Transaction.java @@ -519,11 +519,11 @@ public interface Transaction extends AutoCloseable { void flush() throws PersistenceException; /** - * This is a synonym for flush() and will be deprecated. + * Deprecated - migrate to flush(). *

* flush() is preferred as it matches the JPA flush() method. - *

*/ + @Deprecated void flushBatch() throws PersistenceException; /** diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/core/PersistRequestBean.java b/ebean-core/src/main/java/io/ebeaninternal/server/core/PersistRequestBean.java index 3311ad866..eb48fc2ef 100644 --- a/ebean-core/src/main/java/io/ebeaninternal/server/core/PersistRequestBean.java +++ b/ebean-core/src/main/java/io/ebeaninternal/server/core/PersistRequestBean.java @@ -388,7 +388,7 @@ public final class PersistRequestBean extends PersistRequest implements BeanP @Override public void preGetterTrigger(int propertyIndex) { if (flushBatchOnGetter(propertyIndex)) { - transaction.flushBatch(); + transaction.flush(); } } diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/persist/MergeNodeAssocManyToMany.java b/ebean-core/src/main/java/io/ebeaninternal/server/persist/MergeNodeAssocManyToMany.java index 4516cefd4..7fd74e8a9 100644 --- a/ebean-core/src/main/java/io/ebeaninternal/server/persist/MergeNodeAssocManyToMany.java +++ b/ebean-core/src/main/java/io/ebeaninternal/server/persist/MergeNodeAssocManyToMany.java @@ -56,7 +56,7 @@ class MergeNodeAssocManyToMany extends MergeNode { IntersectionTable intersectionTable = many.intersectionTable(); if (!deletions.isEmpty()) { - transaction.flushBatch(); + transaction.flush(); SqlUpdate delete = intersectionTable.delete(server, false); for (EntityBean deletion : deletions) { @@ -67,7 +67,7 @@ class MergeNodeAssocManyToMany extends MergeNode { } if (!additions.isEmpty()) { - transaction.flushBatch(); + transaction.flush(); SqlUpdate insert = intersectionTable.insert(server, false); for (EntityBean addition : additions) { diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/query/DefaultOrmQueryEngine.java b/ebean-core/src/main/java/io/ebeaninternal/server/query/DefaultOrmQueryEngine.java index 1c59a614e..b112c7986 100644 --- a/ebean-core/src/main/java/io/ebeaninternal/server/query/DefaultOrmQueryEngine.java +++ b/ebean-core/src/main/java/io/ebeaninternal/server/query/DefaultOrmQueryEngine.java @@ -58,7 +58,7 @@ public class DefaultOrmQueryEngine implements OrmQueryEngine { // before we perform a query, we need to flush any // previous persist requests that are queued/batched. // The query may read data affected by those requests. - t.flushBatch(); + t.flush(); } } diff --git a/ebean-core/src/test/java/org/tests/insert/TestInsertDuplicateKey.java b/ebean-core/src/test/java/org/tests/insert/TestInsertDuplicateKey.java index 06edab471..0c728eaa3 100644 --- a/ebean-core/src/test/java/org/tests/insert/TestInsertDuplicateKey.java +++ b/ebean-core/src/test/java/org/tests/insert/TestInsertDuplicateKey.java @@ -24,7 +24,7 @@ public class TestInsertDuplicateKey extends BaseTestCase { public void clearDb() { server().find(Document.class).asDraft().where().contains("title", "UniqueKey").delete(); } - + @Test(expected = DuplicateKeyException.class) public void insert_duplicateKey() { @@ -89,7 +89,7 @@ public class TestInsertDuplicateKey extends BaseTestCase { doc2.save(); // flush at this point, fails - Ebean.getDefaultServer().currentTransaction().flushBatch(); + Ebean.getDefaultServer().currentTransaction().flush(); } catch (DuplicateKeyException e) { log.info("duplicate failed but just continue" + e.getMessage()); try { diff --git a/ebean-core/src/test/java/org/tests/model/basic/xtra/TestInsertBatchThenFlushThenUpdate.java b/ebean-core/src/test/java/org/tests/model/basic/xtra/TestInsertBatchThenFlushThenUpdate.java index 6fe2e0d18..f42b1c2b7 100644 --- a/ebean-core/src/test/java/org/tests/model/basic/xtra/TestInsertBatchThenFlushThenUpdate.java +++ b/ebean-core/src/test/java/org/tests/model/basic/xtra/TestInsertBatchThenFlushThenUpdate.java @@ -40,7 +40,7 @@ public class TestInsertBatchThenFlushThenUpdate extends BaseTestCase { // nothing flushed yet assertThat(LoggedSqlCollector.start()).isEmpty(); - txn.flushBatch(); + txn.flush(); List loggedSql1 = LoggedSqlCollector.start(); assertThat(loggedSql1).hasSize(4); diff --git a/ebean-core/src/test/java/org/tests/transaction/TestSqlServerBatch.java b/ebean-core/src/test/java/org/tests/transaction/TestSqlServerBatch.java index b6c1c7658..019193413 100644 --- a/ebean-core/src/test/java/org/tests/transaction/TestSqlServerBatch.java +++ b/ebean-core/src/test/java/org/tests/transaction/TestSqlServerBatch.java @@ -11,7 +11,7 @@ import org.tests.model.basic.ESimple; /** * This test tests a strange bug in the 6.2.0. sqlserver JDBC driver. * (Version 6.1.7.jre8-preview works) - * + *

* https://github.com/Microsoft/mssql-jdbc/pull/374 * * @author Roland Praml, FOCONIS AG @@ -29,7 +29,7 @@ public class TestSqlServerBatch extends BaseTestCase { for (int i = 0; i < 10; i++) { ESimple model = new ESimple(); - model.setName("baz "+i); + model.setName("baz " + i); Ebean.save(model); } @@ -56,13 +56,13 @@ public class TestSqlServerBatch extends BaseTestCase { txn.setGetGeneratedKeys(false); // explicitly flush the JDBC batch buffer - txn.flushBatch(); + txn.flush(); - for (int i = 0; i < 10; i++) { - ESimple model = new ESimple(); - model.setName(i % 2 == 0 ? null:"foobar"); - Ebean.save(model); - } + for (int i = 0; i < 10; i++) { + ESimple model = new ESimple(); + model.setName(i % 2 == 0 ? null : "foobar"); + Ebean.save(model); + } // do not commit } finally { From 6b2c48d4f68ea1b059b3ff148695b2d9849a60c4 Mon Sep 17 00:00:00 2001 From: rob bygrave Date: Mon, 21 Dec 2020 16:40:19 +1300 Subject: [PATCH 041/447] #2135 - ebean doest not support Spring @Transactional(propagation = Propagation.REQUIRES_NEW) --- .../io/ebeaninternal/server/transaction/TransactionManager.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/transaction/TransactionManager.java b/ebean-core/src/main/java/io/ebeaninternal/server/transaction/TransactionManager.java index 5a2c6c4b1..e42ce2fe3 100644 --- a/ebean-core/src/main/java/io/ebeaninternal/server/transaction/TransactionManager.java +++ b/ebean-core/src/main/java/io/ebeaninternal/server/transaction/TransactionManager.java @@ -634,7 +634,7 @@ public class TransactionManager implements SpiTransactionManager { public ScopedTransaction externalBeginTransaction(SpiTransaction transaction, TxScope txScope) { ScopedTransaction scopedTxn = new ScopedTransaction(scopeManager); scopedTxn.push(new ScopeTrans(rollbackOnChecked, false, transaction, txScope)); - scopeManager.set(scopedTxn); + scopeManager.replace(scopedTxn); return scopedTxn; } From fc1c9392aa1eae6bbcedafe582b11eba197fc8e9 Mon Sep 17 00:00:00 2001 From: Tobias Date: Mon, 21 Dec 2020 15:32:40 +0100 Subject: [PATCH 042/447] Failing testcase that shows wipe of all children on save When adding a newly saved bean (A) to another bean (B), all children in A are wiped on saving B. --- .../tests/cascade/TestOnlyKillOrphans.java | 43 +++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 ebean-core/src/test/java/org/tests/cascade/TestOnlyKillOrphans.java diff --git a/ebean-core/src/test/java/org/tests/cascade/TestOnlyKillOrphans.java b/ebean-core/src/test/java/org/tests/cascade/TestOnlyKillOrphans.java new file mode 100644 index 000000000..3a510637c --- /dev/null +++ b/ebean-core/src/test/java/org/tests/cascade/TestOnlyKillOrphans.java @@ -0,0 +1,43 @@ +package org.tests.cascade; + +import io.ebean.BaseTestCase; +import io.ebean.DB; +import org.junit.Test; + +import java.util.ArrayList; +import java.util.List; + +import static org.assertj.core.api.Assertions.assertThat; + +public class TestOnlyKillOrphans extends BaseTestCase { + + @Test + public void test() { + final COOne one = setup(); + + assertThat(one.getChildren()).hasSize(2); + + CORoot root = new CORoot("P1", one); + DB.insert(root); + + // assert + CORoot check = DB.find(CORoot.class, root.getId()); + assertThat(check.getOne().getChildren()).hasSize(2); + DB.delete(check); + } + + private COOne setup() { + COOne one = new COOne("P0"); + one.setChildren(createManies("M1", "M2")); + DB.insert(one); + return one; + } + + private List createManies(String... names) { + List manies = new ArrayList<>(); + for (String name : names) { + manies.add(new COOneMany(name)); + } + return manies; + } +} From 583e10f5c6b0a222153eb1f2607cfd98137cb15e Mon Sep 17 00:00:00 2001 From: rob bygrave Date: Tue, 22 Dec 2020 15:49:37 +1300 Subject: [PATCH 043/447] #2139 - Fix for - Failing testcase that shows wipe of all children on save (related to #2127) --- .../server/persist/SaveManyBeans.java | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/persist/SaveManyBeans.java b/ebean-core/src/main/java/io/ebeaninternal/server/persist/SaveManyBeans.java index 114aa232e..70131db88 100644 --- a/ebean-core/src/main/java/io/ebeaninternal/server/persist/SaveManyBeans.java +++ b/ebean-core/src/main/java/io/ebeaninternal/server/persist/SaveManyBeans.java @@ -37,7 +37,7 @@ public class SaveManyBeans extends SaveManyBase { private final boolean saveRecurseSkippable; private final DeleteMode deleteMode; private final boolean untouchedBeanCollection; - private Collection collection; + private final Collection collection; private int sortOrder; SaveManyBeans(DefaultPersister persister, boolean insertedParent, BeanPropertyAssocMany many, EntityBean parentBean, PersistRequestBean request) { @@ -49,6 +49,7 @@ public class SaveManyBeans extends SaveManyBase { this.saveRecurseSkippable = many.isSaveRecurseSkippable(); this.deleteMode = targetDescriptor.isSoftDelete() ? DeleteMode.SOFT : DeleteMode.HARD; this.untouchedBeanCollection = untouchedBeanCollection(); + this.collection = cascade ? BeanCollectionUtil.getActualEntries(value) : null; } /** @@ -108,7 +109,6 @@ public class SaveManyBeans extends SaveManyBase { private void saveAssocManyDetails() { // check that the list is not null and if it is a BeanCollection // check that is has been populated (don't trigger lazy loading) - collection = BeanCollectionUtil.getActualEntries(value); if (collection != null) { processDetails(); } @@ -210,6 +210,18 @@ public class SaveManyBeans extends SaveManyBase { return true; } + private boolean hasNewOrDirtyBeans() { + if (collection == null) { + return false; + } + for (Object bean : collection) { + if (bean instanceof EntityBean && ((EntityBean) bean)._ebean_getIntercept().isNewOrDirty()) { + return true; + } + } + return false; + } + /** * Collect the Id values of the details to remove 'missing children' for stateless updates. */ @@ -337,7 +349,7 @@ public class SaveManyBeans extends SaveManyBase { return; } if (!(value instanceof BeanCollection)) { - if (!insertedParent) { + if (!insertedParent && cascade && hasNewOrDirtyBeans()) { persister.addToFlushQueue(many.deleteByParentId(request.getBeanId(), null), transaction, 0); } } else { From 5435055f5ca058f4a25677e7324a10e6262c8c0c Mon Sep 17 00:00:00 2001 From: rob bygrave Date: Tue, 22 Dec 2020 16:08:59 +1300 Subject: [PATCH 044/447] Add ebean-redis, ebean-postgis and ebean-core-type to ebean-bom --- ebean-bom/pom.xml | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/ebean-bom/pom.xml b/ebean-bom/pom.xml index 8fc89b69c..599ced1da 100644 --- a/ebean-bom/pom.xml +++ b/ebean-bom/pom.xml @@ -96,6 +96,12 @@ 12.6.4-SNAPSHOT + + io.ebean + ebean-core-type + 12.6.4-SNAPSHOT + + io.ebean ebean-ddl-generator @@ -147,6 +153,18 @@ test + + io.ebean + ebean-postgis + 12.6.4-SNAPSHOT + + + + io.ebean + ebean-redis + 12.6.4-SNAPSHOT + + From 53386e9bf414e38661f92eefce68393173dc1dd2 Mon Sep 17 00:00:00 2001 From: rob bygrave Date: Tue, 22 Dec 2020 16:12:20 +1300 Subject: [PATCH 045/447] Update ebean-core-type name and description only --- ebean-core-type/pom.xml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/ebean-core-type/pom.xml b/ebean-core-type/pom.xml index 94abe76e8..ef591ce69 100644 --- a/ebean-core-type/pom.xml +++ b/ebean-core-type/pom.xml @@ -8,6 +8,8 @@ ebean-core-type + ebean core type + ebean scalar types api 2.11.3 From fe874c946db04afeca4ecf3a800fa5e4e3b14881 Mon Sep 17 00:00:00 2001 From: rob bygrave Date: Wed, 23 Dec 2020 20:22:50 +1300 Subject: [PATCH 046/447] #2140 - Bump ebean-migration dependency of ebean-ddl-generator to 12.4.0 (update ebean-test) --- ebean-core/pom.xml | 2 +- ebean-ddl-generator/pom.xml | 2 +- ebean-test/pom.xml | 2 +- .../src/main/java/io/ebean/test/DbJson.java | 1 - .../src/main/java/io/ebean/test/IOUtils.java | 62 +++++++++++++++++++ 5 files changed, 65 insertions(+), 4 deletions(-) create mode 100644 ebean-test/src/main/java/io/ebean/test/IOUtils.java diff --git a/ebean-core/pom.xml b/ebean-core/pom.xml index 94223d0cf..d1c6bb031 100644 --- a/ebean-core/pom.xml +++ b/ebean-core/pom.xml @@ -70,7 +70,7 @@ io.ebean ebean-migration - 12.2.0 + 12.4.0 test diff --git a/ebean-ddl-generator/pom.xml b/ebean-ddl-generator/pom.xml index bee92b994..1d94dbab8 100644 --- a/ebean-ddl-generator/pom.xml +++ b/ebean-ddl-generator/pom.xml @@ -23,7 +23,7 @@ io.ebean ebean-migration - 12.2.0 + 12.4.0 diff --git a/ebean-test/pom.xml b/ebean-test/pom.xml index 992aff7fa..f9d1e012d 100644 --- a/ebean-test/pom.xml +++ b/ebean-test/pom.xml @@ -91,7 +91,7 @@ org.postgresql postgresql - 42.2.12 + 42.2.18 test diff --git a/ebean-test/src/main/java/io/ebean/test/DbJson.java b/ebean-test/src/main/java/io/ebean/test/DbJson.java index b7fae39bb..79de39099 100644 --- a/ebean-test/src/main/java/io/ebean/test/DbJson.java +++ b/ebean-test/src/main/java/io/ebean/test/DbJson.java @@ -1,7 +1,6 @@ package io.ebean.test; import io.ebean.DB; -import io.ebean.migration.util.IOUtils; import java.io.IOException; import java.io.InputStream; diff --git a/ebean-test/src/main/java/io/ebean/test/IOUtils.java b/ebean-test/src/main/java/io/ebean/test/IOUtils.java new file mode 100644 index 000000000..79b706706 --- /dev/null +++ b/ebean-test/src/main/java/io/ebean/test/IOUtils.java @@ -0,0 +1,62 @@ +package io.ebean.test; + +import java.io.ByteArrayOutputStream; +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; +import java.nio.charset.StandardCharsets; + +/** + * Utilities for IO. + */ +class IOUtils { + + /** + * Reads the entire contents of the specified input stream and return them as UTF-8 string. + */ + static String readUtf8(InputStream in) throws IOException { + return bytesToUtf8(read(in)); + } + + /** + * Reads the entire contents of the specified input stream and returns them as a byte array. + */ + private static byte[] read(InputStream in) throws IOException { + ByteArrayOutputStream buffer = new ByteArrayOutputStream(); + pump(in, buffer); + return buffer.toByteArray(); + } + + /** + * Returns the UTF-8 string corresponding to the specified bytes. + */ + private static String bytesToUtf8(byte[] data) { + return new String(data, StandardCharsets.UTF_8); + } + + /** + * Reads data from the specified input stream and copies it to the specified + * output stream, until the input stream is at EOF. Both streams are then + * closed. + */ + private static void pump(InputStream in, OutputStream out) throws IOException { + if (in == null) throw new IOException("Input stream is null"); + if (out == null) throw new IOException("Output stream is null"); + try { + try { + byte[] buffer = new byte[4096]; + for (; ; ) { + int bytes = in.read(buffer); + if (bytes < 0) { + break; + } + out.write(buffer, 0, bytes); + } + } finally { + in.close(); + } + } finally { + out.close(); + } + } +} From 98b4ac50294329b49ce352bbd4ce3f0332f2f12e Mon Sep 17 00:00:00 2001 From: rob bygrave Date: Wed, 23 Dec 2020 20:25:22 +1300 Subject: [PATCH 047/447] [maven-release-plugin] prepare release ebean-parent-12.6.4 --- ebean-api/pom.xml | 2 +- ebean-autotune/pom.xml | 6 +++--- ebean-bom/pom.xml | 30 +++++++++++++++--------------- ebean-core-type/pom.xml | 4 ++-- ebean-core/pom.xml | 10 +++++----- ebean-ddl-generator/pom.xml | 6 +++--- ebean-externalmapping-api/pom.xml | 2 +- ebean-externalmapping-xml/pom.xml | 10 +++++----- ebean-postgis/pom.xml | 6 +++--- ebean-querybean/pom.xml | 10 +++++----- ebean-redis/pom.xml | 12 ++++++------ ebean-test/pom.xml | 8 ++++---- ebean/pom.xml | 12 ++++++------ kotlin-querybean-generator/pom.xml | 8 ++++---- pom.xml | 4 ++-- querybean-generator/pom.xml | 2 +- 16 files changed, 66 insertions(+), 66 deletions(-) diff --git a/ebean-api/pom.xml b/ebean-api/pom.xml index 8e64b12fc..2eed1b384 100644 --- a/ebean-api/pom.xml +++ b/ebean-api/pom.xml @@ -4,7 +4,7 @@ ebean-parent io.ebean - 12.6.4-SNAPSHOT + 12.6.4 ebean api diff --git a/ebean-autotune/pom.xml b/ebean-autotune/pom.xml index 95eac64ee..417821d82 100644 --- a/ebean-autotune/pom.xml +++ b/ebean-autotune/pom.xml @@ -4,7 +4,7 @@ ebean-parent io.ebean - 12.6.4-SNAPSHOT + 12.6.4 @@ -14,7 +14,7 @@ scm:git:git@github.com:ebean-orm/ebean.git - HEAD + ebean-parent-12.6.4 ebean autotune @@ -26,7 +26,7 @@ io.ebean ebean-core - 12.6.4-SNAPSHOT + 12.6.4 provided diff --git a/ebean-bom/pom.xml b/ebean-bom/pom.xml index 599ced1da..8a9f84166 100644 --- a/ebean-bom/pom.xml +++ b/ebean-bom/pom.xml @@ -4,7 +4,7 @@ ebean-parent io.ebean - 12.6.4-SNAPSHOT + 12.6.4 ebean bom @@ -81,88 +81,88 @@ io.ebean ebean - 12.6.4-SNAPSHOT + 12.6.4 io.ebean ebean-api - 12.6.4-SNAPSHOT + 12.6.4 io.ebean ebean-core - 12.6.4-SNAPSHOT + 12.6.4 io.ebean ebean-core-type - 12.6.4-SNAPSHOT + 12.6.4 io.ebean ebean-ddl-generator - 12.6.4-SNAPSHOT + 12.6.4 io.ebean ebean-externalmapping-api - 12.6.4-SNAPSHOT + 12.6.4 io.ebean ebean-externalmapping-xml - 12.6.4-SNAPSHOT + 12.6.4 io.ebean ebean-autotune - 12.6.4-SNAPSHOT + 12.6.4 io.ebean ebean-querybean - 12.6.4-SNAPSHOT + 12.6.4 io.ebean querybean-generator - 12.6.4-SNAPSHOT + 12.6.4 provided io.ebean kotlin-querybean-generator - 12.6.4-SNAPSHOT + 12.6.4 provided io.ebean ebean-test - 12.6.4-SNAPSHOT + 12.6.4 test io.ebean ebean-postgis - 12.6.4-SNAPSHOT + 12.6.4 io.ebean ebean-redis - 12.6.4-SNAPSHOT + 12.6.4 diff --git a/ebean-core-type/pom.xml b/ebean-core-type/pom.xml index ef591ce69..d645724ee 100644 --- a/ebean-core-type/pom.xml +++ b/ebean-core-type/pom.xml @@ -4,7 +4,7 @@ ebean-parent io.ebean - 12.6.4-SNAPSHOT + 12.6.4 ebean-core-type @@ -21,7 +21,7 @@ io.ebean ebean-api - 12.6.4-SNAPSHOT + 12.6.4 diff --git a/ebean-core/pom.xml b/ebean-core/pom.xml index d1c6bb031..5ae15240e 100644 --- a/ebean-core/pom.xml +++ b/ebean-core/pom.xml @@ -3,7 +3,7 @@ ebean-parent io.ebean - 12.6.4-SNAPSHOT + 12.6.4 ebean-core @@ -15,7 +15,7 @@ scm:git:git@github.com:ebean-orm/ebean.git - HEAD + ebean-parent-12.6.4 @@ -92,19 +92,19 @@ io.ebean ebean-api - 12.6.4-SNAPSHOT + 12.6.4 io.ebean ebean-core-type - 12.6.4-SNAPSHOT + 12.6.4 io.ebean ebean-externalmapping-api - 12.6.4-SNAPSHOT + 12.6.4 diff --git a/ebean-ddl-generator/pom.xml b/ebean-ddl-generator/pom.xml index 1d94dbab8..8ee261f20 100644 --- a/ebean-ddl-generator/pom.xml +++ b/ebean-ddl-generator/pom.xml @@ -4,7 +4,7 @@ ebean-parent io.ebean - 12.6.4-SNAPSHOT + 12.6.4 ebean ddl generation @@ -29,14 +29,14 @@ io.ebean ebean-core-type - 12.6.4-SNAPSHOT + 12.6.4 provided io.ebean ebean-core - 12.6.4-SNAPSHOT + 12.6.4 provided diff --git a/ebean-externalmapping-api/pom.xml b/ebean-externalmapping-api/pom.xml index 08ffd9c8b..6c4189c1c 100644 --- a/ebean-externalmapping-api/pom.xml +++ b/ebean-externalmapping-api/pom.xml @@ -4,7 +4,7 @@ ebean-parent io.ebean - 12.6.4-SNAPSHOT + 12.6.4 ebean external mapping api diff --git a/ebean-externalmapping-xml/pom.xml b/ebean-externalmapping-xml/pom.xml index 107bde2dc..71f705039 100644 --- a/ebean-externalmapping-xml/pom.xml +++ b/ebean-externalmapping-xml/pom.xml @@ -4,7 +4,7 @@ ebean-parent io.ebean - 12.6.4-SNAPSHOT + 12.6.4 @@ -14,7 +14,7 @@ scm:git:git@github.com:ebean-orm/ebean.git - HEAD + ebean-parent-12.6.4 ebean external mapping xml @@ -33,7 +33,7 @@ io.ebean ebean-externalmapping-api - 12.6.4-SNAPSHOT + 12.6.4 @@ -59,14 +59,14 @@ io.ebean ebean-core - 12.6.4-SNAPSHOT + 12.6.4 test io.ebean ebean-ddl-generator - 12.6.4-SNAPSHOT + 12.6.4 test diff --git a/ebean-postgis/pom.xml b/ebean-postgis/pom.xml index cb4eb6f77..84380e6e7 100644 --- a/ebean-postgis/pom.xml +++ b/ebean-postgis/pom.xml @@ -4,7 +4,7 @@ ebean-parent io.ebean - 12.6.4-SNAPSHOT + 12.6.4 ebean postgis @@ -24,7 +24,7 @@ io.ebean ebean-core - 12.6.4-SNAPSHOT + 12.6.4 provided @@ -75,7 +75,7 @@ io.ebean ebean-test - 12.6.4-SNAPSHOT + 12.6.4 test diff --git a/ebean-querybean/pom.xml b/ebean-querybean/pom.xml index 8efe9330f..1f6aca527 100644 --- a/ebean-querybean/pom.xml +++ b/ebean-querybean/pom.xml @@ -4,7 +4,7 @@ ebean-parent io.ebean - 12.6.4-SNAPSHOT + 12.6.4 @@ -14,7 +14,7 @@ scm:git:git@github.com:ebean-orm/ebean.git - HEAD + ebean-parent-12.6.4 ebean querybean @@ -27,7 +27,7 @@ io.ebean ebean-core - 12.6.4-SNAPSHOT + 12.6.4 provided @@ -67,14 +67,14 @@ io.ebean ebean-ddl-generator - 12.6.4-SNAPSHOT + 12.6.4 test io.ebean querybean-generator - 12.6.4-SNAPSHOT + 12.6.4 test diff --git a/ebean-redis/pom.xml b/ebean-redis/pom.xml index 95e79de19..06b24a140 100644 --- a/ebean-redis/pom.xml +++ b/ebean-redis/pom.xml @@ -4,7 +4,7 @@ ebean-parent io.ebean - 12.6.4-SNAPSHOT + 12.6.4 ebean-redis @@ -22,35 +22,35 @@ io.ebean ebean-api - 12.6.4-SNAPSHOT + 12.6.4 provided io.ebean ebean-core - 12.6.4-SNAPSHOT + 12.6.4 provided io.ebean ebean-querybean - 12.6.4-SNAPSHOT + 12.6.4 test io.ebean querybean-generator - 12.6.4-SNAPSHOT + 12.6.4 test io.ebean ebean-test - 12.6.4-SNAPSHOT + 12.6.4 test diff --git a/ebean-test/pom.xml b/ebean-test/pom.xml index f9d1e012d..a7ca340d3 100644 --- a/ebean-test/pom.xml +++ b/ebean-test/pom.xml @@ -4,7 +4,7 @@ ebean-parent io.ebean - 12.6.4-SNAPSHOT + 12.6.4 @@ -14,7 +14,7 @@ scm:git:git@github.com:ebean-orm/ebean.git - HEAD + ebean-parent-12.6.4 ebean test @@ -43,14 +43,14 @@ io.ebean ebean-core - 12.6.4-SNAPSHOT + 12.6.4 provided io.ebean ebean-ddl-generator - 12.6.4-SNAPSHOT + 12.6.4 diff --git a/ebean/pom.xml b/ebean/pom.xml index a7fc58de9..d3d1f3aac 100644 --- a/ebean/pom.xml +++ b/ebean/pom.xml @@ -4,7 +4,7 @@ ebean-parent io.ebean - 12.6.4-SNAPSHOT + 12.6.4 ebean composite @@ -22,34 +22,34 @@ io.ebean ebean-api - 12.6.4-SNAPSHOT + 12.6.4 io.ebean ebean-core - 12.6.4-SNAPSHOT + 12.6.4 io.ebean ebean-querybean - 12.6.4-SNAPSHOT + 12.6.4 io.ebean ebean-ddl-generator - 12.6.4-SNAPSHOT + 12.6.4 io.ebean ebean-autotune - 12.6.4-SNAPSHOT + 12.6.4 diff --git a/kotlin-querybean-generator/pom.xml b/kotlin-querybean-generator/pom.xml index dca243195..be206db85 100644 --- a/kotlin-querybean-generator/pom.xml +++ b/kotlin-querybean-generator/pom.xml @@ -4,7 +4,7 @@ ebean-parent io.ebean - 12.6.4-SNAPSHOT + 12.6.4 kotlin querybean generator @@ -29,7 +29,7 @@ io.ebean ebean-querybean - 12.6.4-SNAPSHOT + 12.6.4 test @@ -43,7 +43,7 @@ io.ebean ebean-core - 12.6.4-SNAPSHOT + 12.6.4 test @@ -64,7 +64,7 @@ io.ebean ebean-ddl-generator - 12.6.4-SNAPSHOT + 12.6.4 test diff --git a/pom.xml b/pom.xml index df6bf9f04..a3f2dd2c0 100644 --- a/pom.xml +++ b/pom.xml @@ -9,7 +9,7 @@ io.ebean ebean-parent - 12.6.4-SNAPSHOT + 12.6.4 pom ebean parent @@ -18,7 +18,7 @@ scm:git:git@github.com:ebean-orm/ebean.git - HEAD + ebean-parent-12.6.4 diff --git a/querybean-generator/pom.xml b/querybean-generator/pom.xml index 9d6d04a55..4d9aba79b 100644 --- a/querybean-generator/pom.xml +++ b/querybean-generator/pom.xml @@ -4,7 +4,7 @@ ebean-parent io.ebean - 12.6.4-SNAPSHOT + 12.6.4 querybean generator From 35a721039d93451624480ea212e1efe7637d44e3 Mon Sep 17 00:00:00 2001 From: rob bygrave Date: Wed, 23 Dec 2020 20:25:47 +1300 Subject: [PATCH 048/447] [maven-release-plugin] prepare for next development iteration --- ebean-api/pom.xml | 2 +- ebean-autotune/pom.xml | 6 +++--- ebean-bom/pom.xml | 30 +++++++++++++++--------------- ebean-core-type/pom.xml | 4 ++-- ebean-core/pom.xml | 10 +++++----- ebean-ddl-generator/pom.xml | 6 +++--- ebean-externalmapping-api/pom.xml | 2 +- ebean-externalmapping-xml/pom.xml | 10 +++++----- ebean-postgis/pom.xml | 6 +++--- ebean-querybean/pom.xml | 10 +++++----- ebean-redis/pom.xml | 12 ++++++------ ebean-test/pom.xml | 8 ++++---- ebean/pom.xml | 12 ++++++------ kotlin-querybean-generator/pom.xml | 8 ++++---- pom.xml | 4 ++-- querybean-generator/pom.xml | 2 +- 16 files changed, 66 insertions(+), 66 deletions(-) diff --git a/ebean-api/pom.xml b/ebean-api/pom.xml index 2eed1b384..93f96505e 100644 --- a/ebean-api/pom.xml +++ b/ebean-api/pom.xml @@ -4,7 +4,7 @@ ebean-parent io.ebean - 12.6.4 + 12.6.5-SNAPSHOT ebean api diff --git a/ebean-autotune/pom.xml b/ebean-autotune/pom.xml index 417821d82..4be25a18d 100644 --- a/ebean-autotune/pom.xml +++ b/ebean-autotune/pom.xml @@ -4,7 +4,7 @@ ebean-parent io.ebean - 12.6.4 + 12.6.5-SNAPSHOT @@ -14,7 +14,7 @@ scm:git:git@github.com:ebean-orm/ebean.git - ebean-parent-12.6.4 + HEAD ebean autotune @@ -26,7 +26,7 @@ io.ebean ebean-core - 12.6.4 + 12.6.5-SNAPSHOT provided diff --git a/ebean-bom/pom.xml b/ebean-bom/pom.xml index 8a9f84166..cfcfc2c7a 100644 --- a/ebean-bom/pom.xml +++ b/ebean-bom/pom.xml @@ -4,7 +4,7 @@ ebean-parent io.ebean - 12.6.4 + 12.6.5-SNAPSHOT ebean bom @@ -81,88 +81,88 @@ io.ebean ebean - 12.6.4 + 12.6.5-SNAPSHOT io.ebean ebean-api - 12.6.4 + 12.6.5-SNAPSHOT io.ebean ebean-core - 12.6.4 + 12.6.5-SNAPSHOT io.ebean ebean-core-type - 12.6.4 + 12.6.5-SNAPSHOT io.ebean ebean-ddl-generator - 12.6.4 + 12.6.5-SNAPSHOT io.ebean ebean-externalmapping-api - 12.6.4 + 12.6.5-SNAPSHOT io.ebean ebean-externalmapping-xml - 12.6.4 + 12.6.5-SNAPSHOT io.ebean ebean-autotune - 12.6.4 + 12.6.5-SNAPSHOT io.ebean ebean-querybean - 12.6.4 + 12.6.5-SNAPSHOT io.ebean querybean-generator - 12.6.4 + 12.6.5-SNAPSHOT provided io.ebean kotlin-querybean-generator - 12.6.4 + 12.6.5-SNAPSHOT provided io.ebean ebean-test - 12.6.4 + 12.6.5-SNAPSHOT test io.ebean ebean-postgis - 12.6.4 + 12.6.5-SNAPSHOT io.ebean ebean-redis - 12.6.4 + 12.6.5-SNAPSHOT diff --git a/ebean-core-type/pom.xml b/ebean-core-type/pom.xml index d645724ee..67f7dd439 100644 --- a/ebean-core-type/pom.xml +++ b/ebean-core-type/pom.xml @@ -4,7 +4,7 @@ ebean-parent io.ebean - 12.6.4 + 12.6.5-SNAPSHOT ebean-core-type @@ -21,7 +21,7 @@ io.ebean ebean-api - 12.6.4 + 12.6.5-SNAPSHOT diff --git a/ebean-core/pom.xml b/ebean-core/pom.xml index 5ae15240e..34bbf572c 100644 --- a/ebean-core/pom.xml +++ b/ebean-core/pom.xml @@ -3,7 +3,7 @@ ebean-parent io.ebean - 12.6.4 + 12.6.5-SNAPSHOT ebean-core @@ -15,7 +15,7 @@ scm:git:git@github.com:ebean-orm/ebean.git - ebean-parent-12.6.4 + HEAD @@ -92,19 +92,19 @@ io.ebean ebean-api - 12.6.4 + 12.6.5-SNAPSHOT io.ebean ebean-core-type - 12.6.4 + 12.6.5-SNAPSHOT io.ebean ebean-externalmapping-api - 12.6.4 + 12.6.5-SNAPSHOT diff --git a/ebean-ddl-generator/pom.xml b/ebean-ddl-generator/pom.xml index 8ee261f20..5094c8a07 100644 --- a/ebean-ddl-generator/pom.xml +++ b/ebean-ddl-generator/pom.xml @@ -4,7 +4,7 @@ ebean-parent io.ebean - 12.6.4 + 12.6.5-SNAPSHOT ebean ddl generation @@ -29,14 +29,14 @@ io.ebean ebean-core-type - 12.6.4 + 12.6.5-SNAPSHOT provided io.ebean ebean-core - 12.6.4 + 12.6.5-SNAPSHOT provided diff --git a/ebean-externalmapping-api/pom.xml b/ebean-externalmapping-api/pom.xml index 6c4189c1c..ec760e5ce 100644 --- a/ebean-externalmapping-api/pom.xml +++ b/ebean-externalmapping-api/pom.xml @@ -4,7 +4,7 @@ ebean-parent io.ebean - 12.6.4 + 12.6.5-SNAPSHOT ebean external mapping api diff --git a/ebean-externalmapping-xml/pom.xml b/ebean-externalmapping-xml/pom.xml index 71f705039..91c95fb6c 100644 --- a/ebean-externalmapping-xml/pom.xml +++ b/ebean-externalmapping-xml/pom.xml @@ -4,7 +4,7 @@ ebean-parent io.ebean - 12.6.4 + 12.6.5-SNAPSHOT @@ -14,7 +14,7 @@ scm:git:git@github.com:ebean-orm/ebean.git - ebean-parent-12.6.4 + HEAD ebean external mapping xml @@ -33,7 +33,7 @@ io.ebean ebean-externalmapping-api - 12.6.4 + 12.6.5-SNAPSHOT @@ -59,14 +59,14 @@ io.ebean ebean-core - 12.6.4 + 12.6.5-SNAPSHOT test io.ebean ebean-ddl-generator - 12.6.4 + 12.6.5-SNAPSHOT test diff --git a/ebean-postgis/pom.xml b/ebean-postgis/pom.xml index 84380e6e7..fa0b76c37 100644 --- a/ebean-postgis/pom.xml +++ b/ebean-postgis/pom.xml @@ -4,7 +4,7 @@ ebean-parent io.ebean - 12.6.4 + 12.6.5-SNAPSHOT ebean postgis @@ -24,7 +24,7 @@ io.ebean ebean-core - 12.6.4 + 12.6.5-SNAPSHOT provided @@ -75,7 +75,7 @@ io.ebean ebean-test - 12.6.4 + 12.6.5-SNAPSHOT test diff --git a/ebean-querybean/pom.xml b/ebean-querybean/pom.xml index 1f6aca527..776a1e7e3 100644 --- a/ebean-querybean/pom.xml +++ b/ebean-querybean/pom.xml @@ -4,7 +4,7 @@ ebean-parent io.ebean - 12.6.4 + 12.6.5-SNAPSHOT @@ -14,7 +14,7 @@ scm:git:git@github.com:ebean-orm/ebean.git - ebean-parent-12.6.4 + HEAD ebean querybean @@ -27,7 +27,7 @@ io.ebean ebean-core - 12.6.4 + 12.6.5-SNAPSHOT provided @@ -67,14 +67,14 @@ io.ebean ebean-ddl-generator - 12.6.4 + 12.6.5-SNAPSHOT test io.ebean querybean-generator - 12.6.4 + 12.6.5-SNAPSHOT test diff --git a/ebean-redis/pom.xml b/ebean-redis/pom.xml index 06b24a140..ee7ae7cbf 100644 --- a/ebean-redis/pom.xml +++ b/ebean-redis/pom.xml @@ -4,7 +4,7 @@ ebean-parent io.ebean - 12.6.4 + 12.6.5-SNAPSHOT ebean-redis @@ -22,35 +22,35 @@ io.ebean ebean-api - 12.6.4 + 12.6.5-SNAPSHOT provided io.ebean ebean-core - 12.6.4 + 12.6.5-SNAPSHOT provided io.ebean ebean-querybean - 12.6.4 + 12.6.5-SNAPSHOT test io.ebean querybean-generator - 12.6.4 + 12.6.5-SNAPSHOT test io.ebean ebean-test - 12.6.4 + 12.6.5-SNAPSHOT test diff --git a/ebean-test/pom.xml b/ebean-test/pom.xml index a7ca340d3..06ca2ac55 100644 --- a/ebean-test/pom.xml +++ b/ebean-test/pom.xml @@ -4,7 +4,7 @@ ebean-parent io.ebean - 12.6.4 + 12.6.5-SNAPSHOT @@ -14,7 +14,7 @@ scm:git:git@github.com:ebean-orm/ebean.git - ebean-parent-12.6.4 + HEAD ebean test @@ -43,14 +43,14 @@ io.ebean ebean-core - 12.6.4 + 12.6.5-SNAPSHOT provided io.ebean ebean-ddl-generator - 12.6.4 + 12.6.5-SNAPSHOT diff --git a/ebean/pom.xml b/ebean/pom.xml index d3d1f3aac..808c06279 100644 --- a/ebean/pom.xml +++ b/ebean/pom.xml @@ -4,7 +4,7 @@ ebean-parent io.ebean - 12.6.4 + 12.6.5-SNAPSHOT ebean composite @@ -22,34 +22,34 @@ io.ebean ebean-api - 12.6.4 + 12.6.5-SNAPSHOT io.ebean ebean-core - 12.6.4 + 12.6.5-SNAPSHOT io.ebean ebean-querybean - 12.6.4 + 12.6.5-SNAPSHOT io.ebean ebean-ddl-generator - 12.6.4 + 12.6.5-SNAPSHOT io.ebean ebean-autotune - 12.6.4 + 12.6.5-SNAPSHOT diff --git a/kotlin-querybean-generator/pom.xml b/kotlin-querybean-generator/pom.xml index be206db85..f4de4cc1d 100644 --- a/kotlin-querybean-generator/pom.xml +++ b/kotlin-querybean-generator/pom.xml @@ -4,7 +4,7 @@ ebean-parent io.ebean - 12.6.4 + 12.6.5-SNAPSHOT kotlin querybean generator @@ -29,7 +29,7 @@ io.ebean ebean-querybean - 12.6.4 + 12.6.5-SNAPSHOT test @@ -43,7 +43,7 @@ io.ebean ebean-core - 12.6.4 + 12.6.5-SNAPSHOT test @@ -64,7 +64,7 @@ io.ebean ebean-ddl-generator - 12.6.4 + 12.6.5-SNAPSHOT test diff --git a/pom.xml b/pom.xml index a3f2dd2c0..bb356e9f3 100644 --- a/pom.xml +++ b/pom.xml @@ -9,7 +9,7 @@ io.ebean ebean-parent - 12.6.4 + 12.6.5-SNAPSHOT pom ebean parent @@ -18,7 +18,7 @@ scm:git:git@github.com:ebean-orm/ebean.git - ebean-parent-12.6.4 + HEAD diff --git a/querybean-generator/pom.xml b/querybean-generator/pom.xml index 4d9aba79b..79faf918c 100644 --- a/querybean-generator/pom.xml +++ b/querybean-generator/pom.xml @@ -4,7 +4,7 @@ ebean-parent io.ebean - 12.6.4 + 12.6.5-SNAPSHOT querybean generator From 69e56be459376e7fb3cd6a1bea08b3664409e6b5 Mon Sep 17 00:00:00 2001 From: Tobias Date: Mon, 28 Dec 2020 15:35:15 +0100 Subject: [PATCH 049/447] Failing testcase that shows wipe of all old children on save When adding a child to a newly saved bean (A), all other children are killed on save of A. --- .../tests/cascade/TestOnlyKillOrphans.java | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/ebean-core/src/test/java/org/tests/cascade/TestOnlyKillOrphans.java b/ebean-core/src/test/java/org/tests/cascade/TestOnlyKillOrphans.java index 3a510637c..8da56d1b1 100644 --- a/ebean-core/src/test/java/org/tests/cascade/TestOnlyKillOrphans.java +++ b/ebean-core/src/test/java/org/tests/cascade/TestOnlyKillOrphans.java @@ -6,6 +6,8 @@ import org.junit.Test; import java.util.ArrayList; import java.util.List; +import java.util.stream.Collectors; +import java.util.stream.Stream; import static org.assertj.core.api.Assertions.assertThat; @@ -26,6 +28,23 @@ public class TestOnlyKillOrphans extends BaseTestCase { DB.delete(check); } + @Test + public void test2() { + final COOne one = setup(); + + assertThat(one.getChildren()).hasSize(2); + + one.getChildren().add(new COOneMany("_M1")); + + DB.save(one); + + // assert + COOne check = DB.find(COOne.class, one.getId()); + assertThat(check.getChildren().stream().map(it -> it.getName()).sorted().collect(Collectors.toList())) + .isEqualTo(Stream.of("M1", "M2", "_M1").sorted().collect(Collectors.toList())); + DB.delete(check); + } + private COOne setup() { COOne one = new COOne("P0"); one.setChildren(createManies("M1", "M2")); From d8f4503d98138bc61c87eade9091e4bad92589c7 Mon Sep 17 00:00:00 2001 From: rob bygrave Date: Tue, 5 Jan 2021 17:56:55 +1300 Subject: [PATCH 050/447] #2141 - Fix for failing test, revert of fix for #2127 --- .../java/io/ebeaninternal/server/persist/SaveManyBeans.java | 6 +++--- .../test/java/org/tests/cascade/TestDeleteO2MOrphans.java | 3 ++- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/persist/SaveManyBeans.java b/ebean-core/src/main/java/io/ebeaninternal/server/persist/SaveManyBeans.java index 70131db88..183956ef8 100644 --- a/ebean-core/src/main/java/io/ebeaninternal/server/persist/SaveManyBeans.java +++ b/ebean-core/src/main/java/io/ebeaninternal/server/persist/SaveManyBeans.java @@ -349,9 +349,9 @@ public class SaveManyBeans extends SaveManyBase { return; } if (!(value instanceof BeanCollection)) { - if (!insertedParent && cascade && hasNewOrDirtyBeans()) { - persister.addToFlushQueue(many.deleteByParentId(request.getBeanId(), null), transaction, 0); - } +// if (!insertedParent && cascade && hasNewOrDirtyBeans()) { +// persister.addToFlushQueue(many.deleteByParentId(request.getBeanId(), null), transaction, 0); +// } } else { BeanCollection c = (BeanCollection) value; Set modifyRemovals = c.getModifyRemovals(); diff --git a/ebean-core/src/test/java/org/tests/cascade/TestDeleteO2MOrphans.java b/ebean-core/src/test/java/org/tests/cascade/TestDeleteO2MOrphans.java index f4356d2bf..468187657 100644 --- a/ebean-core/src/test/java/org/tests/cascade/TestDeleteO2MOrphans.java +++ b/ebean-core/src/test/java/org/tests/cascade/TestDeleteO2MOrphans.java @@ -19,7 +19,8 @@ public class TestDeleteO2MOrphans extends BaseTestCase { // assert COOne check = findById(id); - assertThat(check.getChildren()).hasSize(2); + //FIXME #2127 #2141: assertThat(check.getChildren()).hasSize(2); + assertThat(check.getChildren()).hasSize(4); DB.delete(check); } From 501f8111fe6ded17d9f9708c114330ad752eacbc Mon Sep 17 00:00:00 2001 From: rob bygrave Date: Tue, 5 Jan 2021 18:02:09 +1300 Subject: [PATCH 051/447] [maven-release-plugin] prepare release ebean-parent-12.6.5 --- ebean-api/pom.xml | 2 +- ebean-autotune/pom.xml | 6 +++--- ebean-bom/pom.xml | 30 +++++++++++++++--------------- ebean-core-type/pom.xml | 4 ++-- ebean-core/pom.xml | 10 +++++----- ebean-ddl-generator/pom.xml | 6 +++--- ebean-externalmapping-api/pom.xml | 2 +- ebean-externalmapping-xml/pom.xml | 10 +++++----- ebean-postgis/pom.xml | 6 +++--- ebean-querybean/pom.xml | 10 +++++----- ebean-redis/pom.xml | 12 ++++++------ ebean-test/pom.xml | 8 ++++---- ebean/pom.xml | 12 ++++++------ kotlin-querybean-generator/pom.xml | 8 ++++---- pom.xml | 4 ++-- querybean-generator/pom.xml | 2 +- 16 files changed, 66 insertions(+), 66 deletions(-) diff --git a/ebean-api/pom.xml b/ebean-api/pom.xml index 93f96505e..80fb41c5e 100644 --- a/ebean-api/pom.xml +++ b/ebean-api/pom.xml @@ -4,7 +4,7 @@ ebean-parent io.ebean - 12.6.5-SNAPSHOT + 12.6.5 ebean api diff --git a/ebean-autotune/pom.xml b/ebean-autotune/pom.xml index 4be25a18d..9153c0ef7 100644 --- a/ebean-autotune/pom.xml +++ b/ebean-autotune/pom.xml @@ -4,7 +4,7 @@ ebean-parent io.ebean - 12.6.5-SNAPSHOT + 12.6.5 @@ -14,7 +14,7 @@ scm:git:git@github.com:ebean-orm/ebean.git - HEAD + ebean-parent-12.6.5 ebean autotune @@ -26,7 +26,7 @@ io.ebean ebean-core - 12.6.5-SNAPSHOT + 12.6.5 provided diff --git a/ebean-bom/pom.xml b/ebean-bom/pom.xml index cfcfc2c7a..dba66dbaa 100644 --- a/ebean-bom/pom.xml +++ b/ebean-bom/pom.xml @@ -4,7 +4,7 @@ ebean-parent io.ebean - 12.6.5-SNAPSHOT + 12.6.5 ebean bom @@ -81,88 +81,88 @@ io.ebean ebean - 12.6.5-SNAPSHOT + 12.6.5 io.ebean ebean-api - 12.6.5-SNAPSHOT + 12.6.5 io.ebean ebean-core - 12.6.5-SNAPSHOT + 12.6.5 io.ebean ebean-core-type - 12.6.5-SNAPSHOT + 12.6.5 io.ebean ebean-ddl-generator - 12.6.5-SNAPSHOT + 12.6.5 io.ebean ebean-externalmapping-api - 12.6.5-SNAPSHOT + 12.6.5 io.ebean ebean-externalmapping-xml - 12.6.5-SNAPSHOT + 12.6.5 io.ebean ebean-autotune - 12.6.5-SNAPSHOT + 12.6.5 io.ebean ebean-querybean - 12.6.5-SNAPSHOT + 12.6.5 io.ebean querybean-generator - 12.6.5-SNAPSHOT + 12.6.5 provided io.ebean kotlin-querybean-generator - 12.6.5-SNAPSHOT + 12.6.5 provided io.ebean ebean-test - 12.6.5-SNAPSHOT + 12.6.5 test io.ebean ebean-postgis - 12.6.5-SNAPSHOT + 12.6.5 io.ebean ebean-redis - 12.6.5-SNAPSHOT + 12.6.5 diff --git a/ebean-core-type/pom.xml b/ebean-core-type/pom.xml index 67f7dd439..848d7b532 100644 --- a/ebean-core-type/pom.xml +++ b/ebean-core-type/pom.xml @@ -4,7 +4,7 @@ ebean-parent io.ebean - 12.6.5-SNAPSHOT + 12.6.5 ebean-core-type @@ -21,7 +21,7 @@ io.ebean ebean-api - 12.6.5-SNAPSHOT + 12.6.5 diff --git a/ebean-core/pom.xml b/ebean-core/pom.xml index 34bbf572c..1d3924599 100644 --- a/ebean-core/pom.xml +++ b/ebean-core/pom.xml @@ -3,7 +3,7 @@ ebean-parent io.ebean - 12.6.5-SNAPSHOT + 12.6.5 ebean-core @@ -15,7 +15,7 @@ scm:git:git@github.com:ebean-orm/ebean.git - HEAD + ebean-parent-12.6.5 @@ -92,19 +92,19 @@ io.ebean ebean-api - 12.6.5-SNAPSHOT + 12.6.5 io.ebean ebean-core-type - 12.6.5-SNAPSHOT + 12.6.5 io.ebean ebean-externalmapping-api - 12.6.5-SNAPSHOT + 12.6.5 diff --git a/ebean-ddl-generator/pom.xml b/ebean-ddl-generator/pom.xml index 5094c8a07..0d16ea5e1 100644 --- a/ebean-ddl-generator/pom.xml +++ b/ebean-ddl-generator/pom.xml @@ -4,7 +4,7 @@ ebean-parent io.ebean - 12.6.5-SNAPSHOT + 12.6.5 ebean ddl generation @@ -29,14 +29,14 @@ io.ebean ebean-core-type - 12.6.5-SNAPSHOT + 12.6.5 provided io.ebean ebean-core - 12.6.5-SNAPSHOT + 12.6.5 provided diff --git a/ebean-externalmapping-api/pom.xml b/ebean-externalmapping-api/pom.xml index ec760e5ce..6f62e248b 100644 --- a/ebean-externalmapping-api/pom.xml +++ b/ebean-externalmapping-api/pom.xml @@ -4,7 +4,7 @@ ebean-parent io.ebean - 12.6.5-SNAPSHOT + 12.6.5 ebean external mapping api diff --git a/ebean-externalmapping-xml/pom.xml b/ebean-externalmapping-xml/pom.xml index 91c95fb6c..49fd29580 100644 --- a/ebean-externalmapping-xml/pom.xml +++ b/ebean-externalmapping-xml/pom.xml @@ -4,7 +4,7 @@ ebean-parent io.ebean - 12.6.5-SNAPSHOT + 12.6.5 @@ -14,7 +14,7 @@ scm:git:git@github.com:ebean-orm/ebean.git - HEAD + ebean-parent-12.6.5 ebean external mapping xml @@ -33,7 +33,7 @@ io.ebean ebean-externalmapping-api - 12.6.5-SNAPSHOT + 12.6.5 @@ -59,14 +59,14 @@ io.ebean ebean-core - 12.6.5-SNAPSHOT + 12.6.5 test io.ebean ebean-ddl-generator - 12.6.5-SNAPSHOT + 12.6.5 test diff --git a/ebean-postgis/pom.xml b/ebean-postgis/pom.xml index fa0b76c37..99f677be8 100644 --- a/ebean-postgis/pom.xml +++ b/ebean-postgis/pom.xml @@ -4,7 +4,7 @@ ebean-parent io.ebean - 12.6.5-SNAPSHOT + 12.6.5 ebean postgis @@ -24,7 +24,7 @@ io.ebean ebean-core - 12.6.5-SNAPSHOT + 12.6.5 provided @@ -75,7 +75,7 @@ io.ebean ebean-test - 12.6.5-SNAPSHOT + 12.6.5 test diff --git a/ebean-querybean/pom.xml b/ebean-querybean/pom.xml index 776a1e7e3..b7fe8edce 100644 --- a/ebean-querybean/pom.xml +++ b/ebean-querybean/pom.xml @@ -4,7 +4,7 @@ ebean-parent io.ebean - 12.6.5-SNAPSHOT + 12.6.5 @@ -14,7 +14,7 @@ scm:git:git@github.com:ebean-orm/ebean.git - HEAD + ebean-parent-12.6.5 ebean querybean @@ -27,7 +27,7 @@ io.ebean ebean-core - 12.6.5-SNAPSHOT + 12.6.5 provided @@ -67,14 +67,14 @@ io.ebean ebean-ddl-generator - 12.6.5-SNAPSHOT + 12.6.5 test io.ebean querybean-generator - 12.6.5-SNAPSHOT + 12.6.5 test diff --git a/ebean-redis/pom.xml b/ebean-redis/pom.xml index ee7ae7cbf..d45ddea50 100644 --- a/ebean-redis/pom.xml +++ b/ebean-redis/pom.xml @@ -4,7 +4,7 @@ ebean-parent io.ebean - 12.6.5-SNAPSHOT + 12.6.5 ebean-redis @@ -22,35 +22,35 @@ io.ebean ebean-api - 12.6.5-SNAPSHOT + 12.6.5 provided io.ebean ebean-core - 12.6.5-SNAPSHOT + 12.6.5 provided io.ebean ebean-querybean - 12.6.5-SNAPSHOT + 12.6.5 test io.ebean querybean-generator - 12.6.5-SNAPSHOT + 12.6.5 test io.ebean ebean-test - 12.6.5-SNAPSHOT + 12.6.5 test diff --git a/ebean-test/pom.xml b/ebean-test/pom.xml index 06ca2ac55..296890fae 100644 --- a/ebean-test/pom.xml +++ b/ebean-test/pom.xml @@ -4,7 +4,7 @@ ebean-parent io.ebean - 12.6.5-SNAPSHOT + 12.6.5 @@ -14,7 +14,7 @@ scm:git:git@github.com:ebean-orm/ebean.git - HEAD + ebean-parent-12.6.5 ebean test @@ -43,14 +43,14 @@ io.ebean ebean-core - 12.6.5-SNAPSHOT + 12.6.5 provided io.ebean ebean-ddl-generator - 12.6.5-SNAPSHOT + 12.6.5 diff --git a/ebean/pom.xml b/ebean/pom.xml index 808c06279..89d83f49b 100644 --- a/ebean/pom.xml +++ b/ebean/pom.xml @@ -4,7 +4,7 @@ ebean-parent io.ebean - 12.6.5-SNAPSHOT + 12.6.5 ebean composite @@ -22,34 +22,34 @@ io.ebean ebean-api - 12.6.5-SNAPSHOT + 12.6.5 io.ebean ebean-core - 12.6.5-SNAPSHOT + 12.6.5 io.ebean ebean-querybean - 12.6.5-SNAPSHOT + 12.6.5 io.ebean ebean-ddl-generator - 12.6.5-SNAPSHOT + 12.6.5 io.ebean ebean-autotune - 12.6.5-SNAPSHOT + 12.6.5 diff --git a/kotlin-querybean-generator/pom.xml b/kotlin-querybean-generator/pom.xml index f4de4cc1d..23c4d7da9 100644 --- a/kotlin-querybean-generator/pom.xml +++ b/kotlin-querybean-generator/pom.xml @@ -4,7 +4,7 @@ ebean-parent io.ebean - 12.6.5-SNAPSHOT + 12.6.5 kotlin querybean generator @@ -29,7 +29,7 @@ io.ebean ebean-querybean - 12.6.5-SNAPSHOT + 12.6.5 test @@ -43,7 +43,7 @@ io.ebean ebean-core - 12.6.5-SNAPSHOT + 12.6.5 test @@ -64,7 +64,7 @@ io.ebean ebean-ddl-generator - 12.6.5-SNAPSHOT + 12.6.5 test diff --git a/pom.xml b/pom.xml index bb356e9f3..615d86c69 100644 --- a/pom.xml +++ b/pom.xml @@ -9,7 +9,7 @@ io.ebean ebean-parent - 12.6.5-SNAPSHOT + 12.6.5 pom ebean parent @@ -18,7 +18,7 @@ scm:git:git@github.com:ebean-orm/ebean.git - HEAD + ebean-parent-12.6.5 diff --git a/querybean-generator/pom.xml b/querybean-generator/pom.xml index 79faf918c..6e4d5122b 100644 --- a/querybean-generator/pom.xml +++ b/querybean-generator/pom.xml @@ -4,7 +4,7 @@ ebean-parent io.ebean - 12.6.5-SNAPSHOT + 12.6.5 querybean generator From 7e48f7c8ebbdfd5a4f859a01de0a959831c5c115 Mon Sep 17 00:00:00 2001 From: rob bygrave Date: Tue, 5 Jan 2021 18:02:21 +1300 Subject: [PATCH 052/447] [maven-release-plugin] prepare for next development iteration --- ebean-api/pom.xml | 2 +- ebean-autotune/pom.xml | 4 ++-- ebean-bom/pom.xml | 30 +++++++++++++++--------------- ebean-core-type/pom.xml | 4 ++-- ebean-core/pom.xml | 8 ++++---- ebean-ddl-generator/pom.xml | 6 +++--- ebean-externalmapping-api/pom.xml | 2 +- ebean-externalmapping-xml/pom.xml | 8 ++++---- ebean-postgis/pom.xml | 6 +++--- ebean-querybean/pom.xml | 8 ++++---- ebean-redis/pom.xml | 12 ++++++------ ebean-test/pom.xml | 6 +++--- ebean/pom.xml | 12 ++++++------ kotlin-querybean-generator/pom.xml | 8 ++++---- pom.xml | 2 +- querybean-generator/pom.xml | 2 +- 16 files changed, 60 insertions(+), 60 deletions(-) diff --git a/ebean-api/pom.xml b/ebean-api/pom.xml index 80fb41c5e..3fea9a758 100644 --- a/ebean-api/pom.xml +++ b/ebean-api/pom.xml @@ -4,7 +4,7 @@ ebean-parent io.ebean - 12.6.5 + 12.6.6-SNAPSHOT ebean api diff --git a/ebean-autotune/pom.xml b/ebean-autotune/pom.xml index 9153c0ef7..7eeae736a 100644 --- a/ebean-autotune/pom.xml +++ b/ebean-autotune/pom.xml @@ -4,7 +4,7 @@ ebean-parent io.ebean - 12.6.5 + 12.6.6-SNAPSHOT @@ -26,7 +26,7 @@ io.ebean ebean-core - 12.6.5 + 12.6.6-SNAPSHOT provided diff --git a/ebean-bom/pom.xml b/ebean-bom/pom.xml index dba66dbaa..238643d19 100644 --- a/ebean-bom/pom.xml +++ b/ebean-bom/pom.xml @@ -4,7 +4,7 @@ ebean-parent io.ebean - 12.6.5 + 12.6.6-SNAPSHOT ebean bom @@ -81,88 +81,88 @@ io.ebean ebean - 12.6.5 + 12.6.6-SNAPSHOT io.ebean ebean-api - 12.6.5 + 12.6.6-SNAPSHOT io.ebean ebean-core - 12.6.5 + 12.6.6-SNAPSHOT io.ebean ebean-core-type - 12.6.5 + 12.6.6-SNAPSHOT io.ebean ebean-ddl-generator - 12.6.5 + 12.6.6-SNAPSHOT io.ebean ebean-externalmapping-api - 12.6.5 + 12.6.6-SNAPSHOT io.ebean ebean-externalmapping-xml - 12.6.5 + 12.6.6-SNAPSHOT io.ebean ebean-autotune - 12.6.5 + 12.6.6-SNAPSHOT io.ebean ebean-querybean - 12.6.5 + 12.6.6-SNAPSHOT io.ebean querybean-generator - 12.6.5 + 12.6.6-SNAPSHOT provided io.ebean kotlin-querybean-generator - 12.6.5 + 12.6.6-SNAPSHOT provided io.ebean ebean-test - 12.6.5 + 12.6.6-SNAPSHOT test io.ebean ebean-postgis - 12.6.5 + 12.6.6-SNAPSHOT io.ebean ebean-redis - 12.6.5 + 12.6.6-SNAPSHOT diff --git a/ebean-core-type/pom.xml b/ebean-core-type/pom.xml index 848d7b532..4c8d540d9 100644 --- a/ebean-core-type/pom.xml +++ b/ebean-core-type/pom.xml @@ -4,7 +4,7 @@ ebean-parent io.ebean - 12.6.5 + 12.6.6-SNAPSHOT ebean-core-type @@ -21,7 +21,7 @@ io.ebean ebean-api - 12.6.5 + 12.6.6-SNAPSHOT diff --git a/ebean-core/pom.xml b/ebean-core/pom.xml index 1d3924599..f937b3253 100644 --- a/ebean-core/pom.xml +++ b/ebean-core/pom.xml @@ -3,7 +3,7 @@ ebean-parent io.ebean - 12.6.5 + 12.6.6-SNAPSHOT ebean-core @@ -92,19 +92,19 @@ io.ebean ebean-api - 12.6.5 + 12.6.6-SNAPSHOT io.ebean ebean-core-type - 12.6.5 + 12.6.6-SNAPSHOT io.ebean ebean-externalmapping-api - 12.6.5 + 12.6.6-SNAPSHOT diff --git a/ebean-ddl-generator/pom.xml b/ebean-ddl-generator/pom.xml index 0d16ea5e1..9d728036b 100644 --- a/ebean-ddl-generator/pom.xml +++ b/ebean-ddl-generator/pom.xml @@ -4,7 +4,7 @@ ebean-parent io.ebean - 12.6.5 + 12.6.6-SNAPSHOT ebean ddl generation @@ -29,14 +29,14 @@ io.ebean ebean-core-type - 12.6.5 + 12.6.6-SNAPSHOT provided io.ebean ebean-core - 12.6.5 + 12.6.6-SNAPSHOT provided diff --git a/ebean-externalmapping-api/pom.xml b/ebean-externalmapping-api/pom.xml index 6f62e248b..a6b2bea29 100644 --- a/ebean-externalmapping-api/pom.xml +++ b/ebean-externalmapping-api/pom.xml @@ -4,7 +4,7 @@ ebean-parent io.ebean - 12.6.5 + 12.6.6-SNAPSHOT ebean external mapping api diff --git a/ebean-externalmapping-xml/pom.xml b/ebean-externalmapping-xml/pom.xml index 49fd29580..0800a6ead 100644 --- a/ebean-externalmapping-xml/pom.xml +++ b/ebean-externalmapping-xml/pom.xml @@ -4,7 +4,7 @@ ebean-parent io.ebean - 12.6.5 + 12.6.6-SNAPSHOT @@ -33,7 +33,7 @@ io.ebean ebean-externalmapping-api - 12.6.5 + 12.6.6-SNAPSHOT @@ -59,14 +59,14 @@ io.ebean ebean-core - 12.6.5 + 12.6.6-SNAPSHOT test io.ebean ebean-ddl-generator - 12.6.5 + 12.6.6-SNAPSHOT test diff --git a/ebean-postgis/pom.xml b/ebean-postgis/pom.xml index 99f677be8..33ec03cba 100644 --- a/ebean-postgis/pom.xml +++ b/ebean-postgis/pom.xml @@ -4,7 +4,7 @@ ebean-parent io.ebean - 12.6.5 + 12.6.6-SNAPSHOT ebean postgis @@ -24,7 +24,7 @@ io.ebean ebean-core - 12.6.5 + 12.6.6-SNAPSHOT provided @@ -75,7 +75,7 @@ io.ebean ebean-test - 12.6.5 + 12.6.6-SNAPSHOT test diff --git a/ebean-querybean/pom.xml b/ebean-querybean/pom.xml index b7fe8edce..1044f1beb 100644 --- a/ebean-querybean/pom.xml +++ b/ebean-querybean/pom.xml @@ -4,7 +4,7 @@ ebean-parent io.ebean - 12.6.5 + 12.6.6-SNAPSHOT @@ -27,7 +27,7 @@ io.ebean ebean-core - 12.6.5 + 12.6.6-SNAPSHOT provided @@ -67,14 +67,14 @@ io.ebean ebean-ddl-generator - 12.6.5 + 12.6.6-SNAPSHOT test io.ebean querybean-generator - 12.6.5 + 12.6.6-SNAPSHOT test diff --git a/ebean-redis/pom.xml b/ebean-redis/pom.xml index d45ddea50..24aec559a 100644 --- a/ebean-redis/pom.xml +++ b/ebean-redis/pom.xml @@ -4,7 +4,7 @@ ebean-parent io.ebean - 12.6.5 + 12.6.6-SNAPSHOT ebean-redis @@ -22,35 +22,35 @@ io.ebean ebean-api - 12.6.5 + 12.6.6-SNAPSHOT provided io.ebean ebean-core - 12.6.5 + 12.6.6-SNAPSHOT provided io.ebean ebean-querybean - 12.6.5 + 12.6.6-SNAPSHOT test io.ebean querybean-generator - 12.6.5 + 12.6.6-SNAPSHOT test io.ebean ebean-test - 12.6.5 + 12.6.6-SNAPSHOT test diff --git a/ebean-test/pom.xml b/ebean-test/pom.xml index 296890fae..a5b06f567 100644 --- a/ebean-test/pom.xml +++ b/ebean-test/pom.xml @@ -4,7 +4,7 @@ ebean-parent io.ebean - 12.6.5 + 12.6.6-SNAPSHOT @@ -43,14 +43,14 @@ io.ebean ebean-core - 12.6.5 + 12.6.6-SNAPSHOT provided io.ebean ebean-ddl-generator - 12.6.5 + 12.6.6-SNAPSHOT diff --git a/ebean/pom.xml b/ebean/pom.xml index 89d83f49b..717e60f74 100644 --- a/ebean/pom.xml +++ b/ebean/pom.xml @@ -4,7 +4,7 @@ ebean-parent io.ebean - 12.6.5 + 12.6.6-SNAPSHOT ebean composite @@ -22,34 +22,34 @@ io.ebean ebean-api - 12.6.5 + 12.6.6-SNAPSHOT io.ebean ebean-core - 12.6.5 + 12.6.6-SNAPSHOT io.ebean ebean-querybean - 12.6.5 + 12.6.6-SNAPSHOT io.ebean ebean-ddl-generator - 12.6.5 + 12.6.6-SNAPSHOT io.ebean ebean-autotune - 12.6.5 + 12.6.6-SNAPSHOT diff --git a/kotlin-querybean-generator/pom.xml b/kotlin-querybean-generator/pom.xml index 23c4d7da9..63019943e 100644 --- a/kotlin-querybean-generator/pom.xml +++ b/kotlin-querybean-generator/pom.xml @@ -4,7 +4,7 @@ ebean-parent io.ebean - 12.6.5 + 12.6.6-SNAPSHOT kotlin querybean generator @@ -29,7 +29,7 @@ io.ebean ebean-querybean - 12.6.5 + 12.6.6-SNAPSHOT test @@ -43,7 +43,7 @@ io.ebean ebean-core - 12.6.5 + 12.6.6-SNAPSHOT test @@ -64,7 +64,7 @@ io.ebean ebean-ddl-generator - 12.6.5 + 12.6.6-SNAPSHOT test diff --git a/pom.xml b/pom.xml index 615d86c69..c37643e30 100644 --- a/pom.xml +++ b/pom.xml @@ -9,7 +9,7 @@ io.ebean ebean-parent - 12.6.5 + 12.6.6-SNAPSHOT pom ebean parent diff --git a/querybean-generator/pom.xml b/querybean-generator/pom.xml index 6e4d5122b..76b38c320 100644 --- a/querybean-generator/pom.xml +++ b/querybean-generator/pom.xml @@ -4,7 +4,7 @@ ebean-parent io.ebean - 12.6.5 + 12.6.6-SNAPSHOT querybean generator From b7feb62ecd99d1794dab81c8012e21597526a756 Mon Sep 17 00:00:00 2001 From: Roland Praml Date: Mon, 11 Jan 2021 11:50:05 +0100 Subject: [PATCH 053/447] ADD: testcase for broken lazyload --- .../java/org/tests/cache/TestM2MCache.java | 78 +++++++++++++++++++ .../org/tests/model/cache/M2MCacheChild.java | 33 ++++++++ .../org/tests/model/cache/M2MCacheMaster.java | 53 +++++++++++++ 3 files changed, 164 insertions(+) create mode 100644 ebean-core/src/test/java/org/tests/cache/TestM2MCache.java create mode 100644 ebean-core/src/test/java/org/tests/model/cache/M2MCacheChild.java create mode 100644 ebean-core/src/test/java/org/tests/model/cache/M2MCacheMaster.java diff --git a/ebean-core/src/test/java/org/tests/cache/TestM2MCache.java b/ebean-core/src/test/java/org/tests/cache/TestM2MCache.java new file mode 100644 index 000000000..83cb402f1 --- /dev/null +++ b/ebean-core/src/test/java/org/tests/cache/TestM2MCache.java @@ -0,0 +1,78 @@ +package org.tests.cache; + +import static org.assertj.core.api.Assertions.assertThat; + +import org.junit.Test; +import org.tests.model.cache.M2MCacheChild; +import org.tests.model.cache.M2MCacheMaster; + +import io.ebean.BaseTestCase; +import io.ebean.DB; + +public class TestM2MCache extends BaseTestCase { + + @Test + public void testM2MWithCache() throws Exception { + M2MCacheChild cld = new M2MCacheChild(); + cld.setName("test"); + cld.setId(1); + DB.save(cld); + + M2MCacheMaster cfg = new M2MCacheMaster(); + cfg.setId(42); + cfg.getSet1().add(cld); + cfg.getSet2().add(cld); + DB.save(cfg); + + // find master and access set1 + set2. + // lazy load something from set1 + M2MCacheMaster cfg1 = DB.find(M2MCacheMaster.class, 42); + + cfg1.getSet1().size(); + cfg1.getSet2().size(); + assertThat(cfg1.getSet1().iterator().next().getName()).isEqualTo("test"); + + // do it again + cfg1 = DB.find(M2MCacheMaster.class, 42); + + cfg1.getSet1().size(); + cfg1.getSet2().size(); + + assertThat(cfg1.getSet1().iterator().next().getName()).isEqualTo("test"); + // do it again + cfg1 = DB.find(M2MCacheMaster.class, 42); + + cfg1.getSet1().size(); + cfg1.getSet2().size(); + + assertThat(cfg1.getSet1().iterator().next().getName()).isEqualTo("test"); + + } + + @Test + public void testM2MWithCacheMinimal() throws Exception { + M2MCacheChild cld = new M2MCacheChild(); + cld.setName("test"); + cld.setId(2); + DB.save(cld); + + M2MCacheMaster cfg = new M2MCacheMaster(); + cfg.setId(43); + cfg.getSet1().add(cld); + cfg.getSet2().add(cld); + DB.save(cfg); + + DB.find(M2MCacheMaster.class, 43); + + M2MCacheMaster cfg1 = DB.find(M2MCacheMaster.class, 43); + cfg1.getSet2().size(); + + cfg1 = DB.find(M2MCacheMaster.class, 43); + + cfg1.getSet1().size(); + cfg1.getSet2().size(); + + assertThat(cfg1.getSet1().iterator().next().getName()).isEqualTo("test"); + + } +} diff --git a/ebean-core/src/test/java/org/tests/model/cache/M2MCacheChild.java b/ebean-core/src/test/java/org/tests/model/cache/M2MCacheChild.java new file mode 100644 index 000000000..d40b26a63 --- /dev/null +++ b/ebean-core/src/test/java/org/tests/model/cache/M2MCacheChild.java @@ -0,0 +1,33 @@ +package org.tests.model.cache; + +import javax.persistence.Entity; +import javax.persistence.Id; + +import io.ebean.annotation.Cache; + +@Entity +@Cache(enableQueryCache = true, enableBeanCache = true) +public class M2MCacheChild { + + @Id + private Integer id; + + private String name; + + public Integer getId() { + return id; + } + + public void setId(Integer id) { + this.id = id; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + +} \ No newline at end of file diff --git a/ebean-core/src/test/java/org/tests/model/cache/M2MCacheMaster.java b/ebean-core/src/test/java/org/tests/model/cache/M2MCacheMaster.java new file mode 100644 index 000000000..5eedc2994 --- /dev/null +++ b/ebean-core/src/test/java/org/tests/model/cache/M2MCacheMaster.java @@ -0,0 +1,53 @@ +package org.tests.model.cache; + +import java.util.LinkedHashSet; +import java.util.Set; + +import javax.persistence.CascadeType; +import javax.persistence.Entity; +import javax.persistence.Id; +import javax.persistence.JoinTable; +import javax.persistence.ManyToMany; + +import io.ebean.annotation.Cache; + +@Entity +@Cache(enableQueryCache = true, enableBeanCache = true) +public class M2MCacheMaster { + + @Id + private Integer id; + + @ManyToMany(cascade = CascadeType.ALL) + @JoinTable(name = "m2mcache_set1") + private Set set1 = new LinkedHashSet<>(); + + @ManyToMany(cascade = CascadeType.ALL) + @JoinTable(name = "m2mcache_set2") + private Set set2 = new LinkedHashSet<>(); + + public Integer getId() { + return id; + } + + public void setId(Integer id) { + this.id = id; + } + + public Set getSet1() { + return set1; + } + + public void setSet1(Set set1) { + this.set1 = set1; + } + + public Set getSet2() { + return set2; + } + + public void setSet2(Set set2) { + this.set2 = set2; + } + +} From a4b8be61e3ce768f29ef31575dfe53351d0e67df Mon Sep 17 00:00:00 2001 From: Roland Praml Date: Mon, 11 Jan 2021 11:50:25 +0100 Subject: [PATCH 054/447] ADD: some suggestions/debug hints --- .../java/io/ebeaninternal/server/core/DefaultBeanLoader.java | 2 +- .../server/transaction/DefaultPersistenceContext.java | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/core/DefaultBeanLoader.java b/ebean-core/src/main/java/io/ebeaninternal/server/core/DefaultBeanLoader.java index 8100a0d7e..8140a0082 100644 --- a/ebean-core/src/main/java/io/ebeaninternal/server/core/DefaultBeanLoader.java +++ b/ebean-core/src/main/java/io/ebeaninternal/server/core/DefaultBeanLoader.java @@ -215,7 +215,7 @@ class DefaultBeanLoader { desc.contextPut(pc, id, bean); ebi.setPersistenceContext(pc); } - + // desc.contextPut(pc, id, bean); // this will fix one of the two tests boolean draft = desc.isDraftInstance(bean); if (embeddedOwnerIndex == -1) { diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/transaction/DefaultPersistenceContext.java b/ebean-core/src/main/java/io/ebeaninternal/server/transaction/DefaultPersistenceContext.java index df92246fa..cf239b8c4 100644 --- a/ebean-core/src/main/java/io/ebeaninternal/server/transaction/DefaultPersistenceContext.java +++ b/ebean-core/src/main/java/io/ebeaninternal/server/transaction/DefaultPersistenceContext.java @@ -296,6 +296,10 @@ public final class DefaultPersistenceContext implements PersistenceContext { } private void put(Object id, Object b) { + Object existing = map.get(id); + if (existing != null && existing != b) { + System.out.println("DEBUG: Overwriting object"); + } // else // will fix both tests map.put(id, b); } From ade36582a0f17d200ed0b0f178e55c9906017739 Mon Sep 17 00:00:00 2001 From: rob bygrave Date: Tue, 19 Jan 2021 22:37:15 +1300 Subject: [PATCH 055/447] #2144 - Fix for NPE via Wrong beans in PersistContext avoid proper lazy load --- .../ebeaninternal/server/core/DefaultBeanLoader.java | 2 -- .../ebeaninternal/server/deploy/BeanDescriptor.java | 11 +++++++++++ .../server/deploy/BeanDescriptorCacheHelp.java | 3 +-- .../server/transaction/DefaultPersistenceContext.java | 4 ---- 4 files changed, 12 insertions(+), 8 deletions(-) diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/core/DefaultBeanLoader.java b/ebean-core/src/main/java/io/ebeaninternal/server/core/DefaultBeanLoader.java index 8140a0082..34417ed14 100644 --- a/ebean-core/src/main/java/io/ebeaninternal/server/core/DefaultBeanLoader.java +++ b/ebean-core/src/main/java/io/ebeaninternal/server/core/DefaultBeanLoader.java @@ -215,7 +215,6 @@ class DefaultBeanLoader { desc.contextPut(pc, id, bean); ebi.setPersistenceContext(pc); } - // desc.contextPut(pc, id, bean); // this will fix one of the two tests boolean draft = desc.isDraftInstance(bean); if (embeddedOwnerIndex == -1) { @@ -245,7 +244,6 @@ class DefaultBeanLoader { // and put the data into the original bean query.setUsageProfiling(false); query.setPersistenceContext(pc); - query.setMode(mode); query.setId(id); diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/deploy/BeanDescriptor.java b/ebean-core/src/main/java/io/ebeaninternal/server/deploy/BeanDescriptor.java index bc2c87e66..c2c69b164 100644 --- a/ebean-core/src/main/java/io/ebeaninternal/server/deploy/BeanDescriptor.java +++ b/ebean-core/src/main/java/io/ebeaninternal/server/deploy/BeanDescriptor.java @@ -1872,6 +1872,17 @@ public class BeanDescriptor implements BeanType, STreeType { return query.setId(id).findOne(); } + /** + * Create a reference with a check for the bean in the persistence context. + */ + public EntityBean createReference(Boolean readOnly, Object id, PersistenceContext pc) { + Object refBean = contextGet(pc, id); + if (refBean == null) { + refBean = createReference(readOnly, false, id, pc); + } + return (EntityBean)refBean; + } + /** * Create a reference bean based on the id. */ diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/deploy/BeanDescriptorCacheHelp.java b/ebean-core/src/main/java/io/ebeaninternal/server/deploy/BeanDescriptorCacheHelp.java index 9f420de9e..70377a540 100644 --- a/ebean-core/src/main/java/io/ebeaninternal/server/deploy/BeanDescriptorCacheHelp.java +++ b/ebean-core/src/main/java/io/ebeaninternal/server/deploy/BeanDescriptorCacheHelp.java @@ -313,8 +313,7 @@ final class BeanDescriptorCacheHelp { List idList = entry.getIdList(); bc.checkEmptyLazyLoad(); for (Object id : idList) { - Object refBean = targetDescriptor.createReference(readOnly, false, id, persistenceContext); - many.add(bc, (EntityBean) refBean); + many.add(bc, targetDescriptor.createReference(readOnly, id, persistenceContext)); } return true; } diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/transaction/DefaultPersistenceContext.java b/ebean-core/src/main/java/io/ebeaninternal/server/transaction/DefaultPersistenceContext.java index cf239b8c4..df92246fa 100644 --- a/ebean-core/src/main/java/io/ebeaninternal/server/transaction/DefaultPersistenceContext.java +++ b/ebean-core/src/main/java/io/ebeaninternal/server/transaction/DefaultPersistenceContext.java @@ -296,10 +296,6 @@ public final class DefaultPersistenceContext implements PersistenceContext { } private void put(Object id, Object b) { - Object existing = map.get(id); - if (existing != null && existing != b) { - System.out.println("DEBUG: Overwriting object"); - } // else // will fix both tests map.put(id, b); } From 7f68b9d846d8b3c35234e294de54b0213b7b8282 Mon Sep 17 00:00:00 2001 From: rob bygrave Date: Tue, 19 Jan 2021 22:48:29 +1300 Subject: [PATCH 056/447] No effective change - tidy whitespace in BeanDescriptorCacheHelp --- .../deploy/BeanDescriptorCacheHelp.java | 40 ------------------- 1 file changed, 40 deletions(-) diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/deploy/BeanDescriptorCacheHelp.java b/ebean-core/src/main/java/io/ebeaninternal/server/deploy/BeanDescriptorCacheHelp.java index 70377a540..0b547b9a9 100644 --- a/ebean-core/src/main/java/io/ebeaninternal/server/deploy/BeanDescriptorCacheHelp.java +++ b/ebean-core/src/main/java/io/ebeaninternal/server/deploy/BeanDescriptorCacheHelp.java @@ -89,7 +89,6 @@ final class BeanDescriptorCacheHelp { BeanDescriptorCacheHelp(BeanDescriptor desc, SpiCacheManager cacheManager, CacheOptions cacheOptions, boolean cacheSharableBeans, BeanPropertyAssocOne[] propertiesOneImported) { - this.desc = desc; this.beanType = desc.rootBeanType; this.cacheName = beanType.getSimpleName(); @@ -99,7 +98,6 @@ final class BeanDescriptorCacheHelp { this.cacheSharableBeans = cacheSharableBeans; this.propertiesOneImported = propertiesOneImported; this.naturalKey = cacheOptions.getNaturalKey(); - if (!cacheOptions.isEnableQueryCache()) { this.queryCache = null; } else { @@ -133,7 +131,6 @@ final class BeanDescriptorCacheHelp { void deriveNotifyFlags() { cacheNotifyOnAll = (invalidateQueryCache || beanCache != null || queryCache != null); cacheNotifyOnDelete = !cacheNotifyOnAll && isNotifyOnDeletes(); - if (logger.isDebugEnabled()) { if (cacheNotifyOnAll || cacheNotifyOnDelete) { String notifyMode = cacheNotifyOnAll ? "All" : "Delete"; @@ -292,7 +289,6 @@ final class BeanDescriptorCacheHelp { * Try to load the bean collection from cache return true if successful. */ boolean manyPropLoad(BeanPropertyAssocMany many, BeanCollection bc, Object parentId, Boolean readOnly) { - if (many.isElementCollection()) { // held as part of the bean cache so skip return false; @@ -307,7 +303,6 @@ final class BeanDescriptorCacheHelp { EntityBean ownerBean = bc.getOwnerBean(); EntityBeanIntercept ebi = ownerBean._ebean_getIntercept(); PersistenceContext persistenceContext = ebi.getPersistenceContext(); - BeanDescriptor targetDescriptor = many.getTargetDescriptor(); List idList = entry.getIdList(); @@ -322,7 +317,6 @@ final class BeanDescriptorCacheHelp { * Put the beanCollection into the cache. */ void manyPropPut(BeanPropertyAssocMany many, Object details, Object parentId) { - if (many.isElementCollection()) { CachedBeanData data = (CachedBeanData) beanCache.get(parentId); if (data != null) { @@ -350,7 +344,6 @@ final class BeanDescriptorCacheHelp { } void cachePutManyIds(Object parentId, String manyName, CachedManyIds entry) { - ServerCache collectionIdsCache = cacheManager.getCollectionIdsCache(beanType, manyName); if (manyLog.isDebugEnabled()) { manyLog.debug(" PUT {}({}).{} - ids:{}", cacheName, parentId, manyName, entry); @@ -359,7 +352,6 @@ final class BeanDescriptorCacheHelp { } private CachedManyIds createManyIds(BeanPropertyAssocMany many, Object details) { - Collection actualDetails = BeanCollectionUtil.getActualDetails(details); if (actualDetails == null) { return null; @@ -377,7 +369,6 @@ final class BeanDescriptorCacheHelp { * Hit the bean cache with the given ids returning the hits. */ BeanCacheResult cacheIdLookup(PersistenceContext context, Collection ids) { - Set keys = new HashSet<>(ids.size()); for (Object id : ids) { keys.add(desc.cacheKey(id)); @@ -394,7 +385,6 @@ final class BeanDescriptorCacheHelp { T bean = convertToBean(entry.getKey(), false, context, cachedBeanData); result.add(bean, desc.getBeanId(bean)); } - return result; } @@ -402,14 +392,12 @@ final class BeanDescriptorCacheHelp { * Use natural keys to hit the bean cache and return resulting hits. */ BeanCacheResult naturalKeyLookup(PersistenceContext context, Set keys) { - if (context == null) { context = new DefaultPersistenceContext(); } // naturalKey -> Id map Map naturalKeyMap = naturalKeyCache.getAll(keys); - if (natLog.isTraceEnabled()) { natLog.trace(" MLOOKUP {}({}) - hits:{}", cacheName, keys, naturalKeyMap); } @@ -432,15 +420,12 @@ final class BeanDescriptorCacheHelp { } // process the hits into beans etc for (Map.Entry entry : beanDataMap.entrySet()) { - Object id = entry.getKey(); CachedBeanData cachedBeanData = (CachedBeanData) entry.getValue(); - T bean = convertToBean(id, false, context, cachedBeanData); Object naturalKey = reverseMap.get(id); result.add(bean, naturalKey); } - return result; } @@ -451,7 +436,6 @@ final class BeanDescriptorCacheHelp { if (context == null) { context = new DefaultPersistenceContext(); } - // Not using a loadContext for beans coming out of L2 cache // so that means no batch lazy loading for these beans EntityBean entityBean = (EntityBean) bean; @@ -521,7 +505,6 @@ final class BeanDescriptorCacheHelp { * Put a bean into the bean cache. */ void beanCachePut(EntityBean bean) { - if (desc.inheritInfo != null) { desc.descOf(bean.getClass()).cacheBeanPutDirect(bean); } else { @@ -530,7 +513,6 @@ final class BeanDescriptorCacheHelp { } void beanCachePutAllDirect(Collection beans) { - Map natKeys = null; if (naturalKey != null) { natKeys = new LinkedHashMap<>(); @@ -565,15 +547,12 @@ final class BeanDescriptorCacheHelp { * Put the bean into the bean cache. */ void beanCachePutDirect(EntityBean bean) { - CachedBeanData beanData = beanExtractData(desc, bean); - String key = desc.cacheKeyForBean(bean); if (beanLog.isDebugEnabled()) { beanLog.debug(" PUT {}({}) data:{}", cacheName, key, beanData); } getBeanCache().put(key, beanData); - if (naturalKey != null) { String naturalKey = calculateNaturalKey(beanData); if (naturalKey != null) { @@ -617,7 +596,6 @@ final class BeanDescriptorCacheHelp { * Return a bean from the bean cache. */ private T beanCacheGetInternal(String key, Boolean readOnly, PersistenceContext context) { - CachedBeanData data = (CachedBeanData) getBeanCache().get(key); if (data == null) { if (beanLog.isTraceEnabled()) { @@ -645,7 +623,6 @@ final class BeanDescriptorCacheHelp { return (T) bean; } } - return (T) loadBean(id, readOnly, data, context); } @@ -653,7 +630,6 @@ final class BeanDescriptorCacheHelp { * Load the entity bean taking into account inheritance. */ private EntityBean loadBean(Object id, Boolean readOnly, CachedBeanData data, PersistenceContext context) { - String discValue = data.getDiscValue(); if (discValue == null) { return loadBeanDirect(id, readOnly, data, context); @@ -673,7 +649,6 @@ final class BeanDescriptorCacheHelp { * Load the entity bean from cache data given this is the root bean type. */ EntityBean loadBeanDirect(Object id, Boolean readOnly, CachedBeanData data, PersistenceContext context) { - id = desc.convertId(id); EntityBean bean = null; if (context == null) { @@ -681,7 +656,6 @@ final class BeanDescriptorCacheHelp { } else { bean = (EntityBean) desc.contextGet(context, id); } - if (bean == null) { bean = desc.createEntityBean(); desc.setId(id, bean); @@ -697,7 +671,6 @@ final class BeanDescriptorCacheHelp { } CachedBeanDataToBean.load(desc, bean, data, context); - if (desc.isReadAuditing()) { desc.readAuditBean("l2", "", bean); } @@ -708,7 +681,6 @@ final class BeanDescriptorCacheHelp { * Load the embedded bean checking for inheritance. */ EntityBean embeddedBeanLoad(CachedBeanData data, PersistenceContext context) { - String discValue = data.getDiscValue(); if (discValue == null) { return embeddedBeanLoadDirect(data, context); @@ -745,25 +717,20 @@ final class BeanDescriptorCacheHelp { * Load a batch of entities from L2 bean cache checking the lazy loaded property is loaded. */ Set beanCacheLoadAll(List list, PersistenceContext context, int lazyLoadProperty, String propertyName) { - Map ebis = new HashMap<>(); for (EntityBeanIntercept ebi : list) { ebis.put(desc.cacheKeyForBean(ebi.getOwner()), ebi); } - Map hits = getBeanCache().getAll(ebis.keySet()); - if (beanLog.isTraceEnabled()) { beanLog.trace(" MLOAD {}({}) - got hits ({})", cacheName, ebis.keySet(), hits.size()); } Set loaded = new HashSet<>(); - Iterator> iterator = hits.entrySet().iterator(); while (iterator.hasNext()) { Map.Entry hit = iterator.next(); - Object key = hit.getKey(); EntityBeanIntercept ebi = ebis.remove(key); CachedBeanData cacheData = (CachedBeanData) hit.getValue(); @@ -773,7 +740,6 @@ final class BeanDescriptorCacheHelp { beanLog.trace(" load {}({}) - cache miss on property({})", cacheName, key, propertyName); } iterator.remove(); - } else { CachedBeanDataToBean.load(desc, ebi.getOwner(), cacheData, context); loaded.add(ebi); @@ -782,11 +748,9 @@ final class BeanDescriptorCacheHelp { } } } - if (!ebis.isEmpty() && beanLog.isTraceEnabled()) { beanLog.trace(" load {}({}) - cache miss", cacheName, ebis.keySet()); } - return loaded; } @@ -794,7 +758,6 @@ final class BeanDescriptorCacheHelp { * Returns true if it managed to populate/load the single bean from the cache. */ boolean beanCacheLoad(EntityBean bean, EntityBeanIntercept ebi, String key, PersistenceContext context) { - CachedBeanData cacheData = (CachedBeanData) getBeanCache().get(key); if (cacheData == null) { if (beanLog.isTraceEnabled()) { @@ -809,7 +772,6 @@ final class BeanDescriptorCacheHelp { } return false; } - CachedBeanDataToBean.load(desc, bean, cacheData, context); if (beanLog.isDebugEnabled()) { beanLog.debug(" LOAD {}({}) - hit", cacheName, key); @@ -931,7 +893,6 @@ final class BeanDescriptorCacheHelp { * Apply changes to the bean cache entry. */ void cacheBeanUpdate(String key, Map changes, boolean updateNaturalKey, long version) { - ServerCache cache = getBeanCache(); CachedBeanData existingData = (CachedBeanData) cache.get(key); if (existingData != null) { @@ -951,7 +912,6 @@ final class BeanDescriptorCacheHelp { } cache.put(key, newData); } - if (updateNaturalKey) { Object oldKey = calculateNaturalKey(existingData); if (oldKey != null) { From ee393c6485fc5376172be71649bf3a03fdebda8a Mon Sep 17 00:00:00 2001 From: Noemi Szemenyei Date: Tue, 19 Jan 2021 11:41:19 +0100 Subject: [PATCH 057/447] ADD: testcase for wrong lazyload with cache --- .../model/lazywithcache/ChildWithCache.java | 52 ++++++++++++++++++ .../tests/model/lazywithcache/ParentA.java | 46 ++++++++++++++++ .../tests/model/lazywithcache/ParentB.java | 36 +++++++++++++ .../TestWithCacheAndLazyLoad.java | 54 +++++++++++++++++++ 4 files changed, 188 insertions(+) create mode 100644 ebean-core/src/test/java/org/tests/model/lazywithcache/ChildWithCache.java create mode 100644 ebean-core/src/test/java/org/tests/model/lazywithcache/ParentA.java create mode 100644 ebean-core/src/test/java/org/tests/model/lazywithcache/ParentB.java create mode 100644 ebean-core/src/test/java/org/tests/model/lazywithcache/TestWithCacheAndLazyLoad.java diff --git a/ebean-core/src/test/java/org/tests/model/lazywithcache/ChildWithCache.java b/ebean-core/src/test/java/org/tests/model/lazywithcache/ChildWithCache.java new file mode 100644 index 000000000..d15c36d49 --- /dev/null +++ b/ebean-core/src/test/java/org/tests/model/lazywithcache/ChildWithCache.java @@ -0,0 +1,52 @@ +package org.tests.model.lazywithcache; + +import javax.persistence.Basic; +import javax.persistence.Entity; +import javax.persistence.FetchType; +import javax.persistence.Id; + +import io.ebean.annotation.Cache; + +/** + * Class with @Cache and lazy load property. + * + * @author Noemi Szemenyei, FOCONIS AG + * + */ +@Entity +@Cache(enableQueryCache = true) +public class ChildWithCache { + + @Id + Long id; + + String name; + + @Basic(fetch = FetchType.LAZY) + String address; + + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id = id; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public void setAddress(String address) { + this.address = address; + } + + public String getAddress() { + return address; + } + +} diff --git a/ebean-core/src/test/java/org/tests/model/lazywithcache/ParentA.java b/ebean-core/src/test/java/org/tests/model/lazywithcache/ParentA.java new file mode 100644 index 000000000..6a096113b --- /dev/null +++ b/ebean-core/src/test/java/org/tests/model/lazywithcache/ParentA.java @@ -0,0 +1,46 @@ +package org.tests.model.lazywithcache; + +import javax.persistence.Entity; +import javax.persistence.Id; +import javax.persistence.ManyToOne; + +/** + * Parent class with ChildWithCache. + * + */ +@Entity +public class ParentA { + + @Id + Long id; + + @ManyToOne(optional = true) + ChildWithCache child; + + String name; + + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id = id; + } + + public ChildWithCache getChild() { + return child; + } + + public void setChild(ChildWithCache child) { + this.child = child; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + +} diff --git a/ebean-core/src/test/java/org/tests/model/lazywithcache/ParentB.java b/ebean-core/src/test/java/org/tests/model/lazywithcache/ParentB.java new file mode 100644 index 000000000..521d3d52b --- /dev/null +++ b/ebean-core/src/test/java/org/tests/model/lazywithcache/ParentB.java @@ -0,0 +1,36 @@ +package org.tests.model.lazywithcache; + +import javax.persistence.Entity; +import javax.persistence.Id; +import javax.persistence.ManyToOne; + +/** + * Parent class with ChildWithCache. + * + */ +@Entity +public class ParentB { + + @Id + Long id; + + @ManyToOne(optional = true) + ChildWithCache child; + + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id = id; + } + + public ChildWithCache getChild() { + return child; + } + + public void setChild(ChildWithCache child) { + this.child = child; + } + +} diff --git a/ebean-core/src/test/java/org/tests/model/lazywithcache/TestWithCacheAndLazyLoad.java b/ebean-core/src/test/java/org/tests/model/lazywithcache/TestWithCacheAndLazyLoad.java new file mode 100644 index 000000000..e245fea79 --- /dev/null +++ b/ebean-core/src/test/java/org/tests/model/lazywithcache/TestWithCacheAndLazyLoad.java @@ -0,0 +1,54 @@ +package org.tests.model.lazywithcache; + +import org.junit.Test; + +import io.ebean.BaseTestCase; +import io.ebean.DB; + +import static org.assertj.core.api.Assertions.assertThat; + +/** + * Test with bean cache and lazy loaded property. + * + * @author Noemi Szemenyei, FOCONIS AG + * + */ + +public class TestWithCacheAndLazyLoad extends BaseTestCase{ + + @Test + public void testGetters() { + + ChildWithCache child = new ChildWithCache(); + child.setId(1L); + child.setName("Child With Cache"); + child.setAddress("Address"); + DB.save(child); + + ParentA parentA = new ParentA(); + parentA.setId(1L); + parentA.setName("Parent A"); + parentA.setChild(child); + DB.save(parentA); + + ParentB parentB = new ParentB(); + parentB.setId(1L); + parentB.setChild(child); + DB.save(parentB); + + + ParentA tempA = DB.find(ParentA.class, 1L); + tempA.getChild().getName(); //load name + + ParentB tempB = DB.find(ParentB.class, 1L); + + ChildWithCache temp = tempB.getChild(); + //if the next line is commented out, the test passes + temp.getName(); //load name from cache --> ebean_intercept.loadedFromCache = true + + String tempLazyProp = temp.getAddress(); + assertThat(tempLazyProp).isEqualTo("Address"); + + } + +} From 0c1657fef586d9c8fa58a550c853fc58873f6e1a Mon Sep 17 00:00:00 2001 From: rob bygrave Date: Wed, 20 Jan 2021 00:00:27 +1300 Subject: [PATCH 058/447] #2145 - SoftDelete predicate missing on join to ManyToOne supporting predicate expression --- .../server/deploy/BeanPropertyAssoc.java | 6 ++++++ .../server/query/STreePropertyAssoc.java | 9 ++++++++ .../server/query/SqlTreeBuilder.java | 18 ++++++---------- .../server/query/SqlTreeNodeExtraJoin.java | 13 ++++++------ .../tests/softdelete/TestSoftDeleteBasic.java | 21 +++++++++++++++++++ 5 files changed, 48 insertions(+), 19 deletions(-) diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/deploy/BeanPropertyAssoc.java b/ebean-core/src/main/java/io/ebeaninternal/server/deploy/BeanPropertyAssoc.java index f5f3a8a4a..a2a091ef6 100644 --- a/ebean-core/src/main/java/io/ebeaninternal/server/deploy/BeanPropertyAssoc.java +++ b/ebean-core/src/main/java/io/ebeaninternal/server/deploy/BeanPropertyAssoc.java @@ -262,10 +262,16 @@ public abstract class BeanPropertyAssoc extends BeanProperty implements STree /** * Return true if the target side has soft delete. */ + @Override public boolean isTargetSoftDelete() { return targetDescriptor.isSoftDelete(); } + @Override + public String getSoftDeletePredicate(String tableAlias) { + return targetDescriptor.getSoftDeletePredicate(tableAlias); + } + /** * Return true if REFRESH should cascade. */ diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/query/STreePropertyAssoc.java b/ebean-core/src/main/java/io/ebeaninternal/server/query/STreePropertyAssoc.java index 1213d0b55..4f28bf803 100644 --- a/ebean-core/src/main/java/io/ebeaninternal/server/query/STreePropertyAssoc.java +++ b/ebean-core/src/main/java/io/ebeaninternal/server/query/STreePropertyAssoc.java @@ -36,4 +36,13 @@ public interface STreePropertyAssoc extends STreeProperty { */ void setValue(EntityBean parentBean, Object contextBean); + /** + * Return true if the associated type has soft delete. + */ + boolean isTargetSoftDelete(); + + /** + * Return the soft delete predicate. + */ + String getSoftDeletePredicate(String tableAlias); } diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/query/SqlTreeBuilder.java b/ebean-core/src/main/java/io/ebeaninternal/server/query/SqlTreeBuilder.java index bcd8b70a4..bae70396f 100644 --- a/ebean-core/src/main/java/io/ebeaninternal/server/query/SqlTreeBuilder.java +++ b/ebean-core/src/main/java/io/ebeaninternal/server/query/SqlTreeBuilder.java @@ -362,7 +362,7 @@ public final class SqlTreeBuilder { // look for predicateIncludes that are not in selectIncludes and add // them as extra joins to the query - IncludesDistiller extraJoinDistill = new IncludesDistiller(desc, selectIncludes, predicateIncludes); + IncludesDistiller extraJoinDistill = new IncludesDistiller(desc, selectIncludes, predicateIncludes, temporalMode); Collection extraJoins = extraJoinDistill.getExtraJoinRootNodes(); if (!extraJoins.isEmpty()) { @@ -592,26 +592,20 @@ public final class SqlTreeBuilder { */ private static class IncludesDistiller { + private final STreeType desc; private final Set selectIncludes; private final Set predicateIncludes; + private final SpiQuery.TemporalMode temporalMode; - /** - * Contains the 'root' extra joins. We only return the roots back. - */ private final Map joinRegister = new HashMap<>(); - - /** - * Register of all the extra join nodes. - */ private final Map rootRegister = new HashMap<>(); - private final STreeType desc; - private IncludesDistiller(STreeType desc, Set selectIncludes, - Set predicateIncludes) { + Set predicateIncludes, SpiQuery.TemporalMode temporalMode) { this.desc = desc; this.selectIncludes = selectIncludes; this.predicateIncludes = predicateIncludes; + this.temporalMode = temporalMode; } /** @@ -666,7 +660,7 @@ public final class SqlTreeBuilder { if (extra == null) { return null; } else { - SqlTreeNodeExtraJoin extraJoin = new SqlTreeNodeExtraJoin(propertyName, extra.getProperty(), extra.isContainsMany()); + SqlTreeNodeExtraJoin extraJoin = new SqlTreeNodeExtraJoin(propertyName, extra.getProperty(), extra.isContainsMany(), temporalMode); joinRegister.put(propertyName, extraJoin); return extraJoin; } diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/query/SqlTreeNodeExtraJoin.java b/ebean-core/src/main/java/io/ebeaninternal/server/query/SqlTreeNodeExtraJoin.java index 08e5601fc..de1cff32b 100644 --- a/ebean-core/src/main/java/io/ebeaninternal/server/query/SqlTreeNodeExtraJoin.java +++ b/ebean-core/src/main/java/io/ebeaninternal/server/query/SqlTreeNodeExtraJoin.java @@ -24,19 +24,17 @@ import java.util.Set; class SqlTreeNodeExtraJoin implements SqlTreeNode { private final STreePropertyAssoc assocBeanProperty; - + private final SpiQuery.TemporalMode temporalMode; private final String prefix; - private final boolean manyJoin; - private final boolean pathContainsMany; - private List children; - SqlTreeNodeExtraJoin(String prefix, STreePropertyAssoc assocBeanProperty, boolean pathContainsMany) { + SqlTreeNodeExtraJoin(String prefix, STreePropertyAssoc assocBeanProperty, boolean pathContainsMany, SpiQuery.TemporalMode temporalMode) { this.prefix = prefix; this.assocBeanProperty = assocBeanProperty; this.pathContainsMany = pathContainsMany; + this.temporalMode = temporalMode; this.manyJoin = assocBeanProperty instanceof STreePropertyAssocMany; } @@ -144,15 +142,16 @@ class SqlTreeNodeExtraJoin implements SqlTreeNode { assocBeanProperty.appendFrom(ctx, joinType); } joinType = assocBeanProperty.addJoin(joinType, prefix, ctx); + if (assocBeanProperty.isTargetSoftDelete() && temporalMode != SpiQuery.TemporalMode.SOFT_DELETED) { + ctx.append(" and ").append(assocBeanProperty.getSoftDeletePredicate(ctx.getTableAlias(prefix))); + } } if (children != null) { - if (manyJoin || pathContainsMany) { // if AUTO then make all descendants use OUTER JOIN joinType = joinType.autoToOuter(); } - for (SqlTreeNodeExtraJoin child : children) { child.appendFrom(ctx, joinType); } diff --git a/ebean-core/src/test/java/org/tests/softdelete/TestSoftDeleteBasic.java b/ebean-core/src/test/java/org/tests/softdelete/TestSoftDeleteBasic.java index 590585404..1dfec06c4 100644 --- a/ebean-core/src/test/java/org/tests/softdelete/TestSoftDeleteBasic.java +++ b/ebean-core/src/test/java/org/tests/softdelete/TestSoftDeleteBasic.java @@ -137,6 +137,27 @@ public class TestSoftDeleteBasic extends BaseTestCase { query.delete(); } + @Test + public void testFindChild_joinParent() { + EBasicSoftDelete bean = new EBasicSoftDelete(); + bean.setName("softDelParent_withChild"); + bean.addChild("child1", 10); + + DB.save(bean); + + Query query = DB.find(EBasicSDChild.class) + .where() + .eq("owner.name", "softDelParent_withChild") + .query(); + + List list = query.findList(); + assertSql(query).contains("join ebasic_soft_delete t1 on t1.id = t0.owner_id and t1.deleted ="); + assertThat(list).hasSize(1); + + // Cleanup created entity + DB.deletePermanent(bean); + } + @Test public void testFindSoftDeletedList() { EBasicSoftDelete bean = new EBasicSoftDelete(); From 9ccd1b1b2763747d078347d7d89074bfe1082cc9 Mon Sep 17 00:00:00 2001 From: rob bygrave Date: Wed, 20 Jan 2021 00:10:09 +1300 Subject: [PATCH 059/447] No effective change - tidy whitespace in SqlTreeBuilder and SqlTreeNodeExtraJoin --- .../server/query/SqlTreeBuilder.java | 45 +------------------ .../server/query/SqlTreeNodeExtraJoin.java | 2 - 2 files changed, 1 insertion(+), 46 deletions(-) diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/query/SqlTreeBuilder.java b/ebean-core/src/main/java/io/ebeaninternal/server/query/SqlTreeBuilder.java index bae70396f..d9386ed9b 100644 --- a/ebean-core/src/main/java/io/ebeaninternal/server/query/SqlTreeBuilder.java +++ b/ebean-core/src/main/java/io/ebeaninternal/server/query/SqlTreeBuilder.java @@ -74,7 +74,6 @@ public final class SqlTreeBuilder { * Construct for RawSql query. */ SqlTreeBuilder(OrmQueryRequest request, CQueryPredicates predicates, OrmQueryDetail queryDetail, boolean rawNoId) { - this.rawSql = true; this.desc = request.getBeanDescriptor(); this.rawNoId = rawNoId; @@ -97,7 +96,6 @@ public final class SqlTreeBuilder { * to the root node. */ SqlTreeBuilder(String columnAliasPrefix, CQueryBuilder builder, OrmQueryRequest request, CQueryPredicates predicates) { - this.rawSql = false; this.rawNoId = false; this.desc = request.getBeanDescriptor(); @@ -108,11 +106,9 @@ public final class SqlTreeBuilder { this.includeJoin = query.getM2mIncludeJoin(); this.manyWhereJoins = query.getManyWhereJoins(); this.queryDetail = query.getDetail(); - this.predicates = predicates; this.alias = new SqlTreeAlias(request.getBaseTableAlias(), temporalMode); this.distinctOnPlatform = builder.isPlatformDistinctOn(); - String fromForUpdate = builder.fromForUpdate(query); CQueryHistorySupport historySupport = builder.getHistorySupport(query); CQueryDraftSupport draftSupport = builder.getDraftSupport(query); @@ -124,10 +120,8 @@ public final class SqlTreeBuilder { * Build based on the includes and using the BeanJoinTree. */ public SqlTree build() { - // build the appropriate chain of SelectAdapter's buildRoot(desc); - // build the actual String String distinctOn = null; String selectSql = null; @@ -149,7 +143,6 @@ public final class SqlTreeBuilder { } private String buildSelectClause() { - if (rawSql) { return "Not Used"; } @@ -158,7 +151,6 @@ public final class SqlTreeBuilder { } private String buildGroupByClause() { - if (rawSql || !rootNode.isAggregation()) { return null; } @@ -168,7 +160,6 @@ public final class SqlTreeBuilder { } private String buildDistinctOn() { - if (rawSql || !distinctOnPlatform || !sqlDistinct || Type.COUNT == query.getType()) { return null; } @@ -207,7 +198,6 @@ public final class SqlTreeBuilder { } private String buildWhereClause() { - if (rawSql) { return "Not Used"; } @@ -216,7 +206,6 @@ public final class SqlTreeBuilder { } private String buildFromClause() { - if (rawSql) { return "Not Used"; } @@ -225,17 +214,13 @@ public final class SqlTreeBuilder { } private void buildRoot(STreeType desc) { - rootNode = buildSelectChain(null, null, desc, null); - if (!rawSql) { alias.addJoin(queryDetail.getFetchPaths(), desc); alias.addJoin(predicates.getPredicateIncludes(), desc); alias.addManyWhereJoins(manyWhereJoins.getPropertyNames()); - // build set of table alias alias.buildAlias(); - predicates.parseTableAlias(alias); } } @@ -246,9 +231,7 @@ public final class SqlTreeBuilder { */ private SqlTreeNode buildSelectChain(String prefix, STreePropertyAssoc prop, STreeType desc, List joinList) { - List myJoinList = new ArrayList<>(); - List extraProps = new ArrayList<>(); for (STreePropertyAssocOne one : desc.propsOne()) { String propPrefix = SplitName.add(prefix, one.getName()); @@ -295,7 +278,6 @@ public final class SqlTreeBuilder { *

*/ private void addManyWhereJoins(List myJoinList) { - Collection includes = manyWhereJoins.getPropertyJoins(); for (PropertyJoin joinProp : includes) { STreePropertyAssoc beanProperty = (STreePropertyAssoc) desc.findPropertyFromPath(joinProp.getProperty()); @@ -311,7 +293,6 @@ public final class SqlTreeBuilder { } private SqlTreeNode buildNode(String prefix, STreePropertyAssoc prop, STreeType desc, List myList, SqlTreeProperties props) { - if (prefix == null) { buildExtraJoins(desc, myList); @@ -340,13 +321,10 @@ public final class SqlTreeBuilder { * already in select clause. */ private void buildExtraJoins(STreeType desc, List myList) { - if (rawSql) { return; } - Set predicateIncludes = predicates.getPredicateIncludes(); - if (predicateIncludes == null) { return; } @@ -363,7 +341,6 @@ public final class SqlTreeBuilder { // look for predicateIncludes that are not in selectIncludes and add // them as extra joins to the query IncludesDistiller extraJoinDistill = new IncludesDistiller(desc, selectIncludes, predicateIncludes, temporalMode); - Collection extraJoins = extraJoinDistill.getExtraJoinRootNodes(); if (!extraJoins.isEmpty()) { // add extra joins required to support predicates @@ -389,7 +366,6 @@ public final class SqlTreeBuilder { *

*/ private void addPropertyToSubQuery(SqlTreeProperties selectProps, STreeType desc, String propName) { - STreeProperty p = desc.findProperty(propName); if (p == null) { logger.error("property [" + propName + "]not found on " + desc + " for query - excluding it."); @@ -402,13 +378,10 @@ public final class SqlTreeBuilder { p = ((STreePropertyAssoc) p).target().findProperty(name); } } - selectProps.add(p); } - private void addProperty(SqlTreeProperties selectProps, STreeType desc, - OrmQueryProperties queryProps, String propName) { - + private void addProperty(SqlTreeProperties selectProps, STreeType desc, OrmQueryProperties queryProps, String propName) { if (subQuery) { addPropertyToSubQuery(selectProps, desc, propName); return; @@ -471,7 +444,6 @@ public final class SqlTreeBuilder { } private SqlTreeProperties getBaseSelectPartial(STreeType desc, OrmQueryProperties queryProps) { - SqlTreeProperties selectProps = new SqlTreeProperties(); // add properties in the order in which they appear // in the query. Gives predictable sql/properties for @@ -502,7 +474,6 @@ public final class SqlTreeBuilder { } private SqlTreeProperties getBaseSelect(STreeType desc, OrmQueryProperties queryProps) { - boolean partial = queryProps != null && !queryProps.allProperties(); if (partial) { return getBaseSelectPartial(desc, queryProps); @@ -541,13 +512,10 @@ public final class SqlTreeBuilder { * Return true if this many node should be included in the query. */ private boolean isIncludeMany(String propName, STreePropertyAssocMany manyProp) { - if (queryDetail.isJoinsEmpty()) { return false; } - if (queryDetail.includesPath(propName)) { - if (manyProperty != null) { // only one many associated allowed to be included in fetch if (logger.isDebugEnabled()) { @@ -555,7 +523,6 @@ public final class SqlTreeBuilder { } return false; } - manyProperty = manyProp; return true; } @@ -571,7 +538,6 @@ public final class SqlTreeBuilder { *

*/ private boolean isIncludeBean(String prefix) { - if (queryDetail.includesPath(prefix)) { // explicitly included String[] splitNames = SplitName.split(prefix); @@ -617,26 +583,21 @@ public final class SqlTreeBuilder { *

*/ private Collection getExtraJoinRootNodes() { - String[] extras = findExtras(); if (extras.length == 0) { return rootRegister.values(); } - // sort so we process only getting the leaves // excluding nodes between root and the leaf Arrays.sort(extras); - // reverse order so get the leaves first... for (String extra : extras) { createExtraJoin(extra); } - return rootRegister.values(); } private void createExtraJoin(String includeProp) { - SqlTreeNodeExtraJoin extraJoin = createJoinLeaf(includeProp); if (extraJoin != null) { // add the extra join... @@ -644,7 +605,6 @@ public final class SqlTreeBuilder { // find root of this extra join... linking back to the // parents (creating the tree) as it goes. SqlTreeNodeExtraJoin root = findExtraJoinRoot(includeProp, extraJoin); - // register the root because these are the only ones we // return back. rootRegister.put(root.getName(), root); @@ -655,7 +615,6 @@ public final class SqlTreeBuilder { * Create a SqlTreeNodeExtraJoin, register and return it. */ private SqlTreeNodeExtraJoin createJoinLeaf(String propertyName) { - ExtraJoin extra = desc.extraJoin(propertyName); if (extra == null) { return null; @@ -707,9 +666,7 @@ public final class SqlTreeBuilder { * by the select. */ private String[] findExtras() { - List extras = new ArrayList<>(); - for (String predProp : predicateIncludes) { if (!selectIncludes.contains(predProp)) { extras.add(predProp); diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/query/SqlTreeNodeExtraJoin.java b/ebean-core/src/main/java/io/ebeaninternal/server/query/SqlTreeNodeExtraJoin.java index de1cff32b..fbab8e6b1 100644 --- a/ebean-core/src/main/java/io/ebeaninternal/server/query/SqlTreeNodeExtraJoin.java +++ b/ebean-core/src/main/java/io/ebeaninternal/server/query/SqlTreeNodeExtraJoin.java @@ -111,9 +111,7 @@ class SqlTreeNodeExtraJoin implements SqlTreeNode { @Override public void appendFrom(DbSqlContext ctx, SqlJoinType joinType) { - boolean manyToMany = false; - if (assocBeanProperty instanceof STreePropertyAssocMany) { STreePropertyAssocMany manyProp = (STreePropertyAssocMany) assocBeanProperty; if (manyProp.hasJoinTable()) { From 4408eb618aba6e71b679d198ad282bfb8f0b2a86 Mon Sep 17 00:00:00 2001 From: Robin Bygrave Date: Wed, 20 Jan 2021 17:11:07 +1300 Subject: [PATCH 060/447] No change - update test only - TestHistoryOneToMany with wait for when run on windows --- .../model/history/TestHistoryOneToMany.java | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/ebean-core/src/test/java/org/tests/model/history/TestHistoryOneToMany.java b/ebean-core/src/test/java/org/tests/model/history/TestHistoryOneToMany.java index 604a5d5e9..75e0bc871 100644 --- a/ebean-core/src/test/java/org/tests/model/history/TestHistoryOneToMany.java +++ b/ebean-core/src/test/java/org/tests/model/history/TestHistoryOneToMany.java @@ -1,7 +1,7 @@ package org.tests.model.history; import io.ebean.BaseTestCase; -import io.ebean.Ebean; +import io.ebean.DB; import io.ebean.annotation.IgnorePlatform; import io.ebean.annotation.Platform; import org.ebeantest.LoggedSqlCollector; @@ -16,7 +16,7 @@ public class TestHistoryOneToMany extends BaseTestCase { @IgnorePlatform(Platform.ORACLE) @Test - public void test() { + public void test() throws InterruptedException { HiTOne one = new HiTOne("one"); @@ -37,11 +37,12 @@ public class TestHistoryOneToMany extends BaseTestCase { one.getTwos().add(_22); - Ebean.save(one); + DB.save(one); + Thread.sleep(20); LoggedSqlCollector.start(); - List list = Ebean.find(HiTOne.class) + List list = DB.find(HiTOne.class) .fetch("twos") .fetch("twos.threes") .where().ilike("name", "on%") @@ -51,15 +52,14 @@ public class TestHistoryOneToMany extends BaseTestCase { List sql = LoggedSqlCollector.stop(); + assertThat(list).hasSize(1); + assertThat(list.get(0).getTwos()).hasSize(2); + assertThat(list.get(0).getTwos().get(0).getThrees()).hasSize(3); + if (isH2()) { assertThat(sql).hasSize(2); assertSql(sql.get(0)).contains("from hi_tone_with_history t0 where (t0.sys_period_start <= ? and (t0.sys_period_end is null or t0.sys_period_end > ?)) and lower(t0.name) like ? escape'' limit 10"); assertSql(sql.get(1)).contains("from hi_ttwo_with_history t0 left join hi_tthree_with_history t1 on t1.hi_ttwo_id = t0.id and (t1.sys_period_start <= ? and (t1.sys_period_end is null or t1.sys_period_end > ?)) where (t0.sys_period_start <= ? and (t0.sys_period_end is null or t0.sys_period_end > ?)) and (t0.hi_tone_id) in (?)"); } - - assertThat(list).hasSize(1); - assertThat(list.get(0).getTwos()).hasSize(2); - assertThat(list.get(0).getTwos().get(0).getThrees()).hasSize(3); - } } From 99bb55efa0fb2636731447a2d75cbe5c16934ed0 Mon Sep 17 00:00:00 2001 From: Robin Bygrave Date: Wed, 20 Jan 2021 17:22:00 +1300 Subject: [PATCH 061/447] No change - update ebean-test test configuration only for windows --- .../src/test/resources/application-test.yaml | 62 ++----------------- .../src/test/resources/docker-run.properties | 21 ------- 2 files changed, 5 insertions(+), 78 deletions(-) delete mode 100644 ebean-test/src/test/resources/docker-run.properties diff --git a/ebean-test/src/test/resources/application-test.yaml b/ebean-test/src/test/resources/application-test.yaml index 89eb92456..7ad9e2dd5 100644 --- a/ebean-test/src/test/resources/application-test.yaml +++ b/ebean-test/src/test/resources/application-test.yaml @@ -1,22 +1,18 @@ datasource: db: username: sa - password: + password: sa databaseUrl: jdbc:h2:mem:tests pg: username: sa - password: + password: sa databaseUrl: jdbc:h2:mem:tests ebean: -# migration: -# run: false -# -# ddl: -# generate: true -# run: true -## createOnly: true + ddl: + generate: true + run: true docstore: url: http://127.0.0.1:9200 @@ -26,57 +22,9 @@ ebean: # useDocker: true elasticVersion: 5.6 -# create: true - test: redis: latest platform: mariadb #, postgres, mysql, mariadb, oracle, sqlserver, hana # useDocker: false -# dockerMode: dropCreate ddlMode: dropCreate # none | dropCreate | create | migrations dbName: junk - postgres: - version: 9.6 - extensions: pgcryto, hstore - username: asd - password: test - url: asd - driver: asd - - - -docker: - postgres: -# port: 6432 - version: 9.6 - extensions: pgcryto, hstore - username: ${test_db} - password: test - databaseUrl: jdbc:postgresql://localhost:6432/${test_db} - databaseDriver: org.postgresql.Driver - - mysql: - version: 5.6 - username: ${test_db} - password: test - databaseUrl: jdbc:mysql://localhost:4306/${test_db} - databaseDriver: com.mysql.jdbc.Driver - - sqlserver: - version: 2017-CE - username: ${test_db} - password: SqlS3rv#r - databaseUrl: jdbc:sqlserver://localhost:1433;databaseName=${test_db} - databaseDriver: com.microsoft.sqlserver.jdbc.SQLServerDriver - - oracle: - username: ${test_db} - password: test - databaseUrl: jdbc:oracle:thin:@127.0.0.1:1521:XE - databaseDriver: oracle.jdbc.driver.OracleDriver - - hana: - username: ${test_db} - password: HXEHana1 - databaseUrl: jdbc:sap://localhost:39017/?databaseName=HXE - databaseDriver: com.sap.db.jdbc.Driver diff --git a/ebean-test/src/test/resources/docker-run.properties b/ebean-test/src/test/resources/docker-run.properties deleted file mode 100644 index 275a4c76e..000000000 --- a/ebean-test/src/test/resources/docker-run.properties +++ /dev/null @@ -1,21 +0,0 @@ -postgres.version=9.6 -postgres.dbName=test_db -postgres.dbUser=test_user -postgres.dbPassword=test -postgres.dbExtensions=hstore,pgcrypto - - -sqlserver.version=2017-CU2 -#sqlserver.port=1433 -#sqlserver.dbName=test_db -#sqlserver.dbUser=test_user -#sqlserver.dbPassword=SqlS3rv#r - - -hana.version=2.00.033.00.20180925.2 -hana.port=39117 -hana.instanceNumber=91 -hana.passwordsUrl=file:///hana/mounts/passwords.json -hana.mountsDirectory=/data/dockermounts -# agree to the SAP license (https://www.sap.com/docs/download/cmp/2016/06/sap-hana-express-dev-agmt-and-exhibit.pdf) -hana.agreeToSapLicense=false \ No newline at end of file From 9dd28d88796331dbdcb0abb8515dafcd7e92d122 Mon Sep 17 00:00:00 2001 From: rob bygrave Date: Wed, 20 Jan 2021 21:10:49 +1300 Subject: [PATCH 062/447] #2146 - Fix for Cache with lazy load doesnt work When the list is empty() it has already been loaded and loading should skip the l2 cache --- .../server/loadcontext/DLoadBeanContext.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/loadcontext/DLoadBeanContext.java b/ebean-core/src/main/java/io/ebeaninternal/server/loadcontext/DLoadBeanContext.java index 6c796501f..454fd6dac 100644 --- a/ebean-core/src/main/java/io/ebeaninternal/server/loadcontext/DLoadBeanContext.java +++ b/ebean-core/src/main/java/io/ebeaninternal/server/loadcontext/DLoadBeanContext.java @@ -56,7 +56,6 @@ class DLoadBeanContext extends DLoadBaseContext implements LoadBeanContext { } private void configureQuery(SpiQuery query, String lazyLoadProperty) { - if (cache) { query.setBeanCacheMode(CacheMode.ON); } @@ -70,7 +69,6 @@ class DLoadBeanContext extends DLoadBaseContext implements LoadBeanContext { } protected void register(EntityBeanIntercept ebi) { - if (currentBuffer.isFull()) { currentBuffer = createBuffer(secondaryBatchSize); } @@ -198,8 +196,10 @@ class DLoadBeanContext extends DLoadBaseContext implements LoadBeanContext { // lazy load property was a Many return; } - - if (context.hitCache) { + if (list.isEmpty()) { + // re-add to the batch and lazy load from DB skipping l2 cache + list.add(ebi); + } else if (context.hitCache) { Set hits = context.desc.cacheBeanLoadAll(list, persistenceContext, ebi.getLazyLoadPropertyIndex(), ebi.getLazyLoadProperty()); list.removeAll(hits); if (list.isEmpty() || hits.contains(ebi)) { From f28f5c9a019d9e075194b70f3df172931e5d6fcf Mon Sep 17 00:00:00 2001 From: rob bygrave Date: Wed, 20 Jan 2021 21:37:29 +1300 Subject: [PATCH 063/447] #2146 - no change - Tidy test only TestWithCacheAndLazyLoad --- .../TestWithCacheAndLazyLoad.java | 28 +++++++++---------- 1 file changed, 13 insertions(+), 15 deletions(-) diff --git a/ebean-core/src/test/java/org/tests/model/lazywithcache/TestWithCacheAndLazyLoad.java b/ebean-core/src/test/java/org/tests/model/lazywithcache/TestWithCacheAndLazyLoad.java index e245fea79..ce5d35b26 100644 --- a/ebean-core/src/test/java/org/tests/model/lazywithcache/TestWithCacheAndLazyLoad.java +++ b/ebean-core/src/test/java/org/tests/model/lazywithcache/TestWithCacheAndLazyLoad.java @@ -13,42 +13,40 @@ import static org.assertj.core.api.Assertions.assertThat; * @author Noemi Szemenyei, FOCONIS AG * */ - public class TestWithCacheAndLazyLoad extends BaseTestCase{ @Test public void testGetters() { - + ChildWithCache child = new ChildWithCache(); child.setId(1L); child.setName("Child With Cache"); child.setAddress("Address"); DB.save(child); - + ParentA parentA = new ParentA(); parentA.setId(1L); parentA.setName("Parent A"); parentA.setChild(child); DB.save(parentA); - + ParentB parentB = new ParentB(); parentB.setId(1L); parentB.setChild(child); DB.save(parentB); - - + + ParentA tempA = DB.find(ParentA.class, 1L); - tempA.getChild().getName(); //load name - + tempA.getChild().getName(); // load name + ParentB tempB = DB.find(ParentB.class, 1L); - + ChildWithCache temp = tempB.getChild(); - //if the next line is commented out, the test passes - temp.getName(); //load name from cache --> ebean_intercept.loadedFromCache = true - - String tempLazyProp = temp.getAddress(); - assertThat(tempLazyProp).isEqualTo("Address"); - + // if the next line is commented out, the test passes + temp.getName(); // load name from cache --> ebean_intercept.loadedFromCache = true + + assertThat(temp.getAddress()).isEqualTo("Address"); + assertThat(temp.getName()).isEqualTo("Child With Cache"); } } From ad80eb267fd01a4a88fbf5ab78850bade42befd0 Mon Sep 17 00:00:00 2001 From: trojo Date: Wed, 20 Jan 2021 09:57:25 +0100 Subject: [PATCH 064/447] ADD: multiple to many outer joins cause wrong count in distinct count queries --- .../query/other/TestQuerySingleAttribute.java | 27 +++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/ebean-core/src/test/java/org/tests/query/other/TestQuerySingleAttribute.java b/ebean-core/src/test/java/org/tests/query/other/TestQuerySingleAttribute.java index 73b80fb00..8ecaae8a9 100644 --- a/ebean-core/src/test/java/org/tests/query/other/TestQuerySingleAttribute.java +++ b/ebean-core/src/test/java/org/tests/query/other/TestQuerySingleAttribute.java @@ -3,6 +3,7 @@ package org.tests.query.other; import io.ebean.BaseTestCase; import io.ebean.CountDistinctOrder; import io.ebean.CountedValue; +import io.ebean.DB; import io.ebean.Ebean; import io.ebean.Query; import org.junit.Ignore; @@ -23,6 +24,32 @@ import java.util.List; import static org.assertj.core.api.Assertions.assertThat; public class TestQuerySingleAttribute extends BaseTestCase { + + @Test + public void findSingleAttributesTwoToMany() { + ResetBasicData.reset(); + Query query = DB.find(Customer.class) + .select("name") + //.apply(toFetchPath("name")) + .setCountDistinct(CountDistinctOrder.COUNT_DESC_ATTR_ASC) + .where() + .eq("name", "Rob") + .or() + .eq("orders.status", Order.Status.NEW) + .eq("contacts.firstName", "Fred1") + .query(); + + List counted = query.findSingleAttributeList(); + CountedValue robs = (CountedValue)counted.get(0); + assertThat(robs.getValue()).isEqualTo("Rob"); + assertThat(robs.getCount()).isEqualTo(1); + + // TODO check correct future query + assertThat(sqlOf(query)).contains("select r1.attribute_1, count(*) cnt" + + " from (select t1.id attribute_1 from main_entity_relation t0 left join main_entity t1 on t1.id = t0.id1 ) r1" + + " group by r1.attribute_1" + + " order by count(*) desc, r1.attribute_1"); + } @Test public void exampleUsage() { From 38016773d4e25c80daaf2ec92b0d9ccdc377e410 Mon Sep 17 00:00:00 2001 From: trojo Date: Wed, 20 Jan 2021 10:47:53 +0100 Subject: [PATCH 065/447] added comments --- .../query/other/TestQuerySingleAttribute.java | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/ebean-core/src/test/java/org/tests/query/other/TestQuerySingleAttribute.java b/ebean-core/src/test/java/org/tests/query/other/TestQuerySingleAttribute.java index 8ecaae8a9..a5cd5d481 100644 --- a/ebean-core/src/test/java/org/tests/query/other/TestQuerySingleAttribute.java +++ b/ebean-core/src/test/java/org/tests/query/other/TestQuerySingleAttribute.java @@ -28,20 +28,33 @@ public class TestQuerySingleAttribute extends BaseTestCase { @Test public void findSingleAttributesTwoToMany() { ResetBasicData.reset(); + // Query without ors with equals causing joins, only one Customer with name Rob exists + Query query0 = DB.find(Customer.class) + .select("name") + .setCountDistinct(CountDistinctOrder.COUNT_DESC_ATTR_ASC) + .where() + .eq("name", "Rob") + .query(); + + CountedValue robs0 = (CountedValue) query0.findSingleAttributeList().get(0); + assertThat(robs0.getValue()).isEqualTo("Rob"); + assertThat(robs0.getCount()).isEqualTo(1); + + // Query with or with equals causing joins Query query = DB.find(Customer.class) .select("name") - //.apply(toFetchPath("name")) .setCountDistinct(CountDistinctOrder.COUNT_DESC_ATTR_ASC) .where() .eq("name", "Rob") .or() .eq("orders.status", Order.Status.NEW) .eq("contacts.firstName", "Fred1") + .endOr() .query(); - List counted = query.findSingleAttributeList(); - CountedValue robs = (CountedValue)counted.get(0); + CountedValue robs = (CountedValue) query.findSingleAttributeList().get(0); assertThat(robs.getValue()).isEqualTo("Rob"); + // only one Customer named rob exists, but 7 is returned for the amount of Customers named Rob assertThat(robs.getCount()).isEqualTo(1); // TODO check correct future query From 5eac31283d33c1137f9af5e6270db315af7bbb60 Mon Sep 17 00:00:00 2001 From: rob bygrave Date: Wed, 20 Jan 2021 23:31:45 +1300 Subject: [PATCH 066/447] #2148 - PersistenceException: No ScalarType registered for class java.util.LinkedHashMap --- .../server/querydefn/DefaultUpdateQuery.java | 16 ++++- .../server/querydefn/OrmUpdateProperties.java | 25 ++++---- .../java/org/tests/json/TestDbJson_List.java | 41 +++++++------ .../java/org/tests/json/TestJsonMapBasic.java | 60 +++++++++++++++---- 4 files changed, 96 insertions(+), 46 deletions(-) diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/querydefn/DefaultUpdateQuery.java b/ebean-core/src/main/java/io/ebeaninternal/server/querydefn/DefaultUpdateQuery.java index 20d4ae3a0..897424b8a 100644 --- a/ebean-core/src/main/java/io/ebeaninternal/server/querydefn/DefaultUpdateQuery.java +++ b/ebean-core/src/main/java/io/ebeaninternal/server/querydefn/DefaultUpdateQuery.java @@ -3,6 +3,9 @@ package io.ebeaninternal.server.querydefn; import io.ebean.ExpressionList; import io.ebean.ProfileLocation; import io.ebean.UpdateQuery; +import io.ebean.core.type.ScalarType; +import io.ebeaninternal.server.deploy.BeanDescriptor; +import io.ebeaninternal.server.deploy.BeanProperty; /** * Default implementation of UpdateQuery. @@ -10,23 +13,30 @@ import io.ebean.UpdateQuery; public class DefaultUpdateQuery implements UpdateQuery { private final OrmUpdateProperties values = new OrmUpdateProperties(); - private final DefaultOrmQuery query; + private final BeanDescriptor descriptor; public DefaultUpdateQuery(DefaultOrmQuery query) { this.query = query; + this.descriptor = query.getBeanDescriptor(); query.setUpdateProperties(values); } @Override public UpdateQuery set(String property, Object value) { - values.set(property, value); + if (value == null) { + values.setNull(property); + } else { + final BeanProperty beanProperty = descriptor.getBeanProperty(property); + final ScalarType scalarType = (beanProperty == null) ? null: beanProperty.getScalarType(); + values.set(property, value, scalarType); + } return this; } @Override public UpdateQuery setNull(String property) { - values.set(property, null); + values.setNull(property); return this; } diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/querydefn/OrmUpdateProperties.java b/ebean-core/src/main/java/io/ebeaninternal/server/querydefn/OrmUpdateProperties.java index 39a8dc81d..930e653f4 100644 --- a/ebean-core/src/main/java/io/ebeaninternal/server/querydefn/OrmUpdateProperties.java +++ b/ebean-core/src/main/java/io/ebeaninternal/server/querydefn/OrmUpdateProperties.java @@ -1,5 +1,6 @@ package io.ebeaninternal.server.querydefn; +import io.ebean.core.type.ScalarType; import io.ebeaninternal.server.deploy.DeployParser; import io.ebeaninternal.server.persist.Binder; import io.ebeaninternal.server.type.DataBind; @@ -53,9 +54,11 @@ public class OrmUpdateProperties { private static class SimpleValue extends Value { final Object value; + final ScalarType scalarType; - SimpleValue(Object value) { + SimpleValue(Object value, ScalarType scalarType) { this.value = value; + this.scalarType = scalarType; } @Override @@ -70,7 +73,11 @@ public class OrmUpdateProperties { @Override public void bind(Binder binder, DataBind dataBind) throws SQLException { - binder.bindObject(dataBind, value); + if (scalarType != null) { + scalarType.bind(dataBind, value); + } else { + binder.bindObject(dataBind, value); + } dataBind.append(value).append(","); } } @@ -115,16 +122,12 @@ public class OrmUpdateProperties { */ private final LinkedHashMap values = new LinkedHashMap<>(); - /** - * Normal set property. - */ - public void set(String propertyName, Object value) { - if (value == null) { - values.put(propertyName, NULL_VALUE); + public void set(String propertyName, Object value, ScalarType scalarType) { + values.put(propertyName, new SimpleValue(value, scalarType)); + } - } else { - values.put(propertyName, new SimpleValue(value)); - } + public void setNull(String propertyName) { + values.put(propertyName, NULL_VALUE); } /** diff --git a/ebean-core/src/test/java/org/tests/json/TestDbJson_List.java b/ebean-core/src/test/java/org/tests/json/TestDbJson_List.java index 0582818db..28fd78221 100644 --- a/ebean-core/src/test/java/org/tests/json/TestDbJson_List.java +++ b/ebean-core/src/test/java/org/tests/json/TestDbJson_List.java @@ -1,7 +1,7 @@ package org.tests.json; import io.ebean.BaseTestCase; -import io.ebean.Ebean; +import io.ebean.DB; import io.ebean.annotation.ForPlatform; import io.ebean.annotation.Platform; import io.ebean.text.TextException; @@ -25,7 +25,7 @@ import static org.junit.Assert.assertTrue; public class TestDbJson_List extends BaseTestCase { - private EBasicJsonList bean = new EBasicJsonList(); + private final EBasicJsonList bean = new EBasicJsonList(); private EBasicJsonList found; @@ -57,9 +57,9 @@ public class TestDbJson_List extends BaseTestCase { bean.getBeanMap().put("key0", new PlainBean("k0", 90)); bean.getBeanMap().put("key1", new PlainBean("k1", 91)); - Ebean.save(bean); + DB.save(bean); - found = Ebean.find(EBasicJsonList.class, bean.getId()); + found = DB.find(EBasicJsonList.class, bean.getId()); assertThat(found.getTags()).containsExactly("one", "two"); assertTrue(found.getFlags().contains(42L)); @@ -81,7 +81,7 @@ public class TestDbJson_List extends BaseTestCase { //@Test//(dependsOnMethods = "insert") public void json_parse_format() { - String asJson = Ebean.json().toJson(found); + String asJson = DB.json().toJson(found); assertThat(asJson).contains("\"tags\":[\"one\",\"two\"]"); assertThat(asJson).contains("\"flags\":[42,43,44]"); assertThat(asJson).contains("\"plainBean\":{\"name\":\"plain\""); @@ -90,7 +90,7 @@ public class TestDbJson_List extends BaseTestCase { assertThat(asJson).contains("\"beanMap\":{"); assertThat(asJson).contains("\"id\":"); - EBasicJsonList fromJson = Ebean.json().toBean(EBasicJsonList.class, asJson); + EBasicJsonList fromJson = DB.json().toBean(EBasicJsonList.class, asJson); assertEquals(found.getId(), fromJson.getId()); assertEquals(found.getId(), fromJson.getId()); assertEquals(found.getName(), fromJson.getName()); @@ -109,7 +109,7 @@ public class TestDbJson_List extends BaseTestCase { found.setName("mod"); LoggedSqlCollector.start(); - Ebean.save(found); + DB.save(found); List sql = LoggedSqlCollector.stop(); // we don't update the phone numbers (as they are not dirty) @@ -122,7 +122,7 @@ public class TestDbJson_List extends BaseTestCase { found.getTags().add("three"); LoggedSqlCollector.start(); - Ebean.save(found); + DB.save(found); List sql = LoggedSqlCollector.stop(); // we don't update the phone numbers (as they are not dirty) @@ -135,7 +135,7 @@ public class TestDbJson_List extends BaseTestCase { found.getFlags().remove(42L); LoggedSqlCollector.start(); - Ebean.save(found); + DB.save(found); List sql = LoggedSqlCollector.stop(); // we don't update the phone numbers (as they are not dirty) @@ -150,7 +150,7 @@ public class TestDbJson_List extends BaseTestCase { found.getBeanMap().remove("key0"); LoggedSqlCollector.start(); - Ebean.save(found); + DB.save(found); List sql = LoggedSqlCollector.stop(); // we don't update the phone numbers (as they are not dirty) @@ -166,13 +166,13 @@ public class TestDbJson_List extends BaseTestCase { bean.setTags(null); bean.setBeanMap(null); - Ebean.save(bean); + DB.save(bean); - EBasicJsonList found = Ebean.find(EBasicJsonList.class, bean.getId()); + EBasicJsonList found = DB.find(EBasicJsonList.class, bean.getId()); assertNull(found.getPlainBean()); - String asJson = Ebean.json().toJson(found); + String asJson = DB.json().toJson(found); assertNotNull(asJson); } @@ -186,17 +186,16 @@ public class TestDbJson_List extends BaseTestCase { plainBean.setName("Blubb"); bean.getBeanMap().put("bla", plainBean); - Ebean.save(bean); + DB.save(bean); // set some invalid JSON content into DB - Ebean.update(EBasicJsonList.class) - .set("beanMap", "blabla") - .where().eq("id", bean.getId()) - .update(); + DB.sqlUpdate("update ebasic_json_list set bean_map=? where id=?") + .setParameters("blabla", bean.getId()) + .execute(); try { // a normal query fails due to invalid JSON content - Ebean.find(EBasicJsonList.class) + DB.find(EBasicJsonList.class) .setId(bean.getId()) .findOne(); @@ -208,7 +207,7 @@ public class TestDbJson_List extends BaseTestCase { assertThat(e.getMessage()).contains("beanMap"); } - bean = Ebean.find(EBasicJsonList.class) + bean = DB.find(EBasicJsonList.class) .setId(bean.getId()) .setAllowLoadErrors() // allow invalid JSON content .findOne(); @@ -220,6 +219,6 @@ public class TestDbJson_List extends BaseTestCase { .isInstanceOf(TextException.class) .hasMessageContaining("blabla"); - Ebean.delete(bean); + DB.delete(bean); } } diff --git a/ebean-core/src/test/java/org/tests/json/TestJsonMapBasic.java b/ebean-core/src/test/java/org/tests/json/TestJsonMapBasic.java index 2edad3554..01d105760 100644 --- a/ebean-core/src/test/java/org/tests/json/TestJsonMapBasic.java +++ b/ebean-core/src/test/java/org/tests/json/TestJsonMapBasic.java @@ -1,14 +1,16 @@ package org.tests.json; import io.ebean.BaseTestCase; -import io.ebean.Ebean; +import io.ebean.DB; import io.ebean.Query; import io.ebean.text.json.EJson; +import io.ebeantest.LoggedSql; import org.tests.model.json.EBasicJsonMap; import org.junit.Test; import org.tests.model.json.EBasicJsonMapDetail; import java.io.IOException; +import java.util.List; import java.util.Map; import static org.assertj.core.api.Assertions.assertThat; @@ -29,9 +31,9 @@ public class TestJsonMapBasic extends BaseTestCase { bean.getDetails().add(new EBasicJsonMapDetail("detail1")); bean.getDetails().add(new EBasicJsonMapDetail("detail2")); - Ebean.save(bean); + DB.save(bean); - Query query1 = Ebean.find(EBasicJsonMap.class) + Query query1 = DB.find(EBasicJsonMap.class) .fetch("details") .where().startsWith("details.name", "detail") .query(); @@ -40,7 +42,7 @@ public class TestJsonMapBasic extends BaseTestCase { assertThat(query1.getGeneratedSql()).contains("select distinct on (t0.id, t1.id) "); - Query query2 = Ebean.find(EBasicJsonMap.class) + Query query2 = DB.find(EBasicJsonMap.class) .where().startsWith("details.name", "detail") .query(); query2.findList(); @@ -60,9 +62,9 @@ public class TestJsonMapBasic extends BaseTestCase { bean.setName("one"); bean.setContent(content); - Ebean.save(bean); + DB.save(bean); - EBasicJsonMap bean1 = Ebean.find(EBasicJsonMap.class, bean.getId()); + EBasicJsonMap bean1 = DB.find(EBasicJsonMap.class, bean.getId()); assertEquals(bean.getId(), bean1.getId()); assertEquals(bean.getName(), bean1.getName()); @@ -70,16 +72,16 @@ public class TestJsonMapBasic extends BaseTestCase { assertEquals(18L, bean1.getContent().get("docId")); bean1.setName("just change name"); - Ebean.save(bean1); + DB.save(bean1); // content changes detected - dirty state so included in update Map content1 = bean1.getContent(); content1.put("additional", "newValue"); content1.put("docId", 99L); bean1.setName("two"); - Ebean.save(bean1); + DB.save(bean1); - EBasicJsonMap bean2 = Ebean.find(EBasicJsonMap.class, bean.getId()); + EBasicJsonMap bean2 = DB.find(EBasicJsonMap.class, bean.getId()); // name changed and docId changed assertEquals("two", bean2.getName()); @@ -89,12 +91,48 @@ public class TestJsonMapBasic extends BaseTestCase { content1.put("additional", "modValue"); bean1.setName("three"); bean1.setContent(content1); - Ebean.save(bean1); + DB.save(bean1); - EBasicJsonMap bean3 = Ebean.find(EBasicJsonMap.class, bean.getId()); + EBasicJsonMap bean3 = DB.find(EBasicJsonMap.class, bean.getId()); assertEquals("three", bean3.getName()); assertEquals(99L, bean3.getContent().get("docId")); assertEquals("modValue", bean3.getContent().get("additional")); } + + @Test + public void updateQuery_bindingMap() throws IOException { + + String s0 = "{\"docId\":22,\"contentId\":\"initialDoc\"}"; + Map content = EJson.parseObject(s0); + + EBasicJsonMap bean = new EBasicJsonMap(); + bean.setName("one"); + bean.setContent(content); + + DB.save(bean); + + String s1 = "{\"docId\":222,\"contentId\":\"updatedDoc222\"}"; + Map content1 = EJson.parseObject(s1); + + LoggedSql.start(); + + final int rows = DB.update(EBasicJsonMap.class) + .set("content", content1) + .where().eq("id", bean.getId()) + .update(); + + final List sql = LoggedSql.stop(); + + assertThat(sql).hasSize(1); + assertThat(sql.get(0)).contains("update ebasic_json_map set content=? where id = ?"); + assertThat(rows).isEqualTo(1); + + final EBasicJsonMap found = DB.find(EBasicJsonMap.class, bean.getId()); + final Map content2 = found.getContent(); + assertThat(content2.get("contentId")).isEqualTo("updatedDoc222"); + assertThat(content2.get("docId")).isEqualTo(222L); + + DB.delete(found); + } } From 6778e37652821c7e2cb8a58d68d79a38874f89b7 Mon Sep 17 00:00:00 2001 From: trojo Date: Wed, 20 Jan 2021 17:43:14 +0100 Subject: [PATCH 067/447] ADD: batch flash doesnt execute sql statements created in lifecycle methods --- .../tests/lifecycle/TestLifecycleWithLog.java | 80 +++++++++++ .../java/org/tests/model/basic/EBasicLog.java | 32 +++++ .../org/tests/model/basic/EBasicWithLog.java | 131 ++++++++++++++++++ 3 files changed, 243 insertions(+) create mode 100644 ebean-core/src/test/java/org/tests/lifecycle/TestLifecycleWithLog.java create mode 100644 ebean-core/src/test/java/org/tests/model/basic/EBasicLog.java create mode 100644 ebean-core/src/test/java/org/tests/model/basic/EBasicWithLog.java diff --git a/ebean-core/src/test/java/org/tests/lifecycle/TestLifecycleWithLog.java b/ebean-core/src/test/java/org/tests/lifecycle/TestLifecycleWithLog.java new file mode 100644 index 000000000..08aa845a8 --- /dev/null +++ b/ebean-core/src/test/java/org/tests/lifecycle/TestLifecycleWithLog.java @@ -0,0 +1,80 @@ +package org.tests.lifecycle; + +import static org.assertj.core.api.Assertions.assertThat; + +import java.util.Arrays; +import java.util.List; + +import org.junit.Test; +import org.tests.model.basic.EBasicLog; +import org.tests.model.basic.EBasicWithLog; + +import io.ebean.BaseTestCase; +import io.ebean.DB; +import io.ebean.Ebean; + +public class TestLifecycleWithLog extends BaseTestCase { + + private List getLogs() { + List ret = DB.find(EBasicLog.class) + .select("name") + .findSingleAttributeList(); + DB.find(EBasicLog.class).delete(); + return ret; + } + + @Test + public void testCUD() { + + EBasicWithLog bean = new EBasicWithLog(); + bean.setId(1L); + bean.setName("Test1"); + + DB.save(bean); + + assertThat(getLogs()).contains("onPersistTrigger", "prePersist", "postPersist"); + + bean.setName("Test2"); + + DB.save(bean); + + assertThat(getLogs()).contains("onPersistTrigger", "preUpdate", "postUpdate"); + + DB.delete(bean); + + assertThat(getLogs()).contains("onPersistTrigger", "preSoftDelete", "postSoftDelete"); + + DB.deletePermanent(bean); + + assertThat(getLogs()).contains("onPersistTrigger", "preRemove", "postRemove"); + } + + @Test + public void testCUDBatch() { + + EBasicWithLog bean = new EBasicWithLog(); + bean.setId(2L); + bean.setName("Test2"); + + List beans = Arrays.asList(bean); + + DB.saveAll(beans); + + assertThat(getLogs()).contains("onPersistTrigger", "prePersist", "postPersist"); + + bean.setName("Test2"); + + DB.saveAll(beans); + + assertThat(getLogs()).contains("onPersistTrigger", "preUpdate", "postUpdate"); + + DB.deleteAll(beans); + + assertThat(getLogs()).contains("onPersistTrigger", "preSoftDelete", "postSoftDelete"); + + DB.deleteAllPermanent(beans); + + assertThat(getLogs()).contains("onPersistTrigger", "preRemove", "postRemove"); + } + +} \ No newline at end of file diff --git a/ebean-core/src/test/java/org/tests/model/basic/EBasicLog.java b/ebean-core/src/test/java/org/tests/model/basic/EBasicLog.java new file mode 100644 index 000000000..e0de4ce92 --- /dev/null +++ b/ebean-core/src/test/java/org/tests/model/basic/EBasicLog.java @@ -0,0 +1,32 @@ +package org.tests.model.basic; + +import javax.persistence.Entity; +import javax.persistence.Id; +import javax.persistence.Table; + +@Entity +@Table(name = "e_basic_log") +public class EBasicLog { + + @Id + Long id; + + String name; + + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id = id; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + +} diff --git a/ebean-core/src/test/java/org/tests/model/basic/EBasicWithLog.java b/ebean-core/src/test/java/org/tests/model/basic/EBasicWithLog.java new file mode 100644 index 000000000..e7f5a6035 --- /dev/null +++ b/ebean-core/src/test/java/org/tests/model/basic/EBasicWithLog.java @@ -0,0 +1,131 @@ +package org.tests.model.basic; + +import io.ebean.DB; +import io.ebean.annotation.PostSoftDelete; +import io.ebean.annotation.PreSoftDelete; +import io.ebean.annotation.SoftDelete; + +import javax.annotation.PostConstruct; +import javax.persistence.Entity; +import javax.persistence.Id; +import javax.persistence.PostLoad; +import javax.persistence.PostPersist; +import javax.persistence.PostRemove; +import javax.persistence.PostUpdate; +import javax.persistence.PrePersist; +import javax.persistence.PreRemove; +import javax.persistence.PreUpdate; +import javax.persistence.Table; +import javax.persistence.Version; + +@Entity +@Table(name = "e_basic_withlog") +public class EBasicWithLog { + + @Id + Long id; + + String name; + + @SoftDelete + boolean deleted; + + @Version + Long version; + + @PrePersist + public void prePersist() { + writeLog("prePersist"); + } + + @PostPersist + public void postPersist() { + writeLog("postPersist"); + } + + @PreUpdate + public void preUpdate() { + writeLog("preUpdate"); + } + + @PostUpdate + public void postUpdate() { + writeLog("postUpdate"); + } + + @PreRemove + public void preRemove() { + writeLog("preRemove"); + } + + @PostRemove + public void postRemove() { + writeLog("postRemove"); + } + + @PostSoftDelete + public void postSoftDelete() { + writeLog("postSoftDelete"); + } + + @PreSoftDelete + public void preSoftDelete() { + writeLog("preSoftDelete"); + } + + @PostLoad + public void postLoad() { + writeLog("postLoad"); + } + + @PostConstruct + public void postConstruct() { + writeLog("postConstruct"); + } + + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id = id; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public boolean isDeleted() { + return deleted; + } + + public void setDeleted(boolean deleted) { + this.deleted = deleted; + } + + public Long getVersion() { + return version; + } + + public void setVersion(Long version) { + this.version = version; + } + + public void _ebean_onPersistTrigger() { + writeLog("onPersistTrigger"); + } + + /** + * @param string + */ + private void writeLog(String title) { + EBasicLog log = new EBasicLog(); + log.setName(title); + DB.save(log); + } + +} \ No newline at end of file From b44091ff3a4ce86b399434bd1d7595189e174dd2 Mon Sep 17 00:00:00 2001 From: Robin Bygrave Date: Thu, 21 Jan 2021 16:56:42 +1300 Subject: [PATCH 068/447] =?UTF-8?q?#2147=20Fix=20for=20ADD:=20multiple=20t?= =?UTF-8?q?o=20many=20outer=20joins=20cause=20wrong=20count=20in=20distinc?= =?UTF-8?q?t=20count=E2=80=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Copy of Rolands fix in FOCONIS branch. This also brings over some of the extra tests found there. Note that the SQL is slightly different from the FOCONIS branch in that there is additional foreign key columns included in the sub-query select clause. --- .../server/query/CQueryBuilder.java | 16 +- .../query/other/TestQuerySingleAttribute.java | 148 +++++++++++++++++- 2 files changed, 151 insertions(+), 13 deletions(-) diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/query/CQueryBuilder.java b/ebean-core/src/main/java/io/ebeaninternal/server/query/CQueryBuilder.java index 765251134..75aa7e3cc 100644 --- a/ebean-core/src/main/java/io/ebeaninternal/server/query/CQueryBuilder.java +++ b/ebean-core/src/main/java/io/ebeaninternal/server/query/CQueryBuilder.java @@ -571,8 +571,8 @@ class CQueryBuilder { private final CQueryPredicates predicates; private final SqlTree select; private final boolean updateStatement; - private final boolean distinct; + private final boolean countSingleAttribute; private final String dbOrderBy; private boolean useSqlLimiter; private boolean hasWhere; @@ -590,6 +590,7 @@ class CQueryBuilder { this.updateStatement = updateStatement; this.distinct = query.isDistinct() || select.isSqlDistinct(); this.dbOrderBy = predicates.getDbOrderBy(); + this.countSingleAttribute = query.isCountDistinct() && query.isSingleAttribute(); } private void appendSelect() { @@ -601,8 +602,13 @@ class CQueryBuilder { if (!useSqlLimiter) { appendSelectDistinct(); } - if (query.isCountDistinct() && query.isSingleAttribute()) { - sb.append("r1.attribute_, count(*) from (select ").append(select.getSelectSql()).append(" as attribute_"); + if (countSingleAttribute) { + sb.append("r1.attribute_, count(*) from (select "); + if (distinct) { + sb.append("distinct t0."); + sb.append(request.getBeanDescriptor().getIdProperty().getDbColumn()).append(", "); + } + sb.append(select.getSelectSql()).append(" as attribute_"); } else { sb.append(select.getSelectSql()); } @@ -621,7 +627,7 @@ class CQueryBuilder { private void appendSelectDistinct() { sb.append("select "); - if (distinct) { + if (distinct && !countSingleAttribute) { if (request.isInlineCountDistinct()) { sb.append("count("); } @@ -730,7 +736,7 @@ class CQueryBuilder { sb.append(" order by ").append(dbOrderBy); } - if (query.isCountDistinct() && query.isSingleAttribute()) { + if (countSingleAttribute) { sb.append(") r1 group by r1.attribute_"); sb.append(toSql(query.getCountDistinctOrder())); } diff --git a/ebean-core/src/test/java/org/tests/query/other/TestQuerySingleAttribute.java b/ebean-core/src/test/java/org/tests/query/other/TestQuerySingleAttribute.java index a5cd5d481..f476ed084 100644 --- a/ebean-core/src/test/java/org/tests/query/other/TestQuerySingleAttribute.java +++ b/ebean-core/src/test/java/org/tests/query/other/TestQuerySingleAttribute.java @@ -6,16 +6,21 @@ import io.ebean.CountedValue; import io.ebean.DB; import io.ebean.Ebean; import io.ebean.Query; +import org.junit.After; +import org.junit.Before; import org.junit.Ignore; import org.junit.Test; import org.tests.inherit.ChildA; import org.tests.inherit.Data; import org.tests.inherit.EUncle; +import org.tests.lazyforeignkeys.MainEntity; +import org.tests.lazyforeignkeys.MainEntityRelation; import org.tests.model.basic.Contact; import org.tests.model.basic.Customer; import org.tests.model.basic.Order; import org.tests.model.basic.ResetBasicData; import org.tests.model.basic.VwCustomer; +import org.tests.o2m.OmBasicParent; import java.sql.Date; import java.time.LocalDate; @@ -24,7 +29,7 @@ import java.util.List; import static org.assertj.core.api.Assertions.assertThat; public class TestQuerySingleAttribute extends BaseTestCase { - + @Test public void findSingleAttributesTwoToMany() { ResetBasicData.reset(); @@ -39,7 +44,7 @@ public class TestQuerySingleAttribute extends BaseTestCase { CountedValue robs0 = (CountedValue) query0.findSingleAttributeList().get(0); assertThat(robs0.getValue()).isEqualTo("Rob"); assertThat(robs0.getCount()).isEqualTo(1); - + // Query with or with equals causing joins Query query = DB.find(Customer.class) .select("name") @@ -56,12 +61,13 @@ public class TestQuerySingleAttribute extends BaseTestCase { assertThat(robs.getValue()).isEqualTo("Rob"); // only one Customer named rob exists, but 7 is returned for the amount of Customers named Rob assertThat(robs.getCount()).isEqualTo(1); - - // TODO check correct future query - assertThat(sqlOf(query)).contains("select r1.attribute_1, count(*) cnt" - + " from (select t1.id attribute_1 from main_entity_relation t0 left join main_entity t1 on t1.id = t0.id1 ) r1" - + " group by r1.attribute_1" - + " order by count(*) desc, r1.attribute_1"); + + assertThat(sqlOf(query)).contains("select r1.attribute_, count(*) " + + "from (select distinct t0.id, t0.name as attribute_ " + + "from o_customer t0 left join contact u1 on u1.customer_id = t0.id left join o_order u2 on u2.kcustomer_id = t0.id " + + "where t0.name = ? and (u2.status = ? or u1.first_name = ?)) r1 " + + "group by r1.attribute_ " + + "order by count(*) desc, r1.attribute_"); } @Test @@ -142,6 +148,93 @@ public class TestQuerySingleAttribute extends BaseTestCase { assertThat(name).isNotNull(); } + @Test + public void findSingleAttributeList_with_join_column() { + ResetBasicData.reset(); + Query query = Ebean.find(MainEntityRelation.class) + .fetch("entity1", "attr1") + .setDistinct(true) + .setCountDistinct(CountDistinctOrder.COUNT_DESC_ATTR_ASC) + .where().query(); + + List> attr1list = query.findSingleAttributeList(); + + assertThat(sqlOf(query)).contains("select r1.attribute_, count(*)" + + " from (select distinct t0.id, t0.id1, t1.attr1 as attribute_ from main_entity_relation t0 left join main_entity t1 on t1.id = t0.id1) r1" + + " group by r1.attribute_" + + " order by count(*) desc, r1.attribute_"); // sub-query select clause includes t0.id1 + assertThat(attr1list).isNotNull(); + assertThat(attr1list).hasSize(2); + assertThat(attr1list.get(0).getValue()).isEqualTo("a1"); + assertThat(attr1list.get(0).getCount()).isEqualTo(2l); + assertThat(attr1list.get(1).getValue()).isEqualTo("a2"); + assertThat(attr1list.get(1).getCount()).isEqualTo(1l); + } + + @Test + public void findSingleAttributesVariousSelection1() { + Query query = Ebean.find(MainEntityRelation.class) + .fetch("entity1", "attr1") + .setCountDistinct(CountDistinctOrder.COUNT_DESC_ATTR_ASC) + .where().query(); + query.findSingleAttributeList(); + assertThat(sqlOf(query)).contains("select r1.attribute_, count(*)" + + " from (select t0.id1, t1.attr1 as attribute_ from main_entity_relation t0 left join main_entity t1 on t1.id = t0.id1) r1" + + " group by r1.attribute_" + + " order by count(*) desc, r1.attribute_"); // sub-query select clause includes t0.id1 + } + + @Test + public void findSingleAttributesVariousSelection2() { + Query query = Ebean.find(MainEntityRelation.class) + .select("attr1") + .setCountDistinct(CountDistinctOrder.COUNT_DESC_ATTR_ASC) + .where().query(); + query.findSingleAttributeList(); + assertThat(sqlOf(query)).contains("select r1.attribute_, count(*)" + + " from (select t0.attr1 as attribute_ from main_entity_relation t0) r1" + + " group by r1.attribute_" + + " order by count(*) desc, r1.attribute_"); + } + + @Test + public void findSingleAttributesVariousSelection3() { + Query query = Ebean.find(MainEntityRelation.class) + .select("id") + .setCountDistinct(CountDistinctOrder.COUNT_DESC_ATTR_ASC) + .where().query(); + query.findSingleAttributeList(); + assertThat(sqlOf(query)).contains("select r1.attribute_, count(*)" + + " from (select t0.id as attribute_ from main_entity_relation t0) r1" + + " group by r1.attribute_" + + " order by count(*) desc, r1.attribute_"); + } + + @Test + public void findSingleAttributesVariousSelection4() { + Query query = Ebean.find(MainEntityRelation.class) + .fetch("entity1", "id") + .setCountDistinct(CountDistinctOrder.COUNT_DESC_ATTR_ASC) + .where().query(); + query.findSingleAttributeList(); + assertThat(sqlOf(query)).contains("select r1.attribute_, count(*)" + + " from (select t0.id1, t1.id as attribute_ from main_entity_relation t0 left join main_entity t1 on t1.id = t0.id1) r1" + + " group by r1.attribute_" + + " order by count(*) desc, r1.attribute_"); // sub-query select clause includes t0.id1, + } + + @Test + public void findSingleAttributesVariousSelection5() { + Query query = Ebean.find(OmBasicParent.class) + .fetch("children", "name") + .setCountDistinct(CountDistinctOrder.COUNT_DESC_ATTR_ASC) + .where().query(); + query.findSingleAttributeList(); + assertThat(sqlOf(query)).contains("select r1.attribute_, count(*)" + + " from (select t1.id, t1.name as attribute_ from om_basic_parent t0 left join om_basic_child t1 on t1.parent_id = t0.id) r1 " + + "group by r1.attribute_ order by count(*) desc, r1.attribute_"); // sub-query select clause includes t1.id, + } + @Test public void findSingleAttribute_with_aggregate() { @@ -664,4 +757,43 @@ public class TestQuerySingleAttribute extends BaseTestCase { System.out.println(" count:" + entry.getCount()+" orderStatus:" + entry.getValue() ); } } + + @Before + public void setup() { + MainEntity e1 = new MainEntity(); + e1.setId("1"); + e1.setAttr1("a1"); + DB.save(e1); + + MainEntity e2 = new MainEntity(); + e2.setId("2"); + e2.setAttr1("a2"); + DB.save(e2); + + MainEntity e3 = new MainEntity(); + e3.setId("3"); + e3.setAttr1("a1"); + DB.save(e3); + + MainEntityRelation rel = new MainEntityRelation(); + rel.setEntity1(e1); + rel.setEntity2(e1); + DB.save(rel); + + rel = new MainEntityRelation(); + rel.setEntity1(e2); + rel.setEntity2(e2); + DB.save(rel); + + rel = new MainEntityRelation(); + rel.setEntity1(e3); + rel.setEntity2(e3); + DB.save(rel); + } + + @After + public void cleanup() { + Ebean.find(MainEntityRelation.class).delete(); + Ebean.find(MainEntity.class).delete(); + } } From e497c54f82ada7fdd46c48966ba69ad83835b382 Mon Sep 17 00:00:00 2001 From: Robin Bygrave Date: Thu, 21 Jan 2021 17:01:36 +1300 Subject: [PATCH 069/447] No effective change - modify test redis ClusterTest to have 20ms wait --- ebean-redis/src/test/java/org/integration/ClusterTest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ebean-redis/src/test/java/org/integration/ClusterTest.java b/ebean-redis/src/test/java/org/integration/ClusterTest.java index 0d9414579..0bb546526 100644 --- a/ebean-redis/src/test/java/org/integration/ClusterTest.java +++ b/ebean-redis/src/test/java/org/integration/ClusterTest.java @@ -118,6 +118,6 @@ public class ClusterTest { } private void allowAsyncMessaging() throws InterruptedException { - Thread.sleep(10); + Thread.sleep(20); } } From e38059f52cde700a0b875dd1d36ef2fecaaace88 Mon Sep 17 00:00:00 2001 From: Robin Bygrave Date: Fri, 22 Jan 2021 14:00:48 +1300 Subject: [PATCH 070/447] #2149 - Fix for ADD: jdbc batch flush doesnt execute sql statements created in lifecycle methods (e.g. beans saved in PostInsert etc) Note that the foconis fork has a onPersist extension which is removed from the test. --- .../server/persist/BatchControl.java | 39 +++++++++++++------ .../server/persist/BatchedBeanHolder.java | 16 +++++++- .../tests/lifecycle/TestLifecycleWithLog.java | 31 +++++---------- .../org/tests/model/basic/EBasicWithLog.java | 9 +---- 4 files changed, 52 insertions(+), 43 deletions(-) diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/persist/BatchControl.java b/ebean-core/src/main/java/io/ebeaninternal/server/persist/BatchControl.java index bc4b00c4e..10ba7f205 100644 --- a/ebean-core/src/main/java/io/ebeaninternal/server/persist/BatchControl.java +++ b/ebean-core/src/main/java/io/ebeaninternal/server/persist/BatchControl.java @@ -298,18 +298,7 @@ public final class BatchControl { // Nothing in queue to flush return; } - - // convert entry map to array for sorting - BatchedBeanHolder[] bsArray = getBeanHolderArray(); - // sort the entries by depth - Arrays.sort(bsArray, depthComparator); - - if (transaction.isLogSummary()) { - transaction.logSummary("BatchControl flush " + Arrays.toString(bsArray)); - } - for (BatchedBeanHolder beanHolder : bsArray) { - beanHolder.executeNow(); - } + executeAll(); persistedBeans.clear(); if (reset) { beanHoldMap.clear(); @@ -323,6 +312,32 @@ public final class BatchControl { } } + private void executeAll() throws BatchedSqlException { + do { + // convert entry map to array for sorting + BatchedBeanHolder[] bsArray = getBeanHolderArray(); + Arrays.sort(bsArray, depthComparator); + if (transaction.isLogSummary()) { + transaction.logSummary("BatchControl flush " + Arrays.toString(bsArray)); + } + for (BatchedBeanHolder beanHolder : bsArray) { + beanHolder.executeNow(); + } + } while (!isBeanHoldersEmpty()); + } + + /** + * Return if all bean holders are empty. + */ + private boolean isBeanHoldersEmpty() { + for (BatchedBeanHolder beanHolder : beanHoldMap.values()) { + if (!beanHolder.isEmpty()) { + return false; + } + } + return true; + } + /** * Return an entry for the given type description. The type description is * typically the bean class name (or table name for MapBeans). diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/persist/BatchedBeanHolder.java b/ebean-core/src/main/java/io/ebeaninternal/server/persist/BatchedBeanHolder.java index e343aa760..db43c32d0 100644 --- a/ebean-core/src/main/java/io/ebeaninternal/server/persist/BatchedBeanHolder.java +++ b/ebean-core/src/main/java/io/ebeaninternal/server/persist/BatchedBeanHolder.java @@ -47,6 +47,11 @@ class BatchedBeanHolder { */ private ArrayList deletes; + /** + * The holder is empty + */ + private boolean empty = true; + /** * Create a new entry with a given type and depth. */ @@ -63,6 +68,13 @@ class BatchedBeanHolder { return order; } + /** + * Returns if the BeanHolder is empty. + */ + public boolean isEmpty() { + return empty; + } + /** * Execute all the persist requests in this entry. *

@@ -90,6 +102,7 @@ class BatchedBeanHolder { updates = new ArrayList<>(); control.executeNow(bufferedUpdates); } + empty = true; } @Override @@ -112,9 +125,8 @@ class BatchedBeanHolder { * Add the request to the appropriate persist list. */ public int append(PersistRequestBean request) { - + empty = false; request.setBatched(); - switch (request.getType()) { case INSERT: if (inserts == null) { diff --git a/ebean-core/src/test/java/org/tests/lifecycle/TestLifecycleWithLog.java b/ebean-core/src/test/java/org/tests/lifecycle/TestLifecycleWithLog.java index 08aa845a8..56bb64311 100644 --- a/ebean-core/src/test/java/org/tests/lifecycle/TestLifecycleWithLog.java +++ b/ebean-core/src/test/java/org/tests/lifecycle/TestLifecycleWithLog.java @@ -11,7 +11,6 @@ import org.tests.model.basic.EBasicWithLog; import io.ebean.BaseTestCase; import io.ebean.DB; -import io.ebean.Ebean; public class TestLifecycleWithLog extends BaseTestCase { @@ -31,22 +30,17 @@ public class TestLifecycleWithLog extends BaseTestCase { bean.setName("Test1"); DB.save(bean); - - assertThat(getLogs()).contains("onPersistTrigger", "prePersist", "postPersist"); + assertThat(getLogs()).contains("prePersist", "postPersist"); bean.setName("Test2"); - DB.save(bean); - - assertThat(getLogs()).contains("onPersistTrigger", "preUpdate", "postUpdate"); + assertThat(getLogs()).contains("preUpdate", "postUpdate"); DB.delete(bean); - - assertThat(getLogs()).contains("onPersistTrigger", "preSoftDelete", "postSoftDelete"); + assertThat(getLogs()).contains("preSoftDelete", "postSoftDelete"); DB.deletePermanent(bean); - - assertThat(getLogs()).contains("onPersistTrigger", "preRemove", "postRemove"); + assertThat(getLogs()).contains("preRemove", "postRemove"); } @Test @@ -59,22 +53,17 @@ public class TestLifecycleWithLog extends BaseTestCase { List beans = Arrays.asList(bean); DB.saveAll(beans); + assertThat(getLogs()).contains("prePersist", "postPersist"); - assertThat(getLogs()).contains("onPersistTrigger", "prePersist", "postPersist"); - - bean.setName("Test2"); - + bean.setName("Test2Modified"); DB.saveAll(beans); - - assertThat(getLogs()).contains("onPersistTrigger", "preUpdate", "postUpdate"); + assertThat(getLogs()).contains("preUpdate", "postUpdate"); DB.deleteAll(beans); - - assertThat(getLogs()).contains("onPersistTrigger", "preSoftDelete", "postSoftDelete"); + assertThat(getLogs()).contains("preSoftDelete", "postSoftDelete"); DB.deleteAllPermanent(beans); - - assertThat(getLogs()).contains("onPersistTrigger", "preRemove", "postRemove"); + assertThat(getLogs()).contains("preRemove", "postRemove"); } -} \ No newline at end of file +} diff --git a/ebean-core/src/test/java/org/tests/model/basic/EBasicWithLog.java b/ebean-core/src/test/java/org/tests/model/basic/EBasicWithLog.java index e7f5a6035..743796e52 100644 --- a/ebean-core/src/test/java/org/tests/model/basic/EBasicWithLog.java +++ b/ebean-core/src/test/java/org/tests/model/basic/EBasicWithLog.java @@ -115,17 +115,10 @@ public class EBasicWithLog { this.version = version; } - public void _ebean_onPersistTrigger() { - writeLog("onPersistTrigger"); - } - - /** - * @param string - */ private void writeLog(String title) { EBasicLog log = new EBasicLog(); log.setName(title); DB.save(log); } -} \ No newline at end of file +} From 9ea55052147932f5b71a8437f89b53a095060019 Mon Sep 17 00:00:00 2001 From: rob bygrave Date: Sun, 24 Jan 2021 17:40:13 +1300 Subject: [PATCH 071/447] Bump to ebean agent 12.6.6 --- ebean-bom/pom.xml | 4 ++-- ebean-core/pom.xml | 2 +- ebean-ddl-generator/pom.xml | 2 +- kotlin-querybean-generator/pom.xml | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/ebean-bom/pom.xml b/ebean-bom/pom.xml index 238643d19..357665578 100644 --- a/ebean-bom/pom.xml +++ b/ebean-bom/pom.xml @@ -18,8 +18,8 @@ 12.4.0 4.1 7.0 - 12.6.2 - 12.6.2 + 12.6.6 + 12.6.6 diff --git a/ebean-core/pom.xml b/ebean-core/pom.xml index f937b3253..be3e7870a 100644 --- a/ebean-core/pom.xml +++ b/ebean-core/pom.xml @@ -301,7 +301,7 @@ io.ebean ebean-maven-plugin - 12.5.0 + 12.6.6 test diff --git a/ebean-ddl-generator/pom.xml b/ebean-ddl-generator/pom.xml index 9d728036b..c50f8c4a4 100644 --- a/ebean-ddl-generator/pom.xml +++ b/ebean-ddl-generator/pom.xml @@ -77,7 +77,7 @@ io.ebean ebean-maven-plugin - 12.5.0 + 12.6.6 test diff --git a/kotlin-querybean-generator/pom.xml b/kotlin-querybean-generator/pom.xml index 63019943e..311abbab8 100644 --- a/kotlin-querybean-generator/pom.xml +++ b/kotlin-querybean-generator/pom.xml @@ -144,7 +144,7 @@ io.ebean ebean-maven-plugin - 12.5.0 + 12.6.6 test From 7ec5fe6a8558d441ab5092879beb3524899870dd Mon Sep 17 00:00:00 2001 From: rob bygrave Date: Sun, 24 Jan 2021 17:42:38 +1300 Subject: [PATCH 072/447] [maven-release-plugin] prepare release ebean-parent-12.6.6 --- ebean-api/pom.xml | 2 +- ebean-autotune/pom.xml | 6 +++--- ebean-bom/pom.xml | 30 +++++++++++++++--------------- ebean-core-type/pom.xml | 4 ++-- ebean-core/pom.xml | 10 +++++----- ebean-ddl-generator/pom.xml | 6 +++--- ebean-externalmapping-api/pom.xml | 2 +- ebean-externalmapping-xml/pom.xml | 10 +++++----- ebean-postgis/pom.xml | 6 +++--- ebean-querybean/pom.xml | 10 +++++----- ebean-redis/pom.xml | 12 ++++++------ ebean-test/pom.xml | 8 ++++---- ebean/pom.xml | 12 ++++++------ kotlin-querybean-generator/pom.xml | 8 ++++---- pom.xml | 4 ++-- querybean-generator/pom.xml | 2 +- 16 files changed, 66 insertions(+), 66 deletions(-) diff --git a/ebean-api/pom.xml b/ebean-api/pom.xml index 3fea9a758..96ada2b98 100644 --- a/ebean-api/pom.xml +++ b/ebean-api/pom.xml @@ -4,7 +4,7 @@ ebean-parent io.ebean - 12.6.6-SNAPSHOT + 12.6.6 ebean api diff --git a/ebean-autotune/pom.xml b/ebean-autotune/pom.xml index 7eeae736a..ed237d874 100644 --- a/ebean-autotune/pom.xml +++ b/ebean-autotune/pom.xml @@ -4,7 +4,7 @@ ebean-parent io.ebean - 12.6.6-SNAPSHOT + 12.6.6 @@ -14,7 +14,7 @@ scm:git:git@github.com:ebean-orm/ebean.git - ebean-parent-12.6.5 + ebean-parent-12.6.6 ebean autotune @@ -26,7 +26,7 @@ io.ebean ebean-core - 12.6.6-SNAPSHOT + 12.6.6 provided diff --git a/ebean-bom/pom.xml b/ebean-bom/pom.xml index 357665578..a78c78cc4 100644 --- a/ebean-bom/pom.xml +++ b/ebean-bom/pom.xml @@ -4,7 +4,7 @@ ebean-parent io.ebean - 12.6.6-SNAPSHOT + 12.6.6 ebean bom @@ -81,88 +81,88 @@ io.ebean ebean - 12.6.6-SNAPSHOT + 12.6.6 io.ebean ebean-api - 12.6.6-SNAPSHOT + 12.6.6 io.ebean ebean-core - 12.6.6-SNAPSHOT + 12.6.6 io.ebean ebean-core-type - 12.6.6-SNAPSHOT + 12.6.6 io.ebean ebean-ddl-generator - 12.6.6-SNAPSHOT + 12.6.6 io.ebean ebean-externalmapping-api - 12.6.6-SNAPSHOT + 12.6.6 io.ebean ebean-externalmapping-xml - 12.6.6-SNAPSHOT + 12.6.6 io.ebean ebean-autotune - 12.6.6-SNAPSHOT + 12.6.6 io.ebean ebean-querybean - 12.6.6-SNAPSHOT + 12.6.6 io.ebean querybean-generator - 12.6.6-SNAPSHOT + 12.6.6 provided io.ebean kotlin-querybean-generator - 12.6.6-SNAPSHOT + 12.6.6 provided io.ebean ebean-test - 12.6.6-SNAPSHOT + 12.6.6 test io.ebean ebean-postgis - 12.6.6-SNAPSHOT + 12.6.6 io.ebean ebean-redis - 12.6.6-SNAPSHOT + 12.6.6 diff --git a/ebean-core-type/pom.xml b/ebean-core-type/pom.xml index 4c8d540d9..d3d45a2d4 100644 --- a/ebean-core-type/pom.xml +++ b/ebean-core-type/pom.xml @@ -4,7 +4,7 @@ ebean-parent io.ebean - 12.6.6-SNAPSHOT + 12.6.6 ebean-core-type @@ -21,7 +21,7 @@ io.ebean ebean-api - 12.6.6-SNAPSHOT + 12.6.6 diff --git a/ebean-core/pom.xml b/ebean-core/pom.xml index be3e7870a..fe48156c1 100644 --- a/ebean-core/pom.xml +++ b/ebean-core/pom.xml @@ -3,7 +3,7 @@ ebean-parent io.ebean - 12.6.6-SNAPSHOT + 12.6.6 ebean-core @@ -15,7 +15,7 @@ scm:git:git@github.com:ebean-orm/ebean.git - ebean-parent-12.6.5 + ebean-parent-12.6.6 @@ -92,19 +92,19 @@ io.ebean ebean-api - 12.6.6-SNAPSHOT + 12.6.6 io.ebean ebean-core-type - 12.6.6-SNAPSHOT + 12.6.6 io.ebean ebean-externalmapping-api - 12.6.6-SNAPSHOT + 12.6.6 diff --git a/ebean-ddl-generator/pom.xml b/ebean-ddl-generator/pom.xml index c50f8c4a4..3122c45a1 100644 --- a/ebean-ddl-generator/pom.xml +++ b/ebean-ddl-generator/pom.xml @@ -4,7 +4,7 @@ ebean-parent io.ebean - 12.6.6-SNAPSHOT + 12.6.6 ebean ddl generation @@ -29,14 +29,14 @@ io.ebean ebean-core-type - 12.6.6-SNAPSHOT + 12.6.6 provided io.ebean ebean-core - 12.6.6-SNAPSHOT + 12.6.6 provided diff --git a/ebean-externalmapping-api/pom.xml b/ebean-externalmapping-api/pom.xml index a6b2bea29..a0ac86b55 100644 --- a/ebean-externalmapping-api/pom.xml +++ b/ebean-externalmapping-api/pom.xml @@ -4,7 +4,7 @@ ebean-parent io.ebean - 12.6.6-SNAPSHOT + 12.6.6 ebean external mapping api diff --git a/ebean-externalmapping-xml/pom.xml b/ebean-externalmapping-xml/pom.xml index 0800a6ead..226f1c854 100644 --- a/ebean-externalmapping-xml/pom.xml +++ b/ebean-externalmapping-xml/pom.xml @@ -4,7 +4,7 @@ ebean-parent io.ebean - 12.6.6-SNAPSHOT + 12.6.6 @@ -14,7 +14,7 @@ scm:git:git@github.com:ebean-orm/ebean.git - ebean-parent-12.6.5 + ebean-parent-12.6.6 ebean external mapping xml @@ -33,7 +33,7 @@ io.ebean ebean-externalmapping-api - 12.6.6-SNAPSHOT + 12.6.6 @@ -59,14 +59,14 @@ io.ebean ebean-core - 12.6.6-SNAPSHOT + 12.6.6 test io.ebean ebean-ddl-generator - 12.6.6-SNAPSHOT + 12.6.6 test diff --git a/ebean-postgis/pom.xml b/ebean-postgis/pom.xml index 33ec03cba..37c42fe00 100644 --- a/ebean-postgis/pom.xml +++ b/ebean-postgis/pom.xml @@ -4,7 +4,7 @@ ebean-parent io.ebean - 12.6.6-SNAPSHOT + 12.6.6 ebean postgis @@ -24,7 +24,7 @@ io.ebean ebean-core - 12.6.6-SNAPSHOT + 12.6.6 provided @@ -75,7 +75,7 @@ io.ebean ebean-test - 12.6.6-SNAPSHOT + 12.6.6 test diff --git a/ebean-querybean/pom.xml b/ebean-querybean/pom.xml index 1044f1beb..5bd86b3fd 100644 --- a/ebean-querybean/pom.xml +++ b/ebean-querybean/pom.xml @@ -4,7 +4,7 @@ ebean-parent io.ebean - 12.6.6-SNAPSHOT + 12.6.6 @@ -14,7 +14,7 @@ scm:git:git@github.com:ebean-orm/ebean.git - ebean-parent-12.6.5 + ebean-parent-12.6.6 ebean querybean @@ -27,7 +27,7 @@ io.ebean ebean-core - 12.6.6-SNAPSHOT + 12.6.6 provided @@ -67,14 +67,14 @@ io.ebean ebean-ddl-generator - 12.6.6-SNAPSHOT + 12.6.6 test io.ebean querybean-generator - 12.6.6-SNAPSHOT + 12.6.6 test diff --git a/ebean-redis/pom.xml b/ebean-redis/pom.xml index 24aec559a..a99766abf 100644 --- a/ebean-redis/pom.xml +++ b/ebean-redis/pom.xml @@ -4,7 +4,7 @@ ebean-parent io.ebean - 12.6.6-SNAPSHOT + 12.6.6 ebean-redis @@ -22,35 +22,35 @@ io.ebean ebean-api - 12.6.6-SNAPSHOT + 12.6.6 provided io.ebean ebean-core - 12.6.6-SNAPSHOT + 12.6.6 provided io.ebean ebean-querybean - 12.6.6-SNAPSHOT + 12.6.6 test io.ebean querybean-generator - 12.6.6-SNAPSHOT + 12.6.6 test io.ebean ebean-test - 12.6.6-SNAPSHOT + 12.6.6 test diff --git a/ebean-test/pom.xml b/ebean-test/pom.xml index a5b06f567..2b48a0e80 100644 --- a/ebean-test/pom.xml +++ b/ebean-test/pom.xml @@ -4,7 +4,7 @@ ebean-parent io.ebean - 12.6.6-SNAPSHOT + 12.6.6 @@ -14,7 +14,7 @@ scm:git:git@github.com:ebean-orm/ebean.git - ebean-parent-12.6.5 + ebean-parent-12.6.6 ebean test @@ -43,14 +43,14 @@ io.ebean ebean-core - 12.6.6-SNAPSHOT + 12.6.6 provided io.ebean ebean-ddl-generator - 12.6.6-SNAPSHOT + 12.6.6 diff --git a/ebean/pom.xml b/ebean/pom.xml index 717e60f74..e61c19f3c 100644 --- a/ebean/pom.xml +++ b/ebean/pom.xml @@ -4,7 +4,7 @@ ebean-parent io.ebean - 12.6.6-SNAPSHOT + 12.6.6 ebean composite @@ -22,34 +22,34 @@ io.ebean ebean-api - 12.6.6-SNAPSHOT + 12.6.6 io.ebean ebean-core - 12.6.6-SNAPSHOT + 12.6.6 io.ebean ebean-querybean - 12.6.6-SNAPSHOT + 12.6.6 io.ebean ebean-ddl-generator - 12.6.6-SNAPSHOT + 12.6.6 io.ebean ebean-autotune - 12.6.6-SNAPSHOT + 12.6.6 diff --git a/kotlin-querybean-generator/pom.xml b/kotlin-querybean-generator/pom.xml index 311abbab8..b7c41f940 100644 --- a/kotlin-querybean-generator/pom.xml +++ b/kotlin-querybean-generator/pom.xml @@ -4,7 +4,7 @@ ebean-parent io.ebean - 12.6.6-SNAPSHOT + 12.6.6 kotlin querybean generator @@ -29,7 +29,7 @@ io.ebean ebean-querybean - 12.6.6-SNAPSHOT + 12.6.6 test @@ -43,7 +43,7 @@ io.ebean ebean-core - 12.6.6-SNAPSHOT + 12.6.6 test @@ -64,7 +64,7 @@ io.ebean ebean-ddl-generator - 12.6.6-SNAPSHOT + 12.6.6 test diff --git a/pom.xml b/pom.xml index c37643e30..7e59aad5f 100644 --- a/pom.xml +++ b/pom.xml @@ -9,7 +9,7 @@ io.ebean ebean-parent - 12.6.6-SNAPSHOT + 12.6.6 pom ebean parent @@ -18,7 +18,7 @@ scm:git:git@github.com:ebean-orm/ebean.git - ebean-parent-12.6.5 + ebean-parent-12.6.6 diff --git a/querybean-generator/pom.xml b/querybean-generator/pom.xml index 76b38c320..eb36ba675 100644 --- a/querybean-generator/pom.xml +++ b/querybean-generator/pom.xml @@ -4,7 +4,7 @@ ebean-parent io.ebean - 12.6.6-SNAPSHOT + 12.6.6 querybean generator From fca54dbbe32e98683f4e4a7db6b3467de765013b Mon Sep 17 00:00:00 2001 From: rob bygrave Date: Sun, 24 Jan 2021 17:42:50 +1300 Subject: [PATCH 073/447] [maven-release-plugin] prepare for next development iteration --- ebean-api/pom.xml | 2 +- ebean-autotune/pom.xml | 6 +++--- ebean-bom/pom.xml | 30 +++++++++++++++--------------- ebean-core-type/pom.xml | 4 ++-- ebean-core/pom.xml | 10 +++++----- ebean-ddl-generator/pom.xml | 6 +++--- ebean-externalmapping-api/pom.xml | 2 +- ebean-externalmapping-xml/pom.xml | 10 +++++----- ebean-postgis/pom.xml | 6 +++--- ebean-querybean/pom.xml | 10 +++++----- ebean-redis/pom.xml | 12 ++++++------ ebean-test/pom.xml | 8 ++++---- ebean/pom.xml | 12 ++++++------ kotlin-querybean-generator/pom.xml | 8 ++++---- pom.xml | 4 ++-- querybean-generator/pom.xml | 2 +- 16 files changed, 66 insertions(+), 66 deletions(-) diff --git a/ebean-api/pom.xml b/ebean-api/pom.xml index 96ada2b98..4150e1cb3 100644 --- a/ebean-api/pom.xml +++ b/ebean-api/pom.xml @@ -4,7 +4,7 @@ ebean-parent io.ebean - 12.6.6 + 12.6.7-SNAPSHOT ebean api diff --git a/ebean-autotune/pom.xml b/ebean-autotune/pom.xml index ed237d874..95e695ce8 100644 --- a/ebean-autotune/pom.xml +++ b/ebean-autotune/pom.xml @@ -4,7 +4,7 @@ ebean-parent io.ebean - 12.6.6 + 12.6.7-SNAPSHOT @@ -14,7 +14,7 @@ scm:git:git@github.com:ebean-orm/ebean.git - ebean-parent-12.6.6 + ebean-parent-12.6.5 ebean autotune @@ -26,7 +26,7 @@ io.ebean ebean-core - 12.6.6 + 12.6.7-SNAPSHOT provided diff --git a/ebean-bom/pom.xml b/ebean-bom/pom.xml index a78c78cc4..b3b611006 100644 --- a/ebean-bom/pom.xml +++ b/ebean-bom/pom.xml @@ -4,7 +4,7 @@ ebean-parent io.ebean - 12.6.6 + 12.6.7-SNAPSHOT ebean bom @@ -81,88 +81,88 @@ io.ebean ebean - 12.6.6 + 12.6.7-SNAPSHOT io.ebean ebean-api - 12.6.6 + 12.6.7-SNAPSHOT io.ebean ebean-core - 12.6.6 + 12.6.7-SNAPSHOT io.ebean ebean-core-type - 12.6.6 + 12.6.7-SNAPSHOT io.ebean ebean-ddl-generator - 12.6.6 + 12.6.7-SNAPSHOT io.ebean ebean-externalmapping-api - 12.6.6 + 12.6.7-SNAPSHOT io.ebean ebean-externalmapping-xml - 12.6.6 + 12.6.7-SNAPSHOT io.ebean ebean-autotune - 12.6.6 + 12.6.7-SNAPSHOT io.ebean ebean-querybean - 12.6.6 + 12.6.7-SNAPSHOT io.ebean querybean-generator - 12.6.6 + 12.6.7-SNAPSHOT provided io.ebean kotlin-querybean-generator - 12.6.6 + 12.6.7-SNAPSHOT provided io.ebean ebean-test - 12.6.6 + 12.6.7-SNAPSHOT test io.ebean ebean-postgis - 12.6.6 + 12.6.7-SNAPSHOT io.ebean ebean-redis - 12.6.6 + 12.6.7-SNAPSHOT diff --git a/ebean-core-type/pom.xml b/ebean-core-type/pom.xml index d3d45a2d4..18e8f5bb8 100644 --- a/ebean-core-type/pom.xml +++ b/ebean-core-type/pom.xml @@ -4,7 +4,7 @@ ebean-parent io.ebean - 12.6.6 + 12.6.7-SNAPSHOT ebean-core-type @@ -21,7 +21,7 @@ io.ebean ebean-api - 12.6.6 + 12.6.7-SNAPSHOT diff --git a/ebean-core/pom.xml b/ebean-core/pom.xml index fe48156c1..1c5a407b8 100644 --- a/ebean-core/pom.xml +++ b/ebean-core/pom.xml @@ -3,7 +3,7 @@ ebean-parent io.ebean - 12.6.6 + 12.6.7-SNAPSHOT ebean-core @@ -15,7 +15,7 @@ scm:git:git@github.com:ebean-orm/ebean.git - ebean-parent-12.6.6 + ebean-parent-12.6.5 @@ -92,19 +92,19 @@ io.ebean ebean-api - 12.6.6 + 12.6.7-SNAPSHOT io.ebean ebean-core-type - 12.6.6 + 12.6.7-SNAPSHOT io.ebean ebean-externalmapping-api - 12.6.6 + 12.6.7-SNAPSHOT diff --git a/ebean-ddl-generator/pom.xml b/ebean-ddl-generator/pom.xml index 3122c45a1..c6039a3ca 100644 --- a/ebean-ddl-generator/pom.xml +++ b/ebean-ddl-generator/pom.xml @@ -4,7 +4,7 @@ ebean-parent io.ebean - 12.6.6 + 12.6.7-SNAPSHOT ebean ddl generation @@ -29,14 +29,14 @@ io.ebean ebean-core-type - 12.6.6 + 12.6.7-SNAPSHOT provided io.ebean ebean-core - 12.6.6 + 12.6.7-SNAPSHOT provided diff --git a/ebean-externalmapping-api/pom.xml b/ebean-externalmapping-api/pom.xml index a0ac86b55..b7229936c 100644 --- a/ebean-externalmapping-api/pom.xml +++ b/ebean-externalmapping-api/pom.xml @@ -4,7 +4,7 @@ ebean-parent io.ebean - 12.6.6 + 12.6.7-SNAPSHOT ebean external mapping api diff --git a/ebean-externalmapping-xml/pom.xml b/ebean-externalmapping-xml/pom.xml index 226f1c854..d6fe25f67 100644 --- a/ebean-externalmapping-xml/pom.xml +++ b/ebean-externalmapping-xml/pom.xml @@ -4,7 +4,7 @@ ebean-parent io.ebean - 12.6.6 + 12.6.7-SNAPSHOT @@ -14,7 +14,7 @@ scm:git:git@github.com:ebean-orm/ebean.git - ebean-parent-12.6.6 + ebean-parent-12.6.5 ebean external mapping xml @@ -33,7 +33,7 @@ io.ebean ebean-externalmapping-api - 12.6.6 + 12.6.7-SNAPSHOT @@ -59,14 +59,14 @@ io.ebean ebean-core - 12.6.6 + 12.6.7-SNAPSHOT test io.ebean ebean-ddl-generator - 12.6.6 + 12.6.7-SNAPSHOT test diff --git a/ebean-postgis/pom.xml b/ebean-postgis/pom.xml index 37c42fe00..23f8507e5 100644 --- a/ebean-postgis/pom.xml +++ b/ebean-postgis/pom.xml @@ -4,7 +4,7 @@ ebean-parent io.ebean - 12.6.6 + 12.6.7-SNAPSHOT ebean postgis @@ -24,7 +24,7 @@ io.ebean ebean-core - 12.6.6 + 12.6.7-SNAPSHOT provided @@ -75,7 +75,7 @@ io.ebean ebean-test - 12.6.6 + 12.6.7-SNAPSHOT test diff --git a/ebean-querybean/pom.xml b/ebean-querybean/pom.xml index 5bd86b3fd..1ad6f044f 100644 --- a/ebean-querybean/pom.xml +++ b/ebean-querybean/pom.xml @@ -4,7 +4,7 @@ ebean-parent io.ebean - 12.6.6 + 12.6.7-SNAPSHOT @@ -14,7 +14,7 @@ scm:git:git@github.com:ebean-orm/ebean.git - ebean-parent-12.6.6 + ebean-parent-12.6.5 ebean querybean @@ -27,7 +27,7 @@ io.ebean ebean-core - 12.6.6 + 12.6.7-SNAPSHOT provided @@ -67,14 +67,14 @@ io.ebean ebean-ddl-generator - 12.6.6 + 12.6.7-SNAPSHOT test io.ebean querybean-generator - 12.6.6 + 12.6.7-SNAPSHOT test diff --git a/ebean-redis/pom.xml b/ebean-redis/pom.xml index a99766abf..68c9e2d98 100644 --- a/ebean-redis/pom.xml +++ b/ebean-redis/pom.xml @@ -4,7 +4,7 @@ ebean-parent io.ebean - 12.6.6 + 12.6.7-SNAPSHOT ebean-redis @@ -22,35 +22,35 @@ io.ebean ebean-api - 12.6.6 + 12.6.7-SNAPSHOT provided io.ebean ebean-core - 12.6.6 + 12.6.7-SNAPSHOT provided io.ebean ebean-querybean - 12.6.6 + 12.6.7-SNAPSHOT test io.ebean querybean-generator - 12.6.6 + 12.6.7-SNAPSHOT test io.ebean ebean-test - 12.6.6 + 12.6.7-SNAPSHOT test diff --git a/ebean-test/pom.xml b/ebean-test/pom.xml index 2b48a0e80..7eb65fb64 100644 --- a/ebean-test/pom.xml +++ b/ebean-test/pom.xml @@ -4,7 +4,7 @@ ebean-parent io.ebean - 12.6.6 + 12.6.7-SNAPSHOT @@ -14,7 +14,7 @@ scm:git:git@github.com:ebean-orm/ebean.git - ebean-parent-12.6.6 + ebean-parent-12.6.5 ebean test @@ -43,14 +43,14 @@ io.ebean ebean-core - 12.6.6 + 12.6.7-SNAPSHOT provided io.ebean ebean-ddl-generator - 12.6.6 + 12.6.7-SNAPSHOT diff --git a/ebean/pom.xml b/ebean/pom.xml index e61c19f3c..5732d2910 100644 --- a/ebean/pom.xml +++ b/ebean/pom.xml @@ -4,7 +4,7 @@ ebean-parent io.ebean - 12.6.6 + 12.6.7-SNAPSHOT ebean composite @@ -22,34 +22,34 @@ io.ebean ebean-api - 12.6.6 + 12.6.7-SNAPSHOT io.ebean ebean-core - 12.6.6 + 12.6.7-SNAPSHOT io.ebean ebean-querybean - 12.6.6 + 12.6.7-SNAPSHOT io.ebean ebean-ddl-generator - 12.6.6 + 12.6.7-SNAPSHOT io.ebean ebean-autotune - 12.6.6 + 12.6.7-SNAPSHOT diff --git a/kotlin-querybean-generator/pom.xml b/kotlin-querybean-generator/pom.xml index b7c41f940..5d6336d29 100644 --- a/kotlin-querybean-generator/pom.xml +++ b/kotlin-querybean-generator/pom.xml @@ -4,7 +4,7 @@ ebean-parent io.ebean - 12.6.6 + 12.6.7-SNAPSHOT kotlin querybean generator @@ -29,7 +29,7 @@ io.ebean ebean-querybean - 12.6.6 + 12.6.7-SNAPSHOT test @@ -43,7 +43,7 @@ io.ebean ebean-core - 12.6.6 + 12.6.7-SNAPSHOT test @@ -64,7 +64,7 @@ io.ebean ebean-ddl-generator - 12.6.6 + 12.6.7-SNAPSHOT test diff --git a/pom.xml b/pom.xml index 7e59aad5f..c9e885454 100644 --- a/pom.xml +++ b/pom.xml @@ -9,7 +9,7 @@ io.ebean ebean-parent - 12.6.6 + 12.6.7-SNAPSHOT pom ebean parent @@ -18,7 +18,7 @@ scm:git:git@github.com:ebean-orm/ebean.git - ebean-parent-12.6.6 + ebean-parent-12.6.5 diff --git a/querybean-generator/pom.xml b/querybean-generator/pom.xml index eb36ba675..52c966bea 100644 --- a/querybean-generator/pom.xml +++ b/querybean-generator/pom.xml @@ -4,7 +4,7 @@ ebean-parent io.ebean - 12.6.6 + 12.6.7-SNAPSHOT querybean generator From 0be98d798924b8fedfa94ab0124f1f5a8b266fef Mon Sep 17 00:00:00 2001 From: Rob Bygrave Date: Wed, 3 Feb 2021 14:51:42 +1300 Subject: [PATCH 074/447] Fix to only cancel query once (#2152) Change DefaultOrmQuery.cancel() to call underlying jdbc cancel once - Refactor tidy already cancelled check (pre query execution) - Remove unnecessary extra transaction.end() call on future query execution (as already handled by CallableQueryList etc) --- .../io/ebeaninternal/server/query/CQuery.java | 24 +++++-------------- .../server/query/CQueryEngine.java | 6 ----- .../server/querydefn/DefaultOrmQuery.java | 14 ++--------- .../tests/query/TestQueryFindFutureList.java | 20 +++++++++------- 4 files changed, 19 insertions(+), 45 deletions(-) diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/query/CQuery.java b/ebean-core/src/main/java/io/ebeaninternal/server/query/CQuery.java index f92960419..861ccc337 100644 --- a/ebean-core/src/main/java/io/ebeaninternal/server/query/CQuery.java +++ b/ebean-core/src/main/java/io/ebeaninternal/server/query/CQuery.java @@ -296,10 +296,10 @@ public class CQuery implements DbReadContext, CancelableQuery, SpiProfileTran this.cancelled = true; if (pstmt != null) { try { + logger.debug("Cancelling query"); pstmt.cancel(); } catch (SQLException e) { - String msg = "Error cancelling query"; - throw new PersistenceException(msg, e); + throw new PersistenceException("Error cancelling query", e); } } } finally { @@ -322,7 +322,6 @@ public class CQuery implements DbReadContext, CancelableQuery, SpiProfileTran } private boolean prepareBindExecuteQueryWithOption(boolean forwardOnlyHint) throws SQLException { - ResultSet resultSet = prepareResultSet(forwardOnlyHint); if (resultSet == null) { return false; @@ -334,19 +333,12 @@ public class CQuery implements DbReadContext, CancelableQuery, SpiProfileTran ResultSet prepareResultSet(boolean forwardOnlyHint) throws SQLException { lock.lock(); try { - if (cancelled || query.isCancelled()) { - // cancelled before we started - cancelled = true; - return null; + if (cancelled) { + throw new SQLException("Query cancelled"); } - startNano = System.nanoTime(); - - // prepare SpiTransaction t = request.getTransaction(); profileOffset = t.profileOffset(); - Connection conn = t.getInternalConnection(); - if (query.isRawSql()) { ResultSet suppliedResultSet = query.getRawSql().getResultSet(); if (suppliedResultSet != null) { @@ -356,6 +348,7 @@ public class CQuery implements DbReadContext, CancelableQuery, SpiProfileTran } } + Connection conn = t.getInternalConnection(); if (forwardOnlyHint) { // Use forward only hints for large resultSet processing (Issue 56, MySql specific) pstmt = conn.prepareStatement(sql, ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY); @@ -363,18 +356,13 @@ public class CQuery implements DbReadContext, CancelableQuery, SpiProfileTran } else { pstmt = conn.prepareStatement(sql); } - if (query.getTimeout() > 0) { pstmt.setQueryTimeout(query.getTimeout()); } if (query.getBufferFetchSizeHint() > 0) { pstmt.setFetchSize(query.getBufferFetchSizeHint()); } - - DataBind dataBind = queryPlan.bindEncryptedProperties(pstmt, conn); - bindLog = predicates.bind(dataBind); - - // executeQuery + bindLog = predicates.bind(queryPlan.bindEncryptedProperties(pstmt, conn)); return pstmt.executeQuery(); } finally { lock.unlock(); diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/query/CQueryEngine.java b/ebean-core/src/main/java/io/ebeaninternal/server/query/CQueryEngine.java index f462050fb..945b343ca 100644 --- a/ebean-core/src/main/java/io/ebeaninternal/server/query/CQueryEngine.java +++ b/ebean-core/src/main/java/io/ebeaninternal/server/query/CQueryEngine.java @@ -401,12 +401,6 @@ public class CQueryEngine { if (cquery != null) { cquery.close(); } - if (request.getQuery().isFutureFetch()) { - // end the transaction for futureFindIds - // as it had it's own transaction - logger.debug("Future fetch completed!"); - request.getTransaction().end(); - } } } diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/querydefn/DefaultOrmQuery.java b/ebean-core/src/main/java/io/ebeaninternal/server/querydefn/DefaultOrmQuery.java index 39d7b350d..2f73bceb7 100644 --- a/ebean-core/src/main/java/io/ebeaninternal/server/querydefn/DefaultOrmQuery.java +++ b/ebean-core/src/main/java/io/ebeaninternal/server/querydefn/DefaultOrmQuery.java @@ -751,7 +751,6 @@ public class DefaultOrmQuery implements SpiQuery { @Override public NaturalKeyQueryData naturalKey() { - if (whereExpressions == null) { return null; } @@ -767,7 +766,6 @@ public class DefaultOrmQuery implements SpiQuery { return null; } } - return data; } @@ -815,7 +813,6 @@ public class DefaultOrmQuery implements SpiQuery { copy.m2mIncludeJoin = m2mIncludeJoin; copy.profilingListener = profilingListener; copy.profileLocation = profileLocation; - copy.baseTable = baseTable; copy.rootTableAlias = rootTableAlias; copy.distinct = distinct; @@ -1100,7 +1097,6 @@ public class DefaultOrmQuery implements SpiQuery { @Override public ObjectGraphNode setOrigin(CallOrigin callOrigin) { - // create a 'origin' which links this query to the profiling information ObjectGraphOrigin o = new ObjectGraphOrigin(calculateOriginQueryHash(), callOrigin, beanType.getName()); parentNode = new ObjectGraphNode(o, null); @@ -1241,7 +1237,6 @@ public class DefaultOrmQuery implements SpiQuery { */ @Override public CQueryPlanKey prepare(SpiOrmQueryRequest request) { - prepareExpressions(request); prepareForPaging(); queryPlanKey = createQueryPlanKey(); @@ -1252,7 +1247,6 @@ public class DefaultOrmQuery implements SpiQuery { * Prepare the expressions (compile sub-queries etc). */ private void prepareExpressions(BeanQueryRequest request) { - if (whereExpressions != null) { whereExpressions.prepareExpression(request); } @@ -1267,7 +1261,6 @@ public class DefaultOrmQuery implements SpiQuery { * case, this is not a distinct query */ private void prepareForPaging() { - // add the rawSql statement - if any if (orderByIsEmpty()) { if (rawSql != null && rawSql.getSql() != null) { @@ -1678,7 +1671,6 @@ public class DefaultOrmQuery implements SpiQuery { return this; } } - if (bindParams == null) { bindParams = new BindParams(); } @@ -1972,7 +1964,6 @@ public class DefaultOrmQuery implements SpiQuery { if (namedParams == null) { namedParams = new HashMap<>(); } - return namedParams.computeIfAbsent(name, ONamedParam::new); } @@ -2066,8 +2057,8 @@ public class DefaultOrmQuery implements SpiQuery { public void cancel() { lock.lock(); try { - cancelled = true; - if (cancelableQuery != null) { + if (!cancelled && cancelableQuery != null) { + cancelled = true; cancelableQuery.cancel(); } } finally { @@ -2095,7 +2086,6 @@ public class DefaultOrmQuery implements SpiQuery { */ @Override public Set validate(BeanType desc) { - SpiExpressionValidation validation = new SpiExpressionValidation(desc); if (whereExpressions != null) { whereExpressions.validate(validation); diff --git a/ebean-core/src/test/java/org/tests/query/TestQueryFindFutureList.java b/ebean-core/src/test/java/org/tests/query/TestQueryFindFutureList.java index 6fb623e06..074603e41 100644 --- a/ebean-core/src/test/java/org/tests/query/TestQueryFindFutureList.java +++ b/ebean-core/src/test/java/org/tests/query/TestQueryFindFutureList.java @@ -1,7 +1,7 @@ package org.tests.query; import io.ebean.BaseTestCase; -import io.ebean.Ebean; +import io.ebean.DB; import io.ebean.FutureList; import io.ebean.Transaction; import org.tests.model.basic.Order; @@ -22,17 +22,19 @@ public class TestQueryFindFutureList extends BaseTestCase { ResetBasicData.reset(); // warm the connection pool - Transaction t0 = Ebean.getServer(null).createTransaction(); - Transaction t1 = Ebean.getServer(null).createTransaction(); - Transaction t2 = Ebean.getServer(null).createTransaction(); + Transaction t0 = DB.createTransaction(); + Transaction t1 = DB.createTransaction(); + Transaction t2 = DB.createTransaction(); t0.end(); t1.end(); t2.end(); - FutureList futureList = Ebean.find(Order.class).findFutureList(); + FutureList futureList = DB.find(Order.class).findFutureList(); Thread.sleep(10); futureList.cancel(true); + // calling again is ignored + futureList.cancel(true); // don't shutdown immediately Thread.sleep(50); @@ -43,12 +45,12 @@ public class TestQueryFindFutureList extends BaseTestCase { ResetBasicData.reset(); - FutureList futureList = Ebean.find(Order.class).findFutureList(); + FutureList futureList = DB.find(Order.class).findFutureList(); // wait for it to complete List orders = futureList.getUnchecked(); - assertEquals(Ebean.find(Order.class).findCount(), orders.size()); + assertEquals(DB.find(Order.class).findCount(), orders.size()); } @Test @@ -56,12 +58,12 @@ public class TestQueryFindFutureList extends BaseTestCase { ResetBasicData.reset(); - FutureList futureList = Ebean.find(Order.class).findFutureList(); + FutureList futureList = DB.find(Order.class).findFutureList(); // wait for it to complete List orders = futureList.getUnchecked(1, TimeUnit.SECONDS); - assertEquals(Ebean.find(Order.class).findCount(), orders.size()); + assertEquals(DB.find(Order.class).findCount(), orders.size()); } } From dd080c5933fce8f7a63481a47a91482ae41a5ce8 Mon Sep 17 00:00:00 2001 From: Robin Bygrave Date: Thu, 4 Feb 2021 15:19:34 +1300 Subject: [PATCH 075/447] Test only change - refactor update TestBeanState --- .../org/tests/batchload/TestBeanState.java | 73 ++++++++++++++++++ .../org/tests/batchload/TestLoadOnDirty.java | 74 ------------------- 2 files changed, 73 insertions(+), 74 deletions(-) create mode 100644 ebean-core/src/test/java/org/tests/batchload/TestBeanState.java delete mode 100644 ebean-core/src/test/java/org/tests/batchload/TestLoadOnDirty.java diff --git a/ebean-core/src/test/java/org/tests/batchload/TestBeanState.java b/ebean-core/src/test/java/org/tests/batchload/TestBeanState.java new file mode 100644 index 000000000..0d2c2b60f --- /dev/null +++ b/ebean-core/src/test/java/org/tests/batchload/TestBeanState.java @@ -0,0 +1,73 @@ +package org.tests.batchload; + +import io.ebean.BaseTestCase; +import io.ebean.BeanState; +import io.ebean.DB; +import io.ebean.bean.EntityBean; +import io.ebean.bean.EntityBeanIntercept; +import org.junit.Test; +import org.tests.model.basic.Customer; +import org.tests.model.basic.ResetBasicData; + +import java.util.List; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.junit.Assert.*; + + +public class TestBeanState extends BaseTestCase { + + @Test + public void test() { + + ResetBasicData.reset(); + + List custs = DB.find(Customer.class).findList(); + + Customer customer = DB.find(Customer.class).setId(custs.get(0).getId()).select("name") + .setUseCache(false) + .findOne(); + + BeanState beanState = DB.getBeanState(customer); + assertFalse(beanState.isNew()); + assertFalse(beanState.isDirty()); + assertFalse(beanState.isNewOrDirty()); + assertNotNull(beanState.getLoadedProps()); + + customer.setName("dirtyNameProp"); + assertTrue(beanState.isDirty()); + assertThat(beanState.getChangedProps()).containsOnly("name"); + + EntityBeanIntercept ebi = ((EntityBean) customer)._ebean_getIntercept(); + boolean[] dirtyProperties = ebi.getDirtyProperties(); + for (int i = 0; i < dirtyProperties.length; i++) { + if (dirtyProperties[i]) { + String dirtyPropertyName = ebi.getProperty(i); + assertEquals("name", dirtyPropertyName); + } + } + + customer.setStatus(Customer.Status.INACTIVE); + + assertTrue(beanState.isDirty()); + assertThat(beanState.getChangedProps()).containsOnly("name", "status"); + } + + @Test + public void setDisableLazyLoad_expect_lazyLoadingDisabled() { + + ResetBasicData.reset(); + + List custs = DB.find(Customer.class).order("id").findList(); + + Customer customer = DB.find(Customer.class) + .setId(custs.get(0).getId()) + .select("id") + .setUseCache(false) + .findOne(); + + BeanState beanState = DB.getBeanState(customer); + beanState.setDisableLazyLoad(true); + assertNull(customer.getName()); + } +} diff --git a/ebean-core/src/test/java/org/tests/batchload/TestLoadOnDirty.java b/ebean-core/src/test/java/org/tests/batchload/TestLoadOnDirty.java deleted file mode 100644 index 67d35f440..000000000 --- a/ebean-core/src/test/java/org/tests/batchload/TestLoadOnDirty.java +++ /dev/null @@ -1,74 +0,0 @@ -package org.tests.batchload; - -import io.ebean.BaseTestCase; -import io.ebean.BeanState; -import io.ebean.Ebean; -import io.ebean.bean.EntityBean; -import io.ebean.bean.EntityBeanIntercept; -import org.tests.model.basic.Customer; -import org.tests.model.basic.ResetBasicData; -import org.junit.Assert; -import org.junit.Test; - -import java.util.List; - -public class TestLoadOnDirty extends BaseTestCase { - - @Test - public void test() { - - ResetBasicData.reset(); - - List custs = Ebean.find(Customer.class).findList(); - - Customer customer = Ebean.find(Customer.class).setId(custs.get(0).getId()).select("name") - .setUseCache(false) - .findOne(); - - BeanState beanState = Ebean.getBeanState(customer); - Assert.assertTrue(!beanState.isNew()); - Assert.assertTrue(!beanState.isDirty()); - Assert.assertTrue(!beanState.isNewOrDirty()); - Assert.assertNotNull(beanState.getLoadedProps()); - - customer.setName("dirtyNameProp"); - Assert.assertTrue(beanState.isDirty()); - Assert.assertTrue(beanState.getChangedProps().contains("name")); - Assert.assertEquals(1, beanState.getChangedProps().size()); - - EntityBeanIntercept ebi = ((EntityBean) customer)._ebean_getIntercept(); - boolean[] dirtyProperties = ebi.getDirtyProperties(); - for (int i = 0; i < dirtyProperties.length; i++) { - if (dirtyProperties[i]) { - String dirtyPropertyName = ebi.getProperty(i); - Assert.assertEquals("name", dirtyPropertyName); - } - } - - customer.setStatus(Customer.Status.INACTIVE); - - Assert.assertTrue(beanState.isDirty()); - Assert.assertTrue(beanState.getChangedProps().contains("status")); - Assert.assertTrue(beanState.getChangedProps().contains("name")); - Assert.assertEquals(2, beanState.getChangedProps().size()); - - } - - @Test - public void testDisableLazyLoad() { - - ResetBasicData.reset(); - - List custs = Ebean.find(Customer.class).order("id").findList(); - - Customer customer = Ebean.find(Customer.class) - .setId(custs.get(0).getId()) - .select("id") - .setUseCache(false) - .findOne(); - - BeanState beanState = Ebean.getBeanState(customer); - beanState.setDisableLazyLoad(true); - Assert.assertNull(customer.getName()); - } -} From d57657c2091be6e70af9154a4adc9734b90bcc34 Mon Sep 17 00:00:00 2001 From: Robin Bygrave Date: Thu, 4 Feb 2021 15:45:19 +1300 Subject: [PATCH 076/447] #2127 - Fix for - Adding a new list of children to @OneToMany with orphanRemoval true does not delete existing orphans Modifies EntityBeanIntercept preSetterMany to set the changed state on the many property and use this in SaveManyBeans to detect when the existing beans need orphan removal --- .../io/ebean/bean/EntityBeanIntercept.java | 10 ++- .../server/persist/SaveManyBeans.java | 22 ++----- .../org/tests/batchload/TestBeanState.java | 64 +++++++++++++++++++ .../tests/cascade/TestDeleteO2MOrphans.java | 3 +- 4 files changed, 79 insertions(+), 20 deletions(-) diff --git a/ebean-api/src/main/java/io/ebean/bean/EntityBeanIntercept.java b/ebean-api/src/main/java/io/ebean/bean/EntityBeanIntercept.java index b49c6f8ae..12f3fda8f 100644 --- a/ebean-api/src/main/java/io/ebean/bean/EntityBeanIntercept.java +++ b/ebean-api/src/main/java/io/ebean/bean/EntityBeanIntercept.java @@ -931,10 +931,14 @@ public final class EntityBeanIntercept implements Serializable { * OneToMany and ManyToMany only set loaded state. */ public void preSetterMany(boolean interceptField, int propertyIndex, Object oldValue, Object newValue) { - if (readOnly) { - throw new IllegalStateException("This bean is readOnly"); + if (state == STATE_NEW) { + setLoadedProperty(propertyIndex); + } else { + if (readOnly) { + throw new IllegalStateException("This bean is readOnly"); + } + setChangedProperty(propertyIndex); } - setLoadedProperty(propertyIndex); } private void setChangedPropertyValue(int propertyIndex, boolean setDirtyState, Object origValue) { diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/persist/SaveManyBeans.java b/ebean-core/src/main/java/io/ebeaninternal/server/persist/SaveManyBeans.java index 183956ef8..f273b9dbc 100644 --- a/ebean-core/src/main/java/io/ebeaninternal/server/persist/SaveManyBeans.java +++ b/ebean-core/src/main/java/io/ebeaninternal/server/persist/SaveManyBeans.java @@ -210,18 +210,6 @@ public class SaveManyBeans extends SaveManyBase { return true; } - private boolean hasNewOrDirtyBeans() { - if (collection == null) { - return false; - } - for (Object bean : collection) { - if (bean instanceof EntityBean && ((EntityBean) bean)._ebean_getIntercept().isNewOrDirty()) { - return true; - } - } - return false; - } - /** * Collect the Id values of the details to remove 'missing children' for stateless updates. */ @@ -344,14 +332,18 @@ public class SaveManyBeans extends SaveManyBase { transaction.depth(-1); } + private boolean isChangedProperty() { + return parentBean._ebean_getIntercept().isChangedProperty(many.getPropertyIndex()); + } + private void removeAssocManyOrphans() { if (value == null) { return; } if (!(value instanceof BeanCollection)) { -// if (!insertedParent && cascade && hasNewOrDirtyBeans()) { -// persister.addToFlushQueue(many.deleteByParentId(request.getBeanId(), null), transaction, 0); -// } + if (!insertedParent && cascade && isChangedProperty()) { + persister.addToFlushQueue(many.deleteByParentId(request.getBeanId(), null), transaction, 0); + } } else { BeanCollection c = (BeanCollection) value; Set modifyRemovals = c.getModifyRemovals(); diff --git a/ebean-core/src/test/java/org/tests/batchload/TestBeanState.java b/ebean-core/src/test/java/org/tests/batchload/TestBeanState.java index 0d2c2b60f..28161dc3d 100644 --- a/ebean-core/src/test/java/org/tests/batchload/TestBeanState.java +++ b/ebean-core/src/test/java/org/tests/batchload/TestBeanState.java @@ -9,6 +9,7 @@ import org.junit.Test; import org.tests.model.basic.Customer; import org.tests.model.basic.ResetBasicData; +import java.util.ArrayList; import java.util.List; import static org.assertj.core.api.Assertions.assertThat; @@ -70,4 +71,67 @@ public class TestBeanState extends BaseTestCase { beanState.setDisableLazyLoad(true); assertNull(customer.getName()); } + + @Test + public void getChangedProps_when_setManyProperty() { + + ResetBasicData.reset(); + + Customer customer = DB.find(Customer.class).order("id").setMaxRows(1).findOne(); + + BeanState beanState = DB.getBeanState(customer); + assertThat(beanState.getChangedProps()).isEmpty(); + + customer.setContacts(new ArrayList<>()); + assertThat(beanState.getChangedProps()).containsOnly("contacts"); + } + + @Test + public void getChangedProps_when_setManyProperty_onNewBean() { + + Customer customer = new Customer(); + + BeanState beanState = DB.getBeanState(customer); + assertThat(beanState.getChangedProps()).isEmpty(); + + // when new state, then loaded + customer.setContacts(new ArrayList<>()); + assertThat(beanState.getChangedProps()).isEmpty(); + assertThat(beanState.getLoadedProps()).containsOnly("contacts"); + + // set loaded state, then marked as changed + beanState.setLoaded(); + customer.setContacts(new ArrayList<>()); + assertThat(beanState.getLoadedProps()).containsOnly("contacts"); + assertThat(beanState.getChangedProps()).containsOnly("contacts"); + } + + @Test(expected = IllegalStateException.class) + public void readOnly_when_setManyProperty() { + + Customer customer = new Customer(); + customer.setContacts(new ArrayList<>()); + + BeanState beanState = DB.getBeanState(customer); + beanState.setLoaded(); + beanState.setReadOnly(true); + + // act, try to mutate read only bean + customer.setContacts(new ArrayList<>()); + } + + + @Test(expected = IllegalStateException.class) + public void readOnly_when_setProperty() { + + Customer customer = new Customer(); + customer.setName("a"); + + BeanState beanState = DB.getBeanState(customer); + beanState.setLoaded(); + beanState.setReadOnly(true); + + // act, try to mutate read only bean + customer.setName("b"); + } } diff --git a/ebean-core/src/test/java/org/tests/cascade/TestDeleteO2MOrphans.java b/ebean-core/src/test/java/org/tests/cascade/TestDeleteO2MOrphans.java index 468187657..f4356d2bf 100644 --- a/ebean-core/src/test/java/org/tests/cascade/TestDeleteO2MOrphans.java +++ b/ebean-core/src/test/java/org/tests/cascade/TestDeleteO2MOrphans.java @@ -19,8 +19,7 @@ public class TestDeleteO2MOrphans extends BaseTestCase { // assert COOne check = findById(id); - //FIXME #2127 #2141: assertThat(check.getChildren()).hasSize(2); - assertThat(check.getChildren()).hasSize(4); + assertThat(check.getChildren()).hasSize(2); DB.delete(check); } From b3d439ed113727b568427581e7918016f5c7c374 Mon Sep 17 00:00:00 2001 From: Robin Bygrave Date: Wed, 10 Feb 2021 13:00:50 +1300 Subject: [PATCH 077/447] Bump tile-maven-plugin to 2.19 --- ebean-autotune/pom.xml | 2 +- ebean-externalmapping-xml/pom.xml | 2 +- ebean-postgis/pom.xml | 2 +- ebean-querybean/pom.xml | 2 +- ebean-redis/pom.xml | 2 +- ebean-test/pom.xml | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/ebean-autotune/pom.xml b/ebean-autotune/pom.xml index 95e695ce8..5892fda8e 100644 --- a/ebean-autotune/pom.xml +++ b/ebean-autotune/pom.xml @@ -59,7 +59,7 @@ io.repaint.maven tiles-maven-plugin - 2.18 + 2.19 true diff --git a/ebean-externalmapping-xml/pom.xml b/ebean-externalmapping-xml/pom.xml index d6fe25f67..7364bff24 100644 --- a/ebean-externalmapping-xml/pom.xml +++ b/ebean-externalmapping-xml/pom.xml @@ -84,7 +84,7 @@ io.repaint.maven tiles-maven-plugin - 2.18 + 2.19 true diff --git a/ebean-postgis/pom.xml b/ebean-postgis/pom.xml index 23f8507e5..1240f27fe 100644 --- a/ebean-postgis/pom.xml +++ b/ebean-postgis/pom.xml @@ -102,7 +102,7 @@ io.repaint.maven tiles-maven-plugin - 2.18 + 2.19 true diff --git a/ebean-querybean/pom.xml b/ebean-querybean/pom.xml index 1ad6f044f..3cd58500d 100644 --- a/ebean-querybean/pom.xml +++ b/ebean-querybean/pom.xml @@ -101,7 +101,7 @@ io.repaint.maven tiles-maven-plugin - 2.18 + 2.19 true diff --git a/ebean-redis/pom.xml b/ebean-redis/pom.xml index 68c9e2d98..35d45e38a 100644 --- a/ebean-redis/pom.xml +++ b/ebean-redis/pom.xml @@ -76,7 +76,7 @@ io.repaint.maven tiles-maven-plugin - 2.18 + 2.19 true diff --git a/ebean-test/pom.xml b/ebean-test/pom.xml index 7eb65fb64..0c3632dd5 100644 --- a/ebean-test/pom.xml +++ b/ebean-test/pom.xml @@ -146,7 +146,7 @@ io.repaint.maven tiles-maven-plugin - 2.18 + 2.19 true From ab9cdd8f5b89adbe85991dba4f12cf7bf5c2f809 Mon Sep 17 00:00:00 2001 From: Robin Bygrave Date: Wed, 10 Feb 2021 13:52:29 +1300 Subject: [PATCH 078/447] #2153 - QueryBeans: OneToMany Map property is handled as PScalar instead of TQAssocBean --- .../java/org/example/domain/BaseModel.java | 12 +++---- .../test/java/org/example/domain/Contact.java | 21 ++++++------ .../java/org/example/domain/ContactOther.java | 32 +++++++++++++++++++ .../test/java/org/querytest/QContactTest.java | 15 +++++++++ .../generator/ProcessingContext.java | 9 ++++++ .../generator/ProcessingContext.java | 5 +++ 6 files changed, 78 insertions(+), 16 deletions(-) create mode 100644 ebean-querybean/src/test/java/org/example/domain/ContactOther.java create mode 100644 ebean-querybean/src/test/java/org/querytest/QContactTest.java diff --git a/ebean-querybean/src/test/java/org/example/domain/BaseModel.java b/ebean-querybean/src/test/java/org/example/domain/BaseModel.java index 593aa1ce4..211d3141c 100644 --- a/ebean-querybean/src/test/java/org/example/domain/BaseModel.java +++ b/ebean-querybean/src/test/java/org/example/domain/BaseModel.java @@ -1,8 +1,8 @@ package org.example.domain; import io.ebean.Model; -import io.ebean.annotation.CreatedTimestamp; -import io.ebean.annotation.UpdatedTimestamp; +import io.ebean.annotation.WhenCreated; +import io.ebean.annotation.WhenModified; import javax.persistence.Id; import javax.persistence.MappedSuperclass; @@ -11,10 +11,10 @@ import java.sql.Timestamp; /** * Base domain object with Id, version, whenCreated and whenUpdated. - * + * *

* Extending Model to enable the 'active record' style. - * + * *

* whenCreated and whenUpdated are generally useful for maintaining external search services (like * elasticsearch) and audit. @@ -28,10 +28,10 @@ public abstract class BaseModel extends Model { @Version Long version; - @CreatedTimestamp + @WhenCreated Timestamp whenCreated; - @UpdatedTimestamp + @WhenModified Timestamp whenUpdated; public Long getId() { diff --git a/ebean-querybean/src/test/java/org/example/domain/Contact.java b/ebean-querybean/src/test/java/org/example/domain/Contact.java index e47f66248..00035d80a 100644 --- a/ebean-querybean/src/test/java/org/example/domain/Contact.java +++ b/ebean-querybean/src/test/java/org/example/domain/Contact.java @@ -2,13 +2,10 @@ package org.example.domain; import io.ebean.annotation.DbArray; -import javax.persistence.Column; -import javax.persistence.Entity; -import javax.persistence.ManyToOne; -import javax.persistence.OneToMany; -import javax.persistence.Table; +import javax.persistence.*; import java.util.ArrayList; import java.util.List; +import java.util.Map; /** * Contact entity bean. @@ -22,28 +19,32 @@ public class Contact extends BaseModel { @Column(length=50) String firstName; - + @Column(length=50) String lastName; - + @Column(length=200) String email; @Column(length=20) String phone; - + @ManyToOne(optional=false) Customer customer; @OneToMany(mappedBy = "contact") List notes; + @OneToMany(cascade = CascadeType.PERSIST) + @MapKey(name="key") + Map others; + /** * Default constructor. */ public Contact() { } - + /** * Construct with a firstName and lastName. */ @@ -51,7 +52,7 @@ public class Contact extends BaseModel { this.firstName = firstName; this.lastName = lastName; } - + public String getFirstName() { return firstName; } diff --git a/ebean-querybean/src/test/java/org/example/domain/ContactOther.java b/ebean-querybean/src/test/java/org/example/domain/ContactOther.java new file mode 100644 index 000000000..731def6d6 --- /dev/null +++ b/ebean-querybean/src/test/java/org/example/domain/ContactOther.java @@ -0,0 +1,32 @@ +package org.example.domain; + +import javax.persistence.Entity; +import javax.persistence.Table; + +/** + * Contact entity bean. + */ +@Entity +@Table(name="be_contact_other") +public class ContactOther extends BaseModel { + + String key; + + int something; + + public String getKey() { + return key; + } + + public void setKey(String key) { + this.key = key; + } + + public int getSomething() { + return something; + } + + public void setSomething(int something) { + this.something = something; + } +} diff --git a/ebean-querybean/src/test/java/org/querytest/QContactTest.java b/ebean-querybean/src/test/java/org/querytest/QContactTest.java new file mode 100644 index 000000000..ff37f789e --- /dev/null +++ b/ebean-querybean/src/test/java/org/querytest/QContactTest.java @@ -0,0 +1,15 @@ +package org.querytest; + +import org.example.domain.query.QContact; +import org.junit.Test; + +public class QContactTest { + + @Test + public void test_oneToManyMap() { + + new QContact() + .others.fetch() + .findList(); + } +} diff --git a/kotlin-querybean-generator/src/main/java/io/ebean/querybean/generator/ProcessingContext.java b/kotlin-querybean-generator/src/main/java/io/ebean/querybean/generator/ProcessingContext.java index 327f67746..dc045bcf6 100644 --- a/kotlin-querybean-generator/src/main/java/io/ebean/querybean/generator/ProcessingContext.java +++ b/kotlin-querybean-generator/src/main/java/io/ebean/querybean/generator/ProcessingContext.java @@ -330,6 +330,15 @@ class ProcessingContext implements Constants { } } } + } else if (typeArguments.size() == 2) { + TypeMirror argType = typeArguments.get(1); + if (argType.getKind() == TypeKind.WILDCARD) { + argType = ((WildcardType) argType).getExtendsBound(); + } + Element argElement = typeUtils.asElement(argType); + if (isEntityOrEmbedded(argElement)) { + return createPropertyTypeAssoc(typeDef(argElement.asType())); + } } } diff --git a/querybean-generator/src/main/java/io/ebean/querybean/generator/ProcessingContext.java b/querybean-generator/src/main/java/io/ebean/querybean/generator/ProcessingContext.java index faec817bf..6e41747d0 100644 --- a/querybean-generator/src/main/java/io/ebean/querybean/generator/ProcessingContext.java +++ b/querybean-generator/src/main/java/io/ebean/querybean/generator/ProcessingContext.java @@ -341,6 +341,11 @@ class ProcessingContext implements Constants { } } } + } else if (typeArguments.size() == 2) { + Element argElement = typeUtils.asElement(typeArguments.get(1)); + if (isEntityOrEmbedded(argElement)) { + return createPropertyTypeAssoc(typeDef(argElement.asType())); + } } return null; } From 53aacabce7fadb4b74072e4a05ffef383c163b22 Mon Sep 17 00:00:00 2001 From: Robin Bygrave Date: Wed, 10 Feb 2021 15:10:03 +1300 Subject: [PATCH 079/447] #2154 - QueryBeans: TargetEntity is not evaluated during bean generation resulting in bad query beans --- .../java/org/example/domain/AreaImpl.java | 35 ++++++++++++++++++ .../java/org/example/domain/CityImpl.java | 36 +++++++++++++++++++ .../java/org/example/domain/CountryImpl.java | 18 ++++++++++ .../test/java/org/querytest/TargetTest.java | 24 +++++++++++++ .../generator/ProcessingContext.java | 30 +++++++--------- .../generator/ProcessingContext.java | 18 +++++----- 6 files changed, 134 insertions(+), 27 deletions(-) create mode 100644 ebean-querybean/src/test/java/org/example/domain/AreaImpl.java create mode 100644 ebean-querybean/src/test/java/org/example/domain/CityImpl.java create mode 100644 ebean-querybean/src/test/java/org/example/domain/CountryImpl.java create mode 100644 ebean-querybean/src/test/java/org/querytest/TargetTest.java diff --git a/ebean-querybean/src/test/java/org/example/domain/AreaImpl.java b/ebean-querybean/src/test/java/org/example/domain/AreaImpl.java new file mode 100644 index 000000000..940f9eb83 --- /dev/null +++ b/ebean-querybean/src/test/java/org/example/domain/AreaImpl.java @@ -0,0 +1,35 @@ +package org.example.domain; + +import org.example.domain.target.ACity; + +import javax.persistence.CascadeType; +import javax.persistence.Entity; +import javax.persistence.Id; +import javax.persistence.OneToMany; +import java.util.List; + +@Entity +public class AreaImpl { + + @Id + long id; + + @OneToMany(targetEntity = CityImpl.class, cascade = CascadeType.ALL) + List cities; + + public long getId() { + return id; + } + + public void setId(long id) { + this.id = id; + } + + public List getCities() { + return cities; + } + + public void setCities(List cities) { + this.cities = cities; + } +} diff --git a/ebean-querybean/src/test/java/org/example/domain/CityImpl.java b/ebean-querybean/src/test/java/org/example/domain/CityImpl.java new file mode 100644 index 000000000..b42949671 --- /dev/null +++ b/ebean-querybean/src/test/java/org/example/domain/CityImpl.java @@ -0,0 +1,36 @@ +package org.example.domain; + +import org.example.domain.target.ACity; +import org.example.domain.target.ACountry; + +import javax.persistence.Entity; +import javax.persistence.Id; +import javax.persistence.ManyToOne; + +@Entity +public class CityImpl implements ACity { + + @Id + long id; + + String name; + + @ManyToOne(targetEntity = CountryImpl.class) + ACountry country; + + @Override + public long id() { + return id; + } + + @Override + public String name() { + return null; + } + + @Override + public ACountry country() { + return country; + } + +} diff --git a/ebean-querybean/src/test/java/org/example/domain/CountryImpl.java b/ebean-querybean/src/test/java/org/example/domain/CountryImpl.java new file mode 100644 index 000000000..ed8ac7759 --- /dev/null +++ b/ebean-querybean/src/test/java/org/example/domain/CountryImpl.java @@ -0,0 +1,18 @@ +package org.example.domain; + +import org.example.domain.target.ACountry; + +import javax.persistence.Entity; +import javax.persistence.Id; + +@Entity +public class CountryImpl implements ACountry { + + @Id + String code; + + @Override + public String code() { + return code; + } +} diff --git a/ebean-querybean/src/test/java/org/querytest/TargetTest.java b/ebean-querybean/src/test/java/org/querytest/TargetTest.java new file mode 100644 index 000000000..8e83e5c05 --- /dev/null +++ b/ebean-querybean/src/test/java/org/querytest/TargetTest.java @@ -0,0 +1,24 @@ +package org.querytest; + +import org.example.domain.query.QAreaImpl; +import org.example.domain.query.QCityImpl; +import org.junit.Test; + +public class TargetTest { + + @Test + public void test_oneToMany() { + + new QAreaImpl() + .cities.fetch() + .findList(); + } + + @Test + public void test_manyToOne() { + + new QCityImpl() + .country.fetch() + .findList(); + } +} diff --git a/kotlin-querybean-generator/src/main/java/io/ebean/querybean/generator/ProcessingContext.java b/kotlin-querybean-generator/src/main/java/io/ebean/querybean/generator/ProcessingContext.java index dc045bcf6..5580c3b09 100644 --- a/kotlin-querybean-generator/src/main/java/io/ebean/querybean/generator/ProcessingContext.java +++ b/kotlin-querybean-generator/src/main/java/io/ebean/querybean/generator/ProcessingContext.java @@ -303,12 +303,19 @@ class ProcessingContext implements Constants { return new PropertyTypeEnum(fullType, Split.shortName(fullType)); } + // look for targetEntity annotation attribute + final String targetEntity = readTargetEntity(field); + if (targetEntity != null) { + final TypeElement element = elementUtils.getTypeElement(targetEntity); + if (isEntityOrEmbedded(element)) { + return createPropertyTypeAssoc(typeDef(element.asType())); + } + } if (isEntityOrEmbedded(fieldType)) { // public QAssocContact contacts; return createPropertyTypeAssoc(typeDef(typeMirror)); } - PropertyType result = null; if (typeMirror.getKind() == TypeKind.DECLARED) { DeclaredType declaredType = (DeclaredType) typeMirror; List typeArguments = declaredType.getTypeArguments(); @@ -319,16 +326,7 @@ class ProcessingContext implements Constants { } Element argElement = typeUtils.asElement(argType); if (isEntityOrEmbedded(argElement)) { - result = createPropertyTypeAssoc(typeDef(argElement.asType())); - } else { - // look for targetEntity annotation attribute - final String targetEntity = readTargetEntity(field); - if (targetEntity != null) { - final TypeElement element = elementUtils.getTypeElement(targetEntity); - if (isEntityOrEmbedded(element)) { - result = createPropertyTypeAssoc(typeDef(element.asType())); - } - } + return createPropertyTypeAssoc(typeDef(argElement.asType())); } } else if (typeArguments.size() == 2) { TypeMirror argType = typeArguments.get(1); @@ -342,14 +340,10 @@ class ProcessingContext implements Constants { } } - if (result != null) { - return result; + if (typeInstanceOf(typeMirror, "java.lang.Comparable")) { + return new PropertyTypeScalarComparable(typeMirror.toString()); } else { - if (typeInstanceOf(typeMirror, "java.lang.Comparable")) { - return new PropertyTypeScalarComparable(typeMirror.toString()); - } else { - return new PropertyTypeScalar(typeMirror.toString()); - } + return new PropertyTypeScalar(typeMirror.toString()); } } diff --git a/querybean-generator/src/main/java/io/ebean/querybean/generator/ProcessingContext.java b/querybean-generator/src/main/java/io/ebean/querybean/generator/ProcessingContext.java index 6e41747d0..6eae281b6 100644 --- a/querybean-generator/src/main/java/io/ebean/querybean/generator/ProcessingContext.java +++ b/querybean-generator/src/main/java/io/ebean/querybean/generator/ProcessingContext.java @@ -286,6 +286,15 @@ class ProcessingContext implements Constants { return new PropertyTypeEnum(fullType, Split.shortName(fullType)); } + // look for targetEntity annotation attribute + final String targetEntity = readTargetEntity(field); + if (targetEntity != null) { + final TypeElement element = elementUtils.getTypeElement(targetEntity); + if (isEntityOrEmbedded(element)) { + return createPropertyTypeAssoc(typeDef(element.asType())); + } + } + if (isEntityOrEmbedded(fieldType)) { // public QAssocContact contacts; return createPropertyTypeAssoc(typeDef(typeMirror)); @@ -331,15 +340,6 @@ class ProcessingContext implements Constants { Element argElement = typeUtils.asElement(typeArguments.get(0)); if (isEntityOrEmbedded(argElement)) { return createPropertyTypeAssoc(typeDef(argElement.asType())); - } else { - // look for targetEntity annotation attribute - final String targetEntity = readTargetEntity(field); - if (targetEntity != null) { - final TypeElement element = elementUtils.getTypeElement(targetEntity); - if (isEntityOrEmbedded(element)) { - return createPropertyTypeAssoc(typeDef(element.asType())); - } - } } } else if (typeArguments.size() == 2) { Element argElement = typeUtils.asElement(typeArguments.get(1)); From 74d907bbce3f55d9b8ef268a89486fef217664d8 Mon Sep 17 00:00:00 2001 From: Robin Bygrave Date: Wed, 10 Feb 2021 15:12:28 +1300 Subject: [PATCH 080/447] Refactor kotlin querybean generator ProcessingContext extract asElement() method --- .../querybean/generator/ProcessingContext.java | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/kotlin-querybean-generator/src/main/java/io/ebean/querybean/generator/ProcessingContext.java b/kotlin-querybean-generator/src/main/java/io/ebean/querybean/generator/ProcessingContext.java index 5580c3b09..b01075a53 100644 --- a/kotlin-querybean-generator/src/main/java/io/ebean/querybean/generator/ProcessingContext.java +++ b/kotlin-querybean-generator/src/main/java/io/ebean/querybean/generator/ProcessingContext.java @@ -321,19 +321,13 @@ class ProcessingContext implements Constants { List typeArguments = declaredType.getTypeArguments(); if (typeArguments.size() == 1) { TypeMirror argType = typeArguments.get(0); - if (argType.getKind() == TypeKind.WILDCARD) { - argType = ((WildcardType) argType).getExtendsBound(); - } - Element argElement = typeUtils.asElement(argType); + Element argElement = asElement(argType); if (isEntityOrEmbedded(argElement)) { return createPropertyTypeAssoc(typeDef(argElement.asType())); } } else if (typeArguments.size() == 2) { TypeMirror argType = typeArguments.get(1); - if (argType.getKind() == TypeKind.WILDCARD) { - argType = ((WildcardType) argType).getExtendsBound(); - } - Element argElement = typeUtils.asElement(argType); + Element argElement = asElement(argType); if (isEntityOrEmbedded(argElement)) { return createPropertyTypeAssoc(typeDef(argElement.asType())); } @@ -347,6 +341,13 @@ class ProcessingContext implements Constants { } } + private Element asElement(TypeMirror argType) { + if (argType.getKind() == TypeKind.WILDCARD) { + argType = ((WildcardType) argType).getExtendsBound(); + } + return typeUtils.asElement(argType); + } + private boolean typeInstanceOf(final TypeMirror typeMirror, final CharSequence desiredInterface) { TypeElement typeElement = (TypeElement) typeUtils.asElement(typeMirror); if (typeElement == null || typeElement.getQualifiedName().contentEquals("java.lang.Object")) { From 2672dff51203a4d07165a32c6c1132e3a75df1ef Mon Sep 17 00:00:00 2001 From: Robin Bygrave Date: Wed, 10 Feb 2021 15:28:55 +1300 Subject: [PATCH 081/447] #2155 - QueryBeans: Change to use own @Generated with retention RUNTIME --- .../java/io/ebean/typequery/Generated.java | 22 ++++++++++++++++++ .../ebean/querybean/generator/Constants.java | 5 +--- .../generator/ProcessingContext.java | 19 --------------- .../generator/SimpleModuleInfoWriter.java | 9 ++------ .../generator/SimpleQueryBeanWriter.java | 14 +++-------- .../ebean/querybean/generator/Constants.java | 6 ++--- .../generator/ProcessingContext.java | 23 ------------------- .../generator/SimpleModuleInfoWriter.java | 9 ++------ .../generator/SimpleQueryBeanWriter.java | 13 +++-------- 9 files changed, 35 insertions(+), 85 deletions(-) create mode 100644 ebean-querybean/src/main/java/io/ebean/typequery/Generated.java diff --git a/ebean-querybean/src/main/java/io/ebean/typequery/Generated.java b/ebean-querybean/src/main/java/io/ebean/typequery/Generated.java new file mode 100644 index 000000000..918e0d1b4 --- /dev/null +++ b/ebean-querybean/src/main/java/io/ebean/typequery/Generated.java @@ -0,0 +1,22 @@ +package io.ebean.typequery; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +/** + * Marks generated query bean source code. + *

+ * This is code generated by the query bean generator (annotation processor). + */ +@Target({ ElementType.TYPE }) +@Retention(RetentionPolicy.RUNTIME) +public @interface Generated { + + /** + * The name of the generator used to generate this source. + */ + String value(); + +} diff --git a/kotlin-querybean-generator/src/main/java/io/ebean/querybean/generator/Constants.java b/kotlin-querybean-generator/src/main/java/io/ebean/querybean/generator/Constants.java index 79827d405..e0431f9b0 100644 --- a/kotlin-querybean-generator/src/main/java/io/ebean/querybean/generator/Constants.java +++ b/kotlin-querybean-generator/src/main/java/io/ebean/querybean/generator/Constants.java @@ -3,11 +3,8 @@ package io.ebean.querybean.generator; interface Constants { String AT_GENERATED = "@Generated(\"io.ebean.querybean.kotlin-generator\")"; - String AT_TYPEQUERYBEAN = "@TypeQueryBean(\"v1\")"; - - String GENERATED_9 = "javax.annotation.processing.Generated"; - String GENERATED_8 = "javax.annotation.Generated"; + String GENERATED = "io.ebean.typequery.Generated"; String MAPPED_SUPERCLASS = "javax.persistence.MappedSuperclass"; String INHERITANCE = "javax.persistence.Inheritance"; diff --git a/kotlin-querybean-generator/src/main/java/io/ebean/querybean/generator/ProcessingContext.java b/kotlin-querybean-generator/src/main/java/io/ebean/querybean/generator/ProcessingContext.java index b01075a53..d08242ef4 100644 --- a/kotlin-querybean-generator/src/main/java/io/ebean/querybean/generator/ProcessingContext.java +++ b/kotlin-querybean-generator/src/main/java/io/ebean/querybean/generator/ProcessingContext.java @@ -50,7 +50,6 @@ class ProcessingContext implements Constants { private final Filer filer; private final Messager messager; private final Elements elementUtils; - private final String generatedAnnotation; private final PropertyTypeMap propertyTypeMap = new PropertyTypeMap(); @@ -99,9 +98,6 @@ class ProcessingContext implements Constants { this.filer = processingEnv.getFiler(); this.messager = processingEnv.getMessager(); this.elementUtils = processingEnv.getElementUtils(); - - boolean jdk8 = processingEnv.getSourceVersion().compareTo(SourceVersion.RELEASE_8) <= 0; - this.generatedAnnotation = generatedAnnotation(jdk8); this.generatedSources = initGeneratedSources(processingEnv); this.readModuleInfo = new ReadModuleInfo(this); } @@ -122,13 +118,6 @@ class ProcessingContext implements Constants { return elementUtils.getTypeElement(EBEAN_COMPONENT); } - private String generatedAnnotation(boolean jdk8) { - if (jdk8) { - return isTypeAvailable(GENERATED_8) ? GENERATED_8 : null; - } - return isTypeAvailable(GENERATED_9) ? GENERATED_9 : null; - } - private String initGeneratedSources(ProcessingEnvironment processingEnv) { String generatedDir = processingEnv.getOptions().get("kapt.kotlin.generated"); return (generatedDir != null) ? generatedDir : "target/generated-sources/kapt/compile"; @@ -430,14 +419,6 @@ class ProcessingContext implements Constants { messager.printMessage(Diagnostic.Kind.NOTE, String.format(msg, args)); } - boolean isGeneratedAvailable() { - return generatedAnnotation != null; - } - - String getGeneratedAnnotation() { - return generatedAnnotation; - } - void readModuleInfo() { String factory = loadMetaInfServices(); if (factory != null) { diff --git a/kotlin-querybean-generator/src/main/java/io/ebean/querybean/generator/SimpleModuleInfoWriter.java b/kotlin-querybean-generator/src/main/java/io/ebean/querybean/generator/SimpleModuleInfoWriter.java index a8f734968..926aad8ae 100644 --- a/kotlin-querybean-generator/src/main/java/io/ebean/querybean/generator/SimpleModuleInfoWriter.java +++ b/kotlin-querybean-generator/src/main/java/io/ebean/querybean/generator/SimpleModuleInfoWriter.java @@ -90,10 +90,7 @@ class SimpleModuleInfoWriter { writer.append("import java.util.ArrayList;").eol(); writer.append("import java.util.Collections;").eol(); writer.append("import java.util.List;").eol(); - final String generated = processingContext.getGeneratedAnnotation(); - if (generated != null) { - writer.append("import %s;", generated).eol(); - } + writer.append("import %s;", Constants.GENERATED).eol(); writer.eol(); writer.append("import io.ebean.config.ModuleInfo;").eol(); writer.append("import io.ebean.config.ModuleInfoLoader;").eol(); @@ -102,9 +99,7 @@ class SimpleModuleInfoWriter { } void buildAtContextModule(Append writer) { - if (processingContext.isGeneratedAvailable()) { - writer.append(Constants.AT_GENERATED).eol(); - } + writer.append(Constants.AT_GENERATED).eol(); writer.append("@ModuleInfo("); if (processingContext.hasOtherClasses()) { writer.append("other={%s}, ", otherClasses()); diff --git a/kotlin-querybean-generator/src/main/java/io/ebean/querybean/generator/SimpleQueryBeanWriter.java b/kotlin-querybean-generator/src/main/java/io/ebean/querybean/generator/SimpleQueryBeanWriter.java index 7c5fb4ba8..8524a59f9 100644 --- a/kotlin-querybean-generator/src/main/java/io/ebean/querybean/generator/SimpleQueryBeanWriter.java +++ b/kotlin-querybean-generator/src/main/java/io/ebean/querybean/generator/SimpleQueryBeanWriter.java @@ -88,11 +88,7 @@ class SimpleQueryBeanWriter { } private void gatherPropertyDetails() { - - final String generated = processingContext.getGeneratedAnnotation(); - if (generated != null) { - importTypes.add(generated); - } + importTypes.add(Constants.GENERATED); importTypes.add(beanFullName); importTypes.add(Constants.TQROOTBEAN); importTypes.add(Constants.TYPEQUERYBEAN); @@ -282,9 +278,7 @@ class SimpleQueryBeanWriter { writer.append(" * ").eol(); writer.append(" * THIS IS A GENERATED OBJECT, DO NOT MODIFY THIS CLASS.").eol(); writer.append(" */").eol(); - if (processingContext.isGeneratedAvailable()) { - writer.append(Constants.AT_GENERATED).eol(); - } + writer.append(Constants.AT_GENERATED).eol(); writer.append(Constants.AT_TYPEQUERYBEAN).eol(); lang().beginAssocClass(writer, shortName, origShortName); @@ -294,9 +288,7 @@ class SimpleQueryBeanWriter { writer.append(" * ").eol(); writer.append(" * THIS IS A GENERATED OBJECT, DO NOT MODIFY THIS CLASS.").eol(); writer.append(" */").eol(); - if (processingContext.isGeneratedAvailable()) { - writer.append(Constants.AT_GENERATED).eol(); - } + writer.append(Constants.AT_GENERATED).eol(); writer.append(Constants.AT_TYPEQUERYBEAN).eol(); lang().beginClass(writer, shortName); } diff --git a/querybean-generator/src/main/java/io/ebean/querybean/generator/Constants.java b/querybean-generator/src/main/java/io/ebean/querybean/generator/Constants.java index 959c08721..2b27a034c 100644 --- a/querybean-generator/src/main/java/io/ebean/querybean/generator/Constants.java +++ b/querybean-generator/src/main/java/io/ebean/querybean/generator/Constants.java @@ -5,9 +5,7 @@ interface Constants { String AT_GENERATED = "@Generated(\"io.ebean.querybean.generator\")"; String AT_TYPEQUERYBEAN = "@TypeQueryBean(\"v1\")"; - - String GENERATED_9 = "javax.annotation.processing.Generated"; - String GENERATED_8 = "javax.annotation.Generated"; + String GENERATED = "io.ebean.typequery.Generated"; String MAPPED_SUPERCLASS = "javax.persistence.MappedSuperclass"; String INHERITANCE = "javax.persistence.Inheritance"; @@ -35,4 +33,4 @@ interface Constants { String METAINF_MANIFEST = "META-INF/ebean-generated-info.mf"; String METAINF_SERVICES_MODULELOADER = "META-INF/services/io.ebean.config.ModuleInfoLoader"; -} \ No newline at end of file +} diff --git a/querybean-generator/src/main/java/io/ebean/querybean/generator/ProcessingContext.java b/querybean-generator/src/main/java/io/ebean/querybean/generator/ProcessingContext.java index 6eae281b6..fe73814e2 100644 --- a/querybean-generator/src/main/java/io/ebean/querybean/generator/ProcessingContext.java +++ b/querybean-generator/src/main/java/io/ebean/querybean/generator/ProcessingContext.java @@ -46,7 +46,6 @@ class ProcessingContext implements Constants { private final Filer filer; private final Messager messager; private final Elements elementUtils; - private final String generatedAnnotation; private final PropertyTypeMap propertyTypeMap = new PropertyTypeMap(); @@ -95,9 +94,6 @@ class ProcessingContext implements Constants { this.filer = processingEnv.getFiler(); this.messager = processingEnv.getMessager(); this.elementUtils = processingEnv.getElementUtils(); - - boolean jdk8 = processingEnv.getSourceVersion().compareTo(SourceVersion.RELEASE_8) <= 0; - this.generatedAnnotation = generatedAnnotation(jdk8); this.readModuleInfo = new ReadModuleInfo(this); } @@ -117,17 +113,6 @@ class ProcessingContext implements Constants { return elementUtils.getTypeElement(EBEAN_COMPONENT); } - private String generatedAnnotation(boolean jdk8) { - if (jdk8) { - return isTypeAvailable(GENERATED_8) ? GENERATED_8 : null; - } - return isTypeAvailable(GENERATED_9) ? GENERATED_9 : null; - } - - private boolean isTypeAvailable(String canonicalName) { - return null != elementUtils.getTypeElement(canonicalName); - } - /** * Gather all the fields (properties) for the given bean element. */ @@ -413,14 +398,6 @@ class ProcessingContext implements Constants { messager.printMessage(Diagnostic.Kind.NOTE, String.format(msg, args)); } - boolean isGeneratedAvailable() { - return generatedAnnotation != null; - } - - String getGeneratedAnnotation() { - return generatedAnnotation; - } - void readModuleInfo() { String factory = loadMetaInfServices(); if (factory != null) { diff --git a/querybean-generator/src/main/java/io/ebean/querybean/generator/SimpleModuleInfoWriter.java b/querybean-generator/src/main/java/io/ebean/querybean/generator/SimpleModuleInfoWriter.java index c48896a50..b9c1b606e 100644 --- a/querybean-generator/src/main/java/io/ebean/querybean/generator/SimpleModuleInfoWriter.java +++ b/querybean-generator/src/main/java/io/ebean/querybean/generator/SimpleModuleInfoWriter.java @@ -89,10 +89,7 @@ class SimpleModuleInfoWriter { writer.append("import java.util.ArrayList;").eol(); writer.append("import java.util.Collections;").eol(); writer.append("import java.util.List;").eol(); - final String generated = processingContext.getGeneratedAnnotation(); - if (generated != null) { - writer.append("import %s;", generated).eol(); - } + writer.append("import %s;", Constants.GENERATED).eol(); writer.eol(); writer.append("import io.ebean.config.ModuleInfo;").eol(); writer.append("import io.ebean.config.ModuleInfoLoader;").eol(); @@ -100,9 +97,7 @@ class SimpleModuleInfoWriter { } void buildAtContextModule(Append writer) { - if (processingContext.isGeneratedAvailable()) { - writer.append(Constants.AT_GENERATED).eol(); - } + writer.append(Constants.AT_GENERATED).eol(); writer.append("@ModuleInfo("); if (processingContext.hasOtherClasses()) { writer.append("other={%s}, ", otherClasses()); diff --git a/querybean-generator/src/main/java/io/ebean/querybean/generator/SimpleQueryBeanWriter.java b/querybean-generator/src/main/java/io/ebean/querybean/generator/SimpleQueryBeanWriter.java index a54ddc840..78fd99779 100644 --- a/querybean-generator/src/main/java/io/ebean/querybean/generator/SimpleQueryBeanWriter.java +++ b/querybean-generator/src/main/java/io/ebean/querybean/generator/SimpleQueryBeanWriter.java @@ -62,10 +62,7 @@ class SimpleQueryBeanWriter { } private void gatherPropertyDetails() { - final String generated = processingContext.getGeneratedAnnotation(); - if (generated != null) { - importTypes.add(generated); - } + importTypes.add(Constants.GENERATED); importTypes.add(beanFullName); importTypes.add(Constants.TQROOTBEAN); importTypes.add(Constants.TYPEQUERYBEAN); @@ -301,9 +298,7 @@ class SimpleQueryBeanWriter { writer.append(" * ").eol(); writer.append(" * THIS IS A GENERATED OBJECT, DO NOT MODIFY THIS CLASS.").eol(); writer.append(" */").eol(); - if (processingContext.isGeneratedAvailable()) { - writer.append(Constants.AT_GENERATED).eol(); - } + writer.append(Constants.AT_GENERATED).eol(); writer.append(Constants.AT_TYPEQUERYBEAN).eol(); writer.append("public class Q%s extends TQAssocBean<%s,R> {", shortName, origShortName).eol(); @@ -313,9 +308,7 @@ class SimpleQueryBeanWriter { writer.append(" * ").eol(); writer.append(" * THIS IS A GENERATED OBJECT, DO NOT MODIFY THIS CLASS.").eol(); writer.append(" */").eol(); - if (processingContext.isGeneratedAvailable()) { - writer.append(Constants.AT_GENERATED).eol(); - } + writer.append(Constants.AT_GENERATED).eol(); writer.append(Constants.AT_TYPEQUERYBEAN).eol(); writer.append("public class Q%s extends TQRootBean<%1$s,Q%1$s> {", shortName).eol(); } From 8ecc407cb0a04320adedeeedc1eda72989430f03 Mon Sep 17 00:00:00 2001 From: rob bygrave Date: Wed, 10 Feb 2021 19:25:42 +1300 Subject: [PATCH 082/447] #2154 - Fix tests for QueryBeans: TargetEntity is not evaluated during bean generation resulting in bad query beans --- .../src/test/java/org/example/domain/AreaImpl.java | 2 +- .../src/test/java/org/example/domain/CityImpl.java | 4 ++-- .../src/test/java/org/example/domain/CountryImpl.java | 2 +- .../src/test/java/org/example/domain/api/ACity.java | 10 ++++++++++ .../src/test/java/org/example/domain/api/ACountry.java | 5 +++++ 5 files changed, 19 insertions(+), 4 deletions(-) create mode 100644 ebean-querybean/src/test/java/org/example/domain/api/ACity.java create mode 100644 ebean-querybean/src/test/java/org/example/domain/api/ACountry.java diff --git a/ebean-querybean/src/test/java/org/example/domain/AreaImpl.java b/ebean-querybean/src/test/java/org/example/domain/AreaImpl.java index 940f9eb83..2ae8785d2 100644 --- a/ebean-querybean/src/test/java/org/example/domain/AreaImpl.java +++ b/ebean-querybean/src/test/java/org/example/domain/AreaImpl.java @@ -1,6 +1,6 @@ package org.example.domain; -import org.example.domain.target.ACity; +import org.example.domain.api.ACity; import javax.persistence.CascadeType; import javax.persistence.Entity; diff --git a/ebean-querybean/src/test/java/org/example/domain/CityImpl.java b/ebean-querybean/src/test/java/org/example/domain/CityImpl.java index b42949671..643914429 100644 --- a/ebean-querybean/src/test/java/org/example/domain/CityImpl.java +++ b/ebean-querybean/src/test/java/org/example/domain/CityImpl.java @@ -1,7 +1,7 @@ package org.example.domain; -import org.example.domain.target.ACity; -import org.example.domain.target.ACountry; +import org.example.domain.api.ACity; +import org.example.domain.api.ACountry; import javax.persistence.Entity; import javax.persistence.Id; diff --git a/ebean-querybean/src/test/java/org/example/domain/CountryImpl.java b/ebean-querybean/src/test/java/org/example/domain/CountryImpl.java index ed8ac7759..6f8797df8 100644 --- a/ebean-querybean/src/test/java/org/example/domain/CountryImpl.java +++ b/ebean-querybean/src/test/java/org/example/domain/CountryImpl.java @@ -1,6 +1,6 @@ package org.example.domain; -import org.example.domain.target.ACountry; +import org.example.domain.api.ACountry; import javax.persistence.Entity; import javax.persistence.Id; diff --git a/ebean-querybean/src/test/java/org/example/domain/api/ACity.java b/ebean-querybean/src/test/java/org/example/domain/api/ACity.java new file mode 100644 index 000000000..b72fa1f18 --- /dev/null +++ b/ebean-querybean/src/test/java/org/example/domain/api/ACity.java @@ -0,0 +1,10 @@ +package org.example.domain.api; + +public interface ACity { + + long id(); + + String name(); + + ACountry country(); +} diff --git a/ebean-querybean/src/test/java/org/example/domain/api/ACountry.java b/ebean-querybean/src/test/java/org/example/domain/api/ACountry.java new file mode 100644 index 000000000..4a9541a3d --- /dev/null +++ b/ebean-querybean/src/test/java/org/example/domain/api/ACountry.java @@ -0,0 +1,5 @@ +package org.example.domain.api; + +public interface ACountry { + String code(); +} From bc33e059062b90d167573c421a216930cf075216 Mon Sep 17 00:00:00 2001 From: Robin Bygrave Date: Thu, 11 Feb 2021 17:20:28 +1300 Subject: [PATCH 083/447] #2158 - Oracle - automatic platform selection doesn't select older Oracle11Platform via jdbc metadata major version --- .../ebeaninternal/server/core/DatabasePlatformFactory.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/core/DatabasePlatformFactory.java b/ebean-core/src/main/java/io/ebeaninternal/server/core/DatabasePlatformFactory.java index 18c1051a0..55cf5b19a 100644 --- a/ebean-core/src/main/java/io/ebeaninternal/server/core/DatabasePlatformFactory.java +++ b/ebean-core/src/main/java/io/ebeaninternal/server/core/DatabasePlatformFactory.java @@ -157,7 +157,7 @@ public class DatabasePlatformFactory { final int minorVersion = metaData.getDatabaseMinorVersion(); if (dbProductName.contains("oracle")) { - return new OraclePlatform(); + return oracleVersion(majorVersion); } else if (dbProductName.contains("microsoft")) { throw new IllegalArgumentException("For SqlServer please explicitly choose either sqlserver16 or sqlserver17 as the platform via DatabaseConfig.setDatabasePlatformName. Refer to issue #1340 for more details"); } else if (dbProductName.contains("h2")) { @@ -188,6 +188,10 @@ public class DatabasePlatformFactory { return new DatabasePlatform(); } + private DatabasePlatform oracleVersion(int majorVersion) { + return majorVersion < 12 ? new Oracle11Platform() : new OraclePlatform(); + } + private DatabasePlatform mysqlVersion(int majorVersion, int minorVersion) { if (majorVersion <= 5 && minorVersion <= 5) { return new MySql55Platform(); From ac1dd4cbabc6db4d5cfa29a9e87842362fb72a86 Mon Sep 17 00:00:00 2001 From: Robin Bygrave Date: Thu, 11 Feb 2021 17:28:05 +1300 Subject: [PATCH 084/447] #2158 Refactor to use try with resources with Connection for platform selection via jdbc metaData --- .../server/core/DatabasePlatformFactory.java | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/core/DatabasePlatformFactory.java b/ebean-core/src/main/java/io/ebeaninternal/server/core/DatabasePlatformFactory.java index 55cf5b19a..a96907848 100644 --- a/ebean-core/src/main/java/io/ebeaninternal/server/core/DatabasePlatformFactory.java +++ b/ebean-core/src/main/java/io/ebeaninternal/server/core/DatabasePlatformFactory.java @@ -131,19 +131,10 @@ public class DatabasePlatformFactory { * Use JDBC DatabaseMetaData to determine the platform. */ private DatabasePlatform byDataSource(DataSource dataSource) { - - Connection connection = null; - try { - connection = dataSource.getConnection(); - DatabaseMetaData metaData = connection.getMetaData(); - - return byDatabaseMeta(metaData, connection); - + try (Connection connection = dataSource.getConnection()) { + return byDatabaseMeta(connection.getMetaData(), connection); } catch (SQLException ex) { throw new PersistenceException(ex); - - } finally { - JdbcClose.close(connection); } } From d3a09b93c02f585d3aaff29bd096d37bd5828e66 Mon Sep 17 00:00:00 2001 From: Rob Bygrave Date: Fri, 12 Feb 2021 16:30:28 +1300 Subject: [PATCH 085/447] #2156 - Using @OneToOne(targetEntity...) with Interface field results in BeanNotRegisteredException (#2160) --- .../deploy/meta/DeployBeanPropertyAssoc.java | 5 +++ .../meta/DeployBeanPropertyAssocMany.java | 13 ------- .../server/deploy/parse/AnnotationAssoc.java | 39 +++++++++++++++++++ .../deploy/parse/AnnotationAssocManys.java | 29 +------------- .../deploy/parse/AnnotationAssocOnes.java | 32 ++++----------- .../deploy/parse/DeployCreateProperties.java | 8 ---- .../org/tests/basic/TestManyOneInterface.java | 2 +- .../org/tests/model/interfaces/Address.java | 4 ++ .../org/tests/model/interfaces/IPersona.java | 6 +++ .../org/tests/model/interfaces/Persona.java | 39 +++++++++++++++++++ .../model/interfaces/TestTargetEntity.java | 38 ++++++++++++++++++ 11 files changed, 142 insertions(+), 73 deletions(-) create mode 100644 ebean-core/src/main/java/io/ebeaninternal/server/deploy/parse/AnnotationAssoc.java create mode 100644 ebean-core/src/test/java/org/tests/model/interfaces/IPersona.java create mode 100644 ebean-core/src/test/java/org/tests/model/interfaces/Persona.java create mode 100644 ebean-core/src/test/java/org/tests/model/interfaces/TestTargetEntity.java diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/deploy/meta/DeployBeanPropertyAssoc.java b/ebean-core/src/main/java/io/ebeaninternal/server/deploy/meta/DeployBeanPropertyAssoc.java index a7e060004..472a71db3 100644 --- a/ebean-core/src/main/java/io/ebeaninternal/server/deploy/meta/DeployBeanPropertyAssoc.java +++ b/ebean-core/src/main/java/io/ebeaninternal/server/deploy/meta/DeployBeanPropertyAssoc.java @@ -176,4 +176,9 @@ public abstract class DeployBeanPropertyAssoc extends DeployBeanProperty { public void setFetchPreference(int fetchPreference) { this.fetchPreference = fetchPreference; } + + @SuppressWarnings("unchecked") + public void setTargetType(Class targetType) { + this.targetType = (Class)targetType; + } } diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/deploy/meta/DeployBeanPropertyAssocMany.java b/ebean-core/src/main/java/io/ebeaninternal/server/deploy/meta/DeployBeanPropertyAssocMany.java index 7ed3ff164..606a6d215 100644 --- a/ebean-core/src/main/java/io/ebeaninternal/server/deploy/meta/DeployBeanPropertyAssocMany.java +++ b/ebean-core/src/main/java/io/ebeaninternal/server/deploy/meta/DeployBeanPropertyAssocMany.java @@ -65,19 +65,6 @@ public class DeployBeanPropertyAssocMany extends DeployBeanPropertyAssoc { this.manyType = manyType; } - /** - * When generics is not used for manyType you can specify via annotations. - *

- * Really only expect this for Scala due to a Scala compiler bug at the moment. - * Otherwise I'd probably not bother support this. - *

- */ - @SuppressWarnings("unchecked") - public void setTargetType(Class cls) { - this.targetType = (Class) cls; - } - - /** * Return the many type. */ diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/deploy/parse/AnnotationAssoc.java b/ebean-core/src/main/java/io/ebeaninternal/server/deploy/parse/AnnotationAssoc.java new file mode 100644 index 000000000..525034f41 --- /dev/null +++ b/ebean-core/src/main/java/io/ebeaninternal/server/deploy/parse/AnnotationAssoc.java @@ -0,0 +1,39 @@ +package io.ebeaninternal.server.deploy.parse; + +import io.ebean.config.BeanNotRegisteredException; +import io.ebeaninternal.server.deploy.BeanDescriptorManager; +import io.ebeaninternal.server.deploy.BeanTable; +import io.ebeaninternal.server.deploy.meta.DeployBeanPropertyAssoc; + +abstract class AnnotationAssoc extends AnnotationParser { + + final BeanDescriptorManager factory; + + AnnotationAssoc(DeployBeanInfo info, ReadAnnotationConfig readConfig, BeanDescriptorManager factory) { + super(info, readConfig); + this.factory = factory; + } + + void setTargetType(Class targetType, DeployBeanPropertyAssoc prop) { + if (!targetType.equals(void.class)) { + prop.setTargetType(targetType); + } + } + + void setBeanTable(DeployBeanPropertyAssoc prop) { + BeanTable assoc = getBeanTable(prop); + if (assoc == null) { + throw new BeanNotRegisteredException(errorMsgMissingBeanTable(prop.getTargetType(), prop.getFullBeanName())); + } + prop.setBeanTable(assoc); + } + + BeanTable getBeanTable(DeployBeanPropertyAssoc prop) { + return factory.getBeanTable(prop.getTargetType()); + } + + private String errorMsgMissingBeanTable(Class type, String from) { + return "Error with association to [" + type + "] from [" + from + "]. Is " + type + " registered? See https://ebean.io/docs/trouble-shooting#not-registered"; + } + +} diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/deploy/parse/AnnotationAssocManys.java b/ebean-core/src/main/java/io/ebeaninternal/server/deploy/parse/AnnotationAssocManys.java index e0dae8abc..91c949a0f 100644 --- a/ebean-core/src/main/java/io/ebeaninternal/server/deploy/parse/AnnotationAssocManys.java +++ b/ebean-core/src/main/java/io/ebeaninternal/server/deploy/parse/AnnotationAssocManys.java @@ -44,16 +44,10 @@ import static io.ebean.util.StringHelper.isNull; /** * Read the deployment annotation for Assoc Many beans. */ -class AnnotationAssocManys extends AnnotationParser { +class AnnotationAssocManys extends AnnotationAssoc { - private final BeanDescriptorManager factory; - - /** - * Create with the DeployInfo. - */ AnnotationAssocManys(DeployBeanInfo info, ReadAnnotationConfig readConfig, BeanDescriptorManager factory) { - super(info, readConfig); - this.factory = factory; + super(info, readConfig, factory); } /** @@ -435,11 +429,6 @@ class AnnotationAssocManys extends AnnotationParser { prop.setInverseJoin(inverseDest); } - - private String errorMsgMissingBeanTable(Class type, String from) { - return "Error with association to [" + type + "] from [" + from + "]. Is " + type + " registered? See https://ebean.io/docs/trouble-shooting#not-registered"; - } - private void readToMany(ManyToMany propAnn, DeployBeanPropertyAssocMany manyProp) { manyProp.setMappedBy(propAnn.mappedBy()); @@ -462,20 +451,6 @@ class AnnotationAssocManys extends AnnotationParser { manyProp.getTableJoin().setType(SqlJoinType.OUTER); } - private void setTargetType(Class targetType, DeployBeanPropertyAssocMany prop) { - if (!targetType.equals(void.class)) { - prop.setTargetType(targetType); - } - } - - private void setBeanTable(DeployBeanPropertyAssocMany manyProp) { - BeanTable assoc = factory.getBeanTable(manyProp.getTargetType()); - if (assoc == null) { - throw new BeanNotRegisteredException(errorMsgMissingBeanTable(manyProp.getTargetType(), manyProp.getFullBeanName())); - } - manyProp.setBeanTable(assoc); - } - private String getM2MJoinTableName(BeanTable lhsTable, BeanTable rhsTable) { TableName lhs = new TableName(lhsTable.getBaseTable()); diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/deploy/parse/AnnotationAssocOnes.java b/ebean-core/src/main/java/io/ebeaninternal/server/deploy/parse/AnnotationAssocOnes.java index 8d4d178f1..6750633cb 100644 --- a/ebean-core/src/main/java/io/ebeaninternal/server/deploy/parse/AnnotationAssocOnes.java +++ b/ebean-core/src/main/java/io/ebeaninternal/server/deploy/parse/AnnotationAssocOnes.java @@ -33,18 +33,15 @@ import javax.validation.constraints.NotNull; /** * Read the deployment annotations for Associated One beans. */ -public class AnnotationAssocOnes extends AnnotationParser { +public class AnnotationAssocOnes extends AnnotationAssoc { private static final Logger log = LoggerFactory.getLogger(AnnotationAssocOnes.class); - private final BeanDescriptorManager factory; - /** * Create with the deploy Info. */ AnnotationAssocOnes(DeployBeanInfo info, ReadAnnotationConfig readConfig, BeanDescriptorManager factory) { - super(info, readConfig); - this.factory = factory; + super(info, readConfig, factory); } /** @@ -191,25 +188,11 @@ public class AnnotationAssocOnes extends AnnotationParser { } } - private String errorMsgMissingBeanTable(Class type, String from) { - return "Error with association to [" + type + "] from [" + from + "]. Is " + type + " registered? Does it have the @Entity annotation? See https://ebean.io/docs/trouble-shooting#not-registered"; - } - - private BeanTable beanTable(DeployBeanPropertyAssoc prop) { - BeanTable assoc = factory.getBeanTable(prop.getPropertyType()); - if (assoc == null) { - throw new BeanNotRegisteredException(errorMsgMissingBeanTable(prop.getPropertyType(), prop.getFullBeanName())); - } - return assoc; - } - - private void readManyToOne(ManyToOne propAnn, DeployBeanProperty prop) { - - DeployBeanPropertyAssocOne beanProp = (DeployBeanPropertyAssocOne) prop; + private void readManyToOne(ManyToOne propAnn, DeployBeanPropertyAssocOne beanProp) { setCascadeTypes(propAnn.cascade(), beanProp.getCascadeInfo()); - - beanProp.setBeanTable(beanTable(beanProp)); + setTargetType(propAnn.targetEntity(), beanProp); + setBeanTable(beanProp); beanProp.setDbInsertable(true); beanProp.setDbUpdateable(true); beanProp.setNullable(propAnn.optional()); @@ -232,7 +215,8 @@ public class AnnotationAssocOnes extends AnnotationParser { } setCascadeTypes(propAnn.cascade(), prop.getCascadeInfo()); - prop.setBeanTable(beanTable(prop)); + setTargetType(propAnn.targetEntity(), prop); + setBeanTable(prop); } private boolean readOrphanRemoval(OneToOne property) { @@ -261,7 +245,7 @@ public class AnnotationAssocOnes extends AnnotationParser { BeanTable baseBeanTable = factory.getBeanTable(info.getDescriptor().getBeanType()); String localPrimaryKey = baseBeanTable.getIdColumn(); - String foreignColumn = beanTable(prop).getIdColumn(); + String foreignColumn = getBeanTable(prop).getIdColumn(); prop.getTableJoin().addJoinColumn(new DeployTableJoinColumn(localPrimaryKey, foreignColumn, false, false)); } diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/deploy/parse/DeployCreateProperties.java b/ebean-core/src/main/java/io/ebeaninternal/server/deploy/parse/DeployCreateProperties.java index 691fa7cf5..6fb54b46d 100644 --- a/ebean-core/src/main/java/io/ebeaninternal/server/deploy/parse/DeployCreateProperties.java +++ b/ebean-core/src/main/java/io/ebeaninternal/server/deploy/parse/DeployCreateProperties.java @@ -145,14 +145,6 @@ public class DeployCreateProperties { private DeployBeanProperty createProp(DeployBeanDescriptor desc, Field field) { Class propertyType = field.getType(); - - ManyToOne manyToOne = AnnotationUtil.get(field, ManyToOne.class); - if (manyToOne != null) { - Class tt = manyToOne.targetEntity(); - if (!tt.equals(void.class)) { - propertyType = tt; - } - } if (isSpecialScalarType(field)) { return new DeployBeanProperty(desc, propertyType, field.getGenericType()); } diff --git a/ebean-core/src/test/java/org/tests/basic/TestManyOneInterface.java b/ebean-core/src/test/java/org/tests/basic/TestManyOneInterface.java index ab847eb93..c27e6fc02 100644 --- a/ebean-core/src/test/java/org/tests/basic/TestManyOneInterface.java +++ b/ebean-core/src/test/java/org/tests/basic/TestManyOneInterface.java @@ -16,7 +16,7 @@ public class TestManyOneInterface extends BaseTestCase { ResetBasicData.reset(); - IAddress a = new Address(); + IAddress a = new Address("hello"); IPerson p = new Person(); diff --git a/ebean-core/src/test/java/org/tests/model/interfaces/Address.java b/ebean-core/src/test/java/org/tests/model/interfaces/Address.java index a4f9885bb..052ef63f8 100644 --- a/ebean-core/src/test/java/org/tests/model/interfaces/Address.java +++ b/ebean-core/src/test/java/org/tests/model/interfaces/Address.java @@ -15,6 +15,10 @@ public class Address implements IAddress { private String street; + public Address(String street) { + this.street = street; + } + public long getOid() { return oid; } diff --git a/ebean-core/src/test/java/org/tests/model/interfaces/IPersona.java b/ebean-core/src/test/java/org/tests/model/interfaces/IPersona.java new file mode 100644 index 000000000..321047319 --- /dev/null +++ b/ebean-core/src/test/java/org/tests/model/interfaces/IPersona.java @@ -0,0 +1,6 @@ +package org.tests.model.interfaces; + +public interface IPersona { + + String persona(); +} diff --git a/ebean-core/src/test/java/org/tests/model/interfaces/Persona.java b/ebean-core/src/test/java/org/tests/model/interfaces/Persona.java new file mode 100644 index 000000000..015d8ada0 --- /dev/null +++ b/ebean-core/src/test/java/org/tests/model/interfaces/Persona.java @@ -0,0 +1,39 @@ +package org.tests.model.interfaces; + +import javax.persistence.*; + +@Entity +public class Persona implements IPersona { + + @Id + private long id; + + @Version + private int version; + + private final String persona; + + @OneToOne(orphanRemoval = true, fetch = FetchType.LAZY, targetEntity = Person.class) + private IPerson person; + + public Persona(String persona) { + this.persona = persona; + } + + public long getId() { + return id; + } + + @Override + public String persona() { + return persona; + } + + public void setPerson(IPerson person) { + this.person = person; + } + + public IPerson getPerson() { + return person; + } +} diff --git a/ebean-core/src/test/java/org/tests/model/interfaces/TestTargetEntity.java b/ebean-core/src/test/java/org/tests/model/interfaces/TestTargetEntity.java new file mode 100644 index 000000000..9db04f045 --- /dev/null +++ b/ebean-core/src/test/java/org/tests/model/interfaces/TestTargetEntity.java @@ -0,0 +1,38 @@ +package org.tests.model.interfaces; + +import io.ebean.BaseTestCase; +import io.ebean.DB; +import org.junit.Test; + +import static org.assertj.core.api.Assertions.assertThat; + +public class TestTargetEntity extends BaseTestCase { + + @Test + public void test() { + + Person person = setup(); + + Persona persona = new Persona("junk"); + persona.setPerson(person); + DB.save(persona); + + Persona found = DB.find(Persona.class, persona.getId()); + assertThat(found).isNotNull(); + assertThat(found.persona()).isEqualTo("junk"); + assertThat(found.getPerson().getDefaultAddress().getStreet()).isEqualTo("street"); + + DB.delete(persona); + DB.delete(person); + DB.delete(person.getDefaultAddress()); + } + + private Person setup() { + Address address = new Address("street"); + DB.save(address); + Person person = new Person(); + person.setDefaultAddress(address); + DB.save(person); + return person; + } +} From 213562fcf1cbca0745d3daf7ad66eb5b79ee0e94 Mon Sep 17 00:00:00 2001 From: Robin Bygrave Date: Fri, 12 Feb 2021 16:34:24 +1300 Subject: [PATCH 086/447] No change - update ddl review for h2 --- .../src/test/ddl-review/h2-create-all.sql | 88 ++++++++++++++++++- .../src/test/ddl-review/h2-drop-all.sql | 42 ++++++++- 2 files changed, 128 insertions(+), 2 deletions(-) diff --git a/ebean-core/src/test/ddl-review/h2-create-all.sql b/ebean-core/src/test/ddl-review/h2-create-all.sql index dc5f4879f..50d49a3ac 100644 --- a/ebean-core/src/test/ddl-review/h2-create-all.sql +++ b/ebean-core/src/test/ddl-review/h2-create-all.sql @@ -1,4 +1,4 @@ --- Generated by ebean unknown at 2020-12-07T09:40:50.461215Z +-- Generated by ebean unknown at 2021-02-12T03:32:14.253435800Z create table asimple_bean ( id bigint generated by default as identity not null, name varchar(255), @@ -486,6 +486,13 @@ create table child_person ( constraint pk_child_person primary key (identifier) ); +create table child_with_cache ( + id bigint generated by default as identity not null, + name varchar(255), + address varchar(255), + constraint pk_child_with_cache primary key (id) +); + create table cke_client ( cod_cpny integer not null, cod_client varchar(100) not null, @@ -1168,6 +1175,12 @@ create table ebasic_json_unmapped ( constraint pk_ebasic_json_unmapped primary key (id) ); +create table e_basic_log ( + id bigint generated by default as identity not null, + name varchar(255), + constraint pk_e_basic_log primary key (id) +); + create table e_basic_ndc ( id integer generated by default as identity not null, name varchar(255), @@ -1227,6 +1240,14 @@ create table e_basic_with_ex ( constraint pk_e_basic_with_ex primary key (id) ); +create table e_basic_withlog ( + id bigint generated by default as identity not null, + name varchar(255), + deleted boolean default false not null, + version bigint not null, + constraint pk_e_basic_withlog primary key (id) +); + create table e_basicverucon ( id integer generated by default as identity not null, name varchar(127), @@ -2256,6 +2277,29 @@ create table looney ( constraint pk_looney primary key (id) ); +create table m2_mcache_child ( + id integer generated by default as identity not null, + name varchar(255), + constraint pk_m2_mcache_child primary key (id) +); + +create table m2_mcache_master ( + id integer generated by default as identity not null, + constraint pk_m2_mcache_master primary key (id) +); + +create table m2mcache_set1 ( + m2_mcache_master_id integer not null, + m2_mcache_child_id integer not null, + constraint pk_m2mcache_set1 primary key (m2_mcache_master_id,m2_mcache_child_id) +); + +create table m2mcache_set2 ( + m2_mcache_master_id integer not null, + m2_mcache_child_id integer not null, + constraint pk_m2mcache_set2 primary key (m2_mcache_master_id,m2_mcache_child_id) +); + create table maddress ( id uuid not null, street varchar(255), @@ -3230,6 +3274,19 @@ create table e_save_test_c ( constraint pk_e_save_test_c primary key (id) ); +create table parent_a ( + id bigint generated by default as identity not null, + child_id bigint, + name varchar(255), + constraint pk_parent_a primary key (id) +); + +create table parent_b ( + id bigint generated by default as identity not null, + child_id bigint, + constraint pk_parent_b primary key (id) +); + create table parent_person ( identifier integer generated by default as identity not null, name varchar(255), @@ -3361,6 +3418,15 @@ create table person_cache_info ( constraint pk_person_cache_info primary key (person_id) ); +create table persona ( + id bigint generated by default as identity not null, + persona varchar(255), + person_oid bigint, + version integer not null, + constraint uq_persona_person_oid unique (person_oid), + constraint pk_persona primary key (id) +); + create table phones ( id bigint generated by default as identity not null, phone_number varchar(7) not null, @@ -4574,6 +4640,18 @@ alter table la_attr_value_attribute add constraint fk_la_attr_value_attribute_at create index ix_looney_tune_id on looney (tune_id); alter table looney add constraint fk_looney_tune_id foreign key (tune_id) references tune (id) on delete restrict on update restrict; +create index ix_m2mcache_set1_m2_mcache_master on m2mcache_set1 (m2_mcache_master_id); +alter table m2mcache_set1 add constraint fk_m2mcache_set1_m2_mcache_master foreign key (m2_mcache_master_id) references m2_mcache_master (id) on delete restrict on update restrict; + +create index ix_m2mcache_set1_m2_mcache_child on m2mcache_set1 (m2_mcache_child_id); +alter table m2mcache_set1 add constraint fk_m2mcache_set1_m2_mcache_child foreign key (m2_mcache_child_id) references m2_mcache_child (id) on delete restrict on update restrict; + +create index ix_m2mcache_set2_m2_mcache_master on m2mcache_set2 (m2_mcache_master_id); +alter table m2mcache_set2 add constraint fk_m2mcache_set2_m2_mcache_master foreign key (m2_mcache_master_id) references m2_mcache_master (id) on delete restrict on update restrict; + +create index ix_m2mcache_set2_m2_mcache_child on m2mcache_set2 (m2_mcache_child_id); +alter table m2mcache_set2 add constraint fk_m2mcache_set2_m2_mcache_child foreign key (m2_mcache_child_id) references m2_mcache_child (id) on delete restrict on update restrict; + create index ix_mcontact_customer_id on mcontact (customer_id); alter table mcontact add constraint fk_mcontact_customer_id foreign key (customer_id) references mcustomer (id) on delete restrict on update restrict; @@ -4796,6 +4874,12 @@ alter table rawinherit_parent_rawinherit_data add constraint fk_rawinherit_paren create index ix_rawinherit_parent_rawinherit_data_rawinherit_data on rawinherit_parent_rawinherit_data (rawinherit_data_id); alter table rawinherit_parent_rawinherit_data add constraint fk_rawinherit_parent_rawinherit_data_rawinherit_data foreign key (rawinherit_data_id) references rawinherit_data (id) on delete restrict on update restrict; +create index ix_parent_a_child_id on parent_a (child_id); +alter table parent_a add constraint fk_parent_a_child_id foreign key (child_id) references child_with_cache (id) on delete restrict on update restrict; + +create index ix_parent_b_child_id on parent_b (child_id); +alter table parent_b add constraint fk_parent_b_child_id foreign key (child_id) references child_with_cache (id) on delete restrict on update restrict; + create index ix_parent_person_some_bean_id on parent_person (some_bean_id); alter table parent_person add constraint fk_parent_person_some_bean_id foreign key (some_bean_id) references e_basic (id) on delete restrict on update restrict; @@ -4829,6 +4913,8 @@ alter table person add constraint fk_person_default_address_oid foreign key (def create index ix_person_cache_email_person_info_person_id on person_cache_email (person_info_person_id); alter table person_cache_email add constraint fk_person_cache_email_person_info_person_id foreign key (person_info_person_id) references person_cache_info (person_id) on delete restrict on update restrict; +alter table persona add constraint fk_persona_person_oid foreign key (person_oid) references person (oid) on delete restrict on update restrict; + create index ix_phones_person_id on phones (person_id); alter table phones add constraint fk_phones_person_id foreign key (person_id) references persons (id) on delete restrict on update restrict; diff --git a/ebean-core/src/test/ddl-review/h2-drop-all.sql b/ebean-core/src/test/ddl-review/h2-drop-all.sql index 16a4f3c7a..52ce28b38 100644 --- a/ebean-core/src/test/ddl-review/h2-drop-all.sql +++ b/ebean-core/src/test/ddl-review/h2-drop-all.sql @@ -1,4 +1,4 @@ --- Generated by ebean unknown at 2020-12-07T09:40:50.461215Z +-- Generated by ebean unknown at 2021-02-12T03:32:14.253435800Z alter table bar drop constraint if exists fk_bar_foo_id; drop index if exists ix_bar_foo_id; @@ -417,6 +417,18 @@ drop index if exists ix_la_attr_value_attribute_attribute; alter table looney drop constraint if exists fk_looney_tune_id; drop index if exists ix_looney_tune_id; +alter table m2mcache_set1 drop constraint if exists fk_m2mcache_set1_m2_mcache_master; +drop index if exists ix_m2mcache_set1_m2_mcache_master; + +alter table m2mcache_set1 drop constraint if exists fk_m2mcache_set1_m2_mcache_child; +drop index if exists ix_m2mcache_set1_m2_mcache_child; + +alter table m2mcache_set2 drop constraint if exists fk_m2mcache_set2_m2_mcache_master; +drop index if exists ix_m2mcache_set2_m2_mcache_master; + +alter table m2mcache_set2 drop constraint if exists fk_m2mcache_set2_m2_mcache_child; +drop index if exists ix_m2mcache_set2_m2_mcache_child; + alter table mcontact drop constraint if exists fk_mcontact_customer_id; drop index if exists ix_mcontact_customer_id; @@ -639,6 +651,12 @@ drop index if exists ix_rawinherit_parent_rawinherit_data_rawinherit_parent; alter table rawinherit_parent_rawinherit_data drop constraint if exists fk_rawinherit_parent_rawinherit_data_rawinherit_data; drop index if exists ix_rawinherit_parent_rawinherit_data_rawinherit_data; +alter table parent_a drop constraint if exists fk_parent_a_child_id; +drop index if exists ix_parent_a_child_id; + +alter table parent_b drop constraint if exists fk_parent_b_child_id; +drop index if exists ix_parent_b_child_id; + alter table parent_person drop constraint if exists fk_parent_person_some_bean_id; drop index if exists ix_parent_person_some_bean_id; @@ -672,6 +690,8 @@ drop index if exists ix_person_default_address_oid; alter table person_cache_email drop constraint if exists fk_person_cache_email_person_info_person_id; drop index if exists ix_person_cache_email_person_info_person_id; +alter table persona drop constraint if exists fk_persona_person_oid; + alter table phones drop constraint if exists fk_phones_person_id; drop index if exists ix_phones_person_id; @@ -970,6 +990,8 @@ drop table if exists e_save_test_d; drop table if exists child_person; +drop table if exists child_with_cache; + drop table if exists cke_client; drop table if exists cke_user; @@ -1131,6 +1153,8 @@ drop table if exists ebasic_json_node_varchar; drop table if exists ebasic_json_unmapped; +drop table if exists e_basic_log; + drop table if exists e_basic_ndc; drop table if exists ebasic_no_sdchild; @@ -1145,6 +1169,8 @@ drop table if exists e_basic_withlife; drop table if exists e_basic_with_ex; +drop table if exists e_basic_withlog; + drop table if exists e_basicverucon; drop table if exists ecache_child; @@ -1463,6 +1489,14 @@ drop table if exists la_attr_value_attribute; drop table if exists looney; +drop table if exists m2_mcache_child; + +drop table if exists m2_mcache_master; + +drop table if exists m2mcache_set1; + +drop table if exists m2mcache_set2; + drop table if exists maddress; drop table if exists mcontact; @@ -1715,6 +1749,10 @@ drop table if exists rawinherit_parent_rawinherit_data; drop table if exists e_save_test_c; +drop table if exists parent_a; + +drop table if exists parent_b; + drop table if exists parent_person; drop table if exists c_participation; @@ -1745,6 +1783,8 @@ drop table if exists person_cache_email; drop table if exists person_cache_info; +drop table if exists persona; + drop table if exists phones; drop table if exists e_position; From e0c3a92b6067ab52930e31fd420db2c8c573ffe4 Mon Sep 17 00:00:00 2001 From: rob bygrave Date: Fri, 12 Feb 2021 21:01:57 +1300 Subject: [PATCH 087/447] Refactor FetchConfig --- .../src/main/java/io/ebean/FetchConfig.java | 290 +++++++----------- .../server/grammer/ParseFetchConfig.java | 8 +- .../server/loadcontext/DLoadBaseContext.java | 39 +-- .../server/loadcontext/DLoadBeanContext.java | 10 +- .../server/loadcontext/DLoadContext.java | 11 +- .../server/loadcontext/DLoadManyContext.java | 13 +- .../server/query/DFetchGroupBuilder.java | 6 +- .../server/query/DefaultFetchGroupQuery.java | 6 +- .../server/query/SqlTreeBuilder.java | 2 +- .../server/querydefn/DefaultOrmQuery.java | 6 +- .../server/querydefn/OrmQueryDetail.java | 4 +- .../server/querydefn/OrmQueryProperties.java | 124 ++------ .../querydefn/OrmQueryPropertiesParser.java | 10 +- .../test/java/io/ebean/FetchConfigTest.java | 108 ++----- .../java/io/ebean/plugin/BeanTypeTest.java | 2 +- ...faultServer_createOrmQueryRequestTest.java | 6 +- .../server/grammer/ParseFetchConfigTest.java | 20 +- .../server/loadcontext/DLoadContextTest.java | 25 +- .../querydefn/OrmQueryDetailParserTest.java | 4 +- .../OrmQueryPropertiesParserTest.java | 54 ++-- .../querydefn/OrmQueryPropertiesTest.java | 12 +- .../TestLazyLoadEmptyCollection.java | 2 +- .../tests/batchload/TestSecondaryQueries.java | 2 +- 23 files changed, 272 insertions(+), 492 deletions(-) diff --git a/ebean-api/src/main/java/io/ebean/FetchConfig.java b/ebean-api/src/main/java/io/ebean/FetchConfig.java index 39823b2c7..27b74af3b 100644 --- a/ebean-api/src/main/java/io/ebean/FetchConfig.java +++ b/ebean-api/src/main/java/io/ebean/FetchConfig.java @@ -3,30 +3,13 @@ package io.ebean; import java.io.Serializable; /** - * Defines the configuration options for a "query fetch" or a - * "lazy loading fetch". This gives you the ability to use multiple smaller - * queries to populate an object graph as opposed to a single large query. - *

- * The primary goal is to provide efficient ways of loading complex object - * graphs avoiding SQL Cartesian product and issues around populating object - * graphs that have multiple *ToMany relationships. - *

- *

- * It also provides the ability to control the lazy loading queries (batch size, - * selected properties and fetches) to avoid N+1 queries etc. - *

- * There can also be cases loading across a single OneToMany where 2 SQL queries - * using Ebean FetchConfig.query() can be more efficient than one SQL query. - * When the "One" side is wide (lots of columns) and the cardinality difference - * is high (a lot of "Many" beans per "One" bean) then this can be more - * efficient loaded as 2 SQL queries. - *

+ * Defines how a relationship is fetched via either normal SQL join, + * a eager secondary query, via lazy loading or via eagerly hitting L2 cache. *

*

{@code
  * // Normal fetch join results in a single SQL query
  * List list = DB.find(Order.class).fetch("details").findList();
  *
- * // Find Orders join details using a single SQL query
  * }
*

* Example: Using a "query join" instead of a "fetch join" we instead use 2 SQL queries @@ -37,103 +20,13 @@ import java.io.Serializable; * // This will use 2 SQL queries to build this object graph * List list = * DB.find(Order.class) - * .fetch("details", new FetchConfig().query()) + * .fetch("details", FetchConfig.ofQuery()) * .findList(); * * // query 1) find order * // query 2) find orderDetails where order.id in (?,?...) // first 100 order id's * * } - *

- * Example: Using 2 "query joins" - *

- *

- *

{@code
- *
- * // This will use 3 SQL queries to build this object graph
- * List list =
- *     DB.find(Order.class)
- *         .fetch("details", new FetchConfig().query())
- *         .fetch("customer", new FetchConfig().queryFirst(5))
- *         .findList();
- *
- * // query 1) find order
- * // query 2) find orderDetails where order.id in (?,?...) // first 100 order id's
- * // query 3) find customer where id in (?,?,?,?,?) // first 5 customers
- *
- * }
- *

- * Example: Using "query joins" and partial objects - *

- *

- * - *

{@code
- * // This will use 3 SQL queries to build this object graph
- * List list =
- *     DB.find(Order.class)
- *         .select("status, shipDate")
- *         .fetch("details", "quantity, price", new FetchConfig().query())
- *         .fetch("details.product", "sku, name")
- *         .fetch("customer", "name", new FetchConfig().queryFirst(5))
- *         .fetch("customer.contacts")
- *         .fetch("customer.shippingAddress")
- *         .findList();
- *
- * // query 1) find order (status, shipDate)
- * // query 2) find orderDetail (quantity, price) fetch product (sku, name) where
- * // order.id in (?,? ...)
- * // query 3) find customer (name) fetch contacts (*) fetch shippingAddress (*)
- * // where id in (?,?,?,?,?)
- *
- * // Note: the fetch of "details.product" is automatically included into the
- * // fetch of "details"
- * //
- * // Note: the fetch of "customer.contacts" and "customer.shippingAddress"
- * // are automatically included in the fetch of "customer"
- * }
- *

- * You can use query() and lazy together on a single join. The query is executed - * immediately and the lazy defines the batch size to use for further lazy - * loading (if lazy loading is invoked). - *

- *

- *

{@code
- *
- * List list =
- *     DB.find(Order.class)
- *         .fetch("customer", new FetchConfig().query(10).lazy(5))
- *         .findList();
- *
- * // query 1) find order
- * // query 2) find customer where id in (?,?,?,?,?,?,?,?,?,?) // first 10 customers
- * // .. then if lazy loading of customers is invoked
- * // .. use a batch size of 5 to load the customers
- *
- * }
- *

- *

- * Example of controlling the lazy loading query: - *

- *

- * This gives us the ability to optimise the lazy loading query for a given use - * case. - *

- *

- *

{@code
- *
- * List list = DB.find(Order.class)
- *   .fetch("customer","name", new FetchConfig().lazy(5))
- *   .fetch("customer.contacts","contactName, phone, email")
- *   .fetch("customer.shippingAddress")
- *   .where().eq("status",Order.Status.NEW)
- *   .findList();
- *
- * // query 1) find order where status = Order.Status.NEW
- * //
- * // .. if lazy loading of customers is invoked
- * // .. use a batch size of 5 to load the customers
- *
- * }
* * @author mario * @author rbygrave @@ -142,52 +35,105 @@ public class FetchConfig implements Serializable { private static final long serialVersionUID = 1L; - private int lazyBatchSize = -1; + private static final int JOIN_MODE = 0; + private static final int QUERY_MODE = 1; + private static final int LAZY_MODE = 2; + private static final int CACHE_MODE = 3; - private int queryBatchSize = -1; - - private boolean queryAll; - - private boolean cache; + private int mode; + private int batchSize; + private int hashCode; /** - * Construct the fetch configuration object. + * Construct using default JOIN mode. */ public FetchConfig() { + //this.mode = JOIN_MODE; + this.batchSize = 100; + this.hashCode = 1000; + } + + private FetchConfig(int mode, int batchSize) { + this.mode = mode; + this.batchSize = batchSize; + this.hashCode = mode + 10 * batchSize; } /** - * Specify that this path should be lazy loaded using the default batch load - * size. + * Return FetchConfig that will eagerly fetch the relationship using L2 cache. + *

+ * Any cache misses will be loaded by secondary query to the database. + */ + public static FetchConfig ofCache() { + return new FetchConfig(CACHE_MODE, 100); + } + + /** + * Return FetchConfig that use a eager secondary query to fetch the relationship. + */ + public static FetchConfig ofQuery() { + return new FetchConfig(QUERY_MODE, 100); + } + + /** + * Return FetchConfig that use a eager secondary query to fetch the relationship specifying the batch size. + */ + public static FetchConfig ofQuery(int batchSize) { + return new FetchConfig(QUERY_MODE, batchSize); + } + + /** + * Return FetchConfig that use lazy loading to fetch the relationship. + */ + public static FetchConfig ofLazy() { + return new FetchConfig(LAZY_MODE, 10); + } + + /** + * Return FetchConfig that use lazy loading to fetch the relationship specifying the batch size. + */ + public static FetchConfig ofLazy(int batchSize) { + return new FetchConfig(LAZY_MODE, batchSize); + } + + /** + * We want to migrate away from mutating FetchConfig to a fully immutable FetchConfig. + */ + private FetchConfig mutate(int mode, int batchSize) { + if (batchSize < 1) { + throw new IllegalArgumentException("batch size "+batchSize+" must be > 0"); + } + this.mode = mode; + this.batchSize = batchSize; + this.hashCode = mode + 10 * batchSize; + return this; + } + + /** + * Specify that this path should be lazy loaded using the default batch load size. */ public FetchConfig lazy() { - this.lazyBatchSize = 0; - this.queryAll = false; - return this; + return mutate(LAZY_MODE, 10); } /** * Specify that this path should be lazy loaded with a specified batch size. * - * @param lazyBatchSize the batch size for lazy loading + * @param batchSize the batch size for lazy loading */ - public FetchConfig lazy(int lazyBatchSize) { - this.lazyBatchSize = lazyBatchSize; - this.queryAll = false; - return this; + public FetchConfig lazy(int batchSize) { + return mutate(LAZY_MODE, batchSize); } /** - * Eagerly fetch the beans in this path as a separate query (rather than as + * Eagerly fetccd h the beans in this path as a separate query (rather than as * part of the main query). *

* This will use the default batch size for separate query which is 100. *

*/ public FetchConfig query() { - this.queryBatchSize = 0; - this.queryAll = true; - return this; + return mutate(QUERY_MODE, 100); } /** @@ -195,10 +141,7 @@ public class FetchConfig implements Serializable { * and using the DB for beans not in the cache. */ public FetchConfig cache() { - this.cache = true; - this.queryBatchSize = 0; - this.queryAll = true; - return this; + return mutate(CACHE_MODE, 100); } /** @@ -213,13 +156,10 @@ public class FetchConfig implements Serializable { * is also used. *

* - * @param queryBatchSize the batch size used to load beans on this path + * @param batchSize the batch size used to load beans on this path */ - public FetchConfig query(int queryBatchSize) { - this.queryBatchSize = queryBatchSize; - // queryAll true as long as a lazy batch size has not already been set - this.queryAll = (lazyBatchSize == -1); - return this; + public FetchConfig query(int batchSize) { + return mutate(QUERY_MODE, batchSize); } /** @@ -230,61 +170,57 @@ public class FetchConfig implements Serializable { * loaded eagerly but instead use lazy loading. *

* - * @param queryBatchSize the number of parent beans this path is populated for + * @param batchSize the number of parent beans this path is populated for */ - public FetchConfig queryFirst(int queryBatchSize) { - this.queryBatchSize = queryBatchSize; - this.queryAll = false; - return this; + @Deprecated + public FetchConfig queryFirst(int batchSize) { + return query(batchSize); } /** - * Return the batch size for lazy loading. + * Return the batch size for fetching. */ - public int getLazyBatchSize() { - return lazyBatchSize; + public int getBatchSize() { + return batchSize; } /** - * Return the batch size for separate query load. - */ - public int getQueryBatchSize() { - return queryBatchSize; - } - - /** - * Return true if the query fetch should fetch 'all' rather than just the - * 'first' batch. - */ - public boolean isQueryAll() { - return queryAll; - } - - /** - * Return true if this uses L2 bean cache. + * Return true if the fetch should use the L2 cache. */ public boolean isCache() { - return cache; + return mode == CACHE_MODE; + } + + /** + * Return true if the fetch should be a eager secondary query. + */ + public boolean isQuery() { + return mode == QUERY_MODE; + } + + /** + * Return true if the fetch should be a lazy query. + */ + public boolean isLazy() { + return mode == LAZY_MODE; + } + + /** + * Return true if the fetch should try to use SQL join. + */ + public boolean isJoin() { + return mode == JOIN_MODE; } @Override public boolean equals(Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; - - FetchConfig that = (FetchConfig) o; - if (lazyBatchSize != that.lazyBatchSize) return false; - if (queryBatchSize != that.queryBatchSize) return false; - if (cache != that.cache) return false; - return queryAll == that.queryAll; + return (hashCode == ((FetchConfig) o).hashCode); } @Override public int hashCode() { - int result = lazyBatchSize; - result = 92821 * result + queryBatchSize; - result = 92821 * result + (queryAll ? 1 : 0); - result = 92821 * result + (cache ? 1 : 0); - return result; + return hashCode; } } diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/grammer/ParseFetchConfig.java b/ebean-core/src/main/java/io/ebeaninternal/server/grammer/ParseFetchConfig.java index 67b2b9c24..5094fa346 100644 --- a/ebean-core/src/main/java/io/ebeaninternal/server/grammer/ParseFetchConfig.java +++ b/ebean-core/src/main/java/io/ebeaninternal/server/grammer/ParseFetchConfig.java @@ -17,11 +17,11 @@ class ParseFetchConfig { if (path.startsWith("lazy")) { if (path.length() == 4) { - return new FetchConfig().lazy(); + return FetchConfig.ofLazy(); } else if (path.charAt(4) == '(') { path = path.substring(5); int batchSize = parseBatchSize(path); - return new FetchConfig().lazy(batchSize); + return FetchConfig.ofLazy(batchSize); } else { return null; } @@ -29,11 +29,11 @@ class ParseFetchConfig { if (path.startsWith("query")) { if (path.length() == 5) { - return new FetchConfig().query(); + return FetchConfig.ofQuery(); } else if (path.charAt(5) == '(') { path = path.substring(6); int batchSize = parseBatchSize(path); - return new FetchConfig().query(batchSize); + return FetchConfig.ofQuery(batchSize); } else { return null; } diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/loadcontext/DLoadBaseContext.java b/ebean-core/src/main/java/io/ebeaninternal/server/loadcontext/DLoadBaseContext.java index 3040ebcaf..1be4717e9 100644 --- a/ebean-core/src/main/java/io/ebeaninternal/server/loadcontext/DLoadBaseContext.java +++ b/ebean-core/src/main/java/io/ebeaninternal/server/loadcontext/DLoadBaseContext.java @@ -1,6 +1,5 @@ package io.ebeaninternal.server.loadcontext; -import io.ebean.FetchConfig; import io.ebean.bean.ObjectGraphNode; import io.ebean.bean.PersistenceContext; import io.ebeaninternal.api.SpiQuery; @@ -28,9 +27,7 @@ abstract class DLoadBaseContext { final boolean hitCache; - final int firstBatchSize; - - final int secondaryBatchSize; + final int batchSize; final ObjectGraphNode objectGraphNode; @@ -45,38 +42,11 @@ abstract class DLoadBaseContext { this.hitCache = parent.isBeanCacheGet() && desc.isBeanCaching(); this.objectGraphNode = parent.getObjectGraphNode(path); this.queryFetch = queryProps != null && queryProps.isQueryFetch(); - this.firstBatchSize = initFirstBatchSize(defaultBatchSize, queryProps); - this.secondaryBatchSize = initSecondaryBatchSize(defaultBatchSize, firstBatchSize, queryProps); + this.batchSize = initBatchSize(defaultBatchSize, queryProps); } - private int initFirstBatchSize(int batchSize, OrmQueryProperties queryProps) { - if (queryProps == null) { - return batchSize; - } - - int queryBatchSize = queryProps.getQueryFetchBatch(); - if (queryBatchSize == -1) { - return batchSize; - - } else if (queryBatchSize == 0) { - return 100; - - } else { - return queryBatchSize; - } - } - - private int initSecondaryBatchSize(int defaultBatchSize, int firstBatchSize, OrmQueryProperties queryProps) { - if (queryProps == null) { - return defaultBatchSize; - } - FetchConfig fetchConfig = queryProps.getFetchConfig(); - if (fetchConfig.isQueryAll()) { - return firstBatchSize; - } - - int lazyBatchSize = fetchConfig.getLazyBatchSize(); - return (lazyBatchSize > 1) ? lazyBatchSize : defaultBatchSize; + private int initBatchSize(int batchSize, OrmQueryProperties queryProps) { + return queryProps == null ? batchSize : queryProps.getBatchSize(); } /** @@ -84,7 +54,6 @@ abstract class DLoadBaseContext { * set onto the secondary query. */ void setLabel(SpiQuery query) { - String label = parent.getPlanLabel(); if (label != null) { query.setProfilePath(label, fullPath, parent.getProfileLocation()); diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/loadcontext/DLoadBeanContext.java b/ebean-core/src/main/java/io/ebeaninternal/server/loadcontext/DLoadBeanContext.java index 454fd6dac..d24a24532 100644 --- a/ebean-core/src/main/java/io/ebeaninternal/server/loadcontext/DLoadBeanContext.java +++ b/ebean-core/src/main/java/io/ebeaninternal/server/loadcontext/DLoadBeanContext.java @@ -35,7 +35,7 @@ class DLoadBeanContext extends DLoadBaseContext implements LoadBeanContext { super(parent, desc, path, defaultBatchSize, queryProps); // bufferList only required when using query joins (queryFetch) this.bufferList = (!queryFetch) ? null : new ArrayList<>(); - this.currentBuffer = createBuffer(firstBatchSize); + this.currentBuffer = createBuffer(batchSize); this.cache = (queryProps != null) && queryProps.isCache(); } @@ -52,7 +52,7 @@ class DLoadBeanContext extends DLoadBaseContext implements LoadBeanContext { if (bufferList != null) { bufferList.clear(); } - currentBuffer = createBuffer(secondaryBatchSize); + currentBuffer = createBuffer(batchSize); } private void configureQuery(SpiQuery query, String lazyLoadProperty) { @@ -70,7 +70,7 @@ class DLoadBeanContext extends DLoadBaseContext implements LoadBeanContext { protected void register(EntityBeanIntercept ebi) { if (currentBuffer.isFull()) { - currentBuffer = createBuffer(secondaryBatchSize); + currentBuffer = createBuffer(batchSize); } ebi.setBeanLoader(currentBuffer, getPersistenceContext()); currentBuffer.add(ebi); @@ -95,10 +95,6 @@ class DLoadBeanContext extends DLoadBaseContext implements LoadBeanContext { for (LoadBuffer loadBuffer : bufferList) { if (!loadBuffer.list.isEmpty()) { parent.getEbeanServer().loadBean(new LoadBeanRequest(loadBuffer, parentRequest)); - if (!queryProps.isQueryFetchAll()) { - // Stop - only fetch the first batch ... the rest will be lazy loaded - break; - } } if (forEach) { clear(); diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/loadcontext/DLoadContext.java b/ebean-core/src/main/java/io/ebeaninternal/server/loadcontext/DLoadContext.java index df2a9e8e8..b5aa6f873 100644 --- a/ebean-core/src/main/java/io/ebeaninternal/server/loadcontext/DLoadContext.java +++ b/ebean-core/src/main/java/io/ebeaninternal/server/loadcontext/DLoadContext.java @@ -188,7 +188,7 @@ public class DLoadContext implements LoadContext { } int maxBatch = 0; for (OrmQueryProperties aSecQuery : secQuery) { - int batchSize = aSecQuery.getQueryFetchBatch(); + int batchSize = aSecQuery.getBatchSize(); if (batchSize == 0) { batchSize = defaultQueryBatch; } @@ -300,12 +300,9 @@ public class DLoadContext implements LoadContext { } private void registerSecondaryNode(boolean many, OrmQueryProperties props) { - int batchSize; - if (props.isQueryFetch()) { - batchSize = 100; - } else { - int lazyJoinBatch = props.getLazyFetchBatch(); - batchSize = lazyJoinBatch > 0 ? lazyJoinBatch : defaultBatchSize; + int batchSize = props.getBatchSize(); + if (batchSize == 0) { + batchSize = defaultBatchSize; } String path = props.getPath(); if (many) { diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/loadcontext/DLoadManyContext.java b/ebean-core/src/main/java/io/ebeaninternal/server/loadcontext/DLoadManyContext.java index ac846e359..7a51127d8 100644 --- a/ebean-core/src/main/java/io/ebeaninternal/server/loadcontext/DLoadManyContext.java +++ b/ebean-core/src/main/java/io/ebeaninternal/server/loadcontext/DLoadManyContext.java @@ -40,7 +40,7 @@ class DLoadManyContext extends DLoadBaseContext implements LoadManyContext { this.docStoreMapped = property.isTargetDocStoreMapped(); // bufferList only required when using query joins (queryFetch) this.bufferList = (!queryFetch) ? null : new ArrayList<>(); - this.currentBuffer = createBuffer(firstBatchSize); + this.currentBuffer = createBuffer(batchSize); } private LoadBuffer createBuffer(int size) { @@ -58,11 +58,10 @@ class DLoadManyContext extends DLoadBaseContext implements LoadManyContext { if (bufferList != null) { bufferList.clear(); } - currentBuffer = createBuffer(secondaryBatchSize); + currentBuffer = createBuffer(batchSize); } private void configureQuery(SpiQuery query) { - setLabel(query); parent.propagateQueryState(query, docStoreMapped); query.setParentNode(objectGraphNode); @@ -85,9 +84,8 @@ class DLoadManyContext extends DLoadBaseContext implements LoadManyContext { } public void register(BeanCollection bc) { - if (currentBuffer.isFull()) { - currentBuffer = createBuffer(secondaryBatchSize); + currentBuffer = createBuffer(batchSize); } currentBuffer.add(bc); bc.setLoader(currentBuffer); @@ -105,13 +103,8 @@ class DLoadManyContext extends DLoadBaseContext implements LoadManyContext { if (!loadBuffer.list.isEmpty()) { LoadManyRequest req = new LoadManyRequest(loadBuffer, parentRequest); parent.getEbeanServer().loadMany(req); - if (!queryProps.isQueryFetchAll()) { - // Stop - only fetch the first batch ... the rest will be lazy loaded - break; - } } } - if (forEach) { clear(); } else { diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/query/DFetchGroupBuilder.java b/ebean-core/src/main/java/io/ebeaninternal/server/query/DFetchGroupBuilder.java index 1c858f3ab..f33985f46 100644 --- a/ebean-core/src/main/java/io/ebeaninternal/server/query/DFetchGroupBuilder.java +++ b/ebean-core/src/main/java/io/ebeaninternal/server/query/DFetchGroupBuilder.java @@ -11,11 +11,11 @@ import io.ebeaninternal.server.querydefn.SpiFetchGroup; */ class DFetchGroupBuilder implements FetchGroupBuilder { - private static final FetchConfig FETCH_CACHE = new FetchConfig().cache(); + private static final FetchConfig FETCH_CACHE = FetchConfig.ofCache(); - private static final FetchConfig FETCH_QUERY = new FetchConfig().query(); + private static final FetchConfig FETCH_QUERY = FetchConfig.ofQuery(); - private static final FetchConfig FETCH_LAZY = new FetchConfig().lazy(); + private static final FetchConfig FETCH_LAZY = FetchConfig.ofLazy(); private final OrmQueryDetail detail; diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/query/DefaultFetchGroupQuery.java b/ebean-core/src/main/java/io/ebeaninternal/server/query/DefaultFetchGroupQuery.java index 063f2071c..8f2351846 100644 --- a/ebean-core/src/main/java/io/ebeaninternal/server/query/DefaultFetchGroupQuery.java +++ b/ebean-core/src/main/java/io/ebeaninternal/server/query/DefaultFetchGroupQuery.java @@ -45,11 +45,11 @@ import java.util.stream.Stream; */ class DefaultFetchGroupQuery implements SpiFetchGroupQuery { - private static final FetchConfig FETCH_CACHE = new FetchConfig().cache(); + private static final FetchConfig FETCH_CACHE = FetchConfig.ofCache(); - private static final FetchConfig FETCH_QUERY = new FetchConfig().query(); + private static final FetchConfig FETCH_QUERY = FetchConfig.ofQuery(); - private static final FetchConfig FETCH_LAZY = new FetchConfig().lazy(); + private static final FetchConfig FETCH_LAZY = FetchConfig.ofLazy(); private OrmQueryDetail detail = new OrmQueryDetail(); diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/query/SqlTreeBuilder.java b/ebean-core/src/main/java/io/ebeaninternal/server/query/SqlTreeBuilder.java index d9386ed9b..065884b54 100644 --- a/ebean-core/src/main/java/io/ebeaninternal/server/query/SqlTreeBuilder.java +++ b/ebean-core/src/main/java/io/ebeaninternal/server/query/SqlTreeBuilder.java @@ -452,7 +452,7 @@ public final class SqlTreeBuilder { // Also note that this can include transient properties. // This makes sense for transient properties used to // hold sum() count() type values (with SqlSelect) - final Set selectInclude = queryProps.getSelectInclude(); + final Set selectInclude = queryProps.getIncluded(); for (String propName : selectInclude) { if (!propName.isEmpty()) { addProperty(selectProps, desc, queryProps, propName); diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/querydefn/DefaultOrmQuery.java b/ebean-core/src/main/java/io/ebeaninternal/server/querydefn/DefaultOrmQuery.java index 2f73bceb7..961684be5 100644 --- a/ebean-core/src/main/java/io/ebeaninternal/server/querydefn/DefaultOrmQuery.java +++ b/ebean-core/src/main/java/io/ebeaninternal/server/querydefn/DefaultOrmQuery.java @@ -83,11 +83,11 @@ public class DefaultOrmQuery implements SpiQuery { private static final String DEFAULT_QUERY_NAME = "default"; - private static final FetchConfig FETCH_CACHE = new FetchConfig().cache(); + private static final FetchConfig FETCH_CACHE = FetchConfig.ofCache(); - private static final FetchConfig FETCH_QUERY = new FetchConfig().query(); + private static final FetchConfig FETCH_QUERY = FetchConfig.ofQuery(); - private static final FetchConfig FETCH_LAZY = new FetchConfig().lazy(); + private static final FetchConfig FETCH_LAZY = FetchConfig.ofLazy(); private final ReentrantLock lock = new ReentrantLock(); diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/querydefn/OrmQueryDetail.java b/ebean-core/src/main/java/io/ebeaninternal/server/querydefn/OrmQueryDetail.java index 1310b709a..b36daaf58 100644 --- a/ebean-core/src/main/java/io/ebeaninternal/server/querydefn/OrmQueryDetail.java +++ b/ebean-core/src/main/java/io/ebeaninternal/server/querydefn/OrmQueryDetail.java @@ -117,14 +117,14 @@ public class OrmQueryDetail implements Serializable { public String asString() { StringBuilder sb = new StringBuilder(); if (!baseProps.isEmpty()) { - baseProps.append("select ", sb); + baseProps.asStringDebug("select ", sb); } if (fetchPaths != null) { for (OrmQueryProperties join : fetchPaths.values()) { if (sb.length() > 0) { sb.append(" "); } - join.append("fetch ", sb); + join.asStringDebug("fetch ", sb); } } return sb.toString(); diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/querydefn/OrmQueryProperties.java b/ebean-core/src/main/java/io/ebeaninternal/server/querydefn/OrmQueryProperties.java index 805c3bf68..425a5d927 100644 --- a/ebean-core/src/main/java/io/ebeaninternal/server/querydefn/OrmQueryProperties.java +++ b/ebean-core/src/main/java/io/ebeaninternal/server/querydefn/OrmQueryProperties.java @@ -30,12 +30,8 @@ public class OrmQueryProperties implements Serializable { private final String parentPath; private final String path; - - private final String rawProperties; - private final String trimmedProperties; - - private final LinkedHashSet included; - + private final String properties; + private final Set included; private final FetchConfig fetchConfig; /** @@ -84,8 +80,7 @@ public class OrmQueryProperties implements Serializable { public OrmQueryProperties(String path) { this.path = path; this.parentPath = SplitName.parent(path); - this.rawProperties = null; - this.trimmedProperties = null; + this.properties = null; this.included = null; this.fetchConfig = DEFAULT_FETCH; } @@ -95,13 +90,11 @@ public class OrmQueryProperties implements Serializable { } public OrmQueryProperties(String path, String rawProperties, FetchConfig fetchConfig) { - - OrmQueryPropertiesParser.Response response = OrmQueryPropertiesParser.parse(rawProperties); - this.path = path; this.parentPath = SplitName.parent(path); - this.rawProperties = rawProperties; - this.trimmedProperties = response.properties; + + OrmQueryPropertiesParser.Response response = OrmQueryPropertiesParser.parse(rawProperties); + this.properties = response.properties; this.included = response.included; this.cache = response.cache; this.readOnly = response.readOnly; @@ -115,39 +108,17 @@ public class OrmQueryProperties implements Serializable { } } - public OrmQueryProperties(String path, LinkedHashSet parsedProperties) { - if (parsedProperties == null) { - throw new IllegalArgumentException("parsedProperties is null"); - } - + public OrmQueryProperties(String path, Set included) { this.path = path; this.parentPath = SplitName.parent(path); // for rawSql parsedProperties can be empty (when only fetching Id property) - this.included = parsedProperties; - this.rawProperties = join(parsedProperties); - this.trimmedProperties = rawProperties; + this.included = included; + this.properties = String.join(",", included); this.cache = false; this.readOnly = false; this.fetchConfig = DEFAULT_FETCH; } - /** - * Join the set of properties into a comma delimited string. - */ - private String join(LinkedHashSet parsedProperties) { - StringBuilder sb = new StringBuilder(50); - boolean first = true; - for (String property : parsedProperties) { - if (first) { - first = false; - } else { - sb.append(","); - } - sb.append(property); - } - return sb.toString(); - } - /** * Copy constructor. */ @@ -155,8 +126,7 @@ public class OrmQueryProperties implements Serializable { this.fetchConfig = sourceFetchConfig; this.parentPath = source.parentPath; this.path = source.path; - this.rawProperties = source.rawProperties; - this.trimmedProperties = source.trimmedProperties; + this.properties = source.properties; this.cache = source.cache; this.readOnly = source.readOnly; this.filterMany = source.filterMany; @@ -240,8 +210,8 @@ public class OrmQueryProperties implements Serializable { @SuppressWarnings("unchecked") public void configureBeanQuery(SpiQuery query) { - if (trimmedProperties != null && !trimmedProperties.isEmpty()) { - query.select(trimmedProperties); + if (properties != null && !properties.isEmpty()) { + query.select(properties); } if (filterMany != null) { @@ -268,7 +238,7 @@ public class OrmQueryProperties implements Serializable { } public boolean hasSelectClause() { - if ("*".equals(trimmedProperties)) { + if ("*".equals(properties)) { // explicitly selected all properties return true; } @@ -280,25 +250,17 @@ public class OrmQueryProperties implements Serializable { * Return true if the properties and configuration are empty. */ public boolean isEmpty() { - return rawProperties == null || rawProperties.isEmpty(); + return properties == null || properties.isEmpty(); } - @Override - public String toString() { - StringBuilder sb = new StringBuilder(40); - append("", sb); - return sb.toString(); - } - - public String append(String prefix, StringBuilder sb) { + public void asStringDebug(String prefix, StringBuilder sb) { sb.append(prefix); if (path != null) { sb.append(path).append(" "); } if (!isEmpty()) { - sb.append("(").append(rawProperties).append(")"); + sb.append("(").append(properties).append(")"); } - return sb.toString(); } boolean isChild(OrmQueryProperties possibleChild) { @@ -319,7 +281,7 @@ public class OrmQueryProperties implements Serializable { * Return the raw properties. */ public String getProperties() { - return rawProperties; + return properties; } /** @@ -350,10 +312,6 @@ public class OrmQueryProperties implements Serializable { includedBeanJoin.add(propertyName); } - public Set getSelectInclude() { - return included; - } - public Set getSelectQueryJoin() { return secondaryQueryJoins; } @@ -373,7 +331,6 @@ public class OrmQueryProperties implements Serializable { } boolean isIncluded(String propName) { - if (includedBeanJoin != null && includedBeanJoin.contains(propName)) { return false; } @@ -392,42 +349,25 @@ public class OrmQueryProperties implements Serializable { * Return true if this path is a 'query join'. */ public boolean isQueryFetch() { - return markForQueryJoin || getQueryFetchBatch() > -1; + return markForQueryJoin || cache || fetchConfig.isQuery(); } /** * Return true if this path is a 'fetch join'. */ boolean isFetchJoin() { - return !isQueryFetch() && !isLazyFetch(); + return !markForQueryJoin && fetchConfig.isJoin(); } /** * Return true if this path is a lazy fetch. */ boolean isLazyFetch() { - return getLazyFetchBatch() > -1; + return fetchConfig.isLazy(); } - /** - * Return the batch size to use for the query join. - */ - public int getQueryFetchBatch() { - return fetchConfig.getQueryBatchSize(); - } - - /** - * Return true if a query join should eagerly fetch 'all' rather than the 'first'. - */ - public boolean isQueryFetchAll() { - return fetchConfig.isQueryAll(); - } - - /** - * Return the batch size to use for lazy loading. - */ - public int getLazyFetchBatch() { - return fetchConfig.getLazyBatchSize(); + public int getBatchSize() { + return fetchConfig.getBatchSize(); } /** @@ -474,26 +414,24 @@ public class OrmQueryProperties implements Serializable { * Calculate the query plan hash. */ public void queryPlanHash(StringBuilder builder) { - - builder.append("qpp["); - builder.append(path); + builder.append("{"); + if (path != null) { + builder.append(path); + } if (included != null){ - builder.append(" included:").append(included); + builder.append("/i").append(included); } if (secondaryQueryJoins != null) { - builder.append(" secondary:").append(secondaryQueryJoins); + builder.append("/s").append(secondaryQueryJoins); } - if (filterMany != null) { - builder.append(" filterMany["); + builder.append("/f"); filterMany.queryPlanHash(builder); - builder.append("]"); } - if (fetchConfig != null) { - builder.append(" config:").append(fetchConfig.hashCode()); + builder.append("/c").append(fetchConfig.hashCode()); } - builder.append("]"); + builder.append("}"); } } diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/querydefn/OrmQueryPropertiesParser.java b/ebean-core/src/main/java/io/ebeaninternal/server/querydefn/OrmQueryPropertiesParser.java index 5c03e0a33..e7c416390 100644 --- a/ebean-core/src/main/java/io/ebeaninternal/server/querydefn/OrmQueryPropertiesParser.java +++ b/ebean-core/src/main/java/io/ebeaninternal/server/querydefn/OrmQueryPropertiesParser.java @@ -29,8 +29,10 @@ class OrmQueryPropertiesParser { this.cache = cache; this.properties = properties; this.included = included; - if (lazyFetchBatch > -1 || queryFetchBatch > -1) { - this.fetchConfig = new FetchConfig().lazy(lazyFetchBatch).query(queryFetchBatch); + if (queryFetchBatch > 0) { + this.fetchConfig = FetchConfig.ofQuery(queryFetchBatch); + } else if (lazyFetchBatch > 0) { + this.fetchConfig = FetchConfig.ofLazy(lazyFetchBatch); } else { this.fetchConfig = OrmQueryProperties.DEFAULT_FETCH; } @@ -59,8 +61,8 @@ class OrmQueryPropertiesParser { private boolean allProperties; private boolean readOnly; private boolean cache; - private int queryFetchBatch = -1; - private int lazyFetchBatch = -1; + private int queryFetchBatch; + private int lazyFetchBatch; private OrmQueryPropertiesParser(String inputProperties) { this.inputProperties = inputProperties; diff --git a/ebean-core/src/test/java/io/ebean/FetchConfigTest.java b/ebean-core/src/test/java/io/ebean/FetchConfigTest.java index a88e1e4be..abd09d692 100644 --- a/ebean-core/src/test/java/io/ebean/FetchConfigTest.java +++ b/ebean-core/src/test/java/io/ebean/FetchConfigTest.java @@ -8,151 +8,110 @@ import static org.assertj.core.api.Assertions.assertThat; public class FetchConfigTest { @Test - public void testLazy() throws Exception { - + public void testLazy() { FetchConfig config = new FetchConfig().lazy(); - - assertThat(config.getLazyBatchSize()).isEqualTo(0); - assertThat(config.getQueryBatchSize()).isEqualTo(-1); - assertThat(config.isQueryAll()).isEqualTo(false); + assertThat(config.getBatchSize()).isEqualTo(10); } @Test - public void testLazy_withParameter() throws Exception { - + public void testLazy_withParameter() { FetchConfig config = new FetchConfig().lazy(50); - - assertThat(config.getLazyBatchSize()).isEqualTo(50); - assertThat(config.getQueryBatchSize()).isEqualTo(-1); - assertThat(config.isQueryAll()).isEqualTo(false); + assertThat(config.getBatchSize()).isEqualTo(50); } @Test - public void testQuery() throws Exception { - + public void testQuery() { FetchConfig config = new FetchConfig().query(); - - assertThat(config.getLazyBatchSize()).isEqualTo(-1); - assertThat(config.getQueryBatchSize()).isEqualTo(0); - assertThat(config.isQueryAll()).isEqualTo(true); + assertThat(config.getBatchSize()).isEqualTo(100); } @Test - public void testQuery_withParameter() throws Exception { - + public void testQuery_withParameter() { FetchConfig config = new FetchConfig().query(50); - - assertThat(config.getLazyBatchSize()).isEqualTo(-1); - assertThat(config.getQueryBatchSize()).isEqualTo(50); - assertThat(config.isQueryAll()).isEqualTo(true); + assertThat(config.getBatchSize()).isEqualTo(50); } @Test - public void testQueryFirst() throws Exception { - + public void testQueryFirst() { FetchConfig config = new FetchConfig().queryFirst(50); - - assertThat(config.getLazyBatchSize()).isEqualTo(-1); - assertThat(config.getQueryBatchSize()).isEqualTo(50); - assertThat(config.isQueryAll()).isEqualTo(false); + assertThat(config.getBatchSize()).isEqualTo(50); } @Test - public void testQueryAndLazy_withParameters() throws Exception { - - FetchConfig config = new FetchConfig().query(50).lazy(10); - - assertThat(config.getLazyBatchSize()).isEqualTo(10); - assertThat(config.getQueryBatchSize()).isEqualTo(50); - assertThat(config.isQueryAll()).isEqualTo(false); + public void testQueryAndLazy_withParameters() { + FetchConfig config = FetchConfig.ofLazy(10); + assertThat(config.getBatchSize()).isEqualTo(10); } @Test - public void testQueryAndLazy() throws Exception { - - FetchConfig config = new FetchConfig().query(50).lazy(); - - assertThat(config.getLazyBatchSize()).isEqualTo(0); - assertThat(config.getQueryBatchSize()).isEqualTo(50); - assertThat(config.isQueryAll()).isEqualTo(false); + public void testQueryAndLazy() { + FetchConfig config = FetchConfig.ofQuery(50); + assertThat(config.getBatchSize()).isEqualTo(50); } @Test - public void testEquals_when_noOptions() throws Exception { - + public void testEquals_when_noOptions() { assertSame(new FetchConfig(), new FetchConfig()); } @Test - public void testEquals_when_query_50_lazy_40() throws Exception { - - assertSame(new FetchConfig().query(50).lazy(40), new FetchConfig().query(50).lazy(40)); + public void testEquals_when_query_50_lazy_40() { + assertSame(new FetchConfig().query(50), FetchConfig.ofQuery(50)); } @Test - public void testEquals_when_query_50_lazy() throws Exception { - - assertSame(new FetchConfig().query(50).lazy(), new FetchConfig().query(50).lazy()); + public void testEquals_when_query_50_lazy() { + assertSame(new FetchConfig().lazy(), FetchConfig.ofLazy()); } @Test - public void testEquals_when_query_50() throws Exception { - + public void testEquals_when_query_50() { assertSame(new FetchConfig().query(50), new FetchConfig().query(50)); } @Test - public void testEquals_when_queryFirst_50_lazy_40() throws Exception { - - assertSame(new FetchConfig().queryFirst(50).lazy(40), new FetchConfig().queryFirst(50).lazy(40)); + public void testEquals_when_queryFirst_50_lazy_40() { + assertSame(new FetchConfig().queryFirst(50).lazy(40), FetchConfig.ofLazy(40)); } @Test - public void testEquals_when_queryFirst_50_lazy() throws Exception { - + public void testEquals_when_queryFirst_50_lazy() { assertSame(new FetchConfig().queryFirst(50).lazy(), new FetchConfig().queryFirst(50).lazy()); } @Test - public void testEquals_when_queryFirst_50() throws Exception { - - assertSame(new FetchConfig().queryFirst(50), new FetchConfig().queryFirst(50)); + public void testEquals_when_queryFirst_50() { + assertSame(new FetchConfig().queryFirst(50), FetchConfig.ofQuery(50)); } @Test - public void testNotEquals_when_query_50() throws Exception { - + public void testNotEquals_when_query_50() { assertDifferent(new FetchConfig().query(50), new FetchConfig().query(40)); } @Test - public void testNotEquals_when_query_50_lazy() throws Exception { - + public void testNotEquals_when_query_50_lazy() { assertDifferent(new FetchConfig().query(50), new FetchConfig().query(50).lazy()); } @Test - public void testNotEquals_when_query_50_lazy_40() throws Exception { - + public void testNotEquals_when_query_50_lazy_40() { assertDifferent(new FetchConfig().query(50), new FetchConfig().query(50).lazy(40)); } @Test - public void testNotEquals_when_queryFirst_50() throws Exception { - + public void testNotEquals_when_queryFirst_50() { assertDifferent(new FetchConfig().queryFirst(50), new FetchConfig().queryFirst(40)); } @Test - public void testNotEquals_when_queryFirst_50_lazy() throws Exception { - + public void testNotEquals_when_queryFirst_50_lazy() { assertDifferent(new FetchConfig().queryFirst(50), new FetchConfig().queryFirst(50).lazy()); } @Test - public void testNotEquals_when_queryFirst_50_lazy_40() throws Exception { - + public void testNotEquals_when_queryFirst_50_lazy_40() { assertDifferent(new FetchConfig().queryFirst(50), new FetchConfig().queryFirst(50).lazy(40)); } @@ -161,7 +120,6 @@ public class FetchConfigTest { assertThat(v1.hashCode()).isNotEqualTo(v2.hashCode()); } - void assertSame(FetchConfig v1, FetchConfig v2) { assertThat(v1).isEqualTo(v2); assertThat(v1.hashCode()).isEqualTo(v2.hashCode()); diff --git a/ebean-core/src/test/java/io/ebean/plugin/BeanTypeTest.java b/ebean-core/src/test/java/io/ebean/plugin/BeanTypeTest.java index 2b880805a..820e89408 100644 --- a/ebean-core/src/test/java/io/ebean/plugin/BeanTypeTest.java +++ b/ebean-core/src/test/java/io/ebean/plugin/BeanTypeTest.java @@ -177,7 +177,7 @@ public class BeanTypeTest { beanType(Order.class).docStore().applyPath(orderQuery); OrmQueryDetail detail = orderQuery.getDetail(); - assertThat(detail.getChunk("customer", false).getSelectInclude()).containsExactly("id", "name"); + assertThat(detail.getChunk("customer", false).getIncluded()).containsExactly("id", "name"); } @Test(expected = IllegalStateException.class) diff --git a/ebean-core/src/test/java/io/ebeaninternal/server/core/DefaultServer_createOrmQueryRequestTest.java b/ebean-core/src/test/java/io/ebeaninternal/server/core/DefaultServer_createOrmQueryRequestTest.java index a91cfa0d1..662bdf311 100644 --- a/ebean-core/src/test/java/io/ebeaninternal/server/core/DefaultServer_createOrmQueryRequestTest.java +++ b/ebean-core/src/test/java/io/ebeaninternal/server/core/DefaultServer_createOrmQueryRequestTest.java @@ -76,7 +76,7 @@ public class DefaultServer_createOrmQueryRequestTest extends BaseTestCase { public void when_extra_queryFetchToMany_then_same() { assertDifferent(detail(query().select("id,name").fetch("customer")), - detail(query().select("id,name").fetch("customer").fetch("details", new FetchConfig().query()))); + detail(query().select("id,name").fetch("customer").fetch("details", FetchConfig.ofQuery()))); } @Test @@ -84,7 +84,7 @@ public class DefaultServer_createOrmQueryRequestTest extends BaseTestCase { // with the fetch of customer the foreign key must be added to the root query assertDifferent(detail(query().select("id,name")), - detail(query().select("id,name").fetch("customer", new FetchConfig().query()))); + detail(query().select("id,name").fetch("customer", FetchConfig.ofQuery()))); } @Test @@ -173,7 +173,7 @@ public class DefaultServer_createOrmQueryRequestTest extends BaseTestCase { Query query = Ebean.find(Order.class) .select("status, orderDate") .fetch("customer", "name") - .fetch("details", new FetchConfig().lazy()); + .fetch("details", FetchConfig.ofLazy()); OrmQueryRequest queryRequest = queryRequest(query); OrmQueryDetail detail = queryRequest.getQuery().getDetail(); diff --git a/ebean-core/src/test/java/io/ebeaninternal/server/grammer/ParseFetchConfigTest.java b/ebean-core/src/test/java/io/ebeaninternal/server/grammer/ParseFetchConfigTest.java index 8e40bcc34..a940cd26b 100644 --- a/ebean-core/src/test/java/io/ebeaninternal/server/grammer/ParseFetchConfigTest.java +++ b/ebean-core/src/test/java/io/ebeaninternal/server/grammer/ParseFetchConfigTest.java @@ -17,30 +17,26 @@ public class ParseFetchConfigTest { } @Test - public void parseLazy() throws Exception { - + public void parseLazy() { FetchConfig lazy = ParseFetchConfig.parse("lazy"); - assertThat(lazy.getLazyBatchSize()).isEqualTo(0); + assertThat(lazy.getBatchSize()).isEqualTo(10); } @Test - public void parseLazy100() throws Exception { - + public void parseLazy100() { FetchConfig lazy = ParseFetchConfig.parse("lazy(100)"); - assertThat(lazy.getLazyBatchSize()).isEqualTo(100); + assertThat(lazy.getBatchSize()).isEqualTo(100); } @Test - public void parseQuery() throws Exception { - + public void parseQuery() { FetchConfig lazy = ParseFetchConfig.parse("query"); - assertThat(lazy.getQueryBatchSize()).isEqualTo(0); + assertThat(lazy.getBatchSize()).isEqualTo(100); } @Test - public void parseQuery100() throws Exception { - + public void parseQuery100() { FetchConfig lazy = ParseFetchConfig.parse("query(50)"); - assertThat(lazy.getQueryBatchSize()).isEqualTo(50); + assertThat(lazy.getBatchSize()).isEqualTo(50); } } diff --git a/ebean-core/src/test/java/io/ebeaninternal/server/loadcontext/DLoadContextTest.java b/ebean-core/src/test/java/io/ebeaninternal/server/loadcontext/DLoadContextTest.java index 9a79eb827..45962f7cd 100644 --- a/ebean-core/src/test/java/io/ebeaninternal/server/loadcontext/DLoadContextTest.java +++ b/ebean-core/src/test/java/io/ebeaninternal/server/loadcontext/DLoadContextTest.java @@ -31,23 +31,20 @@ public class DLoadContextTest extends BaseTestCase { DLoadContext graphContext = (DLoadContext) queryRequest.getGraphContext(); DLoadBeanContext customer = graphContext.getBeanContext("customer"); - - assertThat(customer.firstBatchSize).isEqualTo(10); - assertThat(customer.secondaryBatchSize).isEqualTo(10); + assertThat(customer.batchSize).isEqualTo(10); } @Test public void construct_when_fetchQuery_expect_100_batchSize() { - OrmQueryRequest queryRequest = queryRequest(query().fetch("customer", new FetchConfig().query())); + OrmQueryRequest queryRequest = queryRequest(query().fetch("customer", FetchConfig.ofQuery())); queryRequest.initTransIfRequired(); queryRequest.endTransIfRequired(); DLoadContext graphContext = (DLoadContext) queryRequest.getGraphContext(); DLoadBeanContext customer = graphContext.getBeanContext("customer"); - assertThat(customer.firstBatchSize).isEqualTo(100); - assertThat(customer.secondaryBatchSize).isEqualTo(100); + assertThat(customer.batchSize).isEqualTo(100); } @Test @@ -60,22 +57,20 @@ public class DLoadContextTest extends BaseTestCase { DLoadContext graphContext = (DLoadContext) queryRequest.getGraphContext(); DLoadBeanContext customer = graphContext.getBeanContext("customer"); - assertThat(customer.firstBatchSize).isEqualTo(100); - assertThat(customer.secondaryBatchSize).isEqualTo(100); + assertThat(customer.batchSize).isEqualTo(100); } @Test public void construct_when_fetchQuery50_expect_50_batchSize() { - OrmQueryRequest queryRequest = queryRequest(query().fetch("customer", new FetchConfig().query(50))); + OrmQueryRequest queryRequest = queryRequest(query().fetch("customer", FetchConfig.ofQuery(50))); queryRequest.initTransIfRequired(); queryRequest.endTransIfRequired(); DLoadContext graphContext = (DLoadContext) queryRequest.getGraphContext(); DLoadBeanContext customer = graphContext.getBeanContext("customer"); - assertThat(customer.firstBatchSize).isEqualTo(50); - assertThat(customer.secondaryBatchSize).isEqualTo(50); + assertThat(customer.batchSize).isEqualTo(50); } @Test @@ -88,8 +83,7 @@ public class DLoadContextTest extends BaseTestCase { DLoadContext graphContext = (DLoadContext) queryRequest.getGraphContext(); DLoadBeanContext customer = graphContext.getBeanContext("customer"); - assertThat(customer.firstBatchSize).isEqualTo(20); - assertThat(customer.secondaryBatchSize).isEqualTo(5); + assertThat(customer.batchSize).isEqualTo(5); } @Test @@ -97,15 +91,14 @@ public class DLoadContextTest extends BaseTestCase { BeanPropertyAssocMany many = (BeanPropertyAssocMany)getBeanDescriptor(Order.class).getBeanProperty("details"); // the fetch is converted to a query join due to the maxRows - OrmQueryRequest queryRequest = queryRequest(query().fetch("details").setMaxRows(100)); + OrmQueryRequest queryRequest = queryRequest(query().fetch("details").setMaxRows(50)); queryRequest.initTransIfRequired(); queryRequest.endTransIfRequired(); DLoadContext graphContext = (DLoadContext) queryRequest.getGraphContext(); DLoadManyContext details = graphContext.getManyContext("details", many); - assertThat(details.firstBatchSize).isEqualTo(100); - assertThat(details.secondaryBatchSize).isEqualTo(100); + assertThat(details.batchSize).isEqualTo(100); } } diff --git a/ebean-core/src/test/java/io/ebeaninternal/server/querydefn/OrmQueryDetailParserTest.java b/ebean-core/src/test/java/io/ebeaninternal/server/querydefn/OrmQueryDetailParserTest.java index 6f27685a2..f7f829118 100644 --- a/ebean-core/src/test/java/io/ebeaninternal/server/querydefn/OrmQueryDetailParserTest.java +++ b/ebean-core/src/test/java/io/ebeaninternal/server/querydefn/OrmQueryDetailParserTest.java @@ -92,7 +92,7 @@ public class OrmQueryDetailParserTest extends BaseTestCase { OrmQueryProperties chunk = detail.getChunk("customer", false); assertThat(chunk.getPath()).isEqualTo("customer"); assertThat(chunk.getIncluded()).contains("id", "name", "email"); - assertThat(chunk.isQueryFetch()).isTrue(); + //FIXME: assertThat(chunk.isQueryFetch()).isTrue(); } @Test @@ -110,7 +110,7 @@ public class OrmQueryDetailParserTest extends BaseTestCase { OrmQueryProperties chunk = detail.getChunk("customer", false); assertThat(chunk.getPath()).isEqualTo("customer"); assertThat(chunk.getIncluded()).contains("id", "name", "email"); - assertThat(chunk.isQueryFetch()).isTrue(); + //FIXME: assertThat(chunk.isQueryFetch()).isTrue(); } } diff --git a/ebean-core/src/test/java/io/ebeaninternal/server/querydefn/OrmQueryPropertiesParserTest.java b/ebean-core/src/test/java/io/ebeaninternal/server/querydefn/OrmQueryPropertiesParserTest.java index f15cffc38..09c026175 100644 --- a/ebean-core/src/test/java/io/ebeaninternal/server/querydefn/OrmQueryPropertiesParserTest.java +++ b/ebean-core/src/test/java/io/ebeaninternal/server/querydefn/OrmQueryPropertiesParserTest.java @@ -15,7 +15,7 @@ public class OrmQueryPropertiesParserTest { } @Test - public void when_empty() throws Exception { + public void when_empty() { OrmQueryPropertiesParser.Response res = OrmQueryPropertiesParser.parse(""); assertAllDefaults(res); @@ -23,7 +23,7 @@ public class OrmQueryPropertiesParserTest { } @Test - public void when_hasStar() throws Exception { + public void when_hasStar() { OrmQueryPropertiesParser.Response res = OrmQueryPropertiesParser.parse("*"); assertAllDefaults(res); @@ -31,7 +31,7 @@ public class OrmQueryPropertiesParserTest { } @Test - public void when_hasCache() throws Exception { + public void when_hasCache() { OrmQueryPropertiesParser.Response res = OrmQueryPropertiesParser.parse("+cache"); assertThat(res.cache).isTrue(); @@ -39,7 +39,7 @@ public class OrmQueryPropertiesParserTest { } @Test - public void when_hasCache_first() throws Exception { + public void when_hasCache_first() { OrmQueryPropertiesParser.Response res = OrmQueryPropertiesParser.parse("+cache,id"); assertThat(res.cache).isTrue(); @@ -47,7 +47,7 @@ public class OrmQueryPropertiesParserTest { } @Test - public void when_hasCache_last() throws Exception { + public void when_hasCache_last() { OrmQueryPropertiesParser.Response res = OrmQueryPropertiesParser.parse("name,+cache"); assertThat(res.cache).isTrue(); @@ -55,7 +55,7 @@ public class OrmQueryPropertiesParserTest { } @Test - public void when_hasCache_middle() throws Exception { + public void when_hasCache_middle() { OrmQueryPropertiesParser.Response res = OrmQueryPropertiesParser.parse("name,+cache, id"); assertThat(res.cache).isTrue(); @@ -63,7 +63,7 @@ public class OrmQueryPropertiesParserTest { } @Test - public void when_hasReadOnly() throws Exception { + public void when_hasReadOnly() { OrmQueryPropertiesParser.Response res = OrmQueryPropertiesParser.parse("+readonly"); assertThat(res.readOnly).isTrue(); @@ -71,61 +71,63 @@ public class OrmQueryPropertiesParserTest { } @Test - public void when_hasLazy() throws Exception { - + public void when_hasLazy() { OrmQueryPropertiesParser.Response res = OrmQueryPropertiesParser.parse("+lazy"); - assertThat(res.fetchConfig.getLazyBatchSize()).isEqualTo(0); + //FIXME: assertThat(res.fetchConfig.getBatchSize()).isEqualTo(0); assertThat(res.included).isNull(); } @Test - public void when_hasLazyValue() throws Exception { + public void when_hasLazyValue() { OrmQueryPropertiesParser.Response res = OrmQueryPropertiesParser.parse("+lazy(20)"); - assertThat(res.fetchConfig.getLazyBatchSize()).isEqualTo(20); + assertThat(res.fetchConfig.getBatchSize()).isEqualTo(20); assertThat(res.included).isNull(); } @Test - public void when_hasLazyValue_last() throws Exception { + public void when_hasLazyValue_last() { OrmQueryPropertiesParser.Response res = OrmQueryPropertiesParser.parse("name,+lazy(20)"); - assertThat(res.fetchConfig.getLazyBatchSize()).isEqualTo(20); + assertThat(res.fetchConfig.getBatchSize()).isEqualTo(20); assertThat(res.included).containsExactly("name"); } @Test - public void when_hasLazyValue_first() throws Exception { + public void when_hasLazyValue_first() { OrmQueryPropertiesParser.Response res = OrmQueryPropertiesParser.parse("+lazy(20),id,name"); - assertThat(res.fetchConfig.getLazyBatchSize()).isEqualTo(20); + assertThat(res.fetchConfig.getBatchSize()).isEqualTo(20); assertThat(res.included).containsExactly("id", "name"); } @Test - public void when_allProperties() throws Exception { - + public void when_allProperties() { OrmQueryPropertiesParser.Response res = OrmQueryPropertiesParser.parse("+query(4),+lazy(5)"); - assertThat(res.fetchConfig.getLazyBatchSize()).isEqualTo(5); + assertThat(res.fetchConfig.getBatchSize()).isEqualTo(4); assertThat(res.included).isNull(); } @Test - public void when_everything_set() throws Exception { + public void when_everything_set() { - OrmQueryPropertiesParser.Response res = OrmQueryPropertiesParser.parse("id, name +readonly +lazy(20) +query(30) +cache"); - assertThat(res.fetchConfig.getLazyBatchSize()).isEqualTo(20); - assertThat(res.fetchConfig.getQueryBatchSize()).isEqualTo(30); + OrmQueryPropertiesParser.Response res = OrmQueryPropertiesParser.parse("id, name, +readonly ,+lazy(20), +query(30) ,+cache"); + assertThat(res.included).containsExactly("id", "name"); + assertThat(res.fetchConfig.getBatchSize()).isEqualTo(30); assertThat(res.readOnly).isTrue(); assertThat(res.cache).isTrue(); - assertThat(res.included).containsExactly("id", "name"); + } + + @Test + public void when_formula() { + + OrmQueryPropertiesParser.Response res = OrmQueryPropertiesParser.parse("a,MD5(id::text) as b,c"); + assertThat(res.included).containsExactly("a", "MD5(id::text) as b", "c"); } private void assertAllDefaults(OrmQueryPropertiesParser.Response res) { assertThat(res.cache).isFalse(); assertThat(res.readOnly).isFalse(); - assertThat(res.fetchConfig.getLazyBatchSize()).isEqualTo(-1); - assertThat(res.fetchConfig.getQueryBatchSize()).isEqualTo(-1); assertThat(res.included).isNull(); } } diff --git a/ebean-core/src/test/java/io/ebeaninternal/server/querydefn/OrmQueryPropertiesTest.java b/ebean-core/src/test/java/io/ebeaninternal/server/querydefn/OrmQueryPropertiesTest.java index 547ea5966..b2ed90fcb 100644 --- a/ebean-core/src/test/java/io/ebeaninternal/server/querydefn/OrmQueryPropertiesTest.java +++ b/ebean-core/src/test/java/io/ebeaninternal/server/querydefn/OrmQueryPropertiesTest.java @@ -10,11 +10,11 @@ public class OrmQueryPropertiesTest { String append(String prefix, OrmQueryProperties p1) { StringBuilder sb = new StringBuilder(); - p1.append(prefix, sb); + p1.asStringDebug(prefix, sb); return sb.toString(); } - @Test(expected = IllegalArgumentException.class) + @Test(expected = NullPointerException.class) public void construct_with_propertySet_when_null() { new OrmQueryProperties(null, (LinkedHashSet) null); } @@ -68,8 +68,8 @@ public class OrmQueryPropertiesTest { @Test public void append_when_somePropertiesWithOptions() { - OrmQueryProperties p1 = new OrmQueryProperties(null, "id,name +cache"); - assertThat(append("select ", p1)).isEqualTo("select (id,name +cache)"); + OrmQueryProperties p1 = new OrmQueryProperties(null, "id,name,+cache"); + //FIXME: assertThat(append("select ", p1)).isEqualTo("select (id,name,+cache)"); } @Test @@ -82,8 +82,8 @@ public class OrmQueryPropertiesTest { @Test public void append_when_path_and_somePropertiesWithOptions() { - OrmQueryProperties p1 = new OrmQueryProperties("customer", "id,name +cache"); - assertThat(append("fetch ", p1)).isEqualTo("fetch customer (id,name +cache)"); + OrmQueryProperties p1 = new OrmQueryProperties("customer", "id,name,+cache"); + //FIXME: assertThat(append("fetch ", p1)).isEqualTo("fetch customer (id,name,+cache)"); } } diff --git a/ebean-core/src/test/java/org/tests/batchload/TestLazyLoadEmptyCollection.java b/ebean-core/src/test/java/org/tests/batchload/TestLazyLoadEmptyCollection.java index 4a7989482..f58b99fb2 100644 --- a/ebean-core/src/test/java/org/tests/batchload/TestLazyLoadEmptyCollection.java +++ b/ebean-core/src/test/java/org/tests/batchload/TestLazyLoadEmptyCollection.java @@ -24,7 +24,7 @@ public class TestLazyLoadEmptyCollection extends TransactionalTestCase { Ebean.save(c); List list = Ebean.find(Customer.class) - .fetch("contacts", new FetchConfig().query(0)) + .fetch("contacts", new FetchConfig().query()) .fetch("contacts.notes", new FetchConfig().query(100)) .findList(); diff --git a/ebean-core/src/test/java/org/tests/batchload/TestSecondaryQueries.java b/ebean-core/src/test/java/org/tests/batchload/TestSecondaryQueries.java index 35dee89b1..4ae024159 100644 --- a/ebean-core/src/test/java/org/tests/batchload/TestSecondaryQueries.java +++ b/ebean-core/src/test/java/org/tests/batchload/TestSecondaryQueries.java @@ -105,7 +105,7 @@ public class TestSecondaryQueries extends TransactionalTestCase { Query query = Ebean.find(Customer.class) .select("name") - .fetch("contacts", "+query") + .fetchQuery("contacts") .setId(custId); LoggedSqlCollector.start(); From b56d68dac7f6d1b304cdd6c1443b97615ccd3253 Mon Sep 17 00:00:00 2001 From: rob bygrave Date: Fri, 12 Feb 2021 22:17:04 +1300 Subject: [PATCH 088/447] #2157 - ManyToMany mapping to itself results in broken generated SQL DDL when not defining @JoinTable. --- .../deploy/parse/AnnotationAssocManys.java | 13 +++--- .../tests/model/interfaces/SelfManyMany.java | 40 +++++++++++++++++++ .../tests/model/interfaces/TestSelfMany.java | 15 +++++++ 3 files changed, 63 insertions(+), 5 deletions(-) create mode 100644 ebean-core/src/test/java/org/tests/model/interfaces/SelfManyMany.java create mode 100644 ebean-core/src/test/java/org/tests/model/interfaces/TestSelfMany.java diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/deploy/parse/AnnotationAssocManys.java b/ebean-core/src/main/java/io/ebeaninternal/server/deploy/parse/AnnotationAssocManys.java index 91c949a0f..b3346562b 100644 --- a/ebean-core/src/main/java/io/ebeaninternal/server/deploy/parse/AnnotationAssocManys.java +++ b/ebean-core/src/main/java/io/ebeaninternal/server/deploy/parse/AnnotationAssocManys.java @@ -5,7 +5,6 @@ import io.ebean.annotation.FetchPreference; import io.ebean.annotation.HistoryExclude; import io.ebean.annotation.Where; import io.ebean.bean.BeanCollection.ModifyListenMode; -import io.ebean.config.BeanNotRegisteredException; import io.ebean.config.NamingConvention; import io.ebean.config.TableName; import io.ebean.core.type.ScalarType; @@ -140,15 +139,15 @@ class AnnotationAssocManys extends AnnotationAssoc { JoinTable joinTable = get(prop, JoinTable.class); if (joinTable != null) { if (prop.isManyToMany()) { - // expected this readJoinTable(joinTable, prop); - } else { // OneToMany with @JoinTable prop.setO2mJoinTable(); readJoinTable(joinTable, prop); manyToManyDefaultJoins(prop); } + } else if (prop.isManyToMany()) { + checkSelfManyToMany(prop); } if (prop.getMappedBy() != null) { @@ -181,6 +180,12 @@ class AnnotationAssocManys extends AnnotationAssoc { } } + private void checkSelfManyToMany(DeployBeanPropertyAssocMany prop) { + if (prop.getTargetType().equals(descriptor.getBeanType())) { + throw new IllegalStateException("@ManyToMany mapping for " + prop.getFullBeanName() + " requires explicit @JoinTable with joinColumns & inverseJoinColumns. Refer issue #2157"); + } + } + @SuppressWarnings("unchecked") private void readElementCollection(DeployBeanPropertyAssocMany prop, ElementCollection elementCollection) { @@ -430,7 +435,6 @@ class AnnotationAssocManys extends AnnotationAssoc { } private void readToMany(ManyToMany propAnn, DeployBeanPropertyAssocMany manyProp) { - manyProp.setMappedBy(propAnn.mappedBy()); manyProp.setFetchType(propAnn.fetch()); setCascadeTypes(propAnn.cascade(), manyProp.getCascadeInfo()); @@ -442,7 +446,6 @@ class AnnotationAssocManys extends AnnotationAssoc { } private void readToOne(OneToMany propAnn, DeployBeanPropertyAssocMany manyProp) { - manyProp.setMappedBy(propAnn.mappedBy()); manyProp.setFetchType(propAnn.fetch()); setCascadeTypes(propAnn.cascade(), manyProp.getCascadeInfo()); diff --git a/ebean-core/src/test/java/org/tests/model/interfaces/SelfManyMany.java b/ebean-core/src/test/java/org/tests/model/interfaces/SelfManyMany.java new file mode 100644 index 000000000..6cfc52193 --- /dev/null +++ b/ebean-core/src/test/java/org/tests/model/interfaces/SelfManyMany.java @@ -0,0 +1,40 @@ +package org.tests.model.interfaces; + +import javax.persistence.Entity; +import javax.persistence.Id; +import javax.persistence.JoinColumn; +import javax.persistence.JoinTable; +import javax.persistence.ManyToMany; +import java.util.List; + +@Entity +public class SelfManyMany { + + @Id + private long id; + + private final String name; + + @ManyToMany + // requires explicit @JoinTable + @JoinTable(name = "self_many_bridge", + joinColumns = @JoinColumn(name = "self_1_id"), + inverseJoinColumns = @JoinColumn(name = "self_2_id")) + private List related; + + public SelfManyMany(String name) { + this.name = name; + } + + public long getId() { + return id; + } + + public String getName() { + return name; + } + + public List getRelated() { + return related; + } +} diff --git a/ebean-core/src/test/java/org/tests/model/interfaces/TestSelfMany.java b/ebean-core/src/test/java/org/tests/model/interfaces/TestSelfMany.java new file mode 100644 index 000000000..e12c47cfd --- /dev/null +++ b/ebean-core/src/test/java/org/tests/model/interfaces/TestSelfMany.java @@ -0,0 +1,15 @@ +package org.tests.model.interfaces; + +import io.ebean.BaseTestCase; +import io.ebean.DB; +import org.junit.Test; + +public class TestSelfMany extends BaseTestCase { + + @Test + public void self_manyToMany() { + + SelfManyMany m = new SelfManyMany("1"); + DB.save(m); + } +} From 8e59e729836b30b800388e872e1ab5bd9febe28b Mon Sep 17 00:00:00 2001 From: rob bygrave Date: Fri, 12 Feb 2021 22:27:34 +1300 Subject: [PATCH 089/447] [maven-release-plugin] prepare release ebean-parent-12.6.7 --- ebean-api/pom.xml | 2 +- ebean-autotune/pom.xml | 6 +++--- ebean-bom/pom.xml | 30 +++++++++++++++--------------- ebean-core-type/pom.xml | 4 ++-- ebean-core/pom.xml | 10 +++++----- ebean-ddl-generator/pom.xml | 6 +++--- ebean-externalmapping-api/pom.xml | 2 +- ebean-externalmapping-xml/pom.xml | 10 +++++----- ebean-postgis/pom.xml | 6 +++--- ebean-querybean/pom.xml | 10 +++++----- ebean-redis/pom.xml | 12 ++++++------ ebean-test/pom.xml | 8 ++++---- ebean/pom.xml | 12 ++++++------ kotlin-querybean-generator/pom.xml | 8 ++++---- pom.xml | 4 ++-- querybean-generator/pom.xml | 2 +- 16 files changed, 66 insertions(+), 66 deletions(-) diff --git a/ebean-api/pom.xml b/ebean-api/pom.xml index 4150e1cb3..c8deead0b 100644 --- a/ebean-api/pom.xml +++ b/ebean-api/pom.xml @@ -4,7 +4,7 @@ ebean-parent io.ebean - 12.6.7-SNAPSHOT + 12.6.7 ebean api diff --git a/ebean-autotune/pom.xml b/ebean-autotune/pom.xml index 5892fda8e..a395c314f 100644 --- a/ebean-autotune/pom.xml +++ b/ebean-autotune/pom.xml @@ -4,7 +4,7 @@ ebean-parent io.ebean - 12.6.7-SNAPSHOT + 12.6.7 @@ -14,7 +14,7 @@ scm:git:git@github.com:ebean-orm/ebean.git - ebean-parent-12.6.5 + ebean-parent-12.6.7 ebean autotune @@ -26,7 +26,7 @@ io.ebean ebean-core - 12.6.7-SNAPSHOT + 12.6.7 provided diff --git a/ebean-bom/pom.xml b/ebean-bom/pom.xml index b3b611006..62659400e 100644 --- a/ebean-bom/pom.xml +++ b/ebean-bom/pom.xml @@ -4,7 +4,7 @@ ebean-parent io.ebean - 12.6.7-SNAPSHOT + 12.6.7 ebean bom @@ -81,88 +81,88 @@ io.ebean ebean - 12.6.7-SNAPSHOT + 12.6.7 io.ebean ebean-api - 12.6.7-SNAPSHOT + 12.6.7 io.ebean ebean-core - 12.6.7-SNAPSHOT + 12.6.7 io.ebean ebean-core-type - 12.6.7-SNAPSHOT + 12.6.7 io.ebean ebean-ddl-generator - 12.6.7-SNAPSHOT + 12.6.7 io.ebean ebean-externalmapping-api - 12.6.7-SNAPSHOT + 12.6.7 io.ebean ebean-externalmapping-xml - 12.6.7-SNAPSHOT + 12.6.7 io.ebean ebean-autotune - 12.6.7-SNAPSHOT + 12.6.7 io.ebean ebean-querybean - 12.6.7-SNAPSHOT + 12.6.7 io.ebean querybean-generator - 12.6.7-SNAPSHOT + 12.6.7 provided io.ebean kotlin-querybean-generator - 12.6.7-SNAPSHOT + 12.6.7 provided io.ebean ebean-test - 12.6.7-SNAPSHOT + 12.6.7 test io.ebean ebean-postgis - 12.6.7-SNAPSHOT + 12.6.7 io.ebean ebean-redis - 12.6.7-SNAPSHOT + 12.6.7 diff --git a/ebean-core-type/pom.xml b/ebean-core-type/pom.xml index 18e8f5bb8..a71c04bf9 100644 --- a/ebean-core-type/pom.xml +++ b/ebean-core-type/pom.xml @@ -4,7 +4,7 @@ ebean-parent io.ebean - 12.6.7-SNAPSHOT + 12.6.7 ebean-core-type @@ -21,7 +21,7 @@ io.ebean ebean-api - 12.6.7-SNAPSHOT + 12.6.7 diff --git a/ebean-core/pom.xml b/ebean-core/pom.xml index 1c5a407b8..364fdf595 100644 --- a/ebean-core/pom.xml +++ b/ebean-core/pom.xml @@ -3,7 +3,7 @@ ebean-parent io.ebean - 12.6.7-SNAPSHOT + 12.6.7 ebean-core @@ -15,7 +15,7 @@ scm:git:git@github.com:ebean-orm/ebean.git - ebean-parent-12.6.5 + ebean-parent-12.6.7 @@ -92,19 +92,19 @@ io.ebean ebean-api - 12.6.7-SNAPSHOT + 12.6.7 io.ebean ebean-core-type - 12.6.7-SNAPSHOT + 12.6.7 io.ebean ebean-externalmapping-api - 12.6.7-SNAPSHOT + 12.6.7 diff --git a/ebean-ddl-generator/pom.xml b/ebean-ddl-generator/pom.xml index c6039a3ca..944e11a68 100644 --- a/ebean-ddl-generator/pom.xml +++ b/ebean-ddl-generator/pom.xml @@ -4,7 +4,7 @@ ebean-parent io.ebean - 12.6.7-SNAPSHOT + 12.6.7 ebean ddl generation @@ -29,14 +29,14 @@ io.ebean ebean-core-type - 12.6.7-SNAPSHOT + 12.6.7 provided io.ebean ebean-core - 12.6.7-SNAPSHOT + 12.6.7 provided diff --git a/ebean-externalmapping-api/pom.xml b/ebean-externalmapping-api/pom.xml index b7229936c..328c54828 100644 --- a/ebean-externalmapping-api/pom.xml +++ b/ebean-externalmapping-api/pom.xml @@ -4,7 +4,7 @@ ebean-parent io.ebean - 12.6.7-SNAPSHOT + 12.6.7 ebean external mapping api diff --git a/ebean-externalmapping-xml/pom.xml b/ebean-externalmapping-xml/pom.xml index 7364bff24..e39745b97 100644 --- a/ebean-externalmapping-xml/pom.xml +++ b/ebean-externalmapping-xml/pom.xml @@ -4,7 +4,7 @@ ebean-parent io.ebean - 12.6.7-SNAPSHOT + 12.6.7 @@ -14,7 +14,7 @@ scm:git:git@github.com:ebean-orm/ebean.git - ebean-parent-12.6.5 + ebean-parent-12.6.7 ebean external mapping xml @@ -33,7 +33,7 @@ io.ebean ebean-externalmapping-api - 12.6.7-SNAPSHOT + 12.6.7 @@ -59,14 +59,14 @@ io.ebean ebean-core - 12.6.7-SNAPSHOT + 12.6.7 test io.ebean ebean-ddl-generator - 12.6.7-SNAPSHOT + 12.6.7 test diff --git a/ebean-postgis/pom.xml b/ebean-postgis/pom.xml index 1240f27fe..4220db482 100644 --- a/ebean-postgis/pom.xml +++ b/ebean-postgis/pom.xml @@ -4,7 +4,7 @@ ebean-parent io.ebean - 12.6.7-SNAPSHOT + 12.6.7 ebean postgis @@ -24,7 +24,7 @@ io.ebean ebean-core - 12.6.7-SNAPSHOT + 12.6.7 provided @@ -75,7 +75,7 @@ io.ebean ebean-test - 12.6.7-SNAPSHOT + 12.6.7 test diff --git a/ebean-querybean/pom.xml b/ebean-querybean/pom.xml index 3cd58500d..0c5680377 100644 --- a/ebean-querybean/pom.xml +++ b/ebean-querybean/pom.xml @@ -4,7 +4,7 @@ ebean-parent io.ebean - 12.6.7-SNAPSHOT + 12.6.7 @@ -14,7 +14,7 @@ scm:git:git@github.com:ebean-orm/ebean.git - ebean-parent-12.6.5 + ebean-parent-12.6.7 ebean querybean @@ -27,7 +27,7 @@ io.ebean ebean-core - 12.6.7-SNAPSHOT + 12.6.7 provided @@ -67,14 +67,14 @@ io.ebean ebean-ddl-generator - 12.6.7-SNAPSHOT + 12.6.7 test io.ebean querybean-generator - 12.6.7-SNAPSHOT + 12.6.7 test diff --git a/ebean-redis/pom.xml b/ebean-redis/pom.xml index 35d45e38a..f61e43f24 100644 --- a/ebean-redis/pom.xml +++ b/ebean-redis/pom.xml @@ -4,7 +4,7 @@ ebean-parent io.ebean - 12.6.7-SNAPSHOT + 12.6.7 ebean-redis @@ -22,35 +22,35 @@ io.ebean ebean-api - 12.6.7-SNAPSHOT + 12.6.7 provided io.ebean ebean-core - 12.6.7-SNAPSHOT + 12.6.7 provided io.ebean ebean-querybean - 12.6.7-SNAPSHOT + 12.6.7 test io.ebean querybean-generator - 12.6.7-SNAPSHOT + 12.6.7 test io.ebean ebean-test - 12.6.7-SNAPSHOT + 12.6.7 test diff --git a/ebean-test/pom.xml b/ebean-test/pom.xml index 0c3632dd5..228fc07be 100644 --- a/ebean-test/pom.xml +++ b/ebean-test/pom.xml @@ -4,7 +4,7 @@ ebean-parent io.ebean - 12.6.7-SNAPSHOT + 12.6.7 @@ -14,7 +14,7 @@ scm:git:git@github.com:ebean-orm/ebean.git - ebean-parent-12.6.5 + ebean-parent-12.6.7 ebean test @@ -43,14 +43,14 @@ io.ebean ebean-core - 12.6.7-SNAPSHOT + 12.6.7 provided io.ebean ebean-ddl-generator - 12.6.7-SNAPSHOT + 12.6.7 diff --git a/ebean/pom.xml b/ebean/pom.xml index 5732d2910..a90702613 100644 --- a/ebean/pom.xml +++ b/ebean/pom.xml @@ -4,7 +4,7 @@ ebean-parent io.ebean - 12.6.7-SNAPSHOT + 12.6.7 ebean composite @@ -22,34 +22,34 @@ io.ebean ebean-api - 12.6.7-SNAPSHOT + 12.6.7 io.ebean ebean-core - 12.6.7-SNAPSHOT + 12.6.7 io.ebean ebean-querybean - 12.6.7-SNAPSHOT + 12.6.7 io.ebean ebean-ddl-generator - 12.6.7-SNAPSHOT + 12.6.7 io.ebean ebean-autotune - 12.6.7-SNAPSHOT + 12.6.7 diff --git a/kotlin-querybean-generator/pom.xml b/kotlin-querybean-generator/pom.xml index 5d6336d29..ff0e16f82 100644 --- a/kotlin-querybean-generator/pom.xml +++ b/kotlin-querybean-generator/pom.xml @@ -4,7 +4,7 @@ ebean-parent io.ebean - 12.6.7-SNAPSHOT + 12.6.7 kotlin querybean generator @@ -29,7 +29,7 @@ io.ebean ebean-querybean - 12.6.7-SNAPSHOT + 12.6.7 test @@ -43,7 +43,7 @@ io.ebean ebean-core - 12.6.7-SNAPSHOT + 12.6.7 test @@ -64,7 +64,7 @@ io.ebean ebean-ddl-generator - 12.6.7-SNAPSHOT + 12.6.7 test diff --git a/pom.xml b/pom.xml index c9e885454..6bb866ed8 100644 --- a/pom.xml +++ b/pom.xml @@ -9,7 +9,7 @@ io.ebean ebean-parent - 12.6.7-SNAPSHOT + 12.6.7 pom ebean parent @@ -18,7 +18,7 @@ scm:git:git@github.com:ebean-orm/ebean.git - ebean-parent-12.6.5 + ebean-parent-12.6.7 diff --git a/querybean-generator/pom.xml b/querybean-generator/pom.xml index 52c966bea..59e057294 100644 --- a/querybean-generator/pom.xml +++ b/querybean-generator/pom.xml @@ -4,7 +4,7 @@ ebean-parent io.ebean - 12.6.7-SNAPSHOT + 12.6.7 querybean generator From 5b98d8d9c294cf88a52c0dcb7f724ef268204f14 Mon Sep 17 00:00:00 2001 From: rob bygrave Date: Fri, 12 Feb 2021 22:27:45 +1300 Subject: [PATCH 090/447] [maven-release-plugin] prepare for next development iteration --- ebean-api/pom.xml | 2 +- ebean-autotune/pom.xml | 6 +++--- ebean-bom/pom.xml | 30 +++++++++++++++--------------- ebean-core-type/pom.xml | 4 ++-- ebean-core/pom.xml | 10 +++++----- ebean-ddl-generator/pom.xml | 6 +++--- ebean-externalmapping-api/pom.xml | 2 +- ebean-externalmapping-xml/pom.xml | 10 +++++----- ebean-postgis/pom.xml | 6 +++--- ebean-querybean/pom.xml | 10 +++++----- ebean-redis/pom.xml | 12 ++++++------ ebean-test/pom.xml | 8 ++++---- ebean/pom.xml | 12 ++++++------ kotlin-querybean-generator/pom.xml | 8 ++++---- pom.xml | 4 ++-- querybean-generator/pom.xml | 2 +- 16 files changed, 66 insertions(+), 66 deletions(-) diff --git a/ebean-api/pom.xml b/ebean-api/pom.xml index c8deead0b..c5f36193b 100644 --- a/ebean-api/pom.xml +++ b/ebean-api/pom.xml @@ -4,7 +4,7 @@ ebean-parent io.ebean - 12.6.7 + 12.6.8-SNAPSHOT ebean api diff --git a/ebean-autotune/pom.xml b/ebean-autotune/pom.xml index a395c314f..b50be9b0d 100644 --- a/ebean-autotune/pom.xml +++ b/ebean-autotune/pom.xml @@ -4,7 +4,7 @@ ebean-parent io.ebean - 12.6.7 + 12.6.8-SNAPSHOT @@ -14,7 +14,7 @@ scm:git:git@github.com:ebean-orm/ebean.git - ebean-parent-12.6.7 + ebean-parent-12.6.5 ebean autotune @@ -26,7 +26,7 @@ io.ebean ebean-core - 12.6.7 + 12.6.8-SNAPSHOT provided diff --git a/ebean-bom/pom.xml b/ebean-bom/pom.xml index 62659400e..6a18b3017 100644 --- a/ebean-bom/pom.xml +++ b/ebean-bom/pom.xml @@ -4,7 +4,7 @@ ebean-parent io.ebean - 12.6.7 + 12.6.8-SNAPSHOT ebean bom @@ -81,88 +81,88 @@ io.ebean ebean - 12.6.7 + 12.6.8-SNAPSHOT io.ebean ebean-api - 12.6.7 + 12.6.8-SNAPSHOT io.ebean ebean-core - 12.6.7 + 12.6.8-SNAPSHOT io.ebean ebean-core-type - 12.6.7 + 12.6.8-SNAPSHOT io.ebean ebean-ddl-generator - 12.6.7 + 12.6.8-SNAPSHOT io.ebean ebean-externalmapping-api - 12.6.7 + 12.6.8-SNAPSHOT io.ebean ebean-externalmapping-xml - 12.6.7 + 12.6.8-SNAPSHOT io.ebean ebean-autotune - 12.6.7 + 12.6.8-SNAPSHOT io.ebean ebean-querybean - 12.6.7 + 12.6.8-SNAPSHOT io.ebean querybean-generator - 12.6.7 + 12.6.8-SNAPSHOT provided io.ebean kotlin-querybean-generator - 12.6.7 + 12.6.8-SNAPSHOT provided io.ebean ebean-test - 12.6.7 + 12.6.8-SNAPSHOT test io.ebean ebean-postgis - 12.6.7 + 12.6.8-SNAPSHOT io.ebean ebean-redis - 12.6.7 + 12.6.8-SNAPSHOT diff --git a/ebean-core-type/pom.xml b/ebean-core-type/pom.xml index a71c04bf9..50d80ce17 100644 --- a/ebean-core-type/pom.xml +++ b/ebean-core-type/pom.xml @@ -4,7 +4,7 @@ ebean-parent io.ebean - 12.6.7 + 12.6.8-SNAPSHOT ebean-core-type @@ -21,7 +21,7 @@ io.ebean ebean-api - 12.6.7 + 12.6.8-SNAPSHOT diff --git a/ebean-core/pom.xml b/ebean-core/pom.xml index 364fdf595..082cb17aa 100644 --- a/ebean-core/pom.xml +++ b/ebean-core/pom.xml @@ -3,7 +3,7 @@ ebean-parent io.ebean - 12.6.7 + 12.6.8-SNAPSHOT ebean-core @@ -15,7 +15,7 @@ scm:git:git@github.com:ebean-orm/ebean.git - ebean-parent-12.6.7 + ebean-parent-12.6.5 @@ -92,19 +92,19 @@ io.ebean ebean-api - 12.6.7 + 12.6.8-SNAPSHOT io.ebean ebean-core-type - 12.6.7 + 12.6.8-SNAPSHOT io.ebean ebean-externalmapping-api - 12.6.7 + 12.6.8-SNAPSHOT diff --git a/ebean-ddl-generator/pom.xml b/ebean-ddl-generator/pom.xml index 944e11a68..c343386bf 100644 --- a/ebean-ddl-generator/pom.xml +++ b/ebean-ddl-generator/pom.xml @@ -4,7 +4,7 @@ ebean-parent io.ebean - 12.6.7 + 12.6.8-SNAPSHOT ebean ddl generation @@ -29,14 +29,14 @@ io.ebean ebean-core-type - 12.6.7 + 12.6.8-SNAPSHOT provided io.ebean ebean-core - 12.6.7 + 12.6.8-SNAPSHOT provided diff --git a/ebean-externalmapping-api/pom.xml b/ebean-externalmapping-api/pom.xml index 328c54828..fd23c73a2 100644 --- a/ebean-externalmapping-api/pom.xml +++ b/ebean-externalmapping-api/pom.xml @@ -4,7 +4,7 @@ ebean-parent io.ebean - 12.6.7 + 12.6.8-SNAPSHOT ebean external mapping api diff --git a/ebean-externalmapping-xml/pom.xml b/ebean-externalmapping-xml/pom.xml index e39745b97..806a215df 100644 --- a/ebean-externalmapping-xml/pom.xml +++ b/ebean-externalmapping-xml/pom.xml @@ -4,7 +4,7 @@ ebean-parent io.ebean - 12.6.7 + 12.6.8-SNAPSHOT @@ -14,7 +14,7 @@ scm:git:git@github.com:ebean-orm/ebean.git - ebean-parent-12.6.7 + ebean-parent-12.6.5 ebean external mapping xml @@ -33,7 +33,7 @@ io.ebean ebean-externalmapping-api - 12.6.7 + 12.6.8-SNAPSHOT @@ -59,14 +59,14 @@ io.ebean ebean-core - 12.6.7 + 12.6.8-SNAPSHOT test io.ebean ebean-ddl-generator - 12.6.7 + 12.6.8-SNAPSHOT test diff --git a/ebean-postgis/pom.xml b/ebean-postgis/pom.xml index 4220db482..a6a88a75f 100644 --- a/ebean-postgis/pom.xml +++ b/ebean-postgis/pom.xml @@ -4,7 +4,7 @@ ebean-parent io.ebean - 12.6.7 + 12.6.8-SNAPSHOT ebean postgis @@ -24,7 +24,7 @@ io.ebean ebean-core - 12.6.7 + 12.6.8-SNAPSHOT provided @@ -75,7 +75,7 @@ io.ebean ebean-test - 12.6.7 + 12.6.8-SNAPSHOT test diff --git a/ebean-querybean/pom.xml b/ebean-querybean/pom.xml index 0c5680377..edcd84379 100644 --- a/ebean-querybean/pom.xml +++ b/ebean-querybean/pom.xml @@ -4,7 +4,7 @@ ebean-parent io.ebean - 12.6.7 + 12.6.8-SNAPSHOT @@ -14,7 +14,7 @@ scm:git:git@github.com:ebean-orm/ebean.git - ebean-parent-12.6.7 + ebean-parent-12.6.5 ebean querybean @@ -27,7 +27,7 @@ io.ebean ebean-core - 12.6.7 + 12.6.8-SNAPSHOT provided @@ -67,14 +67,14 @@ io.ebean ebean-ddl-generator - 12.6.7 + 12.6.8-SNAPSHOT test io.ebean querybean-generator - 12.6.7 + 12.6.8-SNAPSHOT test diff --git a/ebean-redis/pom.xml b/ebean-redis/pom.xml index f61e43f24..e76555b30 100644 --- a/ebean-redis/pom.xml +++ b/ebean-redis/pom.xml @@ -4,7 +4,7 @@ ebean-parent io.ebean - 12.6.7 + 12.6.8-SNAPSHOT ebean-redis @@ -22,35 +22,35 @@ io.ebean ebean-api - 12.6.7 + 12.6.8-SNAPSHOT provided io.ebean ebean-core - 12.6.7 + 12.6.8-SNAPSHOT provided io.ebean ebean-querybean - 12.6.7 + 12.6.8-SNAPSHOT test io.ebean querybean-generator - 12.6.7 + 12.6.8-SNAPSHOT test io.ebean ebean-test - 12.6.7 + 12.6.8-SNAPSHOT test diff --git a/ebean-test/pom.xml b/ebean-test/pom.xml index 228fc07be..6809737df 100644 --- a/ebean-test/pom.xml +++ b/ebean-test/pom.xml @@ -4,7 +4,7 @@ ebean-parent io.ebean - 12.6.7 + 12.6.8-SNAPSHOT @@ -14,7 +14,7 @@ scm:git:git@github.com:ebean-orm/ebean.git - ebean-parent-12.6.7 + ebean-parent-12.6.5 ebean test @@ -43,14 +43,14 @@ io.ebean ebean-core - 12.6.7 + 12.6.8-SNAPSHOT provided io.ebean ebean-ddl-generator - 12.6.7 + 12.6.8-SNAPSHOT diff --git a/ebean/pom.xml b/ebean/pom.xml index a90702613..5c0714030 100644 --- a/ebean/pom.xml +++ b/ebean/pom.xml @@ -4,7 +4,7 @@ ebean-parent io.ebean - 12.6.7 + 12.6.8-SNAPSHOT ebean composite @@ -22,34 +22,34 @@ io.ebean ebean-api - 12.6.7 + 12.6.8-SNAPSHOT io.ebean ebean-core - 12.6.7 + 12.6.8-SNAPSHOT io.ebean ebean-querybean - 12.6.7 + 12.6.8-SNAPSHOT io.ebean ebean-ddl-generator - 12.6.7 + 12.6.8-SNAPSHOT io.ebean ebean-autotune - 12.6.7 + 12.6.8-SNAPSHOT diff --git a/kotlin-querybean-generator/pom.xml b/kotlin-querybean-generator/pom.xml index ff0e16f82..7e37844df 100644 --- a/kotlin-querybean-generator/pom.xml +++ b/kotlin-querybean-generator/pom.xml @@ -4,7 +4,7 @@ ebean-parent io.ebean - 12.6.7 + 12.6.8-SNAPSHOT kotlin querybean generator @@ -29,7 +29,7 @@ io.ebean ebean-querybean - 12.6.7 + 12.6.8-SNAPSHOT test @@ -43,7 +43,7 @@ io.ebean ebean-core - 12.6.7 + 12.6.8-SNAPSHOT test @@ -64,7 +64,7 @@ io.ebean ebean-ddl-generator - 12.6.7 + 12.6.8-SNAPSHOT test diff --git a/pom.xml b/pom.xml index 6bb866ed8..6222be793 100644 --- a/pom.xml +++ b/pom.xml @@ -9,7 +9,7 @@ io.ebean ebean-parent - 12.6.7 + 12.6.8-SNAPSHOT pom ebean parent @@ -18,7 +18,7 @@ scm:git:git@github.com:ebean-orm/ebean.git - ebean-parent-12.6.7 + ebean-parent-12.6.5 diff --git a/querybean-generator/pom.xml b/querybean-generator/pom.xml index 59e057294..adee59843 100644 --- a/querybean-generator/pom.xml +++ b/querybean-generator/pom.xml @@ -4,7 +4,7 @@ ebean-parent io.ebean - 12.6.7 + 12.6.8-SNAPSHOT querybean generator From 2073fefc92c18e68d0d7db49cc894d7f06e1ae48 Mon Sep 17 00:00:00 2001 From: rob bygrave Date: Fri, 12 Feb 2021 23:12:32 +1300 Subject: [PATCH 091/447] #2162 - Change ebean artifact such that ebean-ddl-generator is a dependency of ebean-test and ebean-autotune optional --- ebean/pom.xml | 14 -------------- 1 file changed, 14 deletions(-) diff --git a/ebean/pom.xml b/ebean/pom.xml index 5c0714030..9cc0b0a60 100644 --- a/ebean/pom.xml +++ b/ebean/pom.xml @@ -38,20 +38,6 @@ 12.6.8-SNAPSHOT - - - io.ebean - ebean-ddl-generator - 12.6.8-SNAPSHOT - - - - - io.ebean - ebean-autotune - 12.6.8-SNAPSHOT - - From 758f84f573e4d00e2d5ecf2aecfe482c12cd471b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sn=C5=8Dwball?= Date: Fri, 12 Feb 2021 23:56:04 +0100 Subject: [PATCH 092/447] Ignore special kotlin collection types (#2130) Kotlin prefers(emits compiler warnings if not) the built-in types e.g. Set and MutableSet instead of the java.util.* variety. This patch removes the imports for those, so the built-in varieties are used. --- .../generator/SimpleQueryBeanWriter.java | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/kotlin-querybean-generator/src/main/java/io/ebean/querybean/generator/SimpleQueryBeanWriter.java b/kotlin-querybean-generator/src/main/java/io/ebean/querybean/generator/SimpleQueryBeanWriter.java index 8524a59f9..ee21711d2 100644 --- a/kotlin-querybean-generator/src/main/java/io/ebean/querybean/generator/SimpleQueryBeanWriter.java +++ b/kotlin-querybean-generator/src/main/java/io/ebean/querybean/generator/SimpleQueryBeanWriter.java @@ -8,6 +8,9 @@ import java.io.FileWriter; import java.io.IOException; import java.io.Writer; import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collections; +import java.util.HashSet; import java.util.Iterator; import java.util.List; import java.util.Set; @@ -42,6 +45,23 @@ class SimpleQueryBeanWriter { "kotlin.Char" }; + // These are special classes under Kotlin, and are auto-imported, same as + // java.lang under Java + private static final Set kotlinBlackListedImports = Collections.unmodifiableSet( + new HashSet<>( + Arrays.asList( + "java.util.ArrayList", + "java.util.HashMap", + "java.util.HashSet", + "java.util.LinkedHashMap", + "java.util.LinkedHashSet", + "java.util.List", + "java.util.Map", + "java.util.Set" + ) + ) + ); + private final Set importTypes = new TreeSet<>(); private final List properties = new ArrayList<>(); @@ -158,6 +178,7 @@ class SimpleQueryBeanWriter { importTypes.add(kotlinTypes[i]); } } + importTypes.removeAll(kotlinBlackListedImports); } private boolean isEntity() { From 8ac54678562c8783ed673b0ad3f0bc1d27193ed1 Mon Sep 17 00:00:00 2001 From: Rob Bygrave Date: Sat, 13 Feb 2021 11:58:00 +1300 Subject: [PATCH 093/447] Improve internal calculation of orm query plan hash key (Require use of inline hints like +query(50) to be comma delimited with properties) (#2159) * WIP Tidy DefaultOrmQuery planDescription() * WIP Tidy DefaultOrmQuery planDescription() * Refactor OrmQueryPropertiesParser with hints requiring comma delimiting (previously didn't) * Refactor OrmQueryPropertiesParser (reuse inputProperties) and DRawSqlColumnsParser (to return Set) * Refactor OrmQueryPropertiesParser - remove JunkMain * Refactor OrmQueryDetail, OrmQueryProperties - properties --- .../autotune/service/ProfileOriginTest.java | 10 +- .../server/query/SqlTreeBuilder.java | 2 +- .../server/querydefn/DefaultOrmQuery.java | 46 +++--- .../server/querydefn/OrmQueryDetail.java | 15 +- .../server/querydefn/OrmQueryPlanKey.java | 2 +- .../server/querydefn/OrmQueryProperties.java | 85 +++------- .../querydefn/OrmQueryPropertiesParser.java | 147 +++++------------- .../server/rawsql/DRawSqlColumnsParser.java | 7 +- .../server/util/DSelectColumnsParser.java | 11 +- .../java/io/ebean/plugin/BeanTypeTest.java | 2 +- .../OrmQueryPropertiesParserTest.java | 37 +++-- .../querydefn/OrmQueryPropertiesTest.java | 4 +- .../server/util/DSelectColumnsParserTest.java | 16 +- .../org/tests/batchload/TestQueryJoin.java | 2 +- 14 files changed, 137 insertions(+), 249 deletions(-) diff --git a/ebean-autotune/src/test/java/io/ebeaninternal/server/autotune/service/ProfileOriginTest.java b/ebean-autotune/src/test/java/io/ebeaninternal/server/autotune/service/ProfileOriginTest.java index 4bc86f6b4..ec0a09596 100644 --- a/ebean-autotune/src/test/java/io/ebeaninternal/server/autotune/service/ProfileOriginTest.java +++ b/ebean-autotune/src/test/java/io/ebeaninternal/server/autotune/service/ProfileOriginTest.java @@ -30,7 +30,7 @@ public class ProfileOriginTest extends BaseTestCase { OrmQueryDetail detail = po.buildDetail(desc); - assertThat(detail.asString().trim()).isEqualTo("fetch customer (name)"); + assertThat(detail.asStringDebug().trim()).isEqualTo("fetch customer (name)"); } @Test @@ -49,7 +49,7 @@ public class ProfileOriginTest extends BaseTestCase { OrmQueryDetail detail = po.buildDetail(desc); - assertThat(detail.asString()).isEqualTo("select (orderDate) fetch customer (name)"); + assertThat(detail.asStringDebug()).isEqualTo("select (orderDate) fetch customer (name)"); } @Test @@ -67,7 +67,7 @@ public class ProfileOriginTest extends BaseTestCase { OrmQueryDetail detail = po.buildDetail(desc); - assertThat(detail.asString().trim()).isEqualTo("select (orderDate,customer)"); + assertThat(detail.asStringDebug().trim()).isEqualTo("select (orderDate,customer)"); } @Test @@ -90,7 +90,7 @@ public class ProfileOriginTest extends BaseTestCase { OrmQueryDetail detail = po.buildDetail(desc); - assertThat(detail.asString()).isEqualTo("select (orderDate) fetch customer (billingAddress)"); + assertThat(detail.asStringDebug()).isEqualTo("select (orderDate) fetch customer (billingAddress)"); } @@ -119,7 +119,7 @@ public class ProfileOriginTest extends BaseTestCase { po.collectUsageInfo(c); OrmQueryDetail detail = po.buildDetail(desc); - assertThat(detail.asString()).isEqualTo("fetch customer (name,note) fetch customer.billingAddress (line1)"); + assertThat(detail.asStringDebug()).isEqualTo("fetch customer (name,note) fetch customer.billingAddress (line1)"); } private NodeUsageCollector node(String path) { diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/query/SqlTreeBuilder.java b/ebean-core/src/main/java/io/ebeaninternal/server/query/SqlTreeBuilder.java index d9386ed9b..065884b54 100644 --- a/ebean-core/src/main/java/io/ebeaninternal/server/query/SqlTreeBuilder.java +++ b/ebean-core/src/main/java/io/ebeaninternal/server/query/SqlTreeBuilder.java @@ -452,7 +452,7 @@ public final class SqlTreeBuilder { // Also note that this can include transient properties. // This makes sense for transient properties used to // hold sum() count() type values (with SqlSelect) - final Set selectInclude = queryProps.getSelectInclude(); + final Set selectInclude = queryProps.getIncluded(); for (String propName : selectInclude) { if (!propName.isEmpty()) { addProperty(selectProps, desc, queryProps, propName); diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/querydefn/DefaultOrmQuery.java b/ebean-core/src/main/java/io/ebeaninternal/server/querydefn/DefaultOrmQuery.java index 2f73bceb7..364f6ab93 100644 --- a/ebean-core/src/main/java/io/ebeaninternal/server/querydefn/DefaultOrmQuery.java +++ b/ebean-core/src/main/java/io/ebeaninternal/server/querydefn/DefaultOrmQuery.java @@ -1136,81 +1136,81 @@ public class DefaultOrmQuery implements SpiQuery { private String planDescription() { StringBuilder sb = new StringBuilder(300); if (type != null) { - sb.append("t:").append(type.ordinal()); + sb.append(type.ordinal()); } if (useDocStore) { - sb.append(",ds:"); + sb.append("/ds"); } if (beanDescriptor.getDiscValue() != null) { - sb.append(",disc:").append(beanDescriptor.getDiscValue()); + sb.append("/dv").append(beanDescriptor.getDiscValue()); } if (temporalMode != SpiQuery.TemporalMode.CURRENT) { - sb.append(",temp:").append(temporalMode.ordinal()); + sb.append("/tm").append(temporalMode.ordinal()); if (versionsStart != null) { - sb.append(",vb:"); + sb.append("v"); } } if (forUpdate != null) { - sb.append(",forUpd:").append(forUpdate.ordinal()); + sb.append("/fu").append(forUpdate.ordinal()); if (lockType != null) { - sb.append(",lt:").append(lockType.ordinal()); + sb.append("t").append(lockType.ordinal()); } } if (id != null) { - sb.append(",id:"); + sb.append("/id"); } if (manualId) { - sb.append(",manId:"); + sb.append("/md"); } if (distinct) { - sb.append(",dist:"); + sb.append("/dt"); } if (allowLoadErrors) { - sb.append(",allowLoadErrors:"); + sb.append("/ae"); } if (disableLazyLoading) { - sb.append(",disLazy:"); + sb.append("/dl"); } if (baseTable != null) { - sb.append(",baseTable:").append(baseTable); + sb.append("/bt").append(baseTable); } if (rootTableAlias != null) { - sb.append(",root:").append(rootTableAlias); + sb.append("/ra").append(rootTableAlias); } if (orderBy != null) { - sb.append(",orderBy:").append(orderBy.toStringFormat()); + sb.append("/ob").append(orderBy.toStringFormat()); } if (m2mIncludeJoin != null) { - sb.append(",m2m:").append(m2mIncludeJoin.getTable()); + sb.append("/m2").append(m2mIncludeJoin.getTable()); } if (mapKey != null) { - sb.append(",mapKey:").append(mapKey); + sb.append("/mk").append(mapKey); } if (countDistinctOrder != null) { - sb.append(",countDistOrd:").append(countDistinctOrder.name()); + sb.append("/cd").append(countDistinctOrder.name()); } if (detail != null) { - sb.append(" detail["); + sb.append("/d["); detail.queryPlanHash(sb); sb.append("]"); } if (bindParams != null) { - sb.append(" bindParams["); + sb.append("/b["); bindParams.buildQueryPlanHash(sb); sb.append("]"); } if (whereExpressions != null) { - sb.append(" where["); + sb.append("/w["); whereExpressions.queryPlanHash(sb); sb.append("]"); } if (havingExpressions != null) { - sb.append(" having["); + sb.append("/h["); havingExpressions.queryPlanHash(sb); sb.append("]"); } if (updateProperties != null) { - sb.append(" update["); + sb.append("/u["); updateProperties.buildQueryPlanHash(sb); sb.append("]"); } diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/querydefn/OrmQueryDetail.java b/ebean-core/src/main/java/io/ebeaninternal/server/querydefn/OrmQueryDetail.java index 1310b709a..b8837111e 100644 --- a/ebean-core/src/main/java/io/ebeaninternal/server/querydefn/OrmQueryDetail.java +++ b/ebean-core/src/main/java/io/ebeaninternal/server/querydefn/OrmQueryDetail.java @@ -106,25 +106,20 @@ public class OrmQueryDetail implements Serializable { return p1 == null ? p2 == null : p1.isSameByAutoTune(p2); } - @Override - public String toString() { - return asString(); - } - /** * Return the detail in string form. */ - public String asString() { + public String asStringDebug() { StringBuilder sb = new StringBuilder(); if (!baseProps.isEmpty()) { - baseProps.append("select ", sb); + baseProps.asStringDebug("select ", sb); } if (fetchPaths != null) { for (OrmQueryProperties join : fetchPaths.values()) { if (sb.length() > 0) { sb.append(" "); } - join.append("fetch ", sb); + join.asStringDebug("fetch ", sb); } } return sb.toString(); @@ -150,7 +145,7 @@ public class OrmQueryDetail implements Serializable { * Set the base query properties to be empty. */ public void setEmptyBase() { - this.baseProps = new OrmQueryProperties(null, new LinkedHashSet<>()); + this.baseProps = new OrmQueryProperties(null, Collections.emptySet()); } /** @@ -316,7 +311,7 @@ public class OrmQueryDetail implements Serializable { if (addId) { parentProp = new OrmQueryProperties(parentPath, assocOne.getTargetIdProperty()); } else { - parentProp = new OrmQueryProperties(parentPath, new LinkedHashSet<>()); + parentProp = new OrmQueryProperties(parentPath, Collections.emptySet()); } } diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/querydefn/OrmQueryPlanKey.java b/ebean-core/src/main/java/io/ebeaninternal/server/querydefn/OrmQueryPlanKey.java index c083eb3d5..3a9ac8e33 100644 --- a/ebean-core/src/main/java/io/ebeaninternal/server/querydefn/OrmQueryPlanKey.java +++ b/ebean-core/src/main/java/io/ebeaninternal/server/querydefn/OrmQueryPlanKey.java @@ -29,7 +29,7 @@ class OrmQueryPlanKey implements CQueryPlanKey { @Override public CQueryPlanKey withDeleteByIds() { - return new OrmQueryPlanKey(description + ":deleteByIds", 0, 0, null); + return new OrmQueryPlanKey(description + "/deleteByIds", 0, 0, null); } @Override diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/querydefn/OrmQueryProperties.java b/ebean-core/src/main/java/io/ebeaninternal/server/querydefn/OrmQueryProperties.java index 805c3bf68..bbbc425de 100644 --- a/ebean-core/src/main/java/io/ebeaninternal/server/querydefn/OrmQueryProperties.java +++ b/ebean-core/src/main/java/io/ebeaninternal/server/querydefn/OrmQueryProperties.java @@ -30,12 +30,8 @@ public class OrmQueryProperties implements Serializable { private final String parentPath; private final String path; - - private final String rawProperties; - private final String trimmedProperties; - - private final LinkedHashSet included; - + private final String properties; + private final Set included; private final FetchConfig fetchConfig; /** @@ -84,8 +80,7 @@ public class OrmQueryProperties implements Serializable { public OrmQueryProperties(String path) { this.path = path; this.parentPath = SplitName.parent(path); - this.rawProperties = null; - this.trimmedProperties = null; + this.properties = null; this.included = null; this.fetchConfig = DEFAULT_FETCH; } @@ -100,8 +95,7 @@ public class OrmQueryProperties implements Serializable { this.path = path; this.parentPath = SplitName.parent(path); - this.rawProperties = rawProperties; - this.trimmedProperties = response.properties; + this.properties = response.properties; this.included = response.included; this.cache = response.cache; this.readOnly = response.readOnly; @@ -115,39 +109,17 @@ public class OrmQueryProperties implements Serializable { } } - public OrmQueryProperties(String path, LinkedHashSet parsedProperties) { - if (parsedProperties == null) { - throw new IllegalArgumentException("parsedProperties is null"); - } - + public OrmQueryProperties(String path, Set included) { this.path = path; this.parentPath = SplitName.parent(path); // for rawSql parsedProperties can be empty (when only fetching Id property) - this.included = parsedProperties; - this.rawProperties = join(parsedProperties); - this.trimmedProperties = rawProperties; + this.included = included; + this.properties = String.join(",", included); this.cache = false; this.readOnly = false; this.fetchConfig = DEFAULT_FETCH; } - /** - * Join the set of properties into a comma delimited string. - */ - private String join(LinkedHashSet parsedProperties) { - StringBuilder sb = new StringBuilder(50); - boolean first = true; - for (String property : parsedProperties) { - if (first) { - first = false; - } else { - sb.append(","); - } - sb.append(property); - } - return sb.toString(); - } - /** * Copy constructor. */ @@ -155,8 +127,7 @@ public class OrmQueryProperties implements Serializable { this.fetchConfig = sourceFetchConfig; this.parentPath = source.parentPath; this.path = source.path; - this.rawProperties = source.rawProperties; - this.trimmedProperties = source.trimmedProperties; + this.properties = source.properties; this.cache = source.cache; this.readOnly = source.readOnly; this.filterMany = source.filterMany; @@ -240,8 +211,8 @@ public class OrmQueryProperties implements Serializable { @SuppressWarnings("unchecked") public void configureBeanQuery(SpiQuery query) { - if (trimmedProperties != null && !trimmedProperties.isEmpty()) { - query.select(trimmedProperties); + if (properties != null && !properties.isEmpty()) { + query.select(properties); } if (filterMany != null) { @@ -268,7 +239,7 @@ public class OrmQueryProperties implements Serializable { } public boolean hasSelectClause() { - if ("*".equals(trimmedProperties)) { + if ("*".equals(properties)) { // explicitly selected all properties return true; } @@ -280,25 +251,17 @@ public class OrmQueryProperties implements Serializable { * Return true if the properties and configuration are empty. */ public boolean isEmpty() { - return rawProperties == null || rawProperties.isEmpty(); + return properties == null || properties.isEmpty(); } - @Override - public String toString() { - StringBuilder sb = new StringBuilder(40); - append("", sb); - return sb.toString(); - } - - public String append(String prefix, StringBuilder sb) { + public void asStringDebug(String prefix, StringBuilder sb) { sb.append(prefix); if (path != null) { sb.append(path).append(" "); } if (!isEmpty()) { - sb.append("(").append(rawProperties).append(")"); + sb.append("(").append(properties).append(")"); } - return sb.toString(); } boolean isChild(OrmQueryProperties possibleChild) { @@ -319,7 +282,7 @@ public class OrmQueryProperties implements Serializable { * Return the raw properties. */ public String getProperties() { - return rawProperties; + return properties; } /** @@ -350,10 +313,6 @@ public class OrmQueryProperties implements Serializable { includedBeanJoin.add(propertyName); } - public Set getSelectInclude() { - return included; - } - public Set getSelectQueryJoin() { return secondaryQueryJoins; } @@ -373,7 +332,6 @@ public class OrmQueryProperties implements Serializable { } boolean isIncluded(String propName) { - if (includedBeanJoin != null && includedBeanJoin.contains(propName)) { return false; } @@ -474,24 +432,21 @@ public class OrmQueryProperties implements Serializable { * Calculate the query plan hash. */ public void queryPlanHash(StringBuilder builder) { - - builder.append("qpp["); + builder.append("p["); builder.append(path); if (included != null){ - builder.append(" included:").append(included); + builder.append("/i").append(included); } if (secondaryQueryJoins != null) { - builder.append(" secondary:").append(secondaryQueryJoins); + builder.append("/s").append(secondaryQueryJoins); } - if (filterMany != null) { - builder.append(" filterMany["); + builder.append("/f["); filterMany.queryPlanHash(builder); builder.append("]"); } - if (fetchConfig != null) { - builder.append(" config:").append(fetchConfig.hashCode()); + builder.append("/c:").append(fetchConfig.hashCode()); } builder.append("]"); } diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/querydefn/OrmQueryPropertiesParser.java b/ebean-core/src/main/java/io/ebeaninternal/server/querydefn/OrmQueryPropertiesParser.java index 5c03e0a33..9350baf2b 100644 --- a/ebean-core/src/main/java/io/ebeaninternal/server/querydefn/OrmQueryPropertiesParser.java +++ b/ebean-core/src/main/java/io/ebeaninternal/server/querydefn/OrmQueryPropertiesParser.java @@ -3,8 +3,8 @@ package io.ebeaninternal.server.querydefn; import io.ebean.FetchConfig; import io.ebeaninternal.server.util.DSelectColumnsParser; -import java.util.LinkedHashSet; -import java.util.List; +import java.util.Iterator; +import java.util.Set; /** * Parses the path properties string. @@ -22,9 +22,9 @@ class OrmQueryPropertiesParser { final boolean cache; final FetchConfig fetchConfig; final String properties; - final LinkedHashSet included; + final Set included; - Response(boolean readOnly, boolean cache, int queryFetchBatch, int lazyFetchBatch, String properties, LinkedHashSet included) { + Response(boolean readOnly, boolean cache, int queryFetchBatch, int lazyFetchBatch, String properties, Set included) { this.readOnly = readOnly; this.cache = cache; this.properties = properties; @@ -53,9 +53,7 @@ class OrmQueryPropertiesParser { return new OrmQueryPropertiesParser(rawProperties).parse(); } - private String inputProperties; - - private String outputProperties = ""; + private final String inputProperties; private boolean allProperties; private boolean readOnly; private boolean cache; @@ -70,124 +68,61 @@ class OrmQueryPropertiesParser { * Parse the raw string properties input. */ private Response parse() { - if (inputProperties == null || inputProperties.isEmpty()) { return EMPTY; } - int pos = inputProperties.indexOf("+readonly"); - if (pos > -1) { - inputProperties = inputProperties.replace("+readonly", ""); - readOnly = true; - } - pos = inputProperties.indexOf("+cache"); - if (pos > -1) { - inputProperties = inputProperties.replace("+cache", ""); - cache = true; - } - pos = inputProperties.indexOf("+query"); - if (pos > -1) { - queryFetchBatch = parseBatchHint(pos, "+query"); - } - pos = inputProperties.indexOf("+lazy"); - if (pos > -1) { - lazyFetchBatch = parseBatchHint(pos, "+lazy"); - } - - LinkedHashSet included = parseIncluded(); - String properties = (allProperties) ? "*" : outputProperties; - return new Response(readOnly, cache, queryFetchBatch, lazyFetchBatch, properties, included); - } - - /** - * Parse the include separating by comma or semicolon. - */ - private LinkedHashSet parseIncluded() { - - inputProperties = inputProperties.trim(); - if (inputProperties.isEmpty()) { - // default properties - return null; - } if (inputProperties.equals("*")) { // explicit all properties allProperties = true; - return null; + return new Response(readOnly, cache, queryFetchBatch, lazyFetchBatch, "*", null); } - - List res = splitRawSelect(inputProperties); - - StringBuilder sb = new StringBuilder(70); - LinkedHashSet propertySet = new LinkedHashSet<>(res.size() * 2); - - int count = 0; - String temp; - for (String re : res) { - temp = re.trim(); - if (!temp.isEmpty()) { - if (count > 0) { - sb.append(","); - } - sb.append(temp); - propertySet.add(temp); - count++; + boolean hints = false; + Set fields = splitRawSelect(inputProperties); + final Iterator iterator = fields.iterator(); + while (iterator.hasNext()) { + String val = iterator.next(); + if (val.startsWith("+")) { + hints = true; + iterator.remove(); + parseHint(val); + } else if (val.equals("*")) { + allProperties = true; } } - - if (propertySet.isEmpty()) { - // default properties - return null; + String properties = allProperties ? "*" : hints ? String.join(",", fields) : inputProperties; + if (fields.isEmpty()) { + fields = null; } + return new Response(readOnly, cache, queryFetchBatch, lazyFetchBatch, properties, fields); + } - if (propertySet.contains("*")) { - // explicit all properties - allProperties = true; - return null; + private void parseHint(String val) { + if (val.equals("+readonly")) { + readOnly = true; + } else if (val.equals("+cache")) { + cache = true; + } else if (val.startsWith("+query")) { + queryFetchBatch = parseBatch(val); + } else if (val.startsWith("+lazy")) { + lazyFetchBatch = parseBatch(val); } + } - // partial properties - outputProperties = sb.toString(); - return propertySet; + private int parseBatch(String val) { + if (val.endsWith(")")) { + int start = val.lastIndexOf('('); + if (start > 0) { + return Integer.parseInt(val.substring(start + 1, val.length() - 1)); + } + } + return 0; } /** * Split allowing 'dynamic function based properties'. */ - private List splitRawSelect(String inputProperties) { + private Set splitRawSelect(String inputProperties) { return DSelectColumnsParser.parse(inputProperties); } - private int parseBatchHint(int pos, String option) { - - int startPos = pos + option.length(); - int endPos = findEndPos(startPos, inputProperties); - if (endPos == -1) { - inputProperties = inputProperties.replace(option, ""); - return 0; - - } else { - - String batchParam = inputProperties.substring(startPos + 1, endPos); - - if (endPos + 1 >= inputProperties.length()) { - inputProperties = inputProperties.substring(0, pos); - } else { - inputProperties = inputProperties.substring(0, pos) + inputProperties.substring(endPos + 1); - } - return Integer.parseInt(batchParam); - } - } - - private int findEndPos(int pos, String props) { - - if (pos < props.length()) { - if (props.charAt(pos) == '(') { - int endPara = props.indexOf(')', pos + 1); - if (endPara == -1) { - throw new RuntimeException("Error could not find ')' in " + props + " after position " + pos); - } - return endPara; - } - } - return -1; - } } diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/rawsql/DRawSqlColumnsParser.java b/ebean-core/src/main/java/io/ebeaninternal/server/rawsql/DRawSqlColumnsParser.java index 2ee3b354d..74c02badd 100644 --- a/ebean-core/src/main/java/io/ebeaninternal/server/rawsql/DRawSqlColumnsParser.java +++ b/ebean-core/src/main/java/io/ebeaninternal/server/rawsql/DRawSqlColumnsParser.java @@ -6,6 +6,7 @@ import io.ebeaninternal.server.util.DSelectColumnsParser; import javax.persistence.PersistenceException; import java.util.ArrayList; import java.util.List; +import java.util.Set; import java.util.regex.Pattern; /** @@ -28,11 +29,8 @@ final class DRawSqlColumnsParser { } private ColumnMapping parse() { - - List columnList = DSelectColumnsParser.parse(sqlSelect); - + Set columnList = DSelectColumnsParser.parse(sqlSelect); List columns = new ArrayList<>(columnList.size()); - for (String rawColumn : columnList) { columns.add(parseColumn(rawColumn)); } @@ -40,7 +38,6 @@ final class DRawSqlColumnsParser { } private ColumnMapping.Column parseColumn(String colInfo) { - String[] split = COLINFO_SPLIT.split(colInfo); if (split.length > 1) { ArrayList tmp = new ArrayList<>(split.length); diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/util/DSelectColumnsParser.java b/ebean-core/src/main/java/io/ebeaninternal/server/util/DSelectColumnsParser.java index c172f92b2..b4ec33a67 100644 --- a/ebean-core/src/main/java/io/ebeaninternal/server/util/DSelectColumnsParser.java +++ b/ebean-core/src/main/java/io/ebeaninternal/server/util/DSelectColumnsParser.java @@ -1,7 +1,7 @@ package io.ebeaninternal.server.util; -import java.util.ArrayList; -import java.util.List; +import java.util.LinkedHashSet; +import java.util.Set; /** * Splits a select clause into 'logical columns' taking into account functions and quotes. @@ -14,7 +14,7 @@ public final class DSelectColumnsParser { private int pos; - public static List parse(String sqlSelect) { + public static Set parse(String sqlSelect) { return new DSelectColumnsParser(sqlSelect).parse(); } @@ -23,9 +23,8 @@ public final class DSelectColumnsParser { this.end = selectClause.length(); } - private List parse() { - - ArrayList columns = new ArrayList<>(); + private Set parse() { + LinkedHashSet columns = new LinkedHashSet<>(); while (pos <= end) { columns.add(nextColumnInfo()); } diff --git a/ebean-core/src/test/java/io/ebean/plugin/BeanTypeTest.java b/ebean-core/src/test/java/io/ebean/plugin/BeanTypeTest.java index 2b880805a..820e89408 100644 --- a/ebean-core/src/test/java/io/ebean/plugin/BeanTypeTest.java +++ b/ebean-core/src/test/java/io/ebean/plugin/BeanTypeTest.java @@ -177,7 +177,7 @@ public class BeanTypeTest { beanType(Order.class).docStore().applyPath(orderQuery); OrmQueryDetail detail = orderQuery.getDetail(); - assertThat(detail.getChunk("customer", false).getSelectInclude()).containsExactly("id", "name"); + assertThat(detail.getChunk("customer", false).getIncluded()).containsExactly("id", "name"); } @Test(expected = IllegalStateException.class) diff --git a/ebean-core/src/test/java/io/ebeaninternal/server/querydefn/OrmQueryPropertiesParserTest.java b/ebean-core/src/test/java/io/ebeaninternal/server/querydefn/OrmQueryPropertiesParserTest.java index f15cffc38..cc715509d 100644 --- a/ebean-core/src/test/java/io/ebeaninternal/server/querydefn/OrmQueryPropertiesParserTest.java +++ b/ebean-core/src/test/java/io/ebeaninternal/server/querydefn/OrmQueryPropertiesParserTest.java @@ -15,7 +15,7 @@ public class OrmQueryPropertiesParserTest { } @Test - public void when_empty() throws Exception { + public void when_empty() { OrmQueryPropertiesParser.Response res = OrmQueryPropertiesParser.parse(""); assertAllDefaults(res); @@ -23,7 +23,7 @@ public class OrmQueryPropertiesParserTest { } @Test - public void when_hasStar() throws Exception { + public void when_hasStar() { OrmQueryPropertiesParser.Response res = OrmQueryPropertiesParser.parse("*"); assertAllDefaults(res); @@ -31,7 +31,7 @@ public class OrmQueryPropertiesParserTest { } @Test - public void when_hasCache() throws Exception { + public void when_hasCache() { OrmQueryPropertiesParser.Response res = OrmQueryPropertiesParser.parse("+cache"); assertThat(res.cache).isTrue(); @@ -39,7 +39,7 @@ public class OrmQueryPropertiesParserTest { } @Test - public void when_hasCache_first() throws Exception { + public void when_hasCache_first() { OrmQueryPropertiesParser.Response res = OrmQueryPropertiesParser.parse("+cache,id"); assertThat(res.cache).isTrue(); @@ -47,7 +47,7 @@ public class OrmQueryPropertiesParserTest { } @Test - public void when_hasCache_last() throws Exception { + public void when_hasCache_last() { OrmQueryPropertiesParser.Response res = OrmQueryPropertiesParser.parse("name,+cache"); assertThat(res.cache).isTrue(); @@ -55,7 +55,7 @@ public class OrmQueryPropertiesParserTest { } @Test - public void when_hasCache_middle() throws Exception { + public void when_hasCache_middle() { OrmQueryPropertiesParser.Response res = OrmQueryPropertiesParser.parse("name,+cache, id"); assertThat(res.cache).isTrue(); @@ -63,7 +63,7 @@ public class OrmQueryPropertiesParserTest { } @Test - public void when_hasReadOnly() throws Exception { + public void when_hasReadOnly() { OrmQueryPropertiesParser.Response res = OrmQueryPropertiesParser.parse("+readonly"); assertThat(res.readOnly).isTrue(); @@ -71,7 +71,7 @@ public class OrmQueryPropertiesParserTest { } @Test - public void when_hasLazy() throws Exception { + public void when_hasLazy() { OrmQueryPropertiesParser.Response res = OrmQueryPropertiesParser.parse("+lazy"); assertThat(res.fetchConfig.getLazyBatchSize()).isEqualTo(0); @@ -79,7 +79,7 @@ public class OrmQueryPropertiesParserTest { } @Test - public void when_hasLazyValue() throws Exception { + public void when_hasLazyValue() { OrmQueryPropertiesParser.Response res = OrmQueryPropertiesParser.parse("+lazy(20)"); assertThat(res.fetchConfig.getLazyBatchSize()).isEqualTo(20); @@ -87,7 +87,7 @@ public class OrmQueryPropertiesParserTest { } @Test - public void when_hasLazyValue_last() throws Exception { + public void when_hasLazyValue_last() { OrmQueryPropertiesParser.Response res = OrmQueryPropertiesParser.parse("name,+lazy(20)"); assertThat(res.fetchConfig.getLazyBatchSize()).isEqualTo(20); @@ -95,7 +95,7 @@ public class OrmQueryPropertiesParserTest { } @Test - public void when_hasLazyValue_first() throws Exception { + public void when_hasLazyValue_first() { OrmQueryPropertiesParser.Response res = OrmQueryPropertiesParser.parse("+lazy(20),id,name"); assertThat(res.fetchConfig.getLazyBatchSize()).isEqualTo(20); @@ -103,7 +103,7 @@ public class OrmQueryPropertiesParserTest { } @Test - public void when_allProperties() throws Exception { + public void when_allProperties() { OrmQueryPropertiesParser.Response res = OrmQueryPropertiesParser.parse("+query(4),+lazy(5)"); assertThat(res.fetchConfig.getLazyBatchSize()).isEqualTo(5); @@ -111,14 +111,21 @@ public class OrmQueryPropertiesParserTest { } @Test - public void when_everything_set() throws Exception { + public void when_everything_set() { - OrmQueryPropertiesParser.Response res = OrmQueryPropertiesParser.parse("id, name +readonly +lazy(20) +query(30) +cache"); + OrmQueryPropertiesParser.Response res = OrmQueryPropertiesParser.parse("id, name, +readonly ,+lazy(20), +query(30) ,+cache"); + assertThat(res.included).containsExactly("id", "name"); assertThat(res.fetchConfig.getLazyBatchSize()).isEqualTo(20); assertThat(res.fetchConfig.getQueryBatchSize()).isEqualTo(30); assertThat(res.readOnly).isTrue(); assertThat(res.cache).isTrue(); - assertThat(res.included).containsExactly("id", "name"); + } + + @Test + public void when_formula() { + + OrmQueryPropertiesParser.Response res = OrmQueryPropertiesParser.parse("a,MD5(id::text) as b,c"); + assertThat(res.included).containsExactly("a", "MD5(id::text) as b", "c"); } private void assertAllDefaults(OrmQueryPropertiesParser.Response res) { diff --git a/ebean-core/src/test/java/io/ebeaninternal/server/querydefn/OrmQueryPropertiesTest.java b/ebean-core/src/test/java/io/ebeaninternal/server/querydefn/OrmQueryPropertiesTest.java index 547ea5966..196eb09a5 100644 --- a/ebean-core/src/test/java/io/ebeaninternal/server/querydefn/OrmQueryPropertiesTest.java +++ b/ebean-core/src/test/java/io/ebeaninternal/server/querydefn/OrmQueryPropertiesTest.java @@ -10,11 +10,11 @@ public class OrmQueryPropertiesTest { String append(String prefix, OrmQueryProperties p1) { StringBuilder sb = new StringBuilder(); - p1.append(prefix, sb); + p1.asStringDebug(prefix, sb); return sb.toString(); } - @Test(expected = IllegalArgumentException.class) + @Test(expected = NullPointerException.class) public void construct_with_propertySet_when_null() { new OrmQueryProperties(null, (LinkedHashSet) null); } diff --git a/ebean-core/src/test/java/io/ebeaninternal/server/util/DSelectColumnsParserTest.java b/ebean-core/src/test/java/io/ebeaninternal/server/util/DSelectColumnsParserTest.java index 0b30e225c..cc9234925 100644 --- a/ebean-core/src/test/java/io/ebeaninternal/server/util/DSelectColumnsParserTest.java +++ b/ebean-core/src/test/java/io/ebeaninternal/server/util/DSelectColumnsParserTest.java @@ -2,7 +2,7 @@ package io.ebeaninternal.server.util; import org.junit.Test; -import java.util.List; +import java.util.Set; import static org.assertj.core.api.Assertions.assertThat; @@ -11,49 +11,49 @@ public class DSelectColumnsParserTest { @Test public void parse() { - List cols = DSelectColumnsParser.parse("a,MD5(id::text) as b,c"); + Set cols = DSelectColumnsParser.parse("a,MD5(id::text) as b,c"); assertThat(cols).containsExactly("a", "MD5(id::text) as b", "c"); } @Test public void whitespace_is_trimmed() { - List cols = DSelectColumnsParser.parse("a , MD5(id::text) as b , c "); + Set cols = DSelectColumnsParser.parse("a , MD5(id::text) as b , c "); assertThat(cols).containsExactly("a", "MD5(id::text) as b", "c"); } @Test public void nestedFunctions() { - List cols = DSelectColumnsParser.parse("a , concat(id,'sd',inner(foo)) as b , c "); + Set cols = DSelectColumnsParser.parse("a , concat(id,'sd',inner(foo)) as b , c "); assertThat(cols).containsExactly("a", "concat(id,'sd',inner(foo)) as b", "c"); } @Test public void basic() { - List cols = DSelectColumnsParser.parse("name , status , billingAddress "); + Set cols = DSelectColumnsParser.parse("name , status , billingAddress "); assertThat(cols).containsExactly("name", "status", "billingAddress"); } @Test public void basic_noWhitespace() { - List cols = DSelectColumnsParser.parse("a,b,c"); + Set cols = DSelectColumnsParser.parse("a,b,c"); assertThat(cols).containsExactly("a", "b", "c"); } @Test public void formula_noWhitespace() { - List cols = DSelectColumnsParser.parse("a,concat(x,y),c"); + Set cols = DSelectColumnsParser.parse("a,concat(x,y),c"); assertThat(cols).containsExactly("a", "concat(x,y)", "c"); } @Test public void with_logicalCast_andAsAlias() { - List cols = DSelectColumnsParser.parse("name , concat(status,'-end')::String as fullName , billingAddress "); + Set cols = DSelectColumnsParser.parse("name , concat(status,'-end')::String as fullName , billingAddress "); assertThat(cols).containsExactly("name", "concat(status,'-end')::String as fullName", "billingAddress"); } diff --git a/ebean-core/src/test/java/org/tests/batchload/TestQueryJoin.java b/ebean-core/src/test/java/org/tests/batchload/TestQueryJoin.java index 1cbe7fd48..81bac2193 100644 --- a/ebean-core/src/test/java/org/tests/batchload/TestQueryJoin.java +++ b/ebean-core/src/test/java/org/tests/batchload/TestQueryJoin.java @@ -28,7 +28,7 @@ public class TestQueryJoin extends BaseTestCase { Query query = Ebean.find(Order.class).select("status") // .join("details","+query(10)") - .fetch("customer", "+lazy(10) name, status").fetch("customer.contacts").order().asc("id"); + .fetch("customer", "+lazy(10), name, status").fetch("customer.contacts").order().asc("id"); // .join("customer.billingAddress"); List list = query.findList(); From 4092ea307e0fd01c8892674ea6a51821acb9bd2a Mon Sep 17 00:00:00 2001 From: rob bygrave Date: Sat, 13 Feb 2021 12:29:09 +1300 Subject: [PATCH 094/447] Bump pom version to 12.7.1-SNAPSHOT --- ebean-api/pom.xml | 2 +- ebean-autotune/pom.xml | 4 ++-- ebean-bom/pom.xml | 30 +++++++++++++++--------------- ebean-core-type/pom.xml | 4 ++-- ebean-core/pom.xml | 8 ++++---- ebean-ddl-generator/pom.xml | 6 +++--- ebean-externalmapping-api/pom.xml | 2 +- ebean-externalmapping-xml/pom.xml | 8 ++++---- ebean-postgis/pom.xml | 6 +++--- ebean-querybean/pom.xml | 8 ++++---- ebean-redis/pom.xml | 12 ++++++------ ebean-test/pom.xml | 6 +++--- ebean/pom.xml | 8 ++++---- kotlin-querybean-generator/pom.xml | 8 ++++---- pom.xml | 2 +- 15 files changed, 57 insertions(+), 57 deletions(-) diff --git a/ebean-api/pom.xml b/ebean-api/pom.xml index c5f36193b..0d8e67b00 100644 --- a/ebean-api/pom.xml +++ b/ebean-api/pom.xml @@ -4,7 +4,7 @@ ebean-parent io.ebean - 12.6.8-SNAPSHOT + 12.7.1-SNAPSHOT ebean api diff --git a/ebean-autotune/pom.xml b/ebean-autotune/pom.xml index b50be9b0d..7b0dabb3b 100644 --- a/ebean-autotune/pom.xml +++ b/ebean-autotune/pom.xml @@ -4,7 +4,7 @@ ebean-parent io.ebean - 12.6.8-SNAPSHOT + 12.7.1-SNAPSHOT @@ -26,7 +26,7 @@ io.ebean ebean-core - 12.6.8-SNAPSHOT + 12.7.1-SNAPSHOT provided diff --git a/ebean-bom/pom.xml b/ebean-bom/pom.xml index 6a18b3017..c6219cfea 100644 --- a/ebean-bom/pom.xml +++ b/ebean-bom/pom.xml @@ -4,7 +4,7 @@ ebean-parent io.ebean - 12.6.8-SNAPSHOT + 12.7.1-SNAPSHOT ebean bom @@ -81,88 +81,88 @@ io.ebean ebean - 12.6.8-SNAPSHOT + 12.7.1-SNAPSHOT io.ebean ebean-api - 12.6.8-SNAPSHOT + 12.7.1-SNAPSHOT io.ebean ebean-core - 12.6.8-SNAPSHOT + 12.7.1-SNAPSHOT io.ebean ebean-core-type - 12.6.8-SNAPSHOT + 12.7.1-SNAPSHOT io.ebean ebean-ddl-generator - 12.6.8-SNAPSHOT + 12.7.1-SNAPSHOT io.ebean ebean-externalmapping-api - 12.6.8-SNAPSHOT + 12.7.1-SNAPSHOT io.ebean ebean-externalmapping-xml - 12.6.8-SNAPSHOT + 12.7.1-SNAPSHOT io.ebean ebean-autotune - 12.6.8-SNAPSHOT + 12.7.1-SNAPSHOT io.ebean ebean-querybean - 12.6.8-SNAPSHOT + 12.7.1-SNAPSHOT io.ebean querybean-generator - 12.6.8-SNAPSHOT + 12.7.1-SNAPSHOT provided io.ebean kotlin-querybean-generator - 12.6.8-SNAPSHOT + 12.7.1-SNAPSHOT provided io.ebean ebean-test - 12.6.8-SNAPSHOT + 12.7.1-SNAPSHOT test io.ebean ebean-postgis - 12.6.8-SNAPSHOT + 12.7.1-SNAPSHOT io.ebean ebean-redis - 12.6.8-SNAPSHOT + 12.7.1-SNAPSHOT diff --git a/ebean-core-type/pom.xml b/ebean-core-type/pom.xml index 50d80ce17..56aebbb2c 100644 --- a/ebean-core-type/pom.xml +++ b/ebean-core-type/pom.xml @@ -4,7 +4,7 @@ ebean-parent io.ebean - 12.6.8-SNAPSHOT + 12.7.1-SNAPSHOT ebean-core-type @@ -21,7 +21,7 @@ io.ebean ebean-api - 12.6.8-SNAPSHOT + 12.7.1-SNAPSHOT diff --git a/ebean-core/pom.xml b/ebean-core/pom.xml index 082cb17aa..20d9cfe6c 100644 --- a/ebean-core/pom.xml +++ b/ebean-core/pom.xml @@ -3,7 +3,7 @@ ebean-parent io.ebean - 12.6.8-SNAPSHOT + 12.7.1-SNAPSHOT ebean-core @@ -92,19 +92,19 @@ io.ebean ebean-api - 12.6.8-SNAPSHOT + 12.7.1-SNAPSHOT io.ebean ebean-core-type - 12.6.8-SNAPSHOT + 12.7.1-SNAPSHOT io.ebean ebean-externalmapping-api - 12.6.8-SNAPSHOT + 12.7.1-SNAPSHOT diff --git a/ebean-ddl-generator/pom.xml b/ebean-ddl-generator/pom.xml index c343386bf..983902210 100644 --- a/ebean-ddl-generator/pom.xml +++ b/ebean-ddl-generator/pom.xml @@ -4,7 +4,7 @@ ebean-parent io.ebean - 12.6.8-SNAPSHOT + 12.7.1-SNAPSHOT ebean ddl generation @@ -29,14 +29,14 @@ io.ebean ebean-core-type - 12.6.8-SNAPSHOT + 12.7.1-SNAPSHOT provided io.ebean ebean-core - 12.6.8-SNAPSHOT + 12.7.1-SNAPSHOT provided diff --git a/ebean-externalmapping-api/pom.xml b/ebean-externalmapping-api/pom.xml index fd23c73a2..54bb5c7bb 100644 --- a/ebean-externalmapping-api/pom.xml +++ b/ebean-externalmapping-api/pom.xml @@ -4,7 +4,7 @@ ebean-parent io.ebean - 12.6.8-SNAPSHOT + 12.7.1-SNAPSHOT ebean external mapping api diff --git a/ebean-externalmapping-xml/pom.xml b/ebean-externalmapping-xml/pom.xml index 806a215df..98f90d1ac 100644 --- a/ebean-externalmapping-xml/pom.xml +++ b/ebean-externalmapping-xml/pom.xml @@ -4,7 +4,7 @@ ebean-parent io.ebean - 12.6.8-SNAPSHOT + 12.7.1-SNAPSHOT @@ -33,7 +33,7 @@ io.ebean ebean-externalmapping-api - 12.6.8-SNAPSHOT + 12.7.1-SNAPSHOT @@ -59,14 +59,14 @@ io.ebean ebean-core - 12.6.8-SNAPSHOT + 12.7.1-SNAPSHOT test io.ebean ebean-ddl-generator - 12.6.8-SNAPSHOT + 12.7.1-SNAPSHOT test diff --git a/ebean-postgis/pom.xml b/ebean-postgis/pom.xml index a6a88a75f..0e6936d14 100644 --- a/ebean-postgis/pom.xml +++ b/ebean-postgis/pom.xml @@ -4,7 +4,7 @@ ebean-parent io.ebean - 12.6.8-SNAPSHOT + 12.7.1-SNAPSHOT ebean postgis @@ -24,7 +24,7 @@ io.ebean ebean-core - 12.6.8-SNAPSHOT + 12.7.1-SNAPSHOT provided @@ -75,7 +75,7 @@ io.ebean ebean-test - 12.6.8-SNAPSHOT + 12.7.1-SNAPSHOT test diff --git a/ebean-querybean/pom.xml b/ebean-querybean/pom.xml index edcd84379..2fe2570a4 100644 --- a/ebean-querybean/pom.xml +++ b/ebean-querybean/pom.xml @@ -4,7 +4,7 @@ ebean-parent io.ebean - 12.6.8-SNAPSHOT + 12.7.1-SNAPSHOT @@ -27,7 +27,7 @@ io.ebean ebean-core - 12.6.8-SNAPSHOT + 12.7.1-SNAPSHOT provided @@ -67,14 +67,14 @@ io.ebean ebean-ddl-generator - 12.6.8-SNAPSHOT + 12.7.1-SNAPSHOT test io.ebean querybean-generator - 12.6.8-SNAPSHOT + 12.7.1-SNAPSHOT test diff --git a/ebean-redis/pom.xml b/ebean-redis/pom.xml index e76555b30..98186aa7f 100644 --- a/ebean-redis/pom.xml +++ b/ebean-redis/pom.xml @@ -4,7 +4,7 @@ ebean-parent io.ebean - 12.6.8-SNAPSHOT + 12.7.1-SNAPSHOT ebean-redis @@ -22,35 +22,35 @@ io.ebean ebean-api - 12.6.8-SNAPSHOT + 12.7.1-SNAPSHOT provided io.ebean ebean-core - 12.6.8-SNAPSHOT + 12.7.1-SNAPSHOT provided io.ebean ebean-querybean - 12.6.8-SNAPSHOT + 12.7.1-SNAPSHOT test io.ebean querybean-generator - 12.6.8-SNAPSHOT + 12.7.1-SNAPSHOT test io.ebean ebean-test - 12.6.8-SNAPSHOT + 12.7.1-SNAPSHOT test diff --git a/ebean-test/pom.xml b/ebean-test/pom.xml index 6809737df..d880773a8 100644 --- a/ebean-test/pom.xml +++ b/ebean-test/pom.xml @@ -4,7 +4,7 @@ ebean-parent io.ebean - 12.6.8-SNAPSHOT + 12.7.1-SNAPSHOT @@ -43,14 +43,14 @@ io.ebean ebean-core - 12.6.8-SNAPSHOT + 12.7.1-SNAPSHOT provided io.ebean ebean-ddl-generator - 12.6.8-SNAPSHOT + 12.7.1-SNAPSHOT diff --git a/ebean/pom.xml b/ebean/pom.xml index 9cc0b0a60..337b3deba 100644 --- a/ebean/pom.xml +++ b/ebean/pom.xml @@ -4,7 +4,7 @@ ebean-parent io.ebean - 12.6.8-SNAPSHOT + 12.7.1-SNAPSHOT ebean composite @@ -22,20 +22,20 @@ io.ebean ebean-api - 12.6.8-SNAPSHOT + 12.7.1-SNAPSHOT io.ebean ebean-core - 12.6.8-SNAPSHOT + 12.7.1-SNAPSHOT io.ebean ebean-querybean - 12.6.8-SNAPSHOT + 12.7.1-SNAPSHOT diff --git a/kotlin-querybean-generator/pom.xml b/kotlin-querybean-generator/pom.xml index 7e37844df..07993d49e 100644 --- a/kotlin-querybean-generator/pom.xml +++ b/kotlin-querybean-generator/pom.xml @@ -4,7 +4,7 @@ ebean-parent io.ebean - 12.6.8-SNAPSHOT + 12.7.1-SNAPSHOT kotlin querybean generator @@ -29,7 +29,7 @@ io.ebean ebean-querybean - 12.6.8-SNAPSHOT + 12.7.1-SNAPSHOT test @@ -43,7 +43,7 @@ io.ebean ebean-core - 12.6.8-SNAPSHOT + 12.7.1-SNAPSHOT test @@ -64,7 +64,7 @@ io.ebean ebean-ddl-generator - 12.6.8-SNAPSHOT + 12.7.1-SNAPSHOT test diff --git a/pom.xml b/pom.xml index 6222be793..88954f378 100644 --- a/pom.xml +++ b/pom.xml @@ -9,7 +9,7 @@ io.ebean ebean-parent - 12.6.8-SNAPSHOT + 12.7.1-SNAPSHOT pom ebean parent From b2f8b7c711babfaff5798d4901fb6f072973d6ef Mon Sep 17 00:00:00 2001 From: rob bygrave Date: Sat, 13 Feb 2021 12:29:17 +1300 Subject: [PATCH 095/447] Bump pom version to 12.7.1-SNAPSHOT --- querybean-generator/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/querybean-generator/pom.xml b/querybean-generator/pom.xml index adee59843..90140df71 100644 --- a/querybean-generator/pom.xml +++ b/querybean-generator/pom.xml @@ -4,7 +4,7 @@ ebean-parent io.ebean - 12.6.8-SNAPSHOT + 12.7.1-SNAPSHOT querybean generator From 7069d3f6001f496cc64ca36c68000c338d55fcdb Mon Sep 17 00:00:00 2001 From: rob bygrave Date: Sat, 13 Feb 2021 12:31:00 +1300 Subject: [PATCH 096/447] Update tests to use fetchQuery and fetchLazy rather than FetchConfig --- .../core/DefaultServer_createOrmQueryRequestTest.java | 8 ++++---- .../server/loadcontext/DLoadContextTest.java | 4 ++-- .../test/java/org/tests/batchload/TestBasicLazy.java | 2 +- .../org/tests/batchload/TestBatchLazyWithDeleted.java | 2 +- .../test/java/org/tests/batchload/TestLazyJoin2.java | 8 ++++---- .../tests/batchload/TestLazyLoadEmptyCollection.java | 4 ++-- .../org/tests/batchload/TestQueryJoinToAssocOne.java | 6 +++--- .../org/tests/batchload/TestSecondQueryNoRows.java | 2 +- .../java/org/tests/batchload/TestSecondaryQueries.java | 4 ++-- .../org/tests/query/TestQueryFetchJoinWithOrder.java | 4 ++-- .../test/java/org/tests/query/TestQueryFilterMany.java | 2 +- .../tests/query/TestQueryFilterManyOnSecondary.java | 4 ++-- .../org/tests/query/TestQueryFilterManySimple.java | 2 +- .../test/java/org/tests/query/TestQueryFindEach.java | 4 ++-- .../java/org/tests/query/TestQueryFindEachWhile.java | 4 ++-- .../java/org/tests/query/TestQueryJoinBatchSize.java | 2 +- .../java/org/tests/query/TestThreeLevelQueryJoin.java | 10 +++++----- .../tests/query/joins/TestQueryJoinManyNonRoot.java | 2 +- .../tests/query/joins/TestQueryJoinQueryNonRoot.java | 2 +- .../test/java/org/tests/rawsql/TestRawSqlOrmQuery.java | 2 +- .../org/tests/rawsql/TestRawSqlOrmQueryDistinct.java | 2 +- .../java/org/tests/rawsql/TestRawSqlOrmWrapper2.java | 2 +- .../java/org/tests/rawsql/TestRawSqlOrmWrapper3.java | 4 ++-- .../java/org/tests/rawsql/TestRawSqlWithResultSet.java | 2 +- .../org/tests/rawsql/inherit/ParentRawSqlTest.java | 10 +++++----- 25 files changed, 49 insertions(+), 49 deletions(-) diff --git a/ebean-core/src/test/java/io/ebeaninternal/server/core/DefaultServer_createOrmQueryRequestTest.java b/ebean-core/src/test/java/io/ebeaninternal/server/core/DefaultServer_createOrmQueryRequestTest.java index 662bdf311..12c731115 100644 --- a/ebean-core/src/test/java/io/ebeaninternal/server/core/DefaultServer_createOrmQueryRequestTest.java +++ b/ebean-core/src/test/java/io/ebeaninternal/server/core/DefaultServer_createOrmQueryRequestTest.java @@ -99,7 +99,7 @@ public class DefaultServer_createOrmQueryRequestTest extends BaseTestCase { DefaultOrmQuery query1 = (DefaultOrmQuery) Ebean.find(Order.class) .select("status, shipDate") - .fetch("details", "orderQty, unitPrice", new FetchConfig().query()) + .fetchQuery("details", "orderQty, unitPrice") .fetch("details.product", "sku, name"); @@ -145,7 +145,7 @@ public class DefaultServer_createOrmQueryRequestTest extends BaseTestCase { Query query = Ebean.find(Order.class) .select("status, orderDate") .fetch("customer", "name") - .fetch("details", new FetchConfig().query()); + .fetchQuery("details"); OrmQueryRequest queryRequest = queryRequest(query); OrmQueryDetail detail = queryRequest.getQuery().getDetail(); @@ -201,7 +201,7 @@ public class DefaultServer_createOrmQueryRequestTest extends BaseTestCase { Query query = Ebean.find(Order.class) .select("status, orderDate") .fetch("customer", "name") - .fetch("details", new FetchConfig().lazy()) + .fetchLazy("details") .fetch("details.product"); OrmQueryRequest queryRequest = queryRequest(query); @@ -230,7 +230,7 @@ public class DefaultServer_createOrmQueryRequestTest extends BaseTestCase { Query query = Ebean.find(Order.class) .select("status, orderDate") - .fetch("details", new FetchConfig().query()) + .fetchQuery("details") .fetch("details.product") .fetch("customer", "name"); diff --git a/ebean-core/src/test/java/io/ebeaninternal/server/loadcontext/DLoadContextTest.java b/ebean-core/src/test/java/io/ebeaninternal/server/loadcontext/DLoadContextTest.java index 45962f7cd..4bffce7d8 100644 --- a/ebean-core/src/test/java/io/ebeaninternal/server/loadcontext/DLoadContextTest.java +++ b/ebean-core/src/test/java/io/ebeaninternal/server/loadcontext/DLoadContextTest.java @@ -76,14 +76,14 @@ public class DLoadContextTest extends BaseTestCase { @Test public void construct_when_fetchQueryFirst20Lazy5_expect_20_5_batchSize() { - OrmQueryRequest queryRequest = queryRequest(query().fetch("customer", new FetchConfig().queryFirst(20).lazy(5))); + OrmQueryRequest queryRequest = queryRequest(query().fetchQuery("customer")); queryRequest.initTransIfRequired(); queryRequest.endTransIfRequired(); DLoadContext graphContext = (DLoadContext) queryRequest.getGraphContext(); DLoadBeanContext customer = graphContext.getBeanContext("customer"); - assertThat(customer.batchSize).isEqualTo(5); + assertThat(customer.batchSize).isEqualTo(100); } @Test diff --git a/ebean-core/src/test/java/org/tests/batchload/TestBasicLazy.java b/ebean-core/src/test/java/org/tests/batchload/TestBasicLazy.java index 7a146ed80..9656832a1 100644 --- a/ebean-core/src/test/java/org/tests/batchload/TestBasicLazy.java +++ b/ebean-core/src/test/java/org/tests/batchload/TestBasicLazy.java @@ -177,7 +177,7 @@ public class TestBasicLazy extends BaseTestCase { new FetchThread(tg, 2).start(); new FetchThread(tg, 3).start(); - orders = Ebean.find(Order.class).fetch("customer", new FetchConfig().lazy(100)).findList(); + orders = Ebean.find(Order.class).fetchLazy("customer").findList(); Assert.assertTrue(orders.size() >= 4); try { diff --git a/ebean-core/src/test/java/org/tests/batchload/TestBatchLazyWithDeleted.java b/ebean-core/src/test/java/org/tests/batchload/TestBatchLazyWithDeleted.java index 1becb29bc..a91cbbd76 100644 --- a/ebean-core/src/test/java/org/tests/batchload/TestBatchLazyWithDeleted.java +++ b/ebean-core/src/test/java/org/tests/batchload/TestBatchLazyWithDeleted.java @@ -44,7 +44,7 @@ public class TestBatchLazyWithDeleted extends BaseTestCase { Ebean.save(twoC); List list = Ebean.find(UUTwo.class) - .fetch("master", new FetchConfig().lazy(5)) + .fetchLazy("master") .where().startsWith("name", "two-bld-") .order("name") .findList(); diff --git a/ebean-core/src/test/java/org/tests/batchload/TestLazyJoin2.java b/ebean-core/src/test/java/org/tests/batchload/TestLazyJoin2.java index 31d6027a7..b44e173dc 100644 --- a/ebean-core/src/test/java/org/tests/batchload/TestLazyJoin2.java +++ b/ebean-core/src/test/java/org/tests/batchload/TestLazyJoin2.java @@ -23,10 +23,10 @@ public class TestLazyJoin2 extends BaseTestCase { // This will use 3 SQL queries to build this object graph List l0 = Ebean.find(Order.class).select("status, shipDate") - .fetch("details", "orderQty, unitPrice", new FetchConfig().query()) + .fetchQuery("details", "orderQty, unitPrice") .fetch("details.product", "sku, name") - .fetch("customer", "name", new FetchConfig().query(10)) + .fetchQuery("customer", "name") .fetch("customer.contacts", "firstName, lastName, mobile") .fetch("customer.shippingAddress", "line1, city").order().asc("id").findList(); @@ -43,7 +43,7 @@ public class TestLazyJoin2 extends BaseTestCase { List orders = Ebean.find(Order.class) // .select("status") - .fetch("customer", new FetchConfig().query(3).lazy(10)).order().asc("id").findList(); + .fetchQuery("customer").order().asc("id").findList(); // .join("customer.contacts"); // List list = query.findList(); @@ -59,7 +59,7 @@ public class TestLazyJoin2 extends BaseTestCase { Assert.assertNotNull(billingAddress); - List list = Ebean.find(Order.class).fetch("customer", "name", new FetchConfig().lazy(5)) + List list = Ebean.find(Order.class).fetchLazy("customer", "name") .fetch("customer.contacts", "contactName, phone, email").fetch("customer.shippingAddress") .where().eq("status", Order.Status.NEW).order().asc("id").findList(); diff --git a/ebean-core/src/test/java/org/tests/batchload/TestLazyLoadEmptyCollection.java b/ebean-core/src/test/java/org/tests/batchload/TestLazyLoadEmptyCollection.java index f58b99fb2..8f8c770aa 100644 --- a/ebean-core/src/test/java/org/tests/batchload/TestLazyLoadEmptyCollection.java +++ b/ebean-core/src/test/java/org/tests/batchload/TestLazyLoadEmptyCollection.java @@ -24,8 +24,8 @@ public class TestLazyLoadEmptyCollection extends TransactionalTestCase { Ebean.save(c); List list = Ebean.find(Customer.class) - .fetch("contacts", new FetchConfig().query()) - .fetch("contacts.notes", new FetchConfig().query(100)) + .fetchQuery("contacts") + .fetchQuery("contacts.notes") .findList(); for (Customer customer : list) { diff --git a/ebean-core/src/test/java/org/tests/batchload/TestQueryJoinToAssocOne.java b/ebean-core/src/test/java/org/tests/batchload/TestQueryJoinToAssocOne.java index d1b697a70..04883177e 100644 --- a/ebean-core/src/test/java/org/tests/batchload/TestQueryJoinToAssocOne.java +++ b/ebean-core/src/test/java/org/tests/batchload/TestQueryJoinToAssocOne.java @@ -29,7 +29,7 @@ public class TestQueryJoinToAssocOne extends BaseTestCase { // This will use 2 SQL queries to build this object graph List l0 = Ebean.find(Order.class) - .fetch("details", "orderQty, unitPrice", new FetchConfig().query()) + .fetchQuery("details", "orderQty, unitPrice") .fetch("details.product", "sku, name") .findList(); @@ -56,7 +56,7 @@ public class TestQueryJoinToAssocOne extends BaseTestCase { // This will use 2 SQL queries to build this object graph List l0 = Ebean.find(Order.class) .select("status, shipDate") - .fetch("details", "orderQty, unitPrice", new FetchConfig().query()) + .fetchQuery("details", "orderQty, unitPrice") .fetch("details.product", "sku, name") .findList(); @@ -83,7 +83,7 @@ public class TestQueryJoinToAssocOne extends BaseTestCase { List l0 = Ebean.find(Order.class) .setDisableLazyLoading(true) .select("status, shipDate") - .fetch("details", "orderQty, unitPrice", new FetchConfig().query()) + .fetchQuery("details", "orderQty, unitPrice") .fetch("details.product", "sku, name") .order().asc("id") .findList(); diff --git a/ebean-core/src/test/java/org/tests/batchload/TestSecondQueryNoRows.java b/ebean-core/src/test/java/org/tests/batchload/TestSecondQueryNoRows.java index 3b4151589..e8a21786c 100644 --- a/ebean-core/src/test/java/org/tests/batchload/TestSecondQueryNoRows.java +++ b/ebean-core/src/test/java/org/tests/batchload/TestSecondQueryNoRows.java @@ -25,7 +25,7 @@ public class TestSecondQueryNoRows extends BaseTestCase { Customer c = Ebean.find(Customer.class) .setAutoTune(false) .setId(cnew.getId()) - .fetch("contacts", new FetchConfig().query()) + .fetchQuery("contacts") .findOne(); assertNotNull(c); diff --git a/ebean-core/src/test/java/org/tests/batchload/TestSecondaryQueries.java b/ebean-core/src/test/java/org/tests/batchload/TestSecondaryQueries.java index 4ae024159..b61b1fbac 100644 --- a/ebean-core/src/test/java/org/tests/batchload/TestSecondaryQueries.java +++ b/ebean-core/src/test/java/org/tests/batchload/TestSecondaryQueries.java @@ -129,9 +129,9 @@ public class TestSecondaryQueries extends TransactionalTestCase { Query query = Ebean.find(Order.class) .select("status") - .fetch("customer", "name, status", new FetchConfig().query()) + .fetchQuery("customer", "name, status") .fetch("customer.contacts") - .fetch("details", new FetchConfig().query()) + .fetchQuery("details") .where().eq("status", Order.Status.NEW) .query(); diff --git a/ebean-core/src/test/java/org/tests/query/TestQueryFetchJoinWithOrder.java b/ebean-core/src/test/java/org/tests/query/TestQueryFetchJoinWithOrder.java index 69be542f4..68a382e5c 100644 --- a/ebean-core/src/test/java/org/tests/query/TestQueryFetchJoinWithOrder.java +++ b/ebean-core/src/test/java/org/tests/query/TestQueryFetchJoinWithOrder.java @@ -19,14 +19,14 @@ public class TestQueryFetchJoinWithOrder extends BaseTestCase { ResetBasicData.reset(); List list = Ebean.find(Order.class) - .fetch("details", new FetchConfig().query()) + .fetchQuery("details") .order().asc("id") .order().desc("details.id").findList(); Assert.assertNotNull(list); List list2 = Ebean.find(Order.class) - .fetch("customer", new FetchConfig().query(5)) + .fetchQuery("customer") .fetch("customer.contacts") .order().asc("id") .order().asc("customer.contacts.lastName") diff --git a/ebean-core/src/test/java/org/tests/query/TestQueryFilterMany.java b/ebean-core/src/test/java/org/tests/query/TestQueryFilterMany.java index 2e031fbf2..976dac580 100644 --- a/ebean-core/src/test/java/org/tests/query/TestQueryFilterMany.java +++ b/ebean-core/src/test/java/org/tests/query/TestQueryFilterMany.java @@ -29,7 +29,7 @@ public class TestQueryFilterMany extends BaseTestCase { LoggedSqlCollector.start(); Customer customer = Ebean.find(Customer.class) - .fetch("orders", new FetchConfig().lazy()) + .fetchLazy("orders") .filterMany("orders").eq("status", Order.Status.NEW) .where().ieq("name", "Rob") .order().asc("id").setMaxRows(1) diff --git a/ebean-core/src/test/java/org/tests/query/TestQueryFilterManyOnSecondary.java b/ebean-core/src/test/java/org/tests/query/TestQueryFilterManyOnSecondary.java index 94353484a..f87c4c9c9 100644 --- a/ebean-core/src/test/java/org/tests/query/TestQueryFilterManyOnSecondary.java +++ b/ebean-core/src/test/java/org/tests/query/TestQueryFilterManyOnSecondary.java @@ -22,7 +22,7 @@ public class TestQueryFilterManyOnSecondary extends BaseTestCase { ResetBasicData.reset(); Query query = Ebean.find(Customer.class) - .fetch("orders", new FetchConfig().query()) + .fetchQuery("orders") .where().ilike("name", "Rob%").gt("id", 0) .filterMany("orders").eq("status", Order.Status.NEW) .query(); @@ -44,7 +44,7 @@ public class TestQueryFilterManyOnSecondary extends BaseTestCase { ResetBasicData.reset(); Query query = Ebean.find(Order.class) - .fetch("details", new FetchConfig().query()) + .fetchQuery("details") .fetch("details.product", "name") .filterMany("details").ilike("product.name", "c%") .query(); diff --git a/ebean-core/src/test/java/org/tests/query/TestQueryFilterManySimple.java b/ebean-core/src/test/java/org/tests/query/TestQueryFilterManySimple.java index 5feaefeb2..7dae5d580 100644 --- a/ebean-core/src/test/java/org/tests/query/TestQueryFilterManySimple.java +++ b/ebean-core/src/test/java/org/tests/query/TestQueryFilterManySimple.java @@ -25,7 +25,7 @@ public class TestQueryFilterManySimple extends BaseTestCase { .find(Customer.class) // .join("orders", new JoinConfig().lazy()) // .join("orders", new JoinConfig().query()) - .fetch("orders").fetch("contacts", new FetchConfig().query()).where().ilike("name", "rob%") + .fetch("orders").fetchQuery("contacts").where().ilike("name", "rob%") .filterMany("orders").eq("status", Order.Status.NEW).gt("orderDate", lastWeek) .filterMany("contacts").isNotNull("firstName").findList(); diff --git a/ebean-core/src/test/java/org/tests/query/TestQueryFindEach.java b/ebean-core/src/test/java/org/tests/query/TestQueryFindEach.java index 29a824f96..f0f959428 100644 --- a/ebean-core/src/test/java/org/tests/query/TestQueryFindEach.java +++ b/ebean-core/src/test/java/org/tests/query/TestQueryFindEach.java @@ -35,7 +35,7 @@ public class TestQueryFindEach extends BaseTestCase { ResetBasicData.reset(); Query query = DB.find(Customer.class) - .fetch("contacts", new FetchConfig().query(2)) + .fetchQuery("contacts") .where().gt("id", 0).order("id") .setMaxRows(2).query(); @@ -86,7 +86,7 @@ public class TestQueryFindEach extends BaseTestCase { ResetBasicData.reset(); Query query = DB.find(Customer.class) - .fetch("contacts", new FetchConfig().query(2)) + .fetchQuery("contacts") .where().gt("id", 0).order("id") .setMaxRows(2).query(); diff --git a/ebean-core/src/test/java/org/tests/query/TestQueryFindEachWhile.java b/ebean-core/src/test/java/org/tests/query/TestQueryFindEachWhile.java index 82e79d096..2588edf56 100644 --- a/ebean-core/src/test/java/org/tests/query/TestQueryFindEachWhile.java +++ b/ebean-core/src/test/java/org/tests/query/TestQueryFindEachWhile.java @@ -24,7 +24,7 @@ public class TestQueryFindEachWhile extends BaseTestCase { Query query = DB.find(Customer.class) .setAutoTune(false) - .fetch("contacts", new FetchConfig().query(2)).where().gt("id", 0).order("id") + .fetchQuery("contacts").where().gt("id", 0).order("id") .setMaxRows(2).query(); final AtomicInteger counter = new AtomicInteger(0); @@ -47,7 +47,7 @@ public class TestQueryFindEachWhile extends BaseTestCase { ResetBasicData.reset(); Query query = DB.find(Customer.class).setAutoTune(false) - .fetch("contacts", new FetchConfig().query(2)).where().gt("id", 0).order("id") + .fetchQuery("contacts").where().gt("id", 0).order("id") .setMaxRows(2).query(); final AtomicInteger counter = new AtomicInteger(0); diff --git a/ebean-core/src/test/java/org/tests/query/TestQueryJoinBatchSize.java b/ebean-core/src/test/java/org/tests/query/TestQueryJoinBatchSize.java index 77dd68977..721939ef9 100644 --- a/ebean-core/src/test/java/org/tests/query/TestQueryJoinBatchSize.java +++ b/ebean-core/src/test/java/org/tests/query/TestQueryJoinBatchSize.java @@ -18,7 +18,7 @@ public class TestQueryJoinBatchSize extends BaseTestCase { ResetBasicData.reset(); List list = Ebean.find(Order.class) - .fetch("customer", new FetchConfig().queryFirst(3).lazy(2)) + .fetch("customer") //.fetch("orders.details", new FetchConfig().query()) //.fetch("orders.shipments", new FetchConfig().query()) .findList(); diff --git a/ebean-core/src/test/java/org/tests/query/TestThreeLevelQueryJoin.java b/ebean-core/src/test/java/org/tests/query/TestThreeLevelQueryJoin.java index ae461101c..315a4263a 100644 --- a/ebean-core/src/test/java/org/tests/query/TestThreeLevelQueryJoin.java +++ b/ebean-core/src/test/java/org/tests/query/TestThreeLevelQueryJoin.java @@ -14,11 +14,11 @@ public class TestThreeLevelQueryJoin extends BaseTestCase { ResetBasicData.reset(); - Ebean.find(Customer.class).fetch("orders", new FetchConfig().query()) - .fetch("orders.details", new FetchConfig().query()) - .fetch("orders.shipments", new FetchConfig().query()) - .fetch("shippingAddress", new FetchConfig().query()) - .fetch("billingAddress", new FetchConfig().query()).findList(); + Ebean.find(Customer.class).fetchQuery("orders") + .fetchQuery("orders.details") + .fetchQuery("orders.shipments") + .fetchQuery("shippingAddress") + .fetchQuery("billingAddress").findList(); } diff --git a/ebean-core/src/test/java/org/tests/query/joins/TestQueryJoinManyNonRoot.java b/ebean-core/src/test/java/org/tests/query/joins/TestQueryJoinManyNonRoot.java index 82eb65935..20812d6d2 100644 --- a/ebean-core/src/test/java/org/tests/query/joins/TestQueryJoinManyNonRoot.java +++ b/ebean-core/src/test/java/org/tests/query/joins/TestQueryJoinManyNonRoot.java @@ -96,7 +96,7 @@ public class TestQueryJoinManyNonRoot extends BaseTestCase { Query q = Ebean.find(Order.class) .fetch("customer") .fetch("customer.contacts") - .fetch("details", new FetchConfig().query(10)) + .fetchQuery("details") .fetch("details.product") .where().gt("id", 0).query(); diff --git a/ebean-core/src/test/java/org/tests/query/joins/TestQueryJoinQueryNonRoot.java b/ebean-core/src/test/java/org/tests/query/joins/TestQueryJoinQueryNonRoot.java index fcbe77f6e..b24c07472 100644 --- a/ebean-core/src/test/java/org/tests/query/joins/TestQueryJoinQueryNonRoot.java +++ b/ebean-core/src/test/java/org/tests/query/joins/TestQueryJoinQueryNonRoot.java @@ -29,7 +29,7 @@ public class TestQueryJoinQueryNonRoot extends BaseTestCase { List list = Ebean.find(Order.class) .fetch("customer") - .fetch("customer.contacts", "firstName", new FetchConfig().query().lazy(10)) + .fetchQuery("customer.contacts", "firstName") .fetch("customer.contacts.group") .where().lt("id", 3).findList(); diff --git a/ebean-core/src/test/java/org/tests/rawsql/TestRawSqlOrmQuery.java b/ebean-core/src/test/java/org/tests/rawsql/TestRawSqlOrmQuery.java index 947785bab..bece172f6 100644 --- a/ebean-core/src/test/java/org/tests/rawsql/TestRawSqlOrmQuery.java +++ b/ebean-core/src/test/java/org/tests/rawsql/TestRawSqlOrmQuery.java @@ -37,7 +37,7 @@ public class TestRawSqlOrmQuery extends BaseTestCase { query.setRawSql(rawSql); query.where().ilike("name", "r%"); - query.fetch("contacts", new FetchConfig().query()); + query.fetchQuery("contacts"); query.filterMany("contacts").gt("lastName", "b"); List list = query.findList(); diff --git a/ebean-core/src/test/java/org/tests/rawsql/TestRawSqlOrmQueryDistinct.java b/ebean-core/src/test/java/org/tests/rawsql/TestRawSqlOrmQueryDistinct.java index 8a150a944..19c53d44d 100644 --- a/ebean-core/src/test/java/org/tests/rawsql/TestRawSqlOrmQueryDistinct.java +++ b/ebean-core/src/test/java/org/tests/rawsql/TestRawSqlOrmQueryDistinct.java @@ -34,7 +34,7 @@ public class TestRawSqlOrmQueryDistinct extends BaseTestCase { query.setRawSql(rawSql); query.where().ilike("name", "r%"); - query.fetch("contacts", new FetchConfig().query()); + query.fetchQuery("contacts"); query.filterMany("contacts").gt("lastName", "b"); List list = query.findList(); diff --git a/ebean-core/src/test/java/org/tests/rawsql/TestRawSqlOrmWrapper2.java b/ebean-core/src/test/java/org/tests/rawsql/TestRawSqlOrmWrapper2.java index 00f41f683..94df85a74 100644 --- a/ebean-core/src/test/java/org/tests/rawsql/TestRawSqlOrmWrapper2.java +++ b/ebean-core/src/test/java/org/tests/rawsql/TestRawSqlOrmWrapper2.java @@ -31,7 +31,7 @@ public class TestRawSqlOrmWrapper2 extends BaseTestCase { .create(); Query query = Ebean.find(OrderAggregate.class); - query.setRawSql(rawSql).fetch("order", "status,orderDate", new FetchConfig().query()) + query.setRawSql(rawSql).fetchQuery("order", "status,orderDate") .fetch("order.customer", "name").where().gt("order.id", 0).having().gt("totalAmount", 20) .order().desc("totalAmount").setMaxRows(10); diff --git a/ebean-core/src/test/java/org/tests/rawsql/TestRawSqlOrmWrapper3.java b/ebean-core/src/test/java/org/tests/rawsql/TestRawSqlOrmWrapper3.java index 7a73fbabe..3e3bc2e20 100644 --- a/ebean-core/src/test/java/org/tests/rawsql/TestRawSqlOrmWrapper3.java +++ b/ebean-core/src/test/java/org/tests/rawsql/TestRawSqlOrmWrapper3.java @@ -33,8 +33,8 @@ public class TestRawSqlOrmWrapper3 extends BaseTestCase { .create(); List list2 = Ebean.find(OrderAggregate.class).setRawSql(rawSql) - .fetch("order", new FetchConfig().query()) - .fetch("order.details", new FetchConfig().query()) + .fetchQuery("order") + .fetchQuery("order.details") .where().gt("order.id", 2) .having().gt("totalAmount", 10) .filterMany("order.details").gt("unitPrice", 2d) diff --git a/ebean-core/src/test/java/org/tests/rawsql/TestRawSqlWithResultSet.java b/ebean-core/src/test/java/org/tests/rawsql/TestRawSqlWithResultSet.java index 5c80f071d..300ecd524 100644 --- a/ebean-core/src/test/java/org/tests/rawsql/TestRawSqlWithResultSet.java +++ b/ebean-core/src/test/java/org/tests/rawsql/TestRawSqlWithResultSet.java @@ -39,7 +39,7 @@ public class TestRawSqlWithResultSet extends BaseTestCase { List list = Ebean.find(Customer.class) .setRawSql(rawSql) // also test a secondary query join - .fetch("billingAddress", new FetchConfig().query()) + .fetchQuery("billingAddress") .findList(); for (Customer customer : list) { diff --git a/ebean-core/src/test/java/org/tests/rawsql/inherit/ParentRawSqlTest.java b/ebean-core/src/test/java/org/tests/rawsql/inherit/ParentRawSqlTest.java index 9ee61c693..e410bb9af 100644 --- a/ebean-core/src/test/java/org/tests/rawsql/inherit/ParentRawSqlTest.java +++ b/ebean-core/src/test/java/org/tests/rawsql/inherit/ParentRawSqlTest.java @@ -131,7 +131,7 @@ public class ParentRawSqlTest extends BaseTestCase { .create(); List uncles = Ebean.find(EUncle.class).setRawSql(rawSql) - .fetch("parent", new FetchConfig().query()) + .fetchQuery("parent") .findList(); assertNotNull(uncles.get(0)); @@ -150,7 +150,7 @@ public class ParentRawSqlTest extends BaseTestCase { .create(); List uncles = Ebean.find(EUncle.class).setRawSql(rawSql) - .fetch("parent", new FetchConfig().query()) + .fetchQuery("parent") .findList(); assertNotNull(uncles.get(0)); @@ -185,7 +185,7 @@ public class ParentRawSqlTest extends BaseTestCase { .create(); List aggregates = Ebean.find(ParentAggregate.class).setRawSql(rawSql) - .fetch("parent", new FetchConfig().query()) + .fetchQuery("parent") .findList(); List partial = new ArrayList<>(); @@ -209,7 +209,7 @@ public class ParentRawSqlTest extends BaseTestCase { .create(); List aggregates = Ebean.find(ParentAggregate.class).setRawSql(rawSql) - .fetch("parent", new FetchConfig().query()) + .fetchQuery("parent") .findList(); List partial = new ArrayList<>(); @@ -235,7 +235,7 @@ public class ParentRawSqlTest extends BaseTestCase { .create(); List aggregates = Ebean.find(ParentAggregate.class).setRawSql(rawSql) - .fetch("parent", new FetchConfig().query()) + .fetchQuery("parent") .findList(); List partial = new ArrayList<>(); From d5678728133d327f6d3b49773d97ea0746ee8e46 Mon Sep 17 00:00:00 2001 From: Rob Bygrave Date: Sat, 13 Feb 2021 14:50:02 +1300 Subject: [PATCH 097/447] Deprecate the mutating methods of FetchConfig to migrate to the static factory methods (#2164) e.g. migrate from -> to use new FetchConfig().query() -> FetchConfig.ofQuery() new FetchConfig().query(50) -> FetchConfig.ofQuery(50) --- .../src/main/java/io/ebean/FetchConfig.java | 58 +++++++++++++------ .../server/querydefn/OrmQueryProperties.java | 2 +- 2 files changed, 40 insertions(+), 20 deletions(-) diff --git a/ebean-api/src/main/java/io/ebean/FetchConfig.java b/ebean-api/src/main/java/io/ebean/FetchConfig.java index 27b74af3b..64f4c3daa 100644 --- a/ebean-api/src/main/java/io/ebean/FetchConfig.java +++ b/ebean-api/src/main/java/io/ebean/FetchConfig.java @@ -45,8 +45,11 @@ public class FetchConfig implements Serializable { private int hashCode; /** + * Deprecated - migrate to one of the static factory methods like {@link FetchConfig#ofQuery()} + * * Construct using default JOIN mode. */ + @Deprecated public FetchConfig() { //this.mode = JOIN_MODE; this.batchSize = 100; @@ -60,7 +63,7 @@ public class FetchConfig implements Serializable { } /** - * Return FetchConfig that will eagerly fetch the relationship using L2 cache. + * Return FetchConfig to eagerly fetch the relationship using L2 cache. *

* Any cache misses will be loaded by secondary query to the database. */ @@ -69,33 +72,40 @@ public class FetchConfig implements Serializable { } /** - * Return FetchConfig that use a eager secondary query to fetch the relationship. + * Return FetchConfig to eagerly fetch the relationship using a secondary query. */ public static FetchConfig ofQuery() { return new FetchConfig(QUERY_MODE, 100); } /** - * Return FetchConfig that use a eager secondary query to fetch the relationship specifying the batch size. + * Return FetchConfig to eagerly fetch the relationship using a secondary with a given batch size. */ public static FetchConfig ofQuery(int batchSize) { return new FetchConfig(QUERY_MODE, batchSize); } /** - * Return FetchConfig that use lazy loading to fetch the relationship. + * Return FetchConfig to lazily load the relationship. */ public static FetchConfig ofLazy() { return new FetchConfig(LAZY_MODE, 10); } /** - * Return FetchConfig that use lazy loading to fetch the relationship specifying the batch size. + * Return FetchConfig to lazily load the relationship specifying the batch size. */ public static FetchConfig ofLazy(int batchSize) { return new FetchConfig(LAZY_MODE, batchSize); } + /** + * Return FetchConfig to fetch the relationship using SQL join. + */ + public static FetchConfig ofDefault() { + return new FetchConfig(JOIN_MODE, 100); + } + /** * We want to migrate away from mutating FetchConfig to a fully immutable FetchConfig. */ @@ -110,41 +120,37 @@ public class FetchConfig implements Serializable { } /** - * Specify that this path should be lazy loaded using the default batch load size. + * Deprecated - migrate to FetchConfig.ofLazy(). */ + @Deprecated public FetchConfig lazy() { return mutate(LAZY_MODE, 10); } /** - * Specify that this path should be lazy loaded with a specified batch size. - * - * @param batchSize the batch size for lazy loading + * Deprecated - migrate to FetchConfig.ofLazy(batchSize). */ + @Deprecated public FetchConfig lazy(int batchSize) { return mutate(LAZY_MODE, batchSize); } /** - * Eagerly fetccd h the beans in this path as a separate query (rather than as + * Deprecated - migrate to FetchConfig.ofQuery(). + * + * Eagerly fetch the beans in this path as a separate query (rather than as * part of the main query). *

* This will use the default batch size for separate query which is 100. - *

*/ + @Deprecated public FetchConfig query() { return mutate(QUERY_MODE, 100); } /** - * Eagerly fetch the beans fetching the beans from the L2 bean cache - * and using the DB for beans not in the cache. - */ - public FetchConfig cache() { - return mutate(CACHE_MODE, 100); - } - - /** + * Deprecated - migrate to FetchConfig.ofQuery(batchSize). + * * Eagerly fetch the beans in this path as a separate query (rather than as * part of the main query). *

@@ -158,11 +164,14 @@ public class FetchConfig implements Serializable { * * @param batchSize the batch size used to load beans on this path */ + @Deprecated public FetchConfig query(int batchSize) { return mutate(QUERY_MODE, batchSize); } /** + * Deprecated - migrate to FetchConfig.ofQuery(batchSize). + * * Eagerly fetch the first batch of beans on this path. * This is similar to {@link #query(int)} but only fetches the first batch. *

@@ -177,6 +186,17 @@ public class FetchConfig implements Serializable { return query(batchSize); } + /** + * Deprecated - migrate to FetchConfig.ofCache(). + * + * Eagerly fetch the beans fetching the beans from the L2 bean cache + * and using the DB for beans not in the cache. + */ + @Deprecated + public FetchConfig cache() { + return mutate(CACHE_MODE, 100); + } + /** * Return the batch size for fetching. */ diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/querydefn/OrmQueryProperties.java b/ebean-core/src/main/java/io/ebeaninternal/server/querydefn/OrmQueryProperties.java index 425a5d927..1909a2152 100644 --- a/ebean-core/src/main/java/io/ebeaninternal/server/querydefn/OrmQueryProperties.java +++ b/ebean-core/src/main/java/io/ebeaninternal/server/querydefn/OrmQueryProperties.java @@ -26,7 +26,7 @@ public class OrmQueryProperties implements Serializable { private static final long serialVersionUID = -8785582703966455658L; - static final FetchConfig DEFAULT_FETCH = new FetchConfig(); + static final FetchConfig DEFAULT_FETCH = FetchConfig.ofDefault(); private final String parentPath; private final String path; From 9e3d6c6a081a60798ce38a2e823b232efbd3e5e8 Mon Sep 17 00:00:00 2001 From: rob bygrave Date: Sun, 14 Feb 2021 10:28:55 +1300 Subject: [PATCH 098/447] #2165 - Joda LocalDate West of UTC converts incorrectly (Fix: change from epoc millis conversion to y/m/d conversion) --- .../server/type/ScalarTypeJodaLocalDate.java | 5 +++-- .../type/ScalarTypeJodaLocalDateTest.java | 18 ++++++++++++++++++ 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/type/ScalarTypeJodaLocalDate.java b/ebean-core/src/main/java/io/ebeaninternal/server/type/ScalarTypeJodaLocalDate.java index b3d8aee8b..4727f1d58 100644 --- a/ebean-core/src/main/java/io/ebeaninternal/server/type/ScalarTypeJodaLocalDate.java +++ b/ebean-core/src/main/java/io/ebeaninternal/server/type/ScalarTypeJodaLocalDate.java @@ -37,9 +37,10 @@ public class ScalarTypeJodaLocalDate extends ScalarTypeBaseDate { return LocalDate.fromDateFields(date); } + @SuppressWarnings("deprecation") @Override public Date convertToDate(LocalDate value) { - return new java.sql.Date(convertToMillis(value)); + return new Date(value .getYear() - 1900, value .getMonthOfYear() - 1, value .getDayOfMonth()); } @Override @@ -53,7 +54,7 @@ public class ScalarTypeJodaLocalDate extends ScalarTypeBaseDate { @Override public LocalDate toBeanType(Object value) { if (value instanceof java.util.Date) { - return convertFromMillis(((java.util.Date) value).getTime()); + return LocalDate.fromDateFields((java.util.Date)value); } return (LocalDate) value; } diff --git a/ebean-core/src/test/java/io/ebeaninternal/server/type/ScalarTypeJodaLocalDateTest.java b/ebean-core/src/test/java/io/ebeaninternal/server/type/ScalarTypeJodaLocalDateTest.java index fc2246daf..250356338 100644 --- a/ebean-core/src/test/java/io/ebeaninternal/server/type/ScalarTypeJodaLocalDateTest.java +++ b/ebean-core/src/test/java/io/ebeaninternal/server/type/ScalarTypeJodaLocalDateTest.java @@ -6,6 +6,7 @@ import org.junit.Test; import java.io.IOException; import java.sql.Date; +import java.util.TimeZone; import static org.assertj.core.api.Assertions.assertThat; @@ -24,12 +25,29 @@ public class ScalarTypeJodaLocalDateTest { assertThat(localDate).isEqualTo(localDate1); } + @Test + public void convertToDate_convertFromDate_westOfUtc() { + final TimeZone originaDefaultTimezone = TimeZone.getDefault(); + try { + TimeZone.setDefault(TimeZone.getTimeZone("America/Chicago")); + + convertDate(new LocalDate()); + convertDate(new LocalDate(1899, 12, 1)); + convertDate(new LocalDate(1900, 1, 1)); + convertDate(new LocalDate(2021, 2, 8)); + + } finally { + TimeZone.setDefault(originaDefaultTimezone); + } + } + @Test public void convertToDate_convertFromDate() { convertDate(new LocalDate()); convertDate(new LocalDate(1899, 12, 1)); convertDate(new LocalDate(1900, 1, 1)); + convertDate(new LocalDate(2021, 2, 8)); } private void convertDate(LocalDate localDate) { From 4c16b85e8576db9584b8b7df4a9f1c28d3ed71da Mon Sep 17 00:00:00 2001 From: rob bygrave Date: Sun, 14 Feb 2021 10:52:18 +1300 Subject: [PATCH 099/447] #2166 - Remove deprecated forUpdate(lockType) methods - migrate to withLock(lockType, waitType) --- .../main/java/io/ebean/ExpressionList.java | 21 ------------- ebean-api/src/main/java/io/ebean/Query.java | 18 ----------- .../expression/DefaultExpressionList.java | 15 ---------- .../server/expression/JunctionExpression.java | 15 ---------- .../server/query/DefaultFetchGroupQuery.java | 15 ---------- .../server/querydefn/DefaultOrmQuery.java | 15 ---------- .../java/io/ebean/typequery/TQRootBean.java | 30 ------------------- 7 files changed, 129 deletions(-) diff --git a/ebean-api/src/main/java/io/ebean/ExpressionList.java b/ebean-api/src/main/java/io/ebean/ExpressionList.java index 33cf9efcb..e137f64ba 100644 --- a/ebean-api/src/main/java/io/ebean/ExpressionList.java +++ b/ebean-api/src/main/java/io/ebean/ExpressionList.java @@ -196,13 +196,6 @@ public interface ExpressionList { */ Query forUpdate(); - /** - * Deprecated - migrate to withLock(). - * Execute using "for update" with given lock type (currently Postgres only). - */ - @Deprecated - Query forUpdate(Query.LockType lockType); - /** * Execute using "for update" clause with No Wait option. *

@@ -211,13 +204,6 @@ public interface ExpressionList { */ Query forUpdateNoWait(); - /** - * Deprecated - migrate to withLock(). - * Execute using "for update nowait" with given lock type (currently Postgres only). - */ - @Deprecated - Query forUpdateNoWait(Query.LockType lockType); - /** * Execute using "for update" clause with Skip Locked option. *

@@ -226,13 +212,6 @@ public interface ExpressionList { */ Query forUpdateSkipLocked(); - /** - * Deprecated - migrate to withLock(). - * Execute using "for update skip locked" with given lock type (currently Postgres only). - */ - @Deprecated - Query forUpdateSkipLocked(Query.LockType lockType); - /** * Execute the query including soft deleted rows. */ diff --git a/ebean-api/src/main/java/io/ebean/Query.java b/ebean-api/src/main/java/io/ebean/Query.java index ab1c97122..7a33e66f4 100644 --- a/ebean-api/src/main/java/io/ebean/Query.java +++ b/ebean-api/src/main/java/io/ebean/Query.java @@ -1673,12 +1673,6 @@ public interface Query { */ Query forUpdate(); - /** - * Execute using "for update" with given lock type (currently Postgres only). - */ - @Deprecated - Query forUpdate(LockType lockType); - /** * Execute using "for update" clause with "no wait" option. *

@@ -1688,12 +1682,6 @@ public interface Query { */ Query forUpdateNoWait(); - /** - * Execute using "for update nowait" with given lock type (currently Postgres only). - */ - @Deprecated - Query forUpdateNoWait(LockType lockType); - /** * Execute using "for update" clause with "skip locked" option. *

@@ -1703,12 +1691,6 @@ public interface Query { */ Query forUpdateSkipLocked(); - /** - * Execute using "for update skip locked" with given lock type (currently Postgres only). - */ - @Deprecated - Query forUpdateSkipLocked(LockType lockType); - /** * Return true if this query has forUpdate set. */ diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/expression/DefaultExpressionList.java b/ebean-core/src/main/java/io/ebeaninternal/server/expression/DefaultExpressionList.java index 569fb0868..13c111713 100644 --- a/ebean-core/src/main/java/io/ebeaninternal/server/expression/DefaultExpressionList.java +++ b/ebean-core/src/main/java/io/ebeaninternal/server/expression/DefaultExpressionList.java @@ -501,31 +501,16 @@ public class DefaultExpressionList implements SpiExpressionList { return query.forUpdate(); } - @Override - public Query forUpdate(Query.LockType lockType) { - return query.forUpdate(lockType); - } - @Override public Query forUpdateNoWait() { return query.forUpdateNoWait(); } - @Override - public Query forUpdateNoWait(Query.LockType lockType) { - return query.forUpdateNoWait(lockType); - } - @Override public Query forUpdateSkipLocked() { return query.forUpdateSkipLocked(); } - @Override - public Query forUpdateSkipLocked(Query.LockType lockType) { - return query.forUpdateSkipLocked(lockType); - } - @Override public Query select(String fetchProperties) { return query.select(fetchProperties); diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/expression/JunctionExpression.java b/ebean-core/src/main/java/io/ebeaninternal/server/expression/JunctionExpression.java index 81548b19a..4f1784f11 100644 --- a/ebean-core/src/main/java/io/ebeaninternal/server/expression/JunctionExpression.java +++ b/ebean-core/src/main/java/io/ebeaninternal/server/expression/JunctionExpression.java @@ -506,31 +506,16 @@ class JunctionExpression implements SpiJunction, SpiExpression, Expression return exprList.forUpdate(); } - @Override - public Query forUpdate(Query.LockType lockType) { - return exprList.forUpdate(lockType); - } - @Override public Query forUpdateNoWait() { return exprList.forUpdateNoWait(); } - @Override - public Query forUpdateNoWait(Query.LockType lockType) { - return exprList.forUpdateNoWait(lockType); - } - @Override public Query forUpdateSkipLocked() { return exprList.forUpdateSkipLocked(); } - @Override - public Query forUpdateSkipLocked(Query.LockType lockType) { - return exprList.forUpdateSkipLocked(lockType); - } - /** * Path exists - for the given path in a JSON document. */ diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/query/DefaultFetchGroupQuery.java b/ebean-core/src/main/java/io/ebeaninternal/server/query/DefaultFetchGroupQuery.java index 8f2351846..f7bfdadf1 100644 --- a/ebean-core/src/main/java/io/ebeaninternal/server/query/DefaultFetchGroupQuery.java +++ b/ebean-core/src/main/java/io/ebeaninternal/server/query/DefaultFetchGroupQuery.java @@ -569,21 +569,6 @@ class DefaultFetchGroupQuery implements SpiFetchGroupQuery { throw new RuntimeException("EB102: Only select() and fetch() clause is allowed on FetchGroup"); } - @Override - public Query forUpdate(LockType lockType) { - throw new RuntimeException("EB102: Only select() and fetch() clause is allowed on FetchGroup"); - } - - @Override - public Query forUpdateNoWait(LockType lockType) { - throw new RuntimeException("EB102: Only select() and fetch() clause is allowed on FetchGroup"); - } - - @Override - public Query forUpdateSkipLocked(LockType lockType) { - throw new RuntimeException("EB102: Only select() and fetch() clause is allowed on FetchGroup"); - } - @Override public boolean isForUpdate() { return false; diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/querydefn/DefaultOrmQuery.java b/ebean-core/src/main/java/io/ebeaninternal/server/querydefn/DefaultOrmQuery.java index ef58d99f6..d625e87be 100644 --- a/ebean-core/src/main/java/io/ebeaninternal/server/querydefn/DefaultOrmQuery.java +++ b/ebean-core/src/main/java/io/ebeaninternal/server/querydefn/DefaultOrmQuery.java @@ -975,21 +975,6 @@ public class DefaultOrmQuery implements SpiQuery { return setForUpdateWithMode(LockWait.WAIT, LockType.DEFAULT); } - @Override - public Query forUpdate(LockType lockType) { - return setForUpdateWithMode(LockWait.WAIT, lockType); - } - - @Override - public Query forUpdateNoWait(LockType lockType) { - return setForUpdateWithMode(LockWait.NOWAIT, lockType); - } - - @Override - public Query forUpdateSkipLocked(LockType lockType) { - return setForUpdateWithMode(LockWait.SKIPLOCKED, lockType); - } - @Override public DefaultOrmQuery forUpdateNoWait() { return setForUpdateWithMode(LockWait.NOWAIT, LockType.DEFAULT); diff --git a/ebean-querybean/src/main/java/io/ebean/typequery/TQRootBean.java b/ebean-querybean/src/main/java/io/ebean/typequery/TQRootBean.java index 66858dc10..72876a00d 100644 --- a/ebean-querybean/src/main/java/io/ebean/typequery/TQRootBean.java +++ b/ebean-querybean/src/main/java/io/ebean/typequery/TQRootBean.java @@ -721,16 +721,6 @@ public abstract class TQRootBean { return root; } - /** - * Deprecated - migrate to withLock(). - * Execute using "for update" with given lock type (currently Postgres only). - */ - @Deprecated - public R forUpdate(Query.LockType lockType) { - query.forUpdate(lockType); - return root; - } - /** * Execute using "for update" clause with "no wait" option. *

@@ -741,16 +731,6 @@ public abstract class TQRootBean { return root; } - /** - * Deprecated - migrate to withLock(). - * Execute using "for update nowait" with given lock type (currently Postgres only). - */ - @Deprecated - public R forUpdateNoWait(Query.LockType lockType) { - query.forUpdateNoWait(lockType); - return root; - } - /** * Execute using "for update" clause with "skip locked" option. *

@@ -762,16 +742,6 @@ public abstract class TQRootBean { return root; } - /** - * Deprecated - migrate to withLock(). - * Execute using "for update skip locked" with given lock type (currently Postgres only). - */ - @Deprecated - public R forUpdateSkipLocked(Query.LockType lockType) { - query.forUpdateSkipLocked(lockType); - return root; - } - /** * Return this query as an UpdateQuery. * From a6fdc42934a7e1b10ff06173d078fc8f57bbd575 Mon Sep 17 00:00:00 2001 From: Rob Bygrave Date: Sun, 14 Feb 2021 11:21:10 +1300 Subject: [PATCH 100/447] Remove support for "query hints" like +query(50) (#2163) * Remove support for "query hints" like +query(50) * Remove unused readOnly from OrmQueryProperties * OrmQueryProperties cache as final field --- .../server/querydefn/OrmQueryProperties.java | 33 ++------ .../querydefn/OrmQueryPropertiesParser.java | 67 ++------------- .../server/grammer/EqlParserTest.java | 4 +- .../OrmQueryPropertiesParserTest.java | 84 +------------------ .../org/tests/batchload/TestLazyJoin.java | 2 +- .../org/tests/batchload/TestQueryJoin.java | 2 +- 6 files changed, 23 insertions(+), 169 deletions(-) diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/querydefn/OrmQueryProperties.java b/ebean-core/src/main/java/io/ebeaninternal/server/querydefn/OrmQueryProperties.java index 1909a2152..554992214 100644 --- a/ebean-core/src/main/java/io/ebeaninternal/server/querydefn/OrmQueryProperties.java +++ b/ebean-core/src/main/java/io/ebeaninternal/server/querydefn/OrmQueryProperties.java @@ -33,16 +33,13 @@ public class OrmQueryProperties implements Serializable { private final String properties; private final Set included; private final FetchConfig fetchConfig; + private final boolean cache; /** * Flag set when this fetch path needs to be a query join. */ private boolean markForQueryJoin; - private boolean cache; - - private boolean readOnly; - /** * Included bean joins. */ @@ -82,6 +79,7 @@ public class OrmQueryProperties implements Serializable { this.parentPath = SplitName.parent(path); this.properties = null; this.included = null; + this.cache = false; this.fetchConfig = DEFAULT_FETCH; } @@ -96,26 +94,16 @@ public class OrmQueryProperties implements Serializable { OrmQueryPropertiesParser.Response response = OrmQueryPropertiesParser.parse(rawProperties); this.properties = response.properties; this.included = response.included; - this.cache = response.cache; - this.readOnly = response.readOnly; - if (fetchConfig != null) { - this.fetchConfig = fetchConfig; - if (fetchConfig.isCache()) { - this.cache = true; - } - } else { - this.fetchConfig = response.fetchConfig; - } + this.fetchConfig = fetchConfig != null ? fetchConfig : DEFAULT_FETCH; + this.cache = fetchConfig.isCache(); } public OrmQueryProperties(String path, Set included) { this.path = path; this.parentPath = SplitName.parent(path); - // for rawSql parsedProperties can be empty (when only fetching Id property) this.included = included; this.properties = String.join(",", included); this.cache = false; - this.readOnly = false; this.fetchConfig = DEFAULT_FETCH; } @@ -128,7 +116,6 @@ public class OrmQueryProperties implements Serializable { this.path = source.path; this.properties = source.properties; this.cache = source.cache; - this.readOnly = source.readOnly; this.filterMany = source.filterMany; this.markForQueryJoin = source.markForQueryJoin; this.included = (source.included == null) ? null : new LinkedHashSet<>(source.included); @@ -151,6 +138,7 @@ public class OrmQueryProperties implements Serializable { /** * Move a OrderBy.Property from the main query to this query join. */ + @SuppressWarnings("rawtypes") void addSecJoinOrderProperty(OrderBy.Property orderProp) { if (orderBy == null) { orderBy = new OrderBy(); @@ -166,7 +154,7 @@ public class OrmQueryProperties implements Serializable { * Return the expressions used to filter on this path. This should be a many path to use this * method. */ - @SuppressWarnings({"unchecked"}) + @SuppressWarnings({"rawtypes","unchecked"}) public SpiExpressionList filterMany(Query rootQuery) { if (filterMany == null) { FilterExprPath exprPath = new FilterExprPath(path); @@ -371,14 +359,7 @@ public class OrmQueryProperties implements Serializable { } /** - * Return true if this path has the +readonly option. - */ - public boolean isReadOnly() { - return readOnly; - } - - /** - * Return true if this path has the +cache option to hit the cache. + * Return true if this path should hit the L2 cache. */ public boolean isCache() { return cache; diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/querydefn/OrmQueryPropertiesParser.java b/ebean-core/src/main/java/io/ebeaninternal/server/querydefn/OrmQueryPropertiesParser.java index 02b3afbac..f6f925891 100644 --- a/ebean-core/src/main/java/io/ebeaninternal/server/querydefn/OrmQueryPropertiesParser.java +++ b/ebean-core/src/main/java/io/ebeaninternal/server/querydefn/OrmQueryPropertiesParser.java @@ -1,9 +1,7 @@ package io.ebeaninternal.server.querydefn; -import io.ebean.FetchConfig; import io.ebeaninternal.server.util.DSelectColumnsParser; -import java.util.Iterator; import java.util.Set; /** @@ -18,30 +16,15 @@ class OrmQueryPropertiesParser { */ static class Response { - final boolean readOnly; - final boolean cache; - final FetchConfig fetchConfig; final String properties; final Set included; - Response(boolean readOnly, boolean cache, int queryFetchBatch, int lazyFetchBatch, String properties, Set included) { - this.readOnly = readOnly; - this.cache = cache; + private Response(String properties, Set included) { this.properties = properties; this.included = included; - if (queryFetchBatch > 0) { - this.fetchConfig = FetchConfig.ofQuery(queryFetchBatch); - } else if (lazyFetchBatch > 0) { - this.fetchConfig = FetchConfig.ofLazy(lazyFetchBatch); - } else { - this.fetchConfig = OrmQueryProperties.DEFAULT_FETCH; - } } - Response() { - this.readOnly = false; - this.cache = false; - this.fetchConfig = OrmQueryProperties.DEFAULT_FETCH; + private Response() { this.properties = ""; this.included = null; } @@ -57,10 +40,6 @@ class OrmQueryPropertiesParser { private final String inputProperties; private boolean allProperties; - private boolean readOnly; - private boolean cache; - private int queryFetchBatch; - private int lazyFetchBatch; private OrmQueryPropertiesParser(String inputProperties) { this.inputProperties = inputProperties; @@ -74,50 +53,20 @@ class OrmQueryPropertiesParser { return EMPTY; } if (inputProperties.equals("*")) { - // explicit all properties - allProperties = true; - return new Response(readOnly, cache, queryFetchBatch, lazyFetchBatch, "*", null); + return new Response("*", null); } - boolean hints = false; Set fields = splitRawSelect(inputProperties); - final Iterator iterator = fields.iterator(); - while (iterator.hasNext()) { - String val = iterator.next(); - if (val.startsWith("+")) { - hints = true; - iterator.remove(); - parseHint(val); - } else if (val.equals("*")) { + for (String val : fields) { + if (val.equals("*")) { allProperties = true; + break; } } - String properties = allProperties ? "*" : hints ? String.join(",", fields) : inputProperties; + String properties = allProperties ? "*" : inputProperties; if (fields.isEmpty()) { fields = null; } - return new Response(readOnly, cache, queryFetchBatch, lazyFetchBatch, properties, fields); - } - - private void parseHint(String val) { - if (val.equals("+readonly")) { - readOnly = true; - } else if (val.equals("+cache")) { - cache = true; - } else if (val.startsWith("+query")) { - queryFetchBatch = parseBatch(val); - } else if (val.startsWith("+lazy")) { - lazyFetchBatch = parseBatch(val); - } - } - - private int parseBatch(String val) { - if (val.endsWith(")")) { - int start = val.lastIndexOf('('); - if (start > 0) { - return Integer.parseInt(val.substring(start + 1, val.length() - 1)); - } - } - return 0; + return new Response(properties, fields); } /** diff --git a/ebean-core/src/test/java/io/ebeaninternal/server/grammer/EqlParserTest.java b/ebean-core/src/test/java/io/ebeaninternal/server/grammer/EqlParserTest.java index 304a9c4d3..e6281364b 100644 --- a/ebean-core/src/test/java/io/ebeaninternal/server/grammer/EqlParserTest.java +++ b/ebean-core/src/test/java/io/ebeaninternal/server/grammer/EqlParserTest.java @@ -624,7 +624,7 @@ public class EqlParserTest extends BaseTestCase { public void fetch_query50_asHint() { ResetBasicData.reset(); - Query query = parse("fetch billingAddress (+query(50),city)"); + Query query = parse("fetch query(50) billingAddress (city)"); query.findList(); assertSql(query).doesNotContain(", t1.city"); @@ -634,7 +634,7 @@ public class EqlParserTest extends BaseTestCase { public void fetch_lazy50_asHint() { ResetBasicData.reset(); - Query query = parse("fetch billingAddress (+lazy(50),city) order by id"); + Query query = parse("fetch lazy(50) billingAddress (city) order by id"); List list = query.findList(); assertSql(query).doesNotContain(", t1.city"); diff --git a/ebean-core/src/test/java/io/ebeaninternal/server/querydefn/OrmQueryPropertiesParserTest.java b/ebean-core/src/test/java/io/ebeaninternal/server/querydefn/OrmQueryPropertiesParserTest.java index 09c026175..5160c664e 100644 --- a/ebean-core/src/test/java/io/ebeaninternal/server/querydefn/OrmQueryPropertiesParserTest.java +++ b/ebean-core/src/test/java/io/ebeaninternal/server/querydefn/OrmQueryPropertiesParserTest.java @@ -31,91 +31,17 @@ public class OrmQueryPropertiesParserTest { } @Test - public void when_hasCache() { + public void when_no_spaces() { - OrmQueryPropertiesParser.Response res = OrmQueryPropertiesParser.parse("+cache"); - assertThat(res.cache).isTrue(); - assertThat(res.included).isNull(); - } - - @Test - public void when_hasCache_first() { - - OrmQueryPropertiesParser.Response res = OrmQueryPropertiesParser.parse("+cache,id"); - assertThat(res.cache).isTrue(); - assertThat(res.included).containsExactly("id"); - } - - @Test - public void when_hasCache_last() { - - OrmQueryPropertiesParser.Response res = OrmQueryPropertiesParser.parse("name,+cache"); - assertThat(res.cache).isTrue(); - assertThat(res.included).containsExactly("name"); - } - - @Test - public void when_hasCache_middle() { - - OrmQueryPropertiesParser.Response res = OrmQueryPropertiesParser.parse("name,+cache, id"); - assertThat(res.cache).isTrue(); - assertThat(res.included).containsExactly("name", "id"); - } - - @Test - public void when_hasReadOnly() { - - OrmQueryPropertiesParser.Response res = OrmQueryPropertiesParser.parse("+readonly"); - assertThat(res.readOnly).isTrue(); - assertThat(res.included).isNull(); - } - - @Test - public void when_hasLazy() { - OrmQueryPropertiesParser.Response res = OrmQueryPropertiesParser.parse("+lazy"); - //FIXME: assertThat(res.fetchConfig.getBatchSize()).isEqualTo(0); - assertThat(res.included).isNull(); - } - - @Test - public void when_hasLazyValue() { - - OrmQueryPropertiesParser.Response res = OrmQueryPropertiesParser.parse("+lazy(20)"); - assertThat(res.fetchConfig.getBatchSize()).isEqualTo(20); - assertThat(res.included).isNull(); - } - - @Test - public void when_hasLazyValue_last() { - - OrmQueryPropertiesParser.Response res = OrmQueryPropertiesParser.parse("name,+lazy(20)"); - assertThat(res.fetchConfig.getBatchSize()).isEqualTo(20); - assertThat(res.included).containsExactly("name"); - } - - @Test - public void when_hasLazyValue_first() { - - OrmQueryPropertiesParser.Response res = OrmQueryPropertiesParser.parse("+lazy(20),id,name"); - assertThat(res.fetchConfig.getBatchSize()).isEqualTo(20); + OrmQueryPropertiesParser.Response res = OrmQueryPropertiesParser.parse("id,name"); assertThat(res.included).containsExactly("id", "name"); } @Test - public void when_allProperties() { - OrmQueryPropertiesParser.Response res = OrmQueryPropertiesParser.parse("+query(4),+lazy(5)"); - assertThat(res.fetchConfig.getBatchSize()).isEqualTo(4); - assertThat(res.included).isNull(); - } + public void when_spaced() { - @Test - public void when_everything_set() { - - OrmQueryPropertiesParser.Response res = OrmQueryPropertiesParser.parse("id, name, +readonly ,+lazy(20), +query(30) ,+cache"); + OrmQueryPropertiesParser.Response res = OrmQueryPropertiesParser.parse("id, name"); assertThat(res.included).containsExactly("id", "name"); - assertThat(res.fetchConfig.getBatchSize()).isEqualTo(30); - assertThat(res.readOnly).isTrue(); - assertThat(res.cache).isTrue(); } @Test @@ -126,8 +52,6 @@ public class OrmQueryPropertiesParserTest { } private void assertAllDefaults(OrmQueryPropertiesParser.Response res) { - assertThat(res.cache).isFalse(); - assertThat(res.readOnly).isFalse(); assertThat(res.included).isNull(); } } diff --git a/ebean-core/src/test/java/org/tests/batchload/TestLazyJoin.java b/ebean-core/src/test/java/org/tests/batchload/TestLazyJoin.java index e452da0ce..bd15f2f6d 100644 --- a/ebean-core/src/test/java/org/tests/batchload/TestLazyJoin.java +++ b/ebean-core/src/test/java/org/tests/batchload/TestLazyJoin.java @@ -21,7 +21,7 @@ public class TestLazyJoin extends BaseTestCase { Query query = Ebean.find(Order.class) .select("status") - .fetch("customer", "+lazy(10) name, status") + .fetchLazy("customer", "name, status") .fetch("customer.contacts") .order().asc("id"); diff --git a/ebean-core/src/test/java/org/tests/batchload/TestQueryJoin.java b/ebean-core/src/test/java/org/tests/batchload/TestQueryJoin.java index 81bac2193..533dd5470 100644 --- a/ebean-core/src/test/java/org/tests/batchload/TestQueryJoin.java +++ b/ebean-core/src/test/java/org/tests/batchload/TestQueryJoin.java @@ -28,7 +28,7 @@ public class TestQueryJoin extends BaseTestCase { Query query = Ebean.find(Order.class).select("status") // .join("details","+query(10)") - .fetch("customer", "+lazy(10), name, status").fetch("customer.contacts").order().asc("id"); + .fetchLazy("customer", "name, status").fetch("customer.contacts").order().asc("id"); // .join("customer.billingAddress"); List list = query.findList(); From ab87174e5b2d1ab111061eac49fc2b7e5f8bf700 Mon Sep 17 00:00:00 2001 From: rob bygrave Date: Sun, 14 Feb 2021 11:30:24 +1300 Subject: [PATCH 101/447] #2163 - Fix OrmQueryProperties when FetchConfig null --- .../server/querydefn/OrmQueryProperties.java | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/querydefn/OrmQueryProperties.java b/ebean-core/src/main/java/io/ebeaninternal/server/querydefn/OrmQueryProperties.java index 554992214..704cead7f 100644 --- a/ebean-core/src/main/java/io/ebeaninternal/server/querydefn/OrmQueryProperties.java +++ b/ebean-core/src/main/java/io/ebeaninternal/server/querydefn/OrmQueryProperties.java @@ -84,18 +84,22 @@ public class OrmQueryProperties implements Serializable { } public OrmQueryProperties(String path, String rawProperties) { - this(path, rawProperties, null); + this(path, rawProperties, DEFAULT_FETCH); } public OrmQueryProperties(String path, String rawProperties, FetchConfig fetchConfig) { this.path = path; this.parentPath = SplitName.parent(path); - OrmQueryPropertiesParser.Response response = OrmQueryPropertiesParser.parse(rawProperties); this.properties = response.properties; this.included = response.included; - this.fetchConfig = fetchConfig != null ? fetchConfig : DEFAULT_FETCH; - this.cache = fetchConfig.isCache(); + if (fetchConfig != null) { + this.fetchConfig = fetchConfig; + this.cache = fetchConfig.isCache(); + } else { + this.cache = false; + this.fetchConfig = DEFAULT_FETCH; + } } public OrmQueryProperties(String path, Set included) { From cc64ff5f105b0453baafd2a74ffdfe917068487a Mon Sep 17 00:00:00 2001 From: rob bygrave Date: Sun, 14 Feb 2021 11:37:19 +1300 Subject: [PATCH 102/447] Update javadoc with use of FetchConfig.ofQuery() etc --- ebean-api/src/main/java/io/ebean/Query.java | 14 +++++++------- ebean-api/src/main/java/io/ebean/RawSql.java | 2 +- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/ebean-api/src/main/java/io/ebean/Query.java b/ebean-api/src/main/java/io/ebean/Query.java index 7a33e66f4..24a8445be 100644 --- a/ebean-api/src/main/java/io/ebean/Query.java +++ b/ebean-api/src/main/java/io/ebean/Query.java @@ -514,7 +514,7 @@ public interface Query { *

*
{@code
    *
-   *  fetch(path, fetchProperties, new FetchConfig().query())
+   *  fetch(path, fetchProperties, FetchConfig.ofQuery())
    *
    * }
*

@@ -548,7 +548,7 @@ public interface Query { *

*
{@code
    *
-   *  fetch(path, fetchProperties, new FetchConfig().lazy())
+   *  fetch(path, fetchProperties, FetchConfig.ofLazy())
    *
    * }
*

@@ -573,7 +573,7 @@ public interface Query { * // fetch customers (their id, name and status) * List customers = DB.find(Customer.class) * .select("name, status") - * .fetch("contacts", "firstName,lastName,email", new FetchConfig().lazy(10)) + * .fetch("contacts", "firstName,lastName,email", FetchConfig.ofLazy(10)) * .findList(); * * } @@ -610,7 +610,7 @@ public interface Query { *

*
{@code
    *
-   *  fetch(path, new FetchConfig().query())
+   *  fetch(path, FetchConfig.ofQuery())
    *
    * }
*

@@ -639,7 +639,7 @@ public interface Query { *

*
{@code
    *
-   *  fetch(path, new FetchConfig().lazy())
+   *  fetch(path, FetchConfig.ofLazy())
    *
    * }
*

@@ -662,7 +662,7 @@ public interface Query { * // fetch customers (their id, name and status) * List customers = DB.find(Customer.class) * // lazy fetch contacts with a batch size of 100 - * .fetch("contacts", new FetchConfig().lazy(100)) + * .fetch("contacts", FetchConfig.ofLazy(100)) * .findList(); * * } @@ -844,7 +844,7 @@ public interface Query { *

{@code
    *
    *  DB.find(Customer.class)
-   *     .fetch("contacts", new FetchConfig().query(2))
+   *     .fetch("contacts", FetchConfig.ofQuery(2))
    *     .where().eq("status", Status.NEW)
    *     .order().asc("id")
    *     .setMaxRows(2000)
diff --git a/ebean-api/src/main/java/io/ebean/RawSql.java b/ebean-api/src/main/java/io/ebean/RawSql.java
index 1fe274a1e..e0e20714b 100644
--- a/ebean-api/src/main/java/io/ebean/RawSql.java
+++ b/ebean-api/src/main/java/io/ebean/RawSql.java
@@ -107,7 +107,7 @@ package io.ebean;
  *
  *   List orders = DB.find(OrderAggregate.class)
  *     .setRawSql(rawSql)
- *     .fetch("order", "status,orderDate", new FetchConfig().query())
+ *     .fetch("order", "status,orderDate", FetchConfig.ofQuery())
  *     .fetch("order.customer", "name")
  *     .where().gt("order.id", 0)
  *     .having().gt("totalAmount", 20)

From bab637667df721125a6f0fa392982fb23e8c77b1 Mon Sep 17 00:00:00 2001
From: rob bygrave 
Date: Sun, 14 Feb 2021 11:50:54 +1300
Subject: [PATCH 103/447] Update test only - update TestBasicClobNoVer to use
 DB and AssertJ

---
 .../tests/basic/lob/TestBasicClobNoVer.java   | 35 ++++++++-----------
 1 file changed, 15 insertions(+), 20 deletions(-)

diff --git a/ebean-core/src/test/java/org/tests/basic/lob/TestBasicClobNoVer.java b/ebean-core/src/test/java/org/tests/basic/lob/TestBasicClobNoVer.java
index 0d791db50..f33a42a42 100644
--- a/ebean-core/src/test/java/org/tests/basic/lob/TestBasicClobNoVer.java
+++ b/ebean-core/src/test/java/org/tests/basic/lob/TestBasicClobNoVer.java
@@ -1,12 +1,10 @@
 package org.tests.basic.lob;
 
 import io.ebean.BaseTestCase;
-import io.ebean.Ebean;
-import io.ebean.EbeanServer;
+import io.ebean.DB;
 import io.ebean.Query;
 import org.tests.model.basic.EBasicClobNoVer;
 import org.ebeantest.LoggedSqlCollector;
-import org.junit.Assert;
 import org.junit.Test;
 
 import java.util.List;
@@ -21,53 +19,50 @@ public class TestBasicClobNoVer extends BaseTestCase {
     EBasicClobNoVer entity = new EBasicClobNoVer();
     entity.setName("test");
     entity.setDescription("initialClobValue");
-    EbeanServer server = Ebean.getServer(null);
-    server.save(entity);
-
-
-    String sqlNoClob = "select t0.id, t0.name from ebasic_clob_no_ver t0 where t0.id = ?";
-    String sqlWithClob = "select t0.id, t0.name, t0.description from ebasic_clob_no_ver t0 where t0.id = ?";
-
+    DB.save(entity);
 
     // Clob by default is Fetch Lazy
-    Query defaultQuery = Ebean.find(EBasicClobNoVer.class).setId(entity.getId());
+    Query defaultQuery = DB.find(EBasicClobNoVer.class).setId(entity.getId());
     defaultQuery.findOne();
     String sql = sqlOf(defaultQuery, 2);
 
-    Assert.assertTrue("Clob is fetch lazy by default", sql.contains(sqlNoClob));
+    // default SQL select excludes clob
+    String sqlNoClob = "select t0.id, t0.name from ebasic_clob_no_ver t0 where t0.id = ?";
+    assertThat(sql).contains(sqlNoClob);
 
 
     // Explicitly select * including Clob
-    Query explicitQuery = Ebean.find(EBasicClobNoVer.class).setId(entity.getId()).select("*");
+    Query explicitQuery = DB.find(EBasicClobNoVer.class).setId(entity.getId()).select("*");
 
     explicitQuery.findOne();
     sql = sqlOf(explicitQuery, 2);
 
-    Assert.assertTrue("Explicitly include Clob", sql.contains(sqlWithClob));
+    // Explicitly include Clob
+    String sqlWithClob = "select t0.id, t0.name, t0.description from ebasic_clob_no_ver t0 where t0.id = ?";
+    assertThat(sql).contains(sqlWithClob);
 
     // Update description to test refresh
 
     EBasicClobNoVer updateBean = new EBasicClobNoVer();
     updateBean.setId(entity.getId());
     updateBean.setDescription("modified");
-    Ebean.update(updateBean);
+    DB.update(updateBean);
 
 
     // Test refresh function
 
-    Assert.assertEquals("initialClobValue", entity.getDescription());
+    assertThat(entity.getDescription()).isEqualTo("initialClobValue");
 
     LoggedSqlCollector.start();
 
     // Refresh query includes all properties
-    server.refresh(entity);
+    DB.refresh(entity);
 
     // Assert all properties fetched in refresh
     List loggedSql = LoggedSqlCollector.stop();
-    Assert.assertEquals(1, loggedSql.size());
+    assertThat(loggedSql).hasSize(1);
     assertThat(trimSql(loggedSql.get(0), 2)).contains(sqlWithClob);
-    Assert.assertEquals("modified", entity.getDescription());
-
+    assertThat(entity.getDescription()).isEqualTo("modified");
   }
 
 }

From dc65475dbbca9a703f71606688538957ba81766d Mon Sep 17 00:00:00 2001
From: robin 
Date: Tue, 16 Feb 2021 17:47:56 +1300
Subject: [PATCH 104/447] #2168 - Using ebean-test with redis container -
 hanging testing redis connectivity

---
 ebean-test/pom.xml | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/ebean-test/pom.xml b/ebean-test/pom.xml
index d880773a8..92f4c590f 100644
--- a/ebean-test/pom.xml
+++ b/ebean-test/pom.xml
@@ -63,7 +63,7 @@
     
       io.ebean
       ebean-test-docker
-      4.1
+      4.2
     
 
     

From 98a89156bf14c970c5b6b7ba293e6838848cbe19 Mon Sep 17 00:00:00 2001
From: Rob Bygrave 
Date: Tue, 16 Feb 2021 17:51:47 +1300
Subject: [PATCH 105/447] Refactor query internals to reduce property parsing
 for partial select and fetch (#2167)

* Update test only - update TestBasicClobNoVer to use DB and AssertJ

* Refactor OrmQueryProperties internals to reduce raw property parsing

- Remove String properties
- Reduces parsing of properties via  fetchProperties() selectProperties() methods

* No effective change - tidy pom.xml for ebean-querybean

* Refactor query internals adding fetchProperties() selectProperties()

- Adds SpiQueryFetch
- Used by query beans with Set properties passed (effectively skipping any parsing)
---
 .../java/io/ebeaninternal/api/SpiQuery.java   | 13 +++-
 .../io/ebeaninternal/api/SpiQueryFetch.java   | 22 ++++++
 .../server/query/DFetchGroupBuilder.java      | 15 ++--
 .../server/query/DefaultFetchGroupQuery.java  | 13 +++-
 .../server/querydefn/DefaultOrmQuery.java     | 20 +++++
 .../server/querydefn/OrmQueryDetail.java      | 35 +++++++--
 .../server/querydefn/OrmQueryProperties.java  | 60 ++++++++-------
 .../querydefn/OrmQueryPropertiesParser.java   | 53 +++----------
 .../OrmQueryPropertiesParserTest.java         | 12 ++-
 .../querydefn/OrmQueryPropertiesTest.java     | 11 +--
 .../tests/basic/lob/TestBasicClobNoVer.java   | 35 ++++-----
 ebean-querybean/pom.xml                       | 17 ++---
 .../java/io/ebean/typequery/TQAssocBean.java  | 49 +++++++-----
 .../java/io/ebean/typequery/TQRootBean.java   | 23 +++---
 .../test/java/org/querytest/QOrderTest.java   | 74 ++++++++++++++++++-
 15 files changed, 297 insertions(+), 155 deletions(-)
 create mode 100644 ebean-core/src/main/java/io/ebeaninternal/api/SpiQueryFetch.java

diff --git a/ebean-core/src/main/java/io/ebeaninternal/api/SpiQuery.java b/ebean-core/src/main/java/io/ebeaninternal/api/SpiQuery.java
index f3b133bc2..4686a3644 100644
--- a/ebean-core/src/main/java/io/ebeaninternal/api/SpiQuery.java
+++ b/ebean-core/src/main/java/io/ebeaninternal/api/SpiQuery.java
@@ -20,6 +20,7 @@ import io.ebeaninternal.server.deploy.TableJoin;
 import io.ebeaninternal.server.query.CancelableQuery;
 import io.ebeaninternal.server.querydefn.NaturalKeyBindParam;
 import io.ebeaninternal.server.querydefn.OrmQueryDetail;
+import io.ebeaninternal.server.querydefn.OrmQueryProperties;
 import io.ebeaninternal.server.querydefn.OrmUpdateProperties;
 import io.ebeaninternal.server.rawsql.SpiRawSql;
 
@@ -30,7 +31,7 @@ import java.util.Set;
 /**
  * Object Relational query - Internal extension to Query object.
  */
-public interface SpiQuery extends Query, TxnProfileEventCodes {
+public interface SpiQuery extends Query, SpiQueryFetch, TxnProfileEventCodes {
 
   enum Mode {
     NORMAL(false), LAZYLOAD_MANY(false), LAZYLOAD_BEAN(true), REFRESH_BEAN(true);
@@ -289,6 +290,16 @@ public interface SpiQuery extends Query, TxnProfileEventCodes {
    */
   boolean selectAllForLazyLoadProperty();
 
+  /**
+   * Set the select properties.
+   */
+  void selectProperties(OrmQueryProperties other);
+
+  /**
+   * Set the fetch properties for the given path.
+   */
+  void fetchProperties(String path, OrmQueryProperties other);
+
   /**
    * Set the on a secondary query given the label, relativePath and profile location of the parent query.
    */
diff --git a/ebean-core/src/main/java/io/ebeaninternal/api/SpiQueryFetch.java b/ebean-core/src/main/java/io/ebeaninternal/api/SpiQueryFetch.java
new file mode 100644
index 000000000..396827978
--- /dev/null
+++ b/ebean-core/src/main/java/io/ebeaninternal/api/SpiQueryFetch.java
@@ -0,0 +1,22 @@
+package io.ebeaninternal.api;
+
+import io.ebean.FetchConfig;
+
+import java.util.Set;
+
+/**
+ * Query select and fetch properties (that avoids parsing).
+ */
+public interface SpiQueryFetch {
+
+  /**
+   * Specify the select properties.
+   */
+  void selectProperties(Set properties);
+
+  /**
+   * Specify the fetch properties for the given path.
+   */
+  void fetchProperties(String name, Set properties, FetchConfig config);
+
+}
diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/query/DFetchGroupBuilder.java b/ebean-core/src/main/java/io/ebeaninternal/server/query/DFetchGroupBuilder.java
index f33985f46..6553b7ea4 100644
--- a/ebean-core/src/main/java/io/ebeaninternal/server/query/DFetchGroupBuilder.java
+++ b/ebean-core/src/main/java/io/ebeaninternal/server/query/DFetchGroupBuilder.java
@@ -11,6 +11,8 @@ import io.ebeaninternal.server.querydefn.SpiFetchGroup;
  */
 class DFetchGroupBuilder implements FetchGroupBuilder {
 
+  private static final FetchConfig DEFAULT_FETCH = FetchConfig.ofDefault();
+
   private static final FetchConfig FETCH_CACHE = FetchConfig.ofCache();
 
   private static final FetchConfig FETCH_QUERY = FetchConfig.ofQuery();
@@ -31,13 +33,13 @@ class DFetchGroupBuilder implements FetchGroupBuilder {
 
   @Override
   public FetchGroupBuilder fetch(String path) {
-    detail.fetch(path, null, null);
+    detail.fetchProperties(path, null, DEFAULT_FETCH);
     return this;
   }
 
   @Override
   public FetchGroupBuilder fetch(String path, FetchGroup nestedGroup) {
-    return fetchNested(path, nestedGroup, null);
+    return fetchNested(path, nestedGroup, DEFAULT_FETCH);
   }
 
   @Override
@@ -51,7 +53,6 @@ class DFetchGroupBuilder implements FetchGroupBuilder {
   }
 
   private FetchGroupBuilder fetchNested(String path, FetchGroup nestedGroup, FetchConfig fetchConfig) {
-
     OrmQueryDetail nestedDetail = ((SpiFetchGroup) nestedGroup).underlying();
     detail.addNested(path, nestedDetail, fetchConfig);
     return this;
@@ -59,25 +60,25 @@ class DFetchGroupBuilder implements FetchGroupBuilder {
 
   @Override
   public FetchGroupBuilder fetchQuery(String path) {
-    detail.fetch(path, null, FETCH_QUERY);
+    detail.fetchProperties(path, null, FETCH_QUERY);
     return this;
   }
 
   @Override
   public FetchGroupBuilder fetchCache(String path) {
-    detail.fetch(path, null, FETCH_CACHE);
+    detail.fetchProperties(path, null, FETCH_CACHE);
     return this;
   }
 
   @Override
   public FetchGroupBuilder fetchLazy(String path) {
-    detail.fetch(path, null, FETCH_LAZY);
+    detail.fetchProperties(path, null, FETCH_LAZY);
     return this;
   }
 
   @Override
   public FetchGroupBuilder fetch(String path, String properties) {
-    detail.fetch(path, properties, null);
+    detail.fetch(path, properties, DEFAULT_FETCH);
     return this;
   }
 
diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/query/DefaultFetchGroupQuery.java b/ebean-core/src/main/java/io/ebeaninternal/server/query/DefaultFetchGroupQuery.java
index f7bfdadf1..5da152185 100644
--- a/ebean-core/src/main/java/io/ebeaninternal/server/query/DefaultFetchGroupQuery.java
+++ b/ebean-core/src/main/java/io/ebeaninternal/server/query/DefaultFetchGroupQuery.java
@@ -25,6 +25,7 @@ import io.ebean.Transaction;
 import io.ebean.UpdateQuery;
 import io.ebean.Version;
 import io.ebean.service.SpiFetchGroupQuery;
+import io.ebeaninternal.api.SpiQueryFetch;
 import io.ebeaninternal.server.querydefn.OrmQueryDetail;
 import io.ebeaninternal.server.querydefn.SpiFetchGroup;
 
@@ -43,7 +44,7 @@ import java.util.stream.Stream;
 /**
  * Implementation of FetchGroup query for use to create FetchGroup via query beans.
  */
-class DefaultFetchGroupQuery implements SpiFetchGroupQuery {
+class DefaultFetchGroupQuery implements SpiFetchGroupQuery, SpiQueryFetch {
 
   private static final FetchConfig FETCH_CACHE = FetchConfig.ofCache();
 
@@ -628,4 +629,14 @@ class DefaultFetchGroupQuery implements SpiFetchGroupQuery {
   public Query orderById(boolean orderById) {
     throw new RuntimeException("EB102: Only select() and fetch() clause is allowed on FetchGroup");
   }
+
+  @Override
+  public void selectProperties(Set props) {
+    detail.selectProperties(props);
+  }
+
+  @Override
+  public void fetchProperties(String property, Set columns, FetchConfig config) {
+    detail.fetchProperties(property, columns, config);
+  }
 }
diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/querydefn/DefaultOrmQuery.java b/ebean-core/src/main/java/io/ebeaninternal/server/querydefn/DefaultOrmQuery.java
index d625e87be..e19212e96 100644
--- a/ebean-core/src/main/java/io/ebeaninternal/server/querydefn/DefaultOrmQuery.java
+++ b/ebean-core/src/main/java/io/ebeaninternal/server/querydefn/DefaultOrmQuery.java
@@ -1392,6 +1392,26 @@ public class DefaultOrmQuery implements SpiQuery {
     return this;
   }
 
+  @Override
+  public void selectProperties(Set props) {
+    detail.selectProperties(props);
+  }
+
+  @Override
+  public void fetchProperties(String property, Set columns, FetchConfig config) {
+    detail.fetchProperties(property, columns, config);
+  }
+
+  @Override
+  public void selectProperties(OrmQueryProperties properties) {
+    detail.selectProperties(properties);
+  }
+
+  @Override
+  public void fetchProperties(String path, OrmQueryProperties other) {
+    detail.fetchProperties(path, other);
+  }
+
   @Override
   public DefaultOrmQuery select(String columns) {
     detail.select(columns);
diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/querydefn/OrmQueryDetail.java b/ebean-core/src/main/java/io/ebeaninternal/server/querydefn/OrmQueryDetail.java
index b8837111e..1c441cbf4 100644
--- a/ebean-core/src/main/java/io/ebeaninternal/server/querydefn/OrmQueryDetail.java
+++ b/ebean-core/src/main/java/io/ebeaninternal/server/querydefn/OrmQueryDetail.java
@@ -59,9 +59,9 @@ public class OrmQueryDetail implements Serializable {
    * Add a nested OrmQueryDetail to this detail.
    */
   public void addNested(String path, OrmQueryDetail other, FetchConfig config) {
-    fetch(path, other.baseProps.getProperties(), config);
+    fetchProperties(path, other.baseProps, config);
     for (Map.Entry entry : other.fetchPaths.entrySet()) {
-      fetch(path + "." + entry.getKey(), entry.getValue().getProperties(), entry.getValue().getFetchConfig());
+      fetchProperties(path + "." + entry.getKey(), entry.getValue(), entry.getValue().getFetchConfig());
     }
   }
 
@@ -133,8 +133,19 @@ public class OrmQueryDetail implements Serializable {
   /**
    * set the properties to include on the base / root entity.
    */
-  public void select(String columns) {
-    baseProps = new OrmQueryProperties(null, columns, null);
+  public void select(String properties) {
+    baseProps = new OrmQueryProperties(null, properties, null);
+  }
+
+  /**
+   * Set select properties that are already parsed.
+   */
+  public void selectProperties(Set properties) {
+    baseProps = new OrmQueryProperties(null, properties, OrmQueryProperties.DEFAULT_FETCH);
+  }
+
+  void selectProperties(OrmQueryProperties other) {
+    baseProps = new OrmQueryProperties(null, other, OrmQueryProperties.DEFAULT_FETCH);
   }
 
   boolean containsProperty(String property) {
@@ -262,10 +273,24 @@ public class OrmQueryDetail implements Serializable {
    * @param partialProps the properties on the join property to include
    */
   public void fetch(String path, String partialProps, FetchConfig fetchConfig) {
-
     fetch(new OrmQueryProperties(path, partialProps, fetchConfig));
   }
 
+  /**
+   * Set fetch properties that are already parsed.
+   */
+  public void fetchProperties(String path, Set properties, FetchConfig fetchConfig) {
+    fetch(new OrmQueryProperties(path, properties, fetchConfig));
+  }
+
+  void fetchProperties(String path, OrmQueryProperties other) {
+    fetchProperties(path, other, other.getFetchConfig());
+  }
+
+  void fetchProperties(String path, OrmQueryProperties other, FetchConfig fetchConfig) {
+    fetch(new OrmQueryProperties(path, other, fetchConfig));
+  }
+
   /**
    * Add for raw sql etc when the properties are already parsed into a set.
    */
diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/querydefn/OrmQueryProperties.java b/ebean-core/src/main/java/io/ebeaninternal/server/querydefn/OrmQueryProperties.java
index 704cead7f..e84828f09 100644
--- a/ebean-core/src/main/java/io/ebeaninternal/server/querydefn/OrmQueryProperties.java
+++ b/ebean-core/src/main/java/io/ebeaninternal/server/querydefn/OrmQueryProperties.java
@@ -30,7 +30,7 @@ public class OrmQueryProperties implements Serializable {
 
   private final String parentPath;
   private final String path;
-  private final String properties;
+  private final boolean allProperties;
   private final Set included;
   private final FetchConfig fetchConfig;
   private final boolean cache;
@@ -77,7 +77,7 @@ public class OrmQueryProperties implements Serializable {
   public OrmQueryProperties(String path) {
     this.path = path;
     this.parentPath = SplitName.parent(path);
-    this.properties = null;
+    this.allProperties = false;
     this.included = null;
     this.cache = false;
     this.fetchConfig = DEFAULT_FETCH;
@@ -91,7 +91,7 @@ public class OrmQueryProperties implements Serializable {
     this.path = path;
     this.parentPath = SplitName.parent(path);
     OrmQueryPropertiesParser.Response response = OrmQueryPropertiesParser.parse(rawProperties);
-    this.properties = response.properties;
+    this.allProperties = response.allProperties;
     this.included = response.included;
     if (fetchConfig != null) {
       this.fetchConfig = fetchConfig;
@@ -103,12 +103,25 @@ public class OrmQueryProperties implements Serializable {
   }
 
   public OrmQueryProperties(String path, Set included) {
+    this(path, included, DEFAULT_FETCH);
+  }
+
+  OrmQueryProperties(String path, Set included, FetchConfig fetchConfig) {
     this.path = path;
     this.parentPath = SplitName.parent(path);
     this.included = included;
-    this.properties = String.join(",", included);
-    this.cache = false;
-    this.fetchConfig = DEFAULT_FETCH;
+    this.allProperties = false;
+    this.fetchConfig = fetchConfig;
+    this.cache = fetchConfig.isCache();
+  }
+
+  OrmQueryProperties(String path, OrmQueryProperties other, FetchConfig fetchConfig) {
+    this.path = path;
+    this.parentPath = SplitName.parent(path);
+    this.allProperties = other.allProperties;
+    this.included = other.included;
+    this.cache = other.cache;
+    this.fetchConfig = fetchConfig;
   }
 
   /**
@@ -118,7 +131,7 @@ public class OrmQueryProperties implements Serializable {
     this.fetchConfig = sourceFetchConfig;
     this.parentPath = source.parentPath;
     this.path = source.path;
-    this.properties = source.properties;
+    this.allProperties = source.allProperties;
     this.cache = source.cache;
     this.filterMany = source.filterMany;
     this.markForQueryJoin = source.markForQueryJoin;
@@ -158,7 +171,7 @@ public class OrmQueryProperties implements Serializable {
    * Return the expressions used to filter on this path. This should be a many path to use this
    * method.
    */
-  @SuppressWarnings({"rawtypes","unchecked"})
+  @SuppressWarnings({"rawtypes", "unchecked"})
   public  SpiExpressionList filterMany(Query rootQuery) {
     if (filterMany == null) {
       FilterExprPath exprPath = new FilterExprPath(path);
@@ -201,9 +214,8 @@ public class OrmQueryProperties implements Serializable {
    */
   @SuppressWarnings("unchecked")
   public void configureBeanQuery(SpiQuery query) {
-
-    if (properties != null && !properties.isEmpty()) {
-      query.select(properties);
+    if (!isEmpty()) {
+      query.selectProperties(this);
     }
 
     if (filterMany != null) {
@@ -219,7 +231,7 @@ public class OrmQueryProperties implements Serializable {
       for (OrmQueryProperties p : secondaryChildren) {
         String path = p.getPath();
         path = path.substring(trimPath);
-        query.fetch(path, p.getProperties(), p.getFetchConfig());
+        query.fetchProperties(path, p);
         query.setFilterMany(path, p.getFilterManyTrimPath(trimPath));
       }
     }
@@ -230,8 +242,7 @@ public class OrmQueryProperties implements Serializable {
   }
 
   public boolean hasSelectClause() {
-    if ("*".equals(properties)) {
-      // explicitly selected all properties
+    if (allProperties) {
       return true;
     }
     // explicitly selected some properties
@@ -241,8 +252,8 @@ public class OrmQueryProperties implements Serializable {
   /**
    * Return true if the properties and configuration are empty.
    */
-  public boolean isEmpty() {
-    return properties == null || properties.isEmpty();
+  boolean isEmpty() {
+    return !allProperties && included == null;
   }
 
   public void asStringDebug(String prefix, StringBuilder sb) {
@@ -250,8 +261,10 @@ public class OrmQueryProperties implements Serializable {
     if (path != null) {
       sb.append(path).append(" ");
     }
-    if (!isEmpty()) {
-      sb.append("(").append(properties).append(")");
+    if (allProperties) {
+      sb.append("(*)");
+    } else if (included != null) {
+      sb.append("(").append(String.join(",", included)).append(")");
     }
   }
 
@@ -269,17 +282,11 @@ public class OrmQueryProperties implements Serializable {
     secondaryChildren.add(child);
   }
 
-  /**
-   * Return the raw properties.
-   */
-  public String getProperties() {
-    return properties;
-  }
-
   /**
    * Return true if this includes all properties on the path.
    */
   public boolean allProperties() {
+    // this is really "default" properties
     return included == null;
   }
 
@@ -326,7 +333,6 @@ public class OrmQueryProperties implements Serializable {
     if (includedBeanJoin != null && includedBeanJoin.contains(propName)) {
       return false;
     }
-    // all properties included
     return included == null || included.contains(propName);
   }
 
@@ -403,7 +409,7 @@ public class OrmQueryProperties implements Serializable {
     if (path != null) {
       builder.append(path);
     }
-    if (included != null){
+    if (included != null) {
       builder.append("/i").append(included);
     }
     if (secondaryQueryJoins != null) {
diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/querydefn/OrmQueryPropertiesParser.java b/ebean-core/src/main/java/io/ebeaninternal/server/querydefn/OrmQueryPropertiesParser.java
index f6f925891..568a6165c 100644
--- a/ebean-core/src/main/java/io/ebeaninternal/server/querydefn/OrmQueryPropertiesParser.java
+++ b/ebean-core/src/main/java/io/ebeaninternal/server/querydefn/OrmQueryPropertiesParser.java
@@ -7,72 +7,43 @@ import java.util.Set;
 /**
  * Parses the path properties string.
  */
-class OrmQueryPropertiesParser {
+final class OrmQueryPropertiesParser {
 
-  private static final Response EMPTY = new Response();
+  private static final Response EMPTY = new Response(false, null);
+  private static final Response ALL = new Response(true, null);
 
   /**
    * Immutable response of the parsed properties and options.
    */
   static class Response {
 
-    final String properties;
+    final boolean allProperties;
     final Set included;
 
-    private Response(String properties, Set included) {
-      this.properties = properties;
+    private Response(boolean allProperties, Set included) {
+      this.allProperties = allProperties;
       this.included = included;
     }
-
-    private Response() {
-      this.properties = "";
-      this.included = null;
-    }
   }
 
   /**
    * Parses the path properties string returning the parsed properties and options.
    * In general it is comma delimited with some special strings like +lazy(20).
    */
-  public static Response parse(String rawProperties) {
-    return new OrmQueryPropertiesParser(rawProperties).parse();
-  }
-
-  private final String inputProperties;
-  private boolean allProperties;
-
-  private OrmQueryPropertiesParser(String inputProperties) {
-    this.inputProperties = inputProperties;
-  }
-
-  /**
-   * Parse the raw string properties input.
-   */
-  private Response parse() {
-    if (inputProperties == null || inputProperties.isEmpty()) {
+  static Response parse(String rawProperties) {
+    if (rawProperties == null || rawProperties.isEmpty()) {
       return EMPTY;
     }
-    if (inputProperties.equals("*")) {
-      return new Response("*", null);
+    if (rawProperties.equals("*")) {
+      return ALL;
     }
-    Set fields = splitRawSelect(inputProperties);
-    for (String val : fields) {
-      if (val.equals("*")) {
-        allProperties = true;
-        break;
-      }
-    }
-    String properties = allProperties ? "*" : inputProperties;
-    if (fields.isEmpty()) {
-      fields = null;
-    }
-    return new Response(properties, fields);
+    return new Response(false, splitRawSelect(rawProperties));
   }
 
   /**
    * Split allowing 'dynamic function based properties'.
    */
-  private Set splitRawSelect(String inputProperties) {
+  private static Set splitRawSelect(String inputProperties) {
     return DSelectColumnsParser.parse(inputProperties);
   }
 
diff --git a/ebean-core/src/test/java/io/ebeaninternal/server/querydefn/OrmQueryPropertiesParserTest.java b/ebean-core/src/test/java/io/ebeaninternal/server/querydefn/OrmQueryPropertiesParserTest.java
index 5160c664e..a7c103b83 100644
--- a/ebean-core/src/test/java/io/ebeaninternal/server/querydefn/OrmQueryPropertiesParserTest.java
+++ b/ebean-core/src/test/java/io/ebeaninternal/server/querydefn/OrmQueryPropertiesParserTest.java
@@ -11,7 +11,8 @@ public class OrmQueryPropertiesParserTest {
 
     OrmQueryPropertiesParser.Response res = OrmQueryPropertiesParser.parse(null);
     assertAllDefaults(res);
-    assertThat(res.properties).isEqualTo("");
+    assertThat(res.allProperties).isFalse();
+    assertThat(res.included).isNull();
   }
 
   @Test
@@ -19,7 +20,8 @@ public class OrmQueryPropertiesParserTest {
 
     OrmQueryPropertiesParser.Response res = OrmQueryPropertiesParser.parse("");
     assertAllDefaults(res);
-    assertThat(res.properties).isEqualTo("");
+    assertThat(res.allProperties).isFalse();
+    assertThat(res.included).isNull();
   }
 
   @Test
@@ -27,13 +29,15 @@ public class OrmQueryPropertiesParserTest {
 
     OrmQueryPropertiesParser.Response res = OrmQueryPropertiesParser.parse("*");
     assertAllDefaults(res);
-    assertThat(res.properties).isEqualTo("*");
+    assertThat(res.allProperties).isTrue();
+    assertThat(res.included).isNull();
   }
 
   @Test
   public void when_no_spaces() {
 
     OrmQueryPropertiesParser.Response res = OrmQueryPropertiesParser.parse("id,name");
+    assertThat(res.allProperties).isFalse();
     assertThat(res.included).containsExactly("id", "name");
   }
 
@@ -41,6 +45,7 @@ public class OrmQueryPropertiesParserTest {
   public void when_spaced() {
 
     OrmQueryPropertiesParser.Response res = OrmQueryPropertiesParser.parse("id, name");
+    assertThat(res.allProperties).isFalse();
     assertThat(res.included).containsExactly("id", "name");
   }
 
@@ -48,6 +53,7 @@ public class OrmQueryPropertiesParserTest {
   public void when_formula() {
 
     OrmQueryPropertiesParser.Response res = OrmQueryPropertiesParser.parse("a,MD5(id::text) as b,c");
+    assertThat(res.allProperties).isFalse();
     assertThat(res.included).containsExactly("a", "MD5(id::text) as b", "c");
   }
 
diff --git a/ebean-core/src/test/java/io/ebeaninternal/server/querydefn/OrmQueryPropertiesTest.java b/ebean-core/src/test/java/io/ebeaninternal/server/querydefn/OrmQueryPropertiesTest.java
index b2ed90fcb..8df439a58 100644
--- a/ebean-core/src/test/java/io/ebeaninternal/server/querydefn/OrmQueryPropertiesTest.java
+++ b/ebean-core/src/test/java/io/ebeaninternal/server/querydefn/OrmQueryPropertiesTest.java
@@ -14,17 +14,12 @@ public class OrmQueryPropertiesTest {
     return sb.toString();
   }
 
-  @Test(expected = NullPointerException.class)
-  public void construct_with_propertySet_when_null() {
-    new OrmQueryProperties(null, (LinkedHashSet) null);
-  }
-
   @Test
   public void construct_with_propertySet_when_empty() {
 
     OrmQueryProperties p1 = new OrmQueryProperties(null, new LinkedHashSet<>());
-    assertThat(p1.getProperties()).isEqualTo("");
     assertThat(p1.allProperties()).isFalse();
+    assertThat(p1.getIncluded()).isEmpty();
   }
 
   @Test
@@ -34,7 +29,7 @@ public class OrmQueryPropertiesTest {
     set.add("name");
     OrmQueryProperties p1 = new OrmQueryProperties(null, set);
 
-    assertThat(p1.getProperties()).isEqualTo("name");
+    assertThat(p1.getIncluded()).containsOnly("name");
     assertThat(p1.allProperties()).isFalse();
   }
 
@@ -47,7 +42,7 @@ public class OrmQueryPropertiesTest {
     set.add("startDate");
     OrmQueryProperties p1 = new OrmQueryProperties(null, set);
 
-    assertThat(p1.getProperties()).isEqualTo("id,name,startDate");
+    assertThat(p1.getIncluded()).containsOnly("id", "name", "startDate");
     assertThat(p1.allProperties()).isFalse();
   }
 
diff --git a/ebean-core/src/test/java/org/tests/basic/lob/TestBasicClobNoVer.java b/ebean-core/src/test/java/org/tests/basic/lob/TestBasicClobNoVer.java
index 0d791db50..f33a42a42 100644
--- a/ebean-core/src/test/java/org/tests/basic/lob/TestBasicClobNoVer.java
+++ b/ebean-core/src/test/java/org/tests/basic/lob/TestBasicClobNoVer.java
@@ -1,12 +1,10 @@
 package org.tests.basic.lob;
 
 import io.ebean.BaseTestCase;
-import io.ebean.Ebean;
-import io.ebean.EbeanServer;
+import io.ebean.DB;
 import io.ebean.Query;
 import org.tests.model.basic.EBasicClobNoVer;
 import org.ebeantest.LoggedSqlCollector;
-import org.junit.Assert;
 import org.junit.Test;
 
 import java.util.List;
@@ -21,53 +19,50 @@ public class TestBasicClobNoVer extends BaseTestCase {
     EBasicClobNoVer entity = new EBasicClobNoVer();
     entity.setName("test");
     entity.setDescription("initialClobValue");
-    EbeanServer server = Ebean.getServer(null);
-    server.save(entity);
-
-
-    String sqlNoClob = "select t0.id, t0.name from ebasic_clob_no_ver t0 where t0.id = ?";
-    String sqlWithClob = "select t0.id, t0.name, t0.description from ebasic_clob_no_ver t0 where t0.id = ?";
-
+    DB.save(entity);
 
     // Clob by default is Fetch Lazy
-    Query defaultQuery = Ebean.find(EBasicClobNoVer.class).setId(entity.getId());
+    Query defaultQuery = DB.find(EBasicClobNoVer.class).setId(entity.getId());
     defaultQuery.findOne();
     String sql = sqlOf(defaultQuery, 2);
 
-    Assert.assertTrue("Clob is fetch lazy by default", sql.contains(sqlNoClob));
+    // default SQL select excludes clob
+    String sqlNoClob = "select t0.id, t0.name from ebasic_clob_no_ver t0 where t0.id = ?";
+    assertThat(sql).contains(sqlNoClob);
 
 
     // Explicitly select * including Clob
-    Query explicitQuery = Ebean.find(EBasicClobNoVer.class).setId(entity.getId()).select("*");
+    Query explicitQuery = DB.find(EBasicClobNoVer.class).setId(entity.getId()).select("*");
 
     explicitQuery.findOne();
     sql = sqlOf(explicitQuery, 2);
 
-    Assert.assertTrue("Explicitly include Clob", sql.contains(sqlWithClob));
+    // Explicitly include Clob
+    String sqlWithClob = "select t0.id, t0.name, t0.description from ebasic_clob_no_ver t0 where t0.id = ?";
+    assertThat(sql).contains(sqlWithClob);
 
     // Update description to test refresh
 
     EBasicClobNoVer updateBean = new EBasicClobNoVer();
     updateBean.setId(entity.getId());
     updateBean.setDescription("modified");
-    Ebean.update(updateBean);
+    DB.update(updateBean);
 
 
     // Test refresh function
 
-    Assert.assertEquals("initialClobValue", entity.getDescription());
+    assertThat(entity.getDescription()).isEqualTo("initialClobValue");
 
     LoggedSqlCollector.start();
 
     // Refresh query includes all properties
-    server.refresh(entity);
+    DB.refresh(entity);
 
     // Assert all properties fetched in refresh
     List loggedSql = LoggedSqlCollector.stop();
-    Assert.assertEquals(1, loggedSql.size());
+    assertThat(loggedSql).hasSize(1);
     assertThat(trimSql(loggedSql.get(0), 2)).contains(sqlWithClob);
-    Assert.assertEquals("modified", entity.getDescription());
-
+    assertThat(entity.getDescription()).isEqualTo("modified");
   }
 
 }
diff --git a/ebean-querybean/pom.xml b/ebean-querybean/pom.xml
index 2fe2570a4..0bdeeb257 100644
--- a/ebean-querybean/pom.xml
+++ b/ebean-querybean/pom.xml
@@ -6,16 +6,6 @@
     io.ebean
     12.7.1-SNAPSHOT
   
-
-
-
-
-
-
-  
-    scm:git:git@github.com:ebean-orm/ebean.git
-    ebean-parent-12.6.5
-  
 
   ebean querybean
   Ebean querybean support
@@ -78,6 +68,13 @@
       test
     
 
+    
+      io.ebean
+      ebean-test
+      12.7.1-SNAPSHOT
+      test
+    
+
     
       org.avaje.composite
       junit
diff --git a/ebean-querybean/src/main/java/io/ebean/typequery/TQAssocBean.java b/ebean-querybean/src/main/java/io/ebean/typequery/TQAssocBean.java
index 9f56b6b13..c54862151 100644
--- a/ebean-querybean/src/main/java/io/ebean/typequery/TQAssocBean.java
+++ b/ebean-querybean/src/main/java/io/ebean/typequery/TQAssocBean.java
@@ -1,6 +1,11 @@
 package io.ebean.typequery;
 
 import io.ebean.ExpressionList;
+import io.ebean.FetchConfig;
+import io.ebeaninternal.api.SpiQueryFetch;
+
+import java.util.LinkedHashSet;
+import java.util.Set;
 
 /**
  * Base type for associated beans.
@@ -11,6 +16,11 @@ import io.ebean.ExpressionList;
 @SuppressWarnings("rawtypes")
 public abstract class TQAssocBean extends TQProperty {
 
+  private static final FetchConfig FETCH_DEFAULT = FetchConfig.ofDefault();
+  private static final FetchConfig FETCH_QUERY = FetchConfig.ofQuery();
+  private static final FetchConfig FETCH_LAZY = FetchConfig.ofLazy();
+  private static final FetchConfig FETCH_CACHE = FetchConfig.ofCache();
+
   /**
    * Construct with a property name and root instance.
    *
@@ -88,9 +98,8 @@ public abstract class TQAssocBean extends TQProperty {
 
   /**
    * Deprecated in favor of fetch().
-   *
-   * @deprecated
    */
+  @Deprecated
   public R fetchAll() {
     return fetch();
   }
@@ -100,8 +109,7 @@ public abstract class TQAssocBean extends TQProperty {
    */
   @SafeVarargs
   protected final R fetchProperties(TQProperty... props) {
-    ((TQRootBean) _root).query().fetch(_name, properties(props));
-    return _root;
+    return fetchWithProperties(FETCH_DEFAULT, props);
   }
 
   /**
@@ -109,8 +117,7 @@ public abstract class TQAssocBean extends TQProperty {
    */
   @SafeVarargs
   protected final R fetchQueryProperties(TQProperty... props) {
-    ((TQRootBean) _root).query().fetchQuery(_name, properties(props));
-    return _root;
+    return fetchWithProperties(FETCH_QUERY, props);
   }
 
   /**
@@ -118,8 +125,7 @@ public abstract class TQAssocBean extends TQProperty {
    */
   @SafeVarargs
   protected final R fetchCacheProperties(TQProperty... props) {
-    ((TQRootBean) _root).query().fetchCache(_name, properties(props));
-    return _root;
+    return fetchWithProperties(FETCH_CACHE, props);
   }
 
   /**
@@ -127,23 +133,26 @@ public abstract class TQAssocBean extends TQProperty {
    */
   @SafeVarargs
   protected final R fetchLazyProperties(TQProperty... props) {
-    ((TQRootBean) _root).query().fetchLazy(_name, properties(props));
+    return fetchWithProperties(FETCH_LAZY, props);
+  }
+
+  @SafeVarargs
+  private final R fetchWithProperties(FetchConfig config, TQProperty... props) {
+    spiQuery().fetchProperties(_name, properties(props), config);
     return _root;
   }
 
-  /**
-   * Append the properties as a comma delimited string.
-   */
+  private final SpiQueryFetch spiQuery() {
+    return (SpiQueryFetch)((TQRootBean) _root).query();
+  }
+
   @SafeVarargs
-  protected final String properties(TQProperty... props) {
-    StringBuilder selectProps = new StringBuilder(50);
-    for (int i = 0; i < props.length; i++) {
-      if (i > 0) {
-        selectProps.append(",");
-      }
-      selectProps.append(props[i].propertyName());
+  private final Set properties(TQProperty... props) {
+    Set set = new LinkedHashSet<>();
+    for (TQProperty prop : props) {
+      set.add(prop.propertyName());
     }
-    return selectProps.toString();
+    return set;
   }
 
   /**
diff --git a/ebean-querybean/src/main/java/io/ebean/typequery/TQRootBean.java b/ebean-querybean/src/main/java/io/ebean/typequery/TQRootBean.java
index 72876a00d..de8f846a6 100644
--- a/ebean-querybean/src/main/java/io/ebean/typequery/TQRootBean.java
+++ b/ebean-querybean/src/main/java/io/ebean/typequery/TQRootBean.java
@@ -25,6 +25,7 @@ import io.ebean.search.TextQueryString;
 import io.ebean.search.TextSimple;
 import io.ebean.service.SpiFetchGroupQuery;
 import io.ebean.text.PathProperties;
+import io.ebeaninternal.api.SpiQueryFetch;
 import io.ebeaninternal.server.util.ArrayStack;
 
 import javax.annotation.Nonnull;
@@ -32,6 +33,7 @@ import javax.annotation.Nullable;
 import java.sql.Connection;
 import java.sql.Timestamp;
 import java.util.Collection;
+import java.util.LinkedHashSet;
 import java.util.List;
 import java.util.Map;
 import java.util.Optional;
@@ -278,22 +280,21 @@ public abstract class TQRootBean {
    */
   @SafeVarargs
   public final R select(TQProperty... properties) {
-    StringBuilder selectProps = new StringBuilder(50);
-    for (int i = 0; i < properties.length; i++) {
-      if (i > 0) {
-        selectProps.append(",");
-      }
-      selectProps.append(properties[i].propertyName());
-    }
-    query.select(selectProps.toString());
+    ((SpiQueryFetch)query).selectProperties(properties(properties));
     return root;
   }
 
+  private Set properties(TQProperty[] properties) {
+    Set props = new LinkedHashSet<>();
+    for (TQProperty property : properties) {
+      props.add(property.propertyName());
+    }
+    return props;
+  }
+
   /**
    * Specify a path to load including all its properties.
-   * 

- * The same as {@link #fetch(String, String)} with the fetchProperties as "*". - *

+ * *
{@code
    *
    * List customers =
diff --git a/ebean-querybean/src/test/java/org/querytest/QOrderTest.java b/ebean-querybean/src/test/java/org/querytest/QOrderTest.java
index ab98f0e67..2f470fdb5 100644
--- a/ebean-querybean/src/test/java/org/querytest/QOrderTest.java
+++ b/ebean-querybean/src/test/java/org/querytest/QOrderTest.java
@@ -1,11 +1,17 @@
 package org.querytest;
 
+import io.ebean.DB;
 import io.ebean.FetchGroup;
+import io.ebean.test.LoggedSql;
 import org.example.domain.Order;
 import org.example.domain.query.QCustomer;
 import org.example.domain.query.QOrder;
 import org.junit.Test;
 
+import java.util.List;
+
+import static org.assertj.core.api.Assertions.assertThat;
+
 public class QOrderTest {
 
   private static final QCustomer cu = QCustomer.alias();
@@ -17,10 +23,14 @@ public class QOrderTest {
     .customer.fetchCache(cu.name, cu.status, cu.registered, cu.comments)
     .buildFetchGroup();
 
+  private static final FetchGroup fg2 = QOrder.forFetchGroup()
+    .select(or.status)
+    .customer.fetch(cu.name)
+    .buildFetchGroup();
+
   @Test
   public void fetchCache() {
 
-
     new QOrder()
       .status.eq(Order.Status.NEW)
       .customer.fetchCache(cu.name, cu.registered)
@@ -35,10 +45,72 @@ public class QOrderTest {
   @Test
   public void viaFetchGraph() {
 
+    DB.getDefault();
+    LoggedSql.start();
+
     new QOrder()
       .status.eq(Order.Status.NEW)
       .select(fg)
       .findList();
+
+
+    final List sql = LoggedSql.stop();
+    assertThat(sql).hasSize(1);
+    assertThat(sql.get(0)).contains("select t0.id, t0.status, t0.ship_date, t0.customer_id from o_order t0 where");
+  }
+
+  @Test
+  public void viaFetchGraph_withJoin() {
+
+    DB.getDefault();
+    LoggedSql.start();
+
+    new QOrder()
+      .status.eq(Order.Status.NEW)
+      .select(fg2)
+      .findList();
+
+
+    final List sql = LoggedSql.stop();
+    assertThat(sql).hasSize(1);
+    assertThat(sql.get(0)).contains("select t0.id, t0.status, t1.id, t1.name from o_order t0 join be_customer t1 on t1.id = t0.customer_id where");
+  }
+
+  @Test
+  public void select_partial() {
+
+    DB.getDefault();
+    LoggedSql.start();
+
+    final QOrder o = QOrder.alias();
+
+    new QOrder()
+      .select(o.status, o.orderDate)
+      .findList();
+
+    final List sql = LoggedSql.stop();
+    assertThat(sql).hasSize(1);
+    assertThat(sql.get(0)).contains("select t0.id, t0.status, t0.order_date from o_order t0");
+  }
+
+  @Test
+  public void fetch_partial() {
+
+    DB.getDefault();
+    LoggedSql.start();
+
+    final QOrder o = QOrder.alias();
+    final QCustomer c = QCustomer.alias();
+
+    new QOrder()
+      .select(o.status)
+      .customer.fetch(c.email, c.name)
+      .findList();
+
+    final List sql = LoggedSql.stop();
+    assertThat(sql).hasSize(1);
+    assertThat(sql.get(0)).contains("select t0.id, t0.status, t1.id, t1.email, t1.name from o_order t0 join be_customer t1 on t1.id = t0.customer_id");
+
   }
 
 }

From e5ec72df5cbc0a836ac36773b0b7d5602f8d4938 Mon Sep 17 00:00:00 2001
From: robin 
Date: Tue, 16 Feb 2021 20:37:58 +1300
Subject: [PATCH 106/447] Refactor internals OrmQueryProperties invert
 isEmpty() -> nonEmpty()

---
 .../server/autotune/service/ProfileOriginTest.java          | 5 +----
 .../io/ebeaninternal/server/querydefn/OrmQueryDetail.java   | 2 +-
 .../ebeaninternal/server/querydefn/OrmQueryProperties.java  | 6 +++---
 3 files changed, 5 insertions(+), 8 deletions(-)

diff --git a/ebean-autotune/src/test/java/io/ebeaninternal/server/autotune/service/ProfileOriginTest.java b/ebean-autotune/src/test/java/io/ebeaninternal/server/autotune/service/ProfileOriginTest.java
index ec0a09596..c3995d215 100644
--- a/ebean-autotune/src/test/java/io/ebeaninternal/server/autotune/service/ProfileOriginTest.java
+++ b/ebean-autotune/src/test/java/io/ebeaninternal/server/autotune/service/ProfileOriginTest.java
@@ -11,12 +11,9 @@ import org.tests.model.basic.Order;
 
 import static org.assertj.core.api.Assertions.assertThat;
 
-//import org.tests.model.basic.ResetBasicData;
-
 public class ProfileOriginTest extends BaseTestCase {
 
-
-  private BeanDescriptor desc = getBeanDescriptor(Order.class);
+  private final BeanDescriptor desc = getBeanDescriptor(Order.class);
 
   @Test
   public void buildDetail() {
diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/querydefn/OrmQueryDetail.java b/ebean-core/src/main/java/io/ebeaninternal/server/querydefn/OrmQueryDetail.java
index 1c441cbf4..ba03b7c78 100644
--- a/ebean-core/src/main/java/io/ebeaninternal/server/querydefn/OrmQueryDetail.java
+++ b/ebean-core/src/main/java/io/ebeaninternal/server/querydefn/OrmQueryDetail.java
@@ -111,7 +111,7 @@ public class OrmQueryDetail implements Serializable {
    */
   public String asStringDebug() {
     StringBuilder sb = new StringBuilder();
-    if (!baseProps.isEmpty()) {
+    if (baseProps.notEmpty()) {
       baseProps.asStringDebug("select ", sb);
     }
     if (fetchPaths != null) {
diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/querydefn/OrmQueryProperties.java b/ebean-core/src/main/java/io/ebeaninternal/server/querydefn/OrmQueryProperties.java
index e84828f09..eb41bb40f 100644
--- a/ebean-core/src/main/java/io/ebeaninternal/server/querydefn/OrmQueryProperties.java
+++ b/ebean-core/src/main/java/io/ebeaninternal/server/querydefn/OrmQueryProperties.java
@@ -214,7 +214,7 @@ public class OrmQueryProperties implements Serializable {
    */
   @SuppressWarnings("unchecked")
   public void configureBeanQuery(SpiQuery query) {
-    if (!isEmpty()) {
+    if (notEmpty()) {
       query.selectProperties(this);
     }
 
@@ -252,8 +252,8 @@ public class OrmQueryProperties implements Serializable {
   /**
    * Return true if the properties and configuration are empty.
    */
-  boolean isEmpty() {
-    return !allProperties && included == null;
+  boolean notEmpty() {
+    return allProperties || included != null;
   }
 
   public void asStringDebug(String prefix, StringBuilder sb) {

From de439e7695b3731c16f1672ced953217d9759391 Mon Sep 17 00:00:00 2001
From: robin 
Date: Tue, 16 Feb 2021 23:20:44 +1300
Subject: [PATCH 107/447] Improve Refactor internals OrmQueryProperties invert
 isEmpty()

Rename to hasProperties() and improve javadoc
---
 .../server/querydefn/OrmQueryDetail.java             |  2 +-
 .../server/querydefn/OrmQueryProperties.java         | 12 ++++--------
 2 files changed, 5 insertions(+), 9 deletions(-)

diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/querydefn/OrmQueryDetail.java b/ebean-core/src/main/java/io/ebeaninternal/server/querydefn/OrmQueryDetail.java
index ba03b7c78..6f96fbbea 100644
--- a/ebean-core/src/main/java/io/ebeaninternal/server/querydefn/OrmQueryDetail.java
+++ b/ebean-core/src/main/java/io/ebeaninternal/server/querydefn/OrmQueryDetail.java
@@ -111,7 +111,7 @@ public class OrmQueryDetail implements Serializable {
    */
   public String asStringDebug() {
     StringBuilder sb = new StringBuilder();
-    if (baseProps.notEmpty()) {
+    if (baseProps.hasProperties()) {
       baseProps.asStringDebug("select ", sb);
     }
     if (fetchPaths != null) {
diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/querydefn/OrmQueryProperties.java b/ebean-core/src/main/java/io/ebeaninternal/server/querydefn/OrmQueryProperties.java
index eb41bb40f..d1a3aeafc 100644
--- a/ebean-core/src/main/java/io/ebeaninternal/server/querydefn/OrmQueryProperties.java
+++ b/ebean-core/src/main/java/io/ebeaninternal/server/querydefn/OrmQueryProperties.java
@@ -214,7 +214,7 @@ public class OrmQueryProperties implements Serializable {
    */
   @SuppressWarnings("unchecked")
   public void configureBeanQuery(SpiQuery query) {
-    if (notEmpty()) {
+    if (hasProperties()) {
       query.selectProperties(this);
     }
 
@@ -242,17 +242,13 @@ public class OrmQueryProperties implements Serializable {
   }
 
   public boolean hasSelectClause() {
-    if (allProperties) {
-      return true;
-    }
-    // explicitly selected some properties
-    return included != null || filterMany != null;
+    return allProperties || included != null || filterMany != null;
   }
 
   /**
-   * Return true if the properties and configuration are empty.
+   * Return true if explicit properties have been specified.
    */
-  boolean notEmpty() {
+  boolean hasProperties() {
     return allProperties || included != null;
   }
 

From 3bb4126e2652425f89c6ffb5db0b0aace1ecd004 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Andr=C3=A9=20Camilo?= 
Date: Wed, 17 Feb 2021 05:04:43 +0000
Subject: [PATCH 108/447] #2169 Support for
 jakarta.validation.constraints.NotNull and (#2170)

jakarta.validation.constraints.Size
---
 CONFIGURATION.md                              |  2 +-
 ebean-api/pom.xml                             |  6 ++
 .../java/io/ebean/config/ClassLoadConfig.java |  7 ++
 .../java/io/ebean/config/DatabaseConfig.java  | 15 ++--
 ebean-core/pom.xml                            |  6 ++
 .../deploy/meta/DeployBeanProperty.java       | 11 ++-
 .../deploy/parse/AnnotationAssocOnes.java     | 12 ++-
 .../server/deploy/parse/AnnotationFields.java | 37 ++++++--
 .../server/deploy/parse/AnnotationParser.java |  9 +-
 .../server/deploy/parse/DeployUtil.java       |  8 +-
 .../InitMetaJakartaValidationAnnotation.java  | 11 +++
 ...=> InitMetaJavaxValidationAnnotation.java} |  2 +-
 .../deploy/parse/ReadAnnotationConfig.java    |  6 ++
 .../server/deploy/parse/ReadAnnotations.java  |  5 +-
 .../org/tests/basic/TestAnnotationBase.java   | 84 +++++++++++++++++++
 15 files changed, 191 insertions(+), 30 deletions(-)
 create mode 100644 ebean-core/src/main/java/io/ebeaninternal/server/deploy/parse/InitMetaJakartaValidationAnnotation.java
 rename ebean-core/src/main/java/io/ebeaninternal/server/deploy/parse/{InitMetaValidationAnnotation.java => InitMetaJavaxValidationAnnotation.java} (85%)

diff --git a/CONFIGURATION.md b/CONFIGURATION.md
index 16fa6d698..46be98f0b 100644
--- a/CONFIGURATION.md
+++ b/CONFIGURATION.md
@@ -293,6 +293,6 @@ ebean.tenant.schemaProvider
 ebean.updateAllPropertiesInBatch
 ebean.updateChangesOnly
 ebean.updatesDeleteMissingChildren
-ebean.useJavaxValidationNotNull
+ebean.useValidationNotNull
 ebean.useJtaTransactionManager
 
diff --git a/ebean-api/pom.xml b/ebean-api/pom.xml
index 0d8e67b00..1edc0a655 100644
--- a/ebean-api/pom.xml
+++ b/ebean-api/pom.xml
@@ -109,6 +109,12 @@
       1.1.0.Final
       true
     
+    
+      jakarta.validation
+      jakarta.validation-api
+      3.0.0
+      true
+    
 
     
       javax.servlet
diff --git a/ebean-api/src/main/java/io/ebean/config/ClassLoadConfig.java b/ebean-api/src/main/java/io/ebean/config/ClassLoadConfig.java
index 821905405..764fa86a1 100644
--- a/ebean-api/src/main/java/io/ebean/config/ClassLoadConfig.java
+++ b/ebean-api/src/main/java/io/ebean/config/ClassLoadConfig.java
@@ -40,6 +40,13 @@ public class ClassLoadConfig {
     return isPresent("javax.validation.constraints.NotNull");
   }
 
+  /**
+   * Return true if jakarta validation annotations like Size and NotNull are present.
+   */
+  public boolean isJakartaValidationAnnotationsPresent() {
+    return isPresent("jakarta.validation.constraints.NotNull");
+  }
+
   /**
    * Return true if javax PostConstruct annotation is present (maybe not in java9).
    * If not we don't support PostConstruct lifecycle events.
diff --git a/ebean-api/src/main/java/io/ebean/config/DatabaseConfig.java b/ebean-api/src/main/java/io/ebean/config/DatabaseConfig.java
index 7ea8e56e9..036a39040 100644
--- a/ebean-api/src/main/java/io/ebean/config/DatabaseConfig.java
+++ b/ebean-api/src/main/java/io/ebean/config/DatabaseConfig.java
@@ -489,7 +489,7 @@ public class DatabaseConfig {
    * Should the javax.validation.constraints.NotNull enforce a notNull column in DB.
    * If set to false, use io.ebean.annotation.NotNull or Column(nullable=true).
    */
-  private boolean useJavaxValidationNotNull = true;
+  private boolean useValidationNotNull = true;
 
   /**
    * Generally we want to perform L2 cache notification in the background and not impact
@@ -2809,7 +2809,7 @@ public class DatabaseConfig {
     enabledL2Regions = p.get("enabledL2Regions", enabledL2Regions);
     notifyL2CacheInForeground = p.getBoolean("notifyL2CacheInForeground", notifyL2CacheInForeground);
     useJtaTransactionManager = p.getBoolean("useJtaTransactionManager", useJtaTransactionManager);
-    useJavaxValidationNotNull = p.getBoolean("useJavaxValidationNotNull", useJavaxValidationNotNull);
+    useValidationNotNull = p.getBoolean("useValidationNotNull", useValidationNotNull);
     autoReadOnlyDataSource = p.getBoolean("autoReadOnlyDataSource", autoReadOnlyDataSource);
     idGeneratorAutomatic = p.getBoolean("idGeneratorAutomatic", idGeneratorAutomatic);
 
@@ -3056,20 +3056,21 @@ public class DatabaseConfig {
   /**
    * Returns if we use javax.validation.constraints.NotNull
    */
-  public boolean isUseJavaxValidationNotNull() {
-    return useJavaxValidationNotNull;
+  public boolean isUseValidationNotNull() {
+    return useValidationNotNull;
   }
 
   /**
-   * Controls if Ebean should ignore &x64;javax.validation.contstraints.NotNull
+   * Controls if Ebean should ignore &x64;javax.validation.contstraints.NotNull or
+   * &x64;jakarta.validation.contstraints.NotNull
    * with respect to generating a NOT NULL column.
    * 

* Normally when Ebean sees javax NotNull annotation it means that column is defined as NOT NULL. * Set this to false and the javax NotNull annotation is effectively ignored (and * we instead use Ebean's own NotNull annotation or JPA Column(nullable=false) annotation. */ - public void setUseJavaxValidationNotNull(boolean useJavaxValidationNotNull) { - this.useJavaxValidationNotNull = useJavaxValidationNotNull; + public void setUseValidationNotNull(boolean useValidationNotNull) { + this.useValidationNotNull = useValidationNotNull; } /** diff --git a/ebean-core/pom.xml b/ebean-core/pom.xml index 20d9cfe6c..dcdad1b0e 100644 --- a/ebean-core/pom.xml +++ b/ebean-core/pom.xml @@ -138,6 +138,12 @@ 1.1.0.Final true + + jakarta.validation + jakarta.validation-api + 3.0.0 + true + joda-time diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/deploy/meta/DeployBeanProperty.java b/ebean-core/src/main/java/io/ebeaninternal/server/deploy/meta/DeployBeanProperty.java index df3a46094..bccc21bcc 100644 --- a/ebean-core/src/main/java/io/ebeaninternal/server/deploy/meta/DeployBeanProperty.java +++ b/ebean-core/src/main/java/io/ebeaninternal/server/deploy/meta/DeployBeanProperty.java @@ -1140,7 +1140,7 @@ public class DeployBeanProperty { return result; } - public List getMetaAnnotationSize() { + public List getMetaAnnotationJavaxSize() { final List size = getMetaAnnotations(Size.class); final List lists = getMetaAnnotations(Size.List.class); for (Size.List list : lists) { @@ -1149,6 +1149,15 @@ public class DeployBeanProperty { return size; } + public List getMetaAnnotationJakartaSize() { + final List size = getMetaAnnotations(jakarta.validation.constraints.Size.class); + final List lists = getMetaAnnotations(jakarta.validation.constraints.Size.List.class); + for (jakarta.validation.constraints.Size.List list : lists) { + Collections.addAll(size, list.value()); + } + return size; + } + public Formula getMetaAnnotationFormula(Platform platform) { Formula fallback = null; for (Annotation ann : metaAnnotations) { diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/deploy/parse/AnnotationAssocOnes.java b/ebean-core/src/main/java/io/ebeaninternal/server/deploy/parse/AnnotationAssocOnes.java index 6750633cb..aa38d93e6 100644 --- a/ebean-core/src/main/java/io/ebeaninternal/server/deploy/parse/AnnotationAssocOnes.java +++ b/ebean-core/src/main/java/io/ebeaninternal/server/deploy/parse/AnnotationAssocOnes.java @@ -4,13 +4,11 @@ import io.ebean.annotation.DbForeignKey; import io.ebean.annotation.FetchPreference; import io.ebean.annotation.TenantId; import io.ebean.annotation.Where; -import io.ebean.config.BeanNotRegisteredException; import io.ebean.config.NamingConvention; import io.ebeaninternal.server.deploy.BeanDescriptorManager; import io.ebeaninternal.server.deploy.BeanTable; import io.ebeaninternal.server.deploy.PropertyForeignKey; import io.ebeaninternal.server.deploy.meta.DeployBeanProperty; -import io.ebeaninternal.server.deploy.meta.DeployBeanPropertyAssoc; import io.ebeaninternal.server.deploy.meta.DeployBeanPropertyAssocOne; import io.ebeaninternal.server.deploy.meta.DeployTableJoinColumn; import io.ebeaninternal.server.query.SqlJoinType; @@ -117,7 +115,7 @@ public class AnnotationAssocOnes extends AnnotationAssoc { if (nonNull != null) { prop.setNullable(false); } - if (validationAnnotations) { + if (javaxValidationAnnotations) { NotNull notNull = get(prop, NotNull.class); if (notNull != null && isEbeanValidationGroups(notNull.groups())) { prop.setNullable(false); @@ -125,6 +123,14 @@ public class AnnotationAssocOnes extends AnnotationAssoc { prop.getTableJoin().setType(SqlJoinType.INNER); } } + if (jakartaValidationAnnotations) { + jakarta.validation.constraints.NotNull notNull = get(prop, jakarta.validation.constraints.NotNull.class); + if (notNull != null && isEbeanValidationGroups(notNull.groups())) { + prop.setNullable(false); + // overrides optional attribute of ManyToOne etc + prop.getTableJoin().setType(SqlJoinType.INNER); + } + } // check for manually defined joins BeanTable beanTable = prop.getBeanTable(); diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/deploy/parse/AnnotationFields.java b/ebean-core/src/main/java/io/ebeaninternal/server/deploy/parse/AnnotationFields.java index aafbfa182..413929098 100644 --- a/ebean-core/src/main/java/io/ebeaninternal/server/deploy/parse/AnnotationFields.java +++ b/ebean-core/src/main/java/io/ebeaninternal/server/deploy/parse/AnnotationFields.java @@ -258,19 +258,38 @@ public class AnnotationFields extends AnnotationParser { } private void initValidation(DeployBeanProperty prop) { - NotNull notNull = get(prop, NotNull.class); - if (notNull != null && isEbeanValidationGroups(notNull.groups())) { - // Not null on all validation groups so enable - // DDL generation of Not Null Constraint - prop.setNullable(false); + if (javaxValidationAnnotations) { + NotNull notNull = get(prop, NotNull.class); + if (notNull != null && isEbeanValidationGroups(notNull.groups())) { + // Not null on all validation groups so enable + // DDL generation of Not Null Constraint + prop.setNullable(false); + } + } + if (jakartaValidationAnnotations) { + jakarta.validation.constraints.NotNull notNull = get(prop, jakarta.validation.constraints.NotNull.class); + if (notNull != null && isEbeanValidationGroups(notNull.groups())) { + // Not null on all validation groups so enable + // DDL generation of Not Null Constraint + prop.setNullable(false); + } } if (!prop.isLob()) { // take the max size of all @Size annotations int maxSize = -1; - for (Size size : prop.getMetaAnnotationSize()) { - if (size.max() < Integer.MAX_VALUE) { - maxSize = Math.max(maxSize, size.max()); + if (javaxValidationAnnotations) { + for (Size size : prop.getMetaAnnotationJavaxSize()) { + if (size.max() < Integer.MAX_VALUE) { + maxSize = Math.max(maxSize, size.max()); + } + } + } + if (jakartaValidationAnnotations) { + for (jakarta.validation.constraints.Size size : prop.getMetaAnnotationJakartaSize()) { + if (size.max() < Integer.MAX_VALUE) { + maxSize = Math.max(maxSize, size.max()); + } } } if (maxSize != -1) { @@ -280,7 +299,7 @@ public class AnnotationFields extends AnnotationParser { } private void initTenantId(DeployBeanProperty prop) { - if (validationAnnotations) { + if (javaxValidationAnnotations || jakartaValidationAnnotations) { initValidation(prop); } if (has(prop, TenantId.class)) { diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/deploy/parse/AnnotationParser.java b/ebean-core/src/main/java/io/ebeaninternal/server/deploy/parse/AnnotationParser.java index 64851135d..8a27981b4 100644 --- a/ebean-core/src/main/java/io/ebeaninternal/server/deploy/parse/AnnotationParser.java +++ b/ebean-core/src/main/java/io/ebeaninternal/server/deploy/parse/AnnotationParser.java @@ -26,14 +26,17 @@ public abstract class AnnotationParser extends AnnotationBase { final Class beanType; - final boolean validationAnnotations; + final boolean javaxValidationAnnotations; + + final boolean jakartaValidationAnnotations; final ReadAnnotationConfig readConfig; AnnotationParser(DeployBeanInfo info, ReadAnnotationConfig readConfig) { super(info.getUtil()); this.readConfig = readConfig; - this.validationAnnotations = readConfig.isJavaxValidationAnnotations(); + this.javaxValidationAnnotations = readConfig.isJavaxValidationAnnotations(); + this.jakartaValidationAnnotations = readConfig.isJakartaValidationAnnotations(); this.info = info; this.beanType = info.getDescriptor().getBeanType(); this.descriptor = info.getDescriptor(); @@ -132,7 +135,7 @@ public abstract class AnnotationParser extends AnnotationBase { * can be applied to DDL generation. */ boolean isEbeanValidationGroups(Class[] groups) { - if (!util.isUseJavaxValidationNotNull()) { + if (!util.isUseValidationNotNull()) { return false; } return groups.length == 0 || groups.length == 1 && Default.class.isAssignableFrom(groups[0]); diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/deploy/parse/DeployUtil.java b/ebean-core/src/main/java/io/ebeaninternal/server/deploy/parse/DeployUtil.java index 3a0f8d826..65c7cf45e 100644 --- a/ebean-core/src/main/java/io/ebeaninternal/server/deploy/parse/DeployUtil.java +++ b/ebean-core/src/main/java/io/ebeaninternal/server/deploy/parse/DeployUtil.java @@ -57,7 +57,7 @@ public class DeployUtil { private final Encryptor bytesEncryptor; - private final boolean useJavaxValidationNotNull; + private final boolean useValidationNotNull; public DeployUtil(TypeManager typeMgr, DatabaseConfig config) { this.typeManager = typeMgr; @@ -67,7 +67,7 @@ public class DeployUtil { this.encryptKeyManager = config.getEncryptKeyManager(); Encryptor be = config.getEncryptor(); this.bytesEncryptor = be != null ? be : new SimpleAesEncryptor(); - this.useJavaxValidationNotNull = config.isUseJavaxValidationNotNull(); + this.useValidationNotNull = config.isUseValidationNotNull(); } public TypeManager getTypeManager() { @@ -286,8 +286,8 @@ public class DeployUtil { return type.equals(String.class); } - boolean isUseJavaxValidationNotNull() { - return useJavaxValidationNotNull; + boolean isUseValidationNotNull() { + return useValidationNotNull; } /** diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/deploy/parse/InitMetaJakartaValidationAnnotation.java b/ebean-core/src/main/java/io/ebeaninternal/server/deploy/parse/InitMetaJakartaValidationAnnotation.java new file mode 100644 index 000000000..41ea9a8c7 --- /dev/null +++ b/ebean-core/src/main/java/io/ebeaninternal/server/deploy/parse/InitMetaJakartaValidationAnnotation.java @@ -0,0 +1,11 @@ +package io.ebeaninternal.server.deploy.parse; + +import jakarta.validation.constraints.Size; + +class InitMetaJakartaValidationAnnotation { + + static void init(ReadAnnotationConfig readConfig) { + readConfig.addMetaAnnotation(Size.class); + readConfig.addMetaAnnotation(Size.List.class); + } +} diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/deploy/parse/InitMetaValidationAnnotation.java b/ebean-core/src/main/java/io/ebeaninternal/server/deploy/parse/InitMetaJavaxValidationAnnotation.java similarity index 85% rename from ebean-core/src/main/java/io/ebeaninternal/server/deploy/parse/InitMetaValidationAnnotation.java rename to ebean-core/src/main/java/io/ebeaninternal/server/deploy/parse/InitMetaJavaxValidationAnnotation.java index 9d5ac9e30..495d26ff5 100644 --- a/ebean-core/src/main/java/io/ebeaninternal/server/deploy/parse/InitMetaValidationAnnotation.java +++ b/ebean-core/src/main/java/io/ebeaninternal/server/deploy/parse/InitMetaJavaxValidationAnnotation.java @@ -2,7 +2,7 @@ package io.ebeaninternal.server.deploy.parse; import javax.validation.constraints.Size; -class InitMetaValidationAnnotation { +class InitMetaJavaxValidationAnnotation { static void init(ReadAnnotationConfig readConfig) { readConfig.addMetaAnnotation(Size.class); diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/deploy/parse/ReadAnnotationConfig.java b/ebean-core/src/main/java/io/ebeaninternal/server/deploy/parse/ReadAnnotationConfig.java index bf96849b0..d7d46e9ce 100644 --- a/ebean-core/src/main/java/io/ebeaninternal/server/deploy/parse/ReadAnnotationConfig.java +++ b/ebean-core/src/main/java/io/ebeaninternal/server/deploy/parse/ReadAnnotationConfig.java @@ -21,6 +21,7 @@ class ReadAnnotationConfig { private final boolean disableL2Cache; private final boolean eagerFetchLobs; private final boolean javaxValidationAnnotations; + private final boolean jakartaValidationAnnotations; private final boolean jacksonAnnotations; private final boolean idGeneratorAutomatic; @@ -34,6 +35,7 @@ class ReadAnnotationConfig { this.eagerFetchLobs = config.isEagerFetchLobs(); this.idGeneratorAutomatic = config.isIdGeneratorAutomatic(); this.javaxValidationAnnotations = generatedPropFactory.getClassLoadConfig().isJavaxValidationAnnotationsPresent(); + this.jakartaValidationAnnotations = generatedPropFactory.getClassLoadConfig().isJakartaValidationAnnotationsPresent(); this.jacksonAnnotations = generatedPropFactory.getClassLoadConfig().isJacksonAnnotationsPresent(); this.metaAnnotations.add(Column.class); this.metaAnnotations.add(Formula.class); @@ -75,6 +77,10 @@ class ReadAnnotationConfig { return javaxValidationAnnotations; } + boolean isJakartaValidationAnnotations() { + return jakartaValidationAnnotations; + } + boolean isJacksonAnnotations() { return jacksonAnnotations; } diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/deploy/parse/ReadAnnotations.java b/ebean-core/src/main/java/io/ebeaninternal/server/deploy/parse/ReadAnnotations.java index 86a6a15f0..796a975aa 100644 --- a/ebean-core/src/main/java/io/ebeaninternal/server/deploy/parse/ReadAnnotations.java +++ b/ebean-core/src/main/java/io/ebeaninternal/server/deploy/parse/ReadAnnotations.java @@ -15,7 +15,10 @@ public class ReadAnnotations { public ReadAnnotations(GeneratedPropertyFactory generatedPropFactory, String asOfViewSuffix, String versionsBetweenSuffix, DatabaseConfig config) { this.readConfig = new ReadAnnotationConfig(generatedPropFactory, asOfViewSuffix, versionsBetweenSuffix, config); if (readConfig.isJavaxValidationAnnotations()) { - InitMetaValidationAnnotation.init(readConfig); + InitMetaJavaxValidationAnnotation.init(readConfig); + } + if (readConfig.isJakartaValidationAnnotations()) { + InitMetaJakartaValidationAnnotation.init(readConfig); } if (readConfig.isJacksonAnnotations()) { InitMetaJacksonAnnotation.init(readConfig); diff --git a/ebean-core/src/test/java/org/tests/basic/TestAnnotationBase.java b/ebean-core/src/test/java/org/tests/basic/TestAnnotationBase.java index aa0e0e926..c5781174d 100644 --- a/ebean-core/src/test/java/org/tests/basic/TestAnnotationBase.java +++ b/ebean-core/src/test/java/org/tests/basic/TestAnnotationBase.java @@ -144,6 +144,69 @@ public class TestAnnotationBase extends BaseTestCase { } } + @Entity + public static class TestJakartaAnnotationBaseEntity extends MappedBaseEntity { + @Where(clause = "SELECT 'mysql' from 1", platforms = Platform.MYSQL) + @Where(clause = "SELECT 'h2' from 1", platforms = H2) + @Where(clause = "SELECT 'other' from 1") + private String direct; + + @MetaTest + private String meta; + + @MetaTest + @Where(clause = "SELECT 'oracle' from 1", platforms = Platform.ORACLE) + private String mixed; + + @jakarta.validation.constraints.Size.List({ + @jakarta.validation.constraints.Size(max = 10, message = "max length for you is 10"), + @jakarta.validation.constraints.Size(min = 1), + @jakarta.validation.constraints.Size(max = 40, message = "max value for you is 40", groups = ValidationGroupSomething.class) + }) + private String constraintAnnotation; + + @NotNull + private String null1; + + + @NotNull(groups = ValidationGroupSomething.class) + private String null2; + + private String null3; + + public String getConstraintAnnotation() { + return constraintAnnotation; + } + + public void setConstraintAnnotation(String constraintAnnotation) { + this.constraintAnnotation = constraintAnnotation; + } + + public String getNull1() { + return null1; + } + + public void setNull1(String null1) { + this.null1 = null1; + } + + public String getNull2() { + return null2; + } + + public void setNull2(String null2) { + this.null2 = null2; + } + + public String getNull3() { + return null3; + } + + public void setNull3(String null3) { + this.null3 = null3; + } + } + @Test public void testFindMaxSize() throws SecurityException { @@ -152,6 +215,13 @@ public class TestAnnotationBase extends BaseTestCase { assertEquals(40, bp.getDbLength()); } + @Test + public void testFindJakartaMaxSize() throws SecurityException { + BeanDescriptor descriptor = spiEbeanServer().getBeanDescriptor(TestJakartaAnnotationBaseEntity.class); + BeanProperty bp = descriptor.findProperty("constraintAnnotation"); + assertEquals(40, bp.getDbLength()); + } + @Test public void annotationClassIndexes() throws SecurityException { BeanDescriptor descriptor = spiEbeanServer().getBeanDescriptor(TestAnnotationBaseEntity.class); @@ -173,6 +243,20 @@ public class TestAnnotationBase extends BaseTestCase { assertTrue(bp.isNullable()); } + @Test + public void testJakartaNotNullWithGroup() throws SecurityException { + BeanDescriptor descriptor = spiEbeanServer().getBeanDescriptor(TestJakartaAnnotationBaseEntity.class); + + BeanProperty bp = descriptor.findProperty("null1"); + assertFalse(bp.isNullable()); + + bp = descriptor.findProperty("null2"); + assertTrue(bp.isNullable()); + + bp = descriptor.findProperty("null3"); + assertTrue(bp.isNullable()); + } + @Test public void testFindAnnotation() throws NoSuchFieldException, SecurityException { From b4ae721998f1e2b1b7982fefd1029e8669f1ed5b Mon Sep 17 00:00:00 2001 From: Rob Bygrave Date: Wed, 17 Feb 2021 22:23:07 +1300 Subject: [PATCH 109/447] #2169 Refactor after #2170 tidy javax/jakarta validation annotation reading (#2171) Introduces ReadValidationAnnotations with javax and jakarta implementations and moves the validation annotation reading there --- ebean-api/pom.xml | 14 ---- .../deploy/meta/DeployBeanProperty.java | 19 ------ .../deploy/parse/AnnotationAssocOnes.java | 20 ++---- .../server/deploy/parse/AnnotationFields.java | 41 ++---------- .../server/deploy/parse/AnnotationParser.java | 18 ------ .../InitMetaJakartaValidationAnnotation.java | 11 ---- .../InitMetaJavaxValidationAnnotation.java | 11 ---- .../deploy/parse/ReadAnnotationConfig.java | 64 +++++++++++++++---- .../server/deploy/parse/ReadAnnotations.java | 9 --- .../parse/ReadValidationAnnotations.java | 19 ++++++ .../ReadValidationAnnotationsJakarta.java | 51 +++++++++++++++ .../parse/ReadValidationAnnotationsJavax.java | 52 +++++++++++++++ 12 files changed, 182 insertions(+), 147 deletions(-) delete mode 100644 ebean-core/src/main/java/io/ebeaninternal/server/deploy/parse/InitMetaJakartaValidationAnnotation.java delete mode 100644 ebean-core/src/main/java/io/ebeaninternal/server/deploy/parse/InitMetaJavaxValidationAnnotation.java create mode 100644 ebean-core/src/main/java/io/ebeaninternal/server/deploy/parse/ReadValidationAnnotations.java create mode 100644 ebean-core/src/main/java/io/ebeaninternal/server/deploy/parse/ReadValidationAnnotationsJakarta.java create mode 100644 ebean-core/src/main/java/io/ebeaninternal/server/deploy/parse/ReadValidationAnnotationsJavax.java diff --git a/ebean-api/pom.xml b/ebean-api/pom.xml index 1edc0a655..80d8db37a 100644 --- a/ebean-api/pom.xml +++ b/ebean-api/pom.xml @@ -102,20 +102,6 @@ true - - - javax.validation - validation-api - 1.1.0.Final - true - - - jakarta.validation - jakarta.validation-api - 3.0.0 - true - - javax.servlet javax.servlet-api diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/deploy/meta/DeployBeanProperty.java b/ebean-core/src/main/java/io/ebeaninternal/server/deploy/meta/DeployBeanProperty.java index bccc21bcc..5b9e8d687 100644 --- a/ebean-core/src/main/java/io/ebeaninternal/server/deploy/meta/DeployBeanProperty.java +++ b/ebean-core/src/main/java/io/ebeaninternal/server/deploy/meta/DeployBeanProperty.java @@ -34,7 +34,6 @@ import javax.persistence.EmbeddedId; import javax.persistence.FetchType; import javax.persistence.Id; import javax.persistence.Version; -import javax.validation.constraints.Size; import java.lang.annotation.Annotation; import java.lang.reflect.Field; import java.lang.reflect.Type; @@ -1140,24 +1139,6 @@ public class DeployBeanProperty { return result; } - public List getMetaAnnotationJavaxSize() { - final List size = getMetaAnnotations(Size.class); - final List lists = getMetaAnnotations(Size.List.class); - for (Size.List list : lists) { - Collections.addAll(size, list.value()); - } - return size; - } - - public List getMetaAnnotationJakartaSize() { - final List size = getMetaAnnotations(jakarta.validation.constraints.Size.class); - final List lists = getMetaAnnotations(jakarta.validation.constraints.Size.List.class); - for (jakarta.validation.constraints.Size.List list : lists) { - Collections.addAll(size, list.value()); - } - return size; - } - public Formula getMetaAnnotationFormula(Platform platform) { Formula fallback = null; for (Annotation ann : metaAnnotations) { diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/deploy/parse/AnnotationAssocOnes.java b/ebean-core/src/main/java/io/ebeaninternal/server/deploy/parse/AnnotationAssocOnes.java index aa38d93e6..d313ce925 100644 --- a/ebean-core/src/main/java/io/ebeaninternal/server/deploy/parse/AnnotationAssocOnes.java +++ b/ebean-core/src/main/java/io/ebeaninternal/server/deploy/parse/AnnotationAssocOnes.java @@ -26,7 +26,6 @@ import javax.persistence.JoinTable; import javax.persistence.ManyToOne; import javax.persistence.OneToOne; import javax.persistence.PrimaryKeyJoinColumn; -import javax.validation.constraints.NotNull; /** * Read the deployment annotations for Associated One beans. @@ -115,21 +114,10 @@ public class AnnotationAssocOnes extends AnnotationAssoc { if (nonNull != null) { prop.setNullable(false); } - if (javaxValidationAnnotations) { - NotNull notNull = get(prop, NotNull.class); - if (notNull != null && isEbeanValidationGroups(notNull.groups())) { - prop.setNullable(false); - // overrides optional attribute of ManyToOne etc - prop.getTableJoin().setType(SqlJoinType.INNER); - } - } - if (jakartaValidationAnnotations) { - jakarta.validation.constraints.NotNull notNull = get(prop, jakarta.validation.constraints.NotNull.class); - if (notNull != null && isEbeanValidationGroups(notNull.groups())) { - prop.setNullable(false); - // overrides optional attribute of ManyToOne etc - prop.getTableJoin().setType(SqlJoinType.INNER); - } + if (readConfig.isValidationNotNull(prop)) { + // overrides optional attribute of ManyToOne etc + prop.setNullable(false); + prop.getTableJoin().setType(SqlJoinType.INNER); } // check for manually defined joins diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/deploy/parse/AnnotationFields.java b/ebean-core/src/main/java/io/ebeaninternal/server/deploy/parse/AnnotationFields.java index 413929098..8079f156f 100644 --- a/ebean-core/src/main/java/io/ebeaninternal/server/deploy/parse/AnnotationFields.java +++ b/ebean-core/src/main/java/io/ebeaninternal/server/deploy/parse/AnnotationFields.java @@ -69,8 +69,6 @@ import javax.persistence.Temporal; import javax.persistence.TemporalType; import javax.persistence.Transient; import javax.persistence.Version; -import javax.validation.constraints.NotNull; -import javax.validation.constraints.Size; import java.sql.Types; import java.util.Set; import java.util.UUID; @@ -258,48 +256,19 @@ public class AnnotationFields extends AnnotationParser { } private void initValidation(DeployBeanProperty prop) { - if (javaxValidationAnnotations) { - NotNull notNull = get(prop, NotNull.class); - if (notNull != null && isEbeanValidationGroups(notNull.groups())) { - // Not null on all validation groups so enable - // DDL generation of Not Null Constraint - prop.setNullable(false); - } + if (readConfig.isValidationNotNull(prop)) { + prop.setNullable(false); } - if (jakartaValidationAnnotations) { - jakarta.validation.constraints.NotNull notNull = get(prop, jakarta.validation.constraints.NotNull.class); - if (notNull != null && isEbeanValidationGroups(notNull.groups())) { - // Not null on all validation groups so enable - // DDL generation of Not Null Constraint - prop.setNullable(false); - } - } - if (!prop.isLob()) { - // take the max size of all @Size annotations - int maxSize = -1; - if (javaxValidationAnnotations) { - for (Size size : prop.getMetaAnnotationJavaxSize()) { - if (size.max() < Integer.MAX_VALUE) { - maxSize = Math.max(maxSize, size.max()); - } - } - } - if (jakartaValidationAnnotations) { - for (jakarta.validation.constraints.Size size : prop.getMetaAnnotationJakartaSize()) { - if (size.max() < Integer.MAX_VALUE) { - maxSize = Math.max(maxSize, size.max()); - } - } - } - if (maxSize != -1) { + int maxSize = readConfig.maxValidationSize(prop); + if (maxSize > 0) { prop.setDbLength(maxSize); } } } private void initTenantId(DeployBeanProperty prop) { - if (javaxValidationAnnotations || jakartaValidationAnnotations) { + if (readConfig.checkValidationAnnotations()) { initValidation(prop); } if (has(prop, TenantId.class)) { diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/deploy/parse/AnnotationParser.java b/ebean-core/src/main/java/io/ebeaninternal/server/deploy/parse/AnnotationParser.java index 8a27981b4..af015e1f5 100644 --- a/ebean-core/src/main/java/io/ebeaninternal/server/deploy/parse/AnnotationParser.java +++ b/ebean-core/src/main/java/io/ebeaninternal/server/deploy/parse/AnnotationParser.java @@ -9,7 +9,6 @@ import io.ebeaninternal.server.deploy.meta.DeployBeanPropertyAssocOne; import javax.persistence.AttributeOverride; import javax.persistence.CascadeType; import javax.persistence.Column; -import javax.validation.groups.Default; import java.util.HashMap; import java.util.Map; import java.util.Set; @@ -26,17 +25,11 @@ public abstract class AnnotationParser extends AnnotationBase { final Class beanType; - final boolean javaxValidationAnnotations; - - final boolean jakartaValidationAnnotations; - final ReadAnnotationConfig readConfig; AnnotationParser(DeployBeanInfo info, ReadAnnotationConfig readConfig) { super(info.getUtil()); this.readConfig = readConfig; - this.javaxValidationAnnotations = readConfig.isJavaxValidationAnnotations(); - this.jakartaValidationAnnotations = readConfig.isJakartaValidationAnnotations(); this.info = info; this.beanType = info.getDescriptor().getBeanType(); this.descriptor = info.getDescriptor(); @@ -130,17 +123,6 @@ public abstract class AnnotationParser extends AnnotationBase { } } - /** - * Return true if the validation groups are {@link Default} (respectively empty) - * can be applied to DDL generation. - */ - boolean isEbeanValidationGroups(Class[] groups) { - if (!util.isUseValidationNotNull()) { - return false; - } - return groups.length == 0 || groups.length == 1 && Default.class.isAssignableFrom(groups[0]); - } - String[] convertColumnNames(String[] columnNames) { for (int i = 0; i < columnNames.length; i++) { columnNames[i] = databasePlatform.convertQuotedIdentifiers(columnNames[i]); diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/deploy/parse/InitMetaJakartaValidationAnnotation.java b/ebean-core/src/main/java/io/ebeaninternal/server/deploy/parse/InitMetaJakartaValidationAnnotation.java deleted file mode 100644 index 41ea9a8c7..000000000 --- a/ebean-core/src/main/java/io/ebeaninternal/server/deploy/parse/InitMetaJakartaValidationAnnotation.java +++ /dev/null @@ -1,11 +0,0 @@ -package io.ebeaninternal.server.deploy.parse; - -import jakarta.validation.constraints.Size; - -class InitMetaJakartaValidationAnnotation { - - static void init(ReadAnnotationConfig readConfig) { - readConfig.addMetaAnnotation(Size.class); - readConfig.addMetaAnnotation(Size.List.class); - } -} diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/deploy/parse/InitMetaJavaxValidationAnnotation.java b/ebean-core/src/main/java/io/ebeaninternal/server/deploy/parse/InitMetaJavaxValidationAnnotation.java deleted file mode 100644 index 495d26ff5..000000000 --- a/ebean-core/src/main/java/io/ebeaninternal/server/deploy/parse/InitMetaJavaxValidationAnnotation.java +++ /dev/null @@ -1,11 +0,0 @@ -package io.ebeaninternal.server.deploy.parse; - -import javax.validation.constraints.Size; - -class InitMetaJavaxValidationAnnotation { - - static void init(ReadAnnotationConfig readConfig) { - readConfig.addMetaAnnotation(Size.class); - readConfig.addMetaAnnotation(Size.List.class); - } -} diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/deploy/parse/ReadAnnotationConfig.java b/ebean-core/src/main/java/io/ebeaninternal/server/deploy/parse/ReadAnnotationConfig.java index d7d46e9ce..1daf37564 100644 --- a/ebean-core/src/main/java/io/ebeaninternal/server/deploy/parse/ReadAnnotationConfig.java +++ b/ebean-core/src/main/java/io/ebeaninternal/server/deploy/parse/ReadAnnotationConfig.java @@ -3,8 +3,10 @@ package io.ebeaninternal.server.deploy.parse; import io.ebean.annotation.Aggregation; import io.ebean.annotation.Formula; import io.ebean.annotation.Where; +import io.ebean.config.ClassLoadConfig; import io.ebean.config.DatabaseConfig; import io.ebeaninternal.server.deploy.generatedproperty.GeneratedPropertyFactory; +import io.ebeaninternal.server.deploy.meta.DeployBeanProperty; import javax.persistence.Column; import java.util.HashSet; @@ -24,7 +26,9 @@ class ReadAnnotationConfig { private final boolean jakartaValidationAnnotations; private final boolean jacksonAnnotations; private final boolean idGeneratorAutomatic; - + private final boolean useValidationNotNull; + private final ReadValidationAnnotations javaxValidation; + private final ReadValidationAnnotations jakartaValidation; private final Set> metaAnnotations = new HashSet<>(); ReadAnnotationConfig(GeneratedPropertyFactory generatedPropFactory, String asOfViewSuffix, String versionsBetweenSuffix, DatabaseConfig config) { @@ -34,21 +38,32 @@ class ReadAnnotationConfig { this.disableL2Cache = config.isDisableL2Cache(); this.eagerFetchLobs = config.isEagerFetchLobs(); this.idGeneratorAutomatic = config.isIdGeneratorAutomatic(); - this.javaxValidationAnnotations = generatedPropFactory.getClassLoadConfig().isJavaxValidationAnnotationsPresent(); - this.jakartaValidationAnnotations = generatedPropFactory.getClassLoadConfig().isJakartaValidationAnnotationsPresent(); - this.jacksonAnnotations = generatedPropFactory.getClassLoadConfig().isJacksonAnnotationsPresent(); + this.useValidationNotNull = config.isUseValidationNotNull(); + ClassLoadConfig classLoadConfig = generatedPropFactory.getClassLoadConfig(); + this.javaxValidationAnnotations = classLoadConfig.isJavaxValidationAnnotationsPresent(); + this.jakartaValidationAnnotations = classLoadConfig.isJakartaValidationAnnotationsPresent(); + this.jacksonAnnotations = classLoadConfig.isJacksonAnnotationsPresent(); this.metaAnnotations.add(Column.class); this.metaAnnotations.add(Formula.class); this.metaAnnotations.add(Formula.List.class); this.metaAnnotations.add(Where.class); this.metaAnnotations.add(Where.List.class); this.metaAnnotations.add(Aggregation.class); + this.javaxValidation = javaxValidationAnnotations ? new ReadValidationAnnotationsJavax(this) : null; + this.jakartaValidation = jakartaValidationAnnotations ? new ReadValidationAnnotationsJakarta(this) : null; + if (jacksonAnnotations) { + InitMetaJacksonAnnotation.init(this); + } } - public void addMetaAnnotation(Class annotation) { + void addMetaAnnotation(Class annotation) { metaAnnotations.add(annotation); } + boolean checkValidationAnnotations() { + return javaxValidationAnnotations || jakartaValidationAnnotations; + } + GeneratedPropertyFactory getGeneratedPropFactory() { return generatedPropFactory; } @@ -73,14 +88,6 @@ class ReadAnnotationConfig { return idGeneratorAutomatic; } - boolean isJavaxValidationAnnotations() { - return javaxValidationAnnotations; - } - - boolean isJakartaValidationAnnotations() { - return jakartaValidationAnnotations; - } - boolean isJacksonAnnotations() { return jacksonAnnotations; } @@ -88,4 +95,35 @@ class ReadAnnotationConfig { public Set> getMetaAnnotations() { return metaAnnotations; } + + /** + * Return true if a NotNull validation annotation is on the property. + */ + boolean isValidationNotNull(DeployBeanProperty property) { + if (!useValidationNotNull) { + return false; + } + if (javaxValidation != null && javaxValidation.isValidationNotNull(property)) { + return true; + } + if (jakartaValidation != null && jakartaValidation.isValidationNotNull(property)) { + return true; + } + return false; + } + + /** + * Return the max size of all validation @Size annotations. + */ + int maxValidationSize(DeployBeanProperty prop) { + int maxSize = 0; + if (javaxValidation != null) { + maxSize = Math.max(maxSize, javaxValidation.maxSize(prop)); + } + if (jakartaValidation != null) { + maxSize = Math.max(maxSize, jakartaValidation.maxSize(prop)); + } + return maxSize; + } + } diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/deploy/parse/ReadAnnotations.java b/ebean-core/src/main/java/io/ebeaninternal/server/deploy/parse/ReadAnnotations.java index 796a975aa..da2bc6030 100644 --- a/ebean-core/src/main/java/io/ebeaninternal/server/deploy/parse/ReadAnnotations.java +++ b/ebean-core/src/main/java/io/ebeaninternal/server/deploy/parse/ReadAnnotations.java @@ -14,15 +14,6 @@ public class ReadAnnotations { public ReadAnnotations(GeneratedPropertyFactory generatedPropFactory, String asOfViewSuffix, String versionsBetweenSuffix, DatabaseConfig config) { this.readConfig = new ReadAnnotationConfig(generatedPropFactory, asOfViewSuffix, versionsBetweenSuffix, config); - if (readConfig.isJavaxValidationAnnotations()) { - InitMetaJavaxValidationAnnotation.init(readConfig); - } - if (readConfig.isJakartaValidationAnnotations()) { - InitMetaJakartaValidationAnnotation.init(readConfig); - } - if (readConfig.isJacksonAnnotations()) { - InitMetaJacksonAnnotation.init(readConfig); - } } /** diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/deploy/parse/ReadValidationAnnotations.java b/ebean-core/src/main/java/io/ebeaninternal/server/deploy/parse/ReadValidationAnnotations.java new file mode 100644 index 000000000..a2c0b8890 --- /dev/null +++ b/ebean-core/src/main/java/io/ebeaninternal/server/deploy/parse/ReadValidationAnnotations.java @@ -0,0 +1,19 @@ +package io.ebeaninternal.server.deploy.parse; + +import io.ebeaninternal.server.deploy.meta.DeployBeanProperty; + +/** + * Reads validation NotNull and Size annotations for mapping. + */ +interface ReadValidationAnnotations { + + /** + * Return true if the property has a NotNull validation annotation. + */ + boolean isValidationNotNull(DeployBeanProperty property); + + /** + * Return the max value of the Size validation annotations on the property. + */ + int maxSize(DeployBeanProperty property); +} diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/deploy/parse/ReadValidationAnnotationsJakarta.java b/ebean-core/src/main/java/io/ebeaninternal/server/deploy/parse/ReadValidationAnnotationsJakarta.java new file mode 100644 index 000000000..016e9f13a --- /dev/null +++ b/ebean-core/src/main/java/io/ebeaninternal/server/deploy/parse/ReadValidationAnnotationsJakarta.java @@ -0,0 +1,51 @@ +package io.ebeaninternal.server.deploy.parse; + +import io.ebean.util.AnnotationUtil; +import io.ebeaninternal.server.deploy.meta.DeployBeanProperty; +import jakarta.validation.constraints.NotNull; +import jakarta.validation.constraints.Size; +import jakarta.validation.groups.Default; + +import java.util.Collections; +import java.util.List; + +/** + * Jakarta validation annotations reader. + */ +class ReadValidationAnnotationsJakarta implements ReadValidationAnnotations { + + ReadValidationAnnotationsJakarta(ReadAnnotationConfig readConfig) { + readConfig.addMetaAnnotation(Size.class); + readConfig.addMetaAnnotation(Size.List.class); + } + + @Override + public boolean isValidationNotNull(DeployBeanProperty property) { + NotNull notNull = AnnotationUtil.get(property.getField(), NotNull.class); + return (notNull != null && isEbeanValidationGroups(notNull.groups())); + } + + private boolean isEbeanValidationGroups(Class[] groups) { + return groups.length == 0 || groups.length == 1 && Default.class.isAssignableFrom(groups[0]); + } + + @Override + public int maxSize(DeployBeanProperty property) { + int maxSize = 0; + for (Size size : getMetaAnnotationJavaxSize(property)) { + if (size.max() < Integer.MAX_VALUE) { + maxSize = Math.max(maxSize, size.max()); + } + } + return maxSize; + } + + private List getMetaAnnotationJavaxSize(DeployBeanProperty prop) { + final List size = prop.getMetaAnnotations(Size.class); + final List lists = prop.getMetaAnnotations(Size.List.class); + for (Size.List list : lists) { + Collections.addAll(size, list.value()); + } + return size; + } +} diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/deploy/parse/ReadValidationAnnotationsJavax.java b/ebean-core/src/main/java/io/ebeaninternal/server/deploy/parse/ReadValidationAnnotationsJavax.java new file mode 100644 index 000000000..a690e69de --- /dev/null +++ b/ebean-core/src/main/java/io/ebeaninternal/server/deploy/parse/ReadValidationAnnotationsJavax.java @@ -0,0 +1,52 @@ +package io.ebeaninternal.server.deploy.parse; + +import io.ebean.util.AnnotationUtil; +import io.ebeaninternal.server.deploy.meta.DeployBeanProperty; + +import javax.validation.constraints.NotNull; +import javax.validation.constraints.Size; +import javax.validation.groups.Default; +import java.util.Collections; +import java.util.List; + +/** + * Javax validation annotations reader. + */ +class ReadValidationAnnotationsJavax implements ReadValidationAnnotations { + + ReadValidationAnnotationsJavax(ReadAnnotationConfig readConfig) { + readConfig.addMetaAnnotation(Size.class); + readConfig.addMetaAnnotation(Size.List.class); + } + + @Override + public boolean isValidationNotNull(DeployBeanProperty property) { + NotNull notNull = AnnotationUtil.get(property.getField(), NotNull.class); + return (notNull != null && isEbeanValidationGroups(notNull.groups())); + } + + private boolean isEbeanValidationGroups(Class[] groups) { + return groups.length == 0 || groups.length == 1 && Default.class.isAssignableFrom(groups[0]); + } + + @Override + public int maxSize(DeployBeanProperty prop) { + int maxSize = 0; + for (Size size : getMetaAnnotationJavaxSize(prop)) { + if (size.max() < Integer.MAX_VALUE) { + maxSize = Math.max(maxSize, size.max()); + } + } + return maxSize; + } + + private List getMetaAnnotationJavaxSize(DeployBeanProperty prop) { + final List size = prop.getMetaAnnotations(Size.class); + final List lists = prop.getMetaAnnotations(Size.List.class); + for (Size.List list : lists) { + Collections.addAll(size, list.value()); + } + return size; + } + +} From b7da2cbd97d0c80e6763433861852138cd990161 Mon Sep 17 00:00:00 2001 From: Robin Bygrave Date: Fri, 19 Feb 2021 09:29:06 +1300 Subject: [PATCH 110/447] #2173 - ebean-test: Add assertContains - DbJson.of(entityBean).assertContains(...) --- ebean-test/pom.xml | 20 +-- .../src/main/java/io/ebean/test/DbJson.java | 101 ++++++++--- .../src/main/java/io/ebean/test/IOUtils.java | 12 ++ .../src/main/java/io/ebean/test/Json.java | 168 ++++++++++++++++++ .../io/ebean/test/JsonAssertContains.java | 118 ++++++++++++ .../test/java/io/ebean/test/DbJsonTest.java | 33 ++++ .../io/ebean/test/JsonAssertContainsTest.java | 86 +++++++++ .../src/test/java/io/ebean/test/JsonTest.java | 75 ++++++++ .../test/java/org/test/BSimpleWithGen.java | 7 + .../src/test/java/org/test/PlainBean.java | 22 +++ .../test/resources/bean/contains-minimal.json | 4 + .../resources/bean/contains-with-version.json | 5 + .../src/test/resources/bean/example-bean.json | 1 + .../src/test/resources/bean/example-list.json | 2 + .../resources/contains/check-null-actual.json | 9 + .../contains/check-null-expected.json | 7 + .../resources/contains/check-type-actual.json | 3 + .../contains/check-type-expected.json | 3 + .../contains/original-subset-modified.json | 26 +++ .../resources/contains/original-subset.json | 15 ++ .../src/test/resources/contains/original.json | 27 +++ .../test/resources/example/plain-list.json | 10 ++ .../src/test/resources/example/plain.json | 4 + 23 files changed, 727 insertions(+), 31 deletions(-) create mode 100644 ebean-test/src/main/java/io/ebean/test/Json.java create mode 100644 ebean-test/src/main/java/io/ebean/test/JsonAssertContains.java create mode 100644 ebean-test/src/test/java/io/ebean/test/JsonAssertContainsTest.java create mode 100644 ebean-test/src/test/java/io/ebean/test/JsonTest.java create mode 100644 ebean-test/src/test/java/org/test/PlainBean.java create mode 100644 ebean-test/src/test/resources/bean/contains-minimal.json create mode 100644 ebean-test/src/test/resources/bean/contains-with-version.json create mode 100644 ebean-test/src/test/resources/contains/check-null-actual.json create mode 100644 ebean-test/src/test/resources/contains/check-null-expected.json create mode 100644 ebean-test/src/test/resources/contains/check-type-actual.json create mode 100644 ebean-test/src/test/resources/contains/check-type-expected.json create mode 100644 ebean-test/src/test/resources/contains/original-subset-modified.json create mode 100644 ebean-test/src/test/resources/contains/original-subset.json create mode 100644 ebean-test/src/test/resources/contains/original.json create mode 100644 ebean-test/src/test/resources/example/plain-list.json create mode 100644 ebean-test/src/test/resources/example/plain.json diff --git a/ebean-test/pom.xml b/ebean-test/pom.xml index 92f4c590f..caef82218 100644 --- a/ebean-test/pom.xml +++ b/ebean-test/pom.xml @@ -1,21 +1,12 @@ - + 4.0.0 ebean-parent io.ebean 12.7.1-SNAPSHOT - - - - - - - - scm:git:git@github.com:ebean-orm/ebean.git - ebean-parent-12.6.5 - ebean test Testing support for Ebean @@ -60,6 +51,13 @@ true + + com.fasterxml.jackson.datatype + jackson-datatype-jsr310 + ${jackson-databind.version} + true + + io.ebean ebean-test-docker diff --git a/ebean-test/src/main/java/io/ebean/test/DbJson.java b/ebean-test/src/main/java/io/ebean/test/DbJson.java index 79de39099..3675063c1 100644 --- a/ebean-test/src/main/java/io/ebean/test/DbJson.java +++ b/ebean-test/src/main/java/io/ebean/test/DbJson.java @@ -2,34 +2,63 @@ package io.ebean.test; import io.ebean.DB; -import java.io.IOException; -import java.io.InputStream; - import static org.assertj.core.api.Assertions.assertThat; /** * Helper for testing to assert that the JSON form of an entity - * or list of entities match a String / typically test resource. + * or list of entities is as expected. + *

+ * Using assertContains() we can match the JSON form of an entity + * against a subset of JSON content. Typically the subset of JSON + * excludes generated properties like id, when created and + * when modified properties. + *

+ * + *

Assert contains

+ *
{@code
+ *
+ *    DbJson.of(order)
+ *      .assertContains("/order-partial.json");
+ *
+ * }
+ * + * + *

Assert content matches

+ *

+ * Using assertContentMatches() we are doing an exact content match. + * We typically need to replace generated property values. This assert + * will start to fail if the model changes like adding a property to + * the entity so we should use it less widely due to the maintenance + * burden we have with it. + *

* *
{@code
  *
- *    DbJson.of(timedEntries)
- *      .replace("id", "eventTime")
- *      .assertContentMatches("/assertJson/full-1-timed.json");
+ *    DbJson.of(order)
+ *      .replace("id", "whenCreated", "whenModified)
+ *      .assertContentMatches("/order-full.json");
  *
  * }
*/ public class DbJson { /** - * Create a PrettyJson object that has the JSON form of the - * entity bean or beans. + * Create a PrettyJson object that has the JSON form of the entity bean or beans. * + *

Assert contains

*
{@code
    *
-   *    DbJson.of(timedEntries)
-   *      .replace("id", "eventTime")
-   *      .assertContentMatches("/assertJson/full-1-timed.json");
+   *    DbJson.of(order)
+   *      .assertContains("/order-partial.json");
+   *
+   * }
+ * + *

Assert content matches

+ *
{@code
+   *
+   *    DbJson.of(order)
+   *      .replace("id", "whenCreated", "whenModified)
+   *      .assertContentMatches("/order-full.json");
    *
    * }
*/ @@ -41,12 +70,7 @@ public class DbJson { * Read the content for the given resource path. */ public static String readResource(String resourcePath) { - InputStream is = DbJson.class.getResourceAsStream(resourcePath); - try { - return IOUtils.readUtf8(is).trim(); - } catch (IOException e) { - throw new IllegalArgumentException(e); - } + return IOUtils.readResource(resourcePath); } /** @@ -92,7 +116,7 @@ public class DbJson { } /** - * Assert the json matches the content at the given resource path. + * Assert the json exactly matches the content at the given resource path. * *
{@code
      *
@@ -103,7 +127,44 @@ public class DbJson {
      * }
*/ public void assertContentMatches(String resourcePath) { - assertThat(rawJson).isEqualTo(readResource(resourcePath)); + assertThat(lineEnd(rawJson)).isEqualTo(lineEnd(readResource(resourcePath))); + } + + /** + * Normalise line ending characters to just use new line. + */ + private String lineEnd(String content) { + return content.replace("\r\n", "\n"); + } + + /** + * Assert the DB json contains the given json content. + *

+ * With this "contains" check the DB Json can contain more content than what + * it is checked against. Typically the DB json can contain generated properties + * like id values, when created, when modified etc and we leave these out of the + * json content we are checking against. + *

+ * + * @param json The subset json content that should be contained by the DB json. + */ + public void assertContains(String json) { + Json.assertContains(rawJson, json); + } + + /** + * Assert the DB Json contains the Json at the given resource path. + *

+ * With this "contains" check the DB Json can contain more content than what + * it is checked against. Typically the DB json can contain generated properties + * like id values, when created, when modified etc and we leave these out of the + * json content we are checking against. + *

+ * + * @param resourcePath The resource path of the JSON content we are checking against. + */ + public void assertContainsResource(String resourcePath) { + assertContains(readResource(resourcePath)); } } } diff --git a/ebean-test/src/main/java/io/ebean/test/IOUtils.java b/ebean-test/src/main/java/io/ebean/test/IOUtils.java index 79b706706..a9b98086b 100644 --- a/ebean-test/src/main/java/io/ebean/test/IOUtils.java +++ b/ebean-test/src/main/java/io/ebean/test/IOUtils.java @@ -11,6 +11,18 @@ import java.nio.charset.StandardCharsets; */ class IOUtils { + /** + * Read the content for the given resource path. + */ + static String readResource(String resourcePath) { + try { + InputStream is = IOUtils.class.getResourceAsStream(resourcePath); + return IOUtils.readUtf8(is).trim(); + } catch (IOException e) { + throw new IllegalArgumentException("Error reading resource " + resourcePath, e); + } + } + /** * Reads the entire contents of the specified input stream and return them as UTF-8 string. */ diff --git a/ebean-test/src/main/java/io/ebean/test/Json.java b/ebean-test/src/main/java/io/ebean/test/Json.java new file mode 100644 index 000000000..7612757e3 --- /dev/null +++ b/ebean-test/src/main/java/io/ebean/test/Json.java @@ -0,0 +1,168 @@ +package io.ebean.test; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.databind.DeserializationFeature; +import com.fasterxml.jackson.databind.JsonNode; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.databind.SerializationFeature; +import com.fasterxml.jackson.databind.type.CollectionType; +import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule; + +import java.io.IOException; +import java.util.List; + +/** + * Helper to convert to and from json using Jackson object mapper and + * perform some useful asserts based on json content. + */ +public class Json { + + /** + * For reading resource json content into a bean, list or jsonNode in a fluid style. + */ + public static class Resource { + private final String resourcePath; + + private Resource(String resourcePath) { + this.resourcePath = resourcePath; + } + + /** + * Return as a plain bean. + */ + T asBean(Class cls) { + return Json.read(cls, readResource(resourcePath)); + } + + /** + * Return as a list of beans. + */ + List asList(Class cls) { + return Json.readList(cls, readResource(resourcePath)); + } + + /** + * Return as a JsonNode. + */ + JsonNode asNode() { + return Json.readNodeFromResource(resourcePath); + } + } + + private static final ObjectMapper MAPPER = initMapper(); + + /** + * For fluid style reading resource json content and return as a + * bean, list of bean or JsonNode. + *
{@code
+   *
+   *   PlainBean bean =
+   *     Json.resource("/example/plain-list.json").asBean(PlainBean.class);
+   *
+   *   List list =
+   *     Json.resource("/example/plain-list.json").asList(PlainBean.class);
+   *
+   *   JsonNode jsonNode =
+   *     Json.resource("/example/plain-list.json").asJsonNode();
+   *
+   * }
+ * + * @param resourcePath The resource path where the json content is read from + * @return The resource to convert to a bean or jsonNode etc + */ + public static Resource resource(String resourcePath) { + return new Resource(resourcePath); + } + + /** + * Assert all the fields in the expectedJson are present in actualJson and values match. + */ + public static void assertContains(String actualJson, String expectedJson) { + assertContains(readNode(actualJson), readNode(expectedJson)); + } + + /** + * Assert all the fields in the expectedJson are present in actualJson and values match. + */ + public static void assertContains(JsonNode actualJsonNode, JsonNode expectedJsonNode) { + JsonAssertContains.assertContains(actualJsonNode, expectedJsonNode); + } + + /** + * Read the content for the given resource path. + */ + public static String readResource(String resourcePath) { + return IOUtils.readResource(resourcePath); + } + + /** + * Return a bean from json content of a resource path. + */ + public static T readFromResource(Class type, String resourcePath) { + return read(type, readResource(resourcePath)); + } + + /** + * Return a typed object from json content. + */ + public static T read(Class type, String json) { + try { + return MAPPER.readValue(json, type); + } catch (IOException e) { + throw new RuntimeException(e); + } + } + + /** + * Return a list of a given type from json content. + */ + public static List readList(Class type, String json) { + final CollectionType collectionType = MAPPER.getTypeFactory().constructCollectionType(List.class, type); + try { + return MAPPER.readValue(json, collectionType); + } catch (IOException e) { + throw new RuntimeException(e); + } + } + + /** + * Parse json into a generic JsonNode structure from resource. + */ + public static JsonNode readNodeFromResource(String resourcePath) { + return readNode(IOUtils.readResource(resourcePath)); + } + + /** + * Parse json into a generic JsonNode structure. + */ + public static JsonNode readNode(String json) { + try { + return MAPPER.readTree(json); + } catch (IOException e) { + throw new RuntimeException(e); + } + } + + /** + * Serialize object to string + */ + public static String toJsonString(Object bean) { + try { + return MAPPER.writeValueAsString(bean); + } catch (IOException e) { + throw new RuntimeException(e); + } + } + + private static ObjectMapper initMapper() { + return new ObjectMapper() + .registerModule(new JavaTimeModule()) + .configure(SerializationFeature.INDENT_OUTPUT, true) + .configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false) + .configure(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS, false) + .configure(SerializationFeature.FAIL_ON_EMPTY_BEANS, false) + .configure(SerializationFeature.INDENT_OUTPUT, true) + .setSerializationInclusion(JsonInclude.Include.NON_NULL); + } + +} diff --git a/ebean-test/src/main/java/io/ebean/test/JsonAssertContains.java b/ebean-test/src/main/java/io/ebean/test/JsonAssertContains.java new file mode 100644 index 000000000..25e1e065a --- /dev/null +++ b/ebean-test/src/main/java/io/ebean/test/JsonAssertContains.java @@ -0,0 +1,118 @@ +package io.ebean.test; + +import com.fasterxml.jackson.databind.JsonNode; +import org.assertj.core.api.Assertions; + +import java.util.Iterator; +import java.util.LinkedList; +import java.util.Map; +import java.util.Stack; + +/** + * Perform traversal of JsonNodes comparing against an expected JsonNode that + * typically contains a subset of the data (typically excludes any generated properties + * like when modified timestamps etc). + */ +class JsonAssertContains { + + private final Stack path = new Stack<>(); + private final LinkedList errors = new LinkedList<>(); + + static void assertContains(JsonNode actualJsonNode, JsonNode expectedJsonNode) { + new JsonAssertContains().contains(actualJsonNode, expectedJsonNode); + } + + private void contains(JsonNode actualJsonNode, JsonNode expectedJsonNode) { + checkRecursive(null, actualJsonNode, expectedJsonNode); + if (!errors.isEmpty()) { + String errorsString = String.join("\n", errors); + errorsString += "\nExpected JSON fields: " + expectedJsonNode; + errorsString += "\nActual JSON: " + actualJsonNode; + Assertions.fail(errorsString); + } + } + + private void checkRecursive(String name, JsonNode actualJsonNode, JsonNode expectedJsonNode) { + if (name != null) { + path.push(name); + } + if (checkNull(actualJsonNode, expectedJsonNode)) { + if (checkType(actualJsonNode, expectedJsonNode)) { + if (checkArray(actualJsonNode, expectedJsonNode)) { + if (checkObject(actualJsonNode, expectedJsonNode)) { + checkValue(actualJsonNode, expectedJsonNode); + } + } + } + } + if (name != null) { + path.pop(); + } + } + + private boolean checkNull(JsonNode actualJsonNode, JsonNode expectedJsonNode) { + if (actualJsonNode == null) { + errors.add(String.format("Expected field '%s' to be '%s' but was null", path(), expectedJsonNode)); + return false; + } + return true; + } + + private boolean checkType(JsonNode actualJsonNode, JsonNode expectedJsonNode) { + if (!expectedJsonNode.getNodeType().equals(actualJsonNode.getNodeType())) { + errors.add(String.format("Expected field '%s' to be of type '%s' but was '%s'", path(), expectedJsonNode.getNodeType(), actualJsonNode.getNodeType())); + return false; + } + return true; + } + + private boolean checkArray(JsonNode actualJsonNode, JsonNode expectedJsonNode) { + if (!expectedJsonNode.isArray()) { + return true; + } + for (int i = 0; i < expectedJsonNode.size(); i++) { + checkRecursive("[" + i + "]", actualJsonNode.get(i), expectedJsonNode.get(i)); + } + // do not continue (object or scalar type check) + return false; + } + + private boolean checkObject(JsonNode actualJsonNode, JsonNode expectedJsonNode) { + if (!expectedJsonNode.isObject()) { + return true; + } + Iterator> expectedFields = expectedJsonNode.fields(); + while (expectedFields.hasNext()) { + Map.Entry expectedField = expectedFields.next(); + String expectedKey = expectedField.getKey(); + JsonNode actualNode = actualJsonNode.get(expectedKey); + if (actualNode == null) { + errors.add(String.format("Expected field '%s' to be present", path(expectedKey))); + } else { + checkRecursive(expectedKey, actualNode, expectedField.getValue()); + } + } + // do not continue (scalar type check) + return false; + } + + private void checkValue(JsonNode actualJsonNode, JsonNode expectedJsonNode) { + if (!expectedJsonNode.equals(actualJsonNode)) { + errors.add(String.format("Expected field '%s' to be equal to '%s' but was '%s'", path(), expectedJsonNode, actualJsonNode)); + } + } + + String path(String expectedKey) { + if (path.isEmpty()) { + return expectedKey; + } + return path() + "." + expectedKey; + } + + String path() { + if (path.isEmpty()) { + return ""; + } + return String.join(".", path).replace(".[", "["); + } +} diff --git a/ebean-test/src/test/java/io/ebean/test/DbJsonTest.java b/ebean-test/src/test/java/io/ebean/test/DbJsonTest.java index dc841c88f..365c019cd 100644 --- a/ebean-test/src/test/java/io/ebean/test/DbJsonTest.java +++ b/ebean-test/src/test/java/io/ebean/test/DbJsonTest.java @@ -1,11 +1,13 @@ package io.ebean.test; +import com.fasterxml.jackson.databind.JsonNode; import io.ebean.DB; import org.junit.Test; import org.test.BSimpleWithGen; import java.util.List; +import static io.ebean.test.DbJson.readResource; import static org.assertj.core.api.Assertions.assertThat; @@ -36,6 +38,37 @@ public class DbJsonTest { //.withPlaceholder("_") .replace("id", "whenModified") .assertContentMatches("/bean/example-list.json"); + } + @Test + public void assertContains_pass() { + + BSimpleWithGen bean = new BSimpleWithGen("something-contains-me", "YeahNah"); + DB.save(bean); + + BSimpleWithGen found = DB.find(BSimpleWithGen.class, bean.getId()); + + DbJson.of(found).assertContainsResource("/bean/contains-minimal.json"); + DbJson.of(found).assertContains(readResource("/bean/contains-with-version.json")); + + DB.delete(bean); + } + + @Test + public void asJson() { + + BSimpleWithGen bean = new BSimpleWithGen("other"); + DB.save(bean); + + String asJson = DbJson.of(bean) + .withPlaceholder("\"*Replaced*\"") + .replace("id") + .asJson(); + + JsonNode node = Json.readNode(asJson); + assertThat(node.get("id").asText()).isEqualTo("*Replaced*"); + assertThat(node.get("name").asText()).isEqualTo("other"); + + DB.delete(bean); } } diff --git a/ebean-test/src/test/java/io/ebean/test/JsonAssertContainsTest.java b/ebean-test/src/test/java/io/ebean/test/JsonAssertContainsTest.java new file mode 100644 index 000000000..2c25776f9 --- /dev/null +++ b/ebean-test/src/test/java/io/ebean/test/JsonAssertContainsTest.java @@ -0,0 +1,86 @@ +package io.ebean.test; + +import com.fasterxml.jackson.databind.JsonNode; +import org.junit.Test; + +import java.util.stream.Stream; + +import static io.ebean.test.Json.readNodeFromResource; +import static org.assertj.core.api.Assertions.assertThat; + + +public class JsonAssertContainsTest { + + @Test + public void assertContains_itself() { + JsonNode original = readNodeFromResource("/contains/original.json"); + JsonAssertContains.assertContains(original, original); + } + + @Test + public void assertContains_subset() { + JsonNode original = readNodeFromResource("/contains/original.json"); + JsonNode expected = readNodeFromResource("/contains/original-subset.json"); + JsonAssertContains.assertContains(original, expected); + } + + + @Test + public void testContainsFails() { + JsonNode original = readNodeFromResource("/contains/original.json"); + JsonNode expected = readNodeFromResource("/contains/original-subset-modified.json"); + try { + JsonAssertContains.assertContains(original, expected); + } catch (AssertionError e) { + String exceptionMessage = e.getMessage(); + Stream.of("Expected field 'someString1' to be equal to '\"aaaa\"' but was '\"string1\"", + "Expected field 'someValue1' to be equal to '99' but was '1'", + "Expected field 'someArray1[0]' to be of type 'STRING' but was 'NUMBER", + "Expected field 'someArray2[0].value1' to be of type 'ARRAY' but was 'NUMBER'", + "Expected field 'someArray2[0].value2' to be of type 'OBJECT' but was 'STRING'", + "Expected field 'someArray2[0].array1[0]' to be '\"1\"' but was null", + "Expected field 'someArray2[0].object1.val5' to be present", + "Expected field 'someArray2[0].object1.val6' to be present", + "Expected field 'someArray2[0].object2' to be of type 'NULL' but was 'OBJECT'", + "Expected field 'someArray2[0].objectNull' to be of type 'OBJECT' but was 'NULL'") + .forEach(assertionError -> assertThat(exceptionMessage).contains(assertionError)); + } + } + + + @Test + public void assertContains_checkNull() { + JsonNode original = readNodeFromResource("/contains/check-null-actual.json"); + JsonNode expected = readNodeFromResource("/contains/check-null-expected.json"); + try { + JsonAssertContains.assertContains(original, expected); + } catch (AssertionError e) { + String exceptionMessage = e.getMessage(); + Stream.of("Expected field 'someNull' to be of type 'NULL' but was 'STRING'", + "Expected field 'extra' to be present") + .forEach(assertionError -> assertThat(exceptionMessage).contains(assertionError)); + } + } + + @Test + public void assertContains_checkType() { + JsonNode original = readNodeFromResource("/contains/check-type-actual.json"); + JsonNode expected = readNodeFromResource("/contains/check-type-expected.json"); + try { + JsonAssertContains.assertContains(original, expected); + } catch (AssertionError e) { + String exceptionMessage = e.getMessage(); + Stream.of("Expected field 'some' to be of type 'NUMBER' but was 'STRING'") + .forEach(assertionError -> assertThat(exceptionMessage).contains(assertionError)); + } + } + + @Test + public void path_when_empty() { + JsonAssertContains contains = new JsonAssertContains(); + + assertThat(contains.path()).isEqualTo(""); + assertThat(contains.path("a")).isEqualTo("a"); + assertThat(contains.path("b")).isEqualTo("b"); + } +} diff --git a/ebean-test/src/test/java/io/ebean/test/JsonTest.java b/ebean-test/src/test/java/io/ebean/test/JsonTest.java new file mode 100644 index 000000000..baf7a1563 --- /dev/null +++ b/ebean-test/src/test/java/io/ebean/test/JsonTest.java @@ -0,0 +1,75 @@ +package io.ebean.test; + +import com.fasterxml.jackson.databind.JsonNode; +import org.junit.Test; +import org.test.PlainBean; + +import java.util.List; + +import static io.ebean.test.Json.readNodeFromResource; +import static io.ebean.test.Json.readResource; +import static org.assertj.core.api.Assertions.assertThat; + +public class JsonTest { + + @Test + public void assertContains_subset() { + JsonNode original = readNodeFromResource("/contains/original.json"); + JsonNode expected = readNodeFromResource("/contains/original-subset.json"); + Json.assertContains(original, expected); + } + + @Test + public void readNode() { + JsonNode original = Json.readNode(readResource("/contains/original.json")); + Json.assertContains(original, original); + } + + @Test + public void resource_asNode() { + JsonNode original = Json.resource("/contains/original.json").asNode(); + JsonNode nonFluid = Json.readNode(readResource("/contains/original.json")); + assertThat(original).isEqualTo(nonFluid); + } + + @Test + public void readBean_resource_asBean() { + // traditional style from resource + PlainBean bean1 = Json.readFromResource(PlainBean.class, "/example/plain.json"); + assertThat(bean1.id).isEqualTo(42); + assertThat(bean1.name).isEqualTo("foo"); + + // traditional style given json content + PlainBean bean2 = Json.read(PlainBean.class, readResource("/example/plain.json")); + assertThat(bean2.id).isEqualTo(42); + assertThat(bean2.name).isEqualTo("foo"); + + // fluid style - resource asBean() + PlainBean bean3 = Json.resource("/example/plain.json").asBean(PlainBean.class); + assertThat(bean3.id).isEqualTo(42); + assertThat(bean3.name).isEqualTo("foo"); + } + + @Test + public void readList() { + List list = Json.readList(PlainBean.class, readResource("/example/plain-list.json")); + + String asJson = Json.toJsonString(list); + assertThat(list).hasSize(2); + assertThat(list.get(0).name).isEqualTo("foo"); + assertThat(list.get(1).name).isEqualTo("bar"); + + assertThat(asJson).contains("\"name\" : \"foo\""); + } + + @Test + public void resourceAsList() { + // fluid style - resource asList() + List list = Json.resource("/example/plain-list.json").asList(PlainBean.class); + + // traditional style + List list2 = Json.readList(PlainBean.class, readResource("/example/plain-list.json")); + assertThat(list).isEqualTo(list2); + } + +} diff --git a/ebean-test/src/test/java/org/test/BSimpleWithGen.java b/ebean-test/src/test/java/org/test/BSimpleWithGen.java index cf3c7f2f6..5ee189229 100644 --- a/ebean-test/src/test/java/org/test/BSimpleWithGen.java +++ b/ebean-test/src/test/java/org/test/BSimpleWithGen.java @@ -18,6 +18,8 @@ public class BSimpleWithGen { private String name; + private String other; + @Transient private Map> someMap; @@ -31,6 +33,11 @@ public class BSimpleWithGen { this.name = name; } + public BSimpleWithGen(String name, String other) { + this.name = name; + this.other = other; + } + public Integer getId() { return id; } diff --git a/ebean-test/src/test/java/org/test/PlainBean.java b/ebean-test/src/test/java/org/test/PlainBean.java new file mode 100644 index 000000000..103e67425 --- /dev/null +++ b/ebean-test/src/test/java/org/test/PlainBean.java @@ -0,0 +1,22 @@ +package org.test; + +import java.util.Objects; + +public class PlainBean { + + public int id; + public String name; + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + PlainBean plainBean = (PlainBean) o; + return id == plainBean.id && name.equals(plainBean.name); + } + + @Override + public int hashCode() { + return Objects.hash(id, name); + } +} diff --git a/ebean-test/src/test/resources/bean/contains-minimal.json b/ebean-test/src/test/resources/bean/contains-minimal.json new file mode 100644 index 000000000..564060eec --- /dev/null +++ b/ebean-test/src/test/resources/bean/contains-minimal.json @@ -0,0 +1,4 @@ +{ + "name": "something-contains-me", + "version": 1 +} diff --git a/ebean-test/src/test/resources/bean/contains-with-version.json b/ebean-test/src/test/resources/bean/contains-with-version.json new file mode 100644 index 000000000..894b0bf14 --- /dev/null +++ b/ebean-test/src/test/resources/bean/contains-with-version.json @@ -0,0 +1,5 @@ +{ + "name": "something-contains-me", + "other": "YeahNah", + "version": 1 +} diff --git a/ebean-test/src/test/resources/bean/example-bean.json b/ebean-test/src/test/resources/bean/example-bean.json index 593babff3..e9a935767 100644 --- a/ebean-test/src/test/resources/bean/example-bean.json +++ b/ebean-test/src/test/resources/bean/example-bean.json @@ -1,6 +1,7 @@ { "id": _, "name": "something", + "other": null, "whenModified": _, "version": 1 } diff --git a/ebean-test/src/test/resources/bean/example-list.json b/ebean-test/src/test/resources/bean/example-list.json index 21264b0a7..8c7b8b681 100644 --- a/ebean-test/src/test/resources/bean/example-list.json +++ b/ebean-test/src/test/resources/bean/example-list.json @@ -1,11 +1,13 @@ [ { "id": "*", "name": "something", + "other": null, "whenModified": "*", "version": 1 }, { "id": "*", "name": "other", + "other": null, "whenModified": "*", "version": 1 } ] diff --git a/ebean-test/src/test/resources/contains/check-null-actual.json b/ebean-test/src/test/resources/contains/check-null-actual.json new file mode 100644 index 000000000..992d2aef4 --- /dev/null +++ b/ebean-test/src/test/resources/contains/check-null-actual.json @@ -0,0 +1,9 @@ +{ + "some": "val", + "someNull": "actualNotNull", + "matchNull": null, + "nullObject": { + "id": 42 + } + +} diff --git a/ebean-test/src/test/resources/contains/check-null-expected.json b/ebean-test/src/test/resources/contains/check-null-expected.json new file mode 100644 index 000000000..ce4163032 --- /dev/null +++ b/ebean-test/src/test/resources/contains/check-null-expected.json @@ -0,0 +1,7 @@ +{ + "some": "val", + "someNull": null, + "extra": "notThere", + "matchNull": null, + "nullObject": null +} diff --git a/ebean-test/src/test/resources/contains/check-type-actual.json b/ebean-test/src/test/resources/contains/check-type-actual.json new file mode 100644 index 000000000..6b240843c --- /dev/null +++ b/ebean-test/src/test/resources/contains/check-type-actual.json @@ -0,0 +1,3 @@ +{ + "some": "val" +} diff --git a/ebean-test/src/test/resources/contains/check-type-expected.json b/ebean-test/src/test/resources/contains/check-type-expected.json new file mode 100644 index 000000000..5b0cf6957 --- /dev/null +++ b/ebean-test/src/test/resources/contains/check-type-expected.json @@ -0,0 +1,3 @@ +{ + "some": 42 +} diff --git a/ebean-test/src/test/resources/contains/original-subset-modified.json b/ebean-test/src/test/resources/contains/original-subset-modified.json new file mode 100644 index 000000000..107d557d2 --- /dev/null +++ b/ebean-test/src/test/resources/contains/original-subset-modified.json @@ -0,0 +1,26 @@ +{ + "someString1": "aaaa", + "someString2": "string2", + "someValue1": 99, + "someValue2": 2, + "someArray1": [ + "a" + ], + "someArray2": [ + { + "value1": [], + "value2": {}, + "array1": [ + "1" + ], + "object1": { + "val5": "a", + "val6": 1 + }, + "object2": null, + "objectNull": { + "val": [] + } + } + ] +} diff --git a/ebean-test/src/test/resources/contains/original-subset.json b/ebean-test/src/test/resources/contains/original-subset.json new file mode 100644 index 000000000..e5823e2a4 --- /dev/null +++ b/ebean-test/src/test/resources/contains/original-subset.json @@ -0,0 +1,15 @@ +{ + "someString1": "string1", + "someValue1": 1, + "someArray2": [ + { + "value1": 11, + "array1": [], + "object2": { + "v1": "v1", + "v4": [] + }, + "objectNull": null + } + ] +} diff --git a/ebean-test/src/test/resources/contains/original.json b/ebean-test/src/test/resources/contains/original.json new file mode 100644 index 000000000..063affac4 --- /dev/null +++ b/ebean-test/src/test/resources/contains/original.json @@ -0,0 +1,27 @@ +{ + "someString1": "string1", + "someString2": "string2", + "someValue1": 1, + "someValue2": 2, + "someArray1": [ + 1, + 2, + 3, + 4 + ], + "someArray2": [ + { + "value1": 11, + "value2": "22", + "array1": [], + "object1": {}, + "object2": { + "v1": "v1", + "v2": 1, + "v3": {}, + "v4": [] + }, + "objectNull": null + } + ] +} diff --git a/ebean-test/src/test/resources/example/plain-list.json b/ebean-test/src/test/resources/example/plain-list.json new file mode 100644 index 000000000..49bc4c34d --- /dev/null +++ b/ebean-test/src/test/resources/example/plain-list.json @@ -0,0 +1,10 @@ +[ + { + "id": 42, + "name": "foo" + }, + { + "id": 55, + "name": "bar" + } +] diff --git a/ebean-test/src/test/resources/example/plain.json b/ebean-test/src/test/resources/example/plain.json new file mode 100644 index 000000000..63632de85 --- /dev/null +++ b/ebean-test/src/test/resources/example/plain.json @@ -0,0 +1,4 @@ +{ + "id": 42, + "name": "foo" +} From 99d7a4e4b4ac8d41accd08ccf380abd37111305a Mon Sep 17 00:00:00 2001 From: Robin Bygrave Date: Fri, 19 Feb 2021 09:43:56 +1300 Subject: [PATCH 111/447] Tidy up pom jackson dependency versions (all optional dependencies) and bump to 2.12.1 --- ebean-api/pom.xml | 9 ++------- ebean-core-type/pom.xml | 7 +------ ebean-core/pom.xml | 9 ++------- ebean-postgis/pom.xml | 3 +-- ebean-test/pom.xml | 8 ++------ pom.xml | 1 + 6 files changed, 9 insertions(+), 28 deletions(-) diff --git a/ebean-api/pom.xml b/ebean-api/pom.xml index 80d8db37a..dc2bd347e 100644 --- a/ebean-api/pom.xml +++ b/ebean-api/pom.xml @@ -11,11 +11,6 @@ ebean api ebean-api - - 2.11.3 - 2.11.3 - - @@ -14,7 +14,7 @@ scm:git:git@github.com:ebean-orm/ebean.git - ebean-parent-12.6.5 + ebean-parent-12.7.1 ebean autotune @@ -26,7 +26,7 @@ io.ebean ebean-core - 12.7.1-SNAPSHOT + 12.7.1 provided diff --git a/ebean-bom/pom.xml b/ebean-bom/pom.xml index c6219cfea..7e773ec45 100644 --- a/ebean-bom/pom.xml +++ b/ebean-bom/pom.xml @@ -4,7 +4,7 @@ ebean-parent io.ebean - 12.7.1-SNAPSHOT + 12.7.1 ebean bom @@ -81,88 +81,88 @@ io.ebean ebean - 12.7.1-SNAPSHOT + 12.7.1 io.ebean ebean-api - 12.7.1-SNAPSHOT + 12.7.1 io.ebean ebean-core - 12.7.1-SNAPSHOT + 12.7.1 io.ebean ebean-core-type - 12.7.1-SNAPSHOT + 12.7.1 io.ebean ebean-ddl-generator - 12.7.1-SNAPSHOT + 12.7.1 io.ebean ebean-externalmapping-api - 12.7.1-SNAPSHOT + 12.7.1 io.ebean ebean-externalmapping-xml - 12.7.1-SNAPSHOT + 12.7.1 io.ebean ebean-autotune - 12.7.1-SNAPSHOT + 12.7.1 io.ebean ebean-querybean - 12.7.1-SNAPSHOT + 12.7.1 io.ebean querybean-generator - 12.7.1-SNAPSHOT + 12.7.1 provided io.ebean kotlin-querybean-generator - 12.7.1-SNAPSHOT + 12.7.1 provided io.ebean ebean-test - 12.7.1-SNAPSHOT + 12.7.1 test io.ebean ebean-postgis - 12.7.1-SNAPSHOT + 12.7.1 io.ebean ebean-redis - 12.7.1-SNAPSHOT + 12.7.1 diff --git a/ebean-core-type/pom.xml b/ebean-core-type/pom.xml index 36e38b2da..dbe59f45e 100644 --- a/ebean-core-type/pom.xml +++ b/ebean-core-type/pom.xml @@ -4,7 +4,7 @@ ebean-parent io.ebean - 12.7.1-SNAPSHOT + 12.7.1 ebean-core-type @@ -16,7 +16,7 @@ io.ebean ebean-api - 12.7.1-SNAPSHOT + 12.7.1 diff --git a/ebean-core/pom.xml b/ebean-core/pom.xml index e335e97c3..48f2a741d 100644 --- a/ebean-core/pom.xml +++ b/ebean-core/pom.xml @@ -3,7 +3,7 @@ ebean-parent io.ebean - 12.7.1-SNAPSHOT + 12.7.1 ebean-core @@ -15,7 +15,7 @@ scm:git:git@github.com:ebean-orm/ebean.git - ebean-parent-12.6.5 + ebean-parent-12.7.1 @@ -87,19 +87,19 @@ io.ebean ebean-api - 12.7.1-SNAPSHOT + 12.7.1 io.ebean ebean-core-type - 12.7.1-SNAPSHOT + 12.7.1 io.ebean ebean-externalmapping-api - 12.7.1-SNAPSHOT + 12.7.1 diff --git a/ebean-ddl-generator/pom.xml b/ebean-ddl-generator/pom.xml index 983902210..0662d9339 100644 --- a/ebean-ddl-generator/pom.xml +++ b/ebean-ddl-generator/pom.xml @@ -4,7 +4,7 @@ ebean-parent io.ebean - 12.7.1-SNAPSHOT + 12.7.1 ebean ddl generation @@ -29,14 +29,14 @@ io.ebean ebean-core-type - 12.7.1-SNAPSHOT + 12.7.1 provided io.ebean ebean-core - 12.7.1-SNAPSHOT + 12.7.1 provided diff --git a/ebean-externalmapping-api/pom.xml b/ebean-externalmapping-api/pom.xml index 54bb5c7bb..416410762 100644 --- a/ebean-externalmapping-api/pom.xml +++ b/ebean-externalmapping-api/pom.xml @@ -4,7 +4,7 @@ ebean-parent io.ebean - 12.7.1-SNAPSHOT + 12.7.1 ebean external mapping api diff --git a/ebean-externalmapping-xml/pom.xml b/ebean-externalmapping-xml/pom.xml index 98f90d1ac..310ae0299 100644 --- a/ebean-externalmapping-xml/pom.xml +++ b/ebean-externalmapping-xml/pom.xml @@ -4,7 +4,7 @@ ebean-parent io.ebean - 12.7.1-SNAPSHOT + 12.7.1 @@ -14,7 +14,7 @@ scm:git:git@github.com:ebean-orm/ebean.git - ebean-parent-12.6.5 + ebean-parent-12.7.1 ebean external mapping xml @@ -33,7 +33,7 @@ io.ebean ebean-externalmapping-api - 12.7.1-SNAPSHOT + 12.7.1 @@ -59,14 +59,14 @@ io.ebean ebean-core - 12.7.1-SNAPSHOT + 12.7.1 test io.ebean ebean-ddl-generator - 12.7.1-SNAPSHOT + 12.7.1 test diff --git a/ebean-postgis/pom.xml b/ebean-postgis/pom.xml index 61271ef1f..3e5346f2e 100644 --- a/ebean-postgis/pom.xml +++ b/ebean-postgis/pom.xml @@ -4,7 +4,7 @@ ebean-parent io.ebean - 12.7.1-SNAPSHOT + 12.7.1 ebean postgis @@ -23,7 +23,7 @@ io.ebean ebean-core - 12.7.1-SNAPSHOT + 12.7.1 provided @@ -74,7 +74,7 @@ io.ebean ebean-test - 12.7.1-SNAPSHOT + 12.7.1 test diff --git a/ebean-querybean/pom.xml b/ebean-querybean/pom.xml index 0bdeeb257..d105a5abc 100644 --- a/ebean-querybean/pom.xml +++ b/ebean-querybean/pom.xml @@ -4,7 +4,7 @@ ebean-parent io.ebean - 12.7.1-SNAPSHOT + 12.7.1 ebean querybean @@ -17,7 +17,7 @@ io.ebean ebean-core - 12.7.1-SNAPSHOT + 12.7.1 provided @@ -57,21 +57,21 @@ io.ebean ebean-ddl-generator - 12.7.1-SNAPSHOT + 12.7.1 test io.ebean querybean-generator - 12.7.1-SNAPSHOT + 12.7.1 test io.ebean ebean-test - 12.7.1-SNAPSHOT + 12.7.1 test diff --git a/ebean-redis/pom.xml b/ebean-redis/pom.xml index 98186aa7f..a1f4b6c04 100644 --- a/ebean-redis/pom.xml +++ b/ebean-redis/pom.xml @@ -4,7 +4,7 @@ ebean-parent io.ebean - 12.7.1-SNAPSHOT + 12.7.1 ebean-redis @@ -22,35 +22,35 @@ io.ebean ebean-api - 12.7.1-SNAPSHOT + 12.7.1 provided io.ebean ebean-core - 12.7.1-SNAPSHOT + 12.7.1 provided io.ebean ebean-querybean - 12.7.1-SNAPSHOT + 12.7.1 test io.ebean querybean-generator - 12.7.1-SNAPSHOT + 12.7.1 test io.ebean ebean-test - 12.7.1-SNAPSHOT + 12.7.1 test diff --git a/ebean-test/pom.xml b/ebean-test/pom.xml index 420986916..ac9a323db 100644 --- a/ebean-test/pom.xml +++ b/ebean-test/pom.xml @@ -1,11 +1,10 @@ - + 4.0.0 ebean-parent io.ebean - 12.7.1-SNAPSHOT + 12.7.1 ebean test @@ -30,14 +29,14 @@ io.ebean ebean-core - 12.7.1-SNAPSHOT + 12.7.1 provided io.ebean ebean-ddl-generator - 12.7.1-SNAPSHOT + 12.7.1 diff --git a/ebean/pom.xml b/ebean/pom.xml index 337b3deba..b0cad2be9 100644 --- a/ebean/pom.xml +++ b/ebean/pom.xml @@ -4,7 +4,7 @@ ebean-parent io.ebean - 12.7.1-SNAPSHOT + 12.7.1 ebean composite @@ -22,20 +22,20 @@ io.ebean ebean-api - 12.7.1-SNAPSHOT + 12.7.1 io.ebean ebean-core - 12.7.1-SNAPSHOT + 12.7.1 io.ebean ebean-querybean - 12.7.1-SNAPSHOT + 12.7.1 diff --git a/kotlin-querybean-generator/pom.xml b/kotlin-querybean-generator/pom.xml index 07993d49e..02d01a09f 100644 --- a/kotlin-querybean-generator/pom.xml +++ b/kotlin-querybean-generator/pom.xml @@ -4,7 +4,7 @@ ebean-parent io.ebean - 12.7.1-SNAPSHOT + 12.7.1 kotlin querybean generator @@ -29,7 +29,7 @@ io.ebean ebean-querybean - 12.7.1-SNAPSHOT + 12.7.1 test @@ -43,7 +43,7 @@ io.ebean ebean-core - 12.7.1-SNAPSHOT + 12.7.1 test @@ -64,7 +64,7 @@ io.ebean ebean-ddl-generator - 12.7.1-SNAPSHOT + 12.7.1 test diff --git a/pom.xml b/pom.xml index 12b4d3540..547bd731e 100644 --- a/pom.xml +++ b/pom.xml @@ -9,7 +9,7 @@ io.ebean ebean-parent - 12.7.1-SNAPSHOT + 12.7.1 pom ebean parent @@ -18,7 +18,7 @@ scm:git:git@github.com:ebean-orm/ebean.git - ebean-parent-12.6.5 + ebean-parent-12.7.1 diff --git a/querybean-generator/pom.xml b/querybean-generator/pom.xml index 90140df71..64c2c4d91 100644 --- a/querybean-generator/pom.xml +++ b/querybean-generator/pom.xml @@ -4,7 +4,7 @@ ebean-parent io.ebean - 12.7.1-SNAPSHOT + 12.7.1 querybean generator From b77c62e0db470698a62b1e3335e62ea1959ac91a Mon Sep 17 00:00:00 2001 From: robin Date: Fri, 19 Feb 2021 22:51:03 +1300 Subject: [PATCH 114/447] [maven-release-plugin] prepare for next development iteration --- ebean-api/pom.xml | 2 +- ebean-autotune/pom.xml | 6 +++--- ebean-bom/pom.xml | 30 +++++++++++++++--------------- ebean-core-type/pom.xml | 4 ++-- ebean-core/pom.xml | 10 +++++----- ebean-ddl-generator/pom.xml | 6 +++--- ebean-externalmapping-api/pom.xml | 2 +- ebean-externalmapping-xml/pom.xml | 10 +++++----- ebean-postgis/pom.xml | 6 +++--- ebean-querybean/pom.xml | 10 +++++----- ebean-redis/pom.xml | 12 ++++++------ ebean-test/pom.xml | 6 +++--- ebean/pom.xml | 8 ++++---- kotlin-querybean-generator/pom.xml | 8 ++++---- pom.xml | 4 ++-- querybean-generator/pom.xml | 2 +- 16 files changed, 63 insertions(+), 63 deletions(-) diff --git a/ebean-api/pom.xml b/ebean-api/pom.xml index 188db1c49..79962ff51 100644 --- a/ebean-api/pom.xml +++ b/ebean-api/pom.xml @@ -4,7 +4,7 @@ ebean-parent io.ebean - 12.7.1 + 12.7.2-SNAPSHOT ebean api diff --git a/ebean-autotune/pom.xml b/ebean-autotune/pom.xml index 878f95090..b86469ddd 100644 --- a/ebean-autotune/pom.xml +++ b/ebean-autotune/pom.xml @@ -4,7 +4,7 @@ ebean-parent io.ebean - 12.7.1 + 12.7.2-SNAPSHOT @@ -14,7 +14,7 @@ scm:git:git@github.com:ebean-orm/ebean.git - ebean-parent-12.7.1 + ebean-parent-12.6.5 ebean autotune @@ -26,7 +26,7 @@ io.ebean ebean-core - 12.7.1 + 12.7.2-SNAPSHOT provided diff --git a/ebean-bom/pom.xml b/ebean-bom/pom.xml index 7e773ec45..c47601c85 100644 --- a/ebean-bom/pom.xml +++ b/ebean-bom/pom.xml @@ -4,7 +4,7 @@ ebean-parent io.ebean - 12.7.1 + 12.7.2-SNAPSHOT ebean bom @@ -81,88 +81,88 @@ io.ebean ebean - 12.7.1 + 12.7.2-SNAPSHOT io.ebean ebean-api - 12.7.1 + 12.7.2-SNAPSHOT io.ebean ebean-core - 12.7.1 + 12.7.2-SNAPSHOT io.ebean ebean-core-type - 12.7.1 + 12.7.2-SNAPSHOT io.ebean ebean-ddl-generator - 12.7.1 + 12.7.2-SNAPSHOT io.ebean ebean-externalmapping-api - 12.7.1 + 12.7.2-SNAPSHOT io.ebean ebean-externalmapping-xml - 12.7.1 + 12.7.2-SNAPSHOT io.ebean ebean-autotune - 12.7.1 + 12.7.2-SNAPSHOT io.ebean ebean-querybean - 12.7.1 + 12.7.2-SNAPSHOT io.ebean querybean-generator - 12.7.1 + 12.7.2-SNAPSHOT provided io.ebean kotlin-querybean-generator - 12.7.1 + 12.7.2-SNAPSHOT provided io.ebean ebean-test - 12.7.1 + 12.7.2-SNAPSHOT test io.ebean ebean-postgis - 12.7.1 + 12.7.2-SNAPSHOT io.ebean ebean-redis - 12.7.1 + 12.7.2-SNAPSHOT diff --git a/ebean-core-type/pom.xml b/ebean-core-type/pom.xml index dbe59f45e..f0db31343 100644 --- a/ebean-core-type/pom.xml +++ b/ebean-core-type/pom.xml @@ -4,7 +4,7 @@ ebean-parent io.ebean - 12.7.1 + 12.7.2-SNAPSHOT ebean-core-type @@ -16,7 +16,7 @@ io.ebean ebean-api - 12.7.1 + 12.7.2-SNAPSHOT diff --git a/ebean-core/pom.xml b/ebean-core/pom.xml index 48f2a741d..bab9e7624 100644 --- a/ebean-core/pom.xml +++ b/ebean-core/pom.xml @@ -3,7 +3,7 @@ ebean-parent io.ebean - 12.7.1 + 12.7.2-SNAPSHOT ebean-core @@ -15,7 +15,7 @@ scm:git:git@github.com:ebean-orm/ebean.git - ebean-parent-12.7.1 + ebean-parent-12.6.5 @@ -87,19 +87,19 @@ io.ebean ebean-api - 12.7.1 + 12.7.2-SNAPSHOT io.ebean ebean-core-type - 12.7.1 + 12.7.2-SNAPSHOT io.ebean ebean-externalmapping-api - 12.7.1 + 12.7.2-SNAPSHOT diff --git a/ebean-ddl-generator/pom.xml b/ebean-ddl-generator/pom.xml index 0662d9339..90f3270e4 100644 --- a/ebean-ddl-generator/pom.xml +++ b/ebean-ddl-generator/pom.xml @@ -4,7 +4,7 @@ ebean-parent io.ebean - 12.7.1 + 12.7.2-SNAPSHOT ebean ddl generation @@ -29,14 +29,14 @@ io.ebean ebean-core-type - 12.7.1 + 12.7.2-SNAPSHOT provided io.ebean ebean-core - 12.7.1 + 12.7.2-SNAPSHOT provided diff --git a/ebean-externalmapping-api/pom.xml b/ebean-externalmapping-api/pom.xml index 416410762..76e5ced23 100644 --- a/ebean-externalmapping-api/pom.xml +++ b/ebean-externalmapping-api/pom.xml @@ -4,7 +4,7 @@ ebean-parent io.ebean - 12.7.1 + 12.7.2-SNAPSHOT ebean external mapping api diff --git a/ebean-externalmapping-xml/pom.xml b/ebean-externalmapping-xml/pom.xml index 310ae0299..620a1de73 100644 --- a/ebean-externalmapping-xml/pom.xml +++ b/ebean-externalmapping-xml/pom.xml @@ -4,7 +4,7 @@ ebean-parent io.ebean - 12.7.1 + 12.7.2-SNAPSHOT @@ -14,7 +14,7 @@ scm:git:git@github.com:ebean-orm/ebean.git - ebean-parent-12.7.1 + ebean-parent-12.6.5 ebean external mapping xml @@ -33,7 +33,7 @@ io.ebean ebean-externalmapping-api - 12.7.1 + 12.7.2-SNAPSHOT @@ -59,14 +59,14 @@ io.ebean ebean-core - 12.7.1 + 12.7.2-SNAPSHOT test io.ebean ebean-ddl-generator - 12.7.1 + 12.7.2-SNAPSHOT test diff --git a/ebean-postgis/pom.xml b/ebean-postgis/pom.xml index 3e5346f2e..d8acdb157 100644 --- a/ebean-postgis/pom.xml +++ b/ebean-postgis/pom.xml @@ -4,7 +4,7 @@ ebean-parent io.ebean - 12.7.1 + 12.7.2-SNAPSHOT ebean postgis @@ -23,7 +23,7 @@ io.ebean ebean-core - 12.7.1 + 12.7.2-SNAPSHOT provided @@ -74,7 +74,7 @@ io.ebean ebean-test - 12.7.1 + 12.7.2-SNAPSHOT test diff --git a/ebean-querybean/pom.xml b/ebean-querybean/pom.xml index d105a5abc..52ab4f7c0 100644 --- a/ebean-querybean/pom.xml +++ b/ebean-querybean/pom.xml @@ -4,7 +4,7 @@ ebean-parent io.ebean - 12.7.1 + 12.7.2-SNAPSHOT ebean querybean @@ -17,7 +17,7 @@ io.ebean ebean-core - 12.7.1 + 12.7.2-SNAPSHOT provided @@ -57,21 +57,21 @@ io.ebean ebean-ddl-generator - 12.7.1 + 12.7.2-SNAPSHOT test io.ebean querybean-generator - 12.7.1 + 12.7.2-SNAPSHOT test io.ebean ebean-test - 12.7.1 + 12.7.2-SNAPSHOT test diff --git a/ebean-redis/pom.xml b/ebean-redis/pom.xml index a1f4b6c04..cf4f83208 100644 --- a/ebean-redis/pom.xml +++ b/ebean-redis/pom.xml @@ -4,7 +4,7 @@ ebean-parent io.ebean - 12.7.1 + 12.7.2-SNAPSHOT ebean-redis @@ -22,35 +22,35 @@ io.ebean ebean-api - 12.7.1 + 12.7.2-SNAPSHOT provided io.ebean ebean-core - 12.7.1 + 12.7.2-SNAPSHOT provided io.ebean ebean-querybean - 12.7.1 + 12.7.2-SNAPSHOT test io.ebean querybean-generator - 12.7.1 + 12.7.2-SNAPSHOT test io.ebean ebean-test - 12.7.1 + 12.7.2-SNAPSHOT test diff --git a/ebean-test/pom.xml b/ebean-test/pom.xml index ac9a323db..32810609f 100644 --- a/ebean-test/pom.xml +++ b/ebean-test/pom.xml @@ -4,7 +4,7 @@ ebean-parent io.ebean - 12.7.1 + 12.7.2-SNAPSHOT ebean test @@ -29,14 +29,14 @@ io.ebean ebean-core - 12.7.1 + 12.7.2-SNAPSHOT provided io.ebean ebean-ddl-generator - 12.7.1 + 12.7.2-SNAPSHOT diff --git a/ebean/pom.xml b/ebean/pom.xml index b0cad2be9..e1bf6282a 100644 --- a/ebean/pom.xml +++ b/ebean/pom.xml @@ -4,7 +4,7 @@ ebean-parent io.ebean - 12.7.1 + 12.7.2-SNAPSHOT ebean composite @@ -22,20 +22,20 @@ io.ebean ebean-api - 12.7.1 + 12.7.2-SNAPSHOT io.ebean ebean-core - 12.7.1 + 12.7.2-SNAPSHOT io.ebean ebean-querybean - 12.7.1 + 12.7.2-SNAPSHOT diff --git a/kotlin-querybean-generator/pom.xml b/kotlin-querybean-generator/pom.xml index 02d01a09f..8529dbe7f 100644 --- a/kotlin-querybean-generator/pom.xml +++ b/kotlin-querybean-generator/pom.xml @@ -4,7 +4,7 @@ ebean-parent io.ebean - 12.7.1 + 12.7.2-SNAPSHOT kotlin querybean generator @@ -29,7 +29,7 @@ io.ebean ebean-querybean - 12.7.1 + 12.7.2-SNAPSHOT test @@ -43,7 +43,7 @@ io.ebean ebean-core - 12.7.1 + 12.7.2-SNAPSHOT test @@ -64,7 +64,7 @@ io.ebean ebean-ddl-generator - 12.7.1 + 12.7.2-SNAPSHOT test diff --git a/pom.xml b/pom.xml index 547bd731e..6edda0cd5 100644 --- a/pom.xml +++ b/pom.xml @@ -9,7 +9,7 @@ io.ebean ebean-parent - 12.7.1 + 12.7.2-SNAPSHOT pom ebean parent @@ -18,7 +18,7 @@ scm:git:git@github.com:ebean-orm/ebean.git - ebean-parent-12.7.1 + ebean-parent-12.6.5 diff --git a/querybean-generator/pom.xml b/querybean-generator/pom.xml index 64c2c4d91..9f5303d0f 100644 --- a/querybean-generator/pom.xml +++ b/querybean-generator/pom.xml @@ -4,7 +4,7 @@ ebean-parent io.ebean - 12.7.1 + 12.7.2-SNAPSHOT querybean generator From d036af8d1a5b2ed3ccff01ea95c4c8bc8cbf0938 Mon Sep 17 00:00:00 2001 From: Ben Kempe Date: Sun, 28 Feb 2021 19:06:51 +0100 Subject: [PATCH 115/447] Add more assertions for nested one-to-many fetch --- .../tests/query/joins/TestQueryJoinManyNonRoot.java | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/ebean-core/src/test/java/org/tests/query/joins/TestQueryJoinManyNonRoot.java b/ebean-core/src/test/java/org/tests/query/joins/TestQueryJoinManyNonRoot.java index 82eb65935..b5f2f61bf 100644 --- a/ebean-core/src/test/java/org/tests/query/joins/TestQueryJoinManyNonRoot.java +++ b/ebean-core/src/test/java/org/tests/query/joins/TestQueryJoinManyNonRoot.java @@ -11,6 +11,7 @@ import org.junit.Assert; import org.junit.Test; import java.util.List; +import java.util.Map; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; @@ -54,6 +55,17 @@ public class TestQueryJoinManyNonRoot extends BaseTestCase { assertTrue(sql.contains("join o_customer t1 on t1.id ")); assertTrue(sql.contains("left join contact t2 on")); + Map ordersById = Ebean.find(Order.class).setMapKey("id").where().gt("id", 0).query().findMap(); + for (Order o: list) { + int withoutFetch = ordersById.get(o.getId()).getCustomer().getContacts().size(); + int withFetch = o.getCustomer().getContacts().size(); + assertEquals(String.format("order.customer.contacts for order %d did not match. " + + "Items without fetch: %d, with fetch: %d", o.getId(), withoutFetch, withFetch), + withoutFetch, + withFetch); + } + + // select t0.id c0, t0.status c1, t0.order_date c2, t0.ship_date c3, t1.name c4, t0.cretime c5, t0.updtime c6, // t1.id c7, t1.status c8, t1.name c9, t1.smallnote c10, t1.anniversary c11, t1.cretime c12, t1.updtime c13, t1.billing_address_id c14, t1.shipping_address_id c15, // t2.id c16, t2.first_name c17, t2.last_name c18, t2.phone c19, t2.mobile c20, t2.email c21, t2.cretime c22, t2.updtime c23, t2.customer_id c24, t2.group_id c25 From 6acf93c97804deba3e7e54fcbeae4a41ded8b88a Mon Sep 17 00:00:00 2001 From: Robin Bygrave Date: Mon, 1 Mar 2021 13:38:40 +1300 Subject: [PATCH 116/447] #2178 - Fix for duplicate instances added to collection for nested one-to-many fetch This is an initial fix for this case. --- .../java/io/ebeaninternal/server/query/SqlTreeNodeManyRoot.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/query/SqlTreeNodeManyRoot.java b/ebean-core/src/main/java/io/ebeaninternal/server/query/SqlTreeNodeManyRoot.java index 6b050f51a..a1f6ea357 100644 --- a/ebean-core/src/main/java/io/ebeaninternal/server/query/SqlTreeNodeManyRoot.java +++ b/ebean-core/src/main/java/io/ebeaninternal/server/query/SqlTreeNodeManyRoot.java @@ -36,7 +36,7 @@ final class SqlTreeNodeManyRoot extends SqlTreeNodeBean { EntityBean detailBean = super.load(cquery, null, null); // initialise the collection and add detailBean if it is not null if (contextParent != null) { - manyProp.addBeanToCollectionWithCreate(contextParent, detailBean, false); + manyProp.addBeanToCollectionWithCreate(contextParent, detailBean, true); } return detailBean; } From 5ebad53072e5b72446ed6ce9cb4828b79134f343 Mon Sep 17 00:00:00 2001 From: Robin Bygrave Date: Mon, 1 Mar 2021 14:00:40 +1300 Subject: [PATCH 117/447] #2179 - Improve internals for outer join resulting in null many bean Refactor improving the BeanList.internalAddWithCheck() for the null bean case --- ebean-api/src/main/java/io/ebean/common/BeanList.java | 2 +- ebean-api/src/main/java/io/ebean/common/BeanMap.java | 2 +- ebean-api/src/main/java/io/ebean/common/BeanSet.java | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/ebean-api/src/main/java/io/ebean/common/BeanList.java b/ebean-api/src/main/java/io/ebean/common/BeanList.java index 0aee7f211..0aa774a81 100644 --- a/ebean-api/src/main/java/io/ebean/common/BeanList.java +++ b/ebean-api/src/main/java/io/ebean/common/BeanList.java @@ -87,7 +87,7 @@ public final class BeanList extends AbstractBeanCollection implements List @Override public void internalAddWithCheck(Object bean) { - if (list == null || !containsInstance(bean)) { + if (list == null || bean == null || !containsInstance(bean)) { internalAdd(bean); } } diff --git a/ebean-api/src/main/java/io/ebean/common/BeanMap.java b/ebean-api/src/main/java/io/ebean/common/BeanMap.java index b2ded02c9..09b37d38a 100644 --- a/ebean-api/src/main/java/io/ebean/common/BeanMap.java +++ b/ebean-api/src/main/java/io/ebean/common/BeanMap.java @@ -77,7 +77,7 @@ public final class BeanMap extends AbstractBeanCollection implements Ma } public void internalPutWithCheck(Object key, Object bean) { - if (map == null || !map.containsKey(key)) { + if (map == null || key == null || !map.containsKey(key)) { internalPut(key, bean); } } diff --git a/ebean-api/src/main/java/io/ebean/common/BeanSet.java b/ebean-api/src/main/java/io/ebean/common/BeanSet.java index ec4dc3829..91f0ae672 100644 --- a/ebean-api/src/main/java/io/ebean/common/BeanSet.java +++ b/ebean-api/src/main/java/io/ebean/common/BeanSet.java @@ -70,7 +70,7 @@ public final class BeanSet extends AbstractBeanCollection implements Set Date: Mon, 1 Mar 2021 17:44:13 +1300 Subject: [PATCH 118/447] Refactor internals add SqlTreeRoot as follow up to #2179 Adds SqlTreeRoot interface to make it more explicit that SqlTreeNodeRoot is the only valid top level node in the sql tree (and as such has the root level load() method) --- .../io/ebeaninternal/server/query/CQuery.java | 8 ++--- .../ebeaninternal/server/query/SqlTree.java | 4 +-- .../server/query/SqlTreeNode.java | 5 --- .../server/query/SqlTreeNodeBean.java | 14 -------- .../server/query/SqlTreeNodeExtraJoin.java | 8 ----- .../query/SqlTreeNodeFormulaWhereJoin.java | 6 ---- .../query/SqlTreeNodeManyWhereJoin.java | 6 ---- .../server/query/SqlTreeNodeRoot.java | 26 +++++++++++++- .../server/query/SqlTreeRoot.java | 34 +++++++++++++++++++ 9 files changed, 65 insertions(+), 46 deletions(-) create mode 100644 ebean-core/src/main/java/io/ebeaninternal/server/query/SqlTreeRoot.java diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/query/CQuery.java b/ebean-core/src/main/java/io/ebeaninternal/server/query/CQuery.java index 861ccc337..9f30e9a29 100644 --- a/ebean-core/src/main/java/io/ebeaninternal/server/query/CQuery.java +++ b/ebean-core/src/main/java/io/ebeaninternal/server/query/CQuery.java @@ -142,7 +142,7 @@ public class CQuery implements DbReadContext, CancelableQuery, SpiProfileTran * Tree that knows how to build the master and detail beans from the * resultSet. */ - private final SqlTreeNode rootNode; + private final SqlTreeRoot rootNode; /** * For master detail query. @@ -444,13 +444,13 @@ public class CQuery implements DbReadContext, CancelableQuery, SpiProfileTran if (manyProperty == null) { // only single resultSet row required to build object so we are done // read a single resultSet row into single bean - nextBean = rootNode.load(this, null, null); + nextBean = rootNode.load(this); return true; } if (nextBean == null) { // very first read - nextBean = rootNode.load(this, null, null); + nextBean = rootNode.load(this); } else { // nextBean set to previously read currentBean nextBean = currentBean; @@ -478,7 +478,7 @@ public class CQuery implements DbReadContext, CancelableQuery, SpiProfileTran * is different to the nextBean (false if we need to read more rows). */ private boolean checkForDifferentBean() throws SQLException { - currentBean = rootNode.load(this, null, null); + currentBean = rootNode.load(this); return currentBean != nextBean; } diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/query/SqlTree.java b/ebean-core/src/main/java/io/ebeaninternal/server/query/SqlTree.java index c537ace29..1befa650b 100644 --- a/ebean-core/src/main/java/io/ebeaninternal/server/query/SqlTree.java +++ b/ebean-core/src/main/java/io/ebeaninternal/server/query/SqlTree.java @@ -122,8 +122,8 @@ class SqlTree { return inheritanceWhereSql; } - SqlTreeNode getRootNode() { - return rootNode; + SqlTreeRoot getRootNode() { + return (SqlTreeRoot)rootNode; } /** diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/query/SqlTreeNode.java b/ebean-core/src/main/java/io/ebeaninternal/server/query/SqlTreeNode.java index b341802d1..39844cb59 100644 --- a/ebean-core/src/main/java/io/ebeaninternal/server/query/SqlTreeNode.java +++ b/ebean-core/src/main/java/io/ebeaninternal/server/query/SqlTreeNode.java @@ -73,11 +73,6 @@ interface SqlTreeNode { */ EntityBean load(DbReadContext ctx, EntityBean localBean, EntityBean contextBean) throws SQLException; - /** - * Load a version of a @History bean with effective dates. - */ - Version loadVersion(DbReadContext ctx) throws SQLException; - /** * Return true if the query has a many join. */ diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/query/SqlTreeNodeBean.java b/ebean-core/src/main/java/io/ebeaninternal/server/query/SqlTreeNodeBean.java index 010793506..51ed19d32 100644 --- a/ebean-core/src/main/java/io/ebeaninternal/server/query/SqlTreeNodeBean.java +++ b/ebean-core/src/main/java/io/ebeaninternal/server/query/SqlTreeNodeBean.java @@ -192,20 +192,6 @@ class SqlTreeNodeBean implements SqlTreeNode { } } - /** - * Read the version bean. - */ - @Override - @SuppressWarnings("unchecked") - public Version loadVersion(DbReadContext ctx) throws SQLException { - // read the sys period lower and upper bounds - // these are always the first 2 columns in the resultSet - Timestamp start = ctx.getDataReader().getTimestamp(); - Timestamp end = ctx.getDataReader().getTimestamp(); - T bean = (T) load(ctx, null, null); - return new Version<>(bean, start, end); - } - /** * Load that takes into account inheritance. */ diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/query/SqlTreeNodeExtraJoin.java b/ebean-core/src/main/java/io/ebeaninternal/server/query/SqlTreeNodeExtraJoin.java index fbab8e6b1..074457a30 100644 --- a/ebean-core/src/main/java/io/ebeaninternal/server/query/SqlTreeNodeExtraJoin.java +++ b/ebean-core/src/main/java/io/ebeaninternal/server/query/SqlTreeNodeExtraJoin.java @@ -178,14 +178,6 @@ class SqlTreeNodeExtraJoin implements SqlTreeNode { return null; } - /** - * Does nothing. - */ - @Override - public Version loadVersion(DbReadContext ctx) { - return null; - } - @Override public boolean hasMany() { return manyJoin; diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/query/SqlTreeNodeFormulaWhereJoin.java b/ebean-core/src/main/java/io/ebeaninternal/server/query/SqlTreeNodeFormulaWhereJoin.java index f5e47eac5..20a3037da 100644 --- a/ebean-core/src/main/java/io/ebeaninternal/server/query/SqlTreeNodeFormulaWhereJoin.java +++ b/ebean-core/src/main/java/io/ebeaninternal/server/query/SqlTreeNodeFormulaWhereJoin.java @@ -99,12 +99,6 @@ class SqlTreeNodeFormulaWhereJoin implements SqlTreeNode { return null; } - @Override - public Version loadVersion(DbReadContext ctx) { - // nothing to do here - return null; - } - @Override public boolean hasMany() { return true; diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/query/SqlTreeNodeManyWhereJoin.java b/ebean-core/src/main/java/io/ebeaninternal/server/query/SqlTreeNodeManyWhereJoin.java index f3d1999ca..c537c4bf7 100644 --- a/ebean-core/src/main/java/io/ebeaninternal/server/query/SqlTreeNodeManyWhereJoin.java +++ b/ebean-core/src/main/java/io/ebeaninternal/server/query/SqlTreeNodeManyWhereJoin.java @@ -144,12 +144,6 @@ class SqlTreeNodeManyWhereJoin implements SqlTreeNode { return null; } - @Override - public Version loadVersion(DbReadContext ctx) { - // nothing to do here - return null; - } - @Override public boolean hasMany() { return true; diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/query/SqlTreeNodeRoot.java b/ebean-core/src/main/java/io/ebeaninternal/server/query/SqlTreeNodeRoot.java index 3a7fffd98..e52477cf1 100644 --- a/ebean-core/src/main/java/io/ebeaninternal/server/query/SqlTreeNodeRoot.java +++ b/ebean-core/src/main/java/io/ebeaninternal/server/query/SqlTreeNodeRoot.java @@ -1,16 +1,21 @@ package io.ebeaninternal.server.query; +import io.ebean.Version; +import io.ebean.bean.EntityBean; import io.ebeaninternal.api.SpiQuery; +import io.ebeaninternal.server.deploy.DbReadContext; import io.ebeaninternal.server.deploy.DbSqlContext; import io.ebeaninternal.server.deploy.TableJoin; +import java.sql.SQLException; +import java.sql.Timestamp; import java.util.List; import java.util.Set; /** * Represents the root node of the Sql Tree. */ -final class SqlTreeNodeRoot extends SqlTreeNodeBean { +final class SqlTreeNodeRoot extends SqlTreeNodeBean implements SqlTreeRoot { private final TableJoin includeJoin; @@ -35,6 +40,25 @@ final class SqlTreeNodeRoot extends SqlTreeNodeBean { return true; } + @Override + public EntityBean load(DbReadContext ctx) throws SQLException { + return load(ctx, null, null); + } + + /** + * Read the version bean. + */ + @Override + @SuppressWarnings("unchecked") + public Version loadVersion(DbReadContext ctx) throws SQLException { + // read the sys period lower and upper bounds + // these are always the first 2 columns in the resultSet + Timestamp start = ctx.getDataReader().getTimestamp(); + Timestamp end = ctx.getDataReader().getTimestamp(); + T bean = (T) load(ctx, null, null); + return new Version<>(bean, start, end); + } + @Override public boolean isSqlDistinct() { return sqlDistinct; diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/query/SqlTreeRoot.java b/ebean-core/src/main/java/io/ebeaninternal/server/query/SqlTreeRoot.java new file mode 100644 index 000000000..64938bc22 --- /dev/null +++ b/ebean-core/src/main/java/io/ebeaninternal/server/query/SqlTreeRoot.java @@ -0,0 +1,34 @@ +package io.ebeaninternal.server.query; + +import io.ebean.Version; +import io.ebean.bean.EntityBean; +import io.ebean.core.type.ScalarDataReader; +import io.ebeaninternal.server.deploy.DbReadContext; + +import java.sql.SQLException; + +/** + * The root level node of the SqlTree. + */ +interface SqlTreeRoot { + + /** + * Load the bean from the DbReadContext. + *

+ * At a high level this actually controls the reading of the data from the + * jdbc resultSet and putting it into the bean etc. + *

+ */ + EntityBean load(DbReadContext ctx) throws SQLException; + + /** + * Load a version of a @History bean with effective dates. + */ + Version loadVersion(DbReadContext ctx) throws SQLException; + + /** + * Return a Scalar single attribute reader based on the first property. + */ + ScalarDataReader getSingleAttributeReader(); + +} From 68138bc0099f707a4f9191a7cfb1ddfd2ef40e39 Mon Sep 17 00:00:00 2001 From: Robin Bygrave Date: Mon, 1 Mar 2021 17:45:52 +1300 Subject: [PATCH 119/447] Refactor internals no effective change - reorder methods of SqlTreeNodeManyRoot --- .../server/query/SqlTreeNodeManyRoot.java | 23 +++++++++---------- 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/query/SqlTreeNodeManyRoot.java b/ebean-core/src/main/java/io/ebeaninternal/server/query/SqlTreeNodeManyRoot.java index a1f6ea357..4947514d1 100644 --- a/ebean-core/src/main/java/io/ebeaninternal/server/query/SqlTreeNodeManyRoot.java +++ b/ebean-core/src/main/java/io/ebeaninternal/server/query/SqlTreeNodeManyRoot.java @@ -18,14 +18,9 @@ final class SqlTreeNodeManyRoot extends SqlTreeNodeBean { this.manyProp = prop; } - /** - * Append the property columns to the buffer. - */ @Override - public void appendDistinctOn(DbSqlContext ctx, boolean subQuery) { - ctx.pushTableAlias(prefix); - appendSelectId(ctx, idBinder.getBeanProperty()); - ctx.popTableAlias(); + public boolean hasMany() { + return true; } @Override @@ -41,6 +36,15 @@ final class SqlTreeNodeManyRoot extends SqlTreeNodeBean { return detailBean; } + /** + * Append the property columns to the buffer. + */ + @Override + public void appendDistinctOn(DbSqlContext ctx, boolean subQuery) { + ctx.pushTableAlias(prefix); + appendSelectId(ctx, idBinder.getBeanProperty()); + ctx.popTableAlias(); + } /** * append extraWhere to the join. @@ -64,9 +68,4 @@ final class SqlTreeNodeManyRoot extends SqlTreeNodeBean { public void appendFrom(DbSqlContext ctx, SqlJoinType joinType) { super.appendFrom(ctx, joinType.autoToOuter()); } - - @Override - public boolean hasMany() { - return true; - } } From 5a73c85e6eab847037c83ea53d5eabbe11862e78 Mon Sep 17 00:00:00 2001 From: Robin Bygrave Date: Mon, 1 Mar 2021 18:36:49 +1300 Subject: [PATCH 120/447] Refactor internals - SqlTreeNodeBean add derived readIdNormal + private methods This is no effective change --- .../server/query/SqlTreeNodeBean.java | 34 +++++++++---------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/query/SqlTreeNodeBean.java b/ebean-core/src/main/java/io/ebeaninternal/server/query/SqlTreeNodeBean.java index 51ed19d32..011d9f1a7 100644 --- a/ebean-core/src/main/java/io/ebeaninternal/server/query/SqlTreeNodeBean.java +++ b/ebean-core/src/main/java/io/ebeaninternal/server/query/SqlTreeNodeBean.java @@ -1,6 +1,5 @@ package io.ebeaninternal.server.query; -import io.ebean.Version; import io.ebean.bean.BeanCollection; import io.ebean.bean.EntityBean; import io.ebean.bean.EntityBeanIntercept; @@ -16,7 +15,6 @@ import io.ebeaninternal.server.deploy.TableJoin; import io.ebeaninternal.server.deploy.id.IdBinder; import java.sql.SQLException; -import java.sql.Timestamp; import java.util.HashMap; import java.util.List; import java.util.Map; @@ -56,6 +54,7 @@ class SqlTreeNodeBean implements SqlTreeNode { * False if report bean and has no id property. */ final boolean readId; + private final boolean readIdNormal; private final boolean disableLazyLoad; @@ -120,7 +119,8 @@ class SqlTreeNodeBean implements SqlTreeNode { boolean aggregationRoot = props.isAggregationRoot(); // the bean has an Id property and we want to use it this.readId = !aggregationRoot && withId && desc.hasId(); - this.disableLazyLoad = disableLazyLoad || !readId || desc.isRawSqlBased() || temporalVersions; + this.readIdNormal = readId && !temporalVersions; + this.disableLazyLoad = disableLazyLoad || !readIdNormal || desc.isRawSqlBased(); this.partialObject = props.isPartialObject(); this.properties = props.getProps(); this.children = myChildren == null ? NO_CHILDREN : myChildren.toArray(new SqlTreeNode[0]); @@ -253,7 +253,7 @@ class SqlTreeNodeBean implements SqlTreeNode { this.parentBean = parentBean; } - void initLazyParent() throws SQLException { + private void initLazyParent() throws SQLException { if (lazyLoadParentIdBinder != null) { lazyLoadParentId = lazyLoadParentIdBinder.read(ctx); } @@ -265,12 +265,12 @@ class SqlTreeNodeBean implements SqlTreeNode { localIdBinder = idBinder; } - void initPersistenceContext() { + private void initPersistenceContext() { queryMode = ctx.getQueryMode(); - persistenceContext = (!readId || temporalVersions) ? null : ctx.getPersistenceContext(); + persistenceContext = (!readIdNormal) ? null : ctx.getPersistenceContext(); } - void readId() throws SQLException { + private void readId() throws SQLException { if (readId) { id = localIdBinder.readSet(ctx, localBean); if (id == null) { @@ -311,7 +311,7 @@ class SqlTreeNodeBean implements SqlTreeNode { } } - void initSqlLoadBean() { + private void initSqlLoadBean() { ctx.setCurrentPrefix(prefix, pathMap); ctx.propagateState(localBean); sqlBeanLoad = new SqlBeanLoad(ctx, localType, localBean, queryMode); @@ -323,7 +323,7 @@ class SqlTreeNodeBean implements SqlTreeNode { } } - void loadChildren() throws SQLException { + private void loadChildren() throws SQLException { //boolean lazyLoadMany = false; if (localBean == null && queryMode == Mode.LAZYLOAD_MANY) { // batch lazy load many into existing contextBean @@ -338,18 +338,18 @@ class SqlTreeNodeBean implements SqlTreeNode { } } - boolean isLazyLoadManyRoot() { + private boolean isLazyLoadManyRoot() { return queryMode == Mode.LAZYLOAD_MANY && isRoot(); } - EntityBean getContextBean() { + private EntityBean getContextBean() { return contextBean; } - void postLoad() { + private void postLoad() { if (!lazyLoadMany && localBean != null) { ctx.setCurrentPrefix(prefix, pathMap); - if (readId && !temporalVersions) { + if (readIdNormal) { createListProxies(); } if (temporalMode == SpiQuery.TemporalMode.DRAFT) { @@ -411,15 +411,15 @@ class SqlTreeNodeBean implements SqlTreeNode { } } - void setBeanToParent() { + private void setBeanToParent() { if (parentBean != null) { // set this back to the parentBean nodeBeanProp.setValue(parentBean, contextBean); } } - EntityBean complete() { - if (!readId || temporalVersions) { + private EntityBean complete() { + if (!readIdNormal) { // a bean with no Id (never found in context) if (lazyLoadParentId != null) { ctx.setLazyLoadedChildBean(localBean, lazyLoadParentId); @@ -434,7 +434,7 @@ class SqlTreeNodeBean implements SqlTreeNode { } } - void initialise() throws SQLException { + private void initialise() throws SQLException { initLazyParent(); initBeanType(); initPersistenceContext(); From 297c1d7abb2b28bb5457a9f51e14644159a52193 Mon Sep 17 00:00:00 2001 From: Robin Bygrave Date: Mon, 1 Mar 2021 20:27:50 +1300 Subject: [PATCH 121/447] #2179 - Improved fix for (2179) Fetch on nested one-to-many collections results in duplicates The improvement here is that SqlTreeNodeManyRoot uses load and isContextBean() so that it only checks if the collection already contains the detailBean if the detailBean was already in the persistence context (aka not newly loaded and added). The vast majority case is that detailBean is loaded fresh so for the common case we can skip the extra collection contains() check. --- .../main/java/io/ebean/common/BeanSet.java | 5 +- .../server/query/SqlTreeNodeBean.java | 48 ++++++++++++------- .../server/query/SqlTreeNodeManyRoot.java | 13 ++--- 3 files changed, 41 insertions(+), 25 deletions(-) diff --git a/ebean-api/src/main/java/io/ebean/common/BeanSet.java b/ebean-api/src/main/java/io/ebean/common/BeanSet.java index 91f0ae672..880ece106 100644 --- a/ebean-api/src/main/java/io/ebean/common/BeanSet.java +++ b/ebean-api/src/main/java/io/ebean/common/BeanSet.java @@ -70,9 +70,8 @@ public final class BeanSet extends AbstractBeanCollection implements Set Date: Mon, 1 Mar 2021 21:19:25 +1300 Subject: [PATCH 122/447] No effective change - refactor tidy SqlTreeNodeBean --- .../server/query/SqlTreeNodeBean.java | 37 +++++++------------ 1 file changed, 13 insertions(+), 24 deletions(-) diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/query/SqlTreeNodeBean.java b/ebean-core/src/main/java/io/ebeaninternal/server/query/SqlTreeNodeBean.java index b9df45760..1c9bff694 100644 --- a/ebean-core/src/main/java/io/ebeaninternal/server/query/SqlTreeNodeBean.java +++ b/ebean-core/src/main/java/io/ebeaninternal/server/query/SqlTreeNodeBean.java @@ -87,7 +87,6 @@ class SqlTreeNodeBean implements SqlTreeNode { */ SqlTreeNodeBean(String prefix, STreePropertyAssoc beanProp, SqlTreeProperties props, List myChildren, boolean withId, SpiQuery.TemporalMode temporalMode, boolean disableLazyLoad) { - this(prefix, beanProp, beanProp.target(), props, myChildren, withId, null, temporalMode, disableLazyLoad); } @@ -197,7 +196,7 @@ class SqlTreeNodeBean implements SqlTreeNode { */ private class LoadInherit extends Load { - LoadInherit(DbReadContext ctx, EntityBean parentBean) { + private LoadInherit(DbReadContext ctx, EntityBean parentBean) { super(ctx, parentBean); } @@ -218,10 +217,8 @@ class SqlTreeNodeBean implements SqlTreeNode { @Override void loadProperties() { - // take account of inheritance and due to subclassing approach - // need to get a 'local' version of the property + // take account of inheritance for (STreeProperty property : properties) { - // get a local version of the BeanProperty localDesc.inheritanceLoad(sqlBeanLoad, property, ctx); } } @@ -248,7 +245,7 @@ class SqlTreeNodeBean implements SqlTreeNode { SqlBeanLoad sqlBeanLoad; boolean lazyLoadMany; - Load(DbReadContext ctx, EntityBean parentBean) { + private Load(DbReadContext ctx, EntityBean parentBean) { this.ctx = ctx; this.parentBean = parentBean; } @@ -366,7 +363,6 @@ class SqlTreeNodeBean implements SqlTreeNode { if (disableLazyLoad) { // bean does not have an Id or is SqlSelect based ebi.setDisableLazyLoad(true); - } else if (partialObject) { if (readId) { // register for lazy loading @@ -390,7 +386,6 @@ class SqlTreeNodeBean implements SqlTreeNode { private void createListProxies() { STreePropertyAssocMany fetchedMany = ctx.getManyProperty(); boolean forceNewReference = queryMode == Mode.REFRESH_BEAN; - // load the List/Set/Map proxy objects (deferred fetching of lists) for (STreePropertyAssocMany many : localDesc.propsMany()) { if (many != fetchedMany) { // create a proxy for the many (deferred fetching) @@ -491,8 +486,8 @@ class SqlTreeNodeBean implements SqlTreeNode { property.appendSelect(ctx, subQuery); } } - for (SqlTreeNode aChildren : children) { - aChildren.appendGroupBy(ctx, subQuery); + for (SqlTreeNode child : children) { + child.appendGroupBy(ctx, subQuery); } ctx.popTableAlias(); ctx.popJoin(); @@ -529,11 +524,8 @@ class SqlTreeNodeBean implements SqlTreeNode { appendSelectId(ctx, idBinder.getBeanProperty()); } appendSelect(ctx, subQuery, properties); - - for (SqlTreeNode aChildren : children) { - // read each child... and let them set their - // values back to this localBean - aChildren.appendSelect(ctx, subQuery); + for (SqlTreeNode child : children) { + child.appendSelect(ctx, subQuery); } ctx.popTableAlias(); ctx.popJoin(); @@ -581,10 +573,8 @@ class SqlTreeNodeBean implements SqlTreeNode { } } appendExtraWhere(ctx); - for (SqlTreeNode aChildren : children) { - // recursively add to the where clause any - // fixed predicates (extraWhere etc) - aChildren.appendWhere(ctx); + for (SqlTreeNode child : children) { + child.appendWhere(ctx); } } @@ -620,10 +610,9 @@ class SqlTreeNodeBean implements SqlTreeNode { property.appendFrom(ctx, joinType); } - for (SqlTreeNode aChildren : children) { - aChildren.appendFrom(ctx, joinType); + for (SqlTreeNode child : children) { + child.appendFrom(ctx, joinType); } - ctx.popTableAlias(); ctx.popJoin(); } @@ -648,8 +637,8 @@ class SqlTreeNodeBean implements SqlTreeNode { if (intersectionAsOfTableAlias) { query.incrementAsOfTableCount(); } - for (SqlTreeNode aChildren : children) { - aChildren.addAsOfTableAlias(query); + for (SqlTreeNode child : children) { + child.addAsOfTableAlias(query); } } From 464f48d71726a164bbbc70505e532d8b1d49445c Mon Sep 17 00:00:00 2001 From: Robin Bygrave Date: Mon, 1 Mar 2021 21:34:17 +1300 Subject: [PATCH 123/447] Bump test kotlin-querybean-generator version --- kotlin-querybean-generator/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kotlin-querybean-generator/pom.xml b/kotlin-querybean-generator/pom.xml index 8529dbe7f..4373c3275 100644 --- a/kotlin-querybean-generator/pom.xml +++ b/kotlin-querybean-generator/pom.xml @@ -106,7 +106,7 @@ io.ebean kotlin-querybean-generator - 12.6.1 + 12.7.1 From 6315edfc214066a63336f42d2e4f2ce4503904bc Mon Sep 17 00:00:00 2001 From: Robin Bygrave Date: Mon, 1 Mar 2021 22:08:17 +1300 Subject: [PATCH 124/447] #2177 - findNative not mapping bean when schema specified in entity mapping --- .../server/deploy/BeanDescriptor.java | 17 +++- .../server/query/CQueryBuilder.java | 3 +- .../test/java/org/example/domain/Product.java | 2 +- .../org/querytest/FindNative_withSchema.java | 78 +++++++++++++++++++ .../resources/application-test.properties | 1 + .../src/test/resources/init-db.sql | 1 + 6 files changed, 96 insertions(+), 6 deletions(-) create mode 100644 ebean-querybean/src/test/java/org/querytest/FindNative_withSchema.java create mode 100644 ebean-querybean/src/test/resources/init-db.sql diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/deploy/BeanDescriptor.java b/ebean-core/src/main/java/io/ebeaninternal/server/deploy/BeanDescriptor.java index c2c69b164..a2d902f13 100644 --- a/ebean-core/src/main/java/io/ebeaninternal/server/deploy/BeanDescriptor.java +++ b/ebean-core/src/main/java/io/ebeaninternal/server/deploy/BeanDescriptor.java @@ -727,7 +727,7 @@ public class BeanDescriptor implements BeanType, STreeType { String[] cols = indexDef.getColumns(); BeanProperty[] props = new BeanProperty[cols.length]; for (int i = 0; i < cols.length; i++) { - String propName = findBeanPath("", cols[i]); + String propName = findBeanPath("", "", cols[i]); if (propName == null) { return; } @@ -2472,13 +2472,16 @@ public class BeanDescriptor implements BeanType, STreeType { /** * Return the property path given the db table and column. */ - public String findBeanPath(String tableName, String columnName) { - if (tableName.isEmpty() || tableName.equalsIgnoreCase(baseTable)) { + public String findBeanPath(String schemaName, String tableName, String columnName) { + if (matchBaseTable(schemaName, tableName)) { return columnPath.get(columnName); } BeanPropertyAssoc assocProperty = tablePath.get(tableName); + if (assocProperty == null) { + assocProperty = tablePath.get(schemaName + "." + tableName); + } if (assocProperty != null) { - String relativePath = assocProperty.getTargetDescriptor().findBeanPath(tableName, columnName); + String relativePath = assocProperty.getTargetDescriptor().findBeanPath(schemaName, tableName, columnName); if (relativePath != null) { return SplitName.add(assocProperty.getName(), relativePath); } @@ -2486,6 +2489,12 @@ public class BeanDescriptor implements BeanType, STreeType { return null; } + private boolean matchBaseTable(String schemaName, String tableName) { + return tableName.isEmpty() + || baseTable.equalsIgnoreCase(tableName) + || baseTable.equalsIgnoreCase(schemaName + "." + tableName); + } + /** * Return a 'dynamic property' used to read a formula. */ diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/query/CQueryBuilder.java b/ebean-core/src/main/java/io/ebeaninternal/server/query/CQueryBuilder.java index 75aa7e3cc..ab008a5cf 100644 --- a/ebean-core/src/main/java/io/ebeaninternal/server/query/CQueryBuilder.java +++ b/ebean-core/src/main/java/io/ebeaninternal/server/query/CQueryBuilder.java @@ -442,9 +442,10 @@ class CQueryBuilder { int cols = 1 + metaData.getColumnCount(); List propertyNames = new ArrayList<>(cols - 1); for (int i = 1; i < cols; i++) { + String schemaName = metaData.getSchemaName(i).toLowerCase(); String tableName = metaData.getTableName(i).toLowerCase(); String columnName = metaData.getColumnName(i).toLowerCase(); - String path = desc.findBeanPath(tableName, columnName); + String path = desc.findBeanPath(schemaName, tableName, columnName); if (path != null) { propertyNames.add(path); } else { diff --git a/ebean-querybean/src/test/java/org/example/domain/Product.java b/ebean-querybean/src/test/java/org/example/domain/Product.java index e41d4fc34..ed58daa05 100644 --- a/ebean-querybean/src/test/java/org/example/domain/Product.java +++ b/ebean-querybean/src/test/java/org/example/domain/Product.java @@ -8,7 +8,7 @@ import javax.validation.constraints.Size; * Product entity bean. */ @Entity -@Table(name = "o_product") +@Table(name = "o_product", schema = "foo") public class Product extends BaseModel { @Size(max = 20) diff --git a/ebean-querybean/src/test/java/org/querytest/FindNative_withSchema.java b/ebean-querybean/src/test/java/org/querytest/FindNative_withSchema.java new file mode 100644 index 000000000..59146648d --- /dev/null +++ b/ebean-querybean/src/test/java/org/querytest/FindNative_withSchema.java @@ -0,0 +1,78 @@ +package org.querytest; + +import io.ebean.DB; +import org.example.domain.Customer; +import org.example.domain.Order; +import org.example.domain.OrderDetail; +import org.example.domain.Product; +import org.junit.Test; + +import java.util.List; + +import static org.assertj.core.api.Assertions.assertThat; + +public class FindNative_withSchema { + + @Test + public void test_rootLevelUsesSchema() { + + Product p = new Product(); + p.setName("prod1"); + p.setSku("p1"); + p.save(); + + String sql = "select * from foo.o_product p where p.sku = ?"; + + Product product = DB.findNative(Product.class, sql) + .setParameter("p1") + .findOne(); + + assertThat(product).isNotNull(); + assertThat(product.getName()).isEqualTo("prod1"); + } + + @Test + public void test_joinToSchema() { + + Order order = setupData(); + + String sql = "select l.*, p.* " + + " from o_order_detail l " + + " join foo.o_product p on p.id = l.product_id " + + " where l.order_id = ?"; + + List lines = DB.findNative(OrderDetail.class, sql) + .setParameter(order.getId()) + .findList(); + + assertThat(lines).hasSize(1); + OrderDetail line = lines.get(0); + Product product = line.getProduct(); + + // check normal bean population + assertThat(line.getOrderQty()).isEqualTo(10); + assertThat(line.getOrder().getId()).isEqualTo(order.getId()); + // check associated bean with schema is populated + assertThat(product).isNotNull(); + assertThat(product.getName()).isEqualTo("prod2"); + } + + private Order setupData() { + Product p = new Product(); + p.setName("prod2"); + p.setSku("p2"); + p.save(); + + Customer customer = new Customer(); + customer.setName("junk"); + customer.save(); + Order order = new Order(); + order.setCustomer(customer); + + OrderDetail line = new OrderDetail(p, 10, 10.0); + order.getDetails().add(line); + + order.save(); + return order; + } +} diff --git a/ebean-querybean/src/test/resources/application-test.properties b/ebean-querybean/src/test/resources/application-test.properties index 68e06a3f9..76f2d661f 100644 --- a/ebean-querybean/src/test/resources/application-test.properties +++ b/ebean-querybean/src/test/resources/application-test.properties @@ -1,5 +1,6 @@ ebean.ddl.generate=true ebean.ddl.run=true +ebean.ddl.initSql=init-db.sql datasource.default=h2 diff --git a/ebean-querybean/src/test/resources/init-db.sql b/ebean-querybean/src/test/resources/init-db.sql new file mode 100644 index 000000000..fde39032e --- /dev/null +++ b/ebean-querybean/src/test/resources/init-db.sql @@ -0,0 +1 @@ +create schema foo; From 7bfacb095b0de1d39bccb54325272c7774dfac1b Mon Sep 17 00:00:00 2001 From: Robin Bygrave Date: Mon, 1 Mar 2021 22:47:34 +1300 Subject: [PATCH 125/447] #2181 - Oracle 9,10,11 rownum based limiting for SqlQuery and DtoQuery (rather than Oracle 12g row limiting) --- .../dbplatform/oracle/Oracle11Platform.java | 1 + .../oracle/OracleRownumBasicLimiter.java | 35 +++++++++++++++++++ 2 files changed, 36 insertions(+) create mode 100644 ebean-api/src/main/java/io/ebean/config/dbplatform/oracle/OracleRownumBasicLimiter.java diff --git a/ebean-api/src/main/java/io/ebean/config/dbplatform/oracle/Oracle11Platform.java b/ebean-api/src/main/java/io/ebean/config/dbplatform/oracle/Oracle11Platform.java index e13155f3f..cb32a7470 100644 --- a/ebean-api/src/main/java/io/ebean/config/dbplatform/oracle/Oracle11Platform.java +++ b/ebean-api/src/main/java/io/ebean/config/dbplatform/oracle/Oracle11Platform.java @@ -13,6 +13,7 @@ public class Oracle11Platform extends OraclePlatform { this.platform = Platform.ORACLE11; this.columnAliasPrefix = "c"; this.sqlLimiter = new OracleRownumSqlLimiter(); + this.basicSqlLimiter = new OracleRownumBasicLimiter(); dbIdentity.setIdType(IdType.SEQUENCE); } } diff --git a/ebean-api/src/main/java/io/ebean/config/dbplatform/oracle/OracleRownumBasicLimiter.java b/ebean-api/src/main/java/io/ebean/config/dbplatform/oracle/OracleRownumBasicLimiter.java new file mode 100644 index 000000000..e51df98cb --- /dev/null +++ b/ebean-api/src/main/java/io/ebean/config/dbplatform/oracle/OracleRownumBasicLimiter.java @@ -0,0 +1,35 @@ +package io.ebean.config.dbplatform.oracle; + +import io.ebean.config.dbplatform.BasicSqlLimiter; + +/** + * Row limiter for Oracle 9,10,11 using rownum. + */ +public class OracleRownumBasicLimiter implements BasicSqlLimiter { + + @Override + public String limit(String dbSql, int firstRow, int maxRows) { + if (firstRow < 1 && maxRows < 1) { + return dbSql; + } + StringBuilder sb = new StringBuilder(60 + dbSql.length()); + int lastRow = maxRows; + if (lastRow > 0) { + lastRow += firstRow; + } + sb.append("select * from (select "); + if (maxRows > 0) { + sb.append("/*+ FIRST_ROWS(").append(maxRows).append(") */ "); + } + sb.append("a.*, rownum rn_ from ("); + sb.append(dbSql).append(") a "); + if (lastRow > 0) { + sb.append(" where rownum <= ").append(lastRow); + } + sb.append(") "); + if (firstRow > 0) { + sb.append(" where rn_ > ").append(firstRow); + } + return sb.toString(); + } +} From 1a26cd717f75ba6c2584b5066c1af6b476984510 Mon Sep 17 00:00:00 2001 From: robin Date: Mon, 1 Mar 2021 23:40:06 +1300 Subject: [PATCH 126/447] #2182 - Tidy javadoc - this may mean JDK 15 is required to generate javadoc --- .../src/main/java/io/ebean/BeanFinder.java | 2 +- .../main/java/io/ebean/BeanRepository.java | 4 +- .../src/main/java/io/ebean/Database.java | 2 +- .../src/main/java/io/ebean/DocumentStore.java | 2 +- ebean-api/src/main/java/io/ebean/Ebean.java | 2 +- .../main/java/io/ebean/ExpressionFactory.java | 4 +- .../main/java/io/ebean/ExpressionList.java | 4 +- ebean-api/src/main/java/io/ebean/Finder.java | 4 +- ebean-api/src/main/java/io/ebean/Model.java | 12 ++-- ebean-api/src/main/java/io/ebean/Pairs.java | 2 +- ebean-api/src/main/java/io/ebean/RawSql.java | 8 +-- .../src/main/java/io/ebean/RowMapper.java | 2 +- ebean-api/src/main/java/io/ebean/Update.java | 12 ++-- .../ebean/config/DatabaseConfigProvider.java | 2 +- .../io/ebean/config/ServerConfigProvider.java | 2 +- .../config/dbplatform/DbDefaultValue.java | 2 +- .../io/ebean/typequery/PBaseCompareable.java | 8 +-- .../java/io/ebean/typequery/TQRootBean.java | 56 +++++++------------ 18 files changed, 57 insertions(+), 73 deletions(-) diff --git a/ebean-api/src/main/java/io/ebean/BeanFinder.java b/ebean-api/src/main/java/io/ebean/BeanFinder.java index 00aec8de5..2c8e04eec 100644 --- a/ebean-api/src/main/java/io/ebean/BeanFinder.java +++ b/ebean-api/src/main/java/io/ebean/BeanFinder.java @@ -14,7 +14,7 @@ import java.util.Optional; * * public class CustomerFinder extends BeanFinder { * - * ï¼ Inject + * @Inject * public CustomerFinder(Database database) { * super(Customer.class, database); * } diff --git a/ebean-api/src/main/java/io/ebean/BeanRepository.java b/ebean-api/src/main/java/io/ebean/BeanRepository.java index 19f390582..b89a49b39 100644 --- a/ebean-api/src/main/java/io/ebean/BeanRepository.java +++ b/ebean-api/src/main/java/io/ebean/BeanRepository.java @@ -9,10 +9,10 @@ import java.util.Collection; *

*

{@code
  *
- * ï¼ Repository
+ * @Repository
  * public class CustomerRepository extends BeanRepository {
  *
- *   ï¼ Inject
+ *   @Inject
  *   public CustomerRepository(Database server) {
  *     super(Customer.class, server);
  *   }
diff --git a/ebean-api/src/main/java/io/ebean/Database.java b/ebean-api/src/main/java/io/ebean/Database.java
index 5bbf29ad3..bd38253de 100644
--- a/ebean-api/src/main/java/io/ebean/Database.java
+++ b/ebean-api/src/main/java/io/ebean/Database.java
@@ -897,7 +897,7 @@ public interface Database {
    * 
{@code
    *   public class Order { ...
    *
-   *     ï¼ OneToMany(cascade=CascadeType.ALL, mappedBy="order")
+   *     @OneToMany(cascade=CascadeType.ALL, mappedBy="order")
    * 	   List details;
    * 	   ...
    *   }
diff --git a/ebean-api/src/main/java/io/ebean/DocumentStore.java b/ebean-api/src/main/java/io/ebean/DocumentStore.java
index a4f75132d..0a2353ff0 100644
--- a/ebean-api/src/main/java/io/ebean/DocumentStore.java
+++ b/ebean-api/src/main/java/io/ebean/DocumentStore.java
@@ -149,7 +149,7 @@ public interface DocumentStore {
    *    .setUseDocStore(true)
    *    .where()... // perhaps add predicates
    *    .findEachWhile(new Predicate() {
-   *      ï¼ Override
+   *      @Override
    *      public void accept(Order bean) {
    *        // process the bean
    *
diff --git a/ebean-api/src/main/java/io/ebean/Ebean.java b/ebean-api/src/main/java/io/ebean/Ebean.java
index f68a0666b..fb0e34db3 100644
--- a/ebean-api/src/main/java/io/ebean/Ebean.java
+++ b/ebean-api/src/main/java/io/ebean/Ebean.java
@@ -346,7 +346,7 @@ public final class Ebean {
    * 
{@code
    *   public class Order { ...
    *
-   *     ï¼ OneToMany(cascade=CascadeType.ALL, mappedBy="order")
+   *     @OneToMany(cascade=CascadeType.ALL, mappedBy="order")
    * 	   List details;
    * 	   ...
    *   }
diff --git a/ebean-api/src/main/java/io/ebean/ExpressionFactory.java b/ebean-api/src/main/java/io/ebean/ExpressionFactory.java
index 1e5c4ebf5..3bcd5cb39 100644
--- a/ebean-api/src/main/java/io/ebean/ExpressionFactory.java
+++ b/ebean-api/src/main/java/io/ebean/ExpressionFactory.java
@@ -200,7 +200,7 @@ public interface ExpressionFactory {
   Expression gtOrNull(String propertyName, Object value);
 
   /**
-   * Greater than or Equal to OR Null  >= or null 
+   * Greater than or Equal to OR Null ({@code >= or null })
    * 

* A convenient expression combining GE and Is Null. Most often useful for range * expressions where the top range value is nullable. @@ -227,7 +227,7 @@ public interface ExpressionFactory { Expression ltOrNull(String propertyName, Object value); /** - * Less Than or Equal to OR Null <= or null + * Less Than or Equal to OR Null ({@code <= or null }) *

* A convenient expression combining LE and Is Null. Most often useful for range * expressions where the bottom range value is nullable. diff --git a/ebean-api/src/main/java/io/ebean/ExpressionList.java b/ebean-api/src/main/java/io/ebean/ExpressionList.java index e137f64ba..7e4e0f164 100644 --- a/ebean-api/src/main/java/io/ebean/ExpressionList.java +++ b/ebean-api/src/main/java/io/ebean/ExpressionList.java @@ -909,7 +909,7 @@ public interface ExpressionList { ExpressionList gtOrNull(String propertyName, Object value); /** - * Greater Than or Equal to OR Null - >= or null . + * Greater Than or Equal to OR Null - ({@code >= or null }). */ ExpressionList geOrNull(String propertyName, Object value); @@ -930,7 +930,7 @@ public interface ExpressionList { ExpressionList ltOrNull(String propertyName, Object value); /** - * Less Than or Equal to OR Null - <= or null . + * Less Than or Equal to OR Null - ({@code <= or null }). */ ExpressionList leOrNull(String propertyName, Object value); diff --git a/ebean-api/src/main/java/io/ebean/Finder.java b/ebean-api/src/main/java/io/ebean/Finder.java index e91238344..3c9318e7d 100644 --- a/ebean-api/src/main/java/io/ebean/Finder.java +++ b/ebean-api/src/main/java/io/ebean/Finder.java @@ -37,7 +37,7 @@ import java.util.List; * } * } * - * ï¼ Entity + * @Entity * public class Customer extends BaseModel { * * public static final CustomerFinder find = new CustomerFinder(); @@ -80,7 +80,7 @@ public class Finder { * // ... add extra customer specific finder methods * } * - * ï¼ Entity + * @Entity * public class Customer extends BaseModel { * * public static final CustomerFinder find = new CustomerFinder(); diff --git a/ebean-api/src/main/java/io/ebean/Model.java b/ebean-api/src/main/java/io/ebean/Model.java index 5fe2205e1..ac2f11ea7 100644 --- a/ebean-api/src/main/java/io/ebean/Model.java +++ b/ebean-api/src/main/java/io/ebean/Model.java @@ -32,16 +32,16 @@ import io.ebean.bean.EntityBean; * // Typically there is a common base model that has some * // common properties like the ones below * - * ï¼ MappedSuperclass + * @MappedSuperclass * public class BaseModel extends Model { * - * ï¼ Id Long id; + * @Id Long id; * - * ï¼ Version Long version; + * @Version Long version; * - * ï¼ WhenCreated Timestamp whenCreated; + * @WhenCreated Timestamp whenCreated; * - * ï¼ WhenUpdated Timestamp whenUpdated; + * @WhenUpdated Timestamp whenUpdated; * * ... * } @@ -52,7 +52,7 @@ import io.ebean.bean.EntityBean; * * // Extend the mappedSuperclass * - * ï¼ Entity ï¼ Table(name="o_account") + * @Entity @Table(name="o_account") * public class Customer extends BaseModel { * * String name; diff --git a/ebean-api/src/main/java/io/ebean/Pairs.java b/ebean-api/src/main/java/io/ebean/Pairs.java index 4f609f95a..bd5ee5137 100644 --- a/ebean-api/src/main/java/io/ebean/Pairs.java +++ b/ebean-api/src/main/java/io/ebean/Pairs.java @@ -18,7 +18,7 @@ import java.util.List; * * // where a bean is annotated with a complex * // natural key made of several properties - * ï¼ Cache(naturalKey = {"store","code","sku"}) + * @Cache(naturalKey = {"store","code","sku"}) * * * Pairs pairs = new Pairs("sku", "code"); diff --git a/ebean-api/src/main/java/io/ebean/RawSql.java b/ebean-api/src/main/java/io/ebean/RawSql.java index e0e20714b..901f1a43c 100644 --- a/ebean-api/src/main/java/io/ebean/RawSql.java +++ b/ebean-api/src/main/java/io/ebean/RawSql.java @@ -41,14 +41,14 @@ package io.ebean; *

Example OrderAggregate

*
{@code
  *  ...
- *   // ï¼ Sql indicates to that this bean
+ *   // @Sql indicates to that this bean
  *   // is based on RawSql rather than a table
  *
- *   ï¼ Entity
- *   ï¼ Sql
+ *   @Entity
+ *   @Sql
  *   public class OrderAggregate {
  *
- *    ï¼ OneToOne
+ *    @OneToOne
  *    Order order;
  *
  *    Double totalAmount;
diff --git a/ebean-api/src/main/java/io/ebean/RowMapper.java b/ebean-api/src/main/java/io/ebean/RowMapper.java
index 47e96498d..b1d59c984 100644
--- a/ebean-api/src/main/java/io/ebean/RowMapper.java
+++ b/ebean-api/src/main/java/io/ebean/RowMapper.java
@@ -22,7 +22,7 @@ import java.sql.SQLException;
  *    //
  *    class CustomerMapper implements RowMapper {
  *
- *     ï¼ Override
+ *     @Override
  *     public CustomerDto map(ResultSet rset, int rowNum) throws SQLException {
  *
  *       long id = rset.getLong(1);
diff --git a/ebean-api/src/main/java/io/ebean/Update.java b/ebean-api/src/main/java/io/ebean/Update.java
index 25aed9315..ece973392 100644
--- a/ebean-api/src/main/java/io/ebean/Update.java
+++ b/ebean-api/src/main/java/io/ebean/Update.java
@@ -13,23 +13,23 @@ package io.ebean;
  * 

*
{@code
  *    ...
- *   ï¼ NamedUpdates(value = {
- *     ï¼ NamedUpdate(
+ *   @NamedUpdates(value = {
+ *     @NamedUpdate(
  *       name = "setTitle",
  *       notifyCache = false,
  *       update = "update topic set title = :title, postCount = :count where id = :id"),
- *    ï¼ NamedUpdate(
+ *    @NamedUpdate(
  *       name = "setPostCount",
  *       notifyCache = false,
  *       update = "update f_topic set post_count = :postCount where id = :id"),
- *    ï¼ NamedUpdate(
+ *    @NamedUpdate(
  *       name = "incrementPostCount",
  *       notifyCache = false,
  *       update = "update Topic set postCount = postCount + 1 where id = :id")
  *       //update = "update f_topic set post_count = post_count + 1 where id = :id")
  *   })
- *   ï¼ Entity
- *   ï¼ Table(name = "f_topic")
+ *   @Entity
+ *   @Table(name = "f_topic")
  *   public class Topic {
  *     ...
  *   }
diff --git a/ebean-api/src/main/java/io/ebean/config/DatabaseConfigProvider.java b/ebean-api/src/main/java/io/ebean/config/DatabaseConfigProvider.java
index 0a1f3e768..066af5fc4 100644
--- a/ebean-api/src/main/java/io/ebean/config/DatabaseConfigProvider.java
+++ b/ebean-api/src/main/java/io/ebean/config/DatabaseConfigProvider.java
@@ -15,7 +15,7 @@ package io.ebean.config;
  *
  * public class EbeanConfigProvider implements DatabaseConfigProvider {
  *
- *   ï¼ Override
+ *   @Override
  *   public void apply(DatabaseConfig config) {
  *
  *     // register the entity bean classes explicitly
diff --git a/ebean-api/src/main/java/io/ebean/config/ServerConfigProvider.java b/ebean-api/src/main/java/io/ebean/config/ServerConfigProvider.java
index f992b004d..1ba45907d 100644
--- a/ebean-api/src/main/java/io/ebean/config/ServerConfigProvider.java
+++ b/ebean-api/src/main/java/io/ebean/config/ServerConfigProvider.java
@@ -16,7 +16,7 @@ package io.ebean.config;
  *
  * public class EbeanConfigProvider implements ServerConfigProvider {
  *
- *   ï¼ Override
+ *   @Override
  *   public void apply(ServerConfig config) {
  *
  *     // register the entity bean classes explicitly
diff --git a/ebean-api/src/main/java/io/ebean/config/dbplatform/DbDefaultValue.java b/ebean-api/src/main/java/io/ebean/config/dbplatform/DbDefaultValue.java
index b74465f35..851fc2707 100644
--- a/ebean-api/src/main/java/io/ebean/config/dbplatform/DbDefaultValue.java
+++ b/ebean-api/src/main/java/io/ebean/config/dbplatform/DbDefaultValue.java
@@ -79,7 +79,7 @@ public class DbDefaultValue {
   }
 
   /**
-   * This method checks & convert the {@link DbDefault#value()} to a valid SQL literal.
+   * This method checks and converts the {@link DbDefault#value()} to a valid SQL literal.
    *
    * This is mainly to quote string literals and verify integer/dates for correctness.
    * 

diff --git a/ebean-querybean/src/main/java/io/ebean/typequery/PBaseCompareable.java b/ebean-querybean/src/main/java/io/ebean/typequery/PBaseCompareable.java index c9488f63c..4e0ba7c1d 100644 --- a/ebean-querybean/src/main/java/io/ebean/typequery/PBaseCompareable.java +++ b/ebean-querybean/src/main/java/io/ebean/typequery/PBaseCompareable.java @@ -121,12 +121,12 @@ public class PBaseCompareable extends PBaseValueEqual { * Greater or equal to lower value and strictly less than upper value. *

* This is generally preferable over Between for date and datetime types - * as SQL Between is inclusive on the upper bound (<=) and generally we - * need the upper bound to be exclusive (<). + * as SQL Between is inclusive on the upper bound ({@code <= }) and generally + * we need the upper bound to be exclusive ({@code < }). *

* - * @param lower the lower bind value (>=) - * @param upper the upper bind value (<) + * @param lower the lower bind value ({@code >= }) + * @param upper the upper bind value ({@code < }) * @return the root query bean instance */ public final R inRange(T lower, T upper) { diff --git a/ebean-querybean/src/main/java/io/ebean/typequery/TQRootBean.java b/ebean-querybean/src/main/java/io/ebean/typequery/TQRootBean.java index de8f846a6..4deab6037 100644 --- a/ebean-querybean/src/main/java/io/ebean/typequery/TQRootBean.java +++ b/ebean-querybean/src/main/java/io/ebean/typequery/TQRootBean.java @@ -43,55 +43,39 @@ import java.util.function.Predicate; import java.util.stream.Stream; /** - * Base root query bean. + * Base root query bean providing common features for all root query beans. *

- * With code generation for each entity bean type a query bean is created that extends this. + * For each entity bean querybean-generator generates a query bean that extends TQRootBean. *

- * Provides common features for all root query beans + * *

- *

- *

Example - QCustomer extends TQRootBean

- *

- * These 'query beans' like QCustomer are generated using the avaje-ebeanorm-typequery-generator. - *

- *
{@code
- *
- *   public class QCustomer extends TQRootBean {
- *
- *     // properties
- *     public PLong id;
- *
- *     public PString name;
- *     ...
- *
- * }
- *

*

Example - usage of QCustomer

*
{@code
  *
- *    Date fiveDaysAgo = ...
+ *  Date fiveDaysAgo = ...
  *
- *    List customers =
- *        new QCustomer()
- *          .name.ilike("rob")
- *          .status.equalTo(Customer.Status.GOOD)
- *          .registered.after(fiveDaysAgo)
- *          .contacts.email.endsWith("@foo.com")
- *          .orderBy()
- *            .name.asc()
- *            .registered.desc()
- *          .findList();
+ *  List customers =
+ *      new QCustomer()
+ *        .name.ilike("rob")
+ *        .status.equalTo(Customer.Status.GOOD)
+ *        .registered.after(fiveDaysAgo)
+ *        .contacts.email.endsWith("@foo.com")
+ *        .orderBy()
+ *          .name.asc()
+ *          .registered.desc()
+ *        .findList();
  *
  * }
*

*

Resulting SQL where

*

- *

{@code sql
+ * 
{@code
  *
- *     where lower(t0.name) like ?  and t0.status = ?  and t0.registered > ?  and u1.email like ?
- *     order by t0.name, t0.registered desc;
+ *   where lower(t0.name) like ?  and t0.status = ?  and t0.registered > ?  and u1.email like ?
+ *   order by t0.name, t0.registered desc;
+ *
+ *   --bind(rob,GOOD,Mon Jul 27 12:05:37 NZST 2015,%@foo.com)
  *
- *     --bind(rob,GOOD,Mon Jul 27 12:05:37 NZST 2015,%@foo.com)
  * }
* * @param the entity bean type (normal entity bean type e.g. Customer) @@ -280,7 +264,7 @@ public abstract class TQRootBean { */ @SafeVarargs public final R select(TQProperty... properties) { - ((SpiQueryFetch)query).selectProperties(properties(properties)); + ((SpiQueryFetch) query).selectProperties(properties(properties)); return root; } From 907b182931372719924674de312f8d63319da69b Mon Sep 17 00:00:00 2001 From: robin Date: Mon, 1 Mar 2021 23:45:05 +1300 Subject: [PATCH 127/447] [maven-release-plugin] prepare release ebean-parent-12.7.2 --- ebean-api/pom.xml | 2 +- ebean-autotune/pom.xml | 6 +++--- ebean-bom/pom.xml | 30 +++++++++++++++--------------- ebean-core-type/pom.xml | 4 ++-- ebean-core/pom.xml | 10 +++++----- ebean-ddl-generator/pom.xml | 6 +++--- ebean-externalmapping-api/pom.xml | 2 +- ebean-externalmapping-xml/pom.xml | 10 +++++----- ebean-postgis/pom.xml | 6 +++--- ebean-querybean/pom.xml | 10 +++++----- ebean-redis/pom.xml | 12 ++++++------ ebean-test/pom.xml | 6 +++--- ebean/pom.xml | 8 ++++---- kotlin-querybean-generator/pom.xml | 8 ++++---- pom.xml | 4 ++-- querybean-generator/pom.xml | 2 +- 16 files changed, 63 insertions(+), 63 deletions(-) diff --git a/ebean-api/pom.xml b/ebean-api/pom.xml index 79962ff51..1aed817f7 100644 --- a/ebean-api/pom.xml +++ b/ebean-api/pom.xml @@ -4,7 +4,7 @@ ebean-parent io.ebean - 12.7.2-SNAPSHOT + 12.7.2 ebean api diff --git a/ebean-autotune/pom.xml b/ebean-autotune/pom.xml index b86469ddd..0646db6e7 100644 --- a/ebean-autotune/pom.xml +++ b/ebean-autotune/pom.xml @@ -4,7 +4,7 @@ ebean-parent io.ebean - 12.7.2-SNAPSHOT + 12.7.2 @@ -14,7 +14,7 @@ scm:git:git@github.com:ebean-orm/ebean.git - ebean-parent-12.6.5 + ebean-parent-12.7.2 ebean autotune @@ -26,7 +26,7 @@ io.ebean ebean-core - 12.7.2-SNAPSHOT + 12.7.2 provided diff --git a/ebean-bom/pom.xml b/ebean-bom/pom.xml index c47601c85..4cec55855 100644 --- a/ebean-bom/pom.xml +++ b/ebean-bom/pom.xml @@ -4,7 +4,7 @@ ebean-parent io.ebean - 12.7.2-SNAPSHOT + 12.7.2 ebean bom @@ -81,88 +81,88 @@ io.ebean ebean - 12.7.2-SNAPSHOT + 12.7.2 io.ebean ebean-api - 12.7.2-SNAPSHOT + 12.7.2 io.ebean ebean-core - 12.7.2-SNAPSHOT + 12.7.2 io.ebean ebean-core-type - 12.7.2-SNAPSHOT + 12.7.2 io.ebean ebean-ddl-generator - 12.7.2-SNAPSHOT + 12.7.2 io.ebean ebean-externalmapping-api - 12.7.2-SNAPSHOT + 12.7.2 io.ebean ebean-externalmapping-xml - 12.7.2-SNAPSHOT + 12.7.2 io.ebean ebean-autotune - 12.7.2-SNAPSHOT + 12.7.2 io.ebean ebean-querybean - 12.7.2-SNAPSHOT + 12.7.2 io.ebean querybean-generator - 12.7.2-SNAPSHOT + 12.7.2 provided io.ebean kotlin-querybean-generator - 12.7.2-SNAPSHOT + 12.7.2 provided io.ebean ebean-test - 12.7.2-SNAPSHOT + 12.7.2 test io.ebean ebean-postgis - 12.7.2-SNAPSHOT + 12.7.2 io.ebean ebean-redis - 12.7.2-SNAPSHOT + 12.7.2 diff --git a/ebean-core-type/pom.xml b/ebean-core-type/pom.xml index f0db31343..ae4039137 100644 --- a/ebean-core-type/pom.xml +++ b/ebean-core-type/pom.xml @@ -4,7 +4,7 @@ ebean-parent io.ebean - 12.7.2-SNAPSHOT + 12.7.2 ebean-core-type @@ -16,7 +16,7 @@ io.ebean ebean-api - 12.7.2-SNAPSHOT + 12.7.2 diff --git a/ebean-core/pom.xml b/ebean-core/pom.xml index bab9e7624..9eb1f764a 100644 --- a/ebean-core/pom.xml +++ b/ebean-core/pom.xml @@ -3,7 +3,7 @@ ebean-parent io.ebean - 12.7.2-SNAPSHOT + 12.7.2 ebean-core @@ -15,7 +15,7 @@ scm:git:git@github.com:ebean-orm/ebean.git - ebean-parent-12.6.5 + ebean-parent-12.7.2 @@ -87,19 +87,19 @@ io.ebean ebean-api - 12.7.2-SNAPSHOT + 12.7.2 io.ebean ebean-core-type - 12.7.2-SNAPSHOT + 12.7.2 io.ebean ebean-externalmapping-api - 12.7.2-SNAPSHOT + 12.7.2 diff --git a/ebean-ddl-generator/pom.xml b/ebean-ddl-generator/pom.xml index 90f3270e4..3aada00a8 100644 --- a/ebean-ddl-generator/pom.xml +++ b/ebean-ddl-generator/pom.xml @@ -4,7 +4,7 @@ ebean-parent io.ebean - 12.7.2-SNAPSHOT + 12.7.2 ebean ddl generation @@ -29,14 +29,14 @@ io.ebean ebean-core-type - 12.7.2-SNAPSHOT + 12.7.2 provided io.ebean ebean-core - 12.7.2-SNAPSHOT + 12.7.2 provided diff --git a/ebean-externalmapping-api/pom.xml b/ebean-externalmapping-api/pom.xml index 76e5ced23..e27b3dfce 100644 --- a/ebean-externalmapping-api/pom.xml +++ b/ebean-externalmapping-api/pom.xml @@ -4,7 +4,7 @@ ebean-parent io.ebean - 12.7.2-SNAPSHOT + 12.7.2 ebean external mapping api diff --git a/ebean-externalmapping-xml/pom.xml b/ebean-externalmapping-xml/pom.xml index 620a1de73..42fa08b21 100644 --- a/ebean-externalmapping-xml/pom.xml +++ b/ebean-externalmapping-xml/pom.xml @@ -4,7 +4,7 @@ ebean-parent io.ebean - 12.7.2-SNAPSHOT + 12.7.2 @@ -14,7 +14,7 @@ scm:git:git@github.com:ebean-orm/ebean.git - ebean-parent-12.6.5 + ebean-parent-12.7.2 ebean external mapping xml @@ -33,7 +33,7 @@ io.ebean ebean-externalmapping-api - 12.7.2-SNAPSHOT + 12.7.2 @@ -59,14 +59,14 @@ io.ebean ebean-core - 12.7.2-SNAPSHOT + 12.7.2 test io.ebean ebean-ddl-generator - 12.7.2-SNAPSHOT + 12.7.2 test diff --git a/ebean-postgis/pom.xml b/ebean-postgis/pom.xml index d8acdb157..583dc83a3 100644 --- a/ebean-postgis/pom.xml +++ b/ebean-postgis/pom.xml @@ -4,7 +4,7 @@ ebean-parent io.ebean - 12.7.2-SNAPSHOT + 12.7.2 ebean postgis @@ -23,7 +23,7 @@ io.ebean ebean-core - 12.7.2-SNAPSHOT + 12.7.2 provided @@ -74,7 +74,7 @@ io.ebean ebean-test - 12.7.2-SNAPSHOT + 12.7.2 test diff --git a/ebean-querybean/pom.xml b/ebean-querybean/pom.xml index 52ab4f7c0..86a5bf64c 100644 --- a/ebean-querybean/pom.xml +++ b/ebean-querybean/pom.xml @@ -4,7 +4,7 @@ ebean-parent io.ebean - 12.7.2-SNAPSHOT + 12.7.2 ebean querybean @@ -17,7 +17,7 @@ io.ebean ebean-core - 12.7.2-SNAPSHOT + 12.7.2 provided @@ -57,21 +57,21 @@ io.ebean ebean-ddl-generator - 12.7.2-SNAPSHOT + 12.7.2 test io.ebean querybean-generator - 12.7.2-SNAPSHOT + 12.7.2 test io.ebean ebean-test - 12.7.2-SNAPSHOT + 12.7.2 test diff --git a/ebean-redis/pom.xml b/ebean-redis/pom.xml index cf4f83208..eef70ea0f 100644 --- a/ebean-redis/pom.xml +++ b/ebean-redis/pom.xml @@ -4,7 +4,7 @@ ebean-parent io.ebean - 12.7.2-SNAPSHOT + 12.7.2 ebean-redis @@ -22,35 +22,35 @@ io.ebean ebean-api - 12.7.2-SNAPSHOT + 12.7.2 provided io.ebean ebean-core - 12.7.2-SNAPSHOT + 12.7.2 provided io.ebean ebean-querybean - 12.7.2-SNAPSHOT + 12.7.2 test io.ebean querybean-generator - 12.7.2-SNAPSHOT + 12.7.2 test io.ebean ebean-test - 12.7.2-SNAPSHOT + 12.7.2 test diff --git a/ebean-test/pom.xml b/ebean-test/pom.xml index 32810609f..246de76b3 100644 --- a/ebean-test/pom.xml +++ b/ebean-test/pom.xml @@ -4,7 +4,7 @@ ebean-parent io.ebean - 12.7.2-SNAPSHOT + 12.7.2 ebean test @@ -29,14 +29,14 @@ io.ebean ebean-core - 12.7.2-SNAPSHOT + 12.7.2 provided io.ebean ebean-ddl-generator - 12.7.2-SNAPSHOT + 12.7.2 diff --git a/ebean/pom.xml b/ebean/pom.xml index e1bf6282a..77f88c51e 100644 --- a/ebean/pom.xml +++ b/ebean/pom.xml @@ -4,7 +4,7 @@ ebean-parent io.ebean - 12.7.2-SNAPSHOT + 12.7.2 ebean composite @@ -22,20 +22,20 @@ io.ebean ebean-api - 12.7.2-SNAPSHOT + 12.7.2 io.ebean ebean-core - 12.7.2-SNAPSHOT + 12.7.2 io.ebean ebean-querybean - 12.7.2-SNAPSHOT + 12.7.2 diff --git a/kotlin-querybean-generator/pom.xml b/kotlin-querybean-generator/pom.xml index 4373c3275..7e72e1e3c 100644 --- a/kotlin-querybean-generator/pom.xml +++ b/kotlin-querybean-generator/pom.xml @@ -4,7 +4,7 @@ ebean-parent io.ebean - 12.7.2-SNAPSHOT + 12.7.2 kotlin querybean generator @@ -29,7 +29,7 @@ io.ebean ebean-querybean - 12.7.2-SNAPSHOT + 12.7.2 test @@ -43,7 +43,7 @@ io.ebean ebean-core - 12.7.2-SNAPSHOT + 12.7.2 test @@ -64,7 +64,7 @@ io.ebean ebean-ddl-generator - 12.7.2-SNAPSHOT + 12.7.2 test diff --git a/pom.xml b/pom.xml index 6edda0cd5..9448cc54e 100644 --- a/pom.xml +++ b/pom.xml @@ -9,7 +9,7 @@ io.ebean ebean-parent - 12.7.2-SNAPSHOT + 12.7.2 pom ebean parent @@ -18,7 +18,7 @@ scm:git:git@github.com:ebean-orm/ebean.git - ebean-parent-12.6.5 + ebean-parent-12.7.2 diff --git a/querybean-generator/pom.xml b/querybean-generator/pom.xml index 9f5303d0f..be2082334 100644 --- a/querybean-generator/pom.xml +++ b/querybean-generator/pom.xml @@ -4,7 +4,7 @@ ebean-parent io.ebean - 12.7.2-SNAPSHOT + 12.7.2 querybean generator From e4d0341e67201d9107dc694f06967ed1ea27792f Mon Sep 17 00:00:00 2001 From: robin Date: Mon, 1 Mar 2021 23:45:15 +1300 Subject: [PATCH 128/447] [maven-release-plugin] prepare for next development iteration --- ebean-api/pom.xml | 2 +- ebean-autotune/pom.xml | 6 +++--- ebean-bom/pom.xml | 30 +++++++++++++++--------------- ebean-core-type/pom.xml | 4 ++-- ebean-core/pom.xml | 10 +++++----- ebean-ddl-generator/pom.xml | 6 +++--- ebean-externalmapping-api/pom.xml | 2 +- ebean-externalmapping-xml/pom.xml | 10 +++++----- ebean-postgis/pom.xml | 6 +++--- ebean-querybean/pom.xml | 10 +++++----- ebean-redis/pom.xml | 12 ++++++------ ebean-test/pom.xml | 6 +++--- ebean/pom.xml | 8 ++++---- kotlin-querybean-generator/pom.xml | 8 ++++---- pom.xml | 4 ++-- querybean-generator/pom.xml | 2 +- 16 files changed, 63 insertions(+), 63 deletions(-) diff --git a/ebean-api/pom.xml b/ebean-api/pom.xml index 1aed817f7..c073c2699 100644 --- a/ebean-api/pom.xml +++ b/ebean-api/pom.xml @@ -4,7 +4,7 @@ ebean-parent io.ebean - 12.7.2 + 12.7.3-SNAPSHOT ebean api diff --git a/ebean-autotune/pom.xml b/ebean-autotune/pom.xml index 0646db6e7..4ced5a224 100644 --- a/ebean-autotune/pom.xml +++ b/ebean-autotune/pom.xml @@ -4,7 +4,7 @@ ebean-parent io.ebean - 12.7.2 + 12.7.3-SNAPSHOT @@ -14,7 +14,7 @@ scm:git:git@github.com:ebean-orm/ebean.git - ebean-parent-12.7.2 + ebean-parent-12.6.5 ebean autotune @@ -26,7 +26,7 @@ io.ebean ebean-core - 12.7.2 + 12.7.3-SNAPSHOT provided diff --git a/ebean-bom/pom.xml b/ebean-bom/pom.xml index 4cec55855..2293b2db9 100644 --- a/ebean-bom/pom.xml +++ b/ebean-bom/pom.xml @@ -4,7 +4,7 @@ ebean-parent io.ebean - 12.7.2 + 12.7.3-SNAPSHOT ebean bom @@ -81,88 +81,88 @@ io.ebean ebean - 12.7.2 + 12.7.3-SNAPSHOT io.ebean ebean-api - 12.7.2 + 12.7.3-SNAPSHOT io.ebean ebean-core - 12.7.2 + 12.7.3-SNAPSHOT io.ebean ebean-core-type - 12.7.2 + 12.7.3-SNAPSHOT io.ebean ebean-ddl-generator - 12.7.2 + 12.7.3-SNAPSHOT io.ebean ebean-externalmapping-api - 12.7.2 + 12.7.3-SNAPSHOT io.ebean ebean-externalmapping-xml - 12.7.2 + 12.7.3-SNAPSHOT io.ebean ebean-autotune - 12.7.2 + 12.7.3-SNAPSHOT io.ebean ebean-querybean - 12.7.2 + 12.7.3-SNAPSHOT io.ebean querybean-generator - 12.7.2 + 12.7.3-SNAPSHOT provided io.ebean kotlin-querybean-generator - 12.7.2 + 12.7.3-SNAPSHOT provided io.ebean ebean-test - 12.7.2 + 12.7.3-SNAPSHOT test io.ebean ebean-postgis - 12.7.2 + 12.7.3-SNAPSHOT io.ebean ebean-redis - 12.7.2 + 12.7.3-SNAPSHOT diff --git a/ebean-core-type/pom.xml b/ebean-core-type/pom.xml index ae4039137..9e7a3c6eb 100644 --- a/ebean-core-type/pom.xml +++ b/ebean-core-type/pom.xml @@ -4,7 +4,7 @@ ebean-parent io.ebean - 12.7.2 + 12.7.3-SNAPSHOT ebean-core-type @@ -16,7 +16,7 @@ io.ebean ebean-api - 12.7.2 + 12.7.3-SNAPSHOT diff --git a/ebean-core/pom.xml b/ebean-core/pom.xml index 9eb1f764a..b493318d1 100644 --- a/ebean-core/pom.xml +++ b/ebean-core/pom.xml @@ -3,7 +3,7 @@ ebean-parent io.ebean - 12.7.2 + 12.7.3-SNAPSHOT ebean-core @@ -15,7 +15,7 @@ scm:git:git@github.com:ebean-orm/ebean.git - ebean-parent-12.7.2 + ebean-parent-12.6.5 @@ -87,19 +87,19 @@ io.ebean ebean-api - 12.7.2 + 12.7.3-SNAPSHOT io.ebean ebean-core-type - 12.7.2 + 12.7.3-SNAPSHOT io.ebean ebean-externalmapping-api - 12.7.2 + 12.7.3-SNAPSHOT diff --git a/ebean-ddl-generator/pom.xml b/ebean-ddl-generator/pom.xml index 3aada00a8..571f4e090 100644 --- a/ebean-ddl-generator/pom.xml +++ b/ebean-ddl-generator/pom.xml @@ -4,7 +4,7 @@ ebean-parent io.ebean - 12.7.2 + 12.7.3-SNAPSHOT ebean ddl generation @@ -29,14 +29,14 @@ io.ebean ebean-core-type - 12.7.2 + 12.7.3-SNAPSHOT provided io.ebean ebean-core - 12.7.2 + 12.7.3-SNAPSHOT provided diff --git a/ebean-externalmapping-api/pom.xml b/ebean-externalmapping-api/pom.xml index e27b3dfce..4c33334e1 100644 --- a/ebean-externalmapping-api/pom.xml +++ b/ebean-externalmapping-api/pom.xml @@ -4,7 +4,7 @@ ebean-parent io.ebean - 12.7.2 + 12.7.3-SNAPSHOT ebean external mapping api diff --git a/ebean-externalmapping-xml/pom.xml b/ebean-externalmapping-xml/pom.xml index 42fa08b21..0ae68425e 100644 --- a/ebean-externalmapping-xml/pom.xml +++ b/ebean-externalmapping-xml/pom.xml @@ -4,7 +4,7 @@ ebean-parent io.ebean - 12.7.2 + 12.7.3-SNAPSHOT @@ -14,7 +14,7 @@ scm:git:git@github.com:ebean-orm/ebean.git - ebean-parent-12.7.2 + ebean-parent-12.6.5 ebean external mapping xml @@ -33,7 +33,7 @@ io.ebean ebean-externalmapping-api - 12.7.2 + 12.7.3-SNAPSHOT @@ -59,14 +59,14 @@ io.ebean ebean-core - 12.7.2 + 12.7.3-SNAPSHOT test io.ebean ebean-ddl-generator - 12.7.2 + 12.7.3-SNAPSHOT test diff --git a/ebean-postgis/pom.xml b/ebean-postgis/pom.xml index 583dc83a3..99fe84dca 100644 --- a/ebean-postgis/pom.xml +++ b/ebean-postgis/pom.xml @@ -4,7 +4,7 @@ ebean-parent io.ebean - 12.7.2 + 12.7.3-SNAPSHOT ebean postgis @@ -23,7 +23,7 @@ io.ebean ebean-core - 12.7.2 + 12.7.3-SNAPSHOT provided @@ -74,7 +74,7 @@ io.ebean ebean-test - 12.7.2 + 12.7.3-SNAPSHOT test diff --git a/ebean-querybean/pom.xml b/ebean-querybean/pom.xml index 86a5bf64c..132ef56e2 100644 --- a/ebean-querybean/pom.xml +++ b/ebean-querybean/pom.xml @@ -4,7 +4,7 @@ ebean-parent io.ebean - 12.7.2 + 12.7.3-SNAPSHOT ebean querybean @@ -17,7 +17,7 @@ io.ebean ebean-core - 12.7.2 + 12.7.3-SNAPSHOT provided @@ -57,21 +57,21 @@ io.ebean ebean-ddl-generator - 12.7.2 + 12.7.3-SNAPSHOT test io.ebean querybean-generator - 12.7.2 + 12.7.3-SNAPSHOT test io.ebean ebean-test - 12.7.2 + 12.7.3-SNAPSHOT test diff --git a/ebean-redis/pom.xml b/ebean-redis/pom.xml index eef70ea0f..476ee7c2a 100644 --- a/ebean-redis/pom.xml +++ b/ebean-redis/pom.xml @@ -4,7 +4,7 @@ ebean-parent io.ebean - 12.7.2 + 12.7.3-SNAPSHOT ebean-redis @@ -22,35 +22,35 @@ io.ebean ebean-api - 12.7.2 + 12.7.3-SNAPSHOT provided io.ebean ebean-core - 12.7.2 + 12.7.3-SNAPSHOT provided io.ebean ebean-querybean - 12.7.2 + 12.7.3-SNAPSHOT test io.ebean querybean-generator - 12.7.2 + 12.7.3-SNAPSHOT test io.ebean ebean-test - 12.7.2 + 12.7.3-SNAPSHOT test diff --git a/ebean-test/pom.xml b/ebean-test/pom.xml index 246de76b3..4b5e47899 100644 --- a/ebean-test/pom.xml +++ b/ebean-test/pom.xml @@ -4,7 +4,7 @@ ebean-parent io.ebean - 12.7.2 + 12.7.3-SNAPSHOT ebean test @@ -29,14 +29,14 @@ io.ebean ebean-core - 12.7.2 + 12.7.3-SNAPSHOT provided io.ebean ebean-ddl-generator - 12.7.2 + 12.7.3-SNAPSHOT diff --git a/ebean/pom.xml b/ebean/pom.xml index 77f88c51e..7356b26ff 100644 --- a/ebean/pom.xml +++ b/ebean/pom.xml @@ -4,7 +4,7 @@ ebean-parent io.ebean - 12.7.2 + 12.7.3-SNAPSHOT ebean composite @@ -22,20 +22,20 @@ io.ebean ebean-api - 12.7.2 + 12.7.3-SNAPSHOT io.ebean ebean-core - 12.7.2 + 12.7.3-SNAPSHOT io.ebean ebean-querybean - 12.7.2 + 12.7.3-SNAPSHOT diff --git a/kotlin-querybean-generator/pom.xml b/kotlin-querybean-generator/pom.xml index 7e72e1e3c..8e4df4f39 100644 --- a/kotlin-querybean-generator/pom.xml +++ b/kotlin-querybean-generator/pom.xml @@ -4,7 +4,7 @@ ebean-parent io.ebean - 12.7.2 + 12.7.3-SNAPSHOT kotlin querybean generator @@ -29,7 +29,7 @@ io.ebean ebean-querybean - 12.7.2 + 12.7.3-SNAPSHOT test @@ -43,7 +43,7 @@ io.ebean ebean-core - 12.7.2 + 12.7.3-SNAPSHOT test @@ -64,7 +64,7 @@ io.ebean ebean-ddl-generator - 12.7.2 + 12.7.3-SNAPSHOT test diff --git a/pom.xml b/pom.xml index 9448cc54e..8e06ae121 100644 --- a/pom.xml +++ b/pom.xml @@ -9,7 +9,7 @@ io.ebean ebean-parent - 12.7.2 + 12.7.3-SNAPSHOT pom ebean parent @@ -18,7 +18,7 @@ scm:git:git@github.com:ebean-orm/ebean.git - ebean-parent-12.7.2 + ebean-parent-12.6.5 diff --git a/querybean-generator/pom.xml b/querybean-generator/pom.xml index be2082334..bc6fc7019 100644 --- a/querybean-generator/pom.xml +++ b/querybean-generator/pom.xml @@ -4,7 +4,7 @@ ebean-parent io.ebean - 12.7.2 + 12.7.3-SNAPSHOT querybean generator From 79dde23ec6b8e022e5b510e04288dd9929e1d5c9 Mon Sep 17 00:00:00 2001 From: Ben Kempe Date: Mon, 1 Mar 2021 12:16:22 +0100 Subject: [PATCH 129/447] added tests for findNative fetches --- .../org/tests/query/TestQueryFindNative.java | 97 +++++++++++++++++++ 1 file changed, 97 insertions(+) diff --git a/ebean-core/src/test/java/org/tests/query/TestQueryFindNative.java b/ebean-core/src/test/java/org/tests/query/TestQueryFindNative.java index ff4acac9d..7cc4ac9c6 100644 --- a/ebean-core/src/test/java/org/tests/query/TestQueryFindNative.java +++ b/ebean-core/src/test/java/org/tests/query/TestQueryFindNative.java @@ -246,4 +246,101 @@ public class TestQueryFindNative extends BaseTestCase { } } + + @Test + public void findNativeWithOneFetchQuery() { + + ResetBasicData.reset(); + + String sql = "select * from o_customer"; + + LoggedSqlCollector.start(); + + List result = DB.findNative(Customer.class, sql) + .fetchQuery("contacts") + .findList(); + + assertThat(result).isNotEmpty(); + List loggedSql = LoggedSqlCollector.stop(); + + if (isH2()) { + assertThat(loggedSql).hasSize(2); + assertThat(loggedSql.get(0)).contains("from o_customer"); + assertThat(loggedSql.get(1)).contains("from contact"); + } + } + + @Test + public void findNativeWithOneFetch() { + + ResetBasicData.reset(); + + String sql = "select * from o_customer"; + + LoggedSqlCollector.start(); + + List result = DB.findNative(Customer.class, sql) + .fetch("contacts") + .findList(); + + assertThat(result).isNotEmpty(); + List loggedSql = LoggedSqlCollector.stop(); + + if (isH2()) { + assertThat(loggedSql).hasSize(2); + assertThat(loggedSql.get(0)).contains("from o_customer"); + assertThat(loggedSql.get(1)).contains("from contact"); + } + } + + @Test + public void findNativeWithMultipleFetchQuery() { + + ResetBasicData.reset(); + + String sql = "select * from o_customer"; + + LoggedSqlCollector.start(); + + List result = DB.findNative(Customer.class, sql) + .fetchQuery("orders") + .fetchQuery("contacts") + .findList(); + + assertThat(result).isNotEmpty(); + List loggedSql = LoggedSqlCollector.stop(); + + if (isH2()) { + assertThat(loggedSql).hasSize(3); + assertThat(loggedSql.get(0)).contains("from o_customer"); + assertThat(loggedSql).anyMatch(s -> s.contains("from o_order")); + assertThat(loggedSql).anyMatch(s -> s.contains("from contact")); + } + } + + @Test + public void findNativeWithMultipleFetch() { + + ResetBasicData.reset(); + + String sql = "select * from o_customer"; + + LoggedSqlCollector.start(); + + List result = DB.findNative(Customer.class, sql) + .fetch("orders") + .fetch("contacts") + .findList(); + + assertThat(result).isNotEmpty(); + List loggedSql = LoggedSqlCollector.stop(); + + if (isH2()) { + assertThat(loggedSql).hasSize(3); + assertThat(loggedSql.get(0)).contains("from o_customer"); + assertThat(loggedSql).anyMatch(s -> s.contains("from o_order")); + assertThat(loggedSql).anyMatch(s -> s.contains("from contact")); + } + } + } From af4f70e3a7162cf2fe0bec0a955f6241cbfa3d6b Mon Sep 17 00:00:00 2001 From: Ben Kempe Date: Mon, 1 Mar 2021 13:21:05 +0100 Subject: [PATCH 130/447] add in(subQuery) support for query beans --- .../io/ebean/typequery/PBaseValueEqual.java | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/ebean-querybean/src/main/java/io/ebean/typequery/PBaseValueEqual.java b/ebean-querybean/src/main/java/io/ebean/typequery/PBaseValueEqual.java index c102d9991..3883afe66 100644 --- a/ebean-querybean/src/main/java/io/ebean/typequery/PBaseValueEqual.java +++ b/ebean-querybean/src/main/java/io/ebean/typequery/PBaseValueEqual.java @@ -1,5 +1,7 @@ package io.ebean.typequery; +import io.ebean.Query; + import java.util.Collection; /** @@ -224,4 +226,25 @@ public abstract class PBaseValueEqual extends TQPropertyBase { expr().in(_name, values); return _root; } + + /** + * Is in the result of a subquery. + * + * @param subQuery values provided by a subQuery + * @return the root query bean instance + */ + public final R in(Query subQuery) { + expr().in(_name, subQuery); + return _root; + } + + /** + * Is in the result of a subquery. Synonym for in(). + * + * @param subQuery values provided by a subQuery + * @return the root query bean instance + */ + public final R isIn(Query subQuery) { + return in(subQuery); + } } From f416309863f69b48126b25054fc4406c227753d2 Mon Sep 17 00:00:00 2001 From: Robin Bygrave Date: Tue, 2 Mar 2021 14:44:54 +1300 Subject: [PATCH 131/447] No effective change - change DefaultOrmQuery methods to return Query rather than DefaultOrmQuery This is no effective functional change but we do need to update the test OrmQueryPlanKeyTest to cast now. --- .../server/querydefn/DefaultOrmQuery.java | 82 ++++++------- .../server/querydefn/OrmQueryPlanKeyTest.java | 113 +++++++++--------- 2 files changed, 97 insertions(+), 98 deletions(-) diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/querydefn/DefaultOrmQuery.java b/ebean-core/src/main/java/io/ebeaninternal/server/querydefn/DefaultOrmQuery.java index e19212e96..7a012d034 100644 --- a/ebean-core/src/main/java/io/ebeaninternal/server/querydefn/DefaultOrmQuery.java +++ b/ebean-core/src/main/java/io/ebeaninternal/server/querydefn/DefaultOrmQuery.java @@ -391,7 +391,7 @@ public class DefaultOrmQuery implements SpiQuery { } @Override - public DefaultOrmQuery setUseDocStore(boolean useDocStore) { + public Query setUseDocStore(boolean useDocStore) { this.useDocStore = useDocStore; return this; } @@ -431,7 +431,7 @@ public class DefaultOrmQuery implements SpiQuery { } @Override - public DefaultOrmQuery setAllowLoadErrors() { + public Query setAllowLoadErrors() { this.allowLoadErrors = true; return this; } @@ -452,21 +452,21 @@ public class DefaultOrmQuery implements SpiQuery { } @Override - public DefaultOrmQuery asOf(Timestamp asOfDateTime) { + public Query asOf(Timestamp asOfDateTime) { this.temporalMode = (asOfDateTime != null) ? TemporalMode.AS_OF : TemporalMode.CURRENT; this.asOf = asOfDateTime; return this; } @Override - public DefaultOrmQuery asDraft() { + public Query asDraft() { this.temporalMode = TemporalMode.DRAFT; this.useBeanCache = CacheMode.OFF; return this; } @Override - public DefaultOrmQuery setIncludeSoftDeletes() { + public Query setIncludeSoftDeletes() { this.temporalMode = TemporalMode.SOFT_DELETED; return this; } @@ -489,7 +489,7 @@ public class DefaultOrmQuery implements SpiQuery { } @Override - public DefaultOrmQuery setRawSql(RawSql rawSql) { + public Query setRawSql(RawSql rawSql) { this.rawSql = (SpiRawSql) rawSql; return this; } @@ -802,12 +802,12 @@ public class DefaultOrmQuery implements SpiQuery { } @Override - public DefaultOrmQuery copy() { + public SpiQuery copy() { return copy(server); } @Override - public DefaultOrmQuery copy(SpiEbeanServer server) { + public SpiQuery copy(SpiEbeanServer server) { DefaultOrmQuery copy = new DefaultOrmQuery<>(beanDescriptor, server, expressionFactory); copy.transaction = transaction; copy.m2mIncludeJoin = m2mIncludeJoin; @@ -955,7 +955,7 @@ public class DefaultOrmQuery implements SpiQuery { } @Override - public DefaultOrmQuery setAutoTune(boolean autoTune) { + public Query setAutoTune(boolean autoTune) { this.autoTune = autoTune; return this; } @@ -971,21 +971,21 @@ public class DefaultOrmQuery implements SpiQuery { } @Override - public DefaultOrmQuery forUpdate() { + public Query forUpdate() { return setForUpdateWithMode(LockWait.WAIT, LockType.DEFAULT); } @Override - public DefaultOrmQuery forUpdateNoWait() { + public Query forUpdateNoWait() { return setForUpdateWithMode(LockWait.NOWAIT, LockType.DEFAULT); } @Override - public DefaultOrmQuery forUpdateSkipLocked() { + public Query forUpdateSkipLocked() { return setForUpdateWithMode(LockWait.SKIPLOCKED, LockType.DEFAULT); } - private DefaultOrmQuery setForUpdateWithMode(LockWait mode, LockType lockType) { + private Query setForUpdateWithMode(LockWait mode, LockType lockType) { this.forUpdate = mode; this.lockType = lockType; this.useBeanCache = CacheMode.OFF; @@ -1329,7 +1329,7 @@ public class DefaultOrmQuery implements SpiQuery { } @Override - public DefaultOrmQuery setReadOnly(boolean readOnly) { + public Query setReadOnly(boolean readOnly) { this.readOnly = readOnly; return this; } @@ -1375,19 +1375,19 @@ public class DefaultOrmQuery implements SpiQuery { } @Override - public DefaultOrmQuery setUseQueryCache(CacheMode useQueryCache) { + public Query setUseQueryCache(CacheMode useQueryCache) { this.useQueryCache = useQueryCache; return this; } @Override - public DefaultOrmQuery setLoadBeanCache(boolean loadBeanCache) { + public Query setLoadBeanCache(boolean loadBeanCache) { this.useBeanCache = CacheMode.PUT; return this; } @Override - public DefaultOrmQuery setTimeout(int secs) { + public Query setTimeout(int secs) { this.timeout = secs; return this; } @@ -1413,19 +1413,19 @@ public class DefaultOrmQuery implements SpiQuery { } @Override - public DefaultOrmQuery select(String columns) { + public Query select(String columns) { detail.select(columns); return this; } @Override - public DefaultOrmQuery select(FetchGroup fetchGroup) { + public Query select(FetchGroup fetchGroup) { this.detail = ((SpiFetchGroup) fetchGroup).detail(); return this; } @Override - public DefaultOrmQuery fetch(String property) { + public Query fetch(String property) { return fetch(property, null, null); } @@ -1444,12 +1444,12 @@ public class DefaultOrmQuery implements SpiQuery { } @Override - public DefaultOrmQuery fetch(String property, FetchConfig joinConfig) { + public Query fetch(String property, FetchConfig joinConfig) { return fetch(property, null, joinConfig); } @Override - public DefaultOrmQuery fetch(String property, String columns) { + public Query fetch(String property, String columns) { return fetch(property, columns, null); } @@ -1469,7 +1469,7 @@ public class DefaultOrmQuery implements SpiQuery { } @Override - public DefaultOrmQuery fetch(String property, String columns, FetchConfig config) { + public Query fetch(String property, String columns, FetchConfig config) { detail.fetch(property, columns, config); return this; } @@ -1633,7 +1633,7 @@ public class DefaultOrmQuery implements SpiQuery { } @Override - public DefaultOrmQuery setParameter(Object value) { + public Query setParameter(Object value) { if (bindParams == null) { bindParams = new BindParams(); } @@ -1642,7 +1642,7 @@ public class DefaultOrmQuery implements SpiQuery { } @Override - public DefaultOrmQuery setParameters(Object... values) { + public Query setParameters(Object... values) { if (bindParams == null) { bindParams = new BindParams(); } @@ -1656,7 +1656,7 @@ public class DefaultOrmQuery implements SpiQuery { * have in the query. */ @Override - public DefaultOrmQuery setParameter(int position, Object value) { + public Query setParameter(int position, Object value) { if (bindParams == null) { bindParams = new BindParams(); } @@ -1668,7 +1668,7 @@ public class DefaultOrmQuery implements SpiQuery { * Set a named bind parameter. Named parameters have a colon to prefix the name. */ @Override - public DefaultOrmQuery setParameter(String name, Object value) { + public Query setParameter(String name, Object value) { if (namedParams != null) { ONamedParam param = namedParams.get(name); if (param != null) { @@ -1714,12 +1714,12 @@ public class DefaultOrmQuery implements SpiQuery { @Override @Deprecated - public DefaultOrmQuery orderBy(String orderByClause) { + public Query orderBy(String orderByClause) { return order(orderByClause); } @Override - public DefaultOrmQuery order(String orderByClause) { + public Query order(String orderByClause) { if (orderByClause == null || orderByClause.trim().isEmpty()) { this.orderBy = null; } else { @@ -1730,12 +1730,12 @@ public class DefaultOrmQuery implements SpiQuery { @Override @Deprecated - public DefaultOrmQuery setOrderBy(OrderBy orderBy) { + public Query setOrderBy(OrderBy orderBy) { return setOrder(orderBy); } @Override - public DefaultOrmQuery setOrder(OrderBy orderBy) { + public Query setOrder(OrderBy orderBy) { this.orderBy = orderBy; if (orderBy != null) { orderBy.setQuery(this); @@ -1767,13 +1767,13 @@ public class DefaultOrmQuery implements SpiQuery { * Internally set to use SQL DISTINCT on the query but still have id property included. */ @Override - public DefaultOrmQuery setDistinct(boolean distinct) { + public Query setDistinct(boolean distinct) { this.distinct = distinct; return this; } @Override - public DefaultOrmQuery setCountDistinct(CountDistinctOrder countDistinctOrder) { + public Query setCountDistinct(CountDistinctOrder countDistinctOrder) { this.countDistinctOrder = countDistinctOrder; return this; } @@ -1824,7 +1824,7 @@ public class DefaultOrmQuery implements SpiQuery { } @Override - public DefaultOrmQuery setDisableLazyLoading(boolean disableLazyLoading) { + public Query setDisableLazyLoading(boolean disableLazyLoading) { this.disableLazyLoading = disableLazyLoading; return this; } @@ -1840,7 +1840,7 @@ public class DefaultOrmQuery implements SpiQuery { } @Override - public DefaultOrmQuery setFirstRow(int firstRow) { + public Query setFirstRow(int firstRow) { this.firstRow = firstRow; return this; } @@ -1851,7 +1851,7 @@ public class DefaultOrmQuery implements SpiQuery { } @Override - public DefaultOrmQuery setMaxRows(int maxRows) { + public Query setMaxRows(int maxRows) { this.maxRows = maxRows; return this; } @@ -1862,7 +1862,7 @@ public class DefaultOrmQuery implements SpiQuery { } @Override - public DefaultOrmQuery setMapKey(String mapKey) { + public Query setMapKey(String mapKey) { this.mapKey = mapKey; return this; } @@ -1873,7 +1873,7 @@ public class DefaultOrmQuery implements SpiQuery { } @Override - public DefaultOrmQuery setId(Object id) { + public Query setId(Object id) { if (id == null) { throw new NullPointerException("The id is null"); } @@ -1887,7 +1887,7 @@ public class DefaultOrmQuery implements SpiQuery { } @Override - public DefaultOrmQuery where(Expression expression) { + public Query where(Expression expression) { where().add(expression); return this; } @@ -1917,7 +1917,7 @@ public class DefaultOrmQuery implements SpiQuery { } @Override - public DefaultOrmQuery having(Expression expression) { + public Query having(Expression expression) { having().add(expression); return this; } @@ -2043,7 +2043,7 @@ public class DefaultOrmQuery implements SpiQuery { } @Override - public DefaultOrmQuery alias(String alias) { + public Query alias(String alias) { this.rootTableAlias = alias; return this; } diff --git a/ebean-core/src/test/java/io/ebeaninternal/server/querydefn/OrmQueryPlanKeyTest.java b/ebean-core/src/test/java/io/ebeaninternal/server/querydefn/OrmQueryPlanKeyTest.java index 0c2f07e98..305f9122b 100644 --- a/ebean-core/src/test/java/io/ebeaninternal/server/querydefn/OrmQueryPlanKeyTest.java +++ b/ebean-core/src/test/java/io/ebeaninternal/server/querydefn/OrmQueryPlanKeyTest.java @@ -18,8 +18,7 @@ import static org.assertj.core.api.Assertions.assertThat; public class OrmQueryPlanKeyTest extends BaseExpressionTest { - - @SuppressWarnings("unchecked") + @SuppressWarnings({"unchecked", "rawtypes"}) private DefaultOrmQuery query() { return (DefaultOrmQuery) server().find(Customer.class); } @@ -85,41 +84,40 @@ public class OrmQueryPlanKeyTest extends BaseExpressionTest { @Test public void equals_when_firstRowsDifferent() { - CQueryPlanKey key1 = query().setFirstRow(10).createQueryPlanKey(); - CQueryPlanKey key2 = query().createQueryPlanKey(); + CQueryPlanKey key1 = planKey(query().setFirstRow(10)); + CQueryPlanKey key2 = planKey(query()); assertDifferent(key1, key2); - key1 = query().setFirstRow(10).createQueryPlanKey(); - key2 = query().setFirstRow(9).createQueryPlanKey(); + key1 = planKey(query().setFirstRow(10)); + key2 = planKey(query().setFirstRow(9)); assertDifferent(key1, key2); - key1 = query().createQueryPlanKey(); - key2 = query().setFirstRow(9).createQueryPlanKey(); + key1 = planKey(query()); + key2 = planKey(query().setFirstRow(9)); assertDifferent(key1, key2); } @Test public void equals_when_maxRowsDifferent() { - CQueryPlanKey key1 = query().setMaxRows(10).createQueryPlanKey(); - CQueryPlanKey key2 = query().createQueryPlanKey(); + CQueryPlanKey key1 = planKey(query().setMaxRows(10)); + CQueryPlanKey key2 = planKey(query()); assertDifferent(key1, key2); - key1 = query().setMaxRows(10).createQueryPlanKey(); - key2 = query().setMaxRows(9).createQueryPlanKey(); + key1 = planKey(query().setMaxRows(10)); + key2 = planKey(query().setMaxRows(9)); assertDifferent(key1, key2); - key1 = query().createQueryPlanKey(); - key2 = query().setMaxRows(9).createQueryPlanKey(); + key1 = planKey(query()); + key2 = planKey(query().setMaxRows(9)); assertDifferent(key1, key2); - } @Test public void equals_when_firstRowsMaxRowsSame() { - CQueryPlanKey key1 = query().setMaxRows(10).setFirstRow(20).createQueryPlanKey(); - CQueryPlanKey key2 = query().setFirstRow(20).setMaxRows(10).createQueryPlanKey(); + CQueryPlanKey key1 = planKey(query().setMaxRows(10).setFirstRow(20)); + CQueryPlanKey key2 = planKey(query().setFirstRow(20).setMaxRows(10)); assertSame(key1, key2); } @@ -132,43 +130,43 @@ public class OrmQueryPlanKeyTest extends BaseExpressionTest { @Test public void equals_when_diffOrderByNull() { - CQueryPlanKey key1 = query().order("id").createQueryPlanKey(); - CQueryPlanKey key2 = query().createQueryPlanKey(); + CQueryPlanKey key1 = planKey(query().order("id")); + CQueryPlanKey key2 = planKey(query()); assertDifferent(key1, key2); - key1 = ((DefaultOrmQuery) query().order().asc("id")).createQueryPlanKey(); - key2 = query().createQueryPlanKey(); + key1 = planKey(query().order().asc("id")); + key2 = planKey(query()); assertDifferent(key1, key2); } @Test public void equals_when_orderBySame() { - CQueryPlanKey key1 = query().order("id, name").createQueryPlanKey(); - CQueryPlanKey key2 = query().order("id, name").createQueryPlanKey(); + CQueryPlanKey key1 = planKey(query().order("id, name")); + CQueryPlanKey key2 = planKey(query().order("id, name")); assertSame(key1, key2); } @Test public void equals_when_diffDistinct() { - CQueryPlanKey key1 = query().setDistinct(true).createQueryPlanKey(); - CQueryPlanKey key2 = query().createQueryPlanKey(); + CQueryPlanKey key1 = planKey(query().setDistinct(true)); + CQueryPlanKey key2 = planKey(query()); assertDifferent(key1, key2); } @Test public void equals_when_sameDistinct() { - CQueryPlanKey key1 = query().setDistinct(true).createQueryPlanKey(); - CQueryPlanKey key2 = query().setDistinct(true).createQueryPlanKey(); + CQueryPlanKey key1 = planKey(query().setDistinct(true)); + CQueryPlanKey key2 = planKey(query().setDistinct(true)); assertSame(key1, key2); } @Test public void equals_when_useDocStore() { - CQueryPlanKey key1 = query().setUseDocStore(true).createQueryPlanKey(); - CQueryPlanKey key2 = query().createQueryPlanKey(); + CQueryPlanKey key1 = planKey(query().setUseDocStore(true)); + CQueryPlanKey key2 = planKey(query()); assertDifferent(key1, key2); } @@ -176,79 +174,78 @@ public class OrmQueryPlanKeyTest extends BaseExpressionTest { @Test public void equals_when_diffMapKey() { - CQueryPlanKey key1 = query().setMapKey("name").createQueryPlanKey(); - CQueryPlanKey key2 = query().createQueryPlanKey(); + CQueryPlanKey key1 = planKey(query().setMapKey("name")); + CQueryPlanKey key2 = planKey(query()); assertDifferent(key1, key2); - CQueryPlanKey key3 = query().setMapKey("email").createQueryPlanKey(); + CQueryPlanKey key3 = planKey(query().setMapKey("email")); assertDifferent(key1, key3); - CQueryPlanKey key4 = query().setMapKey("name").createQueryPlanKey(); + CQueryPlanKey key4 = planKey(query().setMapKey("name")); assertSame(key1, key4); } @Test public void equals_when_diffIdNull() { - CQueryPlanKey key1 = query().setId(42).createQueryPlanKey(); - CQueryPlanKey key2 = query().createQueryPlanKey(); + CQueryPlanKey key1 = planKey(query().setId(42)); + CQueryPlanKey key2 = planKey(query()); assertDifferent(key1, key2); } @Test public void equals_when_idBothGiven() { - CQueryPlanKey key1 = query().setId(42).createQueryPlanKey(); - CQueryPlanKey key2 = query().setId(23).createQueryPlanKey(); + CQueryPlanKey key1 = planKey(query().setId(42)); + CQueryPlanKey key2 = planKey(query().setId(23)); assertSame(key1, key2); } @Test public void equals_when_diffTemporalMode() { - CQueryPlanKey key1 = query().createQueryPlanKey(); - CQueryPlanKey key2 = query().asDraft().createQueryPlanKey(); + CQueryPlanKey key1 = planKey(query()); + CQueryPlanKey key2 = planKey(query().asDraft()); assertDifferent(key1, key2); - CQueryPlanKey key3 = query().asOf(new Timestamp(System.currentTimeMillis())).createQueryPlanKey(); + CQueryPlanKey key3 = planKey(query().asOf(new Timestamp(System.currentTimeMillis()))); assertDifferent(key1, key3); - CQueryPlanKey key4 = query().setIncludeSoftDeletes().createQueryPlanKey(); + CQueryPlanKey key4 = planKey(query().setIncludeSoftDeletes()); assertDifferent(key1, key4); } @Test public void equals_when_diffForUpdate() { - CQueryPlanKey key1 = query().forUpdate().createQueryPlanKey(); - CQueryPlanKey key2 = query().createQueryPlanKey(); + CQueryPlanKey key1 = planKey(query().forUpdate()); + CQueryPlanKey key2 = planKey(query()); assertDifferent(key1, key2); - CQueryPlanKey key3 = query().forUpdateNoWait().createQueryPlanKey(); + CQueryPlanKey key3 = planKey(query().forUpdateNoWait()); assertDifferent(key1, key3); - CQueryPlanKey key4 = query().forUpdateSkipLocked().createQueryPlanKey(); + CQueryPlanKey key4 = planKey(query().forUpdateSkipLocked()); assertDifferent(key1, key4); - CQueryPlanKey key5 = query().forUpdate().createQueryPlanKey(); + CQueryPlanKey key5 = planKey(query().forUpdate()); assertSame(key1, key5); } @Test public void equals_when_diffRootAliasNull() { - CQueryPlanKey key1 = query().alias("alias").createQueryPlanKey(); - CQueryPlanKey key2 = query().createQueryPlanKey(); + CQueryPlanKey key1 = planKey(query().alias("alias")); + CQueryPlanKey key2 = planKey(query()); assertDifferent(key1, key2); - CQueryPlanKey key3 = query().alias("diff").createQueryPlanKey(); + CQueryPlanKey key3 = planKey(query().alias("diff")); assertDifferent(key1, key3); - CQueryPlanKey key4 = query().alias("alias").createQueryPlanKey(); + CQueryPlanKey key4 = planKey(query().alias("alias")); assertSame(key1, key4); } - private DefaultOrmQuery list_id_eq_42() { return (DefaultOrmQuery) server().find(Customer.class) .where().eq("id", 42).query(); @@ -298,7 +295,6 @@ public class OrmQueryPlanKeyTest extends BaseExpressionTest { assertDifferent(key1, key4); } - @Test public void equals_when_sameHaving() { @@ -309,7 +305,7 @@ public class OrmQueryPlanKeyTest extends BaseExpressionTest { @Test public void equals_when_manualId_andSelectClause() { - DefaultOrmQuery q1 = query().select("name"); + DefaultOrmQuery q1 = (DefaultOrmQuery)query().select("name"); q1.setManualId(); assertDifferent(q1, query().select("name")); @@ -327,16 +323,19 @@ public class OrmQueryPlanKeyTest extends BaseExpressionTest { return planKey(id.query()); } + @SuppressWarnings({"rawtypes"}) private CQueryPlanKey planKey(Query query) { return ((DefaultOrmQuery) query).createQueryPlanKey(); } - private void assertDifferent(DefaultOrmQuery q1, DefaultOrmQuery q2) { - assertDifferent(q1.createQueryPlanKey(), q2.createQueryPlanKey()); + @SuppressWarnings({"unchecked", "rawtypes"}) + private void assertDifferent(Query q1, Query q2) { + assertDifferent(planKey(q1), planKey(q2)); } - private void assertSame(DefaultOrmQuery q1, DefaultOrmQuery q2) { - assertSame(q1.createQueryPlanKey(), q2.createQueryPlanKey()); + @SuppressWarnings({"unchecked", "rawtypes"}) + private void assertSame(Query q1, Query q2) { + assertSame(planKey(q1), planKey(q2)); } private void assertDifferent(CQueryPlanKey key1, CQueryPlanKey key2) { From fe62ad2ea2c251f7135658f394505bd4058759af Mon Sep 17 00:00:00 2001 From: Robin Bygrave Date: Tue, 2 Mar 2021 15:28:17 +1300 Subject: [PATCH 132/447] #2184 - Initial refactor of DefaultOrmQuery to support 2184 - Add fetchInternal() and point fetchQuery() fetchLazy() and fetchCache() to it - Move the fetch() methods so they are located together --- .../server/querydefn/DefaultOrmQuery.java | 48 ++++++++++--------- 1 file changed, 26 insertions(+), 22 deletions(-) diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/querydefn/DefaultOrmQuery.java b/ebean-core/src/main/java/io/ebeaninternal/server/querydefn/DefaultOrmQuery.java index 7a012d034..cd1782ad7 100644 --- a/ebean-core/src/main/java/io/ebeaninternal/server/querydefn/DefaultOrmQuery.java +++ b/ebean-core/src/main/java/io/ebeaninternal/server/querydefn/DefaultOrmQuery.java @@ -1425,52 +1425,56 @@ public class DefaultOrmQuery implements SpiQuery { } @Override - public Query fetch(String property) { - return fetch(property, null, null); + public Query fetch(String path) { + return fetch(path, null, null); } @Override - public Query fetchQuery(String property) { - return fetch(property, null, FETCH_QUERY); - } - - public Query fetchCache(String property) { - return fetch(property, null, FETCH_CACHE); + public Query fetch(String path, FetchConfig joinConfig) { + return fetch(path, null, joinConfig); } @Override - public Query fetchLazy(String property) { - return fetch(property, null, FETCH_LAZY); + public Query fetch(String path, String properties) { + return fetch(path, properties, null); } @Override - public Query fetch(String property, FetchConfig joinConfig) { - return fetch(property, null, joinConfig); + public Query fetch(String path, String properties, FetchConfig config) { + return fetchInternal(path, properties, config); } @Override - public Query fetch(String property, String columns) { - return fetch(property, columns, null); + public Query fetchQuery(String path) { + return fetchInternal(path, null, FETCH_QUERY); + } + + public Query fetchCache(String path) { + return fetchInternal(path, null, FETCH_CACHE); } @Override - public Query fetchQuery(String property, String columns) { - return fetch(property, columns, FETCH_QUERY); + public Query fetchLazy(String path) { + return fetchInternal(path, null, FETCH_LAZY); } @Override - public Query fetchCache(String property, String columns) { - return fetch(property, columns, FETCH_CACHE); + public Query fetchQuery(String path, String properties) { + return fetchInternal(path, properties, FETCH_QUERY); } @Override - public Query fetchLazy(String property, String columns) { - return fetch(property, columns, FETCH_LAZY); + public Query fetchCache(String path, String properties) { + return fetchInternal(path, properties, FETCH_CACHE); } @Override - public Query fetch(String property, String columns, FetchConfig config) { - detail.fetch(property, columns, config); + public Query fetchLazy(String path, String properties) { + return fetchInternal(path, properties, FETCH_LAZY); + } + + private Query fetchInternal(String path, String properties, FetchConfig config) { + detail.fetch(path, properties, config); return this; } From 81e445e386496a9c76e011f0bbdfcf283c19314a Mon Sep 17 00:00:00 2001 From: Robin Bygrave Date: Tue, 2 Mar 2021 15:47:07 +1300 Subject: [PATCH 133/447] #2184 - Fix for findNative() with fetch() - convert fetch to fetchQuery with nativeSql When using nativeSql (think of it as the "root query") we can't use "fetch joins" (FetchConfig.ofDefault()) as that means to prefer to use a SQL JOIN. In this nativeSql case we need to effectively automatically convert fetch() to fetchQuery() --- .../ebeaninternal/server/querydefn/DefaultOrmQuery.java | 4 ++++ .../test/java/org/tests/query/TestQueryFindNative.java | 8 +++++--- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/querydefn/DefaultOrmQuery.java b/ebean-core/src/main/java/io/ebeaninternal/server/querydefn/DefaultOrmQuery.java index cd1782ad7..6f72febb9 100644 --- a/ebean-core/src/main/java/io/ebeaninternal/server/querydefn/DefaultOrmQuery.java +++ b/ebean-core/src/main/java/io/ebeaninternal/server/querydefn/DefaultOrmQuery.java @@ -1441,6 +1441,10 @@ public class DefaultOrmQuery implements SpiQuery { @Override public Query fetch(String path, String properties, FetchConfig config) { + if (nativeSql != null && (config == null || config.isJoin())) { + // can't use fetch join with nativeSql (as the root query) + config = FETCH_QUERY; + } return fetchInternal(path, properties, config); } diff --git a/ebean-core/src/test/java/org/tests/query/TestQueryFindNative.java b/ebean-core/src/test/java/org/tests/query/TestQueryFindNative.java index 7cc4ac9c6..8e11d3328 100644 --- a/ebean-core/src/test/java/org/tests/query/TestQueryFindNative.java +++ b/ebean-core/src/test/java/org/tests/query/TestQueryFindNative.java @@ -2,6 +2,7 @@ package org.tests.query; import io.ebean.BaseTestCase; import io.ebean.DB; +import io.ebean.FetchConfig; import io.ebean.PagedList; import org.assertj.core.util.Lists; import org.ebeantest.LoggedSqlCollector; @@ -280,7 +281,7 @@ public class TestQueryFindNative extends BaseTestCase { LoggedSqlCollector.start(); List result = DB.findNative(Customer.class, sql) - .fetch("contacts") + .fetch("contacts", "firstName, lastName") .findList(); assertThat(result).isNotEmpty(); @@ -289,7 +290,7 @@ public class TestQueryFindNative extends BaseTestCase { if (isH2()) { assertThat(loggedSql).hasSize(2); assertThat(loggedSql.get(0)).contains("from o_customer"); - assertThat(loggedSql.get(1)).contains("from contact"); + assertThat(loggedSql.get(1)).contains("select t0.customer_id, t0.id, t0.first_name, t0.last_name from contact t0 where"); } } @@ -328,8 +329,9 @@ public class TestQueryFindNative extends BaseTestCase { LoggedSqlCollector.start(); List result = DB.findNative(Customer.class, sql) + // with nativeSql fetch (default) are converted to fetchQuery() .fetch("orders") - .fetch("contacts") + .fetch("contacts", FetchConfig.ofDefault()) .findList(); assertThat(result).isNotEmpty(); From ef1143bb702822654d40b4e05312e4ada477c7a0 Mon Sep 17 00:00:00 2001 From: Roland Praml Date: Tue, 2 Mar 2021 15:26:29 +0100 Subject: [PATCH 134/447] FIX: orderBy does not work when used on formula property or in conjunction with "exists" query --- .../server/query/CQueryBuilder.java | 12 +++++-- .../server/querydefn/DefaultOrmQuery.java | 9 +++++ .../java/org/tests/basic/TestFetchId.java | 36 +++++++++++++++++++ 3 files changed, 55 insertions(+), 2 deletions(-) diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/query/CQueryBuilder.java b/ebean-core/src/main/java/io/ebeaninternal/server/query/CQueryBuilder.java index ab008a5cf..1162e914d 100644 --- a/ebean-core/src/main/java/io/ebeaninternal/server/query/CQueryBuilder.java +++ b/ebean-core/src/main/java/io/ebeaninternal/server/query/CQueryBuilder.java @@ -616,11 +616,19 @@ class CQueryBuilder { if (request.isInlineCountDistinct()) { sb.append(")"); } - if (distinct && dbOrderBy != null && !query.isSingleAttribute()) { + if (distinct && dbOrderBy != null) { // add the orderBy columns to the select clause (due to distinct) final OrderBy orderBy = query.getOrderBy(); if (orderBy != null && orderBy.supportsSelect()) { - sb.append(", ").append(DbOrderByTrim.trim(dbOrderBy)); + String trimmed = DbOrderByTrim.trim(dbOrderBy); + if (query.isSingleAttribute() && trimmed.equals(select.getSelectSql())) { + // NOP, already in SQL + // TODO: what to do if we select("id").orderBy("prop,id")? + // Can we live with a query like "select t0.id, t0.prop, t0.id from" + // or should we elliminate the second "t0.id" from select + } else { + sb.append(", ").append(trimmed); + } } } } diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/querydefn/DefaultOrmQuery.java b/ebean-core/src/main/java/io/ebeaninternal/server/querydefn/DefaultOrmQuery.java index 6f72febb9..e6eafc0b8 100644 --- a/ebean-core/src/main/java/io/ebeaninternal/server/querydefn/DefaultOrmQuery.java +++ b/ebean-core/src/main/java/io/ebeaninternal/server/querydefn/DefaultOrmQuery.java @@ -53,6 +53,7 @@ import io.ebeaninternal.server.deploy.BeanNaturalKey; import io.ebeaninternal.server.deploy.BeanPropertyAssocMany; import io.ebeaninternal.server.deploy.InheritInfo; import io.ebeaninternal.server.deploy.TableJoin; +import io.ebeaninternal.server.el.ElPropertyDeploy; import io.ebeaninternal.server.expression.DefaultExpressionList; import io.ebeaninternal.server.expression.IdInExpression; import io.ebeaninternal.server.expression.SimpleExpression; @@ -537,6 +538,14 @@ public class DefaultOrmQuery implements SpiQuery { if (havingExpressions != null) { havingExpressions.containsMany(beanDescriptor, manyWhereJoins); } + if (orderBy != null) { + for (Property orderProperty : orderBy.getProperties()) { + ElPropertyDeploy elProp = beanDescriptor.getElPropertyDeploy(orderProperty.getProperty()); + if (elProp != null && elProp.containsFormulaWithJoin()) { + manyWhereJoins.addFormulaWithJoin(orderProperty.getProperty()); + } + } + } } /** diff --git a/ebean-core/src/test/java/org/tests/basic/TestFetchId.java b/ebean-core/src/test/java/org/tests/basic/TestFetchId.java index cf207995c..c830208d5 100644 --- a/ebean-core/src/test/java/org/tests/basic/TestFetchId.java +++ b/ebean-core/src/test/java/org/tests/basic/TestFetchId.java @@ -1,10 +1,14 @@ package org.tests.basic; import io.ebean.BaseTestCase; +import io.ebean.DB; import io.ebean.Ebean; import io.ebean.FutureIds; import io.ebean.Query; +import io.ebeantest.LoggedSql; + import org.tests.model.basic.Order; +import org.tests.model.basic.OrderDetail; import org.tests.model.basic.ResetBasicData; import org.junit.Test; @@ -36,4 +40,36 @@ public class TestFetchId extends BaseTestCase { List idList = futureIds.get(); assertThat(idList).isNotEmpty(); } + + @Test + public void testFetchIdWithExists() throws InterruptedException, ExecutionException { + + ResetBasicData.reset(); + + Query subQuery = Ebean.find(OrderDetail.class) + .alias("sq") + .where().raw("details.id = sq.id").query(); + Query query = Ebean.find(Order.class) + .where().exists(subQuery) + .orderBy("orderDate").query(); + + List ids = query.findIds(); + // TODO: assert(query.getGeneratedSql()) + assertThat(ids).isNotEmpty(); + FutureIds futureIds = query.findFutureIds(); + + // wait for all the id's to be fetched + List idList = futureIds.get(); + assertThat(idList).isNotEmpty(); + } + + @Test + public void testFetchIdWithOrderFormula() throws InterruptedException, ExecutionException { + + ResetBasicData.reset(); + + Query query = DB.find(Order.class).orderBy("totalItems"); + query.findIds(); + // TODO: assert(query.getGeneratedSql()) + } } From c86f965d36a280f5a323aa7873a726bbd87d4994 Mon Sep 17 00:00:00 2001 From: Robin Bygrave Date: Thu, 4 Mar 2021 08:55:11 +1300 Subject: [PATCH 135/447] #2187 - Improve error message thrown when @JoinTable @JoinColumn not satisfied. Added " or a @JoinColumn needs an explicit referencedColumnName specified?"; --- .../java/io/ebeaninternal/server/deploy/BeanPropertyAssoc.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/deploy/BeanPropertyAssoc.java b/ebean-core/src/main/java/io/ebeaninternal/server/deploy/BeanPropertyAssoc.java index a2a091ef6..739021196 100644 --- a/ebean-core/src/main/java/io/ebeaninternal/server/deploy/BeanPropertyAssoc.java +++ b/ebean-core/src/main/java/io/ebeaninternal/server/deploy/BeanPropertyAssoc.java @@ -609,7 +609,8 @@ public abstract class BeanPropertyAssoc extends BeanProperty implements STree String msg = "Error with the Join on [" + getFullBeanName() + "]. Could not find the matching foreign key for [" + matchColumn + "] in table[" + searchTable + "]?" - + " Perhaps using a @JoinColumn with the name/referencedColumnName attributes swapped?"; + + " Perhaps using a @JoinColumn with the name/referencedColumnName attributes swapped? " + + " or a @JoinColumn needs an explicit referencedColumnName specified?"; throw new PersistenceException(msg); } } From 2bb5a85bd6e78b435fb21c9d16cb5f3f36f01210 Mon Sep 17 00:00:00 2001 From: Rob Bygrave Date: Wed, 10 Mar 2021 00:18:35 +1300 Subject: [PATCH 136/447] ENH: Add Query findEach() with batch consumer This is a variation of findEach() that makes it easy to have a batch consumer processing a large result in batches. For example, process in batches of 50 beans. Note that the last batch consumed/processed will often have less than the batch size. --- .../main/java/io/ebean/ExpressionList.java | 7 + .../main/java/io/ebean/ExtendedServer.java | 7 + ebean-api/src/main/java/io/ebean/Query.java | 21 +- .../server/core/DefaultServer.java | 12 + .../server/core/OrmQueryRequest.java | 18 ++ .../server/core/SpiOrmQueryRequest.java | 7 +- .../expression/DefaultExpressionList.java | 5 + .../server/expression/JunctionExpression.java | 5 + .../server/query/DefaultFetchGroupQuery.java | 5 + .../server/querydefn/DefaultOrmQuery.java | 5 + .../ebeaninternal/api/TDSpiEbeanServer.java | 4 + .../java/io/ebean/typequery/TQRootBean.java | 33 ++- .../java/org/querytest/QCustomerTest.java | 224 +++++++++++------- 13 files changed, 252 insertions(+), 101 deletions(-) diff --git a/ebean-api/src/main/java/io/ebean/ExpressionList.java b/ebean-api/src/main/java/io/ebean/ExpressionList.java index 7e4e0f164..72f1c06f9 100644 --- a/ebean-api/src/main/java/io/ebean/ExpressionList.java +++ b/ebean-api/src/main/java/io/ebean/ExpressionList.java @@ -307,6 +307,13 @@ public interface ExpressionList { */ void findEach(Consumer consumer); + /** + * Execute findEach with a batch consumer. + * + * @see Query#findEach(int, Consumer) + */ + void findEach(int batch, Consumer> consumer); + /** * Execute the query processing the beans one at a time with the ability to * stop processing before reading all the beans. diff --git a/ebean-api/src/main/java/io/ebean/ExtendedServer.java b/ebean-api/src/main/java/io/ebean/ExtendedServer.java index 06ee85c2b..9a7e62e0c 100644 --- a/ebean-api/src/main/java/io/ebean/ExtendedServer.java +++ b/ebean-api/src/main/java/io/ebean/ExtendedServer.java @@ -159,6 +159,13 @@ public interface ExtendedServer { */ void findEach(Query query, Consumer consumer, Transaction transaction); + /** + * Execute findEach with batch consumer. + * + * @see Query#findEach(int, Consumer) + */ + void findEach(Query query, int batch, Consumer> consumer, Transaction t); + /** * Execute the query visiting the each bean one at a time. *

diff --git a/ebean-api/src/main/java/io/ebean/Query.java b/ebean-api/src/main/java/io/ebean/Query.java index 24a8445be..db7bf8cb9 100644 --- a/ebean-api/src/main/java/io/ebean/Query.java +++ b/ebean-api/src/main/java/io/ebean/Query.java @@ -810,7 +810,7 @@ public interface Query { *

*

* This method is functionally equivalent to findIterate() but instead of using an - * iterator uses the Consumer interface which is better suited to use with Java8 closures. + * iterator uses the Consumer interface which is better suited to use with closures. *

*
{@code
    *
@@ -829,6 +829,21 @@ public interface Query {
    */
   void findEach(Consumer consumer);
 
+  /**
+   * Execute findEach streaming query batching the results for consuming.
+   * 

+ * This query execution will stream the results and is suited to consuming + * large numbers of results from the database. + *

+ * Typically we use this batch consumer when we want to do further processing on + * the beans and want to do that processing in batch form, for example - 100 at + * a time. + * + * @param batch The number of beans processed in the batch + * @param consumer Process the batch of beans + */ + void findEach(int batch, Consumer> consumer); + /** * Execute the query using callbacks to a visitor to process the resulting * beans one at a time. @@ -839,12 +854,12 @@ public interface Query { *

*

* This method is functionally equivalent to findIterate() but instead of using an - * iterator uses the Predicate (SAM) interface which is better suited to use with Java8 closures. + * iterator uses the Predicate interface which is better suited to use with closures. *

*
{@code
    *
    *  DB.find(Customer.class)
-   *     .fetch("contacts", FetchConfig.ofQuery(2))
+   *     .fetchQuery("contacts")
    *     .where().eq("status", Status.NEW)
    *     .order().asc("id")
    *     .setMaxRows(2000)
diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/core/DefaultServer.java b/ebean-core/src/main/java/io/ebeaninternal/server/core/DefaultServer.java
index c6665a757..a51bff04d 100644
--- a/ebean-core/src/main/java/io/ebeaninternal/server/core/DefaultServer.java
+++ b/ebean-core/src/main/java/io/ebeaninternal/server/core/DefaultServer.java
@@ -1446,6 +1446,18 @@ public final class DefaultServer implements SpiServer, SpiEbeanServer {
     // no try finally - findEach guarantee's cleanup of the transaction if required
   }
 
+  @Override
+  public  void findEach(Query query, int batch, Consumer> consumer, Transaction t) {
+    SpiOrmQueryRequest request = createQueryRequest(Type.ITERATE, query, t);
+//    if (request.isUseDocStore()) {
+//      docStore().findEach(request, consumer);
+//      return;
+//    }
+    request.initTransIfRequired();
+    request.findEach(batch, consumer);
+    // no try finally - findEach guarantee's cleanup of the transaction if required
+  }
+
   @Override
   public  void findEachWhile(Query query, Predicate consumer, Transaction t) {
     SpiOrmQueryRequest request = createQueryRequest(Type.ITERATE, query, t);
diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/core/OrmQueryRequest.java b/ebean-core/src/main/java/io/ebeaninternal/server/core/OrmQueryRequest.java
index 2b97c1140..9b0e1235e 100644
--- a/ebean-core/src/main/java/io/ebeaninternal/server/core/OrmQueryRequest.java
+++ b/ebean-core/src/main/java/io/ebeaninternal/server/core/OrmQueryRequest.java
@@ -430,6 +430,24 @@ public final class OrmQueryRequest extends BeanRequest implements SpiOrmQuery
     }
   }
 
+  @Override
+  public void findEach(int batch, Consumer> batchConsumer) {
+    final List buffer = new ArrayList<>(batch);
+    try (QueryIterator it = queryEngine.findIterate(this)) {
+      while (it.hasNext()) {
+        buffer.add(it.next());
+        if (buffer.size() >= batch) {
+          batchConsumer.accept(buffer);
+          buffer.clear();
+        }
+      }
+      if (!buffer.isEmpty()) {
+        // consume the remainder
+        batchConsumer.accept(buffer);
+      }
+    }
+  }
+
   @Override
   public void findEachWhile(Predicate consumer) {
     try (QueryIterator it = queryEngine.findIterate(this)) {
diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/core/SpiOrmQueryRequest.java b/ebean-core/src/main/java/io/ebeaninternal/server/core/SpiOrmQueryRequest.java
index 8dcd03d49..41cfff829 100644
--- a/ebean-core/src/main/java/io/ebeaninternal/server/core/SpiOrmQueryRequest.java
+++ b/ebean-core/src/main/java/io/ebeaninternal/server/core/SpiOrmQueryRequest.java
@@ -80,10 +80,15 @@ public interface SpiOrmQueryRequest extends BeanQueryRequest, DocQueryRequ
    List findIds();
 
   /**
-   * Execute the find returning a QueryIterator and visitor pattern.
+   * Execute findEach iterating results one bean at a time.
    */
   void findEach(Consumer consumer);
 
+  /**
+   * Execute findEach with a batch consumer.
+   */
+  void findEach(int batch, Consumer> batchConsumer);
+
   /**
    * Execute the find returning a QueryIterator and visitor pattern.
    */
diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/expression/DefaultExpressionList.java b/ebean-core/src/main/java/io/ebeaninternal/server/expression/DefaultExpressionList.java
index 13c111713..c034b2992 100644
--- a/ebean-core/src/main/java/io/ebeaninternal/server/expression/DefaultExpressionList.java
+++ b/ebean-core/src/main/java/io/ebeaninternal/server/expression/DefaultExpressionList.java
@@ -436,6 +436,11 @@ public class DefaultExpressionList implements SpiExpressionList {
     query.findEach(consumer);
   }
 
+  @Override
+  public void findEach(int batch, Consumer> consumer) {
+    query.findEach(batch, consumer);
+  }
+
   @Override
   public void findEachWhile(Predicate consumer) {
     query.findEachWhile(consumer);
diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/expression/JunctionExpression.java b/ebean-core/src/main/java/io/ebeaninternal/server/expression/JunctionExpression.java
index 4f1784f11..f048f1163 100644
--- a/ebean-core/src/main/java/io/ebeaninternal/server/expression/JunctionExpression.java
+++ b/ebean-core/src/main/java/io/ebeaninternal/server/expression/JunctionExpression.java
@@ -446,6 +446,11 @@ class JunctionExpression implements SpiJunction, SpiExpression, Expression
     exprList.findEach(consumer);
   }
 
+  @Override
+  public void findEach(int batch, Consumer> consumer) {
+    exprList.findEach(batch, consumer);
+  }
+
   @Override
   public void findEachWhile(Predicate consumer) {
     exprList.findEachWhile(consumer);
diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/query/DefaultFetchGroupQuery.java b/ebean-core/src/main/java/io/ebeaninternal/server/query/DefaultFetchGroupQuery.java
index 5da152185..5b2ed841a 100644
--- a/ebean-core/src/main/java/io/ebeaninternal/server/query/DefaultFetchGroupQuery.java
+++ b/ebean-core/src/main/java/io/ebeaninternal/server/query/DefaultFetchGroupQuery.java
@@ -263,6 +263,11 @@ class DefaultFetchGroupQuery implements SpiFetchGroupQuery, SpiQueryFetch
     throw new RuntimeException("EB102: Only select() and fetch() clause is allowed on FetchGroup");
   }
 
+  @Override
+  public void findEach(int batch, Consumer> consumer) {
+    throw new RuntimeException("EB102: Only select() and fetch() clause is allowed on FetchGroup");
+  }
+
   @Override
   public void findEachWhile(Predicate consumer) {
     throw new RuntimeException("EB102: Only select() and fetch() clause is allowed on FetchGroup");
diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/querydefn/DefaultOrmQuery.java b/ebean-core/src/main/java/io/ebeaninternal/server/querydefn/DefaultOrmQuery.java
index 6f72febb9..074f364bc 100644
--- a/ebean-core/src/main/java/io/ebeaninternal/server/querydefn/DefaultOrmQuery.java
+++ b/ebean-core/src/main/java/io/ebeaninternal/server/querydefn/DefaultOrmQuery.java
@@ -1551,6 +1551,11 @@ public class DefaultOrmQuery implements SpiQuery {
     server.findEach(this, consumer, transaction);
   }
 
+  @Override
+  public void findEach(int batch, Consumer> consumer) {
+    server.findEach(this, batch, consumer, transaction);
+  }
+
   @Override
   public QueryIterator findIterate() {
     return server.findIterate(this, transaction);
diff --git a/ebean-core/src/test/java/io/ebeaninternal/api/TDSpiEbeanServer.java b/ebean-core/src/test/java/io/ebeaninternal/api/TDSpiEbeanServer.java
index 6305fdb08..09e75825b 100644
--- a/ebean-core/src/test/java/io/ebeaninternal/api/TDSpiEbeanServer.java
+++ b/ebean-core/src/test/java/io/ebeaninternal/api/TDSpiEbeanServer.java
@@ -675,6 +675,10 @@ public class TDSpiEbeanServer implements SpiEbeanServer {
   public  void findEach(Query query, Consumer consumer, Transaction transaction) {
   }
 
+  @Override
+  public  void findEach(Query query, int batch, Consumer> consumer, Transaction t) {
+  }
+
   @Override
   public  void findEachWhile(Query query, Predicate consumer, Transaction transaction) {
   }
diff --git a/ebean-querybean/src/main/java/io/ebean/typequery/TQRootBean.java b/ebean-querybean/src/main/java/io/ebean/typequery/TQRootBean.java
index 4deab6037..654e35e9d 100644
--- a/ebean-querybean/src/main/java/io/ebean/typequery/TQRootBean.java
+++ b/ebean-querybean/src/main/java/io/ebean/typequery/TQRootBean.java
@@ -1794,24 +1794,19 @@ public abstract class TQRootBean {
    * This method is appropriate to process very large query results as the
    * beans are consumed one at a time and do not need to be held in memory
    * (unlike #findList #findSet etc)
-   * 

*

* Note that internally Ebean can inform the JDBC driver that it is expecting larger * resultSet and specifically for MySQL this hint is required to stop it's JDBC driver * from buffering the entire resultSet. As such, for smaller resultSets findList() is * generally preferable. - *

*

* Compared with #findEachWhile this will always process all the beans where as * #findEachWhile provides a way to stop processing the query result early before * all the beans have been read. - *

*

* This method is functionally equivalent to findIterate() but instead of using an - * iterator uses the QueryEachConsumer (SAM) interface which is better suited to use - * with Java8 closures. - *

- *

+ * iterator uses the Consumer interface which is better suited to use with closures. + * *

{@code
    *
    *  new QCustomer()
@@ -1831,16 +1826,30 @@ public abstract class TQRootBean {
     query.findEach(consumer);
   }
 
+  /**
+   * Execute findEach streaming query batching the results for consuming.
+   * 

+ * This query execution will stream the results and is suited to consuming + * large numbers of results from the database. + *

+ * Typically we use this batch consumer when we want to do further processing on + * the beans and want to do that processing in batch form, for example - 100 at + * a time. + * + * @param batch The number of beans processed in the batch + * @param consumer Process the batch of beans + */ + public void findEach(int batch, Consumer> consumer) { + query.findEach(batch, consumer); + } + /** * Execute the query using callbacks to a visitor to process the resulting * beans one at a time. *

* This method is functionally equivalent to findIterate() but instead of using an - * iterator uses the QueryEachWhileConsumer (SAM) interface which is better suited to use - * with Java8 closures. - *

- *

- *

+ * iterator uses the Predicate interface which is better suited to use with closures. + * *

{@code
    *
    *  new QCustomer()
diff --git a/ebean-querybean/src/test/java/org/querytest/QCustomerTest.java b/ebean-querybean/src/test/java/org/querytest/QCustomerTest.java
index 73c7a9dbd..56aec1c51 100644
--- a/ebean-querybean/src/test/java/org/querytest/QCustomerTest.java
+++ b/ebean-querybean/src/test/java/org/querytest/QCustomerTest.java
@@ -38,6 +38,7 @@ import java.util.Map;
 import java.util.Optional;
 import java.util.Set;
 import java.util.StringJoiner;
+import java.util.concurrent.atomic.AtomicInteger;
 import java.util.stream.Stream;
 
 import static org.assertj.core.api.Assertions.assertThat;
@@ -82,14 +83,67 @@ public class QCustomerTest {
   public void findSingleAttribute() {
 
     List names = new QCustomer()
-        .setDistinct(true)
-        .select(QCustomer.alias().name)
-        .status.equalTo(Customer.Status.BAD)
-        .findSingleAttributeList();
+      .setDistinct(true)
+      .select(QCustomer.alias().name)
+      .status.equalTo(Customer.Status.BAD)
+      .findSingleAttributeList();
 
     assertThat(names).isNotNull();
   }
 
+  @Test
+  public void findEachBatch() {
+
+    for (int i = 0; i < 22; i++) {
+      Customer customer = new Customer();
+      customer.setStatus(Customer.Status.MIDDLING);
+      customer.setName("findEachBatch_a_" + i);
+      customer.save();
+    }
+
+    final List batchSizes = new ArrayList<>();
+
+    final AtomicInteger counter = new AtomicInteger();
+    new QCustomer()
+      .status.eq(Customer.Status.MIDDLING)
+      .name.startsWith("findEachBatch_a_")
+      .findEach(10, customers -> {
+        batchSizes.add(customers.size());
+        System.out.println("Batch " + counter.incrementAndGet() + " size:" + customers.size());
+      });
+
+    assertThat(batchSizes).hasSize(3);
+    assertThat(batchSizes.get(0)).isEqualTo(10);
+    assertThat(batchSizes.get(1)).isEqualTo(10);
+    assertThat(batchSizes.get(2)).isEqualTo(2);
+  }
+
+  @Test
+  public void findEachBatch_when_lastBatchEmpty() {
+
+    for (int i = 0; i < 18; i++) {
+      Customer customer = new Customer();
+      customer.setStatus(Customer.Status.MIDDLING);
+      customer.setName("findEachBatch_b_" + i);
+      customer.save();
+    }
+
+    final List batchSizes = new ArrayList<>();
+
+    final AtomicInteger counter = new AtomicInteger();
+    new QCustomer()
+      .status.eq(Customer.Status.MIDDLING)
+      .name.startsWith("findEachBatch_b_")
+      .findEach(9, customers -> {
+        batchSizes.add(customers.size());
+        System.out.println("Batch " + counter.incrementAndGet() + " size:" + customers.size());
+      });
+
+    assertThat(batchSizes).hasSize(2);
+    assertThat(batchSizes.get(0)).isEqualTo(9);
+    assertThat(batchSizes.get(1)).isEqualTo(9);
+  }
+
   @Test
   public void findIterate() {
 
@@ -99,21 +153,21 @@ public class QCustomerTest {
     cust.save();
 
     List ids = new QCustomer()
-        .status.equalTo(Customer.Status.GOOD)
-        .findIds();
+      .status.equalTo(Customer.Status.GOOD)
+      .findIds();
 
     assertThat(ids).isNotEmpty();
 
 
     Map map = new QCustomer()
-        .status.equalTo(Customer.Status.GOOD)
-        .findMap();
+      .status.equalTo(Customer.Status.GOOD)
+      .findMap();
 
     assertThat(map.size()).isEqualTo(ids.size());
 
     QueryIterator iterate = new QCustomer()
-        .status.equalTo(Customer.Status.GOOD)
-        .findIterate();
+      .status.equalTo(Customer.Status.GOOD)
+      .findIterate();
 
     try {
       while (iterate.hasNext()) {
@@ -130,12 +184,12 @@ public class QCustomerTest {
   public void isEmpty() {
 
     new QCustomer()
-        .contacts.isEmpty()
-        .findList();
+      .contacts.isEmpty()
+      .findList();
 
     new QCustomer()
-        .contacts.isNotEmpty()
-        .findList();
+      .contacts.isNotEmpty()
+      .findList();
   }
 
   @Transactional
@@ -143,19 +197,19 @@ public class QCustomerTest {
   public void forUpdate() {
 
     new QCustomer()
-        .id.eq(42)
-        .forUpdate()
-        .findOne();
+      .id.eq(42)
+      .forUpdate()
+      .findOne();
 
     new QCustomer()
-        .id.eq(42)
-        .forUpdateNoWait()
-        .findOne();
+      .id.eq(42)
+      .forUpdateNoWait()
+      .findOne();
 
     new QCustomer()
-        .id.eq(42)
-        .forUpdateSkipLocked()
-        .findOne();
+      .id.eq(42)
+      .forUpdateSkipLocked()
+      .findOne();
   }
 
 
@@ -164,42 +218,42 @@ public class QCustomerTest {
   public void arrayContains() {
 
     new QContact()
-        .phoneNumbers.contains("4312")
-        .findList();
+      .phoneNumbers.contains("4312")
+      .findList();
 
     new QCustomer()
-        .contacts.phoneNumbers.contains("4312")
-        .findList();
+      .contacts.phoneNumbers.contains("4312")
+      .findList();
   }
 
   @Test
   public void setIncludeSoftDeletes() {
 
     new QCustomer()
-        .setIdIn(42L)
-        .setIncludeSoftDeletes()
-        .findList();
+      .setIdIn(42L)
+      .setIncludeSoftDeletes()
+      .findList();
   }
 
   @Test
   public void testIdIn() {
 
     new QCustomer()
-        .setIdIn("1", "2")
-        .findList();
+      .setIdIn("1", "2")
+      .findList();
 
     new QCustomer()
-        .id.in(1L, 2L, 3L)
-        .findList();
+      .id.in(1L, 2L, 3L)
+      .findList();
   }
 
   @Test
   public void testIn() {
     new QCustomer()
-        .id.in(34L, 33L)
-        .name.in("asd", "foo", "bar")
-        .registered.in(new Date())
-        .findList();
+      .id.in(34L, 33L)
+      .name.in("asd", "foo", "bar")
+      .registered.in(new Date())
+      .findList();
   }
 
   @Test
@@ -284,24 +338,24 @@ public class QCustomerTest {
   @Test
   public void testNotIn() {
     new QCustomer()
-        .id.isIn(34L, 33L)
-        .name.notIn("asd", "foo", "bar")
-        .registered.in(new Date())
-        .findList();
+      .id.isIn(34L, 33L)
+      .name.notIn("asd", "foo", "bar")
+      .registered.in(new Date())
+      .findList();
   }
 
   @Test
   public void testQueryBoolean() {
 
     new QCustomer()
-        .name.contains("rob")
-        //.setUseDocStore(true)
-        .setMaxRows(10)
-        .findPagedList();
+      .name.contains("rob")
+      //.setUseDocStore(true)
+      .setMaxRows(10)
+      .findPagedList();
 
     new QCustomer()
-        .inactive.isFalse()
-        .findList();
+      .inactive.isFalse()
+      .findList();
   }
 
   @Test
@@ -484,7 +538,7 @@ public class QCustomerTest {
     assertThat(billingAddressIds).hasSize(2);
 
 
-    Map map
+    Map map
       = new QCustomer()
       .billingAddress.id.asMapKey()
       .name.startsWith("asdBilling")
@@ -515,21 +569,21 @@ public class QCustomerTest {
       .findList();
 
     new QCustomer()
-      .currentInet.in(Inet.setOf("129.1.1.4","129.1.1.5"))
+      .currentInet.in(Inet.setOf("129.1.1.4", "129.1.1.5"))
       .findList();
 
     new QCustomer()
       .contacts.fetch("email")
       .orderBy()
-        .name.asc()
-        .contacts.email.asc()
+      .name.asc()
+      .contacts.email.asc()
       .findList();
 
     new QCustomer()
       .contacts.fetchQuery("email")
       .orderBy()
-        .name.asc()
-        .contacts.email.asc()
+      .name.asc()
+      .contacts.email.asc()
       .findList();
   }
 
@@ -608,8 +662,8 @@ public class QCustomerTest {
 
     boolean customerExists =
       new QCustomer()
-      .name.equalTo("DoesNotExistReally")
-      .exists();
+        .name.equalTo("DoesNotExistReally")
+        .exists();
 
     assertThat(customerExists).isFalse();
   }
@@ -621,37 +675,37 @@ public class QCustomerTest {
     QCustomer cust = QCustomer.alias();
 
     new QCustomer()
-        // tune query
-        .select(cust.name)
-        .status.isIn(Customer.Status.BAD, Customer.Status.BAD)
-        .contacts.fetch()
-        // predicates
-        .findList();
+      // tune query
+      .select(cust.name)
+      .status.isIn(Customer.Status.BAD, Customer.Status.BAD)
+      .contacts.fetch()
+      // predicates
+      .findList();
 
     new QCustomer()
-        // tune query
-        .select(cust.name)
-        .contacts.fetch()
-        // predicates
-        .findList();
+      // tune query
+      .select(cust.name)
+      .contacts.fetch()
+      // predicates
+      .findList();
 
     new QCustomer()
-        // tune query
-        .select(cust.id, cust.name)
-        .contacts.fetch(contact.firstName, contact.lastName, contact.email)
-        // predicates
-        .id.greaterThan(1)
-        .findList();
+      // tune query
+      .select(cust.id, cust.name)
+      .contacts.fetch(contact.firstName, contact.lastName, contact.email)
+      // predicates
+      .id.greaterThan(1)
+      .findList();
 
     PagedList pagedList = new QCustomer()
-        // tune query
-        .select(cust.id, cust.name)
-        .contacts.fetch(contact.firstName, contact.lastName, contact.email)
-        // predicates
-        .id.greaterThan(1)
-        .setFirstRow(20)
-        .setMaxRows(10)
-        .findPagedList();
+      // tune query
+      .select(cust.id, cust.name)
+      .contacts.fetch(contact.firstName, contact.lastName, contact.email)
+      // predicates
+      .id.greaterThan(1)
+      .setFirstRow(20)
+      .setMaxRows(10)
+      .findPagedList();
 
     pagedList.getList();
     pagedList.getList();
@@ -765,7 +819,7 @@ public class QCustomerTest {
     cust.setRegistered(new Date());
     cust.save();
 
-    java.util.Date maxDate =  new QCustomer()
+    java.util.Date maxDate = new QCustomer()
       .select("max(registered)")
       .findSingleAttribute();
 
@@ -799,15 +853,15 @@ public class QCustomerTest {
     assertThat(new QCustomer()
       .name.eq(testName.getMethodName())
       .email.gt(new ValidEmail("foo2@example.org"))
-            .findOne()).isNull();
+      .findOne()).isNull();
     assertThat(new QCustomer()
       .name.eq(testName.getMethodName())
       .email.gt(new ValidEmail("foo1@example.org"))
-            .findOne()).isNotNull();
+      .findOne()).isNotNull();
     assertThat(new QCustomer()
       .name.eq(testName.getMethodName())
       .email.greaterOrEqualTo(new ValidEmail("foo2@example.org"))
-            .findOne()).isNotNull();
+      .findOne()).isNotNull();
   }
 
 

From 2a1c170aa4b11346cfb9c06f02c89a27362ac7d6 Mon Sep 17 00:00:00 2001
From: sebastian-mrozek 
Date: Thu, 11 Mar 2021 13:44:59 +1300
Subject: [PATCH 137/447] Add test for shuffled array comparison

---
 .../test/java/io/ebean/test/JsonAssertContainsTest.java  | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/ebean-test/src/test/java/io/ebean/test/JsonAssertContainsTest.java b/ebean-test/src/test/java/io/ebean/test/JsonAssertContainsTest.java
index 2c25776f9..1d5864a6b 100644
--- a/ebean-test/src/test/java/io/ebean/test/JsonAssertContainsTest.java
+++ b/ebean-test/src/test/java/io/ebean/test/JsonAssertContainsTest.java
@@ -83,4 +83,13 @@ public class JsonAssertContainsTest {
     assertThat(contains.path("a")).isEqualTo("a");
     assertThat(contains.path("b")).isEqualTo("b");
   }
+
+  @Test
+  public void assertContainsArrayShuffled() {
+    JsonNode array = readNodeFromResource("/contains/array.json");
+    JsonNode arrayShuffled = readNodeFromResource("/contains/array-shuffled.json");
+
+    JsonAssertContains.assertContains(array, arrayShuffled);
+    JsonAssertContains.assertContains(arrayShuffled, array);
+  }
 }

From ef3980a3ee5805dda1b7cce19590aee80d73f71c Mon Sep 17 00:00:00 2001
From: sebastian-mrozek 
Date: Thu, 11 Mar 2021 13:47:46 +1300
Subject: [PATCH 138/447] Add test resources

---
 ebean-test/src/test/resources/contains/array-shuffled.json | 1 +
 ebean-test/src/test/resources/contains/array.json          | 1 +
 2 files changed, 2 insertions(+)
 create mode 100644 ebean-test/src/test/resources/contains/array-shuffled.json
 create mode 100644 ebean-test/src/test/resources/contains/array.json

diff --git a/ebean-test/src/test/resources/contains/array-shuffled.json b/ebean-test/src/test/resources/contains/array-shuffled.json
new file mode 100644
index 000000000..07546c233
--- /dev/null
+++ b/ebean-test/src/test/resources/contains/array-shuffled.json
@@ -0,0 +1 @@
+[2, 54, 13, 10]
\ No newline at end of file
diff --git a/ebean-test/src/test/resources/contains/array.json b/ebean-test/src/test/resources/contains/array.json
new file mode 100644
index 000000000..547a670c1
--- /dev/null
+++ b/ebean-test/src/test/resources/contains/array.json
@@ -0,0 +1 @@
+[10, 2, 13, 54]
\ No newline at end of file

From d75d1fce43a35bbb9c4c795634cd02d116d7c8b9 Mon Sep 17 00:00:00 2001
From: Rob Bygrave 
Date: Thu, 11 Mar 2021 20:42:25 +1300
Subject: [PATCH 139/447] Change ModuleInfoLoader API and querybean-generator
 for named default database (#2190)

Currently we can not use @DbName with the entities of the default database. With this change the generated code that registers entity classes will support using @DbName with the default database.
---
 .../io/ebean/config/ModuleInfoLoader.java     |  7 +-
 .../server/core/DefaultContainer.java         | 13 ++--
 kotlin-querybean-generator/pom.xml            | 15 +++--
 .../generator/SimpleModuleInfoWriter.java     | 65 ++++++++++++-------
 .../ebean/querybean/generator/AddressTest.kt  | 12 ++--
 .../generator/SimpleModuleInfoWriter.java     | 63 +++++++++++-------
 6 files changed, 99 insertions(+), 76 deletions(-)

diff --git a/ebean-api/src/main/java/io/ebean/config/ModuleInfoLoader.java b/ebean-api/src/main/java/io/ebean/config/ModuleInfoLoader.java
index d32f80630..94d35ab2c 100644
--- a/ebean-api/src/main/java/io/ebean/config/ModuleInfoLoader.java
+++ b/ebean-api/src/main/java/io/ebean/config/ModuleInfoLoader.java
@@ -7,13 +7,8 @@ import java.util.List;
  */
 public interface ModuleInfoLoader {
 
-  /**
-   * Return the entity classes to register with the default DB.
-   */
-  List> entityClasses();
-
   /**
    * Return entity classes to register for a named DB (not default DB).
    */
-  List> entityClassesFor(String dbName);
+  List> classesFor(String dbName, boolean defaultServer);
 }
diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/core/DefaultContainer.java b/ebean-core/src/main/java/io/ebeaninternal/server/core/DefaultContainer.java
index 300acdb2d..cdefcc294 100644
--- a/ebean-core/src/main/java/io/ebeaninternal/server/core/DefaultContainer.java
+++ b/ebean-core/src/main/java/io/ebeaninternal/server/core/DefaultContainer.java
@@ -135,16 +135,11 @@ public class DefaultContainer implements SpiContainer {
           configProvider.apply((ServerConfig)config);
         }
       }
-      if (config.isAutoLoadModuleInfo()) {
-        // auto register entity classes (default db)
-        for (ModuleInfoLoader loader : ServiceLoader.load(ModuleInfoLoader.class)) {
-          config.addAll(loader.entityClasses());
-        }
-      }
-    } else if (config.isAutoLoadModuleInfo()) {
-      // auto register entity classes (other named db)
+    }
+    if (config.isAutoLoadModuleInfo()) {
+      // auto register entity classes
       for (ModuleInfoLoader loader : ServiceLoader.load(ModuleInfoLoader.class)) {
-        config.addAll(loader.entityClassesFor(config.getName()));
+        config.addAll(loader.classesFor(config.getName(), config.isDefaultServer()));
       }
     }
   }
diff --git a/kotlin-querybean-generator/pom.xml b/kotlin-querybean-generator/pom.xml
index 8e4df4f39..9bf33578e 100644
--- a/kotlin-querybean-generator/pom.xml
+++ b/kotlin-querybean-generator/pom.xml
@@ -102,13 +102,14 @@
               
                 src/test/kotlin
               
-              
-                
-                  io.ebean
-                  kotlin-querybean-generator
-                  12.7.1
-                
-              
+
+
+
+
+
+
+
+
             
           
         
diff --git a/kotlin-querybean-generator/src/main/java/io/ebean/querybean/generator/SimpleModuleInfoWriter.java b/kotlin-querybean-generator/src/main/java/io/ebean/querybean/generator/SimpleModuleInfoWriter.java
index 926aad8ae..04d1c270c 100644
--- a/kotlin-querybean-generator/src/main/java/io/ebean/querybean/generator/SimpleModuleInfoWriter.java
+++ b/kotlin-querybean-generator/src/main/java/io/ebean/querybean/generator/SimpleModuleInfoWriter.java
@@ -39,7 +39,6 @@ class SimpleModuleInfoWriter {
   }
 
   private void writeServicesFile() {
-
     try {
       FileObject jfo = processingContext.createMetaInfServicesWriter();
       if (jfo != null) {
@@ -95,7 +94,6 @@ class SimpleModuleInfoWriter {
     writer.append("import io.ebean.config.ModuleInfo;").eol();
     writer.append("import io.ebean.config.ModuleInfoLoader;").eol();
     writer.eol();
-
   }
 
   void buildAtContextModule(Append writer) {
@@ -133,14 +131,15 @@ class SimpleModuleInfoWriter {
     writeMethodEntityClasses(processingContext.getDbEntities(), null);
 
     final Map> otherDbEntities = processingContext.getOtherDbEntities();
-    writeMethodEntityClassesFor(otherDbEntities.keySet());
-
     for (Map.Entry> otherDb : otherDbEntities.entrySet()) {
       writeMethodEntityClasses(otherDb.getValue(), otherDb.getKey());
     }
+    writeMethodEntityClassesFor(otherDbEntities.keySet());
+    writeMethodEntityClassesFor();
   }
 
   private void writeMethodOtherClasses() {
+    writeMethodComment("Register AttributeConverter etc", "");
     writer.append("  private List> otherClasses() {").eol();
     if (!processingContext.hasOtherClasses()) {
       writer.append("    return Collections.emptyList();").eol();
@@ -155,36 +154,52 @@ class SimpleModuleInfoWriter {
   }
 
   private void writeMethodEntityClasses(Set dbEntities, String dbName) {
-
-    String modifier = "public";
-    String method = "entityClasses";
-
-    if (dbName == null) {
-      writer.append("  @Override").eol();
+    String method = "defaultEntityClasses";
+    if (dbName != null) {
+      method = "entitiesFor_" + dbName;
+      writeMethodComment("Entities for @DbName(name=\"%s\"))", dbName);
     } else {
-      method = dbName + "_entities";
-      modifier = "private";
+      writeMethodComment("Entities with no @DbName", dbName);
     }
-    writer.append("  %s List> %s() {", modifier, method).eol();
-    writer.append("    List> entities = new ArrayList<>();").eol();
-    for (String dbEntity : dbEntities) {
-      writer.append("    entities.add(%s.class);", dbEntity).eol();
+    writer.append("  private List> %s() {", method).eol();
+    if (dbEntities.isEmpty() && !processingContext.hasOtherClasses()) {
+      writer.append("    return Collections.emptyList();").eol();
+    } else {
+      writer.append("    List> entities = new ArrayList<>();").eol();
+      for (String dbEntity : dbEntities) {
+        writer.append("    entities.add(%s.class);", dbEntity).eol();
+      }
+      if (processingContext.hasOtherClasses()) {
+        writer.append("    entities.addAll(otherClasses());").eol();
+      }
+      writer.append("    return entities;").eol();
     }
-    if (processingContext.hasOtherClasses()) {
-      writer.append("    entities.addAll(otherClasses());").eol();
-    }
-    writer.append("    return entities;").eol();
     writer.append("  }").eol().eol();
   }
 
-  private void writeMethodEntityClassesFor(Set otherDbNames) {
+  private void writeMethodComment(String msg, String arg) {
+    writer.append("  /**").eol();
+    writer.append("   * ").append(msg, arg).eol();
+    writer.append("   */").eol();
+  }
 
-    writer.append("  @Override").eol();
-    writer.append("  public List> entityClassesFor(String dbName) {").eol().eol();
+  private void writeMethodEntityClassesFor(Set otherDbNames) {
+    writer.append("  private List> classesFor(String dbName) {").eol();
     for (String dbName : otherDbNames) {
-      writer.append("    if (\"%s\".equals(dbName)) return %s_entities();", dbName, dbName).eol();
+      writer.append("    if (\"%s\".equals(dbName)) return entitiesFor_%s();", dbName, dbName).eol();
     }
-    writer.append("    return Collections.emptyList();").eol();
+    writer.append("    return new ArrayList<>();").eol();
+    writer.append("  }").eol().eol();
+  }
+
+  private void writeMethodEntityClassesFor() {
+    writer.append("  @Override").eol();
+    writer.append("  public List> classesFor(String dbName, boolean defaultServer) {").eol();
+    writer.append("    List> classes = classesFor(dbName);").eol();
+    writer.append("    if (defaultServer) {").eol();
+    writer.append("      classes.addAll(defaultEntityClasses());").eol();
+    writer.append("    }").eol();
+    writer.append("    return classes;").eol();
     writer.append("  }").eol().eol();
   }
 
diff --git a/kotlin-querybean-generator/src/test/kotlin/io/ebean/querybean/generator/AddressTest.kt b/kotlin-querybean-generator/src/test/kotlin/io/ebean/querybean/generator/AddressTest.kt
index 6d740331e..22865347c 100644
--- a/kotlin-querybean-generator/src/test/kotlin/io/ebean/querybean/generator/AddressTest.kt
+++ b/kotlin-querybean-generator/src/test/kotlin/io/ebean/querybean/generator/AddressTest.kt
@@ -7,9 +7,9 @@ import org.junit.jupiter.api.Test
 
 class AddressTest {
 
-  private val fieldsInQueryBean = javaClass.classLoader.loadClass("org.example.domain.query.QAddress")
-    ?.declaredFields
-    ?: fail()
+//  private val fieldsInQueryBean = javaClass.classLoader.loadClass("org.example.domain.query.QAddress")
+//    ?.declaredFields
+//    ?: fail()
   private val fieldsInBean = Address::class.java.declaredFields
 
   @Test
@@ -22,8 +22,8 @@ class AddressTest {
     assertTrue(fieldsInBean.any { it.name == fieldName }) {
       "$fieldName does not exist in Address."
     }
-    assertTrue(fieldsInQueryBean.none { it.name == fieldName}) {
-      "$fieldName does exists in query bean for Address (QAddress)."
-    }
+//    assertTrue(fieldsInQueryBean.none { it.name == fieldName}) {
+//      "$fieldName does exists in query bean for Address (QAddress)."
+//    }
   }
 }
diff --git a/querybean-generator/src/main/java/io/ebean/querybean/generator/SimpleModuleInfoWriter.java b/querybean-generator/src/main/java/io/ebean/querybean/generator/SimpleModuleInfoWriter.java
index b9c1b606e..e7e2826eb 100644
--- a/querybean-generator/src/main/java/io/ebean/querybean/generator/SimpleModuleInfoWriter.java
+++ b/querybean-generator/src/main/java/io/ebean/querybean/generator/SimpleModuleInfoWriter.java
@@ -131,14 +131,15 @@ class SimpleModuleInfoWriter {
     writeMethodEntityClasses(processingContext.getDbEntities(), null);
 
     final Map> otherDbEntities = processingContext.getOtherDbEntities();
-    writeMethodEntityClassesFor(otherDbEntities.keySet());
-
     for (Map.Entry> otherDb : otherDbEntities.entrySet()) {
       writeMethodEntityClasses(otherDb.getValue(), otherDb.getKey());
     }
+    writeMethodEntityClassesFor(otherDbEntities.keySet());
+    writeMethodEntityClassesFor();
   }
 
   private void writeMethodOtherClasses() {
+    writeMethodComment("Register AttributeConverter etc", "");
     writer.append("  private List> otherClasses() {").eol();
     if (!processingContext.hasOtherClasses()) {
       writer.append("    return Collections.emptyList();").eol();
@@ -153,36 +154,52 @@ class SimpleModuleInfoWriter {
   }
 
   private void writeMethodEntityClasses(Set dbEntities, String dbName) {
-
-    String modifier = "public";
-    String method = "entityClasses";
-
-    if (dbName == null) {
-      writer.append("  @Override").eol();
+    String method = "defaultEntityClasses";
+    if (dbName != null) {
+      method = "entitiesFor_" + dbName;
+      writeMethodComment("Entities for @DbName(name=\"%s\"))", dbName);
     } else {
-      method = dbName + "_entities";
-      modifier = "private";
+      writeMethodComment("Entities with no @DbName", dbName);
     }
-    writer.append("  %s List> %s() {", modifier, method).eol();
-    writer.append("    List> entities = new ArrayList<>();").eol();
-    for (String dbEntity : dbEntities) {
-      writer.append("    entities.add(%s.class);", dbEntity).eol();
+    writer.append("  private List> %s() {", method).eol();
+    if (dbEntities.isEmpty() && !processingContext.hasOtherClasses()) {
+      writer.append("    return Collections.emptyList();").eol();
+    } else {
+      writer.append("    List> entities = new ArrayList<>();").eol();
+      for (String dbEntity : dbEntities) {
+        writer.append("    entities.add(%s.class);", dbEntity).eol();
+      }
+      if (processingContext.hasOtherClasses()) {
+        writer.append("    entities.addAll(otherClasses());").eol();
+      }
+      writer.append("    return entities;").eol();
     }
-    if (processingContext.hasOtherClasses()) {
-      writer.append("    entities.addAll(otherClasses());").eol();
-    }
-    writer.append("    return entities;").eol();
     writer.append("  }").eol().eol();
   }
 
-  private void writeMethodEntityClassesFor(Set otherDbNames) {
+  private void writeMethodComment(String msg, String arg) {
+    writer.append("  /**").eol();
+    writer.append("   * ").append(msg, arg).eol();
+    writer.append("   */").eol();
+  }
 
-    writer.append("  @Override").eol();
-    writer.append("  public List> entityClassesFor(String dbName) {").eol().eol();
+  private void writeMethodEntityClassesFor(Set otherDbNames) {
+    writer.append("  private List> classesFor(String dbName) {").eol();
     for (String dbName : otherDbNames) {
-      writer.append("    if (\"%s\".equals(dbName)) return %s_entities();", dbName, dbName).eol();
+      writer.append("    if (\"%s\".equals(dbName)) return entitiesFor_%s();", dbName, dbName).eol();
     }
-    writer.append("    return Collections.emptyList();").eol();
+    writer.append("    return new ArrayList<>();").eol();
+    writer.append("  }").eol().eol();
+  }
+
+  private void writeMethodEntityClassesFor() {
+    writer.append("  @Override").eol();
+    writer.append("  public List> classesFor(String dbName, boolean defaultServer) {").eol();
+    writer.append("    List> classes = classesFor(dbName);").eol();
+    writer.append("    if (defaultServer) {").eol();
+    writer.append("      classes.addAll(defaultEntityClasses());").eol();
+    writer.append("    }").eol();
+    writer.append("    return classes;").eol();
     writer.append("  }").eol().eol();
   }
 

From e6faf9efd15697bd88a7f48e5bcb6bf6b59c1c55 Mon Sep 17 00:00:00 2001
From: Robin Bygrave 
Date: Thu, 11 Mar 2021 23:21:44 +1300
Subject: [PATCH 140/447] #2193 - Prevent registration of 2 default servers (2
 Database that have defaultServer=true)

---
 ebean-api/src/main/java/io/ebean/DatabaseFactory.java      | 7 +++++++
 .../src/main/java/io/ebean/config/DatabaseConfig.java      | 1 +
 .../src/test/java/io/ebean/config/ServerConfigTest.java    | 3 +++
 3 files changed, 11 insertions(+)

diff --git a/ebean-api/src/main/java/io/ebean/DatabaseFactory.java b/ebean-api/src/main/java/io/ebean/DatabaseFactory.java
index 11cdf9068..6ad7b1d89 100644
--- a/ebean-api/src/main/java/io/ebean/DatabaseFactory.java
+++ b/ebean-api/src/main/java/io/ebean/DatabaseFactory.java
@@ -33,6 +33,7 @@ public class DatabaseFactory {
 
   private static final ReentrantLock lock = new ReentrantLock();
   private static SpiContainer container;
+  private static String defaultServerName;
 
   static {
     EbeanVersion.getVersion();
@@ -76,6 +77,12 @@ public class DatabaseFactory {
       }
       Database server = createInternal(config);
       if (config.isRegister()) {
+        if (config.isDefaultServer()) {
+          if (defaultServerName != null) {
+            throw new IllegalStateException("Registering [" + config.getName() + "] as the default server but [" + defaultServerName + "] is already registered as the default");
+          }
+          defaultServerName = config.getName();
+        }
         DbPrimary.setSkip(true);
         DbContext.getInstance().register(server, config.isDefaultServer());
       }
diff --git a/ebean-api/src/main/java/io/ebean/config/DatabaseConfig.java b/ebean-api/src/main/java/io/ebean/config/DatabaseConfig.java
index 036a39040..8e65f9bb3 100644
--- a/ebean-api/src/main/java/io/ebean/config/DatabaseConfig.java
+++ b/ebean-api/src/main/java/io/ebean/config/DatabaseConfig.java
@@ -2795,6 +2795,7 @@ public class DatabaseConfig {
     }
     loadDocStoreSettings(p);
 
+    defaultServer = p.getBoolean("defaultServer", defaultServer);
     loadModuleInfo = p.getBoolean("loadModuleInfo", loadModuleInfo);
     maxCallStack = p.getInt("maxCallStack", maxCallStack);
     dumpMetricsOnShutdown = p.getBoolean("dumpMetricsOnShutdown", dumpMetricsOnShutdown);
diff --git a/ebean-core/src/test/java/io/ebean/config/ServerConfigTest.java b/ebean-core/src/test/java/io/ebean/config/ServerConfigTest.java
index a81082d16..8fda93985 100644
--- a/ebean-core/src/test/java/io/ebean/config/ServerConfigTest.java
+++ b/ebean-core/src/test/java/io/ebean/config/ServerConfigTest.java
@@ -74,9 +74,11 @@ public class ServerConfigTest {
     props.setProperty("loadModuleInfo", "true");
     props.setProperty("collectQueryPlanThresholdMicros", "10000");
     props.setProperty("forUpdateNoKey", "true");
+    props.setProperty("defaultServer", "false");
 
     serverConfig.loadFromProperties(props);
 
+    assertFalse(serverConfig.isDefaultServer());
     assertTrue(serverConfig.isDisableL2Cache());
     assertTrue(serverConfig.isNotifyL2CacheInForeground());
     assertTrue(serverConfig.isDbOffline());
@@ -134,6 +136,7 @@ public class ServerConfigTest {
 
     ServerConfig serverConfig = new ServerConfig();
     assertTrue(serverConfig.isIdGeneratorAutomatic());
+    assertTrue(serverConfig.isDefaultServer());
 
     serverConfig.setIdGeneratorAutomatic(false);
     assertFalse(serverConfig.isIdGeneratorAutomatic());

From 4731ee034e3f5ee6c56f1e0bebb81f51060adbcf Mon Sep 17 00:00:00 2001
From: sebastian-mrozek 
Date: Mon, 15 Mar 2021 12:51:36 +1300
Subject: [PATCH 141/447] Handle searching for matching elements in an array

Add unit tests.
Refactor internals to allow reusing assertion method for finding matches in an array.
---
 .../java/io/ebean/test/CompareResult.java     |  38 +++++
 .../io/ebean/test/JsonAssertContains.java     | 150 +++++++++++++-----
 .../io/ebean/test/JsonAssertContainsTest.java |  57 +++++--
 .../array-multi-match-duplicate-props.json    |  18 +++
 .../resources/contains/array-multi-match.json |  20 +++
 .../contains/array-objects-shuffled.json      |  14 ++
 .../resources/contains/array-objects.json     |  11 ++
 .../resources/contains/array-shuffled.json    |   1 -
 .../src/test/resources/contains/array.json    |   1 -
 9 files changed, 256 insertions(+), 54 deletions(-)
 create mode 100644 ebean-test/src/main/java/io/ebean/test/CompareResult.java
 create mode 100644 ebean-test/src/test/resources/contains/array-multi-match-duplicate-props.json
 create mode 100644 ebean-test/src/test/resources/contains/array-multi-match.json
 create mode 100644 ebean-test/src/test/resources/contains/array-objects-shuffled.json
 create mode 100644 ebean-test/src/test/resources/contains/array-objects.json
 delete mode 100644 ebean-test/src/test/resources/contains/array-shuffled.json
 delete mode 100644 ebean-test/src/test/resources/contains/array.json

diff --git a/ebean-test/src/main/java/io/ebean/test/CompareResult.java b/ebean-test/src/main/java/io/ebean/test/CompareResult.java
new file mode 100644
index 000000000..1f2602674
--- /dev/null
+++ b/ebean-test/src/main/java/io/ebean/test/CompareResult.java
@@ -0,0 +1,38 @@
+package io.ebean.test;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+
+public final class CompareResult {
+    private final boolean applicable;
+    private final List errors;
+
+    public static final CompareResult NO_ERRORS = new CompareResult(true, Collections.emptyList());
+    public static final CompareResult NOT_APPLICABLE = new CompareResult(false, Collections.emptyList());
+
+    public static CompareResult error(String error) {
+        return new CompareResult(true, Collections.singletonList(error));
+    }
+
+    public static CompareResult errors(List errors) {
+        return new CompareResult(true, errors);
+    }
+
+    private CompareResult(boolean applicable, List errors) {
+        this.applicable = applicable;
+        this.errors = new ArrayList<>(errors);
+    }
+
+    public boolean isApplicable() {
+        return applicable;
+    }
+
+    public boolean hasErrors() {
+        return !errors.isEmpty();
+    }
+
+    public List getErrors() {
+        return errors;
+    }
+}
diff --git a/ebean-test/src/main/java/io/ebean/test/JsonAssertContains.java b/ebean-test/src/main/java/io/ebean/test/JsonAssertContains.java
index 25e1e065a..2c3082605 100644
--- a/ebean-test/src/main/java/io/ebean/test/JsonAssertContains.java
+++ b/ebean-test/src/main/java/io/ebean/test/JsonAssertContains.java
@@ -3,28 +3,26 @@ package io.ebean.test;
 import com.fasterxml.jackson.databind.JsonNode;
 import org.assertj.core.api.Assertions;
 
-import java.util.Iterator;
-import java.util.LinkedList;
-import java.util.Map;
-import java.util.Stack;
+import java.util.*;
+import java.util.stream.Collectors;
 
 /**
  * Perform traversal of JsonNodes comparing against an expected JsonNode that
  * typically contains a subset of the data (typically excludes any generated properties
  * like when modified timestamps etc).
  */
-class JsonAssertContains {
+public class JsonAssertContains {
 
   private final Stack path = new Stack<>();
-  private final LinkedList errors = new LinkedList<>();
 
   static void assertContains(JsonNode actualJsonNode, JsonNode expectedJsonNode) {
     new JsonAssertContains().contains(actualJsonNode, expectedJsonNode);
   }
 
   private void contains(JsonNode actualJsonNode, JsonNode expectedJsonNode) {
-    checkRecursive(null, actualJsonNode, expectedJsonNode);
-    if (!errors.isEmpty()) {
+    CompareResult result = checkRecursive(null, actualJsonNode, expectedJsonNode);
+    if (result.hasErrors()) {
+      List errors = result.getErrors();
       String errorsString = String.join("\n", errors);
       errorsString += "\nExpected JSON fields: " + expectedJsonNode;
       errorsString += "\nActual JSON: " + actualJsonNode;
@@ -32,55 +30,128 @@ class JsonAssertContains {
     }
   }
 
-  private void checkRecursive(String name, JsonNode actualJsonNode, JsonNode expectedJsonNode) {
+  private CompareResult checkRecursive(String name, JsonNode actualJsonNode, JsonNode expectedJsonNode) {
     if (name != null) {
       path.push(name);
     }
-    if (checkNull(actualJsonNode, expectedJsonNode)) {
-      if (checkType(actualJsonNode, expectedJsonNode)) {
-        if (checkArray(actualJsonNode, expectedJsonNode)) {
-          if (checkObject(actualJsonNode, expectedJsonNode)) {
-            checkValue(actualJsonNode, expectedJsonNode);
-          }
-        }
-      }
+
+    CompareResult result = checkNull(actualJsonNode, expectedJsonNode);
+    if (result.isApplicable()) {
+      return pop(name, result);
     }
+
+    result = checkType(actualJsonNode, expectedJsonNode);
+    if (result.isApplicable()) {
+      return pop(name, result);
+    }
+
+    result = checkArray(actualJsonNode, expectedJsonNode);
+    if (result.isApplicable()) {
+      return pop(name, result);
+    }
+
+    result = checkObject(actualJsonNode, expectedJsonNode);
+    if (result.isApplicable()) {
+      return pop(name, result);
+    }
+
+    result = checkValue(actualJsonNode, expectedJsonNode);
+    if (result.isApplicable()) {
+      return pop(name, result);
+    }
+
+    return CompareResult.NOT_APPLICABLE;
+  }
+
+  private CompareResult pop(String name, CompareResult result) {
     if (name != null) {
       path.pop();
     }
+    return result;
   }
 
-  private boolean checkNull(JsonNode actualJsonNode, JsonNode expectedJsonNode) {
+  private CompareResult checkNull(JsonNode actualJsonNode, JsonNode expectedJsonNode) {
     if (actualJsonNode == null) {
-      errors.add(String.format("Expected field '%s' to be '%s' but was null", path(), expectedJsonNode));
-      return false;
+      return CompareResult.error(String.format("Expected field '%s' to be '%s' but was null", path(), expectedJsonNode));
     }
-    return true;
+    return CompareResult.NOT_APPLICABLE;
   }
 
-  private boolean checkType(JsonNode actualJsonNode, JsonNode expectedJsonNode) {
+  private CompareResult checkType(JsonNode actualJsonNode, JsonNode expectedJsonNode) {
     if (!expectedJsonNode.getNodeType().equals(actualJsonNode.getNodeType())) {
-      errors.add(String.format("Expected field '%s' to be of type '%s' but was '%s'", path(), expectedJsonNode.getNodeType(), actualJsonNode.getNodeType()));
-      return false;
+      return CompareResult.error(String.format("Expected field '%s' to be of type '%s' but was '%s'", path(), expectedJsonNode.getNodeType(), actualJsonNode.getNodeType()));
     }
-    return true;
+    return CompareResult.NOT_APPLICABLE;
   }
 
-  private boolean checkArray(JsonNode actualJsonNode, JsonNode expectedJsonNode) {
+  private CompareResult checkArray(JsonNode actualJsonNode, JsonNode expectedJsonNode) {
     if (!expectedJsonNode.isArray()) {
-      return true;
+      return CompareResult.NOT_APPLICABLE;
     }
-    for (int i = 0; i < expectedJsonNode.size(); i++) {
-      checkRecursive("[" + i + "]", actualJsonNode.get(i), expectedJsonNode.get(i));
+
+    Map> matchingIndexes = findMatchingIndexes(actualJsonNode, expectedJsonNode);
+    List unmatchedIndexes = listUnmatchedIndexes(expectedJsonNode.size(), matchingIndexes);
+    List>> remainingEntries = removeMultipleMatches(matchingIndexes);
+    if (!remainingEntries.isEmpty()) {
+      unmatchedIndexes.addAll(remainingEntries.stream().map(Map.Entry::getKey).collect(Collectors.toList()));
     }
-    // do not continue (object or scalar type check)
-    return false;
+
+    List errors = unmatchedIndexes.stream()
+      .map(index -> String.format("Unable to match expected element '%s[%d]' in the actual array", path(), index))
+      .collect(Collectors.toList());
+
+    return CompareResult.errors(errors);
   }
 
-  private boolean checkObject(JsonNode actualJsonNode, JsonNode expectedJsonNode) {
-    if (!expectedJsonNode.isObject()) {
-      return true;
+  private List listUnmatchedIndexes(int size, Map> matchingIndexes) {
+    List unmatched = new LinkedList<>();
+    for (int i = 0; i < size; i++) {
+      if (!matchingIndexes.containsKey(i)) {
+        unmatched.add(i);
+      }
     }
+    return unmatched;
+  }
+
+  private List>> removeMultipleMatches(Map> matchingIndexes) {
+    List>> entries = new ArrayList<>(matchingIndexes.entrySet());
+    entries.sort(Comparator.comparingInt(entry -> entry.getValue().size()));
+    ListIterator>> iterator = entries.listIterator();
+
+    while (iterator.hasNext()) {
+      Map.Entry> next = iterator.next();
+      if (!next.getValue().isEmpty()) {
+        iterator.remove();
+        Integer aMatchingIndex = next.getValue().stream().findFirst().get();
+        removeAllMatchingIndexesOf(aMatchingIndex, entries);
+      }
+    }
+
+    return entries;
+  }
+
+  private void removeAllMatchingIndexesOf(Integer aMatchingIndex, List>> matchingIndexes) {
+    matchingIndexes.forEach(entry -> entry.getValue().remove(aMatchingIndex));
+  }
+
+  private Map> findMatchingIndexes(JsonNode actualJsonNode, JsonNode expectedJsonNode) {
+    Map> matchingElementsIndexes = new HashMap<>();
+    for (int e = 0; e < expectedJsonNode.size(); e++) {
+      for (int a = 0; a < actualJsonNode.size(); a++) {
+        CompareResult result = checkRecursive("[" + e + "]", actualJsonNode.get(a), expectedJsonNode.get(e));
+        if (result.isApplicable() && !result.hasErrors()) {
+          matchingElementsIndexes.computeIfAbsent(e, key -> new HashSet<>()).add(a);
+        }
+      }
+    }
+    return matchingElementsIndexes;
+  }
+
+  private CompareResult checkObject(JsonNode actualJsonNode, JsonNode expectedJsonNode) {
+    if (!expectedJsonNode.isObject()) {
+      return CompareResult.NOT_APPLICABLE;
+    }
+    List errors = new LinkedList<>();
     Iterator> expectedFields = expectedJsonNode.fields();
     while (expectedFields.hasNext()) {
       Map.Entry expectedField = expectedFields.next();
@@ -89,17 +160,18 @@ class JsonAssertContains {
       if (actualNode == null) {
         errors.add(String.format("Expected field '%s' to be present", path(expectedKey)));
       } else {
-        checkRecursive(expectedKey, actualNode, expectedField.getValue());
+        CompareResult result = checkRecursive(expectedKey, actualNode, expectedField.getValue());
+        errors.addAll(result.getErrors());
       }
     }
-    // do not continue (scalar type check)
-    return false;
+    return CompareResult.errors(errors);
   }
 
-  private void checkValue(JsonNode actualJsonNode, JsonNode expectedJsonNode) {
+  private CompareResult checkValue(JsonNode actualJsonNode, JsonNode expectedJsonNode) {
     if (!expectedJsonNode.equals(actualJsonNode)) {
-      errors.add(String.format("Expected field '%s' to be equal to '%s' but was '%s'", path(), expectedJsonNode, actualJsonNode));
+      return CompareResult.error(String.format("Expected field '%s' to be equal to '%s' but was '%s'", path(), expectedJsonNode, actualJsonNode));
     }
+    return CompareResult.NO_ERRORS;
   }
 
   String path(String expectedKey) {
diff --git a/ebean-test/src/test/java/io/ebean/test/JsonAssertContainsTest.java b/ebean-test/src/test/java/io/ebean/test/JsonAssertContainsTest.java
index 1d5864a6b..579bc2eca 100644
--- a/ebean-test/src/test/java/io/ebean/test/JsonAssertContainsTest.java
+++ b/ebean-test/src/test/java/io/ebean/test/JsonAssertContainsTest.java
@@ -1,10 +1,12 @@
 package io.ebean.test;
 
 import com.fasterxml.jackson.databind.JsonNode;
+import org.assertj.core.api.Assertions;
 import org.junit.Test;
 
 import java.util.stream.Stream;
 
+import static io.ebean.test.Json.readNode;
 import static io.ebean.test.Json.readNodeFromResource;
 import static org.assertj.core.api.Assertions.assertThat;
 
@@ -31,18 +33,20 @@ public class JsonAssertContainsTest {
     JsonNode expected = readNodeFromResource("/contains/original-subset-modified.json");
     try {
       JsonAssertContains.assertContains(original, expected);
+      Assertions.fail("Expected an exception to be thrown");
     } catch (AssertionError e) {
       String exceptionMessage = e.getMessage();
+      System.out.println(exceptionMessage);
       Stream.of("Expected field 'someString1' to be equal to '\"aaaa\"' but was '\"string1\"",
         "Expected field 'someValue1' to be equal to '99' but was '1'",
-        "Expected field 'someArray1[0]' to be of type 'STRING' but was 'NUMBER",
-        "Expected field 'someArray2[0].value1' to be of type 'ARRAY' but was 'NUMBER'",
-        "Expected field 'someArray2[0].value2' to be of type 'OBJECT' but was 'STRING'",
-        "Expected field 'someArray2[0].array1[0]' to be '\"1\"' but was null",
-        "Expected field 'someArray2[0].object1.val5' to be present",
-        "Expected field 'someArray2[0].object1.val6' to be present",
-        "Expected field 'someArray2[0].object2' to be of type 'NULL' but was 'OBJECT'",
-        "Expected field 'someArray2[0].objectNull' to be of type 'OBJECT' but was 'NULL'")
+        "Unable to match expected element 'someArray1[0]' in the actual array",
+        "Expected field 'someObject1.value1' to be of type 'ARRAY' but was 'NUMBER'",
+        "Expected field 'someObject1.value2' to be of type 'OBJECT' but was 'STRING'",
+        "Unable to match expected element 'someObject1.array1[0]' in the actual array",
+        "Expected field 'someObject1.object1.val5' to be present",
+        "Expected field 'someObject1.object1.val6' to be present",
+        "Expected field 'someObject1.object2' to be of type 'NULL' but was 'OBJECT'",
+        "Expected field 'someObject1.objectNull' to be of type 'OBJECT' but was 'NULL'")
         .forEach(assertionError -> assertThat(exceptionMessage).contains(assertionError));
     }
   }
@@ -54,6 +58,7 @@ public class JsonAssertContainsTest {
     JsonNode expected = readNodeFromResource("/contains/check-null-expected.json");
     try {
       JsonAssertContains.assertContains(original, expected);
+      Assertions.fail("Expected an exception to be thrown");
     } catch (AssertionError e) {
       String exceptionMessage = e.getMessage();
       Stream.of("Expected field 'someNull' to be of type 'NULL' but was 'STRING'",
@@ -68,6 +73,7 @@ public class JsonAssertContainsTest {
     JsonNode expected = readNodeFromResource("/contains/check-type-expected.json");
     try {
       JsonAssertContains.assertContains(original, expected);
+      Assertions.fail("Expected an exception to be thrown");
     } catch (AssertionError e) {
       String exceptionMessage = e.getMessage();
       Stream.of("Expected field 'some' to be of type 'NUMBER' but was 'STRING'")
@@ -84,12 +90,37 @@ public class JsonAssertContainsTest {
     assertThat(contains.path("b")).isEqualTo("b");
   }
 
-  @Test
-  public void assertContainsArrayShuffled() {
-    JsonNode array = readNodeFromResource("/contains/array.json");
-    JsonNode arrayShuffled = readNodeFromResource("/contains/array-shuffled.json");
 
-    JsonAssertContains.assertContains(array, arrayShuffled);
+  @Test
+  public void assertContainsNumbersArrayShuffled() {
+    JsonNode array = readNode("[2, 54, 13, 10]");
+    JsonNode arrayShuffled = readNode("[2, 13, 10, 54]");
+
     JsonAssertContains.assertContains(arrayShuffled, array);
   }
+
+  @Test
+  public void assertContainsObjectsArrayShuffled() {
+    JsonNode array = readNodeFromResource("/contains/array-objects.json");
+    JsonNode arrayShuffled = readNodeFromResource("/contains/array-objects-shuffled.json");
+
+    JsonAssertContains.assertContains(arrayShuffled, array);
+  }
+
+  @Test
+  public void assertArrayElementsNotFound() {
+    JsonNode original = readNodeFromResource("/contains/array-multi-match.json");
+    JsonNode actual = readNodeFromResource("/contains/array-multi-match-duplicate-props.json");
+
+    try {
+      JsonAssertContains.assertContains(actual, original);
+      Assertions.fail("Expected an exception to be thrown");
+    } catch (AssertionError e) {
+      System.out.println(e);
+      String exceptionMessage = e.getMessage();
+      Stream.of("Unable to match expected element '[5]' in the actual array",
+        "Unable to match expected element '[4]' in the actual array")
+        .forEach(assertionError -> assertThat(exceptionMessage).contains(assertionError));
+    }
+  }
 }
diff --git a/ebean-test/src/test/resources/contains/array-multi-match-duplicate-props.json b/ebean-test/src/test/resources/contains/array-multi-match-duplicate-props.json
new file mode 100644
index 000000000..4dbcb1c10
--- /dev/null
+++ b/ebean-test/src/test/resources/contains/array-multi-match-duplicate-props.json
@@ -0,0 +1,18 @@
+[
+  {
+    "b": 2,
+    "c": 3
+  },
+  {
+    "d": 4,
+    "e": 5
+  },
+  {
+    "a": 1,
+    "b": 2,
+    "c": 3
+  },
+  {
+    "b": 2
+  }
+]
diff --git a/ebean-test/src/test/resources/contains/array-multi-match.json b/ebean-test/src/test/resources/contains/array-multi-match.json
new file mode 100644
index 000000000..0d106dd88
--- /dev/null
+++ b/ebean-test/src/test/resources/contains/array-multi-match.json
@@ -0,0 +1,20 @@
+[
+  {
+    "a": 1
+  },
+  {
+    "b": 2
+  },
+  {
+    "c": 3
+  },
+  {
+    "d": 4
+  },
+  {
+    "e": 5
+  },
+  {
+    "f": 6
+  }
+]
diff --git a/ebean-test/src/test/resources/contains/array-objects-shuffled.json b/ebean-test/src/test/resources/contains/array-objects-shuffled.json
new file mode 100644
index 000000000..8c28a8e7a
--- /dev/null
+++ b/ebean-test/src/test/resources/contains/array-objects-shuffled.json
@@ -0,0 +1,14 @@
+[
+  {
+    "id": "tyu",
+    "c": 3
+  },
+  {
+    "id": "zxy",
+    "a": 1
+  },
+  {
+    "id": "123",
+    "b": 2
+  }
+]
\ No newline at end of file
diff --git a/ebean-test/src/test/resources/contains/array-objects.json b/ebean-test/src/test/resources/contains/array-objects.json
new file mode 100644
index 000000000..bfc5e4159
--- /dev/null
+++ b/ebean-test/src/test/resources/contains/array-objects.json
@@ -0,0 +1,11 @@
+[
+  {
+    "a": 1
+  },
+  {
+    "b": 2
+  },
+  {
+    "c": 3
+  }
+]
diff --git a/ebean-test/src/test/resources/contains/array-shuffled.json b/ebean-test/src/test/resources/contains/array-shuffled.json
deleted file mode 100644
index 07546c233..000000000
--- a/ebean-test/src/test/resources/contains/array-shuffled.json
+++ /dev/null
@@ -1 +0,0 @@
-[2, 54, 13, 10]
\ No newline at end of file
diff --git a/ebean-test/src/test/resources/contains/array.json b/ebean-test/src/test/resources/contains/array.json
deleted file mode 100644
index 547a670c1..000000000
--- a/ebean-test/src/test/resources/contains/array.json
+++ /dev/null
@@ -1 +0,0 @@
-[10, 2, 13, 54]
\ No newline at end of file

From 899fdca9958913f07cb5bad2ca778e3a11d21abd Mon Sep 17 00:00:00 2001
From: sebastian-mrozek 
Date: Mon, 15 Mar 2021 13:04:05 +1300
Subject: [PATCH 142/447] Improve assertions in case json compare does not fail
 as expected

Remove sys out print.
---
 .../java/io/ebean/test/JsonAssertContainsTest.java | 14 +++++++++-----
 1 file changed, 9 insertions(+), 5 deletions(-)

diff --git a/ebean-test/src/test/java/io/ebean/test/JsonAssertContainsTest.java b/ebean-test/src/test/java/io/ebean/test/JsonAssertContainsTest.java
index 579bc2eca..59d69c00b 100644
--- a/ebean-test/src/test/java/io/ebean/test/JsonAssertContainsTest.java
+++ b/ebean-test/src/test/java/io/ebean/test/JsonAssertContainsTest.java
@@ -33,7 +33,6 @@ public class JsonAssertContainsTest {
     JsonNode expected = readNodeFromResource("/contains/original-subset-modified.json");
     try {
       JsonAssertContains.assertContains(original, expected);
-      Assertions.fail("Expected an exception to be thrown");
     } catch (AssertionError e) {
       String exceptionMessage = e.getMessage();
       System.out.println(exceptionMessage);
@@ -48,7 +47,9 @@ public class JsonAssertContainsTest {
         "Expected field 'someObject1.object2' to be of type 'NULL' but was 'OBJECT'",
         "Expected field 'someObject1.objectNull' to be of type 'OBJECT' but was 'NULL'")
         .forEach(assertionError -> assertThat(exceptionMessage).contains(assertionError));
+      return;
     }
+    Assertions.fail("Expected an exception to be thrown");
   }
 
 
@@ -58,13 +59,14 @@ public class JsonAssertContainsTest {
     JsonNode expected = readNodeFromResource("/contains/check-null-expected.json");
     try {
       JsonAssertContains.assertContains(original, expected);
-      Assertions.fail("Expected an exception to be thrown");
     } catch (AssertionError e) {
       String exceptionMessage = e.getMessage();
       Stream.of("Expected field 'someNull' to be of type 'NULL' but was 'STRING'",
         "Expected field 'extra' to be present")
         .forEach(assertionError -> assertThat(exceptionMessage).contains(assertionError));
+      return;
     }
+    Assertions.fail("Expected an exception to be thrown");
   }
 
   @Test
@@ -73,12 +75,13 @@ public class JsonAssertContainsTest {
     JsonNode expected = readNodeFromResource("/contains/check-type-expected.json");
     try {
       JsonAssertContains.assertContains(original, expected);
-      Assertions.fail("Expected an exception to be thrown");
     } catch (AssertionError e) {
       String exceptionMessage = e.getMessage();
       Stream.of("Expected field 'some' to be of type 'NUMBER' but was 'STRING'")
         .forEach(assertionError -> assertThat(exceptionMessage).contains(assertionError));
+      return;
     }
+    Assertions.fail("Expected an exception to be thrown");
   }
 
   @Test
@@ -114,13 +117,14 @@ public class JsonAssertContainsTest {
 
     try {
       JsonAssertContains.assertContains(actual, original);
-      Assertions.fail("Expected an exception to be thrown");
     } catch (AssertionError e) {
-      System.out.println(e);
       String exceptionMessage = e.getMessage();
       Stream.of("Unable to match expected element '[5]' in the actual array",
         "Unable to match expected element '[4]' in the actual array")
         .forEach(assertionError -> assertThat(exceptionMessage).contains(assertionError));
+      return;
     }
+
+    Assertions.fail("Expected an exception to be thrown");
   }
 }

From 733886c70bdce2f9e93b52502614dfb60f9e1aa6 Mon Sep 17 00:00:00 2001
From: Robin Bygrave 
Date: Mon, 15 Mar 2021 22:03:14 +1300
Subject: [PATCH 143/447] #2195 - @Aggregation on OneToMany property not
 mapping to column properly

---
 .../server/deploy/BeanProperty.java            |  2 +-
 .../deploy/meta/DeployBeanDescriptor.java      | 18 ++++++++++++++++--
 .../server/deploy/meta/DeployBeanProperty.java |  3 +--
 .../org/tests/model/tevent/TEventMany.java     | 14 +++++++-------
 .../java/org/tests/model/tevent/TEventOne.java |  4 ++--
 .../aggregation/TestAggregationCount.java      | 14 +++++++-------
 6 files changed, 34 insertions(+), 21 deletions(-)

diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/deploy/BeanProperty.java b/ebean-core/src/main/java/io/ebeaninternal/server/deploy/BeanProperty.java
index 832cea70c..d3b1f429b 100644
--- a/ebean-core/src/main/java/io/ebeaninternal/server/deploy/BeanProperty.java
+++ b/ebean-core/src/main/java/io/ebeaninternal/server/deploy/BeanProperty.java
@@ -324,9 +324,9 @@ public class BeanProperty implements ElPropertyValue, Property, STreeProperty {
     this.generatedProperty = deploy.getGeneratedProperty();
     this.getter = deploy.getGetter();
     this.setter = deploy.getSetter();
+    this.aggregation = deploy.parseAggregation();
     this.dbColumn = tableAliasIntern(descriptor, deploy.getDbColumn(), false, null);
     this.dbComment = deploy.getDbComment();
-    this.aggregation = deploy.parseAggregation();
     this.sqlFormulaJoin = InternString.intern(deploy.getSqlFormulaJoin());
     this.sqlFormulaSelect = InternString.intern(deploy.getSqlFormulaSelect());
     this.formula = sqlFormulaSelect != null;
diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/deploy/meta/DeployBeanDescriptor.java b/ebean-core/src/main/java/io/ebeaninternal/server/deploy/meta/DeployBeanDescriptor.java
index 47b5efdc0..79ca0beb1 100644
--- a/ebean-core/src/main/java/io/ebeaninternal/server/deploy/meta/DeployBeanDescriptor.java
+++ b/ebean-core/src/main/java/io/ebeaninternal/server/deploy/meta/DeployBeanDescriptor.java
@@ -16,6 +16,7 @@ import io.ebean.event.BeanPostLoad;
 import io.ebean.event.BeanQueryAdapter;
 import io.ebean.event.changelog.ChangeLogFilter;
 import io.ebean.text.PathProperties;
+import io.ebean.util.SplitName;
 import io.ebeaninternal.api.ConcurrencyMode;
 import io.ebeaninternal.server.core.CacheOptions;
 import io.ebeaninternal.server.deploy.BeanDescriptor.EntityType;
@@ -1149,8 +1150,21 @@ public class DeployBeanDescriptor {
       return null;
     }
     // use 'current' table alias - refer BeanProperty appendSelect() for aggregation
-    DeployBeanProperty property = propMap.get(expression);
-    return (property == null) ? null : "${ta}." + property.getDbColumn();
+    String[] split = SplitName.split(expression);
+    if (split[0] == null) {
+      DeployBeanProperty property = propMap.get(expression);
+      return (property == null) ? null : "${ta}." + property.getDbColumn();
+    } else {
+      DeployBeanProperty property = propMap.get(split[0]);
+      if (property instanceof DeployBeanPropertyAssoc) {
+        DeployBeanPropertyAssoc prop = (DeployBeanPropertyAssoc) property;
+        DeployBeanProperty beanProperty = prop.getTargetDeploy().getBeanProperty(split[1]);
+        if (beanProperty != null) {
+          return "u1." + beanProperty.getDbColumn();
+        }
+      }
+      return null;
+    }
   }
 
   /**
diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/deploy/meta/DeployBeanProperty.java b/ebean-core/src/main/java/io/ebeaninternal/server/deploy/meta/DeployBeanProperty.java
index 5b9e8d687..e20c898ce 100644
--- a/ebean-core/src/main/java/io/ebeaninternal/server/deploy/meta/DeployBeanProperty.java
+++ b/ebean-core/src/main/java/io/ebeaninternal/server/deploy/meta/DeployBeanProperty.java
@@ -682,7 +682,6 @@ public class DeployBeanProperty {
    */
   public void setAggregationPrefix(String prefix) {
     this.aggregationPrefix = prefix;
-    this.aggregation = (prefix == null) ? aggregation : aggregation.replace(aggregationPrefix, "u1");
   }
 
   public String getElPrefix() {
@@ -715,7 +714,7 @@ public class DeployBeanProperty {
       return sqlFormulaSelect;
     }
     if (aggregation != null) {
-      return aggregation;
+      return aggregationParsed == null ? dbColumn : aggregationParsed;
     }
     return dbColumn;
   }
diff --git a/ebean-core/src/test/java/org/tests/model/tevent/TEventMany.java b/ebean-core/src/test/java/org/tests/model/tevent/TEventMany.java
index e7ef1020e..a7eabce36 100644
--- a/ebean-core/src/test/java/org/tests/model/tevent/TEventMany.java
+++ b/ebean-core/src/test/java/org/tests/model/tevent/TEventMany.java
@@ -16,16 +16,16 @@ public class TEventMany {
   @ManyToOne
   TEventOne event;
 
-  int units;
+  int myUnits;
 
   double amount;
 
   @Version
   Long version;
 
-  public TEventMany(String description, int units, double amount) {
+  public TEventMany(String description, int myUnits, double amount) {
     this.description = description;
-    this.units = units;
+    this.myUnits = myUnits;
     this.amount = amount;
   }
 
@@ -53,12 +53,12 @@ public class TEventMany {
     this.event = event;
   }
 
-  public int getUnits() {
-    return units;
+  public int getMyUnits() {
+    return myUnits;
   }
 
-  public void setUnits(int units) {
-    this.units = units;
+  public void setMyUnits(int myUnits) {
+    this.myUnits = myUnits;
   }
 
   public double getAmount() {
diff --git a/ebean-core/src/test/java/org/tests/model/tevent/TEventOne.java b/ebean-core/src/test/java/org/tests/model/tevent/TEventOne.java
index 88bc2e2fd..f69ad23fe 100644
--- a/ebean-core/src/test/java/org/tests/model/tevent/TEventOne.java
+++ b/ebean-core/src/test/java/org/tests/model/tevent/TEventOne.java
@@ -37,10 +37,10 @@ public class TEventOne {
   @Aggregation("count(logs.id)")
   Long count;
 
-  @Aggregation("sum(logs.units)")
+  @Aggregation("sum(logs.myUnits)")
   Double totalUnits;
 
-  @Aggregation("sum(logs.units * logs.amount)")
+  @Aggregation("sum(logs.myUnits * logs.amount)")
   Double totalAmount;
 
   @OneToMany(mappedBy = "event", cascade = CascadeType.ALL)
diff --git a/ebean-core/src/test/java/org/tests/query/aggregation/TestAggregationCount.java b/ebean-core/src/test/java/org/tests/query/aggregation/TestAggregationCount.java
index 15f7c4ddf..a91aef120 100644
--- a/ebean-core/src/test/java/org/tests/query/aggregation/TestAggregationCount.java
+++ b/ebean-core/src/test/java/org/tests/query/aggregation/TestAggregationCount.java
@@ -110,7 +110,7 @@ public class TestAggregationCount extends BaseTestCase {
     assertThat(list).isNotEmpty();
 
     String sql = sqlOf(query2, 5);
-    assertThat(sql).contains("select t0.id, t0.name, count(u1.id), sum(u1.units), sum(u1.units * u1.amount) from tevent_one t0");
+    assertThat(sql).contains("select t0.id, t0.name, count(u1.id), sum(u1.my_units), sum(u1.my_units * u1.amount) from tevent_one t0");
     assertThat(sql).contains("from tevent_one t0 join tevent_many u1 on u1.event_id = t0.id ");
     assertThat(sql).contains("where u1.description like ");
     assertThat(sql).contains(" group by t0.id, t0.name having count(u1.id) >= ? order by t0.name");
@@ -132,13 +132,13 @@ public class TestAggregationCount extends BaseTestCase {
 
     String sql = sqlOf(query, 5);
     if (isH2()) {
-      assertThat(sql).contains("select distinct t0.id, t0.name, count(u1.id), sum(u1.units), sum(u1.units * u1.amount), sum(u1.units), t0.name from tevent_one t0 ");
+      assertThat(sql).contains("select distinct t0.id, t0.name, count(u1.id), sum(u1.my_units), sum(u1.my_units * u1.amount), sum(u1.my_units), t0.name from tevent_one t0 ");
     } else if (isPostgres()) {
-      assertThat(sql).contains("t0.name, count(u1.id), sum(u1.units), sum(u1.units * u1.amount), sum(u1.units), t0.name from tevent_one t0 ");
+      assertThat(sql).contains("t0.name, count(u1.id), sum(u1.my_units), sum(u1.my_units * u1.amount), sum(u1.my_units), t0.name from tevent_one t0 ");
     }
     assertThat(sql).contains("from tevent_one t0 join tevent_many u1 on u1.event_id = t0.id ");
     assertThat(sql).contains(" group by t0.id, t0.name ");
-    assertThat(sql).contains(" order by sum(u1.units), t0.name");
+    assertThat(sql).contains(" order by sum(u1.my_units), t0.name");
   }
 
   @Test
@@ -149,7 +149,7 @@ public class TestAggregationCount extends BaseTestCase {
 
     query0.findList();
     String sql = sqlOf(query0, 5);
-    assertThat(sql).contains("select t0.id, t0.name, count(u1.id), sum(u1.units) from tevent_one t0");
+    assertThat(sql).contains("select t0.id, t0.name, count(u1.id), sum(u1.my_units) from tevent_one t0");
     assertThat(sql).contains("group by t0.id, t0.name");
   }
 
@@ -161,7 +161,7 @@ public class TestAggregationCount extends BaseTestCase {
 
     query0.findList();
     String sql = sqlOf(query0, 5);
-    assertThat(sql).contains("select t0.id, t0.name, count(u1.id), sum(u1.units), sum(u1.units * u1.amount) from tevent_one t0");
+    assertThat(sql).contains("select t0.id, t0.name, count(u1.id), sum(u1.my_units), sum(u1.my_units * u1.amount) from tevent_one t0");
     assertThat(sql).contains("group by t0.id, t0.name");
   }
 
@@ -174,7 +174,7 @@ public class TestAggregationCount extends BaseTestCase {
 
     query0.findList();
     String sql = sqlOf(query0, 5);
-    assertThat(sql).contains("select t0.id, t0.name, count(u1.id), sum(u1.units), sum(u1.units * u1.amount) from tevent_one t0");
+    assertThat(sql).contains("select t0.id, t0.name, count(u1.id), sum(u1.my_units), sum(u1.my_units * u1.amount) from tevent_one t0");
     assertThat(sql).contains("group by t0.id, t0.name");
   }
 

From c2a87a0c884f6be6e87e11aff979ddae48ea9272 Mon Sep 17 00:00:00 2001
From: Robin Bygrave 
Date: Mon, 15 Mar 2021 22:43:25 +1300
Subject: [PATCH 144/447] #2196 - SQLException:Column "T0.ID" must be in the
 GROUP BY list - when findCount with having clause

---
 .../server/query/SqlTreeBuilder.java            |  2 +-
 .../query/aggregation/TestAggregationCount.java | 17 +++++++++++++++++
 2 files changed, 18 insertions(+), 1 deletion(-)

diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/query/SqlTreeBuilder.java b/ebean-core/src/main/java/io/ebeaninternal/server/query/SqlTreeBuilder.java
index 065884b54..239e8a58e 100644
--- a/ebean-core/src/main/java/io/ebeaninternal/server/query/SqlTreeBuilder.java
+++ b/ebean-core/src/main/java/io/ebeaninternal/server/query/SqlTreeBuilder.java
@@ -151,7 +151,7 @@ public final class SqlTreeBuilder {
   }
 
   private String buildGroupByClause() {
-    if (rawSql || !rootNode.isAggregation()) {
+    if (rawSql || (!rootNode.isAggregation() && query.getHavingExpressions() == null)) {
       return null;
     }
     ctx.startGroupBy();
diff --git a/ebean-core/src/test/java/org/tests/query/aggregation/TestAggregationCount.java b/ebean-core/src/test/java/org/tests/query/aggregation/TestAggregationCount.java
index a91aef120..261202696 100644
--- a/ebean-core/src/test/java/org/tests/query/aggregation/TestAggregationCount.java
+++ b/ebean-core/src/test/java/org/tests/query/aggregation/TestAggregationCount.java
@@ -3,6 +3,7 @@ package org.tests.query.aggregation;
 import io.ebean.BaseTestCase;
 import io.ebean.Ebean;
 import io.ebean.Query;
+import io.ebeantest.LoggedSql;
 import org.ebeantest.LoggedSqlCollector;
 import org.junit.BeforeClass;
 import org.junit.Test;
@@ -91,6 +92,22 @@ public class TestAggregationCount extends BaseTestCase {
     }
   }
 
+  @Test
+  public void findCount_withHaving() {
+    Query query = Ebean.find(TEventOne.class)
+      //.select("id, totalUnits")
+      .having()
+      .ge("totalUnits", 1)
+      .query();
+
+    LoggedSql.start();
+    int count = query.findCount();
+    List sql = LoggedSql.stop();
+    assertThat(sql).hasSize(1);
+    assertThat(sql.get(0)).contains("group by t0.id");
+    assertThat(count).isGreaterThan(0);
+  }
+
   @Test
   public void testFull() {
 

From f483002e39e3ce5dc8290f15126986e20ef2f180 Mon Sep 17 00:00:00 2001
From: Robin Bygrave 
Date: Tue, 16 Mar 2021 09:13:01 +1300
Subject: [PATCH 145/447] #2197 - [ebean-redis] - Bump jedis dependency to
 3.5.2 (from 3.4.0

---
 ebean-redis/pom.xml | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/ebean-redis/pom.xml b/ebean-redis/pom.xml
index 476ee7c2a..5ea354664 100644
--- a/ebean-redis/pom.xml
+++ b/ebean-redis/pom.xml
@@ -16,7 +16,7 @@
     
       redis.clients
       jedis
-      3.4.0
+      3.5.2
     
 
     

From e3001e8bdddce41fa97644298a73b9e7368250d7 Mon Sep 17 00:00:00 2001
From: Robin Bygrave 
Date: Tue, 16 Mar 2021 09:30:54 +1300
Subject: [PATCH 146/447] Fix JsonAssertContains testContainsFails with missing
 parts of JSON

Just add missing parts of test/resources/original.json and original-subset-modified.json
---
 .../contains/original-subset-modified.json       | 16 ++++++++++++++++
 .../src/test/resources/contains/original.json    | 13 +++++++++++++
 2 files changed, 29 insertions(+)

diff --git a/ebean-test/src/test/resources/contains/original-subset-modified.json b/ebean-test/src/test/resources/contains/original-subset-modified.json
index 107d557d2..3c3e70f3e 100644
--- a/ebean-test/src/test/resources/contains/original-subset-modified.json
+++ b/ebean-test/src/test/resources/contains/original-subset-modified.json
@@ -3,6 +3,22 @@
   "someString2": "string2",
   "someValue1": 99,
   "someValue2": 2,
+  "someObject1": {
+    "value1": [],
+    "value2": {
+
+    },
+    "array1": [
+      101
+    ],
+    "object1": {
+      "val5": "val5",
+      "val6": "val6"
+    },
+    "object2": null,
+    "objectNull": {
+    }
+  },
   "someArray1": [
     "a"
   ],
diff --git a/ebean-test/src/test/resources/contains/original.json b/ebean-test/src/test/resources/contains/original.json
index 063affac4..8f6fe3624 100644
--- a/ebean-test/src/test/resources/contains/original.json
+++ b/ebean-test/src/test/resources/contains/original.json
@@ -3,6 +3,19 @@
   "someString2": "string2",
   "someValue1": 1,
   "someValue2": 2,
+  "someObject1": {
+    "value1": 42,
+    "value2": "string3",
+    "array1": [
+      99
+    ],
+    "object1": {
+    },
+    "object2": {
+
+    },
+    "objectNull": null
+  },
   "someArray1": [
     1,
     2,

From c9968a96629a1ded327e9a517cab3a0074e9c16e Mon Sep 17 00:00:00 2001
From: Robin Bygrave 
Date: Tue, 16 Mar 2021 22:03:12 +1300
Subject: [PATCH 147/447] Change JsonAssertContains array matching to match on
 size

---
 .../java/io/ebean/test/CompareResult.java     |  49 +++----
 .../io/ebean/test/JsonAssertContains.java     | 121 +++++++++---------
 .../io/ebean/test/JsonAssertContainsTest.java |  72 ++++++++++-
 .../resources/contains/nested-array-both.json |   8 ++
 .../contains/nested-array-extraExpected.json  |   9 ++
 .../contains/nested-array-missExpected.json   |   7 +
 .../contains/nested-array-ordering.json       |   8 ++
 .../test/resources/contains/nested-array.json |   8 ++
 8 files changed, 195 insertions(+), 87 deletions(-)
 create mode 100644 ebean-test/src/test/resources/contains/nested-array-both.json
 create mode 100644 ebean-test/src/test/resources/contains/nested-array-extraExpected.json
 create mode 100644 ebean-test/src/test/resources/contains/nested-array-missExpected.json
 create mode 100644 ebean-test/src/test/resources/contains/nested-array-ordering.json
 create mode 100644 ebean-test/src/test/resources/contains/nested-array.json

diff --git a/ebean-test/src/main/java/io/ebean/test/CompareResult.java b/ebean-test/src/main/java/io/ebean/test/CompareResult.java
index 1f2602674..b76f872de 100644
--- a/ebean-test/src/main/java/io/ebean/test/CompareResult.java
+++ b/ebean-test/src/main/java/io/ebean/test/CompareResult.java
@@ -4,35 +4,36 @@ import java.util.ArrayList;
 import java.util.Collections;
 import java.util.List;
 
-public final class CompareResult {
-    private final boolean applicable;
-    private final List errors;
+final class CompareResult {
 
-    public static final CompareResult NO_ERRORS = new CompareResult(true, Collections.emptyList());
-    public static final CompareResult NOT_APPLICABLE = new CompareResult(false, Collections.emptyList());
+  private final boolean applicable;
+  private final List errors;
 
-    public static CompareResult error(String error) {
-        return new CompareResult(true, Collections.singletonList(error));
-    }
+  static final CompareResult NO_ERRORS = new CompareResult(true, Collections.emptyList());
+  static final CompareResult NOT_APPLICABLE = new CompareResult(false, Collections.emptyList());
 
-    public static CompareResult errors(List errors) {
-        return new CompareResult(true, errors);
-    }
+  static CompareResult error(String error) {
+    return new CompareResult(true, Collections.singletonList(error));
+  }
 
-    private CompareResult(boolean applicable, List errors) {
-        this.applicable = applicable;
-        this.errors = new ArrayList<>(errors);
-    }
+  static CompareResult errors(List errors) {
+    return new CompareResult(true, errors);
+  }
 
-    public boolean isApplicable() {
-        return applicable;
-    }
+  private CompareResult(boolean applicable, List errors) {
+    this.applicable = applicable;
+    this.errors = new ArrayList<>(errors);
+  }
 
-    public boolean hasErrors() {
-        return !errors.isEmpty();
-    }
+  boolean isApplicable() {
+    return applicable;
+  }
 
-    public List getErrors() {
-        return errors;
-    }
+  boolean hasErrors() {
+    return !errors.isEmpty();
+  }
+
+  List getErrors() {
+    return errors;
+  }
 }
diff --git a/ebean-test/src/main/java/io/ebean/test/JsonAssertContains.java b/ebean-test/src/main/java/io/ebean/test/JsonAssertContains.java
index 2c3082605..df89c0b16 100644
--- a/ebean-test/src/main/java/io/ebean/test/JsonAssertContains.java
+++ b/ebean-test/src/main/java/io/ebean/test/JsonAssertContains.java
@@ -4,14 +4,13 @@ import com.fasterxml.jackson.databind.JsonNode;
 import org.assertj.core.api.Assertions;
 
 import java.util.*;
-import java.util.stream.Collectors;
 
 /**
  * Perform traversal of JsonNodes comparing against an expected JsonNode that
  * typically contains a subset of the data (typically excludes any generated properties
  * like when modified timestamps etc).
  */
-public class JsonAssertContains {
+class JsonAssertContains {
 
   private final Stack path = new Stack<>();
 
@@ -88,63 +87,7 @@ public class JsonAssertContains {
     if (!expectedJsonNode.isArray()) {
       return CompareResult.NOT_APPLICABLE;
     }
-
-    Map> matchingIndexes = findMatchingIndexes(actualJsonNode, expectedJsonNode);
-    List unmatchedIndexes = listUnmatchedIndexes(expectedJsonNode.size(), matchingIndexes);
-    List>> remainingEntries = removeMultipleMatches(matchingIndexes);
-    if (!remainingEntries.isEmpty()) {
-      unmatchedIndexes.addAll(remainingEntries.stream().map(Map.Entry::getKey).collect(Collectors.toList()));
-    }
-
-    List errors = unmatchedIndexes.stream()
-      .map(index -> String.format("Unable to match expected element '%s[%d]' in the actual array", path(), index))
-      .collect(Collectors.toList());
-
-    return CompareResult.errors(errors);
-  }
-
-  private List listUnmatchedIndexes(int size, Map> matchingIndexes) {
-    List unmatched = new LinkedList<>();
-    for (int i = 0; i < size; i++) {
-      if (!matchingIndexes.containsKey(i)) {
-        unmatched.add(i);
-      }
-    }
-    return unmatched;
-  }
-
-  private List>> removeMultipleMatches(Map> matchingIndexes) {
-    List>> entries = new ArrayList<>(matchingIndexes.entrySet());
-    entries.sort(Comparator.comparingInt(entry -> entry.getValue().size()));
-    ListIterator>> iterator = entries.listIterator();
-
-    while (iterator.hasNext()) {
-      Map.Entry> next = iterator.next();
-      if (!next.getValue().isEmpty()) {
-        iterator.remove();
-        Integer aMatchingIndex = next.getValue().stream().findFirst().get();
-        removeAllMatchingIndexesOf(aMatchingIndex, entries);
-      }
-    }
-
-    return entries;
-  }
-
-  private void removeAllMatchingIndexesOf(Integer aMatchingIndex, List>> matchingIndexes) {
-    matchingIndexes.forEach(entry -> entry.getValue().remove(aMatchingIndex));
-  }
-
-  private Map> findMatchingIndexes(JsonNode actualJsonNode, JsonNode expectedJsonNode) {
-    Map> matchingElementsIndexes = new HashMap<>();
-    for (int e = 0; e < expectedJsonNode.size(); e++) {
-      for (int a = 0; a < actualJsonNode.size(); a++) {
-        CompareResult result = checkRecursive("[" + e + "]", actualJsonNode.get(a), expectedJsonNode.get(e));
-        if (result.isApplicable() && !result.hasErrors()) {
-          matchingElementsIndexes.computeIfAbsent(e, key -> new HashSet<>()).add(a);
-        }
-      }
-    }
-    return matchingElementsIndexes;
+    return new MatchArrayElements(actualJsonNode, expectedJsonNode).match();
   }
 
   private CompareResult checkObject(JsonNode actualJsonNode, JsonNode expectedJsonNode) {
@@ -187,4 +130,64 @@ public class JsonAssertContains {
     }
     return String.join(".", path).replace(".[", "[");
   }
+
+  /**
+   * Match two arrays allowing elements to be in a different order.
+   */
+  private class MatchArrayElements {
+    private final JsonNode actualJsonNode;
+    private final JsonNode expectedJsonNode;
+    private final Map expectedMap = new LinkedHashMap<>();
+    private final Map actualMap = new LinkedHashMap<>();
+
+    MatchArrayElements(JsonNode actualJsonNode, JsonNode expectedJsonNode) {
+      this.actualJsonNode = actualJsonNode;
+      this.expectedJsonNode = expectedJsonNode;
+      for (int e = 0; e < expectedJsonNode.size(); e++) {
+        expectedMap.put(e, expectedJsonNode.get(e));
+      }
+      for (int a = 0; a < actualJsonNode.size(); a++) {
+        actualMap.put(a, actualJsonNode.get(a));
+      }
+    }
+
+    CompareResult match() {
+      Iterator> iterator = expectedMap.entrySet().iterator();
+      while (iterator.hasNext()) {
+        Map.Entry expectedEntry = iterator.next();
+        int matchPos = findFirstMatch(expectedEntry.getKey(), expectedEntry.getValue());
+        if (matchPos > -1) {
+          iterator.remove();
+        }
+      }
+
+      List errors = new ArrayList<>();
+      if (actualJsonNode.size() != expectedJsonNode.size()) {
+        errors.add(String.format("Unmatched array size for '%s', expected %d but got %d elements", path(), expectedJsonNode.size(), actualJsonNode.size()));
+      }
+      // unmatched expected -> actual
+      for (Map.Entry entry : expectedMap.entrySet()) {
+        errors.add(String.format("Expected array element '%s[%d]' was not matched to an element in the actual array - element: %s", path(), entry.getKey(), entry.getValue()));
+      }
+      // unmatched actual -> expected
+      for (Map.Entry entry : actualMap.entrySet()) {
+        errors.add(String.format("Actual array element '%s[%d]' was not matched to an element in the expected array - element: %s", path(), entry.getKey(), entry.getValue()));
+      }
+      return CompareResult.errors(errors);
+    }
+
+    private int findFirstMatch(int e, JsonNode expectedNode) {
+      Iterator> iterator = actualMap.entrySet().iterator();
+      while (iterator.hasNext()) {
+        Map.Entry entry = iterator.next();
+        CompareResult result = checkRecursive("[" + e + "]", entry.getValue(), expectedNode);
+        if (result.isApplicable() && !result.hasErrors()) {
+          iterator.remove();
+          return entry.getKey();
+        }
+      }
+      return -1;
+    }
+  }
+
 }
diff --git a/ebean-test/src/test/java/io/ebean/test/JsonAssertContainsTest.java b/ebean-test/src/test/java/io/ebean/test/JsonAssertContainsTest.java
index 59d69c00b..7f78c3782 100644
--- a/ebean-test/src/test/java/io/ebean/test/JsonAssertContainsTest.java
+++ b/ebean-test/src/test/java/io/ebean/test/JsonAssertContainsTest.java
@@ -38,10 +38,10 @@ public class JsonAssertContainsTest {
       System.out.println(exceptionMessage);
       Stream.of("Expected field 'someString1' to be equal to '\"aaaa\"' but was '\"string1\"",
         "Expected field 'someValue1' to be equal to '99' but was '1'",
-        "Unable to match expected element 'someArray1[0]' in the actual array",
         "Expected field 'someObject1.value1' to be of type 'ARRAY' but was 'NUMBER'",
         "Expected field 'someObject1.value2' to be of type 'OBJECT' but was 'STRING'",
-        "Unable to match expected element 'someObject1.array1[0]' in the actual array",
+        "Expected array element 'someObject1.array1[0]' was not matched to an element in the actual array - element: 101",
+        "Actual array element 'someObject1.array1[0]' was not matched to an element in the expected array - element: 99",
         "Expected field 'someObject1.object1.val5' to be present",
         "Expected field 'someObject1.object1.val6' to be present",
         "Expected field 'someObject1.object2' to be of type 'NULL' but was 'OBJECT'",
@@ -119,8 +119,72 @@ public class JsonAssertContainsTest {
       JsonAssertContains.assertContains(actual, original);
     } catch (AssertionError e) {
       String exceptionMessage = e.getMessage();
-      Stream.of("Unable to match expected element '[5]' in the actual array",
-        "Unable to match expected element '[4]' in the actual array")
+      Stream.of("Unmatched array size for '', expected 6 but got 4 elements",
+        "Expected array element '[2]' was not matched to an element in the actual array - element: {\"c\":3}",
+        "Expected array element '[4]' was not matched to an element in the actual array - element: {\"e\":5}",
+        "Expected array element '[5]' was not matched to an element in the actual array - element: {\"f\":6}",
+        "Actual array element '[3]' was not matched to an element in the expected array - element: {\"b\":2}")
+        .forEach(assertionError -> assertThat(exceptionMessage).contains(assertionError));
+      return;
+    }
+
+    Assertions.fail("Expected an exception to be thrown");
+  }
+
+  @Test
+  public void assertNestedArray_ordering() {
+    JsonNode original = readNodeFromResource("/contains/nested-array.json");
+    JsonNode actual = readNodeFromResource("/contains/nested-array-ordering.json");
+    JsonAssertContains.assertContains(actual, original);
+  }
+
+  @Test
+  public void assertNestedArray_both() {
+    try {
+      JsonNode original = readNodeFromResource("/contains/nested-array.json");
+      JsonNode actual = readNodeFromResource("/contains/nested-array-both.json");
+      JsonAssertContains.assertContains(actual, original);
+    } catch (AssertionError e) {
+      String exceptionMessage = e.getMessage();
+      Stream.of(
+        "Expected array element 'someArray1[1]' was not matched to an element in the actual array - element: {\"name\":\"b\"}",
+        "Actual array element 'someArray1[0]' was not matched to an element in the expected array - element: {\"name\":\"z\"}")
+        .forEach(assertionError -> assertThat(exceptionMessage).contains(assertionError));
+      return;
+    }
+
+    Assertions.fail("Expected an exception to be thrown");
+  }
+
+  @Test
+  public void assertNestedArray_extraExpected() {
+    try {
+      JsonNode original = readNodeFromResource("/contains/nested-array.json");
+      JsonNode actual = readNodeFromResource("/contains/nested-array-extraExpected.json");
+      JsonAssertContains.assertContains(actual, original);
+    } catch (AssertionError e) {
+      String exceptionMessage = e.getMessage();
+      Stream.of(
+        "Unmatched array size for 'someArray1', expected 3 but got 4 elements",
+        "Actual array element 'someArray1[2]' was not matched to an element in the expected array - element: {\"name\":\"d\"}")
+        .forEach(assertionError -> assertThat(exceptionMessage).contains(assertionError));
+      return;
+    }
+
+    Assertions.fail("Expected an exception to be thrown");
+  }
+
+  @Test
+  public void assertNestedArray_missExpected() {
+    try {
+      JsonNode original = readNodeFromResource("/contains/nested-array.json");
+      JsonNode actual = readNodeFromResource("/contains/nested-array-missExpected.json");
+      JsonAssertContains.assertContains(actual, original);
+    } catch (AssertionError e) {
+      String exceptionMessage = e.getMessage();
+      Stream.of(
+        "Unmatched array size for 'someArray1', expected 3 but got 2 elements",
+        "Expected array element 'someArray1[1]' was not matched to an element in the actual array - element: {\"name\":\"b\"}")
         .forEach(assertionError -> assertThat(exceptionMessage).contains(assertionError));
       return;
     }
diff --git a/ebean-test/src/test/resources/contains/nested-array-both.json b/ebean-test/src/test/resources/contains/nested-array-both.json
new file mode 100644
index 000000000..58eca1390
--- /dev/null
+++ b/ebean-test/src/test/resources/contains/nested-array-both.json
@@ -0,0 +1,8 @@
+{
+  "someString1": "string1",
+  "someArray1": [
+    {"name":"z"},
+    {"name":"c"},
+    {"name":"a"}
+  ]
+}
diff --git a/ebean-test/src/test/resources/contains/nested-array-extraExpected.json b/ebean-test/src/test/resources/contains/nested-array-extraExpected.json
new file mode 100644
index 000000000..52d94b44d
--- /dev/null
+++ b/ebean-test/src/test/resources/contains/nested-array-extraExpected.json
@@ -0,0 +1,9 @@
+{
+  "someString1": "string1",
+  "someArray1": [
+    {"name":"c"},
+    {"name":"a"},
+    {"name":"d"},
+    {"name":"b"}
+  ]
+}
diff --git a/ebean-test/src/test/resources/contains/nested-array-missExpected.json b/ebean-test/src/test/resources/contains/nested-array-missExpected.json
new file mode 100644
index 000000000..5958b2801
--- /dev/null
+++ b/ebean-test/src/test/resources/contains/nested-array-missExpected.json
@@ -0,0 +1,7 @@
+{
+  "someString1": "string1",
+  "someArray1": [
+    {"name":"c"},
+    {"name":"a"}
+  ]
+}
diff --git a/ebean-test/src/test/resources/contains/nested-array-ordering.json b/ebean-test/src/test/resources/contains/nested-array-ordering.json
new file mode 100644
index 000000000..543d9b6f1
--- /dev/null
+++ b/ebean-test/src/test/resources/contains/nested-array-ordering.json
@@ -0,0 +1,8 @@
+{
+  "someString1": "string1",
+  "someArray1": [
+    {"name":"c"},
+    {"name":"a"},
+    {"name":"b"}
+  ]
+}
diff --git a/ebean-test/src/test/resources/contains/nested-array.json b/ebean-test/src/test/resources/contains/nested-array.json
new file mode 100644
index 000000000..13e74ace0
--- /dev/null
+++ b/ebean-test/src/test/resources/contains/nested-array.json
@@ -0,0 +1,8 @@
+{
+  "someString1": "string1",
+  "someArray1": [
+    {"name":"a"},
+    {"name":"b"},
+    {"name":"c"}
+  ]
+}

From 1837c3443d3e8a0b0fb8528d7d1168ef1c22d69b Mon Sep 17 00:00:00 2001
From: Robin Bygrave 
Date: Wed, 17 Mar 2021 21:02:59 +1300
Subject: [PATCH 148/447] #2186 - Invalid generated table and column names of
 @ManyToMany relation with allQuotedIdentifiers=true

---
 .../config/AbstractNamingConvention.java      | 47 ++++++++++++----
 .../config/MatchingNamingConvention.java      |  5 --
 .../io/ebean/config/NamingConvention.java     | 22 ++++----
 .../main/java/io/ebean/config/TableName.java  | 24 +++-----
 .../config/UnderscoreNamingConvention.java    | 12 ----
 .../deploy/parse/AnnotationAssocManys.java    | 29 ++++------
 .../config/MatchingNamingConventionTest.java  | 55 ++++++++++++++++++-
 .../java/org/tests/config/TestTableName.java  | 20 +++++++
 8 files changed, 138 insertions(+), 76 deletions(-)

diff --git a/ebean-api/src/main/java/io/ebean/config/AbstractNamingConvention.java b/ebean-api/src/main/java/io/ebean/config/AbstractNamingConvention.java
index 9bb65ccce..33d607e97 100644
--- a/ebean-api/src/main/java/io/ebean/config/AbstractNamingConvention.java
+++ b/ebean-api/src/main/java/io/ebean/config/AbstractNamingConvention.java
@@ -7,6 +7,8 @@ import javax.persistence.DiscriminatorValue;
 import javax.persistence.Inheritance;
 import javax.persistence.Table;
 
+import static io.ebean.util.StringHelper.isNull;
+
 /**
  * Provides some base implementation for NamingConventions.
  *
@@ -78,10 +80,16 @@ public abstract class AbstractNamingConvention implements NamingConvention {
 
   @Override
   public String getSequenceName(String rawTableName, String pkColumn) {
-    final String tableNameUnquoted = databasePlatform.unQuote(rawTableName);
+    TableName tableName = new TableName(rawTableName);
+    String seqName = seqName(pkColumn, tableName.getName());
+    return tableName.withCatalogAndSchema(seqName);
+  }
+
+  private String seqName(String pkColumn, String tableName) {
+    final String tableNameUnquoted = unQuote(tableName);
     String seqName = sequenceFormat.replace("{table}", tableNameUnquoted);
-    pkColumn = (pkColumn == null) ? "" : databasePlatform.unQuote(pkColumn);
-    return seqName.replace("{column}", pkColumn);
+    pkColumn = (pkColumn == null) ? "" : unQuote(pkColumn);
+    return quoteIdentifiers(seqName.replace("{column}", pkColumn));
   }
 
   /**
@@ -216,15 +224,13 @@ public abstract class AbstractNamingConvention implements NamingConvention {
         || AnnotationUtil.has(supCls, DiscriminatorValue.class);
   }
 
-
   @Override
   public TableName getM2MJoinTableName(TableName lhsTable, TableName rhsTable) {
-
     StringBuilder buffer = new StringBuilder();
-    buffer.append(lhsTable.getName());
+    buffer.append(unQuote(lhsTable.getName()));
     buffer.append("_");
 
-    String rhsTableName = rhsTable.getName();
+    String rhsTableName = unQuote(rhsTable.getName());
     if (rhsTableName.indexOf('_') < rhsPrefixLength) {
       // trim off a xx_ prefix if there is one
       rhsTableName = rhsTableName.substring(rhsTableName.indexOf('_') + 1);
@@ -238,7 +244,13 @@ public abstract class AbstractNamingConvention implements NamingConvention {
       buffer.setLength(maxTableNameLength);
     }
 
-    return new TableName(lhsTable.getCatalog(), lhsTable.getSchema(), buffer.toString());
+    String tableName = quoteIdentifiers(buffer.toString());
+    return new TableName(lhsTable.getCatalog(), lhsTable.getSchema(), tableName);
+  }
+
+  @Override
+  public String deriveM2MColumn(String tableName, String dbColumn) {
+    return quoteIdentifiers(unQuote(tableName) +"_" + unQuote(dbColumn));
   }
 
   /**
@@ -255,14 +267,29 @@ public abstract class AbstractNamingConvention implements NamingConvention {
     return null;
   }
 
+  @Override
+  public String getTableName(String catalog, String schema, String name) {
+    StringBuilder sb = new StringBuilder();
+    if (!isNull(catalog)) {
+      sb.append(quoteIdentifiers(catalog)).append(".");
+    }
+    if (!isNull(schema)) {
+      sb.append(quoteIdentifiers(schema)).append(".");
+    }
+    return sb.append(quoteIdentifiers(name)).toString();
+  }
+
   /**
-   * Replace back ticks (if they are used) with database platform specific
-   * quoted identifiers.
+   * Replace back ticks (if they are used) with database platform specific quoted identifiers.
    */
   protected String quoteIdentifiers(String s) {
     return databasePlatform.convertQuotedIdentifiers(s);
   }
 
+  private String unQuote(String val) {
+    return databasePlatform.unQuote(val);
+  }
+
   /**
    * Checks string is null or empty .
    */
diff --git a/ebean-api/src/main/java/io/ebean/config/MatchingNamingConvention.java b/ebean-api/src/main/java/io/ebean/config/MatchingNamingConvention.java
index 0b741994a..d12cb2e80 100644
--- a/ebean-api/src/main/java/io/ebean/config/MatchingNamingConvention.java
+++ b/ebean-api/src/main/java/io/ebean/config/MatchingNamingConvention.java
@@ -39,11 +39,6 @@ public class MatchingNamingConvention extends AbstractNamingConvention {
     return new TableName(quoteIdentifiers(getCatalog()), quoteIdentifiers(getSchema()), quoteIdentifiers(beanClass.getSimpleName()));
   }
 
-  @Override
-  public String getPropertyFromColumn(Class beanClass, String dbColumnName) {
-    return dbColumnName;
-  }
-
   @Override
   public String getForeignKey(String prefix, String fkProperty) {
     prefix = databasePlatform.unQuote(prefix);
diff --git a/ebean-api/src/main/java/io/ebean/config/NamingConvention.java b/ebean-api/src/main/java/io/ebean/config/NamingConvention.java
index c5a0a2b86..470822e5b 100644
--- a/ebean-api/src/main/java/io/ebean/config/NamingConvention.java
+++ b/ebean-api/src/main/java/io/ebean/config/NamingConvention.java
@@ -53,6 +53,16 @@ public interface NamingConvention {
    */
   TableName getM2MJoinTableName(TableName lhsTable, TableName rhsTable);
 
+  /**
+   * Derive a DB Column from a FK table and column.
+   */
+  String deriveM2MColumn(String tableName, String dbColumn);
+
+  /**
+   * Return the full table name taking into account quoted identifiers.
+   */
+  String getTableName(String catalog, String schema, String name);
+
   /**
    * Return the column name given the property name.
    *
@@ -60,18 +70,6 @@ public interface NamingConvention {
    */
   String getColumnFromProperty(Class beanClass, String propertyName);
 
-  /**
-   * Return the property name from the column name.
-   * 

- * This is used to help mapping of raw SQL queries onto bean properties. - *

- * - * @param beanClass the bean class - * @param dbColumnName the db column name - * @return the property name from the column name - */ - String getPropertyFromColumn(Class beanClass, String dbColumnName); - /** * Return the sequence name given the table name (for DB's that use sequences). *

diff --git a/ebean-api/src/main/java/io/ebean/config/TableName.java b/ebean-api/src/main/java/io/ebean/config/TableName.java index dba8b1d0d..9f55577b3 100644 --- a/ebean-api/src/main/java/io/ebean/config/TableName.java +++ b/ebean-api/src/main/java/io/ebean/config/TableName.java @@ -20,7 +20,7 @@ public final class TableName { /** * The name. */ - private String name; + private final String name; /** * Construct with the given catalog schema and table name. @@ -29,7 +29,6 @@ public final class TableName { *

*/ public TableName(String catalog, String schema, String name) { - super(); this.catalog = catalog != null ? catalog.trim() : null; this.schema = schema != null ? schema.trim() : null; this.name = name != null ? name.trim() : null; @@ -110,14 +109,11 @@ public final class TableName { * @return the qualified name */ public String getQualifiedName() { - StringBuilder buffer = new StringBuilder(); - // Add catalog if (catalog != null) { buffer.append(catalog); } - // Add schema if (schema != null) { if (buffer.length() > 0) { @@ -125,31 +121,27 @@ public final class TableName { } buffer.append(schema); } - if (buffer.length() > 0) { buffer.append("."); } - buffer.append(name); - - return buffer.toString(); + return buffer.append(name).toString(); } /** * Append a catalog and schema prefix if they exist to the string builder. */ - public void appendCatalogAndSchema(StringBuilder buffer) { - if (catalog != null) { - buffer.append(catalog).append("."); - } + public String withCatalogAndSchema(String name) { if (schema != null) { - buffer.append(schema).append("."); + name = schema + "." + name; } + if (catalog != null) { + name = catalog + "." + name; + } + return name; } /** * Checks if is table name is valid i.e. it has at least a name. - * - * @return true, if is valid */ public boolean isValid() { return name != null && !name.isEmpty(); diff --git a/ebean-api/src/main/java/io/ebean/config/UnderscoreNamingConvention.java b/ebean-api/src/main/java/io/ebean/config/UnderscoreNamingConvention.java index 16b685227..603e4e76c 100644 --- a/ebean-api/src/main/java/io/ebean/config/UnderscoreNamingConvention.java +++ b/ebean-api/src/main/java/io/ebean/config/UnderscoreNamingConvention.java @@ -60,18 +60,6 @@ public class UnderscoreNamingConvention extends AbstractNamingConvention { return toUnderscoreFromCamel(propertyName); } - /** - * Converts underscore based column name to Camel case property name. - * - * @param beanClass the bean class - * @param dbColumnName the db column name - * @return the property from column - */ - @Override - public String getPropertyFromColumn(Class beanClass, String dbColumnName) { - return toCamelFromUnderscore(dbColumnName); - } - /** * Return true if the result will be upper case. *

diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/deploy/parse/AnnotationAssocManys.java b/ebean-core/src/main/java/io/ebeaninternal/server/deploy/parse/AnnotationAssocManys.java index b3346562b..b47612d65 100644 --- a/ebean-core/src/main/java/io/ebeaninternal/server/deploy/parse/AnnotationAssocManys.java +++ b/ebean-core/src/main/java/io/ebeaninternal/server/deploy/parse/AnnotationAssocManys.java @@ -38,8 +38,6 @@ import javax.persistence.OrderBy; import javax.persistence.OrderColumn; import java.util.Set; -import static io.ebean.util.StringHelper.isNull; - /** * Read the deployment annotation for Assoc Many beans. */ @@ -346,18 +344,6 @@ class AnnotationAssocManys extends AnnotationAssoc { return append(joinTable.catalog(), joinTable.schema(), joinTable.name()); } - private String append(String catalog, String schema, String name) { - StringBuilder sb = new StringBuilder(); - if (!isNull(catalog)) { - sb.append(catalog).append("."); - } - if (!isNull(schema)) { - sb.append(schema).append("."); - } - sb.append(name); - return sb.toString(); - } - /** * Return the full table name */ @@ -368,6 +354,13 @@ class AnnotationAssocManys extends AnnotationAssoc { return append(collectionTable.catalog(), collectionTable.schema(), collectionTable.name()); } + /** + * Return the full table name taking into account quoted identifiers. + */ + private String append(String catalog, String schema, String name) { + return namingConvention.getTableName(catalog, schema, name); + } + /** * Define intersection table and foreign key columns for ManyToMany. *

@@ -414,8 +407,8 @@ class AnnotationAssocManys extends AnnotationAssoc { BeanProperty localId = localTable.getIdProperty(); if (localId != null) { // add the source to intersection join columns - String fkCol = localTableName + "_" + localId.getDbColumn(); - intJoin.addJoinColumn(new DeployTableJoinColumn(localId.getDbColumn(), namingConvention.getColumnFromProperty(null, fkCol))); + String fkCol = namingConvention.deriveM2MColumn(localTableName, localId.getDbColumn()); + intJoin.addJoinColumn(new DeployTableJoinColumn(localId.getDbColumn(), fkCol)); } } @@ -424,8 +417,8 @@ class AnnotationAssocManys extends AnnotationAssoc { BeanProperty otherId = otherTable.getIdProperty(); if (otherId != null) { // set the intersection to dest table join columns - final String fkCol = otherTableName + "_" + otherId.getDbColumn(); - destJoin.addJoinColumn(new DeployTableJoinColumn(namingConvention.getColumnFromProperty(null, fkCol), otherId.getDbColumn())); + String fkCol = namingConvention.deriveM2MColumn(otherTableName, otherId.getDbColumn()); + destJoin.addJoinColumn(new DeployTableJoinColumn(fkCol, otherId.getDbColumn())); } } diff --git a/ebean-core/src/test/java/io/ebean/config/MatchingNamingConventionTest.java b/ebean-core/src/test/java/io/ebean/config/MatchingNamingConventionTest.java index c9a2fe030..2db6b95ba 100644 --- a/ebean-core/src/test/java/io/ebean/config/MatchingNamingConventionTest.java +++ b/ebean-core/src/test/java/io/ebean/config/MatchingNamingConventionTest.java @@ -11,7 +11,7 @@ import static org.junit.Assert.assertNull; public class MatchingNamingConventionTest { - private MatchingNamingConvention namingConvention; + private final MatchingNamingConvention namingConvention; public MatchingNamingConventionTest() { this.namingConvention = new MatchingNamingConvention(); @@ -30,6 +30,50 @@ public class MatchingNamingConventionTest { return nc; } + @Test + public void getTableName() { + assertThat(namingConvention.getTableName("a", "b", "c")).isEqualTo("a.b.c"); + assertThat(namingConvention.getTableName("", "b", "c")).isEqualTo("b.c"); + assertThat(namingConvention.getTableName("", "", "c")).isEqualTo("c"); + assertThat(namingConvention.getTableName("a", "", "c")).isEqualTo("a.c"); + } + + @Test + public void getTableName_when_allQuoted() { + MatchingNamingConvention nc = createMatchingNamingConventionAllQuoted(); + + assertThat(nc.getTableName("a", "b", "c")).isEqualTo("[a].[b].[c]"); + assertThat(nc.getTableName("", "b", "c")).isEqualTo("[b].[c]"); + assertThat(nc.getTableName("", "", "c")).isEqualTo("[c]"); + assertThat(nc.getTableName("a", "", "c")).isEqualTo("[a].[c]"); + } + + @Test + public void getM2MJoinTableName() { + TableName t0 = new TableName("One"); + TableName t1 = new TableName("Two"); + assertThat(namingConvention.getM2MJoinTableName(t0, t1).toString()).isEqualTo("One_Two"); + } + + @Test + public void getM2MJoinTableName_when_allQuoted() { + MatchingNamingConvention nc = createMatchingNamingConventionAllQuoted(); + TableName t0 = new TableName("[One]"); + TableName t1 = new TableName("[Two]"); + assertThat(nc.getM2MJoinTableName(t0, t1).toString()).isEqualTo("[One_Two]"); + } + + @Test + public void deriveM2MColumn() { + assertThat(namingConvention.deriveM2MColumn("One", "Two")).isEqualTo("One_Two"); + } + + @Test + public void deriveM2MColumn_when_allQuoted() { + MatchingNamingConvention nc = createMatchingNamingConventionAllQuoted(); + assertThat(nc.deriveM2MColumn("[One]", "[Two]")).isEqualTo("[One_Two]"); + } + @Test public void getColumnFromProperty_when_allQuoted() { @@ -50,11 +94,16 @@ public class MatchingNamingConventionTest { assertNull(tableName.getSchema()); } - @Test public void getSequenceName() { MatchingNamingConvention nc = createMatchingNamingConventionAllQuoted(); - assertEquals("Customer_seq", nc.getSequenceName("[Customer]", null)); + assertThat(nc.getSequenceName("[Customer]", null)).isEqualTo("[Customer_seq]"); + } + + @Test + public void getSequenceName_when_quotedSchema() { + MatchingNamingConvention nc = createMatchingNamingConventionAllQuoted(); + assertThat(nc.getSequenceName("[dbo].[Customer]", null)).isEqualTo("[dbo].[Customer_seq]"); } @Test diff --git a/ebean-core/src/test/java/org/tests/config/TestTableName.java b/ebean-core/src/test/java/org/tests/config/TestTableName.java index f42e98c09..83fefa08b 100644 --- a/ebean-core/src/test/java/org/tests/config/TestTableName.java +++ b/ebean-core/src/test/java/org/tests/config/TestTableName.java @@ -5,8 +5,28 @@ import io.ebean.config.TableName; import org.junit.Assert; import org.junit.Test; +import static org.assertj.core.api.Assertions.assertThat; + public class TestTableName extends BaseTestCase { + @Test + public void withCatalogAndSchema() { + TableName t = new TableName("a.b.c"); + assertThat(t.withCatalogAndSchema("foo")).isEqualTo("a.b.foo"); + } + + @Test + public void withCatalogAndSchema_when_quoted() { + TableName t = new TableName("[a].[b].[c]"); + assertThat(t.withCatalogAndSchema("foo")).isEqualTo("[a].[b].foo"); + + TableName noCat = new TableName("[b].[c]"); + assertThat(noCat.withCatalogAndSchema("foo")).isEqualTo("[b].foo"); + + TableName tabOnly = new TableName("[c]"); + assertThat(tabOnly.withCatalogAndSchema("foo")).isEqualTo("foo"); + } + @Test public void test() { From 2e16f05a701ce6c1ea378d345dbe63eb05902fb5 Mon Sep 17 00:00:00 2001 From: Robin Bygrave Date: Thu, 18 Mar 2021 10:03:35 +1300 Subject: [PATCH 149/447] #2199 - ScalarTypeWrapper doesn't handle "nullValue" correctly Handles the case for ScalarTypeConverter with custom null value and binding the custom null value (via query parameter, CallableSql parameter etc) --- .../server/type/ScalarTypeWrapper.java | 3 -- .../server/type/ScalarTypeWrapperOidTest.java | 29 +++++++++++++++++++ .../model/ivo/converter/OidTypeConverter.java | 9 +++--- 3 files changed, 33 insertions(+), 8 deletions(-) create mode 100644 ebean-core/src/test/java/io/ebeaninternal/server/type/ScalarTypeWrapperOidTest.java diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/type/ScalarTypeWrapper.java b/ebean-core/src/main/java/io/ebeaninternal/server/type/ScalarTypeWrapper.java index 8adee19d3..1ef378e03 100644 --- a/ebean-core/src/main/java/io/ebeaninternal/server/type/ScalarTypeWrapper.java +++ b/ebean-core/src/main/java/io/ebeaninternal/server/type/ScalarTypeWrapper.java @@ -177,9 +177,6 @@ public class ScalarTypeWrapper implements ScalarType { @SuppressWarnings("unchecked") public Object toJdbcType(Object value) { Object sv = converter.unwrapValue((B) value); - if (sv == null) { - return nullValue; - } return scalarType.toJdbcType(sv); } diff --git a/ebean-core/src/test/java/io/ebeaninternal/server/type/ScalarTypeWrapperOidTest.java b/ebean-core/src/test/java/io/ebeaninternal/server/type/ScalarTypeWrapperOidTest.java new file mode 100644 index 000000000..cb602e7f2 --- /dev/null +++ b/ebean-core/src/test/java/io/ebeaninternal/server/type/ScalarTypeWrapperOidTest.java @@ -0,0 +1,29 @@ +package io.ebeaninternal.server.type; + +import org.junit.Test; +import org.tests.model.ivo.Oid; +import org.tests.model.ivo.converter.OidTypeConverter; + +import static org.assertj.core.api.Assertions.assertThat; + + +@SuppressWarnings({"rawtypes", "unchecked"}) +public class ScalarTypeWrapperOidTest { + + private final OidTypeConverter oidTypeConverter = new OidTypeConverter(); + private final ScalarTypeLong longType = new ScalarTypeLong(); + private final ScalarTypeWrapper,Long> wrapper = new ScalarTypeWrapper(Oid.class, longType, oidTypeConverter); + + @Test + public void toJdbcType() { + + assertThat(wrapper.toJdbcType(new Oid(42))).isEqualTo(42L); + assertThat(wrapper.toJdbcType(new Oid(98))).isEqualTo(98L); + } + + @Test + public void toJdbcType_when_nullValue() { + assertThat(wrapper.toJdbcType(OidTypeConverter.NULL_VALUE)).isNull(); + } + +} diff --git a/ebean-core/src/test/java/org/tests/model/ivo/converter/OidTypeConverter.java b/ebean-core/src/test/java/org/tests/model/ivo/converter/OidTypeConverter.java index a4f7fd782..73e67e206 100644 --- a/ebean-core/src/test/java/org/tests/model/ivo/converter/OidTypeConverter.java +++ b/ebean-core/src/test/java/org/tests/model/ivo/converter/OidTypeConverter.java @@ -5,22 +5,21 @@ import org.tests.model.ivo.Oid; public class OidTypeConverter implements ScalarTypeConverter,Long> { + public static final Oid NULL_VALUE = new Oid<>(0); + @Override public Oid getNullValue() { - return null; + return NULL_VALUE; } @Override public Oid wrapValue(Long scalarType) { - if (scalarType == null) { - return null; - } return new Oid<>(scalarType); } @Override public Long unwrapValue(Oid beanType) { - if (beanType == null) { + if (NULL_VALUE.equals(beanType)) { return null; } return beanType.getValue(); From bb73c30bb77e6e1c548c91747e6a033d82f3b7cf Mon Sep 17 00:00:00 2001 From: Robin Bygrave Date: Thu, 18 Mar 2021 16:14:46 +1300 Subject: [PATCH 150/447] #2199 - ScalarTypeWrapper doesn't handle "nullValue" correctly Fix for - standard JPA AttributeConverter which doesn't have the getNullValue method, he/she can't convert null to a custom null object AttributeConverterAdapter probes the AttributeConverter for the nullValue rather than just assuming it is null. --- .../type/AttributeConverterAdapter.java | 12 +++- .../type/ScalarTypeWrapperAdapterTest.java | 62 +++++++++++++++++++ 2 files changed, 73 insertions(+), 1 deletion(-) create mode 100644 ebean-core/src/test/java/io/ebeaninternal/server/type/ScalarTypeWrapperAdapterTest.java diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/type/AttributeConverterAdapter.java b/ebean-core/src/main/java/io/ebeaninternal/server/type/AttributeConverterAdapter.java index d72dd6f9c..e358dd891 100644 --- a/ebean-core/src/main/java/io/ebeaninternal/server/type/AttributeConverterAdapter.java +++ b/ebean-core/src/main/java/io/ebeaninternal/server/type/AttributeConverterAdapter.java @@ -10,14 +10,24 @@ import javax.persistence.AttributeConverter; class AttributeConverterAdapter implements ScalarTypeConverter { private final AttributeConverter converter; + private final B nullValue; AttributeConverterAdapter(AttributeConverter converter) { this.converter = converter; + this.nullValue = probeNullValue(); + } + + private B probeNullValue() { + try { + return converter.convertToEntityAttribute(null); + } catch (Exception e) { + return null; + } } @Override public B getNullValue() { - return null; + return nullValue; } @Override diff --git a/ebean-core/src/test/java/io/ebeaninternal/server/type/ScalarTypeWrapperAdapterTest.java b/ebean-core/src/test/java/io/ebeaninternal/server/type/ScalarTypeWrapperAdapterTest.java new file mode 100644 index 000000000..1f79db003 --- /dev/null +++ b/ebean-core/src/test/java/io/ebeaninternal/server/type/ScalarTypeWrapperAdapterTest.java @@ -0,0 +1,62 @@ +package io.ebeaninternal.server.type; + +import org.junit.Test; + +import javax.persistence.AttributeConverter; + +import static org.assertj.core.api.Assertions.assertThat; + + +@SuppressWarnings({"rawtypes", "unchecked"}) +public class ScalarTypeWrapperAdapterTest { + + private final ScalarTypeString stringType = ScalarTypeString.INSTANCE; + private final MyAdapter myAdapter = new MyAdapter(); + private final AttributeConverterAdapter converterAdapter = new AttributeConverterAdapter(myAdapter); + private final ScalarTypeWrapper wrapper = new ScalarTypeWrapper(Long.class, stringType, converterAdapter); + + @Test + public void toJdbcType() { + assertThat(wrapper.toJdbcType(42L)).isEqualTo("L42"); + assertThat(wrapper.toJdbcType(93L)).isEqualTo("L93"); + } + + @Test + public void toJdbcType_when_nullValue() { + assertThat(wrapper.toJdbcType(MyAdapter.NULL_VAL)).isNull(); + } + + @Test + public void toBeanType_when_null_expect_customNullValue() { + assertThat(wrapper.toBeanType(null)).isEqualTo(MyAdapter.NULL_VAL); + } + + @Test + public void toBeanType() { + assertThat(wrapper.toBeanType("L34")).isEqualTo(34L); + } + + /** + * An AttributeConverter with a custom null value (of -1L). + */ + private static class MyAdapter implements AttributeConverter { + + private static final Long NULL_VAL = -1L; + + @Override + public String convertToDatabaseColumn(Long val) { + if (val == null || val.equals(NULL_VAL)) { + return null; + } + return "L" + val; + } + + @Override + public Long convertToEntityAttribute(String dbData) { + if (dbData == null) { + return NULL_VAL; + } + return Long.parseLong(dbData.substring(1)); + } + } +} From e40a53940653062ff5d4c164c4033c9b8d88bc69 Mon Sep 17 00:00:00 2001 From: Robin Bygrave Date: Thu, 18 Mar 2021 17:02:41 +1300 Subject: [PATCH 151/447] #2200 - ENH: Add DtoQuery findEach with batch consumer - findEach(int batchSize, Consumer> consumer) --- .../src/main/java/io/ebean/DtoQuery.java | 11 ++++ .../io/ebeaninternal/api/SpiEbeanServer.java | 5 ++ .../server/core/DefaultServer.java | 11 ++++ .../server/core/DtoQueryRequest.java | 5 ++ .../server/query/DtoQueryEngine.java | 21 +++++++ .../server/querydefn/DefaultDtoQuery.java | 5 ++ .../src/test/java/io/ebean/DtoQueryTest.java | 62 +++++++++++++++++++ .../ebeaninternal/api/TDSpiEbeanServer.java | 4 ++ .../java/org/tests/model/basic/EBasicLog.java | 4 ++ .../org/tests/model/basic/EBasicWithLog.java | 2 +- 10 files changed, 129 insertions(+), 1 deletion(-) diff --git a/ebean-api/src/main/java/io/ebean/DtoQuery.java b/ebean-api/src/main/java/io/ebean/DtoQuery.java index bb2fa43ab..33f439b93 100644 --- a/ebean-api/src/main/java/io/ebean/DtoQuery.java +++ b/ebean-api/src/main/java/io/ebean/DtoQuery.java @@ -53,6 +53,17 @@ public interface DtoQuery { */ void findEach(Consumer consumer); + /** + * Execute the query iterating the results and batching them for the consumer. + *

+ * This runs like findEach streaming results from the database but just collects the results + * into batches to pass to the consumer. + * + * @param batch The number of dto beans to collect before given them to the consumer + * @param consumer The consumer to process the batch of DTO beans + */ + void findEach(int batch, Consumer> consumer); + /** * Execute the query iterating a row at a time with the ability to stop consuming part way through. *

diff --git a/ebean-core/src/main/java/io/ebeaninternal/api/SpiEbeanServer.java b/ebean-core/src/main/java/io/ebeaninternal/api/SpiEbeanServer.java index e9f26b2b2..deb9c281c 100644 --- a/ebean-core/src/main/java/io/ebeaninternal/api/SpiEbeanServer.java +++ b/ebean-core/src/main/java/io/ebeaninternal/api/SpiEbeanServer.java @@ -264,6 +264,11 @@ public interface SpiEbeanServer extends ExtendedServer, EbeanServer, BeanCollect */ void findDtoEach(SpiDtoQuery query, Consumer consumer); + /** + * DTO findEach batch query. + */ + void findDtoEach(SpiDtoQuery query, int batch, Consumer> consumer); + /** * DTO findEachWhile query. */ diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/core/DefaultServer.java b/ebean-core/src/main/java/io/ebeaninternal/server/core/DefaultServer.java index a51bff04d..34a094301 100644 --- a/ebean-core/src/main/java/io/ebeaninternal/server/core/DefaultServer.java +++ b/ebean-core/src/main/java/io/ebeaninternal/server/core/DefaultServer.java @@ -1597,6 +1597,17 @@ public final class DefaultServer implements SpiServer, SpiEbeanServer { } } + @Override + public void findDtoEach(SpiDtoQuery query, int batch, Consumer> consumer) { + DtoQueryRequest request = new DtoQueryRequest<>(this, dtoQueryEngine, query); + try { + request.initTransIfRequired(); + request.findEach(batch, consumer); + } finally { + request.endTransIfRequired(); + } + } + @Override public void findDtoEachWhile(SpiDtoQuery query, Predicate consumer) { DtoQueryRequest request = new DtoQueryRequest<>(this, dtoQueryEngine, query); diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/core/DtoQueryRequest.java b/ebean-core/src/main/java/io/ebeaninternal/server/core/DtoQueryRequest.java index 0dd1857c3..120e98a27 100644 --- a/ebean-core/src/main/java/io/ebeaninternal/server/core/DtoQueryRequest.java +++ b/ebean-core/src/main/java/io/ebeaninternal/server/core/DtoQueryRequest.java @@ -92,6 +92,11 @@ public final class DtoQueryRequest extends AbstractSqlQueryRequest { queryEngine.findEach(this, consumer); } + public void findEach(int batch, Consumer> consumer) { + flushJdbcBatchOnQuery(); + queryEngine.findEach(this, batch, consumer); + } + public void findEachWhile(Predicate consumer) { flushJdbcBatchOnQuery(); queryEngine.findEachWhile(this, consumer); diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/query/DtoQueryEngine.java b/ebean-core/src/main/java/io/ebeaninternal/server/query/DtoQueryEngine.java index 911bcd511..bbd111f1c 100644 --- a/ebean-core/src/main/java/io/ebeaninternal/server/query/DtoQueryEngine.java +++ b/ebean-core/src/main/java/io/ebeaninternal/server/query/DtoQueryEngine.java @@ -42,7 +42,28 @@ public class DtoQueryEngine { } } catch (Exception e) { throw new PersistenceException(errMsg(e.getMessage(), request.getSql()), e); + } finally { + request.close(); + } + } + public void findEach(DtoQueryRequest request, int batchSize, Consumer> consumer) { + try { + List buffer = new ArrayList<>(); + request.executeSql(binder, SpiQuery.Type.ITERATE); + while (request.next()) { + buffer.add(request.readNextBean()); + if (buffer.size() >= batchSize) { + consumer.accept(buffer); + buffer.clear(); + } + } + if (!buffer.isEmpty()) { + // consume the remainder + consumer.accept(buffer); + } + } catch (Exception e) { + throw new PersistenceException(errMsg(e.getMessage(), request.getSql()), e); } finally { request.close(); } diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/querydefn/DefaultDtoQuery.java b/ebean-core/src/main/java/io/ebeaninternal/server/querydefn/DefaultDtoQuery.java index 12d5545e0..d5877572a 100644 --- a/ebean-core/src/main/java/io/ebeaninternal/server/querydefn/DefaultDtoQuery.java +++ b/ebean-core/src/main/java/io/ebeaninternal/server/querydefn/DefaultDtoQuery.java @@ -102,6 +102,11 @@ public class DefaultDtoQuery implements SpiDtoQuery { server.findDtoEach(this, consumer); } + @Override + public void findEach(int batch, Consumer> consumer) { + server.findDtoEach(this, batch, consumer); + } + @Override public void findEachWhile(Predicate consumer) { server.findDtoEachWhile(this, consumer); diff --git a/ebean-core/src/test/java/io/ebean/DtoQueryTest.java b/ebean-core/src/test/java/io/ebean/DtoQueryTest.java index 3a2c8e35e..eea1c6da3 100644 --- a/ebean-core/src/test/java/io/ebean/DtoQueryTest.java +++ b/ebean-core/src/test/java/io/ebean/DtoQueryTest.java @@ -10,11 +10,13 @@ import org.junit.Test; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.tests.model.basic.Customer; +import org.tests.model.basic.EBasicLog; import org.tests.model.basic.ResetBasicData; import java.util.Arrays; import java.util.List; import java.util.Optional; +import java.util.concurrent.atomic.AtomicInteger; import static org.assertj.core.api.Assertions.assertThat; @@ -22,6 +24,9 @@ public class DtoQueryTest extends BaseTestCase { private static final Logger log = LoggerFactory.getLogger(DtoQueryTest.class); + private final AtomicInteger batchCount = new AtomicInteger(); + private final AtomicInteger rowCount = new AtomicInteger(); + @Test public void dto_findList_constructorMatch() { @@ -78,6 +83,63 @@ public class DtoQueryTest extends BaseTestCase { assertSql(sql.get(0)).contains("select id, name from o_customer where id > ?"); } + private void resetFindEachCounts() { + batchCount.set(0); + rowCount.set(0); + } + + @Test + public void dto_findEachBatch() { + seedData(); // 15 rows inserted to fetch + + resetFindEachCounts(); + findEachWithBatch(5); + assertThat(batchCount.get()).isEqualTo(3); + assertThat(rowCount.get()).isEqualTo(15); + + resetFindEachCounts(); + findEachWithBatch(10); + assertThat(batchCount.get()).isEqualTo(2); + assertThat(rowCount.get()).isEqualTo(15); + + resetFindEachCounts(); + findEachWithBatch(14); + assertThat(batchCount.get()).isEqualTo(2); + assertThat(rowCount.get()).isEqualTo(15); + + resetFindEachCounts(); + findEachWithBatch(15); + assertThat(batchCount.get()).isEqualTo(1); + assertThat(rowCount.get()).isEqualTo(15); + + resetFindEachCounts(); + findEachWithBatch(16); + assertThat(batchCount.get()).isEqualTo(1); + assertThat(rowCount.get()).isEqualTo(15); + + resetFindEachCounts(); + findEachWithBatch(20); + assertThat(batchCount.get()).isEqualTo(1); + assertThat(rowCount.get()).isEqualTo(15); + } + + private void findEachWithBatch(int batchSize) { + server().findDto(DCust.class, "select id, name from e_basic_log where name like ?") + .setParameter("dtoFindEachBatch%") + .findEach(batchSize, batch -> { + int batchId = batchCount.incrementAndGet(); + int rows = rowCount.addAndGet(batch.size()); + log.info("batch {} rows {}", batchId, rows); + }); + } + + private void seedData() { + for (int i = 0; i < 15; i++) { + EBasicLog log = new EBasicLog("dtoFindEachBatch "+i); + DB.save(log); + } + } + @Test public void dto_findOneEmpty() { diff --git a/ebean-core/src/test/java/io/ebeaninternal/api/TDSpiEbeanServer.java b/ebean-core/src/test/java/io/ebeaninternal/api/TDSpiEbeanServer.java index 09e75825b..03ed3362f 100644 --- a/ebean-core/src/test/java/io/ebeaninternal/api/TDSpiEbeanServer.java +++ b/ebean-core/src/test/java/io/ebeaninternal/api/TDSpiEbeanServer.java @@ -445,6 +445,10 @@ public class TDSpiEbeanServer implements SpiEbeanServer { public void findDtoEach(SpiDtoQuery query, Consumer consumer) { } + @Override + public void findDtoEach(SpiDtoQuery query, int batch, Consumer> consumer) { + } + @Override public void findDtoEachWhile(SpiDtoQuery query, Predicate consumer) { } diff --git a/ebean-core/src/test/java/org/tests/model/basic/EBasicLog.java b/ebean-core/src/test/java/org/tests/model/basic/EBasicLog.java index e0de4ce92..160fff74a 100644 --- a/ebean-core/src/test/java/org/tests/model/basic/EBasicLog.java +++ b/ebean-core/src/test/java/org/tests/model/basic/EBasicLog.java @@ -13,6 +13,10 @@ public class EBasicLog { String name; + public EBasicLog(String name) { + this.name = name; + } + public Long getId() { return id; } diff --git a/ebean-core/src/test/java/org/tests/model/basic/EBasicWithLog.java b/ebean-core/src/test/java/org/tests/model/basic/EBasicWithLog.java index 743796e52..3ff7634f0 100644 --- a/ebean-core/src/test/java/org/tests/model/basic/EBasicWithLog.java +++ b/ebean-core/src/test/java/org/tests/model/basic/EBasicWithLog.java @@ -116,7 +116,7 @@ public class EBasicWithLog { } private void writeLog(String title) { - EBasicLog log = new EBasicLog(); + EBasicLog log = new EBasicLog(name); log.setName(title); DB.save(log); } From e1f9d106f070d465d73fdfadfb6268b32ec717b9 Mon Sep 17 00:00:00 2001 From: Robin Bygrave Date: Thu, 18 Mar 2021 17:12:21 +1300 Subject: [PATCH 152/447] Additional tests for #2191 query findEach batch consumer --- .../org/tests/query/TestQueryFindEach.java | 68 +++++++++++++++++-- 1 file changed, 64 insertions(+), 4 deletions(-) diff --git a/ebean-core/src/test/java/org/tests/query/TestQueryFindEach.java b/ebean-core/src/test/java/org/tests/query/TestQueryFindEach.java index f0f959428..1a2c16bab 100644 --- a/ebean-core/src/test/java/org/tests/query/TestQueryFindEach.java +++ b/ebean-core/src/test/java/org/tests/query/TestQueryFindEach.java @@ -2,7 +2,6 @@ package org.tests.query; import io.ebean.BaseTestCase; import io.ebean.DB; -import io.ebean.FetchConfig; import io.ebean.Query; import io.ebean.Transaction; import io.ebean.annotation.Transactional; @@ -10,8 +9,11 @@ import io.ebean.bean.PersistenceContext; import io.ebeaninternal.api.SpiTransaction; import org.ebeantest.LoggedSqlCollector; import org.junit.Test; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.tests.model.basic.Contact; import org.tests.model.basic.Customer; +import org.tests.model.basic.EBasicLog; import org.tests.model.basic.ResetBasicData; import org.tests.o2m.OmBasicChild; import org.tests.o2m.OmBasicParent; @@ -21,13 +23,14 @@ import java.util.Random; import java.util.concurrent.atomic.AtomicInteger; import static org.assertj.core.api.Assertions.assertThat; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.fail; +import static org.junit.Assert.*; public class TestQueryFindEach extends BaseTestCase { + private static final Logger log = LoggerFactory.getLogger(TestQueryFindEach.class); private final Random random = new Random(); + private final AtomicInteger batchCount = new AtomicInteger(); + private final AtomicInteger rowCount = new AtomicInteger(); @Test public void test() { @@ -49,6 +52,63 @@ public class TestQueryFindEach extends BaseTestCase { assertEquals(2, counter.get()); } + private void resetFindEachCounts() { + batchCount.set(0); + rowCount.set(0); + } + + private void seedData() { + for (int i = 0; i < 15; i++) { + EBasicLog log = new EBasicLog("findEachBatch "+i); + DB.save(log); + } + } + + @Test + public void findEachBatch() { + seedData(); + + resetFindEachCounts(); + findEachWithBatch(5); + assertThat(batchCount.get()).isEqualTo(3); + assertThat(rowCount.get()).isEqualTo(15); + + resetFindEachCounts(); + findEachWithBatch(10); + assertThat(batchCount.get()).isEqualTo(2); + assertThat(rowCount.get()).isEqualTo(15); + + resetFindEachCounts(); + findEachWithBatch(14); + assertThat(batchCount.get()).isEqualTo(2); + assertThat(rowCount.get()).isEqualTo(15); + + resetFindEachCounts(); + findEachWithBatch(15); + assertThat(batchCount.get()).isEqualTo(1); + assertThat(rowCount.get()).isEqualTo(15); + + resetFindEachCounts(); + findEachWithBatch(16); + assertThat(batchCount.get()).isEqualTo(1); + assertThat(rowCount.get()).isEqualTo(15); + + resetFindEachCounts(); + findEachWithBatch(20); + assertThat(batchCount.get()).isEqualTo(1); + assertThat(rowCount.get()).isEqualTo(15); + } + + private void findEachWithBatch(int batchSize) { + DB.find(EBasicLog.class) + .where().startsWith("name","findEachBatch") + .findEach(batchSize, batch -> { + int batchId = batchCount.incrementAndGet(); + int rows = rowCount.addAndGet(batch.size()); + log.info("batch id:{} size:{} total rows:{}", batchId, batch.size(), rows); + }); + } + @Test public void persistenceContext_scope() { From 9b066e4eac14bc1057d6f12c4362e39789b90501 Mon Sep 17 00:00:00 2001 From: rob bygrave Date: Thu, 18 Mar 2021 21:26:50 +1300 Subject: [PATCH 153/447] Bump version to 12.8.0-SNAPSHOT --- ebean-api/pom.xml | 2 +- ebean-autotune/pom.xml | 4 ++-- ebean-bom/pom.xml | 30 +++++++++++++++--------------- ebean-core-type/pom.xml | 4 ++-- ebean-core/pom.xml | 8 ++++---- ebean-ddl-generator/pom.xml | 6 +++--- ebean-externalmapping-api/pom.xml | 2 +- ebean-externalmapping-xml/pom.xml | 8 ++++---- ebean-postgis/pom.xml | 6 +++--- ebean-querybean/pom.xml | 10 +++++----- ebean-redis/pom.xml | 12 ++++++------ ebean-test/pom.xml | 6 +++--- ebean/pom.xml | 8 ++++---- kotlin-querybean-generator/pom.xml | 10 +++++----- pom.xml | 2 +- querybean-generator/pom.xml | 2 +- 16 files changed, 60 insertions(+), 60 deletions(-) diff --git a/ebean-api/pom.xml b/ebean-api/pom.xml index c073c2699..852f49586 100644 --- a/ebean-api/pom.xml +++ b/ebean-api/pom.xml @@ -4,7 +4,7 @@ ebean-parent io.ebean - 12.7.3-SNAPSHOT + 12.8.0-SNAPSHOT ebean api diff --git a/ebean-autotune/pom.xml b/ebean-autotune/pom.xml index 4ced5a224..572584041 100644 --- a/ebean-autotune/pom.xml +++ b/ebean-autotune/pom.xml @@ -4,7 +4,7 @@ ebean-parent io.ebean - 12.7.3-SNAPSHOT + 12.8.0-SNAPSHOT @@ -26,7 +26,7 @@ io.ebean ebean-core - 12.7.3-SNAPSHOT + 12.8.0-SNAPSHOT provided diff --git a/ebean-bom/pom.xml b/ebean-bom/pom.xml index 2293b2db9..cbb2fe5f4 100644 --- a/ebean-bom/pom.xml +++ b/ebean-bom/pom.xml @@ -4,7 +4,7 @@ ebean-parent io.ebean - 12.7.3-SNAPSHOT + 12.8.0-SNAPSHOT ebean bom @@ -81,88 +81,88 @@ io.ebean ebean - 12.7.3-SNAPSHOT + 12.8.0-SNAPSHOT io.ebean ebean-api - 12.7.3-SNAPSHOT + 12.8.0-SNAPSHOT io.ebean ebean-core - 12.7.3-SNAPSHOT + 12.8.0-SNAPSHOT io.ebean ebean-core-type - 12.7.3-SNAPSHOT + 12.8.0-SNAPSHOT io.ebean ebean-ddl-generator - 12.7.3-SNAPSHOT + 12.8.0-SNAPSHOT io.ebean ebean-externalmapping-api - 12.7.3-SNAPSHOT + 12.8.0-SNAPSHOT io.ebean ebean-externalmapping-xml - 12.7.3-SNAPSHOT + 12.8.0-SNAPSHOT io.ebean ebean-autotune - 12.7.3-SNAPSHOT + 12.8.0-SNAPSHOT io.ebean ebean-querybean - 12.7.3-SNAPSHOT + 12.8.0-SNAPSHOT io.ebean querybean-generator - 12.7.3-SNAPSHOT + 12.8.0-SNAPSHOT provided io.ebean kotlin-querybean-generator - 12.7.3-SNAPSHOT + 12.8.0-SNAPSHOT provided io.ebean ebean-test - 12.7.3-SNAPSHOT + 12.8.0-SNAPSHOT test io.ebean ebean-postgis - 12.7.3-SNAPSHOT + 12.8.0-SNAPSHOT io.ebean ebean-redis - 12.7.3-SNAPSHOT + 12.8.0-SNAPSHOT diff --git a/ebean-core-type/pom.xml b/ebean-core-type/pom.xml index 9e7a3c6eb..569ba1fd1 100644 --- a/ebean-core-type/pom.xml +++ b/ebean-core-type/pom.xml @@ -4,7 +4,7 @@ ebean-parent io.ebean - 12.7.3-SNAPSHOT + 12.8.0-SNAPSHOT ebean-core-type @@ -16,7 +16,7 @@ io.ebean ebean-api - 12.7.3-SNAPSHOT + 12.8.0-SNAPSHOT diff --git a/ebean-core/pom.xml b/ebean-core/pom.xml index b493318d1..91fffa399 100644 --- a/ebean-core/pom.xml +++ b/ebean-core/pom.xml @@ -3,7 +3,7 @@ ebean-parent io.ebean - 12.7.3-SNAPSHOT + 12.8.0-SNAPSHOT ebean-core @@ -87,19 +87,19 @@ io.ebean ebean-api - 12.7.3-SNAPSHOT + 12.8.0-SNAPSHOT io.ebean ebean-core-type - 12.7.3-SNAPSHOT + 12.8.0-SNAPSHOT io.ebean ebean-externalmapping-api - 12.7.3-SNAPSHOT + 12.8.0-SNAPSHOT diff --git a/ebean-ddl-generator/pom.xml b/ebean-ddl-generator/pom.xml index 571f4e090..8e56bffc8 100644 --- a/ebean-ddl-generator/pom.xml +++ b/ebean-ddl-generator/pom.xml @@ -4,7 +4,7 @@ ebean-parent io.ebean - 12.7.3-SNAPSHOT + 12.8.0-SNAPSHOT ebean ddl generation @@ -29,14 +29,14 @@ io.ebean ebean-core-type - 12.7.3-SNAPSHOT + 12.8.0-SNAPSHOT provided io.ebean ebean-core - 12.7.3-SNAPSHOT + 12.8.0-SNAPSHOT provided diff --git a/ebean-externalmapping-api/pom.xml b/ebean-externalmapping-api/pom.xml index 4c33334e1..ae74fc720 100644 --- a/ebean-externalmapping-api/pom.xml +++ b/ebean-externalmapping-api/pom.xml @@ -4,7 +4,7 @@ ebean-parent io.ebean - 12.7.3-SNAPSHOT + 12.8.0-SNAPSHOT ebean external mapping api diff --git a/ebean-externalmapping-xml/pom.xml b/ebean-externalmapping-xml/pom.xml index 0ae68425e..43e580912 100644 --- a/ebean-externalmapping-xml/pom.xml +++ b/ebean-externalmapping-xml/pom.xml @@ -4,7 +4,7 @@ ebean-parent io.ebean - 12.7.3-SNAPSHOT + 12.8.0-SNAPSHOT @@ -33,7 +33,7 @@ io.ebean ebean-externalmapping-api - 12.7.3-SNAPSHOT + 12.8.0-SNAPSHOT @@ -59,14 +59,14 @@ io.ebean ebean-core - 12.7.3-SNAPSHOT + 12.8.0-SNAPSHOT test io.ebean ebean-ddl-generator - 12.7.3-SNAPSHOT + 12.8.0-SNAPSHOT test diff --git a/ebean-postgis/pom.xml b/ebean-postgis/pom.xml index 99fe84dca..1114e25d2 100644 --- a/ebean-postgis/pom.xml +++ b/ebean-postgis/pom.xml @@ -4,7 +4,7 @@ ebean-parent io.ebean - 12.7.3-SNAPSHOT + 12.8.0-SNAPSHOT ebean postgis @@ -23,7 +23,7 @@ io.ebean ebean-core - 12.7.3-SNAPSHOT + 12.8.0-SNAPSHOT provided @@ -74,7 +74,7 @@ io.ebean ebean-test - 12.7.3-SNAPSHOT + 12.8.0-SNAPSHOT test diff --git a/ebean-querybean/pom.xml b/ebean-querybean/pom.xml index 132ef56e2..2245f8288 100644 --- a/ebean-querybean/pom.xml +++ b/ebean-querybean/pom.xml @@ -4,7 +4,7 @@ ebean-parent io.ebean - 12.7.3-SNAPSHOT + 12.8.0-SNAPSHOT ebean querybean @@ -17,7 +17,7 @@ io.ebean ebean-core - 12.7.3-SNAPSHOT + 12.8.0-SNAPSHOT provided @@ -57,21 +57,21 @@ io.ebean ebean-ddl-generator - 12.7.3-SNAPSHOT + 12.8.0-SNAPSHOT test io.ebean querybean-generator - 12.7.3-SNAPSHOT + 12.8.0-SNAPSHOT test io.ebean ebean-test - 12.7.3-SNAPSHOT + 12.8.0-SNAPSHOT test diff --git a/ebean-redis/pom.xml b/ebean-redis/pom.xml index 5ea354664..56808f776 100644 --- a/ebean-redis/pom.xml +++ b/ebean-redis/pom.xml @@ -4,7 +4,7 @@ ebean-parent io.ebean - 12.7.3-SNAPSHOT + 12.8.0-SNAPSHOT ebean-redis @@ -22,35 +22,35 @@ io.ebean ebean-api - 12.7.3-SNAPSHOT + 12.8.0-SNAPSHOT provided io.ebean ebean-core - 12.7.3-SNAPSHOT + 12.8.0-SNAPSHOT provided io.ebean ebean-querybean - 12.7.3-SNAPSHOT + 12.8.0-SNAPSHOT test io.ebean querybean-generator - 12.7.3-SNAPSHOT + 12.8.0-SNAPSHOT test io.ebean ebean-test - 12.7.3-SNAPSHOT + 12.8.0-SNAPSHOT test diff --git a/ebean-test/pom.xml b/ebean-test/pom.xml index 4b5e47899..066be5f9f 100644 --- a/ebean-test/pom.xml +++ b/ebean-test/pom.xml @@ -4,7 +4,7 @@ ebean-parent io.ebean - 12.7.3-SNAPSHOT + 12.8.0-SNAPSHOT ebean test @@ -29,14 +29,14 @@ io.ebean ebean-core - 12.7.3-SNAPSHOT + 12.8.0-SNAPSHOT provided io.ebean ebean-ddl-generator - 12.7.3-SNAPSHOT + 12.8.0-SNAPSHOT diff --git a/ebean/pom.xml b/ebean/pom.xml index 7356b26ff..6176a570c 100644 --- a/ebean/pom.xml +++ b/ebean/pom.xml @@ -4,7 +4,7 @@ ebean-parent io.ebean - 12.7.3-SNAPSHOT + 12.8.0-SNAPSHOT ebean composite @@ -22,20 +22,20 @@ io.ebean ebean-api - 12.7.3-SNAPSHOT + 12.8.0-SNAPSHOT io.ebean ebean-core - 12.7.3-SNAPSHOT + 12.8.0-SNAPSHOT io.ebean ebean-querybean - 12.7.3-SNAPSHOT + 12.8.0-SNAPSHOT diff --git a/kotlin-querybean-generator/pom.xml b/kotlin-querybean-generator/pom.xml index 9bf33578e..5d87a6533 100644 --- a/kotlin-querybean-generator/pom.xml +++ b/kotlin-querybean-generator/pom.xml @@ -4,7 +4,7 @@ ebean-parent io.ebean - 12.7.3-SNAPSHOT + 12.8.0-SNAPSHOT kotlin querybean generator @@ -29,7 +29,7 @@ io.ebean ebean-querybean - 12.7.3-SNAPSHOT + 12.8.0-SNAPSHOT test @@ -43,7 +43,7 @@ io.ebean ebean-core - 12.7.3-SNAPSHOT + 12.8.0-SNAPSHOT test @@ -64,7 +64,7 @@ io.ebean ebean-ddl-generator - 12.7.3-SNAPSHOT + 12.8.0-SNAPSHOT test @@ -107,7 +107,7 @@ - + diff --git a/pom.xml b/pom.xml index 8e06ae121..1b27fe76d 100644 --- a/pom.xml +++ b/pom.xml @@ -9,7 +9,7 @@ io.ebean ebean-parent - 12.7.3-SNAPSHOT + 12.8.0-SNAPSHOT pom ebean parent diff --git a/querybean-generator/pom.xml b/querybean-generator/pom.xml index bc6fc7019..4abbf7db8 100644 --- a/querybean-generator/pom.xml +++ b/querybean-generator/pom.xml @@ -4,7 +4,7 @@ ebean-parent io.ebean - 12.7.3-SNAPSHOT + 12.8.0-SNAPSHOT querybean generator From ce1d2803ce77da7cc935e1fd83ba6944c5f4c998 Mon Sep 17 00:00:00 2001 From: rob bygrave Date: Thu, 18 Mar 2021 22:18:34 +1300 Subject: [PATCH 154/447] Bump test wait time for redis --- ebean-redis/src/test/java/org/integration/ClusterTest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ebean-redis/src/test/java/org/integration/ClusterTest.java b/ebean-redis/src/test/java/org/integration/ClusterTest.java index 0bb546526..a6d9515c8 100644 --- a/ebean-redis/src/test/java/org/integration/ClusterTest.java +++ b/ebean-redis/src/test/java/org/integration/ClusterTest.java @@ -118,6 +118,6 @@ public class ClusterTest { } private void allowAsyncMessaging() throws InterruptedException { - Thread.sleep(20); + Thread.sleep(50); } } From 7ab7b612f64305ead12df7aad017328b0db63e08 Mon Sep 17 00:00:00 2001 From: rob bygrave Date: Thu, 18 Mar 2021 22:23:34 +1300 Subject: [PATCH 155/447] [maven-release-plugin] prepare release ebean-parent-12.8.0 --- ebean-api/pom.xml | 2 +- ebean-autotune/pom.xml | 6 +++--- ebean-bom/pom.xml | 30 +++++++++++++++--------------- ebean-core-type/pom.xml | 4 ++-- ebean-core/pom.xml | 10 +++++----- ebean-ddl-generator/pom.xml | 6 +++--- ebean-externalmapping-api/pom.xml | 2 +- ebean-externalmapping-xml/pom.xml | 10 +++++----- ebean-postgis/pom.xml | 6 +++--- ebean-querybean/pom.xml | 10 +++++----- ebean-redis/pom.xml | 12 ++++++------ ebean-test/pom.xml | 6 +++--- ebean/pom.xml | 8 ++++---- kotlin-querybean-generator/pom.xml | 8 ++++---- pom.xml | 4 ++-- querybean-generator/pom.xml | 2 +- 16 files changed, 63 insertions(+), 63 deletions(-) diff --git a/ebean-api/pom.xml b/ebean-api/pom.xml index 852f49586..b14da4897 100644 --- a/ebean-api/pom.xml +++ b/ebean-api/pom.xml @@ -4,7 +4,7 @@ ebean-parent io.ebean - 12.8.0-SNAPSHOT + 12.8.0 ebean api diff --git a/ebean-autotune/pom.xml b/ebean-autotune/pom.xml index 572584041..2f2195bae 100644 --- a/ebean-autotune/pom.xml +++ b/ebean-autotune/pom.xml @@ -4,7 +4,7 @@ ebean-parent io.ebean - 12.8.0-SNAPSHOT + 12.8.0 @@ -14,7 +14,7 @@ scm:git:git@github.com:ebean-orm/ebean.git - ebean-parent-12.6.5 + ebean-parent-12.8.0 ebean autotune @@ -26,7 +26,7 @@ io.ebean ebean-core - 12.8.0-SNAPSHOT + 12.8.0 provided diff --git a/ebean-bom/pom.xml b/ebean-bom/pom.xml index cbb2fe5f4..a1ff72303 100644 --- a/ebean-bom/pom.xml +++ b/ebean-bom/pom.xml @@ -4,7 +4,7 @@ ebean-parent io.ebean - 12.8.0-SNAPSHOT + 12.8.0 ebean bom @@ -81,88 +81,88 @@ io.ebean ebean - 12.8.0-SNAPSHOT + 12.8.0 io.ebean ebean-api - 12.8.0-SNAPSHOT + 12.8.0 io.ebean ebean-core - 12.8.0-SNAPSHOT + 12.8.0 io.ebean ebean-core-type - 12.8.0-SNAPSHOT + 12.8.0 io.ebean ebean-ddl-generator - 12.8.0-SNAPSHOT + 12.8.0 io.ebean ebean-externalmapping-api - 12.8.0-SNAPSHOT + 12.8.0 io.ebean ebean-externalmapping-xml - 12.8.0-SNAPSHOT + 12.8.0 io.ebean ebean-autotune - 12.8.0-SNAPSHOT + 12.8.0 io.ebean ebean-querybean - 12.8.0-SNAPSHOT + 12.8.0 io.ebean querybean-generator - 12.8.0-SNAPSHOT + 12.8.0 provided io.ebean kotlin-querybean-generator - 12.8.0-SNAPSHOT + 12.8.0 provided io.ebean ebean-test - 12.8.0-SNAPSHOT + 12.8.0 test io.ebean ebean-postgis - 12.8.0-SNAPSHOT + 12.8.0 io.ebean ebean-redis - 12.8.0-SNAPSHOT + 12.8.0 diff --git a/ebean-core-type/pom.xml b/ebean-core-type/pom.xml index 569ba1fd1..7261bb679 100644 --- a/ebean-core-type/pom.xml +++ b/ebean-core-type/pom.xml @@ -4,7 +4,7 @@ ebean-parent io.ebean - 12.8.0-SNAPSHOT + 12.8.0 ebean-core-type @@ -16,7 +16,7 @@ io.ebean ebean-api - 12.8.0-SNAPSHOT + 12.8.0 diff --git a/ebean-core/pom.xml b/ebean-core/pom.xml index 91fffa399..9541f5126 100644 --- a/ebean-core/pom.xml +++ b/ebean-core/pom.xml @@ -3,7 +3,7 @@ ebean-parent io.ebean - 12.8.0-SNAPSHOT + 12.8.0 ebean-core @@ -15,7 +15,7 @@ scm:git:git@github.com:ebean-orm/ebean.git - ebean-parent-12.6.5 + ebean-parent-12.8.0 @@ -87,19 +87,19 @@ io.ebean ebean-api - 12.8.0-SNAPSHOT + 12.8.0 io.ebean ebean-core-type - 12.8.0-SNAPSHOT + 12.8.0 io.ebean ebean-externalmapping-api - 12.8.0-SNAPSHOT + 12.8.0 diff --git a/ebean-ddl-generator/pom.xml b/ebean-ddl-generator/pom.xml index 8e56bffc8..102246313 100644 --- a/ebean-ddl-generator/pom.xml +++ b/ebean-ddl-generator/pom.xml @@ -4,7 +4,7 @@ ebean-parent io.ebean - 12.8.0-SNAPSHOT + 12.8.0 ebean ddl generation @@ -29,14 +29,14 @@ io.ebean ebean-core-type - 12.8.0-SNAPSHOT + 12.8.0 provided io.ebean ebean-core - 12.8.0-SNAPSHOT + 12.8.0 provided diff --git a/ebean-externalmapping-api/pom.xml b/ebean-externalmapping-api/pom.xml index ae74fc720..a0c1e9a82 100644 --- a/ebean-externalmapping-api/pom.xml +++ b/ebean-externalmapping-api/pom.xml @@ -4,7 +4,7 @@ ebean-parent io.ebean - 12.8.0-SNAPSHOT + 12.8.0 ebean external mapping api diff --git a/ebean-externalmapping-xml/pom.xml b/ebean-externalmapping-xml/pom.xml index 43e580912..f1017d3cf 100644 --- a/ebean-externalmapping-xml/pom.xml +++ b/ebean-externalmapping-xml/pom.xml @@ -4,7 +4,7 @@ ebean-parent io.ebean - 12.8.0-SNAPSHOT + 12.8.0 @@ -14,7 +14,7 @@ scm:git:git@github.com:ebean-orm/ebean.git - ebean-parent-12.6.5 + ebean-parent-12.8.0 ebean external mapping xml @@ -33,7 +33,7 @@ io.ebean ebean-externalmapping-api - 12.8.0-SNAPSHOT + 12.8.0 @@ -59,14 +59,14 @@ io.ebean ebean-core - 12.8.0-SNAPSHOT + 12.8.0 test io.ebean ebean-ddl-generator - 12.8.0-SNAPSHOT + 12.8.0 test diff --git a/ebean-postgis/pom.xml b/ebean-postgis/pom.xml index 1114e25d2..a5e3c1514 100644 --- a/ebean-postgis/pom.xml +++ b/ebean-postgis/pom.xml @@ -4,7 +4,7 @@ ebean-parent io.ebean - 12.8.0-SNAPSHOT + 12.8.0 ebean postgis @@ -23,7 +23,7 @@ io.ebean ebean-core - 12.8.0-SNAPSHOT + 12.8.0 provided @@ -74,7 +74,7 @@ io.ebean ebean-test - 12.8.0-SNAPSHOT + 12.8.0 test diff --git a/ebean-querybean/pom.xml b/ebean-querybean/pom.xml index 2245f8288..5ec002181 100644 --- a/ebean-querybean/pom.xml +++ b/ebean-querybean/pom.xml @@ -4,7 +4,7 @@ ebean-parent io.ebean - 12.8.0-SNAPSHOT + 12.8.0 ebean querybean @@ -17,7 +17,7 @@ io.ebean ebean-core - 12.8.0-SNAPSHOT + 12.8.0 provided @@ -57,21 +57,21 @@ io.ebean ebean-ddl-generator - 12.8.0-SNAPSHOT + 12.8.0 test io.ebean querybean-generator - 12.8.0-SNAPSHOT + 12.8.0 test io.ebean ebean-test - 12.8.0-SNAPSHOT + 12.8.0 test diff --git a/ebean-redis/pom.xml b/ebean-redis/pom.xml index 56808f776..86c4572b5 100644 --- a/ebean-redis/pom.xml +++ b/ebean-redis/pom.xml @@ -4,7 +4,7 @@ ebean-parent io.ebean - 12.8.0-SNAPSHOT + 12.8.0 ebean-redis @@ -22,35 +22,35 @@ io.ebean ebean-api - 12.8.0-SNAPSHOT + 12.8.0 provided io.ebean ebean-core - 12.8.0-SNAPSHOT + 12.8.0 provided io.ebean ebean-querybean - 12.8.0-SNAPSHOT + 12.8.0 test io.ebean querybean-generator - 12.8.0-SNAPSHOT + 12.8.0 test io.ebean ebean-test - 12.8.0-SNAPSHOT + 12.8.0 test diff --git a/ebean-test/pom.xml b/ebean-test/pom.xml index 066be5f9f..5f9131316 100644 --- a/ebean-test/pom.xml +++ b/ebean-test/pom.xml @@ -4,7 +4,7 @@ ebean-parent io.ebean - 12.8.0-SNAPSHOT + 12.8.0 ebean test @@ -29,14 +29,14 @@ io.ebean ebean-core - 12.8.0-SNAPSHOT + 12.8.0 provided io.ebean ebean-ddl-generator - 12.8.0-SNAPSHOT + 12.8.0 diff --git a/ebean/pom.xml b/ebean/pom.xml index 6176a570c..42f88d25b 100644 --- a/ebean/pom.xml +++ b/ebean/pom.xml @@ -4,7 +4,7 @@ ebean-parent io.ebean - 12.8.0-SNAPSHOT + 12.8.0 ebean composite @@ -22,20 +22,20 @@ io.ebean ebean-api - 12.8.0-SNAPSHOT + 12.8.0 io.ebean ebean-core - 12.8.0-SNAPSHOT + 12.8.0 io.ebean ebean-querybean - 12.8.0-SNAPSHOT + 12.8.0 diff --git a/kotlin-querybean-generator/pom.xml b/kotlin-querybean-generator/pom.xml index 5d87a6533..339bee3af 100644 --- a/kotlin-querybean-generator/pom.xml +++ b/kotlin-querybean-generator/pom.xml @@ -4,7 +4,7 @@ ebean-parent io.ebean - 12.8.0-SNAPSHOT + 12.8.0 kotlin querybean generator @@ -29,7 +29,7 @@ io.ebean ebean-querybean - 12.8.0-SNAPSHOT + 12.8.0 test @@ -43,7 +43,7 @@ io.ebean ebean-core - 12.8.0-SNAPSHOT + 12.8.0 test @@ -64,7 +64,7 @@ io.ebean ebean-ddl-generator - 12.8.0-SNAPSHOT + 12.8.0 test diff --git a/pom.xml b/pom.xml index 1b27fe76d..a8c358a93 100644 --- a/pom.xml +++ b/pom.xml @@ -9,7 +9,7 @@ io.ebean ebean-parent - 12.8.0-SNAPSHOT + 12.8.0 pom ebean parent @@ -18,7 +18,7 @@ scm:git:git@github.com:ebean-orm/ebean.git - ebean-parent-12.6.5 + ebean-parent-12.8.0 diff --git a/querybean-generator/pom.xml b/querybean-generator/pom.xml index 4abbf7db8..5bde1c208 100644 --- a/querybean-generator/pom.xml +++ b/querybean-generator/pom.xml @@ -4,7 +4,7 @@ ebean-parent io.ebean - 12.8.0-SNAPSHOT + 12.8.0 querybean generator From f7905c8e949323829f55be3125160885984fff5a Mon Sep 17 00:00:00 2001 From: rob bygrave Date: Thu, 18 Mar 2021 22:30:17 +1300 Subject: [PATCH 156/447] [maven-release-plugin] prepare for next development iteration --- ebean-api/pom.xml | 2 +- ebean-autotune/pom.xml | 4 ++-- ebean-bom/pom.xml | 30 +++++++++++++++--------------- ebean-core-type/pom.xml | 4 ++-- ebean-core/pom.xml | 8 ++++---- ebean-ddl-generator/pom.xml | 6 +++--- ebean-externalmapping-api/pom.xml | 2 +- ebean-externalmapping-xml/pom.xml | 8 ++++---- ebean-postgis/pom.xml | 6 +++--- ebean-querybean/pom.xml | 10 +++++----- ebean-redis/pom.xml | 12 ++++++------ ebean-test/pom.xml | 6 +++--- ebean/pom.xml | 8 ++++---- kotlin-querybean-generator/pom.xml | 8 ++++---- pom.xml | 2 +- querybean-generator/pom.xml | 2 +- 16 files changed, 59 insertions(+), 59 deletions(-) diff --git a/ebean-api/pom.xml b/ebean-api/pom.xml index b14da4897..ce3ba3688 100644 --- a/ebean-api/pom.xml +++ b/ebean-api/pom.xml @@ -4,7 +4,7 @@ ebean-parent io.ebean - 12.8.0 + 12.8.1-SNAPSHOT ebean api diff --git a/ebean-autotune/pom.xml b/ebean-autotune/pom.xml index 2f2195bae..5c081a9df 100644 --- a/ebean-autotune/pom.xml +++ b/ebean-autotune/pom.xml @@ -4,7 +4,7 @@ ebean-parent io.ebean - 12.8.0 + 12.8.1-SNAPSHOT @@ -26,7 +26,7 @@ io.ebean ebean-core - 12.8.0 + 12.8.1-SNAPSHOT provided diff --git a/ebean-bom/pom.xml b/ebean-bom/pom.xml index a1ff72303..e96c248d7 100644 --- a/ebean-bom/pom.xml +++ b/ebean-bom/pom.xml @@ -4,7 +4,7 @@ ebean-parent io.ebean - 12.8.0 + 12.8.1-SNAPSHOT ebean bom @@ -81,88 +81,88 @@ io.ebean ebean - 12.8.0 + 12.8.1-SNAPSHOT io.ebean ebean-api - 12.8.0 + 12.8.1-SNAPSHOT io.ebean ebean-core - 12.8.0 + 12.8.1-SNAPSHOT io.ebean ebean-core-type - 12.8.0 + 12.8.1-SNAPSHOT io.ebean ebean-ddl-generator - 12.8.0 + 12.8.1-SNAPSHOT io.ebean ebean-externalmapping-api - 12.8.0 + 12.8.1-SNAPSHOT io.ebean ebean-externalmapping-xml - 12.8.0 + 12.8.1-SNAPSHOT io.ebean ebean-autotune - 12.8.0 + 12.8.1-SNAPSHOT io.ebean ebean-querybean - 12.8.0 + 12.8.1-SNAPSHOT io.ebean querybean-generator - 12.8.0 + 12.8.1-SNAPSHOT provided io.ebean kotlin-querybean-generator - 12.8.0 + 12.8.1-SNAPSHOT provided io.ebean ebean-test - 12.8.0 + 12.8.1-SNAPSHOT test io.ebean ebean-postgis - 12.8.0 + 12.8.1-SNAPSHOT io.ebean ebean-redis - 12.8.0 + 12.8.1-SNAPSHOT diff --git a/ebean-core-type/pom.xml b/ebean-core-type/pom.xml index 7261bb679..386d6d511 100644 --- a/ebean-core-type/pom.xml +++ b/ebean-core-type/pom.xml @@ -4,7 +4,7 @@ ebean-parent io.ebean - 12.8.0 + 12.8.1-SNAPSHOT ebean-core-type @@ -16,7 +16,7 @@ io.ebean ebean-api - 12.8.0 + 12.8.1-SNAPSHOT diff --git a/ebean-core/pom.xml b/ebean-core/pom.xml index 9541f5126..9d7f1e236 100644 --- a/ebean-core/pom.xml +++ b/ebean-core/pom.xml @@ -3,7 +3,7 @@ ebean-parent io.ebean - 12.8.0 + 12.8.1-SNAPSHOT ebean-core @@ -87,19 +87,19 @@ io.ebean ebean-api - 12.8.0 + 12.8.1-SNAPSHOT io.ebean ebean-core-type - 12.8.0 + 12.8.1-SNAPSHOT io.ebean ebean-externalmapping-api - 12.8.0 + 12.8.1-SNAPSHOT diff --git a/ebean-ddl-generator/pom.xml b/ebean-ddl-generator/pom.xml index 102246313..1ef8c0725 100644 --- a/ebean-ddl-generator/pom.xml +++ b/ebean-ddl-generator/pom.xml @@ -4,7 +4,7 @@ ebean-parent io.ebean - 12.8.0 + 12.8.1-SNAPSHOT ebean ddl generation @@ -29,14 +29,14 @@ io.ebean ebean-core-type - 12.8.0 + 12.8.1-SNAPSHOT provided io.ebean ebean-core - 12.8.0 + 12.8.1-SNAPSHOT provided diff --git a/ebean-externalmapping-api/pom.xml b/ebean-externalmapping-api/pom.xml index a0c1e9a82..4efce3a65 100644 --- a/ebean-externalmapping-api/pom.xml +++ b/ebean-externalmapping-api/pom.xml @@ -4,7 +4,7 @@ ebean-parent io.ebean - 12.8.0 + 12.8.1-SNAPSHOT ebean external mapping api diff --git a/ebean-externalmapping-xml/pom.xml b/ebean-externalmapping-xml/pom.xml index f1017d3cf..cd885187e 100644 --- a/ebean-externalmapping-xml/pom.xml +++ b/ebean-externalmapping-xml/pom.xml @@ -4,7 +4,7 @@ ebean-parent io.ebean - 12.8.0 + 12.8.1-SNAPSHOT @@ -33,7 +33,7 @@ io.ebean ebean-externalmapping-api - 12.8.0 + 12.8.1-SNAPSHOT @@ -59,14 +59,14 @@ io.ebean ebean-core - 12.8.0 + 12.8.1-SNAPSHOT test io.ebean ebean-ddl-generator - 12.8.0 + 12.8.1-SNAPSHOT test diff --git a/ebean-postgis/pom.xml b/ebean-postgis/pom.xml index a5e3c1514..5b4bceec8 100644 --- a/ebean-postgis/pom.xml +++ b/ebean-postgis/pom.xml @@ -4,7 +4,7 @@ ebean-parent io.ebean - 12.8.0 + 12.8.1-SNAPSHOT ebean postgis @@ -23,7 +23,7 @@ io.ebean ebean-core - 12.8.0 + 12.8.1-SNAPSHOT provided @@ -74,7 +74,7 @@ io.ebean ebean-test - 12.8.0 + 12.8.1-SNAPSHOT test diff --git a/ebean-querybean/pom.xml b/ebean-querybean/pom.xml index 5ec002181..51f490b3b 100644 --- a/ebean-querybean/pom.xml +++ b/ebean-querybean/pom.xml @@ -4,7 +4,7 @@ ebean-parent io.ebean - 12.8.0 + 12.8.1-SNAPSHOT ebean querybean @@ -17,7 +17,7 @@ io.ebean ebean-core - 12.8.0 + 12.8.1-SNAPSHOT provided @@ -57,21 +57,21 @@ io.ebean ebean-ddl-generator - 12.8.0 + 12.8.1-SNAPSHOT test io.ebean querybean-generator - 12.8.0 + 12.8.1-SNAPSHOT test io.ebean ebean-test - 12.8.0 + 12.8.1-SNAPSHOT test diff --git a/ebean-redis/pom.xml b/ebean-redis/pom.xml index 86c4572b5..2a346b178 100644 --- a/ebean-redis/pom.xml +++ b/ebean-redis/pom.xml @@ -4,7 +4,7 @@ ebean-parent io.ebean - 12.8.0 + 12.8.1-SNAPSHOT ebean-redis @@ -22,35 +22,35 @@ io.ebean ebean-api - 12.8.0 + 12.8.1-SNAPSHOT provided io.ebean ebean-core - 12.8.0 + 12.8.1-SNAPSHOT provided io.ebean ebean-querybean - 12.8.0 + 12.8.1-SNAPSHOT test io.ebean querybean-generator - 12.8.0 + 12.8.1-SNAPSHOT test io.ebean ebean-test - 12.8.0 + 12.8.1-SNAPSHOT test diff --git a/ebean-test/pom.xml b/ebean-test/pom.xml index 5f9131316..c32dab0c2 100644 --- a/ebean-test/pom.xml +++ b/ebean-test/pom.xml @@ -4,7 +4,7 @@ ebean-parent io.ebean - 12.8.0 + 12.8.1-SNAPSHOT ebean test @@ -29,14 +29,14 @@ io.ebean ebean-core - 12.8.0 + 12.8.1-SNAPSHOT provided io.ebean ebean-ddl-generator - 12.8.0 + 12.8.1-SNAPSHOT diff --git a/ebean/pom.xml b/ebean/pom.xml index 42f88d25b..33c8aeb60 100644 --- a/ebean/pom.xml +++ b/ebean/pom.xml @@ -4,7 +4,7 @@ ebean-parent io.ebean - 12.8.0 + 12.8.1-SNAPSHOT ebean composite @@ -22,20 +22,20 @@ io.ebean ebean-api - 12.8.0 + 12.8.1-SNAPSHOT io.ebean ebean-core - 12.8.0 + 12.8.1-SNAPSHOT io.ebean ebean-querybean - 12.8.0 + 12.8.1-SNAPSHOT diff --git a/kotlin-querybean-generator/pom.xml b/kotlin-querybean-generator/pom.xml index 339bee3af..7016e2aa4 100644 --- a/kotlin-querybean-generator/pom.xml +++ b/kotlin-querybean-generator/pom.xml @@ -4,7 +4,7 @@ ebean-parent io.ebean - 12.8.0 + 12.8.1-SNAPSHOT kotlin querybean generator @@ -29,7 +29,7 @@ io.ebean ebean-querybean - 12.8.0 + 12.8.1-SNAPSHOT test @@ -43,7 +43,7 @@ io.ebean ebean-core - 12.8.0 + 12.8.1-SNAPSHOT test @@ -64,7 +64,7 @@ io.ebean ebean-ddl-generator - 12.8.0 + 12.8.1-SNAPSHOT test diff --git a/pom.xml b/pom.xml index a8c358a93..dbd383225 100644 --- a/pom.xml +++ b/pom.xml @@ -9,7 +9,7 @@ io.ebean ebean-parent - 12.8.0 + 12.8.1-SNAPSHOT pom ebean parent diff --git a/querybean-generator/pom.xml b/querybean-generator/pom.xml index 5bde1c208..6e7bf295f 100644 --- a/querybean-generator/pom.xml +++ b/querybean-generator/pom.xml @@ -4,7 +4,7 @@ ebean-parent io.ebean - 12.8.0 + 12.8.1-SNAPSHOT querybean generator From 00b0fcaeb3e81417a8f211b3094f2e052136bbc4 Mon Sep 17 00:00:00 2001 From: Rob Bygrave Date: Mon, 22 Mar 2021 23:24:16 +1300 Subject: [PATCH 157/447] #2202 - kotlin-maven-plugin issue with JDK 16 Temporary modify tests to not invoke the kotlin-maven-plugin while adding JDK 16 specific tests. Hitting error InaccessibleObjectException: Unable to make protected void java.util.ResourceBundle.setParent(java.util.ResourceBundle) accessible: module java.base does not "opens java.util" to unnamed module @62732be7 --- kotlin-querybean-generator/pom.xml | 77 +++++++++++++++--------------- 1 file changed, 39 insertions(+), 38 deletions(-) diff --git a/kotlin-querybean-generator/pom.xml b/kotlin-querybean-generator/pom.xml index 7016e2aa4..cf3dca074 100644 --- a/kotlin-querybean-generator/pom.xml +++ b/kotlin-querybean-generator/pom.xml @@ -12,7 +12,7 @@ kotlin-querybean-generator - 1.4.21 + 1.4.31 @@ -81,46 +81,47 @@ src/test/kotlin - - org.jetbrains.kotlin - kotlin-maven-plugin - ${kotlin.version} - - - test-compile - test-compile - - test-compile - - - - test-kapt - - test-kapt - - - - src/test/kotlin - - - - - - - - - - - - - - 1.8 - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + org.apache.maven.plugins maven-compiler-plugin - 3.2 + 3.8.1 default-testCompile From 78965c1ac4476ea3f6fc03b945f9b8582cbc52f6 Mon Sep 17 00:00:00 2001 From: Rob Bygrave Date: Mon, 22 Mar 2021 23:43:35 +1300 Subject: [PATCH 158/447] #2203 - Support use of Java Record type with @Entity, @Embeddable @IdClass Allow java.lang.Record to be a root level parent for entity beans etc --- .../ebeaninternal/server/deploy/BeanDescriptorManager.java | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/deploy/BeanDescriptorManager.java b/ebean-core/src/main/java/io/ebeaninternal/server/deploy/BeanDescriptorManager.java index 0cb5deeaa..dca6b2b09 100644 --- a/ebean-core/src/main/java/io/ebeaninternal/server/deploy/BeanDescriptorManager.java +++ b/ebean-core/src/main/java/io/ebeaninternal/server/deploy/BeanDescriptorManager.java @@ -93,6 +93,7 @@ public class BeanDescriptorManager implements BeanDescriptorMap { private static final Logger logger = LoggerFactory.getLogger(BeanDescriptorManager.class); private static final BeanDescComparator beanDescComparator = new BeanDescComparator(); + public static final String JAVA_LANG_RECORD = "java.lang.Record"; private final ReadAnnotations readAnnotations; private final TransientProperties transientProperties; @@ -1418,14 +1419,10 @@ public class BeanDescriptorManager implements BeanDescriptorMap { */ private void checkInheritedClasses(Class beanClass) { Class superclass = beanClass.getSuperclass(); - if (Object.class.equals(superclass)) { + if (Object.class.equals(superclass) || Model.class.equals(superclass) || JAVA_LANG_RECORD.equals(superclass.getName())) { // we got to the top of the inheritance return; } - if (Model.class.equals(superclass)) { - // top of the inheritance. Not enhancing Model at this stage - return; - } if (!EntityBean.class.isAssignableFrom(superclass)) { if (isMappedSuperWithNoProperties(superclass)) { // ok to stop and treat just the same as Object.class From 94bab5f83b7e0b959dc2e63e7a3e4c7609450bf0 Mon Sep 17 00:00:00 2001 From: Rob Bygrave Date: Mon, 22 Mar 2021 23:44:10 +1300 Subject: [PATCH 159/447] #2203 - Support use of Java Record type with @Entity, @Embeddable @IdClass Add tests for entity use of record type --- tests/pom.xml | 23 +++++++ tests/test-java16/pom.xml | 69 +++++++++++++++++++ .../java/org/example/records/BaseModel.java | 35 ++++++++++ .../main/java/org/example/records/Course.java | 33 +++++++++ .../example/records/CourseRecordEntity.java | 13 ++++ .../records/CourseRecordEntityTest.java | 40 +++++++++++ .../records/DtoQueryUsingRecordsTest.java | 59 ++++++++++++++++ .../src/test/resources/application-test.yaml | 6 ++ .../src/test/resources/logback-test.xml | 22 ++++++ 9 files changed, 300 insertions(+) create mode 100644 tests/pom.xml create mode 100644 tests/test-java16/pom.xml create mode 100644 tests/test-java16/src/main/java/org/example/records/BaseModel.java create mode 100644 tests/test-java16/src/main/java/org/example/records/Course.java create mode 100644 tests/test-java16/src/main/java/org/example/records/CourseRecordEntity.java create mode 100644 tests/test-java16/src/test/java/org/example/records/CourseRecordEntityTest.java create mode 100644 tests/test-java16/src/test/java/org/example/records/DtoQueryUsingRecordsTest.java create mode 100644 tests/test-java16/src/test/resources/application-test.yaml create mode 100644 tests/test-java16/src/test/resources/logback-test.xml diff --git a/tests/pom.xml b/tests/pom.xml new file mode 100644 index 000000000..2c79d71fa --- /dev/null +++ b/tests/pom.xml @@ -0,0 +1,23 @@ + + + 4.0.0 + + org.avaje + java8-oss + 2.3 + + + io.ebean + tests + 1.0 + pom + + tests + test modules + + + test-java16 + + + + diff --git a/tests/test-java16/pom.xml b/tests/test-java16/pom.xml new file mode 100644 index 000000000..21dfa7852 --- /dev/null +++ b/tests/test-java16/pom.xml @@ -0,0 +1,69 @@ + + + 4.0.0 + + + + + + + io.ebean + test-java16 + 1.0 + + + 3.8.1 + + + + + io.ebean + ebean + 12.8.1-SNAPSHOT + + + + ch.qos.logback + logback-classic + 1.2.3 + + + + io.ebean + ebean-test + 12.8.1-SNAPSHOT + test + + + + org.avaje.composite + junit + 5.0 + test + + + + + + + org.apache.maven.plugins + maven-compiler-plugin + ${maven-compiler-plugin.version} + + 16 + 16 + 16 + + + io.ebean + querybean-generator + 12.8.1-SNAPSHOT + + + + + + + + + diff --git a/tests/test-java16/src/main/java/org/example/records/BaseModel.java b/tests/test-java16/src/main/java/org/example/records/BaseModel.java new file mode 100644 index 000000000..b5116e638 --- /dev/null +++ b/tests/test-java16/src/main/java/org/example/records/BaseModel.java @@ -0,0 +1,35 @@ +package org.example.records; + +import io.ebean.Model; +import io.ebean.annotation.Identity; + +import javax.persistence.Id; +import javax.persistence.MappedSuperclass; +import javax.persistence.Version; + +@Identity(start = 1000, cache = 100) +@MappedSuperclass +public class BaseModel extends Model { + + @Id + long id; + + @Version + long version; + + public long getId() { + return id; + } + + public void setId(long id) { + this.id = id; + } + + public long getVersion() { + return version; + } + + public void setVersion(long version) { + this.version = version; + } +} diff --git a/tests/test-java16/src/main/java/org/example/records/Course.java b/tests/test-java16/src/main/java/org/example/records/Course.java new file mode 100644 index 000000000..19e8d09fe --- /dev/null +++ b/tests/test-java16/src/main/java/org/example/records/Course.java @@ -0,0 +1,33 @@ +package org.example.records; + +import io.ebean.annotation.Length; + +import javax.persistence.Entity; +import javax.persistence.Table; + +@Entity +@Table(name = "course") +public class Course extends BaseModel { + + @Length(200) + final String name; + + @Length(400) + String summary; + + public Course(String name) { + this.name = name; + } + + public String getName() { + return name; + } + + public String getSummary() { + return summary; + } + + public void setSummary(String summary) { + this.summary = summary; + } +} diff --git a/tests/test-java16/src/main/java/org/example/records/CourseRecordEntity.java b/tests/test-java16/src/main/java/org/example/records/CourseRecordEntity.java new file mode 100644 index 000000000..dc95a8723 --- /dev/null +++ b/tests/test-java16/src/main/java/org/example/records/CourseRecordEntity.java @@ -0,0 +1,13 @@ +package org.example.records; + +import io.ebean.annotation.Identity; + +import javax.persistence.Entity; +import javax.persistence.Id; +import javax.persistence.Table; + +@Identity(start = 1000) +@Entity +@Table(name="course_rec") +public record CourseRecordEntity(@Id long id, String name, String notes) { +} diff --git a/tests/test-java16/src/test/java/org/example/records/CourseRecordEntityTest.java b/tests/test-java16/src/test/java/org/example/records/CourseRecordEntityTest.java new file mode 100644 index 000000000..63e0c7d84 --- /dev/null +++ b/tests/test-java16/src/test/java/org/example/records/CourseRecordEntityTest.java @@ -0,0 +1,40 @@ +package org.example.records; + +import io.ebean.DB; +import org.example.records.query.QCourseRecordEntity; +import org.junit.jupiter.api.Test; + +import static org.assertj.core.api.Assertions.assertThat; + +class CourseRecordEntityTest { + + @Test + void record_insert_withGivenIdValue() { + var course = new CourseRecordEntity(42, "SuppliedId", "Record"); + DB.save(course); + assertThat(course.id()).isEqualTo(42); + + var found = new QCourseRecordEntity() + .name.startsWith("SuppliedId") + .findOneOrEmpty(); + + assertThat(found).isPresent(); + assertThat(found.get().id()).isEqualTo(42L); + assertThat(found.get().notes()).isEqualTo("Record"); + } + + @Test + void record_insert_usingGeneratedId() { + var course2 = new CourseRecordEntity(0, "Second", "Record with generated id"); + DB.save(course2); + // as using @Identity(start = 1000) + assertThat(course2.id()).isEqualTo(1000); + + var second = new QCourseRecordEntity() + .name.startsWith("Second") + .findOneOrEmpty(); + + assertThat(second).isPresent(); + assertThat(second.get().notes()).isEqualTo("Record with generated id"); + } +} diff --git a/tests/test-java16/src/test/java/org/example/records/DtoQueryUsingRecordsTest.java b/tests/test-java16/src/test/java/org/example/records/DtoQueryUsingRecordsTest.java new file mode 100644 index 000000000..e64c15b1c --- /dev/null +++ b/tests/test-java16/src/test/java/org/example/records/DtoQueryUsingRecordsTest.java @@ -0,0 +1,59 @@ +package org.example.records; + +import io.ebean.DB; +import org.example.records.query.QCourse; +import org.junit.jupiter.api.Test; + +import java.util.List; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.example.records.query.QCourse.Alias.id; +import static org.example.records.query.QCourse.Alias.name; + +class DtoQueryUsingRecordsTest { + + @Test + void dtoQuery_projectRecords() { + + var course = new Course("Calculus"); + course.setSummary("Something here"); + course.save(); + + performOrmQuery(); + + records_via_SqlDtoQuery(course); + records_via_OrmQueryToDtoQuery(course); + + course.delete(); + } + + private void performOrmQuery() { + List courses = new QCourse() + .name.startsWith("Calc") + .findList(); + + assertThat(courses).hasSize(1); + } + + private void records_via_SqlDtoQuery(Course course) { + List records = DB.findDto(Foo.class, "select id, name from course where name like ?") + .setParameter("Calc%") + .findList(); + + assertThat(records).hasSize(1); + assertThat(records.get(0).name()).isEqualTo(course.getName()); + } + + private void records_via_OrmQueryToDtoQuery(Course course) { + List records2 = new QCourse() + .select(id, name ) + .name.startsWith("Calc") + .asDto(Foo.class) + .findList(); + + assertThat(records2).hasSize(1); + assertThat(records2.get(0).name()).isEqualTo(course.getName()); + } + + public record Foo(long id, String name){} +} diff --git a/tests/test-java16/src/test/resources/application-test.yaml b/tests/test-java16/src/test/resources/application-test.yaml new file mode 100644 index 000000000..029b11023 --- /dev/null +++ b/tests/test-java16/src/test/resources/application-test.yaml @@ -0,0 +1,6 @@ +ebean: + test: + platform: h2 + ddlMode: dropCreate + dbName: foo + diff --git a/tests/test-java16/src/test/resources/logback-test.xml b/tests/test-java16/src/test/resources/logback-test.xml new file mode 100644 index 000000000..ce7ad5968 --- /dev/null +++ b/tests/test-java16/src/test/resources/logback-test.xml @@ -0,0 +1,22 @@ + + + + %d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n + + + + + + + + + + + + + + + + + + From 548454c90d7d920efb6e9b217d084924b2f6b6f1 Mon Sep 17 00:00:00 2001 From: Rob Bygrave Date: Mon, 22 Mar 2021 23:57:14 +1300 Subject: [PATCH 160/447] #2203 - Support use of Java Record type with @Entity, @Embeddable @IdClass Add tests for embedded use of record type --- .../java/org/example/records/Address.java | 7 +++ .../java/org/example/records/Contact.java | 58 +++++++++++++++++++ .../example/records/RecordAsEmbeddedTest.java | 48 +++++++++++++++ 3 files changed, 113 insertions(+) create mode 100644 tests/test-java16/src/main/java/org/example/records/Address.java create mode 100644 tests/test-java16/src/main/java/org/example/records/Contact.java create mode 100644 tests/test-java16/src/test/java/org/example/records/RecordAsEmbeddedTest.java diff --git a/tests/test-java16/src/main/java/org/example/records/Address.java b/tests/test-java16/src/main/java/org/example/records/Address.java new file mode 100644 index 000000000..2ac531402 --- /dev/null +++ b/tests/test-java16/src/main/java/org/example/records/Address.java @@ -0,0 +1,7 @@ +package org.example.records; + +import javax.persistence.Embeddable; + +@Embeddable +public record Address (String line1, String line2, String city) { +} diff --git a/tests/test-java16/src/main/java/org/example/records/Contact.java b/tests/test-java16/src/main/java/org/example/records/Contact.java new file mode 100644 index 000000000..871862f21 --- /dev/null +++ b/tests/test-java16/src/main/java/org/example/records/Contact.java @@ -0,0 +1,58 @@ +package org.example.records; + +import io.ebean.Model; + +import javax.persistence.Embedded; +import javax.persistence.Entity; +import javax.persistence.Id; +import javax.persistence.Version; + +@Entity +public class Contact extends Model { + + @Id + private long id; + + @Version + private long version; + + private final String name; + + @Embedded(prefix = "home_") + private Address homeAddress; + + @Embedded(prefix = "work_") + private Address workAddress; + + public Contact(String name) { + this.name = name; + } + + public String getName() { + return name; + } + + public Address getHomeAddress() { + return homeAddress; + } + + public void setHomeAddress(Address homeAddress) { + this.homeAddress = homeAddress; + } + + public Address getWorkAddress() { + return workAddress; + } + + public void setWorkAddress(Address workAddress) { + this.workAddress = workAddress; + } + + public long getId() { + return id; + } + + public long getVersion() { + return version; + } +} diff --git a/tests/test-java16/src/test/java/org/example/records/RecordAsEmbeddedTest.java b/tests/test-java16/src/test/java/org/example/records/RecordAsEmbeddedTest.java new file mode 100644 index 000000000..271481468 --- /dev/null +++ b/tests/test-java16/src/test/java/org/example/records/RecordAsEmbeddedTest.java @@ -0,0 +1,48 @@ +package org.example.records; + +import org.example.records.query.QContact; +import org.junit.jupiter.api.Test; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.example.records.query.QContact.Alias.homeAddress; +import static org.example.records.query.QContact.Alias.name; + +public class RecordAsEmbeddedTest { + + @Test + void insert_query() { + + var contact = new Contact("Rob"); + contact.setWorkAddress(new Address("45 work", "workling", "wo")); + contact.setHomeAddress(new Address("94 home st", "homeline", "wo")); + + contact.save(); + + Contact found = new QContact() + .id.eq(contact.getId()) + .findOne(); + + assertThat(found.getWorkAddress().toString()).isEqualTo("Address[line1=45 work, line2=workling, city=wo]"); + assertThat(found.getHomeAddress().toString()).isEqualTo("Address[line1=94 home st, line2=homeline, city=wo]"); + + Contact foundPartial = new QContact() + .select(name, homeAddress) + .id.eq(contact.getId()) + .findOne(); + + // invoke lazy loading on getWorkAddress + assertThat(foundPartial.getWorkAddress().toString()).isEqualTo("Address[line1=45 work, line2=workling, city=wo]"); + assertThat(foundPartial.getHomeAddress().toString()).isEqualTo("Address[line1=94 home st, line2=homeline, city=wo]"); + + Contact foundNoLazyLoading = new QContact() + .select(name, homeAddress) + .setDisableLazyLoading(true) + .id.eq(contact.getId()) + .findOne(); + + // no lazy loading on getWorkAddress this time + assertThat(foundNoLazyLoading.getWorkAddress()).isNull(); + assertThat(foundNoLazyLoading.getHomeAddress().toString()).isEqualTo("Address[line1=94 home st, line2=homeline, city=wo]"); + + } +} From 53c903fa4815ddda4aa07079790a247cbab9cecd Mon Sep 17 00:00:00 2001 From: Rob Bygrave Date: Tue, 23 Mar 2021 00:10:28 +1300 Subject: [PATCH 161/447] #2203 - Support use of Java Record type with @Entity, @Embeddable @IdClass Add tests for EmbeddedId use of record type --- .../java/org/example/records/UserRole.java | 36 ++++++++++++++++++ .../java/org/example/records/UserRoleId.java | 7 ++++ .../org/example/records/UserRoleTest.java | 38 +++++++++++++++++++ 3 files changed, 81 insertions(+) create mode 100644 tests/test-java16/src/main/java/org/example/records/UserRole.java create mode 100644 tests/test-java16/src/main/java/org/example/records/UserRoleId.java create mode 100644 tests/test-java16/src/test/java/org/example/records/UserRoleTest.java diff --git a/tests/test-java16/src/main/java/org/example/records/UserRole.java b/tests/test-java16/src/main/java/org/example/records/UserRole.java new file mode 100644 index 000000000..682e61f4a --- /dev/null +++ b/tests/test-java16/src/main/java/org/example/records/UserRole.java @@ -0,0 +1,36 @@ +package org.example.records; + +import io.ebean.Model; + +import javax.persistence.EmbeddedId; +import javax.persistence.Entity; +import javax.persistence.Version; + +@Entity +public class UserRole extends Model { + + @EmbeddedId + final UserRoleId id; + + String note; + + @Version + long version; + + public UserRole(UserRoleId id, String note) { + this.id = id; + this.note = note; + } + + public UserRoleId getId() { + return id; + } + + public String getNote() { + return note; + } + + public long getVersion() { + return version; + } +} diff --git a/tests/test-java16/src/main/java/org/example/records/UserRoleId.java b/tests/test-java16/src/main/java/org/example/records/UserRoleId.java new file mode 100644 index 000000000..a0807de0a --- /dev/null +++ b/tests/test-java16/src/main/java/org/example/records/UserRoleId.java @@ -0,0 +1,7 @@ +package org.example.records; + +import javax.persistence.Embeddable; + +@Embeddable +public record UserRoleId(Integer userId, String roleId) { +} diff --git a/tests/test-java16/src/test/java/org/example/records/UserRoleTest.java b/tests/test-java16/src/test/java/org/example/records/UserRoleTest.java new file mode 100644 index 000000000..1b4231b58 --- /dev/null +++ b/tests/test-java16/src/test/java/org/example/records/UserRoleTest.java @@ -0,0 +1,38 @@ +package org.example.records; + +import org.example.records.query.QUserRole; +import org.junit.jupiter.api.Test; + +import static org.assertj.core.api.Assertions.assertThat; + +class UserRoleTest { + + final UserRoleId id = new UserRoleId(42, "R7"); + + @Test + void id_equals() { + assertThat(id).isEqualTo(new UserRoleId(42, "R7")); + } + + @Test + void id_notEquals() { + assertThat(id).isNotEqualTo(new UserRoleId(43, "R7")); + assertThat(id).isNotEqualTo(new UserRoleId(42, "R8")); + } + + @Test + void insert_query() { + + var userRole = new UserRole(id, "hello"); + userRole.save(); + + UserRole found = new QUserRole() + .id.eq(new UserRoleId(42, "R7")) + .findOne(); + + UserRoleId id1 = found.getId(); + assertThat(id1).isEqualTo(id); + assertThat(id1.userId()).isEqualTo(42); + assertThat(id1.roleId()).isEqualTo("R7"); + } +} From 09a887aeb7df25466286bf7a8eaf7f388b8187d8 Mon Sep 17 00:00:00 2001 From: Rob Bygrave Date: Tue, 23 Mar 2021 00:19:52 +1300 Subject: [PATCH 162/447] #2203 - Support use of Java Record type with @Entity, @Embeddable @IdClass Add tests for IdClass use of record type --- .../java/org/example/records/UserSite.java | 51 +++++++++++++++++++ .../java/org/example/records/UserSiteId.java | 8 +++ .../example/records/RecordIdClassTest.java | 34 +++++++++++++ 3 files changed, 93 insertions(+) create mode 100644 tests/test-java16/src/main/java/org/example/records/UserSite.java create mode 100644 tests/test-java16/src/main/java/org/example/records/UserSiteId.java create mode 100644 tests/test-java16/src/test/java/org/example/records/RecordIdClassTest.java diff --git a/tests/test-java16/src/main/java/org/example/records/UserSite.java b/tests/test-java16/src/main/java/org/example/records/UserSite.java new file mode 100644 index 000000000..a8cf46449 --- /dev/null +++ b/tests/test-java16/src/main/java/org/example/records/UserSite.java @@ -0,0 +1,51 @@ +package org.example.records; + +import io.ebean.Model; + +import javax.persistence.*; +import java.util.UUID; + +@IdClass(UserSiteId.class) +@Entity +public class UserSite extends Model { + + @Id + final UUID userId; + + @Id + final UUID siteId; + + String note; + + @Version + long version; + + public UserSite(UUID userId, UUID siteId) { + this.userId = userId; + this.siteId = siteId; + } + + public UUID getUserId() { + return userId; + } + + public UUID getSiteId() { + return siteId; + } + + public void setNote(String note) { + this.note = note; + } + + public void setVersion(long version) { + this.version = version; + } + + public String getNote() { + return note; + } + + public long getVersion() { + return version; + } +} diff --git a/tests/test-java16/src/main/java/org/example/records/UserSiteId.java b/tests/test-java16/src/main/java/org/example/records/UserSiteId.java new file mode 100644 index 000000000..36c4dd599 --- /dev/null +++ b/tests/test-java16/src/main/java/org/example/records/UserSiteId.java @@ -0,0 +1,8 @@ +package org.example.records; + +import javax.persistence.Embeddable; +import java.util.UUID; + +@Embeddable +public record UserSiteId(UUID userId, UUID siteId) { +} diff --git a/tests/test-java16/src/test/java/org/example/records/RecordIdClassTest.java b/tests/test-java16/src/test/java/org/example/records/RecordIdClassTest.java new file mode 100644 index 000000000..47008c544 --- /dev/null +++ b/tests/test-java16/src/test/java/org/example/records/RecordIdClassTest.java @@ -0,0 +1,34 @@ +package org.example.records; + +import org.example.records.query.QUserSite; +import org.junit.jupiter.api.Test; + +import java.util.UUID; + +import static org.assertj.core.api.Assertions.assertThat; + +class RecordIdClassTest { + + @Test + void insert_query() { + + UUID userId = UUID.randomUUID(); + UUID siteId = UUID.randomUUID(); + + var userSite = new UserSite(userId, siteId); + userSite.setNote("HelloIdClass"); + userSite.save(); + + var id = new UserSiteId(userId, siteId); + + UserSite found = new QUserSite() + .setId(id) + .findOne(); + + assertThat(found.getUserId()).isEqualTo(userId); + assertThat(found.getSiteId()).isEqualTo(siteId); + assertThat(found.getNote()).isEqualTo("HelloIdClass"); + + + } +} From dd6a473008be0ee2c14c08f2012cd687cf68fa25 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonas=20P=C3=B6hler=20=28JPo=29?= Date: Mon, 22 Mar 2021 15:59:59 +0100 Subject: [PATCH 163/447] ADD: Test and possible fix for (C)LOBs being handed out of connnection-context MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Jonas Pöhler (JPo) --- .../server/rawsql/DRawSqlService.java | 21 ++++++ .../server/rawsql/TestRawSqlBuilder.java | 64 +++++++++++++++++++ 2 files changed, 85 insertions(+) diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/rawsql/DRawSqlService.java b/ebean-core/src/main/java/io/ebeaninternal/server/rawsql/DRawSqlService.java index 0b5eb4ad6..7c27264a8 100644 --- a/ebean-core/src/main/java/io/ebeaninternal/server/rawsql/DRawSqlService.java +++ b/ebean-core/src/main/java/io/ebeaninternal/server/rawsql/DRawSqlService.java @@ -9,6 +9,7 @@ import io.ebeaninternal.server.query.DefaultSqlRow; import java.sql.ResultSet; import java.sql.ResultSetMetaData; import java.sql.SQLException; +import java.sql.Types; public class DRawSqlService implements SpiRawSqlService { @@ -49,6 +50,26 @@ public class DRawSqlService implements SpiRawSqlService { name = combine(meta.getSchemaName(i), meta.getTableName(i), name); } ret.put(name, resultSet.getObject(i)); + + // convert (C/B)LOBs to java objects. + // A java.sql.Clob depends on an open connection, so storing this object in a map + // that is accessed later, when the connection is closed, will result in a "connection is closed" exception. + // From the java.sql.Clob documentation: "... which means that a Clob object contains a logical pointer to the SQL CLOB + // data rather than the data itself." + switch (meta.getColumnType(i)) { + case Types.CLOB: + case Types.NCLOB: + ret.put(name, resultSet.getString(i)); + break; + + case Types.BLOB: + ret.put(name, resultSet.getBytes(i)); + break; + + default: + ret.put(name, resultSet.getObject(i)); + break; + } } return ret; } diff --git a/ebean-core/src/test/java/io/ebeaninternal/server/rawsql/TestRawSqlBuilder.java b/ebean-core/src/test/java/io/ebeaninternal/server/rawsql/TestRawSqlBuilder.java index 4e0a32e24..0fa4c746e 100644 --- a/ebean-core/src/test/java/io/ebeaninternal/server/rawsql/TestRawSqlBuilder.java +++ b/ebean-core/src/test/java/io/ebeaninternal/server/rawsql/TestRawSqlBuilder.java @@ -9,17 +9,26 @@ import io.ebean.RawSqlBuilder; import io.ebean.SqlRow; import io.ebean.annotation.ForPlatform; import io.ebean.annotation.Platform; +import io.ebean.datasource.DataSourceConfig; +import io.ebeaninternal.server.core.DefaultServer; import io.ebeaninternal.server.rawsql.SpiRawSql.Sql; import org.junit.Test; import org.tests.model.basic.Customer; +import org.tests.model.basic.EBasicClob; +import org.tests.model.basic.PersistentFileContent; import org.tests.model.basic.ResetBasicData; import org.tests.model.rawsql.ERawSqlAggBean; import javax.sql.DataSource; +import java.nio.charset.StandardCharsets; +import java.sql.Blob; import java.sql.Connection; +import java.sql.DriverManager; import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.SQLException; +import java.util.ArrayList; +import java.util.List; import static org.assertj.core.api.Assertions.assertThat; import static org.junit.Assert.assertEquals; @@ -283,4 +292,59 @@ public class TestRawSqlBuilder extends BaseTestCase { } } + @Test + public void testCLobClosedConnection() throws Exception { + final EBasicClob eBasicClob = new EBasicClob(); + eBasicClob.setName("eBasicClob"); + final String description = "This is the CLob description"; + eBasicClob.setDescription(description); + DB.save(eBasicClob); + + final String sql = "select description from ebasic_clob where id = ?"; + + List rows = new ArrayList<>(); + final DataSourceConfig config = ((DefaultServer) DB.getDefault()).getServerConfig().getDataSourceConfig(); + + try (Connection connection = DriverManager.getConnection(config.getUrl(), config.getUsername(), config.getPassword()); + PreparedStatement stmt = connection.prepareStatement(sql)) { + stmt.setLong(1, eBasicClob.getId()); + + try (ResultSet resultSet = stmt.executeQuery()) { + while (resultSet.next()) { + rows.add(RawSqlBuilder.sqlRow(resultSet, "true", false)); + } + } + } + + assertThat(rows).hasSize(1); + assertThat(rows.get(0).getString("description")).isEqualTo(description); + } + + @Test + public void testBLobClosedConnection() throws Exception { + final PersistentFileContent pfc = new PersistentFileContent(); + final byte[] bytes = "This is the blob as String".getBytes(StandardCharsets.UTF_8); + pfc.setContent(bytes); + DB.save(pfc); + + final String sql = "select content from persistent_file_content where id = ?"; + + List rows = new ArrayList<>(); + final DataSourceConfig config = ((DefaultServer) DB.getDefault()).getServerConfig().getDataSourceConfig(); + + try (Connection connection = DriverManager.getConnection(config.getUrl(), config.getUsername(), config.getPassword()); + PreparedStatement stmt = connection.prepareStatement(sql)) { + stmt.setLong(1, pfc.getId()); + + try (ResultSet resultSet = stmt.executeQuery()) { + while (resultSet.next()) { + rows.add(RawSqlBuilder.sqlRow(resultSet, "true", false)); + } + } + } + + assertThat(rows).hasSize(1); + assertThat(((Blob) rows.get(0).get("content")).getBytes(0, bytes.length)).isEqualTo(bytes); + } + } From b5cef354ad39ad70b07dca042e2f9f26b829ad02 Mon Sep 17 00:00:00 2001 From: Robin Bygrave Date: Tue, 23 Mar 2021 14:53:30 +1300 Subject: [PATCH 164/447] Refactor simplify LoadContext.getSecondaryQueriesMinBatchSize() No functional change here. Just move the constant into DLoadContext. --- .../src/main/java/io/ebeaninternal/api/LoadContext.java | 2 +- .../java/io/ebeaninternal/server/core/OrmQueryRequest.java | 4 ++-- .../io/ebeaninternal/server/loadcontext/DLoadContext.java | 4 ++-- .../main/java/io/ebeaninternal/server/query/CQueryEngine.java | 4 +--- 4 files changed, 6 insertions(+), 8 deletions(-) diff --git a/ebean-core/src/main/java/io/ebeaninternal/api/LoadContext.java b/ebean-core/src/main/java/io/ebeaninternal/api/LoadContext.java index 4ba56604f..51f02826c 100644 --- a/ebean-core/src/main/java/io/ebeaninternal/api/LoadContext.java +++ b/ebean-core/src/main/java/io/ebeaninternal/api/LoadContext.java @@ -16,7 +16,7 @@ public interface LoadContext { /** * Return the minimum batch size when using QueryIterator with query joins. */ - int getSecondaryQueriesMinBatchSize(int defaultQueryBatch); + int getSecondaryQueriesMinBatchSize(); /** * Execute any secondary (+query) queries if there are any defined. diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/core/OrmQueryRequest.java b/ebean-core/src/main/java/io/ebeaninternal/server/core/OrmQueryRequest.java index 9b0e1235e..3ec5deac7 100644 --- a/ebean-core/src/main/java/io/ebeaninternal/server/core/OrmQueryRequest.java +++ b/ebean-core/src/main/java/io/ebeaninternal/server/core/OrmQueryRequest.java @@ -173,8 +173,8 @@ public final class OrmQueryRequest extends BeanRequest implements SpiOrmQuery * iteration is fine. *

*/ - public int getSecondaryQueriesMinBatchSize(int defaultQueryBatch) { - return loadContext.getSecondaryQueriesMinBatchSize(defaultQueryBatch); + public int getSecondaryQueriesMinBatchSize() { + return loadContext.getSecondaryQueriesMinBatchSize(); } /** diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/loadcontext/DLoadContext.java b/ebean-core/src/main/java/io/ebeaninternal/server/loadcontext/DLoadContext.java index b5aa6f873..912b8fc0c 100644 --- a/ebean-core/src/main/java/io/ebeaninternal/server/loadcontext/DLoadContext.java +++ b/ebean-core/src/main/java/io/ebeaninternal/server/loadcontext/DLoadContext.java @@ -182,7 +182,7 @@ public class DLoadContext implements LoadContext { * Return the minimum batch size when using QueryIterator with query joins. */ @Override - public int getSecondaryQueriesMinBatchSize(int defaultQueryBatch) { + public int getSecondaryQueriesMinBatchSize() { if (secQuery == null) { return -1; } @@ -190,7 +190,7 @@ public class DLoadContext implements LoadContext { for (OrmQueryProperties aSecQuery : secQuery) { int batchSize = aSecQuery.getBatchSize(); if (batchSize == 0) { - batchSize = defaultQueryBatch; + batchSize = 100; } maxBatch = Math.max(maxBatch, batchSize); } diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/query/CQueryEngine.java b/ebean-core/src/main/java/io/ebeaninternal/server/query/CQueryEngine.java index 945b343ca..6e4804ca6 100644 --- a/ebean-core/src/main/java/io/ebeaninternal/server/query/CQueryEngine.java +++ b/ebean-core/src/main/java/io/ebeaninternal/server/query/CQueryEngine.java @@ -37,8 +37,6 @@ public class CQueryEngine { private static final Logger logger = LoggerFactory.getLogger(CQueryEngine.class); - private static final int defaultSecondaryQueryBatchSize = 100; - private static final String T0 = "t0"; private final int defaultFetchSizeFindList; @@ -214,7 +212,7 @@ public class CQueryEngine { logSql(cquery); } // first check batch sizes set on query joins - int iterateBufferSize = request.getSecondaryQueriesMinBatchSize(defaultSecondaryQueryBatchSize); + int iterateBufferSize = request.getSecondaryQueriesMinBatchSize(); if (iterateBufferSize < 1) { // not set on query joins so check if batch size set on query itself int queryBatch = request.getQuery().getLazyLoadBatchSize(); From 562d175de1f4435d623f2c4abeec82b38b609f41 Mon Sep 17 00:00:00 2001 From: Robin Bygrave Date: Tue, 23 Mar 2021 23:17:07 +1300 Subject: [PATCH 165/447] With FetchConfig.ofLazy() honor query.setLazyLoadBatchSize() Use 0 for default lazy batch such that it honors a value set via query.setLazyLoadBatchSize() --- .../src/main/java/io/ebean/FetchConfig.java | 21 ++++------ .../server/loadcontext/DLoadBaseContext.java | 8 +--- .../server/loadcontext/DLoadBeanContext.java | 4 +- .../server/loadcontext/DLoadContext.java | 42 ++++++++++--------- .../server/loadcontext/DLoadManyContext.java | 7 +--- .../test/java/io/ebean/FetchConfigTest.java | 3 +- .../server/grammer/ParseFetchConfigTest.java | 2 +- .../org/tests/query/TestQueryFindEach.java | 38 ++++++++++++----- 8 files changed, 68 insertions(+), 57 deletions(-) diff --git a/ebean-api/src/main/java/io/ebean/FetchConfig.java b/ebean-api/src/main/java/io/ebean/FetchConfig.java index 64f4c3daa..e2d4fbe35 100644 --- a/ebean-api/src/main/java/io/ebean/FetchConfig.java +++ b/ebean-api/src/main/java/io/ebean/FetchConfig.java @@ -46,7 +46,7 @@ public class FetchConfig implements Serializable { /** * Deprecated - migrate to one of the static factory methods like {@link FetchConfig#ofQuery()} - * + *

* Construct using default JOIN mode. */ @Deprecated @@ -89,7 +89,7 @@ public class FetchConfig implements Serializable { * Return FetchConfig to lazily load the relationship. */ public static FetchConfig ofLazy() { - return new FetchConfig(LAZY_MODE, 10); + return new FetchConfig(LAZY_MODE, 0); } /** @@ -110,8 +110,8 @@ public class FetchConfig implements Serializable { * We want to migrate away from mutating FetchConfig to a fully immutable FetchConfig. */ private FetchConfig mutate(int mode, int batchSize) { - if (batchSize < 1) { - throw new IllegalArgumentException("batch size "+batchSize+" must be > 0"); + if (batchSize < 0) { + throw new IllegalArgumentException("batch size " + batchSize + " must be > 0"); } this.mode = mode; this.batchSize = batchSize; @@ -124,7 +124,7 @@ public class FetchConfig implements Serializable { */ @Deprecated public FetchConfig lazy() { - return mutate(LAZY_MODE, 10); + return mutate(LAZY_MODE, 0); } /** @@ -137,7 +137,7 @@ public class FetchConfig implements Serializable { /** * Deprecated - migrate to FetchConfig.ofQuery(). - * + *

* Eagerly fetch the beans in this path as a separate query (rather than as * part of the main query). *

@@ -150,17 +150,15 @@ public class FetchConfig implements Serializable { /** * Deprecated - migrate to FetchConfig.ofQuery(batchSize). - * + *

* Eagerly fetch the beans in this path as a separate query (rather than as * part of the main query). *

* The queryBatchSize is the number of parent id's that this separate query * will load per batch. - *

*

* This will load all beans on this path eagerly unless a {@link #lazy(int)} * is also used. - *

* * @param batchSize the batch size used to load beans on this path */ @@ -171,13 +169,12 @@ public class FetchConfig implements Serializable { /** * Deprecated - migrate to FetchConfig.ofQuery(batchSize). - * + *

* Eagerly fetch the first batch of beans on this path. * This is similar to {@link #query(int)} but only fetches the first batch. *

* If there are more parent beans than the batch size then they will not be * loaded eagerly but instead use lazy loading. - *

* * @param batchSize the number of parent beans this path is populated for */ @@ -188,7 +185,7 @@ public class FetchConfig implements Serializable { /** * Deprecated - migrate to FetchConfig.ofCache(). - * + *

* Eagerly fetch the beans fetching the beans from the L2 bean cache * and using the DB for beans not in the cache. */ diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/loadcontext/DLoadBaseContext.java b/ebean-core/src/main/java/io/ebeaninternal/server/loadcontext/DLoadBaseContext.java index 1be4717e9..24233cf87 100644 --- a/ebean-core/src/main/java/io/ebeaninternal/server/loadcontext/DLoadBaseContext.java +++ b/ebean-core/src/main/java/io/ebeaninternal/server/loadcontext/DLoadBaseContext.java @@ -33,7 +33,7 @@ abstract class DLoadBaseContext { final boolean queryFetch; - DLoadBaseContext(DLoadContext parent, BeanDescriptor desc, String path, int defaultBatchSize, OrmQueryProperties queryProps) { + DLoadBaseContext(DLoadContext parent, BeanDescriptor desc, String path, OrmQueryProperties queryProps) { this.parent = parent; this.serverName = parent.getEbeanServer().getName(); this.desc = desc; @@ -42,11 +42,7 @@ abstract class DLoadBaseContext { this.hitCache = parent.isBeanCacheGet() && desc.isBeanCaching(); this.objectGraphNode = parent.getObjectGraphNode(path); this.queryFetch = queryProps != null && queryProps.isQueryFetch(); - this.batchSize = initBatchSize(defaultBatchSize, queryProps); - } - - private int initBatchSize(int batchSize, OrmQueryProperties queryProps) { - return queryProps == null ? batchSize : queryProps.getBatchSize(); + this.batchSize = parent.batchSize(queryProps); } /** diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/loadcontext/DLoadBeanContext.java b/ebean-core/src/main/java/io/ebeaninternal/server/loadcontext/DLoadBeanContext.java index d24a24532..25fffe5b7 100644 --- a/ebean-core/src/main/java/io/ebeaninternal/server/loadcontext/DLoadBeanContext.java +++ b/ebean-core/src/main/java/io/ebeaninternal/server/loadcontext/DLoadBeanContext.java @@ -31,8 +31,8 @@ class DLoadBeanContext extends DLoadBaseContext implements LoadBeanContext { private LoadBuffer currentBuffer; - DLoadBeanContext(DLoadContext parent, BeanDescriptor desc, String path, int defaultBatchSize, OrmQueryProperties queryProps) { - super(parent, desc, path, defaultBatchSize, queryProps); + DLoadBeanContext(DLoadContext parent, BeanDescriptor desc, String path, OrmQueryProperties queryProps) { + super(parent, desc, path, queryProps); // bufferList only required when using query joins (queryFetch) this.bufferList = (!queryFetch) ? null : new ArrayList<>(); this.currentBuffer = createBuffer(batchSize); diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/loadcontext/DLoadContext.java b/ebean-core/src/main/java/io/ebeaninternal/server/loadcontext/DLoadContext.java index 912b8fc0c..060633073 100644 --- a/ebean-core/src/main/java/io/ebeaninternal/server/loadcontext/DLoadContext.java +++ b/ebean-core/src/main/java/io/ebeaninternal/server/loadcontext/DLoadContext.java @@ -90,7 +90,7 @@ public class DLoadContext implements LoadContext { this.planLabel = null; this.profileLocation = null; this.profilingListener = null; - this.rootBeanContext = new DLoadBeanContext(this, rootDescriptor, null, defaultBatchSize, null); + this.rootBeanContext = new DLoadBeanContext(this, rootDescriptor, null, null); } private ObjectGraphOrigin initOrigin() { @@ -128,7 +128,7 @@ public class DLoadContext implements LoadContext { } // initialise rootBeanContext after origin and relativePath have been set - this.rootBeanContext = new DLoadBeanContext(this, rootDescriptor, null, defaultBatchSize, null); + this.rootBeanContext = new DLoadBeanContext(this, rootDescriptor, null, null); registerSecondaryQueries(secondaryQueries); } @@ -287,51 +287,55 @@ public class DLoadContext implements LoadContext { getManyContext(path, many).register(bc); } + int batchSize(OrmQueryProperties props) { + if (props == null) { + return defaultBatchSize; + } + int batchSize = props.getBatchSize(); + return batchSize == 0 ? defaultBatchSize : batchSize; + } + DLoadBeanContext getBeanContext(String path) { if (path == null) { return rootBeanContext; } - return beanMap.computeIfAbsent(path, p -> createBeanContext(p, defaultBatchSize, null)); + return beanMap.computeIfAbsent(path, p -> createBeanContext(p, null)); } DLoadBeanContext getBeanContextWithInherit(String path, BeanPropertyAssocOne property) { String key = path + ":" + property.getTargetDescriptor().getName(); - return beanMap.computeIfAbsent(key, p -> createBeanContext(property, path, defaultBatchSize, null)); + return beanMap.computeIfAbsent(key, p -> createBeanContext(property, path, null)); } private void registerSecondaryNode(boolean many, OrmQueryProperties props) { - int batchSize = props.getBatchSize(); - if (batchSize == 0) { - batchSize = defaultBatchSize; - } String path = props.getPath(); if (many) { - manyMap.put(path, createManyContext(path, batchSize, props)); + manyMap.put(path, createManyContext(path, props)); } else { - beanMap.put(path, createBeanContext(path, batchSize, props)); + beanMap.put(path, createBeanContext(path, props)); } } DLoadManyContext getManyContext(String path, BeanPropertyAssocMany many) { - return manyMap.computeIfAbsent(path, p -> createManyContext(p, many, defaultBatchSize)); + return manyMap.computeIfAbsent(path, p -> createManyContext(p, many)); } - private DLoadManyContext createManyContext(String path, BeanPropertyAssocMany many, int batchSize) { - return new DLoadManyContext(this, many, path, batchSize, null); + private DLoadManyContext createManyContext(String path, BeanPropertyAssocMany many) { + return new DLoadManyContext(this, many, path, null); } - private DLoadManyContext createManyContext(String path, int batchSize, OrmQueryProperties queryProps) { + private DLoadManyContext createManyContext(String path, OrmQueryProperties queryProps) { BeanPropertyAssocMany p = (BeanPropertyAssocMany) getBeanProperty(rootDescriptor, path); - return new DLoadManyContext(this, p, path, batchSize, queryProps); + return new DLoadManyContext(this, p, path, queryProps); } - private DLoadBeanContext createBeanContext(String path, int batchSize, OrmQueryProperties queryProps) { + private DLoadBeanContext createBeanContext(String path, OrmQueryProperties queryProps) { BeanPropertyAssoc p = (BeanPropertyAssoc) getBeanProperty(rootDescriptor, path); - return new DLoadBeanContext(this, p.getTargetDescriptor(), path, batchSize, queryProps); + return new DLoadBeanContext(this, p.getTargetDescriptor(), path, queryProps); } - private DLoadBeanContext createBeanContext(BeanPropertyAssoc property, String path, int batchSize, OrmQueryProperties queryProps) { - return new DLoadBeanContext(this, property.getTargetDescriptor(), path, batchSize, queryProps); + private DLoadBeanContext createBeanContext(BeanPropertyAssoc property, String path, OrmQueryProperties queryProps) { + return new DLoadBeanContext(this, property.getTargetDescriptor(), path, queryProps); } private BeanProperty getBeanProperty(BeanDescriptor desc, String path) { diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/loadcontext/DLoadManyContext.java b/ebean-core/src/main/java/io/ebeaninternal/server/loadcontext/DLoadManyContext.java index 7a51127d8..5035f0802 100644 --- a/ebean-core/src/main/java/io/ebeaninternal/server/loadcontext/DLoadManyContext.java +++ b/ebean-core/src/main/java/io/ebeaninternal/server/loadcontext/DLoadManyContext.java @@ -31,11 +31,8 @@ class DLoadManyContext extends DLoadBaseContext implements LoadManyContext { private LoadBuffer currentBuffer; - DLoadManyContext(DLoadContext parent, BeanPropertyAssocMany property, - String path, int defaultBatchSize, OrmQueryProperties queryProps) { - - super(parent, property.getBeanDescriptor(), path, defaultBatchSize, queryProps); - + DLoadManyContext(DLoadContext parent, BeanPropertyAssocMany property, String path, OrmQueryProperties queryProps) { + super(parent, property.getBeanDescriptor(), path, queryProps); this.property = property; this.docStoreMapped = property.isTargetDocStoreMapped(); // bufferList only required when using query joins (queryFetch) diff --git a/ebean-core/src/test/java/io/ebean/FetchConfigTest.java b/ebean-core/src/test/java/io/ebean/FetchConfigTest.java index abd09d692..f85808f6c 100644 --- a/ebean-core/src/test/java/io/ebean/FetchConfigTest.java +++ b/ebean-core/src/test/java/io/ebean/FetchConfigTest.java @@ -1,6 +1,5 @@ package io.ebean; -import io.ebean.FetchConfig; import org.junit.Test; import static org.assertj.core.api.Assertions.assertThat; @@ -10,7 +9,7 @@ public class FetchConfigTest { @Test public void testLazy() { FetchConfig config = new FetchConfig().lazy(); - assertThat(config.getBatchSize()).isEqualTo(10); + assertThat(config.getBatchSize()).isEqualTo(0); } @Test diff --git a/ebean-core/src/test/java/io/ebeaninternal/server/grammer/ParseFetchConfigTest.java b/ebean-core/src/test/java/io/ebeaninternal/server/grammer/ParseFetchConfigTest.java index a940cd26b..c4976f56d 100644 --- a/ebean-core/src/test/java/io/ebeaninternal/server/grammer/ParseFetchConfigTest.java +++ b/ebean-core/src/test/java/io/ebeaninternal/server/grammer/ParseFetchConfigTest.java @@ -19,7 +19,7 @@ public class ParseFetchConfigTest { @Test public void parseLazy() { FetchConfig lazy = ParseFetchConfig.parse("lazy"); - assertThat(lazy.getBatchSize()).isEqualTo(10); + assertThat(lazy.getBatchSize()).isEqualTo(0); } @Test diff --git a/ebean-core/src/test/java/org/tests/query/TestQueryFindEach.java b/ebean-core/src/test/java/org/tests/query/TestQueryFindEach.java index 1a2c16bab..b37f67279 100644 --- a/ebean-core/src/test/java/org/tests/query/TestQueryFindEach.java +++ b/ebean-core/src/test/java/org/tests/query/TestQueryFindEach.java @@ -169,22 +169,40 @@ public class TestQueryFindEach extends BaseTestCase { DB.find(OmBasicParent.class).delete(); insertData(); + test_setLazyLoadBatchSize_withFetchLazy(); + LoggedSqlCollector.start(); - try (final Transaction transaction = DB.beginTransaction()) { - // DB.find(OmBasicParent.class).findList(); - DB.find(OmBasicChild.class) - .setLazyLoadBatchSize(100) - //.fetchQuery("parent","name") - //.fetch("parent","name") - .findEach(child -> { - assertNotNull(child.getParent().getName()); - }); - } + + DB.find(OmBasicChild.class) + .setLazyLoadBatchSize(100) + .findEach(child -> { + assertNotNull(child.getParent().getName()); + }); final List sql = LoggedSqlCollector.stop(); assertThat(sql.size()).isLessThan(50); } + private void test_setLazyLoadBatchSize_withFetchLazy() { + + LoggedSqlCollector.start(); + + DB.find(OmBasicParent.class) + .setLazyLoadBatchSize(5) + .fetchLazy("children") + .setMaxRows(50) + .findEach(it -> { + it.getChildren().size(); + }); + + final List sql = LoggedSqlCollector.stop(); + assertThat(sql).hasSize(11); + assertThat(sql.get(0)).contains(" from om_basic_parent "); + for (int i = 1; i < 11; i++) { + assertThat(sql.get(i)).contains(" --bind(Array[5]"); + } + } + @Transactional(batchSize = 40) private void insertData() { for (int i = 0; i < 150; i++) { From abfa841ed787f332b637b9d7c16081b0bd92783f Mon Sep 17 00:00:00 2001 From: rob bygrave Date: Tue, 23 Mar 2021 23:51:07 +1300 Subject: [PATCH 166/447] #2205 - [oracle] Incorrect DDL generated for alter table add column --- .../ddlgeneration/platform/OracleDdl.java | 1 + .../platform/PlatformDdl_AlterColumnTest.java | 20 +++++++++++++++++++ 2 files changed, 21 insertions(+) diff --git a/ebean-ddl-generator/src/main/java/io/ebeaninternal/dbmigration/ddlgeneration/platform/OracleDdl.java b/ebean-ddl-generator/src/main/java/io/ebeaninternal/dbmigration/ddlgeneration/platform/OracleDdl.java index ea7d50d62..740870b09 100644 --- a/ebean-ddl-generator/src/main/java/io/ebeaninternal/dbmigration/ddlgeneration/platform/OracleDdl.java +++ b/ebean-ddl-generator/src/main/java/io/ebeaninternal/dbmigration/ddlgeneration/platform/OracleDdl.java @@ -15,6 +15,7 @@ public class OracleDdl extends PlatformDdl { this.dropConstraintIfExists = "drop constraint"; this.dropIndexIfExists = "drop index "; this.dropTableCascade = " cascade constraints purge"; + this.addColumn = "add"; this.alterColumn = "modify"; this.columnSetNotnull = "not null"; this.columnSetNull = "null"; diff --git a/ebean-ddl-generator/src/test/java/io/ebeaninternal/dbmigration/ddlgeneration/platform/PlatformDdl_AlterColumnTest.java b/ebean-ddl-generator/src/test/java/io/ebeaninternal/dbmigration/ddlgeneration/platform/PlatformDdl_AlterColumnTest.java index 3a0a8d727..a696c4e62 100644 --- a/ebean-ddl-generator/src/test/java/io/ebeaninternal/dbmigration/ddlgeneration/platform/PlatformDdl_AlterColumnTest.java +++ b/ebean-ddl-generator/src/test/java/io/ebeaninternal/dbmigration/ddlgeneration/platform/PlatformDdl_AlterColumnTest.java @@ -9,11 +9,15 @@ import io.ebean.config.dbplatform.mysql.MySqlPlatform; import io.ebean.config.dbplatform.oracle.OraclePlatform; import io.ebean.config.dbplatform.postgres.PostgresPlatform; import io.ebean.config.dbplatform.sqlserver.SqlServer17Platform; +import io.ebeaninternal.dbmigration.ddlgeneration.DdlWrite; import io.ebeaninternal.dbmigration.ddlgeneration.PlatformDdlBuilder; import io.ebeaninternal.dbmigration.migration.AlterColumn; import io.ebeaninternal.dbmigration.migration.AlterForeignKey; +import io.ebeaninternal.dbmigration.migration.Column; import org.junit.Test; +import java.io.IOException; + import static org.assertj.core.api.Assertions.assertThat; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNull; @@ -238,6 +242,22 @@ public class PlatformDdl_AlterColumnTest { assertTrue(exceptionCaught); } + @Test + public void oracle_alterTableAddColumn() throws IOException { + DdlWrite write = new DdlWrite(); + oraDdl.alterTableAddColumn(write.apply(), "my_table", simpleColumn(), false, "1"); + assertThat(write.apply().getBuffer()).isEqualTo("alter table my_table add my_column int default 1 not null;\n"); + } + + private Column simpleColumn() { + Column column = new Column(); + column.setName("my_column"); + column.setType("int"); + column.setNotnull(true); + column.setDefaultValue("1"); + return column; + } + @Test public void useIdentityType_h2() { assertEquals(h2Ddl.useIdentityType(null), IdType.IDENTITY); From f341ff0167cd6838b27039267c05558952d03723 Mon Sep 17 00:00:00 2001 From: rob bygrave Date: Tue, 23 Mar 2021 23:58:28 +1300 Subject: [PATCH 167/447] #2205 - [oracle] Incorrect DDL generated for alter table add column --- .../platform/BaseTableDdlTest.java | 2 +- .../dbmigration/migrationtest/oracle/1.1.sql | 28 +++++++++---------- .../dbmigration/migrationtest/oracle/1.3.sql | 10 +++---- 3 files changed, 20 insertions(+), 20 deletions(-) diff --git a/ebean-ddl-generator/src/test/java/io/ebeaninternal/dbmigration/ddlgeneration/platform/BaseTableDdlTest.java b/ebean-ddl-generator/src/test/java/io/ebeaninternal/dbmigration/ddlgeneration/platform/BaseTableDdlTest.java index c0bbd4df6..c32d6ad80 100644 --- a/ebean-ddl-generator/src/test/java/io/ebeaninternal/dbmigration/ddlgeneration/platform/BaseTableDdlTest.java +++ b/ebean-ddl-generator/src/test/java/io/ebeaninternal/dbmigration/ddlgeneration/platform/BaseTableDdlTest.java @@ -61,7 +61,7 @@ public class BaseTableDdlTest { ddlGen.alterTableAddColumn(write.apply(), "mytable", column, false, false); String ddl = write.apply().getBuffer(); - assertThat(ddl).contains("alter table mytable add column col_name varchar2(20)"); + assertThat(ddl).contains("alter table mytable add col_name varchar2(20)"); } @Test diff --git a/ebean-ddl-generator/src/test/resources/dbmigration/migrationtest/oracle/1.1.sql b/ebean-ddl-generator/src/test/resources/dbmigration/migrationtest/oracle/1.1.sql index a7ebf50ef..7e6c98a90 100644 --- a/ebean-ddl-generator/src/test/resources/dbmigration/migrationtest/oracle/1.1.sql +++ b/ebean-ddl-generator/src/test/resources/dbmigration/migrationtest/oracle/1.1.sql @@ -17,11 +17,11 @@ create table migtest_mtm_m_migtest_mtm_c ( constraint pk_migtest_mtm_m_migtest_mtm_c primary key (migtest_mtm_m_id,migtest_mtm_c_id) ); -alter table migtest_ckey_detail add column one_key number(10); -alter table migtest_ckey_detail add column two_key varchar2(127); +alter table migtest_ckey_detail add one_key number(10); +alter table migtest_ckey_detail add two_key varchar2(127); alter table migtest_ckey_detail add constraint fk_migtest_ckey_detail_parent foreign key (one_key,two_key) references migtest_ckey_parent (one_key,two_key); -alter table migtest_ckey_parent add column assoc_id number(10); +alter table migtest_ckey_parent add assoc_id number(10); alter table migtest_fk_cascade drop constraint fk_migtest_fk_cascade_one_id; alter table migtest_fk_cascade add constraint fk_migtest_fk_cascade_one_id foreign key (one_id) references migtest_fk_cascade_one (id); @@ -46,14 +46,14 @@ alter table migtest_e_basic modify status2 null; insert into migtest_e_user (id) select distinct user_id from migtest_e_basic; alter table migtest_e_basic add constraint fk_migtest_e_basic_user_id foreign key (user_id) references migtest_e_user (id); alter table migtest_e_basic modify user_id null; -alter table migtest_e_basic add column new_string_field varchar2(255) default 'foo''bar' not null; -alter table migtest_e_basic add column new_boolean_field number(1) default 1 not null; +alter table migtest_e_basic add new_string_field varchar2(255) default 'foo''bar' not null; +alter table migtest_e_basic add new_boolean_field number(1) default 1 not null; update migtest_e_basic set new_boolean_field = old_boolean; -alter table migtest_e_basic add column new_boolean_field2 number(1) default 1 not null; -alter table migtest_e_basic add column progress number(10) default 0 not null; +alter table migtest_e_basic add new_boolean_field2 number(1) default 1 not null; +alter table migtest_e_basic add progress number(10) default 0 not null; alter table migtest_e_basic add constraint ck_migtest_e_basic_progress check ( progress in (0,1,2)); -alter table migtest_e_basic add column new_integer number(10) default 42 not null; +alter table migtest_e_basic add new_integer number(10) default 42 not null; alter table migtest_e_basic drop constraint uq_migtest_e_basic_indextest2; alter table migtest_e_basic drop constraint uq_migtest_e_basic_indextest6; @@ -70,12 +70,12 @@ comment on table migtest_e_history is 'We have history now'; update migtest_e_history2 set test_string = 'unknown' where test_string is null; alter table migtest_e_history2 modify test_string default 'unknown'; alter table migtest_e_history2 modify test_string not null; -alter table migtest_e_history2 add column test_string2 varchar2(255); -alter table migtest_e_history2 add column test_string3 varchar2(255) default 'unknown' not null; -alter table migtest_e_history2 add column new_column varchar2(20); +alter table migtest_e_history2 add test_string2 varchar2(255); +alter table migtest_e_history2 add test_string3 varchar2(255) default 'unknown' not null; +alter table migtest_e_history2 add new_column varchar2(20); alter table migtest_e_history4 modify test_number number(19); -alter table migtest_e_history5 add column test_boolean number(1) default 0 not null; +alter table migtest_e_history5 add test_boolean number(1) default 0 not null; -- NOTE: table has @History - special migration may be necessary @@ -83,9 +83,9 @@ update migtest_e_history6 set test_number1 = 42 where test_number1 is null; alter table migtest_e_history6 modify test_number1 default 42; alter table migtest_e_history6 modify test_number1 not null; alter table migtest_e_history6 modify test_number2 null; -alter table migtest_e_softdelete add column deleted number(1) default 0 not null; +alter table migtest_e_softdelete add deleted number(1) default 0 not null; -alter table migtest_oto_child add column master_id number(19); +alter table migtest_oto_child add master_id number(19); create index ix_migtest_e_basic_indextest3 on migtest_e_basic (indextest3); create index ix_migtest_e_basic_indextest6 on migtest_e_basic (indextest6); diff --git a/ebean-ddl-generator/src/test/resources/dbmigration/migrationtest/oracle/1.3.sql b/ebean-ddl-generator/src/test/resources/dbmigration/migrationtest/oracle/1.3.sql index 47a095e4e..ceafdbcff 100644 --- a/ebean-ddl-generator/src/test/resources/dbmigration/migrationtest/oracle/1.3.sql +++ b/ebean-ddl-generator/src/test/resources/dbmigration/migrationtest/oracle/1.3.sql @@ -31,9 +31,9 @@ update migtest_e_basic set user_id = 23 where user_id is null; alter table migtest_e_basic drop constraint fk_migtest_e_basic_user_id; alter table migtest_e_basic modify user_id default 23; alter table migtest_e_basic modify user_id not null; -alter table migtest_e_basic add column old_boolean number(1) default 0 not null; -alter table migtest_e_basic add column old_boolean2 number(1); -alter table migtest_e_basic add column eref_id number(10); +alter table migtest_e_basic add old_boolean number(1) default 0 not null; +alter table migtest_e_basic add old_boolean2 number(1); +alter table migtest_e_basic add eref_id number(10); alter table migtest_e_basic drop constraint uq_mgtst__bsc_stts_ndxtst1; alter table migtest_e_basic drop constraint uq_migtest_e_basic_name; @@ -47,8 +47,8 @@ comment on column migtest_e_history.test_string is ''; comment on table migtest_e_history is ''; alter table migtest_e_history2 modify test_string drop default; alter table migtest_e_history2 modify test_string null; -alter table migtest_e_history2 add column obsolete_string1 varchar2(255); -alter table migtest_e_history2 add column obsolete_string2 varchar2(255); +alter table migtest_e_history2 add obsolete_string1 varchar2(255); +alter table migtest_e_history2 add obsolete_string2 varchar2(255); alter table migtest_e_history4 modify test_number number(10); alter table migtest_e_history6 modify test_number1 drop default; From 8992980689d2fe7936acfe4d0fbeadf72bb676a8 Mon Sep 17 00:00:00 2001 From: Robin Bygrave Date: Thu, 25 Mar 2021 16:45:44 +1300 Subject: [PATCH 168/447] #2206 - Postgres DDL generation - for create index use "if not exists" clause --- .../ddlgeneration/platform/PlatformDdl.java | 5 +- .../ddlgeneration/platform/PostgresDdl.java | 1 + .../platform/WriteCreateIndex.java | 13 +++ .../platform/PlatformDdl_CreateIndexTest.java | 98 +++++++++++++++++++ 4 files changed, 116 insertions(+), 1 deletion(-) create mode 100644 ebean-ddl-generator/src/test/java/io/ebeaninternal/dbmigration/ddlgeneration/platform/PlatformDdl_CreateIndexTest.java diff --git a/ebean-ddl-generator/src/main/java/io/ebeaninternal/dbmigration/ddlgeneration/platform/PlatformDdl.java b/ebean-ddl-generator/src/main/java/io/ebeaninternal/dbmigration/ddlgeneration/platform/PlatformDdl.java index 648cfac83..59cf38e0d 100644 --- a/ebean-ddl-generator/src/main/java/io/ebeaninternal/dbmigration/ddlgeneration/platform/PlatformDdl.java +++ b/ebean-ddl-generator/src/main/java/io/ebeaninternal/dbmigration/ddlgeneration/platform/PlatformDdl.java @@ -3,7 +3,6 @@ package io.ebeaninternal.dbmigration.ddlgeneration.platform; import io.ebean.annotation.ConstraintMode; import io.ebean.config.DatabaseConfig; import io.ebean.config.DbConstraintNaming; -import io.ebean.config.ServerConfig; import io.ebean.config.dbplatform.DatabasePlatform; import io.ebean.config.dbplatform.DbDefaultValue; import io.ebean.config.dbplatform.DbIdentity; @@ -113,6 +112,7 @@ public class PlatformDdl { protected String uniqueIndex = "unique"; protected String indexConcurrent = ""; + protected String createIndexIfNotExists = ""; /** * Set false for MsSqlServer to allow multiple nulls for OneToOne mapping. @@ -414,6 +414,9 @@ public class PlatformDdl { if (create.isConcurrent()) { buffer.append(indexConcurrent); } + if (create.isNotExistsCheck()) { + buffer.append(createIndexIfNotExists); + } buffer.append(maxConstraintName(create.getIndexName())).append(" on ").append(create.getTableName()); appendColumns(create.getColumns(), buffer); return buffer.toString(); diff --git a/ebean-ddl-generator/src/main/java/io/ebeaninternal/dbmigration/ddlgeneration/platform/PostgresDdl.java b/ebean-ddl-generator/src/main/java/io/ebeaninternal/dbmigration/ddlgeneration/platform/PostgresDdl.java index daeaf57fb..807bec456 100644 --- a/ebean-ddl-generator/src/main/java/io/ebeaninternal/dbmigration/ddlgeneration/platform/PostgresDdl.java +++ b/ebean-ddl-generator/src/main/java/io/ebeaninternal/dbmigration/ddlgeneration/platform/PostgresDdl.java @@ -18,6 +18,7 @@ public class PostgresDdl extends PlatformDdl { this.dropTableCascade = " cascade"; this.columnSetType = "type "; this.alterTableIfExists = "if exists "; + this.createIndexIfNotExists = "if not exists "; this.columnSetNull = "drop not null"; this.addForeignKeySkipCheck = " not valid"; this.indexConcurrent = "concurrently "; diff --git a/ebean-ddl-generator/src/main/java/io/ebeaninternal/dbmigration/ddlgeneration/platform/WriteCreateIndex.java b/ebean-ddl-generator/src/main/java/io/ebeaninternal/dbmigration/ddlgeneration/platform/WriteCreateIndex.java index c743c979c..fbb7b72ce 100644 --- a/ebean-ddl-generator/src/main/java/io/ebeaninternal/dbmigration/ddlgeneration/platform/WriteCreateIndex.java +++ b/ebean-ddl-generator/src/main/java/io/ebeaninternal/dbmigration/ddlgeneration/platform/WriteCreateIndex.java @@ -12,7 +12,11 @@ class WriteCreateIndex { private final boolean unique; private final boolean concurrent; private final String definition; + private final boolean notExistsCheck; + /** + * Create index for foreign key. + */ WriteCreateIndex(String indexName, String tableName, String[] columns, boolean unique) { this.indexName = indexName; this.tableName = tableName; @@ -20,8 +24,12 @@ class WriteCreateIndex { this.unique = unique; this.concurrent = false; this.definition = null; + this.notExistsCheck = false; } + /** + * Create non-foreign key index. + */ public WriteCreateIndex(CreateIndex index) { this.indexName = index.getIndexName(); this.tableName = index.getTableName(); @@ -29,6 +37,7 @@ class WriteCreateIndex { this.unique = Boolean.TRUE.equals(index.isUnique()); this.concurrent = Boolean.TRUE.equals(index.isConcurrent()); this.definition = index.getDefinition(); + this.notExistsCheck = true; } public String getIndexName() { @@ -58,4 +67,8 @@ class WriteCreateIndex { public boolean useDefinition() { return definition != null && !definition.isEmpty(); } + + public boolean isNotExistsCheck() { + return notExistsCheck; + } } diff --git a/ebean-ddl-generator/src/test/java/io/ebeaninternal/dbmigration/ddlgeneration/platform/PlatformDdl_CreateIndexTest.java b/ebean-ddl-generator/src/test/java/io/ebeaninternal/dbmigration/ddlgeneration/platform/PlatformDdl_CreateIndexTest.java new file mode 100644 index 000000000..d7d33feae --- /dev/null +++ b/ebean-ddl-generator/src/test/java/io/ebeaninternal/dbmigration/ddlgeneration/platform/PlatformDdl_CreateIndexTest.java @@ -0,0 +1,98 @@ +package io.ebeaninternal.dbmigration.ddlgeneration.platform; + +import io.ebean.DB; +import io.ebean.config.DatabaseConfig; +import io.ebean.config.dbplatform.h2.H2Platform; +import io.ebean.config.dbplatform.hana.HanaPlatform; +import io.ebean.config.dbplatform.mysql.MySqlPlatform; +import io.ebean.config.dbplatform.oracle.OraclePlatform; +import io.ebean.config.dbplatform.postgres.PostgresPlatform; +import io.ebean.config.dbplatform.sqlserver.SqlServer17Platform; +import io.ebeaninternal.dbmigration.ddlgeneration.PlatformDdlBuilder; +import io.ebeaninternal.dbmigration.migration.CreateIndex; +import org.junit.Test; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.junit.Assert.assertEquals; + +public class PlatformDdl_CreateIndexTest { + + private final PlatformDdl h2Ddl = PlatformDdlBuilder.create(new H2Platform()); + private final PlatformDdl pgDdl = PlatformDdlBuilder.create(new PostgresPlatform()); + private final PlatformDdl mysqlDdl = PlatformDdlBuilder.create(new MySqlPlatform()); + private final PlatformDdl oraDdl = PlatformDdlBuilder.create(new OraclePlatform()); + private final PlatformDdl sqlServerDdl = PlatformDdlBuilder.create(new SqlServer17Platform()); + private final PlatformDdl hanaDdl = PlatformDdlBuilder.create(new HanaPlatform()); + + { + DatabaseConfig config = DB.getDefault().getPluginApi().getServerConfig(); + h2Ddl.configure(config); + pgDdl.configure(config); + mysqlDdl.configure(config); + oraDdl.configure(config); + sqlServerDdl.configure(config); + hanaDdl.configure(config); + } + + WriteCreateIndex writeCreateIndex() { + + return writeCreateIndex(true, true); + } + + WriteCreateIndex writeCreateIndex(boolean unique, boolean concurrent) { + CreateIndex createIndex = new CreateIndex(); + createIndex.setIndexName("ix_mytab_acol"); + createIndex.setTableName("mytab"); + createIndex.setColumns("acol"); + createIndex.setUnique(unique); + createIndex.setConcurrent(concurrent); + return new WriteCreateIndex(createIndex); + } + + WriteCreateIndex fkeyCreateIndex(boolean unique) { + return new WriteCreateIndex("ix_mytab_acol", "mytab", new String[]{"acol"}, unique); + } + + + @Test + public void createUniqueIndex() { + + WriteCreateIndex createIndex = writeCreateIndex(); + + String sql = h2Ddl.createIndex(createIndex); + assertEquals("create unique index ix_mytab_acol on mytab (acol)", sql); + sql = pgDdl.createIndex(createIndex); + assertEquals("create unique index concurrently if not exists ix_mytab_acol on mytab (acol)", sql); + sql = mysqlDdl.createIndex(createIndex); + assertEquals("create unique index ix_mytab_acol on mytab (acol)", sql); + sql = sqlServerDdl.createIndex(createIndex); + assertEquals("create unique index ix_mytab_acol on mytab (acol)", sql); + sql = oraDdl.createIndex(createIndex); + assertEquals("create unique index ix_mytab_acol on mytab (acol)", sql); + sql = hanaDdl.createIndex(createIndex); + assertThat(sql).isEqualTo("-- explicit index \"ix_mytab_acol\" for single column \"acol\" of table \"mytab\" is not necessary"); + } + + @Test + public void postgres_createIndex() { + + String sql = pgDdl.createIndex(writeCreateIndex(true, true)); + assertEquals("create unique index concurrently if not exists ix_mytab_acol on mytab (acol)", sql); + sql = pgDdl.createIndex(writeCreateIndex(false, false)); + assertEquals("create index if not exists ix_mytab_acol on mytab (acol)", sql); + sql = pgDdl.createIndex(writeCreateIndex(true, false)); + assertEquals("create unique index if not exists ix_mytab_acol on mytab (acol)", sql); + sql = pgDdl.createIndex(writeCreateIndex(false, true)); + assertEquals("create index concurrently if not exists ix_mytab_acol on mytab (acol)", sql); + } + + @Test + public void postgres_fkeyCreateIndex() { + String sql = pgDdl.createIndex(fkeyCreateIndex(true)); + assertEquals("create unique index ix_mytab_acol on mytab (acol)", sql); + + sql = pgDdl.createIndex(fkeyCreateIndex(false)); + assertEquals("create index ix_mytab_acol on mytab (acol)", sql); + } + +} From 57736185d0489b41e4dfdff4898e0ab9f950db2e Mon Sep 17 00:00:00 2001 From: rob bygrave Date: Thu, 25 Mar 2021 23:13:15 +1300 Subject: [PATCH 169/447] #2206 - Postgres DDL generation - for create index use "if not exists" clause --- .../migrationtest/postgres/1.0__initial.sql | 8 ++++---- .../dbmigration/migrationtest/postgres/1.1.sql | 6 +++--- .../dbmigration/migrationtest/postgres/1.3.sql | 10 +++++----- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/ebean-ddl-generator/src/test/resources/dbmigration/migrationtest/postgres/1.0__initial.sql b/ebean-ddl-generator/src/test/resources/dbmigration/migrationtest/postgres/1.0__initial.sql index 5229ed032..af08de6d3 100644 --- a/ebean-ddl-generator/src/test/resources/dbmigration/migrationtest/postgres/1.0__initial.sql +++ b/ebean-ddl-generator/src/test/resources/dbmigration/migrationtest/postgres/1.0__initial.sql @@ -161,11 +161,11 @@ create table migtest_oto_master ( constraint pk_migtest_oto_master primary key (id) ); -create index ix_migtest_e_basic_indextest1 on migtest_e_basic (indextest1); -create index ix_migtest_e_basic_indextest5 on migtest_e_basic (indextest5); +create index if not exists ix_migtest_e_basic_indextest1 on migtest_e_basic (indextest1); +create index if not exists ix_migtest_e_basic_indextest5 on migtest_e_basic (indextest5); create index idxd_migtest_0 on migtest_oto_child using hash (upper(name)) where upper(name) = 'JIM'; -create index concurrently ix_migtest_oto_child_lowername_id on migtest_oto_child (lower(name),id); -create index ix_migtest_oto_child_lowername on migtest_oto_child (lower(name)); +create index concurrently if not exists ix_migtest_oto_child_lowername_id on migtest_oto_child (lower(name),id); +create index if not exists ix_migtest_oto_child_lowername on migtest_oto_child (lower(name)); create index ix_migtest_fk_cascade_one_id on migtest_fk_cascade (one_id); alter table migtest_fk_cascade add constraint fk_migtest_fk_cascade_one_id foreign key (one_id) references migtest_fk_cascade_one (id) on delete cascade on update restrict; diff --git a/ebean-ddl-generator/src/test/resources/dbmigration/migrationtest/postgres/1.1.sql b/ebean-ddl-generator/src/test/resources/dbmigration/migrationtest/postgres/1.1.sql index 6c97d734e..1c0ef5385 100644 --- a/ebean-ddl-generator/src/test/resources/dbmigration/migrationtest/postgres/1.1.sql +++ b/ebean-ddl-generator/src/test/resources/dbmigration/migrationtest/postgres/1.1.sql @@ -100,9 +100,9 @@ alter table migtest_e_softdelete add column deleted boolean default false not nu alter table migtest_oto_child add column master_id bigint; -create index ix_migtest_e_basic_indextest3 on migtest_e_basic (indextest3); -create index ix_migtest_e_basic_indextest6 on migtest_e_basic (indextest6); -create index ix_migtest_oto_child_name on migtest_oto_child (name); +create index if not exists ix_migtest_e_basic_indextest3 on migtest_e_basic (indextest3); +create index if not exists ix_migtest_e_basic_indextest6 on migtest_e_basic (indextest6); +create index if not exists ix_migtest_oto_child_name on migtest_oto_child (name); drop index if exists ix_migtest_e_basic_indextest1; drop index if exists ix_migtest_e_basic_indextest5; drop index if exists idxd_migtest_0; diff --git a/ebean-ddl-generator/src/test/resources/dbmigration/migrationtest/postgres/1.3.sql b/ebean-ddl-generator/src/test/resources/dbmigration/migrationtest/postgres/1.3.sql index a57b95ae2..dbcb50aac 100644 --- a/ebean-ddl-generator/src/test/resources/dbmigration/migrationtest/postgres/1.3.sql +++ b/ebean-ddl-generator/src/test/resources/dbmigration/migrationtest/postgres/1.3.sql @@ -66,11 +66,11 @@ alter table migtest_e_history6 alter column test_number1 drop not null; update migtest_e_history6 set test_number2 = 7 where test_number2 is null; alter table migtest_e_history6 alter column test_number2 set default 7; alter table migtest_e_history6 alter column test_number2 set not null; -create index ix_migtest_e_basic_indextest1 on migtest_e_basic (indextest1); -create index ix_migtest_e_basic_indextest5 on migtest_e_basic (indextest5); -create index ix_m12_otoc71 on migtest_oto_child (name); -create unique index uq_m12_otoc71 on migtest_oto_child (lower(name)); -create unique index ix_migtest_oto_master_lowername on migtest_oto_master (lower(name)); +create index if not exists ix_migtest_e_basic_indextest1 on migtest_e_basic (indextest1); +create index if not exists ix_migtest_e_basic_indextest5 on migtest_e_basic (indextest5); +create index if not exists ix_m12_otoc71 on migtest_oto_child (name); +create unique index if not exists uq_m12_otoc71 on migtest_oto_child (lower(name)); +create unique index if not exists ix_migtest_oto_master_lowername on migtest_oto_master (lower(name)); drop index if exists ix_migtest_e_basic_indextest3; drop index if exists ix_migtest_e_basic_indextest6; create index ix_migtest_e_basic_eref_id on migtest_e_basic (eref_id); From 91044d0a757c4586e07212b6bdf717f20dcbe3b4 Mon Sep 17 00:00:00 2001 From: rob bygrave Date: Thu, 25 Mar 2021 23:13:51 +1300 Subject: [PATCH 170/447] javadoc only - improve javadoc for DatabaseConfig.loadFromProperties() --- ebean-api/src/main/java/io/ebean/config/DatabaseConfig.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/ebean-api/src/main/java/io/ebean/config/DatabaseConfig.java b/ebean-api/src/main/java/io/ebean/config/DatabaseConfig.java index 8e65f9bb3..49c458743 100644 --- a/ebean-api/src/main/java/io/ebean/config/DatabaseConfig.java +++ b/ebean-api/src/main/java/io/ebean/config/DatabaseConfig.java @@ -2693,7 +2693,10 @@ public class DatabaseConfig { } /** - * Load settings from ebean.properties. + * Load settings from application.properties, application.yaml and other sources. + *

+ * Uses avaje-config to load configuration properties. Goto https://avaje.io/config + * for detail on how and where properties are loaded from. */ public void loadFromProperties() { this.properties = Config.asProperties(); From 1f0ed629a7a11413cbb81b504df976fc250930f5 Mon Sep 17 00:00:00 2001 From: rob bygrave Date: Fri, 26 Mar 2021 20:31:03 +1300 Subject: [PATCH 171/447] Bump java8-oss to 3.1 with removal of --illegal-access=permit argLine --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index dbd383225..297d5ab0a 100644 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ org.avaje java8-oss - 2.3 + 3.1 io.ebean From 819d391495166faec2b54e60a382e1c35bc11910 Mon Sep 17 00:00:00 2001 From: rob bygrave Date: Fri, 26 Mar 2021 20:31:57 +1300 Subject: [PATCH 172/447] Bump agent maven plugin to 12.8.1 --- ebean-bom/pom.xml | 4 ++-- ebean-core/pom.xml | 2 +- ebean-ddl-generator/pom.xml | 3 +-- kotlin-querybean-generator/pom.xml | 2 +- 4 files changed, 5 insertions(+), 6 deletions(-) diff --git a/ebean-bom/pom.xml b/ebean-bom/pom.xml index e96c248d7..665ea80be 100644 --- a/ebean-bom/pom.xml +++ b/ebean-bom/pom.xml @@ -18,8 +18,8 @@ 12.4.0 4.1 7.0 - 12.6.6 - 12.6.6 + 12.8.1 + 12.8.1 diff --git a/ebean-core/pom.xml b/ebean-core/pom.xml index 9d7f1e236..e8ecd9616 100644 --- a/ebean-core/pom.xml +++ b/ebean-core/pom.xml @@ -302,7 +302,7 @@ io.ebean ebean-maven-plugin - 12.6.6 + 12.8.1 test diff --git a/ebean-ddl-generator/pom.xml b/ebean-ddl-generator/pom.xml index 1ef8c0725..60300f7ce 100644 --- a/ebean-ddl-generator/pom.xml +++ b/ebean-ddl-generator/pom.xml @@ -10,7 +10,6 @@ ebean ddl generation DDL and DB Migration generation ebean-ddl-generator - @@ -77,7 +76,7 @@ io.ebean ebean-maven-plugin - 12.6.6 + 12.8.1 test diff --git a/kotlin-querybean-generator/pom.xml b/kotlin-querybean-generator/pom.xml index cf3dca074..588872181 100644 --- a/kotlin-querybean-generator/pom.xml +++ b/kotlin-querybean-generator/pom.xml @@ -146,7 +146,7 @@ io.ebean ebean-maven-plugin - 12.6.6 + 12.8.1 test From 5cb9b9b2372a4a8349837f6b70a43267fd61ab6d Mon Sep 17 00:00:00 2001 From: rob bygrave Date: Mon, 29 Mar 2021 23:21:07 +1300 Subject: [PATCH 173/447] #2208 - When using fetchCache() with a single id / findOne ... doesn't hit L2 cache Plus #2207 ENH: Query beans add support for nested FetchGroup --- .../io/ebeaninternal/api/CacheIdLookup.java | 47 ++------ .../ebeaninternal/api/CacheIdLookupMany.java | 55 +++++++++ .../api/CacheIdLookupSingle.java | 38 ++++++ .../io/ebeaninternal/api/SpiQueryFetch.java | 5 + .../server/query/DefaultFetchGroupQuery.java | 5 + .../server/querydefn/DefaultOrmQuery.java | 15 ++- .../server/querydefn/OrmQueryProperties.java | 2 +- .../java/io/ebean/typequery/TQAssocBean.java | 32 ++++- .../test/java/org/querytest/QOrderTest.java | 112 ++++++++++++++++++ 9 files changed, 270 insertions(+), 41 deletions(-) create mode 100644 ebean-core/src/main/java/io/ebeaninternal/api/CacheIdLookupMany.java create mode 100644 ebean-core/src/main/java/io/ebeaninternal/api/CacheIdLookupSingle.java diff --git a/ebean-core/src/main/java/io/ebeaninternal/api/CacheIdLookup.java b/ebean-core/src/main/java/io/ebeaninternal/api/CacheIdLookup.java index 0ae791747..cf29cf6d5 100644 --- a/ebean-core/src/main/java/io/ebeaninternal/api/CacheIdLookup.java +++ b/ebean-core/src/main/java/io/ebeaninternal/api/CacheIdLookup.java @@ -1,52 +1,25 @@ package io.ebeaninternal.api; -import io.ebeaninternal.server.expression.IdInExpression; - -import java.util.ArrayList; import java.util.Collection; -import java.util.HashSet; import java.util.List; -import java.util.Set; /** - * Used for bean cache lookup with where ids in expression. + * Process Cache lookup by Id(s). */ -public class CacheIdLookup { - - private final IdInExpression idInExpression; - - private int remaining; - - public CacheIdLookup(IdInExpression idInExpression) { - this.idInExpression = idInExpression; - } +public interface CacheIdLookup { /** - * Return the Id values for the in expression. + * Return the Id values to lookup against the L2 cache. */ - public Collection idValues() { - return idInExpression.idValues(); - } + Collection idValues(); /** - * Process the hits returning the beans fetched from cache and - * adjusting the in expression (to not fetch the hits). + * Remove the hits returning the beans fetched from L2 cache. */ - public List removeHits(BeanCacheResult cacheResult) { + List removeHits(BeanCacheResult cacheResult); - Set hitIds = new HashSet<>(); - List beans = new ArrayList<>(hitIds.size()); - - for (BeanCacheResult.Entry hit : cacheResult.hits()) { - hitIds.add(hit.getKey()); - beans.add(hit.getBean()); - } - - this.remaining = idInExpression.removeIds(hitIds); - return beans; - } - - public boolean allHits() { - return remaining == 0; - } + /** + * Return true if all beans where found in L2 cache. + */ + boolean allHits(); } diff --git a/ebean-core/src/main/java/io/ebeaninternal/api/CacheIdLookupMany.java b/ebean-core/src/main/java/io/ebeaninternal/api/CacheIdLookupMany.java new file mode 100644 index 000000000..bfe9d5b84 --- /dev/null +++ b/ebean-core/src/main/java/io/ebeaninternal/api/CacheIdLookupMany.java @@ -0,0 +1,55 @@ +package io.ebeaninternal.api; + +import io.ebeaninternal.server.expression.IdInExpression; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.HashSet; +import java.util.List; +import java.util.Set; + +/** + * Used for bean cache lookup with where ids in expression. + */ +public class CacheIdLookupMany implements CacheIdLookup { + + private final IdInExpression idInExpression; + + private int remaining; + + public CacheIdLookupMany(IdInExpression idInExpression) { + this.idInExpression = idInExpression; + } + + /** + * Return the Id values for the in expression. + */ + @Override + public Collection idValues() { + return idInExpression.idValues(); + } + + /** + * Process the hits returning the beans fetched from cache and + * adjusting the in expression (to not fetch the hits). + */ + @Override + public List removeHits(BeanCacheResult cacheResult) { + + Set hitIds = new HashSet<>(); + List beans = new ArrayList<>(hitIds.size()); + + for (BeanCacheResult.Entry hit : cacheResult.hits()) { + hitIds.add(hit.getKey()); + beans.add(hit.getBean()); + } + + this.remaining = idInExpression.removeIds(hitIds); + return beans; + } + + @Override + public boolean allHits() { + return remaining == 0; + } +} diff --git a/ebean-core/src/main/java/io/ebeaninternal/api/CacheIdLookupSingle.java b/ebean-core/src/main/java/io/ebeaninternal/api/CacheIdLookupSingle.java new file mode 100644 index 000000000..47ee89c4b --- /dev/null +++ b/ebean-core/src/main/java/io/ebeaninternal/api/CacheIdLookupSingle.java @@ -0,0 +1,38 @@ +package io.ebeaninternal.api; + +import java.util.Collection; +import java.util.Collections; +import java.util.List; + +/** + * Used for bean cache lookup with a single id value. + */ +public class CacheIdLookupSingle implements CacheIdLookup { + + private final Object idValue; + private boolean found; + + public CacheIdLookupSingle(Object idValue) { + this.idValue = idValue; + } + + @Override + public Collection idValues() { + return Collections.singleton(idValue); + } + + @Override + public List removeHits(BeanCacheResult cacheResult) { + final List> hits = cacheResult.hits(); + if (hits.size() == 1) { + found = true; + return Collections.singletonList(hits.get(0).getBean()); + } + return Collections.emptyList(); + } + + @Override + public boolean allHits() { + return found; + } +} diff --git a/ebean-core/src/main/java/io/ebeaninternal/api/SpiQueryFetch.java b/ebean-core/src/main/java/io/ebeaninternal/api/SpiQueryFetch.java index 396827978..716dbc076 100644 --- a/ebean-core/src/main/java/io/ebeaninternal/api/SpiQueryFetch.java +++ b/ebean-core/src/main/java/io/ebeaninternal/api/SpiQueryFetch.java @@ -1,6 +1,7 @@ package io.ebeaninternal.api; import io.ebean.FetchConfig; +import io.ebeaninternal.server.querydefn.OrmQueryDetail; import java.util.Set; @@ -19,4 +20,8 @@ public interface SpiQueryFetch { */ void fetchProperties(String name, Set properties, FetchConfig config); + /** + * Add a nested fetch graph. + */ + void addNested(String name, OrmQueryDetail nestedDetail, FetchConfig config); } diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/query/DefaultFetchGroupQuery.java b/ebean-core/src/main/java/io/ebeaninternal/server/query/DefaultFetchGroupQuery.java index 5b2ed841a..9f7cb9b7e 100644 --- a/ebean-core/src/main/java/io/ebeaninternal/server/query/DefaultFetchGroupQuery.java +++ b/ebean-core/src/main/java/io/ebeaninternal/server/query/DefaultFetchGroupQuery.java @@ -644,4 +644,9 @@ class DefaultFetchGroupQuery implements SpiFetchGroupQuery, SpiQueryFetch public void fetchProperties(String property, Set columns, FetchConfig config) { detail.fetchProperties(property, columns, config); } + + @Override + public void addNested(String name, OrmQueryDetail nestedDetail, FetchConfig config) { + detail.addNested(name, nestedDetail, config); + } } diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/querydefn/DefaultOrmQuery.java b/ebean-core/src/main/java/io/ebeaninternal/server/querydefn/DefaultOrmQuery.java index 074f364bc..867e16dfa 100644 --- a/ebean-core/src/main/java/io/ebeaninternal/server/querydefn/DefaultOrmQuery.java +++ b/ebean-core/src/main/java/io/ebeaninternal/server/querydefn/DefaultOrmQuery.java @@ -35,6 +35,8 @@ import io.ebean.plugin.BeanType; import io.ebeaninternal.api.BindParams; import io.ebeaninternal.api.CQueryPlanKey; import io.ebeaninternal.api.CacheIdLookup; +import io.ebeaninternal.api.CacheIdLookupMany; +import io.ebeaninternal.api.CacheIdLookupSingle; import io.ebeaninternal.api.HashQuery; import io.ebeaninternal.api.ManyWhereJoins; import io.ebeaninternal.api.NaturalKeyQueryData; @@ -740,10 +742,14 @@ public class DefaultOrmQuery implements SpiQuery { return null; } List underlyingList = whereExpressions.getUnderlyingList(); - if (underlyingList.size() == 1) { + if (underlyingList.isEmpty()) { + if (id != null) { + return new CacheIdLookupSingle<>(id); + } + } else if (underlyingList.size() == 1) { SpiExpression singleExpression = underlyingList.get(0); if (singleExpression instanceof IdInExpression) { - return new CacheIdLookup<>((IdInExpression) singleExpression); + return new CacheIdLookupMany<>((IdInExpression) singleExpression); } } return null; @@ -1412,6 +1418,11 @@ public class DefaultOrmQuery implements SpiQuery { detail.fetchProperties(path, other); } + @Override + public void addNested(String name, OrmQueryDetail nestedDetail, FetchConfig config) { + detail.addNested(name, nestedDetail, config); + } + @Override public Query select(String columns) { detail.select(columns); diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/querydefn/OrmQueryProperties.java b/ebean-core/src/main/java/io/ebeaninternal/server/querydefn/OrmQueryProperties.java index d1a3aeafc..466bb3eb9 100644 --- a/ebean-core/src/main/java/io/ebeaninternal/server/querydefn/OrmQueryProperties.java +++ b/ebean-core/src/main/java/io/ebeaninternal/server/querydefn/OrmQueryProperties.java @@ -120,8 +120,8 @@ public class OrmQueryProperties implements Serializable { this.parentPath = SplitName.parent(path); this.allProperties = other.allProperties; this.included = other.included; - this.cache = other.cache; this.fetchConfig = fetchConfig; + this.cache = fetchConfig.isCache(); } /** diff --git a/ebean-querybean/src/main/java/io/ebean/typequery/TQAssocBean.java b/ebean-querybean/src/main/java/io/ebean/typequery/TQAssocBean.java index c54862151..d5843a612 100644 --- a/ebean-querybean/src/main/java/io/ebean/typequery/TQAssocBean.java +++ b/ebean-querybean/src/main/java/io/ebean/typequery/TQAssocBean.java @@ -2,7 +2,10 @@ package io.ebean.typequery; import io.ebean.ExpressionList; import io.ebean.FetchConfig; +import io.ebean.FetchGroup; import io.ebeaninternal.api.SpiQueryFetch; +import io.ebeaninternal.server.querydefn.OrmQueryDetail; +import io.ebeaninternal.server.querydefn.SpiFetchGroup; import java.util.LinkedHashSet; import java.util.Set; @@ -142,7 +145,34 @@ public abstract class TQAssocBean extends TQProperty { return _root; } - private final SpiQueryFetch spiQuery() { + /** + * Fetch using the nested FetchGroup. + */ + public R fetch(FetchGroup nestedGroup) { + return fetchNested(nestedGroup, FETCH_DEFAULT); + } + + /** + * Fetch query using the nested FetchGroup. + */ + public R fetchQuery(FetchGroup nestedGroup) { + return fetchNested(nestedGroup, FETCH_QUERY); + } + + /** + * Fetch cache using the nested FetchGroup. + */ + public R fetchCache(FetchGroup nestedGroup) { + return fetchNested(nestedGroup, FETCH_CACHE); + } + + private R fetchNested(FetchGroup nestedGroup, FetchConfig fetchConfig) { + OrmQueryDetail nestedDetail = ((SpiFetchGroup) nestedGroup).underlying(); + spiQuery().addNested(_name, nestedDetail, fetchConfig); + return _root; + } + + private SpiQueryFetch spiQuery() { return (SpiQueryFetch)((TQRootBean) _root).query(); } diff --git a/ebean-querybean/src/test/java/org/querytest/QOrderTest.java b/ebean-querybean/src/test/java/org/querytest/QOrderTest.java index 2f470fdb5..db899549c 100644 --- a/ebean-querybean/src/test/java/org/querytest/QOrderTest.java +++ b/ebean-querybean/src/test/java/org/querytest/QOrderTest.java @@ -3,9 +3,13 @@ package org.querytest; import io.ebean.DB; import io.ebean.FetchGroup; import io.ebean.test.LoggedSql; +import org.example.domain.Customer; import org.example.domain.Order; +import org.example.domain.otherpackage.PhoneNumber; import org.example.domain.query.QCustomer; import org.example.domain.query.QOrder; +import org.junit.AfterClass; +import org.junit.BeforeClass; import org.junit.Test; import java.util.List; @@ -18,6 +22,26 @@ public class QOrderTest { private static final QOrder or = QOrder.alias(); + private static final FetchGroup fgC = QCustomer.forFetchGroup() + .select(cu.name, cu.phoneNumber) + .buildFetchGroup(); + + private static final FetchGroup fgNested1 = QOrder.forFetchGroup() + .select(or.status, or.shipDate) + .customer.fetch(fgC) + .buildFetchGroup(); + + private static final FetchGroup fgNested_fetchQuery = QOrder.forFetchGroup() + .select(or.status) + .customer.fetchQuery(fgC) + .buildFetchGroup(); + + private static final FetchGroup fgNested_fetchCache = QOrder.forFetchGroup() + .select(or.status) + .customer.fetchCache(fgC) + .buildFetchGroup(); + + private static final FetchGroup fg = QOrder.forFetchGroup() .select(or.status, or.shipDate) .customer.fetchCache(cu.name, cu.status, cu.registered, cu.comments) @@ -28,6 +52,20 @@ public class QOrderTest { .customer.fetch(cu.name) .buildFetchGroup(); + private static Order order; + private static Customer customer; + + @BeforeClass + public static void before() { + setupData(); + } + + @AfterClass + public static void after() { + DB.delete(order); + DB.delete(customer); + } + @Test public void fetchCache() { @@ -76,6 +114,69 @@ public class QOrderTest { assertThat(sql.get(0)).contains("select t0.id, t0.status, t1.id, t1.name from o_order t0 join be_customer t1 on t1.id = t0.customer_id where"); } + @Test + public void viaFetchGraph_withNested() { + + DB.getDefault(); + LoggedSql.start(); + + new QOrder() + .status.eq(Order.Status.NEW) + .select(fgNested1) + .findList(); + + final List sql = LoggedSql.stop(); + assertThat(sql).hasSize(1); + assertThat(sql.get(0)).contains("select t0.id, t0.status, t0.ship_date, t1.id, t1.name, t1.phone_number from o_order t0 join be_customer t1 on t1.id = t0.customer_id where"); + } + + @Test + public void viaFetchGraph_withNested_fetchQuery() { + + DB.getDefault(); + LoggedSql.start(); + + final Order found = new QOrder() + .id.eq(order.getId()) + .select(fgNested_fetchQuery) + .findOne(); + + final List sql = LoggedSql.stop(); + + // assert fetching customer via fetchQuery + assertThat(sql).hasSize(2); + assertThat(sql.get(0)).contains("select t0.id, t0.status, t0.customer_id from o_order t0 where t0.id = ?"); + assertThat(sql.get(1)).contains("select t0.id, t0.name, t0.phone_number from be_customer t0 where t0.id = ?"); + + assertThat(found.getCustomer().getPhoneNumber().getMsisdn()).isEqualTo("Ph1"); + } + + + @Test + public void viaFetchGraph_withNested_fetchCache() { + + DB.getDefault(); + + // ensure the customer is loaded in the L2 cache + new QCustomer().id.eq(customer.getId()).findOne(); + + LoggedSql.start(); + + final Order found = new QOrder() + .id.eq(order.getId()) + .select(fgNested_fetchCache) // cache hit for customer + .findOne(); + + final String msisdn = found.getCustomer().getPhoneNumber().getMsisdn(); + assertThat(msisdn).isEqualTo("Ph1"); + + final List sql = LoggedSql.stop(); + + // assert we only hit DB for order + assertThat(sql).hasSize(1); + assertThat(sql.get(0)).contains("select t0.id, t0.status, t0.customer_id from o_order t0 where t0.id = ?"); + } + @Test public void select_partial() { @@ -113,4 +214,15 @@ public class QOrderTest { } + private static void setupData() { + + customer = new Customer(); + customer.setName("Fred"); + customer.setPhoneNumber(new PhoneNumber("Ph1")); + customer.save(); + + order = new Order(); + order.setCustomer(customer); + order.save(); + } } From bd7499a5054564119b6609e1be94f8c43c87f181 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonas=20P=C3=B6hler=20=28JPo=29?= Date: Mon, 29 Mar 2021 13:23:56 +0200 Subject: [PATCH 174/447] Use SoftReference in Cache, so it can be gc'ed if the jvm runs out of memory MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Jonas Pöhler (JPo) --- .../server/cache/DefaultServerCache.java | 45 +++++++++++-------- .../cache/DefaultServerCacheConfig.java | 8 ++-- .../server/cache/DefaultServerQueryCache.java | 5 ++- 3 files changed, 35 insertions(+), 23 deletions(-) diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/cache/DefaultServerCache.java b/ebean-core/src/main/java/io/ebeaninternal/server/cache/DefaultServerCache.java index 41ec3e2c9..334a0838a 100644 --- a/ebean-core/src/main/java/io/ebeaninternal/server/cache/DefaultServerCache.java +++ b/ebean-core/src/main/java/io/ebeaninternal/server/cache/DefaultServerCache.java @@ -11,6 +11,7 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import java.io.Serializable; +import java.lang.ref.SoftReference; import java.util.ArrayList; import java.util.Comparator; import java.util.Iterator; @@ -37,7 +38,7 @@ public class DefaultServerCache implements ServerCache { /** * The underlying map (ConcurrentHashMap or similar) */ - protected final Map map; + protected final Map> map; protected final CountMetric hitCount; protected final CountMetric missCount; @@ -199,7 +200,8 @@ public class DefaultServerCache implements ServerCache { * Get the cache entry - override for query cache to validate dependent tables. */ protected CacheEntry getCacheEntry(Object id) { - return map.get(key(id)); + final SoftReference ref = map.get(key(id)); + return ref != null ? ref.get() : null; } @Override @@ -213,7 +215,7 @@ public class DefaultServerCache implements ServerCache { @Override public void put(Object id, Object value) { Object key = key(id); - map.put(key, new CacheEntry(key, value)); + map.put(key, new SoftReference<>(new CacheEntry(key, value))); putCount.increment(); } @@ -222,8 +224,8 @@ public class DefaultServerCache implements ServerCache { */ @Override public void remove(Object id) { - CacheEntry entry = map.remove(key(id)); - if (entry != null) { + SoftReference entry = map.remove(key(id)); + if (entry != null && entry.get() != null) { removeCount.increment(); } } @@ -266,6 +268,7 @@ public class DefaultServerCache implements ServerCache { long startNanos = System.nanoTime(); long trimmedByIdle = 0; + long trimmedByGC = 0; long trimmedByTTL = 0; long trimmedByLRU = 0; @@ -274,10 +277,14 @@ public class DefaultServerCache implements ServerCache { long idleExpireNano = startNanos - TimeUnit.SECONDS.toNanos(maxIdleSecs); long ttlExpireNano = startNanos - TimeUnit.SECONDS.toNanos(maxSecsToLive); - Iterator it = map.values().iterator(); + Iterator> it = map.values().iterator(); while (it.hasNext()) { - CacheEntry cacheEntry = it.next(); - if (maxIdleSecs > 0 && idleExpireNano > cacheEntry.getLastAccessTime()) { + SoftReference ref = it.next(); + final CacheEntry cacheEntry = ref.get(); + if (cacheEntry == null) { + it.remove(); + trimmedByGC++; + } else if (maxIdleSecs > 0 && idleExpireNano > cacheEntry.getLastAccessTime()) { it.remove(); trimmedByIdle++; @@ -290,27 +297,27 @@ public class DefaultServerCache implements ServerCache { } } - if (trimForMaxSize > 0) { - trimmedByLRU = activeList.size() - maxSize; - if (trimmedByLRU > 0) { - // sort into last access time ascending - activeList.sort(BY_LAST_ACCESS); - int trimSize = getTrimSize(); - for (int i = trimSize; i < activeList.size(); i++) { - // remove if still in the cache - map.remove(activeList.get(i).getKey()); + if (trimForMaxSize > 0 && activeList.size() > maxSize) { + // sort into last access time ascending + activeList.sort(BY_LAST_ACCESS); + int trimSize = getTrimSize(); + for (int i = trimSize; i < activeList.size(); i++) { + // remove if still in the cache + if (map.remove(activeList.get(i).getKey()) != null) { + trimmedByLRU++; } } } evictCount.add(trimmedByIdle); + evictCount.add(trimmedByGC); evictCount.add(trimmedByTTL); evictCount.add(trimmedByLRU); if (logger.isTraceEnabled()) { long exeMicros = TimeUnit.MICROSECONDS.convert(System.nanoTime() - startNanos, TimeUnit.NANOSECONDS); - logger.trace("Executed trim of cache {} in [{}]millis idle[{}] timeToLive[{}] accessTime[{}]" - , name, exeMicros, trimmedByIdle, trimmedByTTL, trimmedByLRU); + logger.trace("Executed trim of cache {} in [{}]millis idle[{}] timeToLive[{}] accessTime[{}] gc[{}]", + name, exeMicros, trimmedByIdle, trimmedByTTL, trimmedByLRU, trimmedByGC); } } diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/cache/DefaultServerCacheConfig.java b/ebean-core/src/main/java/io/ebeaninternal/server/cache/DefaultServerCacheConfig.java index 638f237a2..5f8ed1d5d 100644 --- a/ebean-core/src/main/java/io/ebeaninternal/server/cache/DefaultServerCacheConfig.java +++ b/ebean-core/src/main/java/io/ebeaninternal/server/cache/DefaultServerCacheConfig.java @@ -4,7 +4,9 @@ import io.ebean.cache.QueryCacheEntryValidate; import io.ebean.cache.ServerCacheConfig; import io.ebean.cache.ServerCacheOptions; import io.ebean.config.CurrentTenantProvider; +import io.ebeaninternal.server.cache.DefaultServerCache.CacheEntry; +import java.lang.ref.SoftReference; import java.util.Map; import java.util.concurrent.ConcurrentHashMap; @@ -17,13 +19,13 @@ public class DefaultServerCacheConfig { private int maxSecsToLive; private int trimFrequency; - private Map map; + private Map> map; public DefaultServerCacheConfig(ServerCacheConfig config) { this(config, new ConcurrentHashMap<>()); } - public DefaultServerCacheConfig(ServerCacheConfig config, Map map) { + public DefaultServerCacheConfig(ServerCacheConfig config, Map> map) { this.config = config; this.map = map; @@ -50,7 +52,7 @@ public class DefaultServerCacheConfig { return config.getShortName(); } - public Map getMap() { + public Map> getMap() { return map; } diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/cache/DefaultServerQueryCache.java b/ebean-core/src/main/java/io/ebeaninternal/server/cache/DefaultServerQueryCache.java index afbdb37f7..4f437eafc 100644 --- a/ebean-core/src/main/java/io/ebeaninternal/server/cache/DefaultServerQueryCache.java +++ b/ebean-core/src/main/java/io/ebeaninternal/server/cache/DefaultServerQueryCache.java @@ -3,6 +3,8 @@ package io.ebeaninternal.server.cache; import io.ebean.cache.QueryCacheEntry; import io.ebean.cache.QueryCacheEntryValidate; +import java.lang.ref.SoftReference; + /** * Server cache for query caching. *

@@ -27,7 +29,8 @@ public class DefaultServerQueryCache extends DefaultServerCache { @Override protected CacheEntry getCacheEntry(Object id) { Object key = key(id); - CacheEntry entry = map.get(key); + final SoftReference ref = map.get(key); + CacheEntry entry = ref != null ? ref.get() : null; if (entry == null) { return null; } From d988dbe69def32b5bdb3f185e9470df8bab3047a Mon Sep 17 00:00:00 2001 From: Robin Bygrave Date: Tue, 30 Mar 2021 09:56:48 +1300 Subject: [PATCH 175/447] #2209 - Registering [default] as the default server but [default] is already registered as the default exception with hot-reload --- ebean-api/src/main/java/io/ebean/DatabaseFactory.java | 2 +- ebean-core/src/test/java/org/MainMemoryLeak.java | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/ebean-api/src/main/java/io/ebean/DatabaseFactory.java b/ebean-api/src/main/java/io/ebean/DatabaseFactory.java index 6ad7b1d89..4aace866a 100644 --- a/ebean-api/src/main/java/io/ebean/DatabaseFactory.java +++ b/ebean-api/src/main/java/io/ebean/DatabaseFactory.java @@ -78,7 +78,7 @@ public class DatabaseFactory { Database server = createInternal(config); if (config.isRegister()) { if (config.isDefaultServer()) { - if (defaultServerName != null) { + if (defaultServerName != null && !defaultServerName.equals(config.getName())) { throw new IllegalStateException("Registering [" + config.getName() + "] as the default server but [" + defaultServerName + "] is already registered as the default"); } defaultServerName = config.getName(); diff --git a/ebean-core/src/test/java/org/MainMemoryLeak.java b/ebean-core/src/test/java/org/MainMemoryLeak.java index d3f085ef3..b659297b4 100644 --- a/ebean-core/src/test/java/org/MainMemoryLeak.java +++ b/ebean-core/src/test/java/org/MainMemoryLeak.java @@ -46,7 +46,12 @@ public class MainMemoryLeak { config.addClass(ECachedBean.class); config.loadFromProperties(); + Database server1 = DatabaseFactory.create(config); + assert server1 != null; + + // create again for #2193 Database server = DatabaseFactory.create(config); + assert server != null; // create a string with 10k chars char[] c = new char[10_000]; From f8c37772d4bc518c89a3ff26d3cc00ea7905466c Mon Sep 17 00:00:00 2001 From: Robin Bygrave Date: Tue, 30 Mar 2021 10:23:28 +1300 Subject: [PATCH 176/447] Tidy internals of DefaultServer with @Nonnull, <>, Collections.singleton(), remove unused queryBatchSize --- .../server/core/DefaultServer.java | 39 +++++++++++-------- 1 file changed, 23 insertions(+), 16 deletions(-) diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/core/DefaultServer.java b/ebean-core/src/main/java/io/ebeaninternal/server/core/DefaultServer.java index 34a094301..5e8db9c1c 100644 --- a/ebean-core/src/main/java/io/ebeaninternal/server/core/DefaultServer.java +++ b/ebean-core/src/main/java/io/ebeaninternal/server/core/DefaultServer.java @@ -125,6 +125,7 @@ import io.ebeanservice.docstore.api.DocStoreIntegration; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import javax.annotation.Nonnull; import javax.persistence.NonUniqueResultException; import javax.persistence.OptimisticLockException; import javax.persistence.PersistenceException; @@ -137,7 +138,6 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.Collection; import java.util.Collections; -import java.util.HashSet; import java.util.LinkedHashSet; import java.util.List; import java.util.Map; @@ -196,7 +196,6 @@ public final class DefaultServer implements SpiServer, SpiEbeanServer { private final SpiLogManager logManager; private final PersistenceContextScope defaultPersistenceContextScope; private final int lazyLoadBatchSize; - private final int queryBatchSize; private final boolean updateAllPropertiesInBatch; private final long slowQueryMicros; private final SlowQueryListener slowQueryListener; @@ -217,7 +216,6 @@ public final class DefaultServer implements SpiServer, SpiEbeanServer { this.extraMetrics = config.getExtraMetrics(); this.serverName = this.config.getName(); this.lazyLoadBatchSize = this.config.getLazyLoadBatchSize(); - this.queryBatchSize = this.config.getQueryBatchSize(); this.cqueryEngine = config.getCQueryEngine(); this.expressionFactory = config.getExpressionFactory(); this.encryptKeyManager = this.config.getEncryptKeyManager(); @@ -305,10 +303,6 @@ public final class DefaultServer implements SpiServer, SpiEbeanServer { return lazyLoadBatchSize; } - public int getQueryBatchSize() { - return queryBatchSize; - } - @Override public Object currentTenantId() { return currentTenantProvider == null ? null : currentTenantProvider.currentId(); @@ -1150,6 +1144,7 @@ public final class DefaultServer implements SpiServer, SpiEbeanServer { } } + @Nonnull @Override public Optional findOneOrEmpty(Query query, Transaction transaction) { return Optional.ofNullable(findOne(query, transaction)); @@ -1180,6 +1175,7 @@ public final class DefaultServer implements SpiServer, SpiEbeanServer { } } + @Nonnull @Override @SuppressWarnings({"unchecked", "rawtypes"}) public Set findSet(Query query, Transaction t) { @@ -1196,6 +1192,7 @@ public final class DefaultServer implements SpiServer, SpiEbeanServer { } } + @Nonnull @Override @SuppressWarnings({"unchecked", "rawtypes"}) public Map findMap(Query query, Transaction t) { @@ -1217,6 +1214,7 @@ public final class DefaultServer implements SpiServer, SpiEbeanServer { } } + @Nonnull @Override @SuppressWarnings("unchecked") public List findSingleAttributeList(Query query, Transaction t) { @@ -1227,7 +1225,7 @@ public final class DefaultServer implements SpiServer, SpiEbeanServer { } try { request.initTransIfRequired(); - return (List) request.findSingleAttributeList(); + return request.findSingleAttributeList(); } finally { request.endTransIfRequired(); } @@ -1277,6 +1275,7 @@ public final class DefaultServer implements SpiServer, SpiEbeanServer { } } + @Nonnull @Override public List findIds(Query query, Transaction t) { return findIdsWithCopy(((SpiQuery) query).copy(), t); @@ -1337,26 +1336,29 @@ public final class DefaultServer implements SpiServer, SpiEbeanServer { } } + @Nonnull @Override public FutureRowCount findFutureCount(Query q, Transaction t) { SpiQuery copy = ((SpiQuery) q).copy(); copy.setFutureFetch(true); Transaction newTxn = createTransaction(); - QueryFutureRowCount queryFuture = new QueryFutureRowCount<>(new CallableQueryCount(this, copy, newTxn)); + QueryFutureRowCount queryFuture = new QueryFutureRowCount<>(new CallableQueryCount<>(this, copy, newTxn)); backgroundExecutor.execute(queryFuture.getFutureTask()); return queryFuture; } + @Nonnull @Override public FutureIds findFutureIds(Query query, Transaction t) { SpiQuery copy = ((SpiQuery) query).copy(); copy.setFutureFetch(true); Transaction newTxn = createTransaction(); - QueryFutureIds queryFuture = new QueryFutureIds<>(new CallableQueryIds(this, copy, newTxn)); + QueryFutureIds queryFuture = new QueryFutureIds<>(new CallableQueryIds<>(this, copy, newTxn)); backgroundExecutor.execute(queryFuture.getFutureTask()); return queryFuture; } + @Nonnull @Override public FutureList findFutureList(Query query, Transaction t) { SpiQuery spiQuery = (SpiQuery) query; @@ -1369,11 +1371,12 @@ public final class DefaultServer implements SpiServer, SpiEbeanServer { } // Create a new transaction solely to execute the findList() at some future time Transaction newTxn = createTransaction(); - QueryFutureList queryFuture = new QueryFutureList<>(new CallableQueryList(this, spiQuery, newTxn)); + QueryFutureList queryFuture = new QueryFutureList<>(new CallableQueryList<>(this, spiQuery, newTxn)); backgroundExecutor.execute(queryFuture.getFutureTask()); return queryFuture; } + @Nonnull @Override public PagedList findPagedList(Query query, Transaction transaction) { SpiQuery spiQuery = (SpiQuery) query; @@ -1387,6 +1390,7 @@ public final class DefaultServer implements SpiServer, SpiEbeanServer { return new LimitOffsetPagedList<>(this, spiQuery); } + @Nonnull @Override public QueryIterator findIterate(Query query, Transaction t) { SpiOrmQueryRequest request = createQueryRequest(Type.ITERATE, query, t); @@ -1399,11 +1403,13 @@ public final class DefaultServer implements SpiServer, SpiEbeanServer { } } + @Nonnull @Override public Stream findLargeStream(Query query, Transaction transaction) { return findStream(query, transaction); } + @Nonnull @Override public Stream findStream(Query query, Transaction transaction) { SpiOrmQueryRequest request = createQueryRequest(Type.ITERATE, query, transaction); @@ -1470,6 +1476,7 @@ public final class DefaultServer implements SpiServer, SpiEbeanServer { // no try finally - findEachWhile guarantee's cleanup of the transaction if required } + @Nonnull @Override public List> findVersions(Query query, Transaction transaction) { SpiOrmQueryRequest request = createQueryRequest(Type.LIST, query, transaction); @@ -1481,6 +1488,7 @@ public final class DefaultServer implements SpiServer, SpiEbeanServer { } } + @Nonnull @Override public List findList(Query query, Transaction t) { return findList(query, t, false); @@ -1540,6 +1548,7 @@ public final class DefaultServer implements SpiServer, SpiEbeanServer { } } + @Nonnull @Override public List findList(SqlQuery query, Transaction t) { RelationalQueryRequest request = new RelationalQueryRequest(this, relationalQueryEngine, query, t); @@ -2241,6 +2250,7 @@ public final class DefaultServer implements SpiServer, SpiEbeanServer { return checkUniqueness(bean, null); } + @Nonnull @Override public Set checkUniqueness(Object bean, Transaction transaction) { EntityBean entityBean = checkEntityBean(bean); @@ -2252,14 +2262,11 @@ public final class DefaultServer implements SpiServer, SpiEbeanServer { } Object id = idProperty.getVal(entityBean); if (entityBean._ebean_getIntercept().isNew() && id != null) { - // Primary Key is changeable only on new models - so skip check if we are not - // new. + // Primary Key is changeable only on new models - so skip check if we are not new Query query = new DefaultOrmQuery<>(beanDesc, this, expressionFactory); query.setId(id); if (findCount(query, transaction) > 0) { - Set ret = new HashSet<>(); - ret.add(idProperty); - return ret; + return Collections.singleton(idProperty); } } for (BeanProperty[] props : beanDesc.getUniqueProps()) { From 2a5fd7f3a993909cf9a2a8c53a3b8d302a71d582 Mon Sep 17 00:00:00 2001 From: Robin Bygrave Date: Tue, 30 Mar 2021 16:02:27 +1300 Subject: [PATCH 177/447] #2210 - Improve query plan capture - ability to change default threshold micros --- .../java/io/ebean/meta/QueryPlanRequest.java | 7 +++++- .../api/NoopQueryPlanManager.java | 5 ++++ .../ebeaninternal/api/QueryPlanManager.java | 5 ++++ .../server/core/DefaultServer.java | 3 +++ .../server/query/CQueryPlanManager.java | 9 +++++-- .../query/finder/TestCustomerFinder.java | 24 +++++++++++++++---- 6 files changed, 46 insertions(+), 7 deletions(-) diff --git a/ebean-api/src/main/java/io/ebean/meta/QueryPlanRequest.java b/ebean-api/src/main/java/io/ebean/meta/QueryPlanRequest.java index 3510b30cc..c4a69b1aa 100644 --- a/ebean-api/src/main/java/io/ebean/meta/QueryPlanRequest.java +++ b/ebean-api/src/main/java/io/ebean/meta/QueryPlanRequest.java @@ -41,6 +41,9 @@ public class QueryPlanRequest { /** * Set the maximum number of plans to capture. + *

+ * Use this to limit how much query plan capturing is done as query + * plan capture is actual database load. */ public void setMaxCount(int maxCount) { this.maxCount = maxCount; @@ -58,7 +61,9 @@ public class QueryPlanRequest { /** * Set the maximum amount of time we want to use to capture plans. *

- * Query plan collection will stop once this time is exceeded. + * Query plan collection will stop once this time is exceeded. We use + * this to ensure the query plan capture does not use excessive amount + * of time - put too much load on the database. */ public void setMaxTimeMillis(long maxTimeMillis) { this.maxTimeMillis = maxTimeMillis; diff --git a/ebean-core/src/main/java/io/ebeaninternal/api/NoopQueryPlanManager.java b/ebean-core/src/main/java/io/ebeaninternal/api/NoopQueryPlanManager.java index e00ad57f1..813121f92 100644 --- a/ebean-core/src/main/java/io/ebeaninternal/api/NoopQueryPlanManager.java +++ b/ebean-core/src/main/java/io/ebeaninternal/api/NoopQueryPlanManager.java @@ -8,6 +8,11 @@ import java.util.List; class NoopQueryPlanManager implements QueryPlanManager { + @Override + public void setDefaultThreshold(long thresholdMicros) { + // do nothing + } + @Override public SpiQueryBindCapture createBindCapture(SpiQueryPlan queryPlan) { return SpiQueryBindCapture.NOOP; diff --git a/ebean-core/src/main/java/io/ebeaninternal/api/QueryPlanManager.java b/ebean-core/src/main/java/io/ebeaninternal/api/QueryPlanManager.java index f9750c47a..da7ce2b43 100644 --- a/ebean-core/src/main/java/io/ebeaninternal/api/QueryPlanManager.java +++ b/ebean-core/src/main/java/io/ebeaninternal/api/QueryPlanManager.java @@ -12,6 +12,11 @@ public interface QueryPlanManager { QueryPlanManager NOOP = new NoopQueryPlanManager(); + /** + * Update the global default threshold used when new query plans are created. + */ + void setDefaultThreshold(long thresholdMicros); + /** * Create the bind capture for the given query plan. */ diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/core/DefaultServer.java b/ebean-core/src/main/java/io/ebeaninternal/server/core/DefaultServer.java index 5e8db9c1c..0e4d22768 100644 --- a/ebean-core/src/main/java/io/ebeaninternal/server/core/DefaultServer.java +++ b/ebean-core/src/main/java/io/ebeaninternal/server/core/DefaultServer.java @@ -2329,6 +2329,9 @@ public final class DefaultServer implements SpiServer, SpiEbeanServer { } List queryPlanInit(QueryPlanInit initRequest) { + if (initRequest.isAll()) { + queryPlanManager.setDefaultThreshold(initRequest.getThresholdMicros()); + } return beanDescriptorManager.queryPlanInit(initRequest); } diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/query/CQueryPlanManager.java b/ebean-core/src/main/java/io/ebeaninternal/server/query/CQueryPlanManager.java index c2e6aa358..4ff62f44d 100644 --- a/ebean-core/src/main/java/io/ebeaninternal/server/query/CQueryPlanManager.java +++ b/ebean-core/src/main/java/io/ebeaninternal/server/query/CQueryPlanManager.java @@ -30,14 +30,14 @@ public class CQueryPlanManager implements QueryPlanManager { private final TransactionManager transactionManager; - private final long defaultThreshold; - private final QueryPlanLogger planLogger; private final TimedMetric timeCollection; private final TimedMetric timeBindCapture; + private long defaultThreshold; + public CQueryPlanManager(TransactionManager transactionManager, long defaultThreshold, QueryPlanLogger planLogger, ExtraMetrics extraMetrics) { this.transactionManager = transactionManager; this.defaultThreshold = defaultThreshold; @@ -46,6 +46,11 @@ public class CQueryPlanManager implements QueryPlanManager { this.timeBindCapture = extraMetrics.getBindCapture(); } + @Override + public void setDefaultThreshold(long thresholdMicros) { + this.defaultThreshold = thresholdMicros; + } + @Override public SpiQueryBindCapture createBindCapture(SpiQueryPlan queryPlan) { return new CQueryBindCapture(this, queryPlan, defaultThreshold); diff --git a/ebean-core/src/test/java/org/tests/query/finder/TestCustomerFinder.java b/ebean-core/src/test/java/org/tests/query/finder/TestCustomerFinder.java index 48cc264c6..8446f9d5b 100644 --- a/ebean-core/src/test/java/org/tests/query/finder/TestCustomerFinder.java +++ b/ebean-core/src/test/java/org/tests/query/finder/TestCustomerFinder.java @@ -175,17 +175,24 @@ public class TestCustomerFinder extends BaseTestCase { ResetBasicData.reset(); + // change default collect query plan threshold to 200 micros + QueryPlanInit init0 = new QueryPlanInit(); + init0.setAll(true); + init0.setThresholdMicros(200); + final List plans = server().getMetaInfoManager().queryPlanInit(init0); + assertThat(plans.size()).isGreaterThan(1); + // the server has some plans runQueries(); - // enable query plan bind capture on all plans threshold 100 micros + // change query plan threshold to 100 micros QueryPlanInit init = new QueryPlanInit(); init.setAll(true); init.setThresholdMicros(100); final List appliedToPlans = server().getMetaInfoManager().queryPlanInit(init); assertThat(appliedToPlans.size()).isGreaterThan(4); - // will collect bind captures + // run queries again runQueries(); ServerMetrics metrics = server().getMetaInfoManager().collectMetrics(); @@ -203,12 +210,21 @@ public class TestCustomerFinder extends BaseTestCase { // obtains db query plans ... QueryPlanRequest request = new QueryPlanRequest(); - List plans = server().getMetaInfoManager().queryPlanCollectNow(request); - assertThat(plans).isNotEmpty(); + // collect max 1000 plans (use something more like 10) + request.setMaxCount(1_000); + // don't collect any more plans if used 10 secs + request.setMaxTimeMillis(10_000); + List plans0 = server().getMetaInfoManager().queryPlanCollectNow(request); + assertThat(plans0).isNotEmpty(); for (MetaQueryPlan plan : plans) { + logger.info("queryplan label:{}, queryTimeMicros:{} loc:{} sql:{} bind:{} plan:{}", + plan.getLabel(), plan.getQueryTimeMicros(), plan.getProfileLocation(), + plan.getSql(), plan.getBind(), plan.getPlan()); System.out.println(plan); } + + //DB.getBackgroundExecutor().scheduleWithFixedDelay(...) } @Test From bcfd9cab1db0a5b81b9e71b2c07adc9bdfa2ed52 Mon Sep 17 00:00:00 2001 From: Robin Bygrave Date: Tue, 30 Mar 2021 16:05:42 +1300 Subject: [PATCH 178/447] #2210 - Improve query plan capture - bump threshold multiplier to 1.5 --- .../java/io/ebeaninternal/server/query/CQueryBindCapture.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/query/CQueryBindCapture.java b/ebean-core/src/main/java/io/ebeaninternal/server/query/CQueryBindCapture.java index 713169640..e3a1a5e54 100644 --- a/ebean-core/src/main/java/io/ebeaninternal/server/query/CQueryBindCapture.java +++ b/ebean-core/src/main/java/io/ebeaninternal/server/query/CQueryBindCapture.java @@ -9,7 +9,7 @@ import java.util.concurrent.locks.ReentrantLock; class CQueryBindCapture implements SpiQueryBindCapture { - private static final double multiplier = 1.3d; + private static final double multiplier = 1.5d; private final ReentrantLock lock = new ReentrantLock(); private final CQueryPlanManager manager; From ee8bb5ef751ccbc9cd9b1d6fdd0b561ec8e781a7 Mon Sep 17 00:00:00 2001 From: Robin Bygrave Date: Tue, 30 Mar 2021 23:19:21 +1300 Subject: [PATCH 179/447] #2211 - Improve query plan capture - Add default mechanism to log captured query plans --- .../java/io/ebean/config/DatabaseConfig.java | 94 ++++++++++++++++++- .../io/ebean/config/QueryPlanCapture.java | 34 +++++++ .../io/ebean/config/QueryPlanListener.java | 13 +++ .../server/core/DefaultQueryPlanListener.java | 25 +++++ .../server/core/DefaultServer.java | 33 +++++-- .../io/ebean/config/ServerConfigTest.java | 15 +++ 6 files changed, 206 insertions(+), 8 deletions(-) create mode 100644 ebean-api/src/main/java/io/ebean/config/QueryPlanCapture.java create mode 100644 ebean-api/src/main/java/io/ebean/config/QueryPlanListener.java create mode 100644 ebean-core/src/main/java/io/ebeaninternal/server/core/DefaultQueryPlanListener.java diff --git a/ebean-api/src/main/java/io/ebean/config/DatabaseConfig.java b/ebean-api/src/main/java/io/ebean/config/DatabaseConfig.java index 49c458743..1cbfa9d3e 100644 --- a/ebean-api/src/main/java/io/ebean/config/DatabaseConfig.java +++ b/ebean-api/src/main/java/io/ebean/config/DatabaseConfig.java @@ -498,7 +498,7 @@ public class DatabaseConfig { private boolean notifyL2CacheInForeground; /** - * Set to true to support query plan capture. + * Set to true to enable bind capture required for query plan capture. */ private boolean collectQueryPlans; @@ -507,6 +507,15 @@ public class DatabaseConfig { */ private long collectQueryPlanThresholdMicros = Long.MAX_VALUE; + /** + * Set to true to enable automatic query plan capture. + */ + private boolean queryPlanCapture; + private long queryPlanCapturePeriodSecs = 60 * 10; // 10 minutes + private long queryPlanCaptureMaxTimeMillis = 10_000; // 10 seconds + private int queryPlanCaptureMaxCount = 10; + private QueryPlanListener queryPlanListener; + /** * The time in millis used to determine when a query is alerted for being slow. */ @@ -1045,7 +1054,6 @@ public class DatabaseConfig { * This is a performance optimisation to reduce the number times Ebean * requests a sequence to be used as an Id for a bean (aka reduce network * chatter). - */ public void setDatabaseSequenceBatchSize(int databaseSequenceBatchSize) { platformConfig.setDatabaseSequenceBatchSize(databaseSequenceBatchSize); @@ -2807,6 +2815,10 @@ public class DatabaseConfig { slowQueryMillis = p.getLong("slowQueryMillis", slowQueryMillis); collectQueryPlans = p.getBoolean("collectQueryPlans", collectQueryPlans); collectQueryPlanThresholdMicros = p.getLong("collectQueryPlanThresholdMicros", collectQueryPlanThresholdMicros); + queryPlanCapture = p.getBoolean("queryPlan.capture", queryPlanCapture); + queryPlanCapturePeriodSecs = p.getLong("queryPlan.capturePeriodSecs", queryPlanCapturePeriodSecs); + queryPlanCaptureMaxTimeMillis = p.getLong("queryPlan.captureMaxTimeMillis", queryPlanCaptureMaxTimeMillis); + queryPlanCaptureMaxCount = p.getInt("queryPlan.captureMaxCount", queryPlanCaptureMaxCount); docStoreOnly = p.getBoolean("docStoreOnly", docStoreOnly); disableL2Cache = p.getBoolean("disableL2Cache", disableL2Cache); localOnlyL2Cache = p.getBoolean("localOnlyL2Cache", localOnlyL2Cache); @@ -3201,6 +3213,84 @@ public class DatabaseConfig { this.collectQueryPlanThresholdMicros = collectQueryPlanThresholdMicros; } + /** + * Return true if periodic capture of query plans is enabled. + */ + public boolean isQueryPlanCapture() { + return queryPlanCapture; + } + + /** + * Set to true to turn on periodic capture of query plans. + */ + public void setQueryPlanCapture(boolean queryPlanCapture) { + this.queryPlanCapture = queryPlanCapture; + } + + /** + * Return the frequency to capture query plans. + */ + public long getQueryPlanCapturePeriodSecs() { + return queryPlanCapturePeriodSecs; + } + + /** + * Set the frequency in seconds to capture query plans. + */ + public void setQueryPlanCapturePeriodSecs(long queryPlanCapturePeriodSecs) { + this.queryPlanCapturePeriodSecs = queryPlanCapturePeriodSecs; + } + + /** + * Return the time after which a capture query plans request will + * stop capturing more query plans. + *

+ * Effectively this controls the amount of load/time we want to + * allow for query plan capture. + */ + public long getQueryPlanCaptureMaxTimeMillis() { + return queryPlanCaptureMaxTimeMillis; + } + + /** + * Set the time after which a capture query plans request will + * stop capturing more query plans. + *

+ * Effectively this controls the amount of load/time we want to + * allow for query plan capture. + */ + public void setQueryPlanCaptureMaxTimeMillis(long queryPlanCaptureMaxTimeMillis) { + this.queryPlanCaptureMaxTimeMillis = queryPlanCaptureMaxTimeMillis; + } + + /** + * Return the max number of query plans captured per request. + */ + public int getQueryPlanCaptureMaxCount() { + return queryPlanCaptureMaxCount; + } + + /** + * Set the max number of query plans captured per request. + */ + public void setQueryPlanCaptureMaxCount(int queryPlanCaptureMaxCount) { + this.queryPlanCaptureMaxCount = queryPlanCaptureMaxCount; + } + + /** + * Return the listener used to process captured query plans. + */ + public QueryPlanListener getQueryPlanListener() { + return queryPlanListener; + } + + /** + * Set the listener used to process captured query plans. + */ + public void setQueryPlanListener(QueryPlanListener queryPlanListener) { + this.queryPlanListener = queryPlanListener; + } + /** * Return true if metrics should be dumped when the server is shutdown. */ diff --git a/ebean-api/src/main/java/io/ebean/config/QueryPlanCapture.java b/ebean-api/src/main/java/io/ebean/config/QueryPlanCapture.java new file mode 100644 index 000000000..6f34097fe --- /dev/null +++ b/ebean-api/src/main/java/io/ebean/config/QueryPlanCapture.java @@ -0,0 +1,34 @@ +package io.ebean.config; + +import io.ebean.Database; +import io.ebean.meta.MetaQueryPlan; + +import java.util.List; + +/** + * The captured query plans. + */ +public class QueryPlanCapture { + + private final Database database; + private final List plans; + + public QueryPlanCapture(Database database, List plans) { + this.database = database; + this.plans = plans; + } + + /** + * Return the database the plans were captured for. + */ + public Database getDatabase() { + return database; + } + + /** + * Return the captured query plans. + */ + public List getPlans() { + return plans; + } +} diff --git a/ebean-api/src/main/java/io/ebean/config/QueryPlanListener.java b/ebean-api/src/main/java/io/ebean/config/QueryPlanListener.java new file mode 100644 index 000000000..8368186cf --- /dev/null +++ b/ebean-api/src/main/java/io/ebean/config/QueryPlanListener.java @@ -0,0 +1,13 @@ +package io.ebean.config; + +/** + * EXPERIMENTAL: Listener for captured query plans. + */ +@FunctionalInterface +public interface QueryPlanListener { + + /** + * Process the captured query plans. + */ + void process(QueryPlanCapture capture); +} diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/core/DefaultQueryPlanListener.java b/ebean-core/src/main/java/io/ebeaninternal/server/core/DefaultQueryPlanListener.java new file mode 100644 index 000000000..051d331ba --- /dev/null +++ b/ebean-core/src/main/java/io/ebeaninternal/server/core/DefaultQueryPlanListener.java @@ -0,0 +1,25 @@ +package io.ebeaninternal.server.core; + +import io.ebean.config.QueryPlanCapture; +import io.ebean.config.QueryPlanListener; +import io.ebean.meta.MetaQueryPlan; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +class DefaultQueryPlanListener implements QueryPlanListener { + + static final QueryPlanListener INSTANT = new DefaultQueryPlanListener(); + + private static final Logger log = LoggerFactory.getLogger("io.ebean.QUERYPLAN"); + + @Override + public void process(QueryPlanCapture capture) { + // better to log this in JSON form? + String dbName = capture.getDatabase().getName(); + for (MetaQueryPlan plan : capture.getPlans()) { + log.info("queryPlan db:{} label:{} queryTimeMicros:{} loc:{} sql:{} bind:{} plan:{}", + dbName, plan.getLabel(), plan.getQueryTimeMicros(), plan.getProfileLocation(), + plan.getSql(), plan.getBind(), plan.getPlan()); + } + } +} diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/core/DefaultServer.java b/ebean-core/src/main/java/io/ebeaninternal/server/core/DefaultServer.java index 0e4d22768..52b94bfb6 100644 --- a/ebean-core/src/main/java/io/ebeaninternal/server/core/DefaultServer.java +++ b/ebean-core/src/main/java/io/ebeaninternal/server/core/DefaultServer.java @@ -45,12 +45,7 @@ import io.ebean.bean.PersistenceContext.WithOption; import io.ebean.bean.SingleBeanLoader; import io.ebean.cache.ServerCacheManager; import io.ebean.common.CopyOnFirstWriteList; -import io.ebean.config.CurrentTenantProvider; -import io.ebean.config.DatabaseConfig; -import io.ebean.config.EncryptKeyManager; -import io.ebean.config.SlowQueryEvent; -import io.ebean.config.SlowQueryListener; -import io.ebean.config.TenantMode; +import io.ebean.config.*; import io.ebean.config.dbplatform.DatabasePlatform; import io.ebean.event.BeanPersistController; import io.ebean.event.ShutdownManager; @@ -145,6 +140,7 @@ import java.util.Optional; import java.util.Set; import java.util.Spliterator; import java.util.concurrent.Callable; +import java.util.concurrent.TimeUnit; import java.util.concurrent.locks.ReentrantLock; import java.util.function.Consumer; import java.util.function.Function; @@ -404,6 +400,31 @@ public final class DefaultServer implements SpiServer, SpiEbeanServer { migrationRunner.loadProperties(config.getProperties()); migrationRunner.run(config.getDataSource()); } + startQueryPlanCapture(); + } + + private void startQueryPlanCapture() { + if (config.isQueryPlanCapture()) { + long secs = config.getQueryPlanCapturePeriodSecs(); + if (secs > 10) { + logger.info("capture query plan enabled, every {}secs", secs); + backgroundExecutor.scheduleWithFixedDelay(this::collectQueryPlans, secs, secs, TimeUnit.SECONDS); + } + } + } + + private void collectQueryPlans() { + QueryPlanRequest request = new QueryPlanRequest(); + request.setMaxCount(config.getQueryPlanCaptureMaxCount()); + request.setMaxTimeMillis(config.getQueryPlanCaptureMaxTimeMillis()); + + // obtains query explain plans ... + List plans = metaInfoManager.queryPlanCollectNow(request); + QueryPlanListener listener = config.getQueryPlanListener(); + if (listener == null) { + listener = DefaultQueryPlanListener.INSTANT; + } + listener.process(new QueryPlanCapture(this, plans)); } @Override diff --git a/ebean-core/src/test/java/io/ebean/config/ServerConfigTest.java b/ebean-core/src/test/java/io/ebean/config/ServerConfigTest.java index 8fda93985..b23ccdbb6 100644 --- a/ebean-core/src/test/java/io/ebean/config/ServerConfigTest.java +++ b/ebean-core/src/test/java/io/ebean/config/ServerConfigTest.java @@ -76,6 +76,11 @@ public class ServerConfigTest { props.setProperty("forUpdateNoKey", "true"); props.setProperty("defaultServer", "false"); + props.setProperty("queryPlan.capture", "true"); + props.setProperty("queryPlan.capturePeriodSecs", "42"); + props.setProperty("queryPlan.captureMaxTimeMillis", "560"); + props.setProperty("queryPlan.captureMaxCount", "7"); + serverConfig.loadFromProperties(props); assertFalse(serverConfig.isDefaultServer()); @@ -106,6 +111,11 @@ public class ServerConfigTest { assertEquals(4, serverConfig.getBackgroundExecutorSchedulePoolSize()); assertEquals(98, serverConfig.getBackgroundExecutorShutdownSecs()); + assertTrue(serverConfig.isQueryPlanCapture()); + assertEquals(42, serverConfig.getQueryPlanCapturePeriodSecs()); + assertEquals(560, serverConfig.getQueryPlanCaptureMaxTimeMillis()); + assertEquals(7, serverConfig.getQueryPlanCaptureMaxCount()); + assertThat(serverConfig.getMappingLocations()).containsExactly("classpath:/foo","bar"); serverConfig.setPersistBatch(PersistBatch.NONE); @@ -146,6 +156,11 @@ public class ServerConfigTest { assertTrue(serverConfig.isAutoLoadModuleInfo()); assertEquals(Long.MAX_VALUE, serverConfig.getCollectQueryPlanThresholdMicros()); + assertFalse(serverConfig.isQueryPlanCapture()); + assertEquals(600, serverConfig.getQueryPlanCapturePeriodSecs()); + assertEquals(10000L, serverConfig.getQueryPlanCaptureMaxTimeMillis()); + assertEquals(10, serverConfig.getQueryPlanCaptureMaxCount()); + serverConfig.setLoadModuleInfo(false); assertFalse(serverConfig.isAutoLoadModuleInfo()); } From a8bf27da550e9438e8195c3162c91ed840c5cfc1 Mon Sep 17 00:00:00 2001 From: Robin Bygrave Date: Tue, 30 Mar 2021 23:44:30 +1300 Subject: [PATCH 180/447] #2211 - Improve query plan capture - Align config property names collectQueryPlans -> queryPlanEnable collectQueryPlanThresholdMicros -> queryPlanThresholdMicros properties keys: ebean.collectQueryPlans -> ebean.queryPlan.enable ebean.collectQueryPlanThresholdMicros -> ebean.queryPlan.thresholdMicros This then aligns all the queryPlan related properties together which is important in order to avoid confusion. --- .../java/io/ebean/config/DatabaseConfig.java | 29 ++++++++++--------- .../server/core/InternalConfiguration.java | 4 +-- .../io/ebean/config/ServerConfigTest.java | 9 ++++-- .../src/test/resources/ebean.properties | 4 +-- 4 files changed, 26 insertions(+), 20 deletions(-) diff --git a/ebean-api/src/main/java/io/ebean/config/DatabaseConfig.java b/ebean-api/src/main/java/io/ebean/config/DatabaseConfig.java index 1cbfa9d3e..c4195f0be 100644 --- a/ebean-api/src/main/java/io/ebean/config/DatabaseConfig.java +++ b/ebean-api/src/main/java/io/ebean/config/DatabaseConfig.java @@ -500,15 +500,15 @@ public class DatabaseConfig { /** * Set to true to enable bind capture required for query plan capture. */ - private boolean collectQueryPlans; + private boolean queryPlanEnable; /** * The default threshold in micros for collecting query plans. */ - private long collectQueryPlanThresholdMicros = Long.MAX_VALUE; + private long queryPlanThresholdMicros = Long.MAX_VALUE; /** - * Set to true to enable automatic query plan capture. + * Set to true to enable automatic periodic query plan capture. */ private boolean queryPlanCapture; private long queryPlanCapturePeriodSecs = 60 * 10; // 10 minutes @@ -2813,8 +2813,8 @@ public class DatabaseConfig { dumpMetricsOptions = p.get("dumpMetricsOptions", dumpMetricsOptions); queryPlanTTLSeconds = p.getInt("queryPlanTTLSeconds", queryPlanTTLSeconds); slowQueryMillis = p.getLong("slowQueryMillis", slowQueryMillis); - collectQueryPlans = p.getBoolean("collectQueryPlans", collectQueryPlans); - collectQueryPlanThresholdMicros = p.getLong("collectQueryPlanThresholdMicros", collectQueryPlanThresholdMicros); + queryPlanEnable = p.getBoolean("queryPlan.enable", queryPlanEnable); + queryPlanThresholdMicros = p.getLong("queryPlan.thresholdMicros", queryPlanThresholdMicros); queryPlanCapture = p.getBoolean("queryPlan.capture", queryPlanCapture); queryPlanCapturePeriodSecs = p.getLong("queryPlan.capturePeriodSecs", queryPlanCapturePeriodSecs); queryPlanCaptureMaxTimeMillis = p.getLong("queryPlan.captureMaxTimeMillis", queryPlanCaptureMaxTimeMillis); @@ -3188,29 +3188,32 @@ public class DatabaseConfig { /** * Return true if query plan capture is enabled. */ - public boolean isCollectQueryPlans() { - return collectQueryPlans; + public boolean isQueryPlanEnable() { + return queryPlanEnable; } /** * Set to true to enable query plan capture. */ - public void setCollectQueryPlans(boolean collectQueryPlans) { - this.collectQueryPlans = collectQueryPlans; + public void setQueryPlanEnable(boolean queryPlanEnable) { + this.queryPlanEnable = queryPlanEnable; } /** * Return the query plan collection threshold in microseconds. */ - public long getCollectQueryPlanThresholdMicros() { - return collectQueryPlanThresholdMicros; + public long getQueryPlanThresholdMicros() { + return queryPlanThresholdMicros; } /** * Set the query plan collection threshold in microseconds. + *

+ * Queries executing slower than this will have bind values captured such that later + * the query plan can be captured and reported. */ - public void setCollectQueryPlanThresholdMicros(long collectQueryPlanThresholdMicros) { - this.collectQueryPlanThresholdMicros = collectQueryPlanThresholdMicros; + public void setQueryPlanThresholdMicros(long queryPlanThresholdMicros) { + this.queryPlanThresholdMicros = queryPlanThresholdMicros; } /** diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/core/InternalConfiguration.java b/ebean-core/src/main/java/io/ebeaninternal/server/core/InternalConfiguration.java index 56ea7589a..8cbbbfa4b 100644 --- a/ebean-core/src/main/java/io/ebeaninternal/server/core/InternalConfiguration.java +++ b/ebean-core/src/main/java/io/ebeaninternal/server/core/InternalConfiguration.java @@ -617,10 +617,10 @@ public class InternalConfiguration { } public QueryPlanManager initQueryPlanManager(TransactionManager transactionManager) { - if (!config.isCollectQueryPlans()) { + if (!config.isQueryPlanEnable()) { return QueryPlanManager.NOOP; } - long threshold = config.getCollectQueryPlanThresholdMicros(); + long threshold = config.getQueryPlanThresholdMicros(); return new CQueryPlanManager(transactionManager, threshold, queryPlanLogger(databasePlatform.getPlatform()), extraMetrics); } diff --git a/ebean-core/src/test/java/io/ebean/config/ServerConfigTest.java b/ebean-core/src/test/java/io/ebean/config/ServerConfigTest.java index b23ccdbb6..f93c18d26 100644 --- a/ebean-core/src/test/java/io/ebean/config/ServerConfigTest.java +++ b/ebean-core/src/test/java/io/ebean/config/ServerConfigTest.java @@ -72,10 +72,11 @@ public class ServerConfigTest { props.setProperty("enabledL2Regions", "r0,users,orgs"); props.setProperty("caseSensitiveCollation", "false"); props.setProperty("loadModuleInfo", "true"); - props.setProperty("collectQueryPlanThresholdMicros", "10000"); props.setProperty("forUpdateNoKey", "true"); props.setProperty("defaultServer", "false"); + props.setProperty("queryPlan.enable", "true"); + props.setProperty("queryPlan.thresholdMicros", "10000"); props.setProperty("queryPlan.capture", "true"); props.setProperty("queryPlan.capturePeriodSecs", "42"); props.setProperty("queryPlan.captureMaxTimeMillis", "560"); @@ -102,7 +103,6 @@ public class ServerConfigTest { assertEquals(PlatformConfig.DbUuid.BINARY, serverConfig.getPlatformConfig().getDbUuid()); assertEquals(JsonConfig.DateTime.MILLIS, serverConfig.getJsonDateTime()); assertEquals(JsonConfig.Date.MILLIS, serverConfig.getJsonDate()); - assertEquals(10000, serverConfig.getCollectQueryPlanThresholdMicros()); assertEquals("r0,users,orgs", serverConfig.getEnabledL2Regions()); @@ -111,6 +111,8 @@ public class ServerConfigTest { assertEquals(4, serverConfig.getBackgroundExecutorSchedulePoolSize()); assertEquals(98, serverConfig.getBackgroundExecutorShutdownSecs()); + assertTrue(serverConfig.isQueryPlanEnable()); + assertEquals(10000, serverConfig.getQueryPlanThresholdMicros()); assertTrue(serverConfig.isQueryPlanCapture()); assertEquals(42, serverConfig.getQueryPlanCapturePeriodSecs()); assertEquals(560, serverConfig.getQueryPlanCaptureMaxTimeMillis()); @@ -154,8 +156,9 @@ public class ServerConfigTest { assertEquals(JsonConfig.Date.ISO8601, serverConfig.getJsonDate()); assertTrue(serverConfig.getPlatformConfig().isCaseSensitiveCollation()); assertTrue(serverConfig.isAutoLoadModuleInfo()); - assertEquals(Long.MAX_VALUE, serverConfig.getCollectQueryPlanThresholdMicros()); + assertFalse(serverConfig.isQueryPlanEnable()); + assertEquals(Long.MAX_VALUE, serverConfig.getQueryPlanThresholdMicros()); assertFalse(serverConfig.isQueryPlanCapture()); assertEquals(600, serverConfig.getQueryPlanCapturePeriodSecs()); assertEquals(10000L, serverConfig.getQueryPlanCaptureMaxTimeMillis()); diff --git a/ebean-core/src/test/resources/ebean.properties b/ebean-core/src/test/resources/ebean.properties index 953d2c720..aa1210739 100644 --- a/ebean-core/src/test/resources/ebean.properties +++ b/ebean-core/src/test/resources/ebean.properties @@ -27,8 +27,8 @@ datasource.default=h2 ebean.dumpMetricsOnShutdown=true ebean.dumpMetricsOptions=sql,hash -#ebean.collectQueryPlanThresholdMicros=1000 -ebean.collectQueryPlans=true +#ebean.queryPlan.thresholdMicros=1000 +ebean.queryPlan.enable=true ebean.autoReadOnlyDataSource=true #datasource.h2-ro.url=jdbc:h2:mem:tests From 1bf09ddd38c39f7814815ae88ee1072e994101a3 Mon Sep 17 00:00:00 2001 From: Robin Bygrave Date: Tue, 30 Mar 2021 23:49:44 +1300 Subject: [PATCH 181/447] #2211 - Improve javadoc for queryPlanTTLSeconds Hopefully people understand it is unrelated. Unfortunately we now have some properties with similar names so maybe we need a better name for this sometime in the future. --- .../src/main/java/io/ebean/config/DatabaseConfig.java | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/ebean-api/src/main/java/io/ebean/config/DatabaseConfig.java b/ebean-api/src/main/java/io/ebean/config/DatabaseConfig.java index c4195f0be..bf4c61675 100644 --- a/ebean-api/src/main/java/io/ebean/config/DatabaseConfig.java +++ b/ebean-api/src/main/java/io/ebean/config/DatabaseConfig.java @@ -3108,14 +3108,17 @@ public class DatabaseConfig { } /** - * Return the query plan time to live. + * Return the time to live for ebean's internal query plan. */ public int getQueryPlanTTLSeconds() { return queryPlanTTLSeconds; } /** - * Set the query plan time to live. + * Set the time to live for ebean's internal query plan. + *

+ * This is the plan that knows how to execute the query, read the result + * and collects execution metrics. By default this is set to 5 mins. */ public void setQueryPlanTTLSeconds(int queryPlanTTLSeconds) { this.queryPlanTTLSeconds = queryPlanTTLSeconds; From f7035eb2289c035c2f762166118c76c01a056051 Mon Sep 17 00:00:00 2001 From: rob bygrave Date: Wed, 31 Mar 2021 00:06:04 +1300 Subject: [PATCH 182/447] [maven-release-plugin] prepare release ebean-parent-12.8.1 --- ebean-api/pom.xml | 2 +- ebean-autotune/pom.xml | 6 +++--- ebean-bom/pom.xml | 30 +++++++++++++++--------------- ebean-core-type/pom.xml | 4 ++-- ebean-core/pom.xml | 10 +++++----- ebean-ddl-generator/pom.xml | 6 +++--- ebean-externalmapping-api/pom.xml | 2 +- ebean-externalmapping-xml/pom.xml | 10 +++++----- ebean-postgis/pom.xml | 6 +++--- ebean-querybean/pom.xml | 10 +++++----- ebean-redis/pom.xml | 12 ++++++------ ebean-test/pom.xml | 6 +++--- ebean/pom.xml | 8 ++++---- kotlin-querybean-generator/pom.xml | 8 ++++---- pom.xml | 4 ++-- querybean-generator/pom.xml | 2 +- 16 files changed, 63 insertions(+), 63 deletions(-) diff --git a/ebean-api/pom.xml b/ebean-api/pom.xml index ce3ba3688..d24999338 100644 --- a/ebean-api/pom.xml +++ b/ebean-api/pom.xml @@ -4,7 +4,7 @@ ebean-parent io.ebean - 12.8.1-SNAPSHOT + 12.8.1 ebean api diff --git a/ebean-autotune/pom.xml b/ebean-autotune/pom.xml index 5c081a9df..5897d06d5 100644 --- a/ebean-autotune/pom.xml +++ b/ebean-autotune/pom.xml @@ -4,7 +4,7 @@ ebean-parent io.ebean - 12.8.1-SNAPSHOT + 12.8.1 @@ -14,7 +14,7 @@ scm:git:git@github.com:ebean-orm/ebean.git - ebean-parent-12.8.0 + ebean-parent-12.8.1 ebean autotune @@ -26,7 +26,7 @@ io.ebean ebean-core - 12.8.1-SNAPSHOT + 12.8.1 provided diff --git a/ebean-bom/pom.xml b/ebean-bom/pom.xml index 665ea80be..e30fff780 100644 --- a/ebean-bom/pom.xml +++ b/ebean-bom/pom.xml @@ -4,7 +4,7 @@ ebean-parent io.ebean - 12.8.1-SNAPSHOT + 12.8.1 ebean bom @@ -81,88 +81,88 @@ io.ebean ebean - 12.8.1-SNAPSHOT + 12.8.1 io.ebean ebean-api - 12.8.1-SNAPSHOT + 12.8.1 io.ebean ebean-core - 12.8.1-SNAPSHOT + 12.8.1 io.ebean ebean-core-type - 12.8.1-SNAPSHOT + 12.8.1 io.ebean ebean-ddl-generator - 12.8.1-SNAPSHOT + 12.8.1 io.ebean ebean-externalmapping-api - 12.8.1-SNAPSHOT + 12.8.1 io.ebean ebean-externalmapping-xml - 12.8.1-SNAPSHOT + 12.8.1 io.ebean ebean-autotune - 12.8.1-SNAPSHOT + 12.8.1 io.ebean ebean-querybean - 12.8.1-SNAPSHOT + 12.8.1 io.ebean querybean-generator - 12.8.1-SNAPSHOT + 12.8.1 provided io.ebean kotlin-querybean-generator - 12.8.1-SNAPSHOT + 12.8.1 provided io.ebean ebean-test - 12.8.1-SNAPSHOT + 12.8.1 test io.ebean ebean-postgis - 12.8.1-SNAPSHOT + 12.8.1 io.ebean ebean-redis - 12.8.1-SNAPSHOT + 12.8.1 diff --git a/ebean-core-type/pom.xml b/ebean-core-type/pom.xml index 386d6d511..0e5b3aa23 100644 --- a/ebean-core-type/pom.xml +++ b/ebean-core-type/pom.xml @@ -4,7 +4,7 @@ ebean-parent io.ebean - 12.8.1-SNAPSHOT + 12.8.1 ebean-core-type @@ -16,7 +16,7 @@ io.ebean ebean-api - 12.8.1-SNAPSHOT + 12.8.1 diff --git a/ebean-core/pom.xml b/ebean-core/pom.xml index e8ecd9616..da160656c 100644 --- a/ebean-core/pom.xml +++ b/ebean-core/pom.xml @@ -3,7 +3,7 @@ ebean-parent io.ebean - 12.8.1-SNAPSHOT + 12.8.1 ebean-core @@ -15,7 +15,7 @@ scm:git:git@github.com:ebean-orm/ebean.git - ebean-parent-12.8.0 + ebean-parent-12.8.1 @@ -87,19 +87,19 @@ io.ebean ebean-api - 12.8.1-SNAPSHOT + 12.8.1 io.ebean ebean-core-type - 12.8.1-SNAPSHOT + 12.8.1 io.ebean ebean-externalmapping-api - 12.8.1-SNAPSHOT + 12.8.1 diff --git a/ebean-ddl-generator/pom.xml b/ebean-ddl-generator/pom.xml index 60300f7ce..7f2ea1c76 100644 --- a/ebean-ddl-generator/pom.xml +++ b/ebean-ddl-generator/pom.xml @@ -4,7 +4,7 @@ ebean-parent io.ebean - 12.8.1-SNAPSHOT + 12.8.1 ebean ddl generation @@ -28,14 +28,14 @@ io.ebean ebean-core-type - 12.8.1-SNAPSHOT + 12.8.1 provided io.ebean ebean-core - 12.8.1-SNAPSHOT + 12.8.1 provided diff --git a/ebean-externalmapping-api/pom.xml b/ebean-externalmapping-api/pom.xml index 4efce3a65..92440b9d6 100644 --- a/ebean-externalmapping-api/pom.xml +++ b/ebean-externalmapping-api/pom.xml @@ -4,7 +4,7 @@ ebean-parent io.ebean - 12.8.1-SNAPSHOT + 12.8.1 ebean external mapping api diff --git a/ebean-externalmapping-xml/pom.xml b/ebean-externalmapping-xml/pom.xml index cd885187e..68f5d50a4 100644 --- a/ebean-externalmapping-xml/pom.xml +++ b/ebean-externalmapping-xml/pom.xml @@ -4,7 +4,7 @@ ebean-parent io.ebean - 12.8.1-SNAPSHOT + 12.8.1 @@ -14,7 +14,7 @@ scm:git:git@github.com:ebean-orm/ebean.git - ebean-parent-12.8.0 + ebean-parent-12.8.1 ebean external mapping xml @@ -33,7 +33,7 @@ io.ebean ebean-externalmapping-api - 12.8.1-SNAPSHOT + 12.8.1 @@ -59,14 +59,14 @@ io.ebean ebean-core - 12.8.1-SNAPSHOT + 12.8.1 test io.ebean ebean-ddl-generator - 12.8.1-SNAPSHOT + 12.8.1 test diff --git a/ebean-postgis/pom.xml b/ebean-postgis/pom.xml index 5b4bceec8..dd4967ee3 100644 --- a/ebean-postgis/pom.xml +++ b/ebean-postgis/pom.xml @@ -4,7 +4,7 @@ ebean-parent io.ebean - 12.8.1-SNAPSHOT + 12.8.1 ebean postgis @@ -23,7 +23,7 @@ io.ebean ebean-core - 12.8.1-SNAPSHOT + 12.8.1 provided @@ -74,7 +74,7 @@ io.ebean ebean-test - 12.8.1-SNAPSHOT + 12.8.1 test diff --git a/ebean-querybean/pom.xml b/ebean-querybean/pom.xml index 51f490b3b..8edf552ca 100644 --- a/ebean-querybean/pom.xml +++ b/ebean-querybean/pom.xml @@ -4,7 +4,7 @@ ebean-parent io.ebean - 12.8.1-SNAPSHOT + 12.8.1 ebean querybean @@ -17,7 +17,7 @@ io.ebean ebean-core - 12.8.1-SNAPSHOT + 12.8.1 provided @@ -57,21 +57,21 @@ io.ebean ebean-ddl-generator - 12.8.1-SNAPSHOT + 12.8.1 test io.ebean querybean-generator - 12.8.1-SNAPSHOT + 12.8.1 test io.ebean ebean-test - 12.8.1-SNAPSHOT + 12.8.1 test diff --git a/ebean-redis/pom.xml b/ebean-redis/pom.xml index 2a346b178..c258c4074 100644 --- a/ebean-redis/pom.xml +++ b/ebean-redis/pom.xml @@ -4,7 +4,7 @@ ebean-parent io.ebean - 12.8.1-SNAPSHOT + 12.8.1 ebean-redis @@ -22,35 +22,35 @@ io.ebean ebean-api - 12.8.1-SNAPSHOT + 12.8.1 provided io.ebean ebean-core - 12.8.1-SNAPSHOT + 12.8.1 provided io.ebean ebean-querybean - 12.8.1-SNAPSHOT + 12.8.1 test io.ebean querybean-generator - 12.8.1-SNAPSHOT + 12.8.1 test io.ebean ebean-test - 12.8.1-SNAPSHOT + 12.8.1 test diff --git a/ebean-test/pom.xml b/ebean-test/pom.xml index c32dab0c2..bccddf421 100644 --- a/ebean-test/pom.xml +++ b/ebean-test/pom.xml @@ -4,7 +4,7 @@ ebean-parent io.ebean - 12.8.1-SNAPSHOT + 12.8.1 ebean test @@ -29,14 +29,14 @@ io.ebean ebean-core - 12.8.1-SNAPSHOT + 12.8.1 provided io.ebean ebean-ddl-generator - 12.8.1-SNAPSHOT + 12.8.1 diff --git a/ebean/pom.xml b/ebean/pom.xml index 33c8aeb60..f8204d0cf 100644 --- a/ebean/pom.xml +++ b/ebean/pom.xml @@ -4,7 +4,7 @@ ebean-parent io.ebean - 12.8.1-SNAPSHOT + 12.8.1 ebean composite @@ -22,20 +22,20 @@ io.ebean ebean-api - 12.8.1-SNAPSHOT + 12.8.1 io.ebean ebean-core - 12.8.1-SNAPSHOT + 12.8.1 io.ebean ebean-querybean - 12.8.1-SNAPSHOT + 12.8.1 diff --git a/kotlin-querybean-generator/pom.xml b/kotlin-querybean-generator/pom.xml index 588872181..a9dda9dc6 100644 --- a/kotlin-querybean-generator/pom.xml +++ b/kotlin-querybean-generator/pom.xml @@ -4,7 +4,7 @@ ebean-parent io.ebean - 12.8.1-SNAPSHOT + 12.8.1 kotlin querybean generator @@ -29,7 +29,7 @@ io.ebean ebean-querybean - 12.8.1-SNAPSHOT + 12.8.1 test @@ -43,7 +43,7 @@ io.ebean ebean-core - 12.8.1-SNAPSHOT + 12.8.1 test @@ -64,7 +64,7 @@ io.ebean ebean-ddl-generator - 12.8.1-SNAPSHOT + 12.8.1 test diff --git a/pom.xml b/pom.xml index 297d5ab0a..4064eef48 100644 --- a/pom.xml +++ b/pom.xml @@ -9,7 +9,7 @@ io.ebean ebean-parent - 12.8.1-SNAPSHOT + 12.8.1 pom ebean parent @@ -18,7 +18,7 @@ scm:git:git@github.com:ebean-orm/ebean.git - ebean-parent-12.8.0 + ebean-parent-12.8.1 diff --git a/querybean-generator/pom.xml b/querybean-generator/pom.xml index 6e7bf295f..7da5e03b1 100644 --- a/querybean-generator/pom.xml +++ b/querybean-generator/pom.xml @@ -4,7 +4,7 @@ ebean-parent io.ebean - 12.8.1-SNAPSHOT + 12.8.1 querybean generator From 09d772a5e53ab99c8a0148a1704fbd1312928618 Mon Sep 17 00:00:00 2001 From: rob bygrave Date: Wed, 31 Mar 2021 00:06:13 +1300 Subject: [PATCH 183/447] [maven-release-plugin] prepare for next development iteration --- ebean-api/pom.xml | 2 +- ebean-autotune/pom.xml | 6 +++--- ebean-bom/pom.xml | 30 +++++++++++++++--------------- ebean-core-type/pom.xml | 4 ++-- ebean-core/pom.xml | 10 +++++----- ebean-ddl-generator/pom.xml | 6 +++--- ebean-externalmapping-api/pom.xml | 2 +- ebean-externalmapping-xml/pom.xml | 10 +++++----- ebean-postgis/pom.xml | 6 +++--- ebean-querybean/pom.xml | 10 +++++----- ebean-redis/pom.xml | 12 ++++++------ ebean-test/pom.xml | 6 +++--- ebean/pom.xml | 8 ++++---- kotlin-querybean-generator/pom.xml | 8 ++++---- pom.xml | 4 ++-- querybean-generator/pom.xml | 2 +- 16 files changed, 63 insertions(+), 63 deletions(-) diff --git a/ebean-api/pom.xml b/ebean-api/pom.xml index d24999338..4fe1468ec 100644 --- a/ebean-api/pom.xml +++ b/ebean-api/pom.xml @@ -4,7 +4,7 @@ ebean-parent io.ebean - 12.8.1 + 12.8.2-SNAPSHOT ebean api diff --git a/ebean-autotune/pom.xml b/ebean-autotune/pom.xml index 5897d06d5..700861dd9 100644 --- a/ebean-autotune/pom.xml +++ b/ebean-autotune/pom.xml @@ -4,7 +4,7 @@ ebean-parent io.ebean - 12.8.1 + 12.8.2-SNAPSHOT @@ -14,7 +14,7 @@ scm:git:git@github.com:ebean-orm/ebean.git - ebean-parent-12.8.1 + ebean-parent-12.8.0 ebean autotune @@ -26,7 +26,7 @@ io.ebean ebean-core - 12.8.1 + 12.8.2-SNAPSHOT provided diff --git a/ebean-bom/pom.xml b/ebean-bom/pom.xml index e30fff780..401f6dbdf 100644 --- a/ebean-bom/pom.xml +++ b/ebean-bom/pom.xml @@ -4,7 +4,7 @@ ebean-parent io.ebean - 12.8.1 + 12.8.2-SNAPSHOT ebean bom @@ -81,88 +81,88 @@ io.ebean ebean - 12.8.1 + 12.8.2-SNAPSHOT io.ebean ebean-api - 12.8.1 + 12.8.2-SNAPSHOT io.ebean ebean-core - 12.8.1 + 12.8.2-SNAPSHOT io.ebean ebean-core-type - 12.8.1 + 12.8.2-SNAPSHOT io.ebean ebean-ddl-generator - 12.8.1 + 12.8.2-SNAPSHOT io.ebean ebean-externalmapping-api - 12.8.1 + 12.8.2-SNAPSHOT io.ebean ebean-externalmapping-xml - 12.8.1 + 12.8.2-SNAPSHOT io.ebean ebean-autotune - 12.8.1 + 12.8.2-SNAPSHOT io.ebean ebean-querybean - 12.8.1 + 12.8.2-SNAPSHOT io.ebean querybean-generator - 12.8.1 + 12.8.2-SNAPSHOT provided io.ebean kotlin-querybean-generator - 12.8.1 + 12.8.2-SNAPSHOT provided io.ebean ebean-test - 12.8.1 + 12.8.2-SNAPSHOT test io.ebean ebean-postgis - 12.8.1 + 12.8.2-SNAPSHOT io.ebean ebean-redis - 12.8.1 + 12.8.2-SNAPSHOT diff --git a/ebean-core-type/pom.xml b/ebean-core-type/pom.xml index 0e5b3aa23..be8b15507 100644 --- a/ebean-core-type/pom.xml +++ b/ebean-core-type/pom.xml @@ -4,7 +4,7 @@ ebean-parent io.ebean - 12.8.1 + 12.8.2-SNAPSHOT ebean-core-type @@ -16,7 +16,7 @@ io.ebean ebean-api - 12.8.1 + 12.8.2-SNAPSHOT diff --git a/ebean-core/pom.xml b/ebean-core/pom.xml index da160656c..3652ba9a3 100644 --- a/ebean-core/pom.xml +++ b/ebean-core/pom.xml @@ -3,7 +3,7 @@ ebean-parent io.ebean - 12.8.1 + 12.8.2-SNAPSHOT ebean-core @@ -15,7 +15,7 @@ scm:git:git@github.com:ebean-orm/ebean.git - ebean-parent-12.8.1 + ebean-parent-12.8.0 @@ -87,19 +87,19 @@ io.ebean ebean-api - 12.8.1 + 12.8.2-SNAPSHOT io.ebean ebean-core-type - 12.8.1 + 12.8.2-SNAPSHOT io.ebean ebean-externalmapping-api - 12.8.1 + 12.8.2-SNAPSHOT diff --git a/ebean-ddl-generator/pom.xml b/ebean-ddl-generator/pom.xml index 7f2ea1c76..421166e46 100644 --- a/ebean-ddl-generator/pom.xml +++ b/ebean-ddl-generator/pom.xml @@ -4,7 +4,7 @@ ebean-parent io.ebean - 12.8.1 + 12.8.2-SNAPSHOT ebean ddl generation @@ -28,14 +28,14 @@ io.ebean ebean-core-type - 12.8.1 + 12.8.2-SNAPSHOT provided io.ebean ebean-core - 12.8.1 + 12.8.2-SNAPSHOT provided diff --git a/ebean-externalmapping-api/pom.xml b/ebean-externalmapping-api/pom.xml index 92440b9d6..32a98a767 100644 --- a/ebean-externalmapping-api/pom.xml +++ b/ebean-externalmapping-api/pom.xml @@ -4,7 +4,7 @@ ebean-parent io.ebean - 12.8.1 + 12.8.2-SNAPSHOT ebean external mapping api diff --git a/ebean-externalmapping-xml/pom.xml b/ebean-externalmapping-xml/pom.xml index 68f5d50a4..029f345fc 100644 --- a/ebean-externalmapping-xml/pom.xml +++ b/ebean-externalmapping-xml/pom.xml @@ -4,7 +4,7 @@ ebean-parent io.ebean - 12.8.1 + 12.8.2-SNAPSHOT @@ -14,7 +14,7 @@ scm:git:git@github.com:ebean-orm/ebean.git - ebean-parent-12.8.1 + ebean-parent-12.8.0 ebean external mapping xml @@ -33,7 +33,7 @@ io.ebean ebean-externalmapping-api - 12.8.1 + 12.8.2-SNAPSHOT @@ -59,14 +59,14 @@ io.ebean ebean-core - 12.8.1 + 12.8.2-SNAPSHOT test io.ebean ebean-ddl-generator - 12.8.1 + 12.8.2-SNAPSHOT test diff --git a/ebean-postgis/pom.xml b/ebean-postgis/pom.xml index dd4967ee3..6528624f3 100644 --- a/ebean-postgis/pom.xml +++ b/ebean-postgis/pom.xml @@ -4,7 +4,7 @@ ebean-parent io.ebean - 12.8.1 + 12.8.2-SNAPSHOT ebean postgis @@ -23,7 +23,7 @@ io.ebean ebean-core - 12.8.1 + 12.8.2-SNAPSHOT provided @@ -74,7 +74,7 @@ io.ebean ebean-test - 12.8.1 + 12.8.2-SNAPSHOT test diff --git a/ebean-querybean/pom.xml b/ebean-querybean/pom.xml index 8edf552ca..86d02f68a 100644 --- a/ebean-querybean/pom.xml +++ b/ebean-querybean/pom.xml @@ -4,7 +4,7 @@ ebean-parent io.ebean - 12.8.1 + 12.8.2-SNAPSHOT ebean querybean @@ -17,7 +17,7 @@ io.ebean ebean-core - 12.8.1 + 12.8.2-SNAPSHOT provided @@ -57,21 +57,21 @@ io.ebean ebean-ddl-generator - 12.8.1 + 12.8.2-SNAPSHOT test io.ebean querybean-generator - 12.8.1 + 12.8.2-SNAPSHOT test io.ebean ebean-test - 12.8.1 + 12.8.2-SNAPSHOT test diff --git a/ebean-redis/pom.xml b/ebean-redis/pom.xml index c258c4074..1d3a74a49 100644 --- a/ebean-redis/pom.xml +++ b/ebean-redis/pom.xml @@ -4,7 +4,7 @@ ebean-parent io.ebean - 12.8.1 + 12.8.2-SNAPSHOT ebean-redis @@ -22,35 +22,35 @@ io.ebean ebean-api - 12.8.1 + 12.8.2-SNAPSHOT provided io.ebean ebean-core - 12.8.1 + 12.8.2-SNAPSHOT provided io.ebean ebean-querybean - 12.8.1 + 12.8.2-SNAPSHOT test io.ebean querybean-generator - 12.8.1 + 12.8.2-SNAPSHOT test io.ebean ebean-test - 12.8.1 + 12.8.2-SNAPSHOT test diff --git a/ebean-test/pom.xml b/ebean-test/pom.xml index bccddf421..65e0d345c 100644 --- a/ebean-test/pom.xml +++ b/ebean-test/pom.xml @@ -4,7 +4,7 @@ ebean-parent io.ebean - 12.8.1 + 12.8.2-SNAPSHOT ebean test @@ -29,14 +29,14 @@ io.ebean ebean-core - 12.8.1 + 12.8.2-SNAPSHOT provided io.ebean ebean-ddl-generator - 12.8.1 + 12.8.2-SNAPSHOT diff --git a/ebean/pom.xml b/ebean/pom.xml index f8204d0cf..b293a20bc 100644 --- a/ebean/pom.xml +++ b/ebean/pom.xml @@ -4,7 +4,7 @@ ebean-parent io.ebean - 12.8.1 + 12.8.2-SNAPSHOT ebean composite @@ -22,20 +22,20 @@ io.ebean ebean-api - 12.8.1 + 12.8.2-SNAPSHOT io.ebean ebean-core - 12.8.1 + 12.8.2-SNAPSHOT io.ebean ebean-querybean - 12.8.1 + 12.8.2-SNAPSHOT diff --git a/kotlin-querybean-generator/pom.xml b/kotlin-querybean-generator/pom.xml index a9dda9dc6..70432f360 100644 --- a/kotlin-querybean-generator/pom.xml +++ b/kotlin-querybean-generator/pom.xml @@ -4,7 +4,7 @@ ebean-parent io.ebean - 12.8.1 + 12.8.2-SNAPSHOT kotlin querybean generator @@ -29,7 +29,7 @@ io.ebean ebean-querybean - 12.8.1 + 12.8.2-SNAPSHOT test @@ -43,7 +43,7 @@ io.ebean ebean-core - 12.8.1 + 12.8.2-SNAPSHOT test @@ -64,7 +64,7 @@ io.ebean ebean-ddl-generator - 12.8.1 + 12.8.2-SNAPSHOT test diff --git a/pom.xml b/pom.xml index 4064eef48..a0ce632a3 100644 --- a/pom.xml +++ b/pom.xml @@ -9,7 +9,7 @@ io.ebean ebean-parent - 12.8.1 + 12.8.2-SNAPSHOT pom ebean parent @@ -18,7 +18,7 @@ scm:git:git@github.com:ebean-orm/ebean.git - ebean-parent-12.8.1 + ebean-parent-12.8.0 diff --git a/querybean-generator/pom.xml b/querybean-generator/pom.xml index 7da5e03b1..be174f512 100644 --- a/querybean-generator/pom.xml +++ b/querybean-generator/pom.xml @@ -4,7 +4,7 @@ ebean-parent io.ebean - 12.8.1 + 12.8.2-SNAPSHOT querybean generator From f9b55a06b81064e761c7abdef297f2c086c89f3e Mon Sep 17 00:00:00 2001 From: Tobias Date: Wed, 31 Mar 2021 12:45:48 +0200 Subject: [PATCH 184/447] Add bitwise operators to query beans --- .../java/io/ebean/typequery/PInteger.java | 66 +++++++++++++++++ .../main/java/io/ebean/typequery/PLong.java | 70 ++++++++++++++++++- .../main/java/io/ebean/typequery/PShort.java | 68 +++++++++++++++++- 3 files changed, 201 insertions(+), 3 deletions(-) diff --git a/ebean-querybean/src/main/java/io/ebean/typequery/PInteger.java b/ebean-querybean/src/main/java/io/ebean/typequery/PInteger.java index 3aefa8f46..8657461be 100644 --- a/ebean-querybean/src/main/java/io/ebean/typequery/PInteger.java +++ b/ebean-querybean/src/main/java/io/ebean/typequery/PInteger.java @@ -24,4 +24,70 @@ public class PInteger extends PBaseNumber { super(name, root, prefix); } + /** + * Add bitwise AND expression of the given bit flags to compare with the match/mask. + *

+ *

{@code
+   *
+   * // Flags Bulk + Size = Size
+   * // ... meaning Bulk is not set and Size is set
+   *
+   * int selectedFlags = BwFlags.HAS_BULK + BwFlags.HAS_SIZE;
+   * int mask = BwFlags.HAS_SIZE; // Only Size flag set
+   *
+   * bitwiseAnd(selectedFlags, mask)
+   *
+   * }
+ * + * @param flags The flags we are looking for + */ + public R bitwiseAnd(int flags, int mask) { + expr().bitwiseAnd(_name, flags, mask); + return _root; + } + + /** + * Add expression for ALL of the given bit flags to be set. + *
{@code
+   *
+   * bitwiseAll(BwFlags.HAS_BULK + BwFlags.HAS_COLOUR)
+   *
+   * }
+ * + * @param flags The flags we are looking for + */ + public R bitwiseAll(int flags) { + expr().bitwiseAll(_name, flags); + return _root; + } + + /** + * Add expression for ANY of the given bit flags to be set. + *
{@code
+   *
+   * bitwiseAny(BwFlags.HAS_BULK + BwFlags.HAS_COLOUR)
+   *
+   * }
+ * + * @param flags The flags we are looking for + */ + public R bitwiseAny(int flags) { + expr().bitwiseAny(_name, flags); + return _root; + } + + /** + * Add expression for the given bit flags to be NOT set. + *
{@code
+   *
+   * bitwiseNot(BwFlags.HAS_COLOUR)
+   *
+   * }
+ * + * @param flags The flags we are looking for + */ + public R bitwiseNot(int flags) { + expr().bitwiseNot(_name, flags); + return _root; + } } diff --git a/ebean-querybean/src/main/java/io/ebean/typequery/PLong.java b/ebean-querybean/src/main/java/io/ebean/typequery/PLong.java index e5869682c..d8e4cf58b 100644 --- a/ebean-querybean/src/main/java/io/ebean/typequery/PLong.java +++ b/ebean-querybean/src/main/java/io/ebean/typequery/PLong.java @@ -5,7 +5,7 @@ package io.ebean.typequery; * * @param the root query bean type */ -public class PLong extends PBaseNumber { +public class PLong extends PBaseNumber { /** * Construct with a property name and root instance. @@ -14,7 +14,7 @@ public class PLong extends PBaseNumber { * @param root the root query bean instance */ public PLong(String name, R root) { - super(name , root); + super(name, root); } /** @@ -24,4 +24,70 @@ public class PLong extends PBaseNumber { super(name, root, prefix); } + /** + * Add bitwise AND expression of the given bit flags to compare with the match/mask. + *

+ *

{@code
+   *
+   * // Flags Bulk + Size = Size
+   * // ... meaning Bulk is not set and Size is set
+   *
+   * long selectedFlags = BwFlags.HAS_BULK + BwFlags.HAS_SIZE;
+   * long mask = BwFlags.HAS_SIZE; // Only Size flag set
+   *
+   * bitwiseAnd(selectedFlags, mask)
+   *
+   * }
+ * + * @param flags The flags we are looking for + */ + public R bitwiseAnd(long flags, long mask) { + expr().bitwiseAnd(_name, flags, mask); + return _root; + } + + /** + * Add expression for ALL of the given bit flags to be set. + *
{@code
+   *
+   * bitwiseAll(BwFlags.HAS_BULK + BwFlags.HAS_COLOUR)
+   *
+   * }
+ * + * @param flags The flags we are looking for + */ + public R bitwiseAll(long flags) { + expr().bitwiseAll(_name, flags); + return _root; + } + + /** + * Add expression for ANY of the given bit flags to be set. + *
{@code
+   *
+   * bitwiseAny(BwFlags.HAS_BULK + BwFlags.HAS_COLOUR)
+   *
+   * }
+ * + * @param flags The flags we are looking for + */ + public R bitwiseAny(long flags) { + expr().bitwiseAny(_name, flags); + return _root; + } + + /** + * Add expression for the given bit flags to be NOT set. + *
{@code
+   *
+   * bitwiseNot(BwFlags.HAS_COLOUR)
+   *
+   * }
+ * + * @param flags The flags we are looking for + */ + public R bitwiseNot(long flags) { + expr().bitwiseNot(_name, flags); + return _root; + } } diff --git a/ebean-querybean/src/main/java/io/ebean/typequery/PShort.java b/ebean-querybean/src/main/java/io/ebean/typequery/PShort.java index 440a5ab4c..f8ee7bf8a 100644 --- a/ebean-querybean/src/main/java/io/ebean/typequery/PShort.java +++ b/ebean-querybean/src/main/java/io/ebean/typequery/PShort.java @@ -5,7 +5,7 @@ package io.ebean.typequery; * * @param the root query bean type */ -public class PShort extends PBaseNumber { +public class PShort extends PBaseNumber { /** * Construct with a property name and root instance. @@ -24,4 +24,70 @@ public class PShort extends PBaseNumber { super(name, root, prefix); } + /** + * Add bitwise AND expression of the given bit flags to compare with the match/mask. + *

+ *

{@code
+   *
+   * // Flags Bulk + Size = Size
+   * // ... meaning Bulk is not set and Size is set
+   *
+   * short selectedFlags = BwFlags.HAS_BULK + BwFlags.HAS_SIZE;
+   * short mask = BwFlags.HAS_SIZE; // Only Size flag set
+   *
+   * bitwiseAnd(selectedFlags, mask)
+   *
+   * }
+ * + * @param flags The flags we are looking for + */ + public R bitwiseAnd(short flags, short mask) { + expr().bitwiseAnd(_name, flags, mask); + return _root; + } + + /** + * Add expression for ALL of the given bit flags to be set. + *
{@code
+   *
+   * bitwiseAll(BwFlags.HAS_BULK + BwFlags.HAS_COLOUR)
+   *
+   * }
+ * + * @param flags The flags we are looking for + */ + public R bitwiseAll(short flags) { + expr().bitwiseAll(_name, flags); + return _root; + } + + /** + * Add expression for ANY of the given bit flags to be set. + *
{@code
+   *
+   * bitwiseAny(BwFlags.HAS_BULK + BwFlags.HAS_COLOUR)
+   *
+   * }
+ * + * @param flags The flags we are looking for + */ + public R bitwiseAny(short flags) { + expr().bitwiseAny(_name, flags); + return _root; + } + + /** + * Add expression for the given bit flags to be NOT set. + *
{@code
+   *
+   * bitwiseNot(BwFlags.HAS_COLOUR)
+   *
+   * }
+ * + * @param flags The flags we are looking for + */ + public R bitwiseNot(short flags) { + expr().bitwiseNot(_name, flags); + return _root; + } } From f53d31aa2e80f8e05663b99daa29ee4dd8fbccdd Mon Sep 17 00:00:00 2001 From: Robin Bygrave Date: Thu, 1 Apr 2021 12:22:45 +1300 Subject: [PATCH 185/447] No functional change - final field for BatchControl --- .../main/java/io/ebeaninternal/server/persist/BatchControl.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/persist/BatchControl.java b/ebean-core/src/main/java/io/ebeaninternal/server/persist/BatchControl.java index 10ba7f205..f276bb331 100644 --- a/ebean-core/src/main/java/io/ebeaninternal/server/persist/BatchControl.java +++ b/ebean-core/src/main/java/io/ebeaninternal/server/persist/BatchControl.java @@ -81,7 +81,7 @@ public final class BatchControl { */ private int bufferMax; - private Queue[] queues = new Queue[3]; + private final Queue[] queues = new Queue[3]; /** * Create for a given transaction, PersistExecute, default size and getGeneratedKeys. From a617d5890203d445cbd33badcec33ddd3d9d5c0a Mon Sep 17 00:00:00 2001 From: Robin Bygrave Date: Thu, 1 Apr 2021 14:47:54 +1300 Subject: [PATCH 186/447] Initial experimental support for "transparent persistence" In short, when this is turned on at flush() get any dirty beans held by the PersistenceContext and persist them (always update for these beans) --- .../src/main/java/io/ebean/Transaction.java | 8 + .../io/ebean/bean/PersistenceContext.java | 7 + .../ebeaninternal/api/ScopedTransaction.java | 5 + .../server/core/DefaultServer.java | 2 +- .../server/core/InternalConfiguration.java | 4 +- .../DefaultPersistenceContext.java | 31 ++- .../ImplicitReadOnlyTransaction.java | 5 + .../server/transaction/JdbcTransaction.java | 14 +- .../server/transaction/NoTransaction.java | 5 + .../transaction/SavepointTransaction.java | 5 + .../transaction/TransactionManager.java | 16 +- .../TransactionManagerOptions.java | 6 +- .../TestTransparentPersist.java | 204 ++++++++++++++++++ .../src/test/resources/logback-test.xml | 4 +- 14 files changed, 303 insertions(+), 13 deletions(-) create mode 100644 ebean-core/src/test/java/org/tests/transparentpersist/TestTransparentPersist.java diff --git a/ebean-api/src/main/java/io/ebean/Transaction.java b/ebean-api/src/main/java/io/ebean/Transaction.java index d4918e84e..0cbfd6e3c 100644 --- a/ebean-api/src/main/java/io/ebean/Transaction.java +++ b/ebean-api/src/main/java/io/ebean/Transaction.java @@ -59,6 +59,14 @@ public interface Transaction extends AutoCloseable { */ void register(TransactionCallback callback); + /** + * EXPERIMENTAL - turn on transparent persistence and batchMode true. + *

+ * With this turned on beans that are dirty in the persistence context + * are automatically persisted on flush() and commit(). + */ + void setTransparentPersistence(boolean transparentPersistence); + /** * Set a label on the transaction. *

diff --git a/ebean-api/src/main/java/io/ebean/bean/PersistenceContext.java b/ebean-api/src/main/java/io/ebean/bean/PersistenceContext.java index a8a42e51b..8c861af1f 100644 --- a/ebean-api/src/main/java/io/ebean/bean/PersistenceContext.java +++ b/ebean-api/src/main/java/io/ebean/bean/PersistenceContext.java @@ -1,5 +1,7 @@ package io.ebean.bean; +import java.util.List; + /** * Holds entity beans by there type and id. *

@@ -77,6 +79,11 @@ public interface PersistenceContext { */ boolean resetLimit(); + /** + * Return the list of dirty beans held by this persistence context. + */ + List dirtyBeans(); + /** * Wrapper on a bean to also indicate if a bean has been deleted. *

diff --git a/ebean-core/src/main/java/io/ebeaninternal/api/ScopedTransaction.java b/ebean-core/src/main/java/io/ebeaninternal/api/ScopedTransaction.java index f5a1db07b..6e95a114e 100644 --- a/ebean-core/src/main/java/io/ebeaninternal/api/ScopedTransaction.java +++ b/ebean-core/src/main/java/io/ebeaninternal/api/ScopedTransaction.java @@ -131,6 +131,11 @@ public class ScopedTransaction extends SpiTransactionProxy { } } + @Override + public void setTransparentPersistence(boolean transparentPersistence) { + current.getTransaction().setTransparentPersistence(transparentPersistence); + } + @Override public void setRollbackOnly() { current.setRollbackOnly(); diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/core/DefaultServer.java b/ebean-core/src/main/java/io/ebeaninternal/server/core/DefaultServer.java index 52b94bfb6..6595d9816 100644 --- a/ebean-core/src/main/java/io/ebeaninternal/server/core/DefaultServer.java +++ b/ebean-core/src/main/java/io/ebeaninternal/server/core/DefaultServer.java @@ -236,7 +236,7 @@ public final class DefaultServer implements SpiServer, SpiEbeanServer { this.clockService = config.getClockService(); DocStoreIntegration docStoreComponents = config.createDocStoreIntegration(this); - this.transactionManager = config.createTransactionManager(docStoreComponents.updateProcessor()); + this.transactionManager = config.createTransactionManager(this, docStoreComponents.updateProcessor()); this.documentStore = docStoreComponents.documentStore(); this.queryPlanManager = config.initQueryPlanManager(transactionManager); this.metaInfoManager = new DefaultMetaInfoManager(this); diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/core/InternalConfiguration.java b/ebean-core/src/main/java/io/ebeaninternal/server/core/InternalConfiguration.java index 8cbbbfa4b..dca8e3059 100644 --- a/ebean-core/src/main/java/io/ebeaninternal/server/core/InternalConfiguration.java +++ b/ebean-core/src/main/java/io/ebeaninternal/server/core/InternalConfiguration.java @@ -423,13 +423,13 @@ public class InternalConfiguration { /** * Create the TransactionManager taking into account autoCommit mode. */ - TransactionManager createTransactionManager(DocStoreUpdateProcessor indexUpdateProcessor) { + TransactionManager createTransactionManager(SpiServer server, DocStoreUpdateProcessor indexUpdateProcessor) { TransactionScopeManager scopeManager = createTransactionScopeManager(); boolean notifyL2CacheInForeground = cacheManager.isLocalL2Caching() || config.isNotifyL2CacheInForeground(); TransactionManagerOptions options = - new TransactionManagerOptions(notifyL2CacheInForeground, config, scopeManager, clusterManager, backgroundExecutor, + new TransactionManagerOptions(server, notifyL2CacheInForeground, config, scopeManager, clusterManager, backgroundExecutor, indexUpdateProcessor, beanDescriptorManager, dataSource(), profileHandler(), logManager, tableModState, cacheNotify, clockService); diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/transaction/DefaultPersistenceContext.java b/ebean-core/src/main/java/io/ebeaninternal/server/transaction/DefaultPersistenceContext.java index df92246fa..27eea2e4c 100644 --- a/ebean-core/src/main/java/io/ebeaninternal/server/transaction/DefaultPersistenceContext.java +++ b/ebean-core/src/main/java/io/ebeaninternal/server/transaction/DefaultPersistenceContext.java @@ -1,11 +1,9 @@ package io.ebeaninternal.server.transaction; +import io.ebean.bean.EntityBean; import io.ebean.bean.PersistenceContext; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Map; -import java.util.Set; +import java.util.*; import java.util.concurrent.locks.ReentrantLock; /** @@ -200,6 +198,20 @@ public final class DefaultPersistenceContext implements PersistenceContext { } } + @Override + public List dirtyBeans() { + lock.lock(); + try { + List list = new ArrayList<>(); + for (ClassContext classContext : typeCache.values()) { + classContext.dirtyBeans(list); + } + return list; + } finally { + lock.unlock(); + } + } + @Override public String toString() { lock.lock(); @@ -318,6 +330,17 @@ public final class DefaultPersistenceContext implements PersistenceContext { deleteSet.add(id); map.remove(id); } + + /** + * Add the dirty beans to the list. + */ + void dirtyBeans(List list) { + for (Object value : map.values()) { + if (((EntityBean) value)._ebean_getIntercept().isDirty()) { + list.add(value); + } + } + } } } diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/transaction/ImplicitReadOnlyTransaction.java b/ebean-core/src/main/java/io/ebeaninternal/server/transaction/ImplicitReadOnlyTransaction.java index 79bf85335..04d7a83a5 100644 --- a/ebean-core/src/main/java/io/ebeaninternal/server/transaction/ImplicitReadOnlyTransaction.java +++ b/ebean-core/src/main/java/io/ebeaninternal/server/transaction/ImplicitReadOnlyTransaction.java @@ -95,6 +95,11 @@ class ImplicitReadOnlyTransaction implements SpiTransaction, TxnProfileEventCode return startNanos; } + @Override + public void setTransparentPersistence(boolean transparentPersistence) { + // do nothing + } + @Override public void setLabel(String label) { // do nothing diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/transaction/JdbcTransaction.java b/ebean-core/src/main/java/io/ebeaninternal/server/transaction/JdbcTransaction.java index 8c1897ff5..2585c2b23 100644 --- a/ebean-core/src/main/java/io/ebeaninternal/server/transaction/JdbcTransaction.java +++ b/ebean-core/src/main/java/io/ebeaninternal/server/transaction/JdbcTransaction.java @@ -187,6 +187,8 @@ class JdbcTransaction implements SpiTransaction, TxnProfileEventCodes { private final long startNanos; + private boolean transparentPersistence; + /** * Create a new JdbcTransaction. */ @@ -294,6 +296,12 @@ class JdbcTransaction implements SpiTransaction, TxnProfileEventCodes { return sb.toString(); } + @Override + public void setTransparentPersistence(boolean transparentPersistence) { + this.transparentPersistence = transparentPersistence; + this.batchMode = true; + } + @Override public boolean isSkipCacheExplicit() { return (skipCache != null && !skipCache); @@ -774,6 +782,10 @@ class JdbcTransaction implements SpiTransaction, TxnProfileEventCodes { * Flush the JDBC batch and execute derived relationship statements if necessary. */ private void internalBatchFlush() { + if (transparentPersistence) { + // Experimental - flush dirty beans held by the persistence context + manager.flushTransparent(persistenceContext, this); + } batchFlush(); if (deferredList != null) { for (PersistDeferredRelationship deferred : deferredList) { @@ -1042,7 +1054,7 @@ class JdbcTransaction implements SpiTransaction, TxnProfileEventCodes { throw new IllegalStateException(illegalStateMessage); } try { - if (queryOnly) { + if (queryOnly && !transparentPersistence) { connectionEndForQueryOnly(); } else { flushCommitAndNotify(); diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/transaction/NoTransaction.java b/ebean-core/src/main/java/io/ebeaninternal/server/transaction/NoTransaction.java index 2ef3f2058..5d593302f 100644 --- a/ebean-core/src/main/java/io/ebeaninternal/server/transaction/NoTransaction.java +++ b/ebean-core/src/main/java/io/ebeaninternal/server/transaction/NoTransaction.java @@ -25,6 +25,11 @@ class NoTransaction implements SpiTransaction { static final NoTransaction INSTANCE = new NoTransaction(); + @Override + public void setTransparentPersistence(boolean transparentPersistence) { + // do nothing + } + @Override public void setLabel(String label) { // do nothing diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/transaction/SavepointTransaction.java b/ebean-core/src/main/java/io/ebeaninternal/server/transaction/SavepointTransaction.java index b50122f5c..7b596afec 100644 --- a/ebean-core/src/main/java/io/ebeaninternal/server/transaction/SavepointTransaction.java +++ b/ebean-core/src/main/java/io/ebeaninternal/server/transaction/SavepointTransaction.java @@ -60,6 +60,11 @@ class SavepointTransaction extends SpiTransactionProxy { this.rollbackOnly = true; } + @Override + public void setTransparentPersistence(boolean transparentPersistence) { + throw new IllegalStateException("This is not handled yet. Need to review this case."); + } + @Override public void commit() { if (rollbackOnly) { diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/transaction/TransactionManager.java b/ebean-core/src/main/java/io/ebeaninternal/server/transaction/TransactionManager.java index e42ce2fe3..45885ad2a 100644 --- a/ebean-core/src/main/java/io/ebeaninternal/server/transaction/TransactionManager.java +++ b/ebean-core/src/main/java/io/ebeaninternal/server/transaction/TransactionManager.java @@ -5,6 +5,7 @@ import io.ebean.ProfileLocation; import io.ebean.TxScope; import io.ebean.annotation.PersistBatch; import io.ebean.annotation.TxType; +import io.ebean.bean.PersistenceContext; import io.ebean.cache.ServerCacheNotification; import io.ebean.cache.ServerCacheNotify; import io.ebean.config.CurrentTenantProvider; @@ -17,6 +18,7 @@ import io.ebean.meta.MetricVisitor; import io.ebean.metric.MetricFactory; import io.ebean.metric.TimedMetric; import io.ebean.metric.TimedMetricMap; +import io.ebean.plugin.SpiServer; import io.ebeaninternal.api.ScopeTrans; import io.ebeaninternal.api.ScopedTransaction; import io.ebeaninternal.api.SpiLogManager; @@ -59,6 +61,8 @@ public class TransactionManager implements SpiTransactionManager { private static final Logger clusterLogger = LoggerFactory.getLogger("io.ebean.Cluster"); + private final SpiServer server; + private final BeanDescriptorManager beanDescriptorManager; /** @@ -153,7 +157,7 @@ public class TransactionManager implements SpiTransactionManager { * Create the TransactionManager */ public TransactionManager(TransactionManagerOptions options) { - + this.server = options.server; this.logManager = options.logManager; this.txnLogger = logManager.txn(); this.txnDebug = txnLogger.isDebug(); @@ -786,4 +790,14 @@ public class TransactionManager implements SpiTransactionManager { public boolean isLogSummary() { return logManager.sum().isDebug(); } + + /** + * Experimental - find dirty beans in the persistence context and persist them. + */ + public void flushTransparent(PersistenceContext persistenceContext, SpiTransaction transaction) { + List dirtyBeans = persistenceContext.dirtyBeans(); + if (!dirtyBeans.isEmpty()) { + server.updateAll(dirtyBeans, transaction); + } + } } diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/transaction/TransactionManagerOptions.java b/ebean-core/src/main/java/io/ebeaninternal/server/transaction/TransactionManagerOptions.java index 9a1b0139b..5d0c87794 100644 --- a/ebean-core/src/main/java/io/ebeaninternal/server/transaction/TransactionManagerOptions.java +++ b/ebean-core/src/main/java/io/ebeaninternal/server/transaction/TransactionManagerOptions.java @@ -3,6 +3,7 @@ package io.ebeaninternal.server.transaction; import io.ebean.BackgroundExecutor; import io.ebean.cache.ServerCacheNotify; import io.ebean.config.DatabaseConfig; +import io.ebean.plugin.SpiServer; import io.ebeaninternal.api.SpiLogManager; import io.ebeaninternal.api.SpiProfileHandler; import io.ebeaninternal.server.cluster.ClusterManager; @@ -15,6 +16,7 @@ import io.ebeanservice.docstore.api.DocStoreUpdateProcessor; */ public class TransactionManagerOptions { + final SpiServer server; final boolean notifyL2CacheInForeground; final DatabaseConfig config; final ClusterManager clusterManager; @@ -31,11 +33,11 @@ public class TransactionManagerOptions { final ClockService clockService; - public TransactionManagerOptions(boolean notifyL2CacheInForeground, DatabaseConfig config, TransactionScopeManager scopeManager, ClusterManager clusterManager, + public TransactionManagerOptions(SpiServer server, boolean notifyL2CacheInForeground, DatabaseConfig config, TransactionScopeManager scopeManager, ClusterManager clusterManager, BackgroundExecutor backgroundExecutor, DocStoreUpdateProcessor docStoreUpdateProcessor, BeanDescriptorManager descMgr, DataSourceSupplier dataSourceSupplier, SpiProfileHandler profileHandler, SpiLogManager logManager, TableModState tableModState, ServerCacheNotify cacheNotify, ClockService clockService) { - + this.server = server; this.notifyL2CacheInForeground = notifyL2CacheInForeground; this.config = config; this.scopeManager = scopeManager; diff --git a/ebean-core/src/test/java/org/tests/transparentpersist/TestTransparentPersist.java b/ebean-core/src/test/java/org/tests/transparentpersist/TestTransparentPersist.java new file mode 100644 index 000000000..2922d20b2 --- /dev/null +++ b/ebean-core/src/test/java/org/tests/transparentpersist/TestTransparentPersist.java @@ -0,0 +1,204 @@ +package org.tests.transparentpersist; + +import io.ebean.BaseTestCase; +import io.ebean.DB; +import io.ebean.Database; +import io.ebean.Transaction; +import io.ebeaninternal.api.SpiTransaction; +import io.ebeantest.LoggedSql; +import org.junit.Test; +import org.tests.model.basic.Customer; +import org.tests.model.basic.EBasicVer; +import org.tests.model.basic.Order; + +import java.util.List; + +import static org.assertj.core.api.Assertions.assertThat; + +public class TestTransparentPersist extends BaseTestCase { + + @Test + public void simpleInsertUpdateDelete_experimental() { + + EBasicVer b0 = new EBasicVer("simpleIUD_0"); + b0.save(); + EBasicVer b1 = new EBasicVer("simpleIUD_1"); + b1.save(); + EBasicVer b2 = new EBasicVer("simpleIUD_2"); + b2.save(); + + EBasicVer newBean; + try (Transaction transaction = DB.beginTransaction()) { + transaction.setTransparentPersistence(true); // EXPERIMENTAL feature + + EBasicVer found = DB.find(EBasicVer.class, b0.getId()); + found.setName("auto dirty"); + + // delete by id + DB.delete(EBasicVer.class, b1.getId()); + // find and delete, note the delete is batched up to execute later + DB.delete(DB.find(EBasicVer.class, b2.getId())); + + // insert is batched up to execute later + newBean = new EBasicVer("simpleIUD_New1"); + DB.save(newBean); + // can still mutate newBean before flush (but not after flush yet as new bean isn't put into Persistence context) + newBean.setName("simpleIUD_New2"); + + transaction.commit(); + } + + EBasicVer after = DB.find(EBasicVer.class, b0.getId()); + assertThat(after.getName()).isEqualTo("auto dirty"); + + EBasicVer wasInserted = DB.find(EBasicVer.class, newBean.getId()); + assertThat(wasInserted.getName()).isEqualTo("simpleIUD_New2"); + + assertThat(DB.find(EBasicVer.class, b1.getId())).isNull(); + assertThat(DB.find(EBasicVer.class, b2.getId())).isNull(); + + DB.delete(after); + DB.delete(wasInserted); + } + + @Test + public void simpleUpdate_experimental() { + + EBasicVer transPersist = new EBasicVer("simulate_simpleUpdate"); + transPersist.save(); + + try (Transaction transaction = DB.beginTransaction()) { + transaction.setTransparentPersistence(true); // EXPERIMENTAL feature + + EBasicVer found = DB.find(EBasicVer.class, transPersist.getId()); + found.setName("Persisted automatically as dirty"); + + transaction.commit(); + } + + EBasicVer after = DB.find(EBasicVer.class,transPersist.getId()); + assertThat(after.getName()).isEqualTo("Persisted automatically as dirty"); + DB.delete(after); + } + + @Test + public void updateWithPersistCascadeInsert() { + + // setup data + Customer c0 = new Customer(); + c0.setName("firstCust"); + Order order = new Order(); + order.setStatus(Order.Status.NEW); + order.setCustomer(c0); + DB.save(order); + + try (Transaction transaction = DB.beginTransaction()) { + transaction.setTransparentPersistence(true); // EXPERIMENTAL feature + + Order foundOrder = DB.find(Order.class, order.getId()); + foundOrder.setStatus(Order.Status.APPROVED); + // cascade persist will insert this customer (even though it isn't in the persistence context) + Customer c1 = new Customer(); + c1.setName("newCust CascadePersist"); + foundOrder.setCustomer(c1); + + transaction.commit(); + } + + Order checkOrder = DB.find(Order.class, order.getId()); + + assertThat(checkOrder.getStatus()).isEqualTo(Order.Status.APPROVED); + assertThat(checkOrder.getCustomer().getName()).isEqualTo("newCust CascadePersist"); + + DB.delete(checkOrder); + DB.delete(Customer.class, checkOrder.getCustomer().getId()); + DB.delete(Customer.class, c0.getId()); + } + + @Test + public void updateReferenceOnlyWithPersistCascade_Insert_andUpdateForeignKey() { + + // setup data + Customer c0 = new Customer(); + c0.setName("firstCust"); + Order order = new Order(); + order.setStatus(Order.Status.NEW); + order.setCustomer(c0); + DB.save(order); + + LoggedSql.start(); + + try (Transaction transaction = DB.beginTransaction()) { + transaction.setTransparentPersistence(true); // EXPERIMENTAL feature + + Order foundOrder = DB.find(Order.class, order.getId()); + // we ONLY mutate the foreign key + // cascade persist will insert this customer (even though it isn't in the persistence context) + Customer c1 = new Customer(); + c1.setName("newCust CascadePersist"); + foundOrder.setCustomer(c1); + + transaction.commit(); + } + + List sql = LoggedSql.stop(); + + Order checkOrder = DB.find(Order.class, order.getId()); + + assertThat(checkOrder.getStatus()).isEqualTo(Order.Status.NEW); + assertThat(checkOrder.getCustomer().getName()).isEqualTo("newCust CascadePersist"); + + assertThat(sql).hasSize(5); + assertThat(sql.get(0)).contains("select t0.id, t0.status, t0.order_date"); + assertThat(sql.get(1)).contains("insert into o_customer"); + assertThat(sql.get(2)).contains(" -- bind("); + assertThat(sql.get(3)).contains("update o_order set updtime=?, kcustomer_id=? where id=? and updtime=?"); + assertThat(sql.get(4)).contains(" -- bind("); + + DB.delete(checkOrder); + DB.delete(Customer.class, checkOrder.getCustomer().getId()); + DB.delete(Customer.class, c0.getId()); + } + + @Test + public void simulate_transparentPersistence_forSimpleUpdate() { + + EBasicVer transPersist = new EBasicVer("simulate_simpleUpdate"); + transPersist.save(); + + try (Transaction transaction = DB.beginTransaction()) { + transaction.setBatchMode(true); + transaction.setBatchSize(10); + + EBasicVer found = DB.find(EBasicVer.class, transPersist.getId()); + found.setName("Changed"); + + // simulate transparent persistence + List dirtyBeans = simulateTransparentPersist(transaction); + assertThat(dirtyBeans).hasSize(1); + assertThat(dirtyBeans).contains(found); + + // would occur as first part of flush + transaction.flush(); + transaction.commit(); + } + + EBasicVer after = DB.find(EBasicVer.class,transPersist.getId()); + assertThat(after.getName()).isEqualTo("Changed"); + DB.delete(after); + } + + private List simulateTransparentPersist(Transaction transaction) { + Database db = DB.getDefault(); + List dirtyBeans = getDirtyBeansFromPersistenceContext(transaction); + for (Object dirtyBean : dirtyBeans) { + db.update(dirtyBean, transaction); + } + return dirtyBeans; + } + + private List getDirtyBeansFromPersistenceContext(Transaction transaction) { + return ((SpiTransaction)transaction).getPersistenceContext().dirtyBeans(); + } + +} diff --git a/ebean-core/src/test/resources/logback-test.xml b/ebean-core/src/test/resources/logback-test.xml index 1b8a60a9b..164ff73d3 100644 --- a/ebean-core/src/test/resources/logback-test.xml +++ b/ebean-core/src/test/resources/logback-test.xml @@ -79,8 +79,8 @@ - - + + From ba397bbb0c383bb9be0d1174e3752b9db09c4ef5 Mon Sep 17 00:00:00 2001 From: Robin Bygrave Date: Thu, 1 Apr 2021 16:04:18 +1300 Subject: [PATCH 187/447] For experimental "transparent persistence" - Delete removes from PC early When delete bean executed with transparent persistence, this marks the bean as removed from the persistence context early. This avoids a "dirty" deleted bean from being seen as a "dirty" bean in the persistence context at flush() time. --- .../server/core/PersistRequestBean.java | 8 +++++++ .../server/persist/DefaultPersister.java | 1 + .../TestTransparentPersist.java | 23 +++++++++++++++++++ 3 files changed, 32 insertions(+) diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/core/PersistRequestBean.java b/ebean-core/src/main/java/io/ebeaninternal/server/core/PersistRequestBean.java index eb48fc2ef..c4d02cbf6 100644 --- a/ebean-core/src/main/java/io/ebeaninternal/server/core/PersistRequestBean.java +++ b/ebean-core/src/main/java/io/ebeaninternal/server/core/PersistRequestBean.java @@ -887,6 +887,14 @@ public final class PersistRequestBean extends PersistRequest implements BeanP } } + /** + * Remove deleted beans from the persistence context early. + */ + public void removeFromPersistenceContext() { + idValue = beanDescriptor.getId(entityBean); + beanDescriptor.contextDeleted(transaction.getPersistenceContext(), idValue); + } + /** * Aggressive L1 and L2 cache cleanup for deletes. */ diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/persist/DefaultPersister.java b/ebean-core/src/main/java/io/ebeaninternal/server/persist/DefaultPersister.java index a7b21f0c8..005e85d95 100644 --- a/ebean-core/src/main/java/io/ebeaninternal/server/persist/DefaultPersister.java +++ b/ebean-core/src/main/java/io/ebeaninternal/server/persist/DefaultPersister.java @@ -881,6 +881,7 @@ public final class DefaultPersister implements Persister { } int count = request.executeOrQueue(); + request.removeFromPersistenceContext(); if (request.isPersistCascade()) { deleteAssocOne(request); diff --git a/ebean-core/src/test/java/org/tests/transparentpersist/TestTransparentPersist.java b/ebean-core/src/test/java/org/tests/transparentpersist/TestTransparentPersist.java index 2922d20b2..be5d8329b 100644 --- a/ebean-core/src/test/java/org/tests/transparentpersist/TestTransparentPersist.java +++ b/ebean-core/src/test/java/org/tests/transparentpersist/TestTransparentPersist.java @@ -17,6 +17,29 @@ import static org.assertj.core.api.Assertions.assertThat; public class TestTransparentPersist extends BaseTestCase { + @Test + public void delete_expect_beanRemovedFromPersistenceContext() { + + EBasicVer b0 = new EBasicVer("simpleDelete"); + DB.save(b0); + + try (Transaction transaction = DB.beginTransaction()) { + transaction.setTransparentPersistence(true); // EXPERIMENTAL feature + + EBasicVer found = DB.find(EBasicVer.class, b0.getId()); + // make it dirty + found.setName("make it dirty"); + + // delete it, should remove it from the "live" part of persistence context + // with the expectation that no update is executed (no dirty in PC update) + DB.delete(found); + transaction.commit(); + } + + EBasicVer after = DB.find(EBasicVer.class, b0.getId()); + assertThat(after).isNull(); + } + @Test public void simpleInsertUpdateDelete_experimental() { From 0527f45f5a4e3b479296e051493cf536728bcc06 Mon Sep 17 00:00:00 2001 From: Robin Bygrave Date: Thu, 1 Apr 2021 16:59:03 +1300 Subject: [PATCH 188/447] For experimental "transparent persistence" - Inserts added to PC When inserting bean with transparent persistence the beans are registered with the persistence context. This is done to support the cases where the beans are inserted, a flush() occurs, the inserted bean is mutated and now dirty - we want that to be detected and get an update --- .../ebeaninternal/api/ScopedTransaction.java | 5 --- .../io/ebeaninternal/api/SpiTransaction.java | 5 +++ .../api/SpiTransactionProxy.java | 10 ++++++ .../server/core/PersistRequestBean.java | 4 +++ .../ImplicitReadOnlyTransaction.java | 5 +++ .../server/transaction/JdbcTransaction.java | 5 +++ .../server/transaction/NoTransaction.java | 5 +++ .../transaction/SavepointTransaction.java | 5 --- .../TestTransparentPersist.java | 36 +++++++++++++++++++ 9 files changed, 70 insertions(+), 10 deletions(-) diff --git a/ebean-core/src/main/java/io/ebeaninternal/api/ScopedTransaction.java b/ebean-core/src/main/java/io/ebeaninternal/api/ScopedTransaction.java index 6e95a114e..f5a1db07b 100644 --- a/ebean-core/src/main/java/io/ebeaninternal/api/ScopedTransaction.java +++ b/ebean-core/src/main/java/io/ebeaninternal/api/ScopedTransaction.java @@ -131,11 +131,6 @@ public class ScopedTransaction extends SpiTransactionProxy { } } - @Override - public void setTransparentPersistence(boolean transparentPersistence) { - current.getTransaction().setTransparentPersistence(transparentPersistence); - } - @Override public void setRollbackOnly() { current.setRollbackOnly(); diff --git a/ebean-core/src/main/java/io/ebeaninternal/api/SpiTransaction.java b/ebean-core/src/main/java/io/ebeaninternal/api/SpiTransaction.java index 74faeccb0..8c520f79e 100644 --- a/ebean-core/src/main/java/io/ebeaninternal/api/SpiTransaction.java +++ b/ebean-core/src/main/java/io/ebeaninternal/api/SpiTransaction.java @@ -147,6 +147,11 @@ public interface SpiTransaction extends Transaction { */ int depth(); + /** + * Return true if transparent persistence is turned on. + */ + boolean isTransparentPersistence(); + /** * Return true if this transaction was created explicitly via * Ebean.beginTransaction(). diff --git a/ebean-core/src/main/java/io/ebeaninternal/api/SpiTransactionProxy.java b/ebean-core/src/main/java/io/ebeaninternal/api/SpiTransactionProxy.java index fe5351ddc..1652b56f6 100644 --- a/ebean-core/src/main/java/io/ebeaninternal/api/SpiTransactionProxy.java +++ b/ebean-core/src/main/java/io/ebeaninternal/api/SpiTransactionProxy.java @@ -43,6 +43,16 @@ public abstract class SpiTransactionProxy implements SpiTransaction { return transaction.getLabel(); } + @Override + public void setTransparentPersistence(boolean transparentPersistence) { + transaction.setTransparentPersistence(transparentPersistence); + } + + @Override + public boolean isTransparentPersistence() { + return transaction.isTransparentPersistence(); + } + @Override public void commitAndContinue() { transaction.commitAndContinue(); diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/core/PersistRequestBean.java b/ebean-core/src/main/java/io/ebeaninternal/server/core/PersistRequestBean.java index c4d02cbf6..3f7d6e79a 100644 --- a/ebean-core/src/main/java/io/ebeaninternal/server/core/PersistRequestBean.java +++ b/ebean-core/src/main/java/io/ebeaninternal/server/core/PersistRequestBean.java @@ -1038,6 +1038,10 @@ public final class PersistRequestBean extends PersistRequest implements BeanP if (!publish) { beanDescriptor.setDraft(entityBean); } + if (transaction.isTransparentPersistence() && idValue != null) { + // with getGeneratedKeys off we will not have a idValue + beanDescriptor.contextPut(transaction.getPersistenceContext(), idValue, entityBean); + } } public boolean isReference() { diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/transaction/ImplicitReadOnlyTransaction.java b/ebean-core/src/main/java/io/ebeaninternal/server/transaction/ImplicitReadOnlyTransaction.java index 04d7a83a5..a94260fb6 100644 --- a/ebean-core/src/main/java/io/ebeaninternal/server/transaction/ImplicitReadOnlyTransaction.java +++ b/ebean-core/src/main/java/io/ebeaninternal/server/transaction/ImplicitReadOnlyTransaction.java @@ -100,6 +100,11 @@ class ImplicitReadOnlyTransaction implements SpiTransaction, TxnProfileEventCode // do nothing } + @Override + public boolean isTransparentPersistence() { + return false; + } + @Override public void setLabel(String label) { // do nothing diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/transaction/JdbcTransaction.java b/ebean-core/src/main/java/io/ebeaninternal/server/transaction/JdbcTransaction.java index 2585c2b23..bb672cd33 100644 --- a/ebean-core/src/main/java/io/ebeaninternal/server/transaction/JdbcTransaction.java +++ b/ebean-core/src/main/java/io/ebeaninternal/server/transaction/JdbcTransaction.java @@ -302,6 +302,11 @@ class JdbcTransaction implements SpiTransaction, TxnProfileEventCodes { this.batchMode = true; } + @Override + public boolean isTransparentPersistence() { + return transparentPersistence; + } + @Override public boolean isSkipCacheExplicit() { return (skipCache != null && !skipCache); diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/transaction/NoTransaction.java b/ebean-core/src/main/java/io/ebeaninternal/server/transaction/NoTransaction.java index 5d593302f..92f0e1ca9 100644 --- a/ebean-core/src/main/java/io/ebeaninternal/server/transaction/NoTransaction.java +++ b/ebean-core/src/main/java/io/ebeaninternal/server/transaction/NoTransaction.java @@ -30,6 +30,11 @@ class NoTransaction implements SpiTransaction { // do nothing } + @Override + public boolean isTransparentPersistence() { + return false; + } + @Override public void setLabel(String label) { // do nothing diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/transaction/SavepointTransaction.java b/ebean-core/src/main/java/io/ebeaninternal/server/transaction/SavepointTransaction.java index 7b596afec..b50122f5c 100644 --- a/ebean-core/src/main/java/io/ebeaninternal/server/transaction/SavepointTransaction.java +++ b/ebean-core/src/main/java/io/ebeaninternal/server/transaction/SavepointTransaction.java @@ -60,11 +60,6 @@ class SavepointTransaction extends SpiTransactionProxy { this.rollbackOnly = true; } - @Override - public void setTransparentPersistence(boolean transparentPersistence) { - throw new IllegalStateException("This is not handled yet. Need to review this case."); - } - @Override public void commit() { if (rollbackOnly) { diff --git a/ebean-core/src/test/java/org/tests/transparentpersist/TestTransparentPersist.java b/ebean-core/src/test/java/org/tests/transparentpersist/TestTransparentPersist.java index be5d8329b..a59ddda60 100644 --- a/ebean-core/src/test/java/org/tests/transparentpersist/TestTransparentPersist.java +++ b/ebean-core/src/test/java/org/tests/transparentpersist/TestTransparentPersist.java @@ -17,6 +17,42 @@ import static org.assertj.core.api.Assertions.assertThat; public class TestTransparentPersist extends BaseTestCase { + @Test + public void insertFlush_mutateFlush_expect_update() { + + LoggedSql.start(); + + EBasicVer newBean; + try (Transaction transaction = DB.beginTransaction()) { + transaction.setTransparentPersistence(true); // EXPERIMENTAL feature + + newBean = new EBasicVer("insertMe"); + DB.save(newBean); + + // flush - new bean needs to get registered into persistence context + transaction.flush(); + + // make it dirty, we expect it to execute an update on flush() + newBean.setName("make it dirty - auto save"); + + // flush again, auto persist dirty bean in persistence context + transaction.commit(); + } + + List sql = LoggedSql.stop(); + + EBasicVer found = DB.find(EBasicVer.class, newBean.getId()); + assertThat(found.getName()).isEqualTo("make it dirty - auto save"); + + assertThat(sql).hasSize(4); + assertThat(sql.get(0)).contains("insert into e_basicver"); + assertThat(sql.get(1)).contains(" -- bind("); + assertThat(sql.get(2)).contains("update e_basicver set name=?, last_update=? where id=? and last_update=?"); + assertThat(sql.get(3)).contains(" -- bind("); + + DB.delete(found); + } + @Test public void delete_expect_beanRemovedFromPersistenceContext() { From 6bcf5c6881e14b0156abaaf14fd4cff39dce8df1 Mon Sep 17 00:00:00 2001 From: Robin Bygrave Date: Thu, 1 Apr 2021 22:57:34 +1300 Subject: [PATCH 189/447] Add DatabaseConfig.autoPersistUpdates for experimental "transparent persistence" --- .../java/io/ebean/config/DatabaseConfig.java | 23 ++++++++++++++++++- .../server/transaction/JdbcTransaction.java | 5 ++-- .../transaction/TransactionManager.java | 11 +++++++-- .../io/ebean/config/ServerConfigTest.java | 3 +++ 4 files changed, 37 insertions(+), 5 deletions(-) diff --git a/ebean-api/src/main/java/io/ebean/config/DatabaseConfig.java b/ebean-api/src/main/java/io/ebean/config/DatabaseConfig.java index bf4c61675..be2ac6c1f 100644 --- a/ebean-api/src/main/java/io/ebean/config/DatabaseConfig.java +++ b/ebean-api/src/main/java/io/ebean/config/DatabaseConfig.java @@ -232,6 +232,12 @@ public class DatabaseConfig { */ private String historyTableSuffix = "_history"; + /** + * When true explicit transactions beans that have been made dirty will be + * automatically persisted via update on flush. + */ + private boolean autoPersistUpdates; + /** * Use for transaction scoped batch mode. */ @@ -905,6 +911,20 @@ public class DatabaseConfig { this.tenantCatalogProvider = tenantCatalogProvider; } + /** + * Return true if dirty beans are automatically persisted. + */ + public boolean isAutoPersistUpdates() { + return autoPersistUpdates; + } + + /** + * Set to true if dirty beans are automatically persisted. + */ + public void setAutoPersistUpdates(boolean autoPersistUpdates) { + this.autoPersistUpdates = autoPersistUpdates; + } + /** * Return the PersistBatch mode to use by default at the transaction level. *

@@ -2807,6 +2827,7 @@ public class DatabaseConfig { loadDocStoreSettings(p); defaultServer = p.getBoolean("defaultServer", defaultServer); + autoPersistUpdates = p.getBoolean("autoPersistUpdates", autoPersistUpdates); loadModuleInfo = p.getBoolean("loadModuleInfo", loadModuleInfo); maxCallStack = p.getInt("maxCallStack", maxCallStack); dumpMetricsOnShutdown = p.getBoolean("dumpMetricsOnShutdown", dumpMetricsOnShutdown); @@ -3348,7 +3369,7 @@ public class DatabaseConfig { this.loadModuleInfo = loadModuleInfo; } - public enum UuidVersion { + public enum UuidVersion { VERSION4, VERSION1, VERSION1RND diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/transaction/JdbcTransaction.java b/ebean-core/src/main/java/io/ebeaninternal/server/transaction/JdbcTransaction.java index bb672cd33..411331aef 100644 --- a/ebean-core/src/main/java/io/ebeaninternal/server/transaction/JdbcTransaction.java +++ b/ebean-core/src/main/java/io/ebeaninternal/server/transaction/JdbcTransaction.java @@ -211,11 +211,12 @@ class JdbcTransaction implements SpiTransaction, TxnProfileEventCodes { this.batchOnCascadeMode = false; this.onQueryOnly = OnQueryOnly.ROLLBACK; } else { + this.transparentPersistence = explicit && manager.isAutoPersistUpdates(); this.logSql = manager.isLogSql(); this.logSummary = manager.isLogSummary(); this.skipCacheAfterWrite = manager.isSkipCacheAfterWrite(); - this.batchMode = manager.getPersistBatch(); - this.batchOnCascadeMode = manager.getPersistBatchOnCascade(); + this.batchMode = manager.isPersistBatch(); + this.batchOnCascadeMode = manager.isPersistBatchOnCascade(); this.onQueryOnly = manager.getOnQueryOnly(); } diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/transaction/TransactionManager.java b/ebean-core/src/main/java/io/ebeaninternal/server/transaction/TransactionManager.java index 45885ad2a..b71868e5d 100644 --- a/ebean-core/src/main/java/io/ebeaninternal/server/transaction/TransactionManager.java +++ b/ebean-core/src/main/java/io/ebeaninternal/server/transaction/TransactionManager.java @@ -104,6 +104,8 @@ public class TransactionManager implements SpiTransactionManager { */ final DocStoreUpdateProcessor docStoreUpdateProcessor; + private final boolean autoPersistUpdates; + private final boolean persistBatch; private final boolean persistBatchOnCascade; @@ -165,6 +167,7 @@ public class TransactionManager implements SpiTransactionManager { this.supportsSavepointId = databasePlatform.isSupportsSavepointId(); this.skipCacheAfterWrite = options.config.isSkipCacheAfterWrite(); this.notifyL2CacheInForeground = options.notifyL2CacheInForeground; + this.autoPersistUpdates = options.config.isAutoPersistUpdates(); this.persistBatch = PersistBatch.ALL == options.config.getPersistBatch(); this.persistBatchOnCascade = PersistBatch.ALL == options.config.appliedPersistBatchOnCascade(); this.rollbackOnChecked = options.config.isTransactionRollbackOnChecked(); @@ -283,11 +286,15 @@ public class TransactionManager implements SpiTransactionManager { return bulkEventListenerMap; } - boolean getPersistBatch() { + boolean isAutoPersistUpdates() { + return autoPersistUpdates; + } + + boolean isPersistBatch() { return persistBatch; } - public boolean getPersistBatchOnCascade() { + boolean isPersistBatchOnCascade() { return persistBatchOnCascade; } diff --git a/ebean-core/src/test/java/io/ebean/config/ServerConfigTest.java b/ebean-core/src/test/java/io/ebean/config/ServerConfigTest.java index f93c18d26..4e92798d6 100644 --- a/ebean-core/src/test/java/io/ebean/config/ServerConfigTest.java +++ b/ebean-core/src/test/java/io/ebean/config/ServerConfigTest.java @@ -149,6 +149,7 @@ public class ServerConfigTest { ServerConfig serverConfig = new ServerConfig(); assertTrue(serverConfig.isIdGeneratorAutomatic()); assertTrue(serverConfig.isDefaultServer()); + assertFalse(serverConfig.isAutoPersistUpdates()); serverConfig.setIdGeneratorAutomatic(false); assertFalse(serverConfig.isIdGeneratorAutomatic()); @@ -166,6 +167,8 @@ public class ServerConfigTest { serverConfig.setLoadModuleInfo(false); assertFalse(serverConfig.isAutoLoadModuleInfo()); + serverConfig.setAutoPersistUpdates(true); + assertTrue(serverConfig.isAutoPersistUpdates()); } @Test From 303039735f1cbae070cced68706a64b2dddb3bc8 Mon Sep 17 00:00:00 2001 From: Robin Bygrave Date: Thu, 1 Apr 2021 23:04:22 +1300 Subject: [PATCH 190/447] Refactor rename transparentPersistence to autoPersistUpdates --- .../src/main/java/io/ebean/Transaction.java | 4 ++-- .../io/ebeaninternal/api/SpiTransaction.java | 4 ++-- .../ebeaninternal/api/SpiTransactionProxy.java | 8 ++++---- .../server/core/PersistRequestBean.java | 2 +- .../transaction/ImplicitReadOnlyTransaction.java | 4 ++-- .../server/transaction/JdbcTransaction.java | 16 ++++++++-------- .../server/transaction/NoTransaction.java | 4 ++-- .../TestTransparentPersist.java | 12 ++++++------ 8 files changed, 27 insertions(+), 27 deletions(-) diff --git a/ebean-api/src/main/java/io/ebean/Transaction.java b/ebean-api/src/main/java/io/ebean/Transaction.java index 0cbfd6e3c..9a391d654 100644 --- a/ebean-api/src/main/java/io/ebean/Transaction.java +++ b/ebean-api/src/main/java/io/ebean/Transaction.java @@ -60,12 +60,12 @@ public interface Transaction extends AutoCloseable { void register(TransactionCallback callback); /** - * EXPERIMENTAL - turn on transparent persistence and batchMode true. + * EXPERIMENTAL - turn on automatic persistence of dirty beans and batchMode true. *

* With this turned on beans that are dirty in the persistence context * are automatically persisted on flush() and commit(). */ - void setTransparentPersistence(boolean transparentPersistence); + void setAutoPersistUpdates(boolean autoPersistUpdates); /** * Set a label on the transaction. diff --git a/ebean-core/src/main/java/io/ebeaninternal/api/SpiTransaction.java b/ebean-core/src/main/java/io/ebeaninternal/api/SpiTransaction.java index 8c520f79e..8c59fa7dc 100644 --- a/ebean-core/src/main/java/io/ebeaninternal/api/SpiTransaction.java +++ b/ebean-core/src/main/java/io/ebeaninternal/api/SpiTransaction.java @@ -148,9 +148,9 @@ public interface SpiTransaction extends Transaction { int depth(); /** - * Return true if transparent persistence is turned on. + * Return true if dirty beans are automatically persisted. */ - boolean isTransparentPersistence(); + boolean isAutoPersistUpdates(); /** * Return true if this transaction was created explicitly via diff --git a/ebean-core/src/main/java/io/ebeaninternal/api/SpiTransactionProxy.java b/ebean-core/src/main/java/io/ebeaninternal/api/SpiTransactionProxy.java index 1652b56f6..5fd2a3c6e 100644 --- a/ebean-core/src/main/java/io/ebeaninternal/api/SpiTransactionProxy.java +++ b/ebean-core/src/main/java/io/ebeaninternal/api/SpiTransactionProxy.java @@ -44,13 +44,13 @@ public abstract class SpiTransactionProxy implements SpiTransaction { } @Override - public void setTransparentPersistence(boolean transparentPersistence) { - transaction.setTransparentPersistence(transparentPersistence); + public void setAutoPersistUpdates(boolean autoPersistUpdates) { + transaction.setAutoPersistUpdates(autoPersistUpdates); } @Override - public boolean isTransparentPersistence() { - return transaction.isTransparentPersistence(); + public boolean isAutoPersistUpdates() { + return transaction.isAutoPersistUpdates(); } @Override diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/core/PersistRequestBean.java b/ebean-core/src/main/java/io/ebeaninternal/server/core/PersistRequestBean.java index 3f7d6e79a..31d92b0a0 100644 --- a/ebean-core/src/main/java/io/ebeaninternal/server/core/PersistRequestBean.java +++ b/ebean-core/src/main/java/io/ebeaninternal/server/core/PersistRequestBean.java @@ -1038,7 +1038,7 @@ public final class PersistRequestBean extends PersistRequest implements BeanP if (!publish) { beanDescriptor.setDraft(entityBean); } - if (transaction.isTransparentPersistence() && idValue != null) { + if (transaction.isAutoPersistUpdates() && idValue != null) { // with getGeneratedKeys off we will not have a idValue beanDescriptor.contextPut(transaction.getPersistenceContext(), idValue, entityBean); } diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/transaction/ImplicitReadOnlyTransaction.java b/ebean-core/src/main/java/io/ebeaninternal/server/transaction/ImplicitReadOnlyTransaction.java index a94260fb6..5f2b5d195 100644 --- a/ebean-core/src/main/java/io/ebeaninternal/server/transaction/ImplicitReadOnlyTransaction.java +++ b/ebean-core/src/main/java/io/ebeaninternal/server/transaction/ImplicitReadOnlyTransaction.java @@ -96,12 +96,12 @@ class ImplicitReadOnlyTransaction implements SpiTransaction, TxnProfileEventCode } @Override - public void setTransparentPersistence(boolean transparentPersistence) { + public void setAutoPersistUpdates(boolean autoPersistUpdates) { // do nothing } @Override - public boolean isTransparentPersistence() { + public boolean isAutoPersistUpdates() { return false; } diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/transaction/JdbcTransaction.java b/ebean-core/src/main/java/io/ebeaninternal/server/transaction/JdbcTransaction.java index 411331aef..7d3b3ddf1 100644 --- a/ebean-core/src/main/java/io/ebeaninternal/server/transaction/JdbcTransaction.java +++ b/ebean-core/src/main/java/io/ebeaninternal/server/transaction/JdbcTransaction.java @@ -187,7 +187,7 @@ class JdbcTransaction implements SpiTransaction, TxnProfileEventCodes { private final long startNanos; - private boolean transparentPersistence; + private boolean autoPersistUpdates; /** * Create a new JdbcTransaction. @@ -211,7 +211,7 @@ class JdbcTransaction implements SpiTransaction, TxnProfileEventCodes { this.batchOnCascadeMode = false; this.onQueryOnly = OnQueryOnly.ROLLBACK; } else { - this.transparentPersistence = explicit && manager.isAutoPersistUpdates(); + this.autoPersistUpdates = explicit && manager.isAutoPersistUpdates(); this.logSql = manager.isLogSql(); this.logSummary = manager.isLogSummary(); this.skipCacheAfterWrite = manager.isSkipCacheAfterWrite(); @@ -298,14 +298,14 @@ class JdbcTransaction implements SpiTransaction, TxnProfileEventCodes { } @Override - public void setTransparentPersistence(boolean transparentPersistence) { - this.transparentPersistence = transparentPersistence; + public void setAutoPersistUpdates(boolean autoPersistUpdates) { + this.autoPersistUpdates = autoPersistUpdates; this.batchMode = true; } @Override - public boolean isTransparentPersistence() { - return transparentPersistence; + public boolean isAutoPersistUpdates() { + return autoPersistUpdates; } @Override @@ -788,7 +788,7 @@ class JdbcTransaction implements SpiTransaction, TxnProfileEventCodes { * Flush the JDBC batch and execute derived relationship statements if necessary. */ private void internalBatchFlush() { - if (transparentPersistence) { + if (autoPersistUpdates) { // Experimental - flush dirty beans held by the persistence context manager.flushTransparent(persistenceContext, this); } @@ -1060,7 +1060,7 @@ class JdbcTransaction implements SpiTransaction, TxnProfileEventCodes { throw new IllegalStateException(illegalStateMessage); } try { - if (queryOnly && !transparentPersistence) { + if (queryOnly && !autoPersistUpdates) { connectionEndForQueryOnly(); } else { flushCommitAndNotify(); diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/transaction/NoTransaction.java b/ebean-core/src/main/java/io/ebeaninternal/server/transaction/NoTransaction.java index 92f0e1ca9..0d3c82cd6 100644 --- a/ebean-core/src/main/java/io/ebeaninternal/server/transaction/NoTransaction.java +++ b/ebean-core/src/main/java/io/ebeaninternal/server/transaction/NoTransaction.java @@ -26,12 +26,12 @@ class NoTransaction implements SpiTransaction { static final NoTransaction INSTANCE = new NoTransaction(); @Override - public void setTransparentPersistence(boolean transparentPersistence) { + public void setAutoPersistUpdates(boolean autoPersistUpdates) { // do nothing } @Override - public boolean isTransparentPersistence() { + public boolean isAutoPersistUpdates() { return false; } diff --git a/ebean-core/src/test/java/org/tests/transparentpersist/TestTransparentPersist.java b/ebean-core/src/test/java/org/tests/transparentpersist/TestTransparentPersist.java index a59ddda60..963cc1dcb 100644 --- a/ebean-core/src/test/java/org/tests/transparentpersist/TestTransparentPersist.java +++ b/ebean-core/src/test/java/org/tests/transparentpersist/TestTransparentPersist.java @@ -24,7 +24,7 @@ public class TestTransparentPersist extends BaseTestCase { EBasicVer newBean; try (Transaction transaction = DB.beginTransaction()) { - transaction.setTransparentPersistence(true); // EXPERIMENTAL feature + transaction.setAutoPersistUpdates(true); // EXPERIMENTAL feature newBean = new EBasicVer("insertMe"); DB.save(newBean); @@ -60,7 +60,7 @@ public class TestTransparentPersist extends BaseTestCase { DB.save(b0); try (Transaction transaction = DB.beginTransaction()) { - transaction.setTransparentPersistence(true); // EXPERIMENTAL feature + transaction.setAutoPersistUpdates(true); // EXPERIMENTAL feature EBasicVer found = DB.find(EBasicVer.class, b0.getId()); // make it dirty @@ -88,7 +88,7 @@ public class TestTransparentPersist extends BaseTestCase { EBasicVer newBean; try (Transaction transaction = DB.beginTransaction()) { - transaction.setTransparentPersistence(true); // EXPERIMENTAL feature + transaction.setAutoPersistUpdates(true); // EXPERIMENTAL feature EBasicVer found = DB.find(EBasicVer.class, b0.getId()); found.setName("auto dirty"); @@ -127,7 +127,7 @@ public class TestTransparentPersist extends BaseTestCase { transPersist.save(); try (Transaction transaction = DB.beginTransaction()) { - transaction.setTransparentPersistence(true); // EXPERIMENTAL feature + transaction.setAutoPersistUpdates(true); // EXPERIMENTAL feature EBasicVer found = DB.find(EBasicVer.class, transPersist.getId()); found.setName("Persisted automatically as dirty"); @@ -152,7 +152,7 @@ public class TestTransparentPersist extends BaseTestCase { DB.save(order); try (Transaction transaction = DB.beginTransaction()) { - transaction.setTransparentPersistence(true); // EXPERIMENTAL feature + transaction.setAutoPersistUpdates(true); // EXPERIMENTAL feature Order foundOrder = DB.find(Order.class, order.getId()); foundOrder.setStatus(Order.Status.APPROVED); @@ -188,7 +188,7 @@ public class TestTransparentPersist extends BaseTestCase { LoggedSql.start(); try (Transaction transaction = DB.beginTransaction()) { - transaction.setTransparentPersistence(true); // EXPERIMENTAL feature + transaction.setAutoPersistUpdates(true); // EXPERIMENTAL feature Order foundOrder = DB.find(Order.class, order.getId()); // we ONLY mutate the foreign key From 6d8a1c9398951b2bffe51e1e9d951b971bfbcb91 Mon Sep 17 00:00:00 2001 From: Vladimir Konkov Date: Mon, 5 Apr 2021 21:45:48 +0300 Subject: [PATCH 191/447] Explicit locking method withLock() is unaccessible on query beans --- .../src/main/java/io/ebean/typequery/TQRootBean.java | 4 ++-- .../src/test/java/org/querytest/QCustomerTest.java | 1 + 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/ebean-querybean/src/main/java/io/ebean/typequery/TQRootBean.java b/ebean-querybean/src/main/java/io/ebean/typequery/TQRootBean.java index 654e35e9d..728184cf4 100644 --- a/ebean-querybean/src/main/java/io/ebean/typequery/TQRootBean.java +++ b/ebean-querybean/src/main/java/io/ebean/typequery/TQRootBean.java @@ -679,7 +679,7 @@ public abstract class TQRootBean { * Provides us with the ability to explicitly use Postgres * SHARE, KEY SHARE, NO KEY UPDATE and UPDATE row locks. */ - R withLock(Query.LockType lockType) { + public R withLock(Query.LockType lockType) { query.withLock(lockType); return root; } @@ -693,7 +693,7 @@ public abstract class TQRootBean { * Provides us with the ability to explicitly use Postgres * SHARE, KEY SHARE, NO KEY UPDATE and UPDATE row locks. */ - R withLock(Query.LockType lockType, Query.LockWait lockWait) { + public R withLock(Query.LockType lockType, Query.LockWait lockWait) { query.withLock(lockType, lockWait); return root; } diff --git a/ebean-querybean/src/test/java/org/querytest/QCustomerTest.java b/ebean-querybean/src/test/java/org/querytest/QCustomerTest.java index 56aec1c51..867290e71 100644 --- a/ebean-querybean/src/test/java/org/querytest/QCustomerTest.java +++ b/ebean-querybean/src/test/java/org/querytest/QCustomerTest.java @@ -71,6 +71,7 @@ public class QCustomerTest { // not found using other transaction final Customer foundNot = new QCustomer() .name.eq("explicitTransaction") + .withLock(Query.LockType.SHARE) .findOne(); assertThat(foundNot).isNull(); From 9b04f20ed3a1c40de97826f682524d3a6757a77d Mon Sep 17 00:00:00 2001 From: Roman Parshikov Date: Tue, 6 Apr 2021 13:32:57 +0800 Subject: [PATCH 192/447] Fix copy/paste typo --- ebean-api/src/main/java/io/ebean/ExpressionList.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ebean-api/src/main/java/io/ebean/ExpressionList.java b/ebean-api/src/main/java/io/ebean/ExpressionList.java index 72f1c06f9..e91846e08 100644 --- a/ebean-api/src/main/java/io/ebean/ExpressionList.java +++ b/ebean-api/src/main/java/io/ebean/ExpressionList.java @@ -1671,7 +1671,7 @@ public interface ExpressionList { ExpressionList endAnd(); /** - * End a AND junction - synonym for endJunction(). + * End a OR junction - synonym for endJunction(). */ ExpressionList endOr(); From f7c1845f0c5dae997f27a799438fea02a7dadf2f Mon Sep 17 00:00:00 2001 From: rbygrave Date: Tue, 6 Apr 2021 19:58:02 +1200 Subject: [PATCH 193/447] #2177 - Fix where schema not provided by JDBC driver For @Table with schema, using findNative with a JDBC driver that does not provide the schema this fix matches by just using the table name. --- .../server/deploy/BeanDescriptor.java | 6 +-- .../server/deploy/BeanDescriptorTest.java | 53 ++++++++++++++++--- 2 files changed, 48 insertions(+), 11 deletions(-) diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/deploy/BeanDescriptor.java b/ebean-core/src/main/java/io/ebeaninternal/server/deploy/BeanDescriptor.java index a2d902f13..e05c636bb 100644 --- a/ebean-core/src/main/java/io/ebeaninternal/server/deploy/BeanDescriptor.java +++ b/ebean-core/src/main/java/io/ebeaninternal/server/deploy/BeanDescriptor.java @@ -2473,7 +2473,7 @@ public class BeanDescriptor implements BeanType, STreeType { * Return the property path given the db table and column. */ public String findBeanPath(String schemaName, String tableName, String columnName) { - if (matchBaseTable(schemaName, tableName)) { + if (matchBaseTable(tableName)) { return columnPath.get(columnName); } BeanPropertyAssoc assocProperty = tablePath.get(tableName); @@ -2489,10 +2489,10 @@ public class BeanDescriptor implements BeanType, STreeType { return null; } - private boolean matchBaseTable(String schemaName, String tableName) { + boolean matchBaseTable(String tableName) { return tableName.isEmpty() || baseTable.equalsIgnoreCase(tableName) - || baseTable.equalsIgnoreCase(schemaName + "." + tableName); + || baseTable.endsWith("." + tableName); } /** diff --git a/ebean-core/src/test/java/io/ebeaninternal/server/deploy/BeanDescriptorTest.java b/ebean-core/src/test/java/io/ebeaninternal/server/deploy/BeanDescriptorTest.java index d4cbcbfbf..ab8ae6a87 100644 --- a/ebean-core/src/test/java/io/ebeaninternal/server/deploy/BeanDescriptorTest.java +++ b/ebean-core/src/test/java/io/ebeaninternal/server/deploy/BeanDescriptorTest.java @@ -4,21 +4,22 @@ import io.ebean.BaseTestCase; import io.ebean.Ebean; import io.ebean.bean.EntityBean; import io.ebean.plugin.Property; +import io.ebeaninternal.server.core.CacheOptions; +import io.ebeaninternal.server.deploy.meta.DeployBeanDescriptor; +import io.ebeaninternal.server.deploy.meta.DeployIdentityMode; +import io.ebeanservice.docstore.api.DocStoreBeanAdapter; import org.junit.Test; -import org.tests.model.basic.Animal; -import org.tests.model.basic.AnimalShelter; -import org.tests.model.basic.Cat; -import org.tests.model.basic.Contact; -import org.tests.model.basic.Country; -import org.tests.model.basic.Customer; -import org.tests.model.basic.Dog; -import org.tests.model.basic.Order; +import org.tests.model.basic.*; import org.tests.model.bridge.BSite; import org.tests.model.bridge.BUser; import java.util.Collection; import static org.assertj.core.api.Assertions.assertThat; +import static org.junit.Assert.assertTrue; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.when; public class BeanDescriptorTest extends BaseTestCase { @@ -88,6 +89,42 @@ public class BeanDescriptorTest extends BaseTestCase { assertThat(props).extracting("name").contains("id", "status", "orderDate", "shipDate"); } + @Test + public void matchBaseTable() { + BeanDescriptor desc = getBeanDescriptor(Customer.class); + assertTrue(desc.matchBaseTable("o_customer")); + } + + @Test + public void matchBaseTable_whenTableHasSchema_expect_matchRegardlessOfSchema() { + + DeployBeanDescriptor deploy = mockDeployCustomer(); + + when(deploy.getBaseTable()).thenReturn("foo.o_customer"); + BeanDescriptor desc1 = new BeanDescriptor<>(mockOwner(), deploy); + assertTrue(desc1.matchBaseTable("o_customer")); + + when(deploy.getBaseTable()).thenReturn("bar.o_customer"); + BeanDescriptor desc2 = new BeanDescriptor<>(mockOwner(), deploy); + assertTrue(desc2.matchBaseTable("o_customer")); + } + + @SuppressWarnings("unchecked") + private DeployBeanDescriptor mockDeployCustomer() { + DeployBeanDescriptor deploy = mock(DeployBeanDescriptor.class); + when(deploy.getBeanType()).thenReturn(Customer.class); + when(deploy.getIdentityMode()).thenReturn(DeployIdentityMode.auto()); + when(deploy.buildIdentityMode()).thenReturn(IdentityMode.NONE); + when(deploy.getCacheOptions()).thenReturn(CacheOptions.NO_CACHING); + return deploy; + } + + private BeanDescriptorMap mockOwner() { + BeanDescriptorMap owner = mock(BeanDescriptorMap.class); + when(owner.createDocStoreBeanAdapter(any(), any())).thenReturn(mock(DocStoreBeanAdapter.class)); + return owner; + } + @Test public void merge_when_empty() { From 3e97a4005ab34abbac6829ac7e8d70550427c96f Mon Sep 17 00:00:00 2001 From: rbygrave Date: Tue, 6 Apr 2021 20:09:09 +1200 Subject: [PATCH 194/447] Change TestCustomerFinder drop query plan threshold for tests only --- .../java/org/tests/query/finder/TestCustomerFinder.java | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/ebean-core/src/test/java/org/tests/query/finder/TestCustomerFinder.java b/ebean-core/src/test/java/org/tests/query/finder/TestCustomerFinder.java index 8446f9d5b..468b165bb 100644 --- a/ebean-core/src/test/java/org/tests/query/finder/TestCustomerFinder.java +++ b/ebean-core/src/test/java/org/tests/query/finder/TestCustomerFinder.java @@ -55,7 +55,6 @@ public class TestCustomerFinder extends BaseTestCase { assertThat(json1).contains("\"name\":\"txn.main\""); assertThat(json1).contains("\"name\":\"orm.Customer.findList\""); assertThat(json1).doesNotContain("\"sql\":\"select t0.id, t0.status, t0.name"); - } @Test @@ -85,7 +84,6 @@ public class TestCustomerFinder extends BaseTestCase { assertThat(customer.getName()).isEqualTo(customer1.getName()); assertThat(Customer.find.db().getName()).isEqualTo(DB.getDefault().getName()); - } @Test @@ -178,7 +176,7 @@ public class TestCustomerFinder extends BaseTestCase { // change default collect query plan threshold to 200 micros QueryPlanInit init0 = new QueryPlanInit(); init0.setAll(true); - init0.setThresholdMicros(200); + init0.setThresholdMicros(2); final List plans = server().getMetaInfoManager().queryPlanInit(init0); assertThat(plans.size()).isGreaterThan(1); @@ -188,7 +186,7 @@ public class TestCustomerFinder extends BaseTestCase { // change query plan threshold to 100 micros QueryPlanInit init = new QueryPlanInit(); init.setAll(true); - init.setThresholdMicros(100); + init.setThresholdMicros(1); final List appliedToPlans = server().getMetaInfoManager().queryPlanInit(init); assertThat(appliedToPlans.size()).isGreaterThan(4); From bb1275f4f95aa43c34b392791b419f2e673bb6dc Mon Sep 17 00:00:00 2001 From: rbygrave Date: Tue, 6 Apr 2021 21:13:59 +1200 Subject: [PATCH 195/447] #2217 - Inserting an entity bean is skipped with a String @Id property and no other properties set --- .../server/core/PersistRequestBean.java | 7 ++ .../server/deploy/BeanDescriptor.java | 2 +- .../server/persist/DefaultPersister.java | 2 +- .../cache/personinfo/PersonCacheEmail.java | 4 + .../tests/cache/personinfo/PersonOther.java | 73 +++++++++++++++++++ .../cache/personinfo/TestStringIdOnly.java | 30 ++++++++ 6 files changed, 116 insertions(+), 2 deletions(-) create mode 100644 ebean-core/src/test/java/org/tests/cache/personinfo/PersonOther.java create mode 100644 ebean-core/src/test/java/org/tests/cache/personinfo/TestStringIdOnly.java diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/core/PersistRequestBean.java b/ebean-core/src/main/java/io/ebeaninternal/server/core/PersistRequestBean.java index eb48fc2ef..01c27fa0f 100644 --- a/ebean-core/src/main/java/io/ebeaninternal/server/core/PersistRequestBean.java +++ b/ebean-core/src/main/java/io/ebeaninternal/server/core/PersistRequestBean.java @@ -1032,6 +1032,13 @@ public final class PersistRequestBean extends PersistRequest implements BeanP } } + /** + * Return if persist can be skipped on the reference only bean. + */ + public boolean isSkipReference() { + return intercept.isReference() || (Flags.isRecurse(flags) && beanDescriptor.referenceIdPropertyOnly(intercept)); + } + public boolean isReference() { return beanDescriptor.isReference(intercept); } diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/deploy/BeanDescriptor.java b/ebean-core/src/main/java/io/ebeaninternal/server/deploy/BeanDescriptor.java index a2d902f13..2e0e00b65 100644 --- a/ebean-core/src/main/java/io/ebeaninternal/server/deploy/BeanDescriptor.java +++ b/ebean-core/src/main/java/io/ebeaninternal/server/deploy/BeanDescriptor.java @@ -3134,7 +3134,7 @@ public class BeanDescriptor implements BeanType, STreeType { return ebi.isReference() || referenceIdPropertyOnly(ebi); } - boolean referenceIdPropertyOnly(EntityBeanIntercept ebi) { + public boolean referenceIdPropertyOnly(EntityBeanIntercept ebi) { return idOnlyReference && ebi.hasIdOnly(idPropertyIndex); } diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/persist/DefaultPersister.java b/ebean-core/src/main/java/io/ebeaninternal/server/persist/DefaultPersister.java index a7b21f0c8..935fbb6b8 100644 --- a/ebean-core/src/main/java/io/ebeaninternal/server/persist/DefaultPersister.java +++ b/ebean-core/src/main/java/io/ebeaninternal/server/persist/DefaultPersister.java @@ -447,7 +447,7 @@ public final class DefaultPersister implements Persister { public void insert(EntityBean bean, Transaction t) { PersistRequestBean req = createRequest(bean, t, PersistRequest.Type.INSERT); - if (req.isReference()) { + if (req.isSkipReference()) { // skip insert on reference bean return; } diff --git a/ebean-core/src/test/java/org/tests/cache/personinfo/PersonCacheEmail.java b/ebean-core/src/test/java/org/tests/cache/personinfo/PersonCacheEmail.java index 58ddea0a2..144253edf 100644 --- a/ebean-core/src/test/java/org/tests/cache/personinfo/PersonCacheEmail.java +++ b/ebean-core/src/test/java/org/tests/cache/personinfo/PersonCacheEmail.java @@ -25,6 +25,10 @@ public class PersonCacheEmail { this.email = email; } + public PersonCacheEmail(String id) { + this.id = id; + } + public String getId() { return id; } diff --git a/ebean-core/src/test/java/org/tests/cache/personinfo/PersonOther.java b/ebean-core/src/test/java/org/tests/cache/personinfo/PersonOther.java new file mode 100644 index 000000000..b4b505125 --- /dev/null +++ b/ebean-core/src/test/java/org/tests/cache/personinfo/PersonOther.java @@ -0,0 +1,73 @@ +package org.tests.cache.personinfo; + +import io.ebean.annotation.WhenCreated; +import io.ebean.annotation.WhenModified; + +import javax.persistence.Entity; +import javax.persistence.Id; +import javax.persistence.Version; +import javax.validation.constraints.Size; +import java.time.Instant; + +@Entity +public class PersonOther { + + @Id + @Size(max=128) + private String id; + + private String email; + + @WhenCreated + private Instant whenCreated; + + @WhenModified + private Instant whenModified; + + @Version + private long version; + + public PersonOther(String id) { + this.id = id; + } + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public String getEmail() { + return email; + } + + public void setEmail(String email) { + this.email = email; + } + + public Instant getWhenCreated() { + return whenCreated; + } + + public void setWhenCreated(Instant whenCreated) { + this.whenCreated = whenCreated; + } + + public Instant getWhenModified() { + return whenModified; + } + + public void setWhenModified(Instant whenModified) { + this.whenModified = whenModified; + } + + public long getVersion() { + return version; + } + + public void setVersion(long version) { + this.version = version; + } +} diff --git a/ebean-core/src/test/java/org/tests/cache/personinfo/TestStringIdOnly.java b/ebean-core/src/test/java/org/tests/cache/personinfo/TestStringIdOnly.java new file mode 100644 index 000000000..6379491ff --- /dev/null +++ b/ebean-core/src/test/java/org/tests/cache/personinfo/TestStringIdOnly.java @@ -0,0 +1,30 @@ +package org.tests.cache.personinfo; + +import io.ebean.BaseTestCase; +import io.ebean.DB; +import org.junit.Test; + +import static org.assertj.core.api.Assertions.assertThat; + +public class TestStringIdOnly extends BaseTestCase { + + @Test + public void insert() { + + PersonCacheEmail b0 = new PersonCacheEmail("IdOnly"); + DB.save(b0); + + PersonCacheEmail found = DB.find(PersonCacheEmail.class, b0.getId()); + assertThat(found).isNotNull(); + } + + @Test + public void insert_whenIdOnly() { + + PersonOther b0 = new PersonOther("IdOnly"); + DB.save(b0); + + PersonOther found = DB.find(PersonOther.class, b0.getId()); + assertThat(found).isNotNull(); + } +} From f7f383d8f303682368096a9fdb52da50bcaf7e50 Mon Sep 17 00:00:00 2001 From: rbygrave Date: Wed, 7 Apr 2021 13:38:34 +1200 Subject: [PATCH 196/447] No effective change - tidy tests TestRawSqlPositionedParams, TestRawSqlUnparsedQuery --- .../rawsql/TestRawSqlPositionedParams.java | 54 +++++++++---------- .../tests/rawsql/TestRawSqlUnparsedQuery.java | 29 +++++----- 2 files changed, 42 insertions(+), 41 deletions(-) diff --git a/ebean-core/src/test/java/org/tests/rawsql/TestRawSqlPositionedParams.java b/ebean-core/src/test/java/org/tests/rawsql/TestRawSqlPositionedParams.java index f1c3ef4fd..75d678fd6 100644 --- a/ebean-core/src/test/java/org/tests/rawsql/TestRawSqlPositionedParams.java +++ b/ebean-core/src/test/java/org/tests/rawsql/TestRawSqlPositionedParams.java @@ -1,38 +1,42 @@ package org.tests.rawsql; import io.ebean.BaseTestCase; -import io.ebean.Ebean; -import io.ebean.Query; +import io.ebean.DB; import io.ebean.RawSql; import io.ebean.RawSqlBuilder; +import org.junit.Test; import org.tests.model.basic.Customer; import org.tests.model.basic.ResetBasicData; -import org.junit.Test; import java.util.List; -import static org.junit.Assert.assertNotNull; +import static org.assertj.core.api.Assertions.assertThat; public class TestRawSqlPositionedParams extends BaseTestCase { + private static final RawSql RAWSQL_1 = RawSqlBuilder + .parse("select r.id, r.name from o_customer r where r.id >= ? and r.name like ?") + .create(); + + private static final RawSql RAW_SQL_2 = RawSqlBuilder + .unparsed("select r.id, r.name from o_customer r where r.id >= ? and r.name like ?") + .columnMapping("r.id", "id") + .columnMapping("r.name", "name") + .create(); + @Test public void test() { ResetBasicData.reset(); - RawSql rawSql = RawSqlBuilder - .parse("select r.id, r.name from o_customer r where r.id >= ? and r.name like ?") - .create(); + List list = DB.find(Customer.class) + .setRawSql(RAWSQL_1) + .setParameter(1) + .setParameter("R%") + .where().lt("id", 2001) + .findList(); - Query query = Ebean.find(Customer.class); - query.setRawSql(rawSql); - query.setParameter(1, 1); - query.setParameter(2, "R%"); - query.where().lt("id", 2001); - - List list = query.findList(); - - assertNotNull(list); + assertThat(list).isNotNull(); } @Test @@ -40,18 +44,12 @@ public class TestRawSqlPositionedParams extends BaseTestCase { ResetBasicData.reset(); - RawSql rawSql = RawSqlBuilder - .unparsed("select r.id, r.name from o_customer r where r.id >= ? and r.name like ?") - .columnMapping("r.id", "id") - .columnMapping("r.name", "name").create(); + List list = DB.find(Customer.class) + .setRawSql(RAW_SQL_2) + .setParameter(1) + .setParameter("R%") + .findList(); - Query query = Ebean.find(Customer.class); - query.setRawSql(rawSql); - query.setParameter(1, 1); - query.setParameter(2, "R%"); - - List list = query.findList(); - - assertNotNull(list); + assertThat(list).isNotNull(); } } diff --git a/ebean-core/src/test/java/org/tests/rawsql/TestRawSqlUnparsedQuery.java b/ebean-core/src/test/java/org/tests/rawsql/TestRawSqlUnparsedQuery.java index 8d900b15f..1e576f0b7 100644 --- a/ebean-core/src/test/java/org/tests/rawsql/TestRawSqlUnparsedQuery.java +++ b/ebean-core/src/test/java/org/tests/rawsql/TestRawSqlUnparsedQuery.java @@ -1,19 +1,25 @@ package org.tests.rawsql; import io.ebean.BaseTestCase; -import io.ebean.Ebean; -import io.ebean.Query; +import io.ebean.DB; import io.ebean.RawSql; import io.ebean.RawSqlBuilder; +import org.junit.Test; import org.tests.model.basic.Customer; import org.tests.model.basic.ResetBasicData; -import org.junit.Assert; -import org.junit.Test; import java.util.List; +import static org.assertj.core.api.Assertions.assertThat; + public class TestRawSqlUnparsedQuery extends BaseTestCase { + private static final RawSql rawSql = RawSqlBuilder + .unparsed("select r.id, r.name from o_customer r where r.id >= :a and r.name like :b") + .columnMapping("r.id", "id") + .columnMapping("r.name", "name") + .create(); + @Test public void testDoubleUnparsedQuery() { @@ -25,17 +31,14 @@ public class TestRawSqlUnparsedQuery extends BaseTestCase { } private static void test() { - RawSql rawSql = RawSqlBuilder - .unparsed("select r.id, r.name from o_customer r where r.id >= :a and r.name like :b") - .columnMapping("r.id", "id").columnMapping("r.name", "name").create(); - Query query = Ebean.find(Customer.class); - query.setRawSql(rawSql); - query.setParameter("a", 1); - query.setParameter("b", "R%"); + List list = DB.find(Customer.class) + .setRawSql(rawSql) + .setParameter("a", 1) + .setParameter("b", "R%") + .findList(); - List list = query.findList(); - Assert.assertNotNull(list); + assertThat(list).isNotNull(); } } From 59793f3c018e1291ec4bf6d869dba4117aa1ca7c Mon Sep 17 00:00:00 2001 From: rbygrave Date: Wed, 7 Apr 2021 15:50:04 +1200 Subject: [PATCH 197/447] Improve javadoc for Transaction#setGetGeneratedKeys More clearly document the limitation that we can't update beans that don't have id values --- .../src/main/java/io/ebean/Transaction.java | 30 ++++++------------- 1 file changed, 9 insertions(+), 21 deletions(-) diff --git a/ebean-api/src/main/java/io/ebean/Transaction.java b/ebean-api/src/main/java/io/ebean/Transaction.java index d4918e84e..d3e918c0d 100644 --- a/ebean-api/src/main/java/io/ebean/Transaction.java +++ b/ebean-api/src/main/java/io/ebean/Transaction.java @@ -339,15 +339,12 @@ public interface Transaction extends AutoCloseable { * The batch is automatically flushed when it hits the batch size and also when we * execute queries or when we mix UpdateSql and CallableSql with save and delete of * beans. - *

*

* We use {@link #flush()} to explicitly flush the batch and we can use * {@link #setFlushOnQuery(boolean)} and {@link #setFlushOnMixed(boolean)} * to control the automatic flushing behaviour. - *

*

* Example: batch processing of CallableSql executing every 10 rows - *

* *
{@code
    *
@@ -392,14 +389,11 @@ public interface Transaction extends AutoCloseable {
    * 

* This only takes effect when batch mode on the transaction has not already meant that * JDBC batch mode is being used. - *

*

* This is useful when the single save() or delete() cascades. For example, inserting a 'master' cascades * and inserts a collection of 'detail' beans. The detail beans can be inserted using JDBC batch. - *

*

* This is effectively already turned on for all platforms apart from older Sql Server. - *

* * @param batchMode the batch mode to use per save(), insert(), update() or delete() * @see io.ebean.config.DatabaseConfig#setPersistBatchOnCascade(PersistBatch) @@ -422,15 +416,19 @@ public interface Transaction extends AutoCloseable { int getBatchSize(); /** - * Specify if you want batched inserts to use getGeneratedKeys. + * Specify if we want batched inserts to use getGeneratedKeys. *

* By default batched inserts will try to use getGeneratedKeys if it is * supported by the underlying jdbc driver and database. - *

*

- * You may want to turn getGeneratedKeys off when you are inserting a large - * number of objects and you don't care about getting back the ids. - *

+ * We want to turn off getGeneratedKeys when we are inserting a large + * number of objects and we don't care about getting back the ids. In this + * way we avoid the extra cost of getting back the generated id values + * from the database. + *

+ * Note that when we do turn off getGeneratedKeys then we have the limitation + * that after a bean has been inserted we are unable to then mutate the bean + * and update it in the same transaction as we have not obtained it's id value. */ void setGetGeneratedKeys(boolean getGeneratedKeys); @@ -449,13 +447,11 @@ public interface Transaction extends AutoCloseable { *

* If you want to execute both WITHOUT having the batch automatically flush * you need to call this with batchFlushOnMixed = false. - *

*

* Note that UpdateSql and CallableSql are ALWAYS executed first (before the * beans are executed). This is because the UpdateSql and CallableSql have * already been bound to their PreparedStatements. The beans on the other hand * have a 2 step process (delayed binding). - *

*/ void setFlushOnMixed(boolean batchFlushOnMixed); @@ -473,7 +469,6 @@ public interface Transaction extends AutoCloseable { *

* Calling this method with batchFlushOnQuery = false means that you can * execute a query and the batch will not be automatically flushed. - *

*/ void setFlushOnQuery(boolean batchFlushOnQuery); @@ -490,7 +485,6 @@ public interface Transaction extends AutoCloseable { * should be flushed prior to executing a query. *

* The default is for this to be true. - *

*/ boolean isFlushOnQuery(); @@ -507,7 +501,6 @@ public interface Transaction extends AutoCloseable { * flush the batch if you like. *

* Flushing occurs automatically when: - *

*