mirror of
https://github.com/ebean-orm/ebean.git
synced 2026-11-22 15:10:02 +00:00
Merge branch 'master' into wip/EntityBeanIntercept-interface
This commit is contained in:
commit
d1b5400f2c
138 files changed
+1249
-2851
No files matched your search
@@ -9,31 +9,31 @@ public class FetchConfigTest {
|
||||
|
||||
@Test
|
||||
public void testLazy() {
|
||||
FetchConfig config = new FetchConfig().lazy();
|
||||
FetchConfig config = FetchConfig.ofLazy();
|
||||
assertThat(config.getBatchSize()).isEqualTo(0);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testLazy_withParameter() {
|
||||
FetchConfig config = new FetchConfig().lazy(50);
|
||||
FetchConfig config = FetchConfig.ofLazy(50);
|
||||
assertThat(config.getBatchSize()).isEqualTo(50);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testQuery() {
|
||||
FetchConfig config = new FetchConfig().query();
|
||||
FetchConfig config = FetchConfig.ofQuery();
|
||||
assertThat(config.getBatchSize()).isEqualTo(100);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testQuery_withParameter() {
|
||||
FetchConfig config = new FetchConfig().query(50);
|
||||
FetchConfig config = FetchConfig.ofQuery(50);
|
||||
assertThat(config.getBatchSize()).isEqualTo(50);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testQueryFirst() {
|
||||
FetchConfig config = new FetchConfig().queryFirst(50);
|
||||
FetchConfig config = FetchConfig.ofQuery(50);
|
||||
assertThat(config.getBatchSize()).isEqualTo(50);
|
||||
}
|
||||
|
||||
@@ -52,67 +52,67 @@ public class FetchConfigTest {
|
||||
|
||||
@Test
|
||||
public void testEquals_when_noOptions() {
|
||||
assertSame(new FetchConfig(), new FetchConfig());
|
||||
assertSame(FetchConfig.ofDefault(), FetchConfig.ofDefault());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testEquals_when_query_50_lazy_40() {
|
||||
assertSame(new FetchConfig().query(50), FetchConfig.ofQuery(50));
|
||||
assertSame(FetchConfig.ofQuery(50), FetchConfig.ofQuery(50));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testEquals_when_query_50_lazy() {
|
||||
assertSame(new FetchConfig().lazy(), FetchConfig.ofLazy());
|
||||
assertSame(FetchConfig.ofLazy(), FetchConfig.ofLazy());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testEquals_when_query_50() {
|
||||
assertSame(new FetchConfig().query(50), new FetchConfig().query(50));
|
||||
assertSame(FetchConfig.ofQuery(50), FetchConfig.ofQuery(50));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testEquals_when_queryFirst_50_lazy_40() {
|
||||
assertSame(new FetchConfig().queryFirst(50).lazy(40), FetchConfig.ofLazy(40));
|
||||
assertSame(FetchConfig.ofLazy(40), FetchConfig.ofLazy(40));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testEquals_when_queryFirst_50_lazy() {
|
||||
assertSame(new FetchConfig().queryFirst(50).lazy(), new FetchConfig().queryFirst(50).lazy());
|
||||
assertSame(FetchConfig.ofLazy(), FetchConfig.ofLazy());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testEquals_when_queryFirst_50() {
|
||||
assertSame(new FetchConfig().queryFirst(50), FetchConfig.ofQuery(50));
|
||||
assertSame(FetchConfig.ofQuery(50), FetchConfig.ofQuery(50));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testNotEquals_when_query_50() {
|
||||
assertDifferent(new FetchConfig().query(50), new FetchConfig().query(40));
|
||||
assertDifferent(FetchConfig.ofQuery(50), FetchConfig.ofQuery(40));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testNotEquals_when_query_50_lazy() {
|
||||
assertDifferent(new FetchConfig().query(50), new FetchConfig().query(50).lazy());
|
||||
assertDifferent(FetchConfig.ofQuery(50), FetchConfig.ofLazy(50));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testNotEquals_when_query_50_lazy_40() {
|
||||
assertDifferent(new FetchConfig().query(50), new FetchConfig().query(50).lazy(40));
|
||||
assertDifferent(FetchConfig.ofQuery(50), FetchConfig.ofLazy(40));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testNotEquals_when_queryFirst_50() {
|
||||
assertDifferent(new FetchConfig().queryFirst(50), new FetchConfig().queryFirst(40));
|
||||
assertDifferent(FetchConfig.ofQuery(50), FetchConfig.ofQuery(40));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testNotEquals_when_queryFirst_50_lazy() {
|
||||
assertDifferent(new FetchConfig().queryFirst(50), new FetchConfig().queryFirst(50).lazy());
|
||||
assertDifferent(FetchConfig.ofQuery(50), FetchConfig.ofLazy());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testNotEquals_when_queryFirst_50_lazy_40() {
|
||||
assertDifferent(new FetchConfig().queryFirst(50), new FetchConfig().queryFirst(50).lazy(40));
|
||||
assertDifferent(FetchConfig.ofQuery(50), FetchConfig.ofLazy(40));
|
||||
}
|
||||
|
||||
void assertDifferent(FetchConfig v1, FetchConfig v2) {
|
||||
|
||||
+2
-2
@@ -1,7 +1,7 @@
|
||||
package io.ebean.xtest.internal.server.cluster.binarymessage;
|
||||
|
||||
import io.ebean.Database;
|
||||
import io.ebean.xtest.BaseTestCase;
|
||||
import io.ebean.EbeanServer;
|
||||
import io.ebean.xtest.internal.api.TDSpiEbeanServer;
|
||||
import io.ebeaninternal.api.TransactionEventTable;
|
||||
import io.ebeaninternal.server.cache.RemoteCacheEvent;
|
||||
@@ -94,7 +94,7 @@ public class BinaryTransactionEventReadWriteTest extends BaseTestCase {
|
||||
|
||||
class TDServerLookup implements ServerLookup {
|
||||
@Override
|
||||
public EbeanServer getServer(String name) {
|
||||
public Database getServer(String name) {
|
||||
return mockEbeanServer;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,16 +1,13 @@
|
||||
package main;
|
||||
|
||||
import io.ebean.docker.commands.CockroachConfig;
|
||||
import io.ebean.docker.commands.CockroachContainer;
|
||||
|
||||
public class StartCockroach {
|
||||
|
||||
public static void main(String[] args) {
|
||||
|
||||
CockroachConfig config = new CockroachConfig("v21.2.4");
|
||||
config.setDbName("unit");
|
||||
|
||||
CockroachContainer container = new CockroachContainer(config);
|
||||
container.start();
|
||||
CockroachContainer.newBuilder("v21.2.4")
|
||||
.dbName("unit")
|
||||
.build()
|
||||
.start();
|
||||
}
|
||||
}
|
||||
@@ -1,22 +1,18 @@
|
||||
package main;
|
||||
|
||||
import io.ebean.docker.commands.Db2Config;
|
||||
import io.ebean.docker.commands.Db2Container;
|
||||
|
||||
public class StartDb2 {
|
||||
|
||||
public static void main(String[] args) {
|
||||
|
||||
Db2Config config = new Db2Config("11.5.6.0a");
|
||||
config.setDbName("unit");
|
||||
config.setUser("unit");
|
||||
config.setPassword("unit");
|
||||
|
||||
// to change collation, charset and other parameters like pagesize:
|
||||
config.setCreateOptions("USING CODESET UTF-8 TERRITORY DE COLLATE USING IDENTITY PAGESIZE 32768");
|
||||
config.setConfigOptions("USING STRING_UNITS CODEUNITS32");
|
||||
|
||||
Db2Container container = new Db2Container(config);
|
||||
container.startWithDropCreate();
|
||||
Db2Container.newBuilder("11.5.6.0a")
|
||||
.dbName("unit")
|
||||
.user("unit")
|
||||
.password("unit")
|
||||
// to change collation, charset and other parameters like pagesize:
|
||||
.configOptions("USING CODESET UTF-8 TERRITORY DE COLLATE USING IDENTITY PAGESIZE 32768")
|
||||
.configOptions("USING STRING_UNITS CODEUNITS32")
|
||||
.build()
|
||||
.startWithDropCreate();
|
||||
}
|
||||
}
|
||||
@@ -1,18 +1,15 @@
|
||||
package main;
|
||||
|
||||
import io.ebean.docker.commands.MariaDBConfig;
|
||||
import io.ebean.docker.commands.MariaDBContainer;
|
||||
|
||||
public class StartMariaDb {
|
||||
|
||||
public static void main(String[] args) {
|
||||
|
||||
MariaDBConfig config = new MariaDBConfig("10.5");
|
||||
config.setDbName("unit");
|
||||
config.setUser("unit");
|
||||
config.setPassword("unit");
|
||||
|
||||
MariaDBContainer container = new MariaDBContainer(config);
|
||||
container.startWithDropCreate();
|
||||
MariaDBContainer.newBuilder("10.5")
|
||||
.dbName("unit")
|
||||
.user("unit")
|
||||
.password("unit")
|
||||
.build()
|
||||
.startWithDropCreate();
|
||||
}
|
||||
}
|
||||
@@ -1,16 +1,17 @@
|
||||
package main;
|
||||
|
||||
import io.ebean.docker.commands.MySqlConfig;
|
||||
import io.ebean.docker.commands.MySqlContainer;
|
||||
|
||||
public class StartMySql {
|
||||
|
||||
public static void main(String[] args) {
|
||||
|
||||
MySqlConfig config = new MySqlConfig("8.0");
|
||||
config.setDbName("unit");
|
||||
config.setUser("unit");
|
||||
config.setPassword("unit");
|
||||
MySqlContainer.newBuilder("8.0")
|
||||
.dbName("unit")
|
||||
.user("unit")
|
||||
.password("unit")
|
||||
.build()
|
||||
.startWithDropCreate();
|
||||
|
||||
// by default this mysql docker collation is case sensitive
|
||||
// using utf8mb4_bin
|
||||
@@ -22,7 +23,5 @@ public class StartMySql {
|
||||
// config.setCollation("utf8mb4_unicode_ci");
|
||||
// config.setCharacterSet("utf8mb4");
|
||||
|
||||
MySqlContainer container = new MySqlContainer(config);
|
||||
container.startWithDropCreate();
|
||||
}
|
||||
}
|
||||
@@ -1,16 +1,14 @@
|
||||
package main;
|
||||
|
||||
import io.ebean.docker.commands.NuoDBConfig;
|
||||
import io.ebean.docker.commands.NuoDBContainer;
|
||||
|
||||
public class StartNuoDB {
|
||||
|
||||
public static void main(String[] args) {
|
||||
NuoDBContainer container = NuoDBContainer.newBuilder("4.0")
|
||||
.schema("test_user")
|
||||
.build();
|
||||
|
||||
NuoDBConfig config = new NuoDBConfig();
|
||||
config.setSchema("test_user");
|
||||
|
||||
NuoDBContainer container = new NuoDBContainer(config);
|
||||
container.stopRemove();
|
||||
container.startWithDropCreate();
|
||||
}
|
||||
|
||||
@@ -1,16 +1,13 @@
|
||||
package main;
|
||||
|
||||
import io.ebean.docker.commands.OracleConfig;
|
||||
import io.ebean.docker.commands.OracleContainer;
|
||||
|
||||
public class StartOracle {
|
||||
|
||||
public static void main(String[] args) {
|
||||
|
||||
OracleConfig config = new OracleConfig();
|
||||
config.setUser("test_ebean");
|
||||
|
||||
OracleContainer container = new OracleContainer(config);
|
||||
container.startWithDropCreate();
|
||||
OracleContainer.newBuilder("latest")
|
||||
.user("test_ebean")
|
||||
.build()
|
||||
.startWithDropCreate();
|
||||
}
|
||||
}
|
||||
@@ -1,21 +1,18 @@
|
||||
package main;
|
||||
|
||||
import io.ebean.docker.commands.PostgresConfig;
|
||||
import io.ebean.docker.commands.PostgresContainer;
|
||||
|
||||
public class StartPostgres {
|
||||
|
||||
public static void main(String[] args) {
|
||||
|
||||
PostgresConfig config = new PostgresConfig("13");
|
||||
config.setPort(5432);
|
||||
config.setDbName("unit");
|
||||
config.setUser("unit");
|
||||
config.setPassword("unit");
|
||||
config.setContainerName("pg13x");
|
||||
config.setExtensions("hstore,pgcrypto");
|
||||
|
||||
PostgresContainer container = new PostgresContainer(config);
|
||||
container.startWithDropCreate();
|
||||
PostgresContainer.newBuilder("13")
|
||||
.port(5432)
|
||||
.dbName("unit")
|
||||
.user("unit")
|
||||
.password("unit")
|
||||
.containerName("pg13x")
|
||||
.extensions("hstore,pgcrypto")
|
||||
.build()
|
||||
.startWithDropCreate();
|
||||
}
|
||||
}
|
||||
@@ -1,15 +1,15 @@
|
||||
package main;
|
||||
|
||||
import io.ebean.docker.commands.SqlServerConfig;
|
||||
import io.ebean.docker.commands.SqlServerContainer;
|
||||
|
||||
public class StartSqlServer {
|
||||
|
||||
public static void main(String[] args) {
|
||||
|
||||
SqlServerConfig config = new SqlServerConfig("2019-GA-ubuntu-16.04");
|
||||
config.setDbName("test_ebean");
|
||||
config.setUser("test_ebean");
|
||||
SqlServerContainer.newBuilder("2019-GA-ubuntu-16.04")
|
||||
.dbName("test_ebean")
|
||||
.user("test_ebean")
|
||||
.build()
|
||||
.start();
|
||||
|
||||
// by default this sqlserver docker collation is case sensitive
|
||||
// using MSSQL_COLLATION=Latin1_General_100_BIN2
|
||||
@@ -20,8 +20,5 @@ public class StartSqlServer {
|
||||
|
||||
//config.setCollation("default");
|
||||
//config.setCollation("Latin1_General_100_CI");
|
||||
|
||||
SqlServerContainer container = new SqlServerContainer(config);
|
||||
container.start();
|
||||
}
|
||||
}
|
||||
@@ -1,20 +1,16 @@
|
||||
package main;
|
||||
|
||||
import io.ebean.docker.commands.YugabyteConfig;
|
||||
import io.ebean.docker.commands.YugabyteContainer;
|
||||
|
||||
public class StartYugabyte {
|
||||
|
||||
public static void main(String[] args) {
|
||||
|
||||
// Check add extensions ?
|
||||
YugabyteConfig config = new YugabyteConfig("2.11.2.0-b89");
|
||||
config.setDbName("unit");
|
||||
config.setUser("unit");
|
||||
config.setExtensions("pgcrypto");
|
||||
|
||||
YugabyteContainer container = new YugabyteContainer(config);
|
||||
container.startWithDropCreate();
|
||||
YugabyteContainer.newBuilder("2.11.2.0-b89")
|
||||
.dbName("unit")
|
||||
.user("unit")
|
||||
.extensions("pgcrypto")
|
||||
.build()
|
||||
.startWithDropCreate();
|
||||
|
||||
// Run container ut_yugabyte with host:localhost port:6433 db:unit user:unit/test shutdown:None
|
||||
// docker run -d --name ut_yugabyte -p 6433:5433 -p 7000:7000 -p 9000:9000 -p 9042:9042 yugabytedb/yugabyte:2.11.2.0-b89 bin/yugabyted start --daemon=false
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
package org.tests.model.history;
|
||||
|
||||
import io.ebean.annotation.History;
|
||||
import javax.persistence.CascadeType;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.OneToOne;
|
||||
import org.tests.model.draftable.BaseDomain;
|
||||
|
||||
@History
|
||||
@Entity
|
||||
public class HistoryOneToOne extends BaseDomain {
|
||||
|
||||
final String name;
|
||||
|
||||
@OneToOne(cascade = CascadeType.REFRESH)
|
||||
HistorylessOneToOne historylessOneToOne;
|
||||
|
||||
public HistoryOneToOne(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public HistorylessOneToOne less() {
|
||||
return historylessOneToOne;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
package org.tests.model.history;
|
||||
|
||||
import org.tests.model.draftable.BaseDomain;
|
||||
|
||||
import javax.persistence.CascadeType;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.OneToOne;
|
||||
|
||||
@Entity
|
||||
public class HistorylessOneToOne extends BaseDomain {
|
||||
|
||||
private final String name;
|
||||
|
||||
/**
|
||||
* This @OneToOne(mappedBy=...) side should really be FetchType.LAZY
|
||||
*/
|
||||
@OneToOne(mappedBy = "historylessOneToOne", cascade = CascadeType.ALL, orphanRemoval = true)//, fetch = FetchType.LAZY)
|
||||
HistoryOneToOne historyOneToOne;
|
||||
|
||||
public HistorylessOneToOne(final String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public HistoryOneToOne getHistoryOneToOne() {
|
||||
return historyOneToOne;
|
||||
}
|
||||
|
||||
public void setHistoryOneToOne(final HistoryOneToOne historyOneToOne) {
|
||||
this.historyOneToOne = historyOneToOne;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,90 @@
|
||||
package org.tests.model.history;
|
||||
|
||||
import io.ebean.DB;
|
||||
import io.ebean.annotation.Platform;
|
||||
import io.ebean.xtest.BaseTestCase;
|
||||
import io.ebean.xtest.IgnorePlatform;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.sql.Timestamp;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
class TestHistoryOneToOne extends BaseTestCase {
|
||||
|
||||
private Long expectedLessId;
|
||||
private Long expectedHistoryId;
|
||||
|
||||
@IgnorePlatform({Platform.ORACLE, Platform.COCKROACH})
|
||||
@Test
|
||||
void test() throws InterruptedException {
|
||||
HistorylessOneToOne historylessOneToOne = new HistorylessOneToOne("less");
|
||||
historylessOneToOne.setHistoryOneToOne(new HistoryOneToOne("one"));
|
||||
DB.save(historylessOneToOne);
|
||||
Thread.sleep(20);
|
||||
|
||||
expectedLessId = historylessOneToOne.getId();
|
||||
expectedHistoryId = historylessOneToOne.getHistoryOneToOne().getId();
|
||||
|
||||
findViaHistory();
|
||||
findViaLess();
|
||||
|
||||
findViaLess_fetch();
|
||||
findViaHistory_fetch();
|
||||
}
|
||||
|
||||
private void findViaLess() {
|
||||
HistorylessOneToOne lessFetched = DB.find(HistorylessOneToOne.class)
|
||||
.asOf(new Timestamp(System.currentTimeMillis()))
|
||||
.findOne();
|
||||
|
||||
expected_findViaLess(lessFetched);
|
||||
}
|
||||
|
||||
|
||||
private void findViaLess_fetch() {
|
||||
HistorylessOneToOne lessFetched = DB.find(HistorylessOneToOne.class)
|
||||
.asOf(new Timestamp(System.currentTimeMillis()))
|
||||
.fetch("historyOneToOne")
|
||||
.findOne();
|
||||
|
||||
expected_findViaLess(lessFetched);
|
||||
}
|
||||
|
||||
private void expected_findViaLess(HistorylessOneToOne lessFetched) {
|
||||
assert lessFetched != null;
|
||||
assertThat(lessFetched.getId()).isEqualTo(expectedLessId);
|
||||
HistoryOneToOne history1 = lessFetched.getHistoryOneToOne();
|
||||
assertThat(history1.getId()).isEqualTo(expectedHistoryId);
|
||||
assertThat(history1.less().getId()).isEqualTo(expectedLessId);
|
||||
assertThat(history1.less().getName()).isEqualTo("less");
|
||||
assertThat(history1.getName()).isEqualTo("one");
|
||||
}
|
||||
|
||||
|
||||
private void findViaHistory_fetch() {
|
||||
|
||||
HistoryOneToOne oneFetched = DB.find(HistoryOneToOne.class)
|
||||
.asOf(new Timestamp(System.currentTimeMillis()))
|
||||
.fetch("historylessOneToOne")
|
||||
.findOne();
|
||||
|
||||
expected_viaHistory(oneFetched);
|
||||
}
|
||||
|
||||
private void findViaHistory() {
|
||||
HistoryOneToOne oneFetched = DB.find(HistoryOneToOne.class)
|
||||
.asOf(new Timestamp(System.currentTimeMillis()))
|
||||
.findOne();
|
||||
|
||||
expected_viaHistory(oneFetched);
|
||||
}
|
||||
|
||||
private void expected_viaHistory(HistoryOneToOne oneFetched) {
|
||||
assert oneFetched != null;
|
||||
assertThat(oneFetched.getId()).isEqualTo(expectedHistoryId);
|
||||
assertThat(oneFetched.less().getId()).isEqualTo(expectedLessId);
|
||||
assertThat(oneFetched.less().getName()).isEqualTo("less");
|
||||
assertThat(oneFetched.getName()).isEqualTo("one");
|
||||
}
|
||||
}
|
||||
@@ -68,7 +68,7 @@ public class TestQueryJoinOnFormula extends BaseTestCase {
|
||||
List<String> sql = LoggedSql.stop();
|
||||
assertEquals(1, sql.size());
|
||||
assertSql(sql.get(0)).contains("join (select order_id, count(*) as total_items,");
|
||||
assertSql(sql.get(0)).contains("select count(*) from ( select t0.id from o_order t0 left join (select order_id,");
|
||||
assertSql(sql.get(0)).contains("select count(*) from ( select t0.id from o_order t0 left join (select order_id,");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -83,7 +83,7 @@ public class TestQueryJoinOnFormula extends BaseTestCase {
|
||||
shipQuery.findList();
|
||||
assertSql(shipQuery.getGeneratedSql()).isEqualTo("select t0.id "
|
||||
+ "from or_order_ship t0 "
|
||||
+ "left join o_order t1 on t1.id = t0.order_id "
|
||||
+ "left join o_order t1 on t1.id = t0.order_id "
|
||||
+ "left join (select order_id, count(*) as total_items, sum(order_qty*unit_price) as total_amount from o_order_detail group by order_id) z_bt1 on z_bt1.order_id = t1.id "
|
||||
+ "order by z_bt1.total_amount");
|
||||
}
|
||||
@@ -100,7 +100,7 @@ public class TestQueryJoinOnFormula extends BaseTestCase {
|
||||
shipQuery.findList();
|
||||
assertSql(shipQuery.getGeneratedSql()).isEqualTo("select t0.id "
|
||||
+ "from or_order_ship t0 "
|
||||
+ "left join o_order t1 on t1.id = t0.order_id "
|
||||
+ "left join o_order t1 on t1.id = t0.order_id "
|
||||
+ "left join (select order_id, count(*) as total_items, sum(order_qty*unit_price) as total_amount from o_order_detail group by order_id) z_bt1 on z_bt1.order_id = t1.id "
|
||||
+ "where z_bt1.total_amount is not null");
|
||||
}
|
||||
@@ -124,7 +124,7 @@ public class TestQueryJoinOnFormula extends BaseTestCase {
|
||||
"from or_order_ship t0 " +
|
||||
"join o_order u1 on u1.id = t0.order_id " +
|
||||
"join or_order_ship u2 on u2.order_id = u1.id " +
|
||||
"join o_order u3 on u3.id = u2.order_id " +
|
||||
"join o_order u3 on u3.id = u2.order_id " +
|
||||
"left join (select order_id, count(*) as total_items, sum(order_qty*unit_price) as total_amount from o_order_detail group by order_id) z_bu3 on z_bu3.order_id = u3.id " +
|
||||
"where z_bu3.total_amount is not null");
|
||||
}
|
||||
@@ -141,7 +141,7 @@ public class TestQueryJoinOnFormula extends BaseTestCase {
|
||||
shipQuery.findList();
|
||||
assertSql(shipQuery.getGeneratedSql()).isEqualTo("select t0.id, t1.id, z_bt1.total_amount "
|
||||
+ "from or_order_ship t0 "
|
||||
+ "left join o_order t1 on t1.id = t0.order_id "
|
||||
+ "left join o_order t1 on t1.id = t0.order_id "
|
||||
+ "left join (select order_id, count(*) as total_items, sum(order_qty*unit_price) as total_amount from o_order_detail group by order_id) z_bt1 on z_bt1.order_id = t1.id "
|
||||
+ "order by z_bt1.total_amount");
|
||||
|
||||
@@ -158,7 +158,7 @@ public class TestQueryJoinOnFormula extends BaseTestCase {
|
||||
shipQuery.findList();
|
||||
assertSql(shipQuery.getGeneratedSql()).isEqualTo("select t0.id, t1.id, z_bt1.total_amount "
|
||||
+ "from or_order_ship t0 "
|
||||
+ "left join o_order t1 on t1.id = t0.order_id "
|
||||
+ "left join o_order t1 on t1.id = t0.order_id "
|
||||
+ "left join (select order_id, count(*) as total_items, sum(order_qty*unit_price) as total_amount from o_order_detail group by order_id) z_bt1 on z_bt1.order_id = t1.id "
|
||||
+ "where z_bt1.total_amount is not null");
|
||||
|
||||
@@ -179,7 +179,7 @@ public class TestQueryJoinOnFormula extends BaseTestCase {
|
||||
|
||||
List<String> sql = LoggedSql.stop();
|
||||
assertEquals(1, sql.size());
|
||||
assertSql(sql.get(0)).contains("select count(*) from ( select t0.id from o_order t0 left join (select order_id,");
|
||||
assertSql(sql.get(0)).contains("select count(*) from ( select t0.id from o_order t0 left join (select order_id,");
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -12,6 +12,7 @@ import java.io.PrintStream;
|
||||
import java.net.URL;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
public class TestFileType extends BaseTestCase {
|
||||
|
||||
@@ -184,6 +185,31 @@ public class TestFileType extends BaseTestCase {
|
||||
DB.delete(bean3);
|
||||
}
|
||||
|
||||
@Test
|
||||
void test_FileDirty() throws Exception {
|
||||
SomeFileBean bean0 = new SomeFileBean();
|
||||
bean0.setName("afile");
|
||||
bean0.setContent(file);
|
||||
|
||||
DB.save(bean0);
|
||||
|
||||
SomeFileBean bean1 = DB.find(SomeFileBean.class)
|
||||
.select("name, file")
|
||||
.setId(bean0.getId())
|
||||
.findOne();
|
||||
|
||||
assertThat(bean1.getContent())
|
||||
.isNotEqualTo(file) // not same file object, but same content
|
||||
.hasSameBinaryContentAs(file);
|
||||
|
||||
assertFalse(DB.beanState(bean1).isDirty());
|
||||
bean1.setContent(file);
|
||||
assertFalse(DB.beanState(bean1).isDirty());
|
||||
bean1.setContent(file2);
|
||||
assertTrue(DB.beanState(bean1).isDirty());
|
||||
|
||||
}
|
||||
|
||||
private File getFile(String resource) {
|
||||
URL url = getClass().getResource(resource);
|
||||
return new File(url.getFile());
|
||||
|
||||
@@ -23,7 +23,7 @@ ebean.ddl.run=true
|
||||
ebean.ddl.header=-- Generated by ebean ${version} at ${timestamp}
|
||||
ebean.packages=org.tests,org.etest
|
||||
datasource.default=h2
|
||||
#datasource.default=yugabyte
|
||||
#datasource.default=sqlserver
|
||||
#datasource.h2.capturestacktrace=true
|
||||
|
||||
#ebean.dumpMetricsOnShutdown=true
|
||||
@@ -177,7 +177,8 @@ ebean.sqlserver.databasePlatformName=sqlserver17
|
||||
#ebean.sqlserver.caseSensitiveCollation=false
|
||||
datasource.sqlserver.username=test_ebean
|
||||
datasource.sqlserver.password=SqlS3rv#r
|
||||
datasource.sqlserver.url=jdbc:sqlserver://localhost:1433;databaseName=test_ebean;sendTimeAsDateTime=false
|
||||
#datasource.sqlserver.url=jdbc:sqlserver://localhost:1433;databaseName=test_ebean;sendTimeAsDateTime=false;integratedSecurity=false;trustServerCertificate=true
|
||||
datasource.sqlserver.url=jdbc:sqlserver://localhost:9435;databaseName=test_ebean;sendTimeAsDateTime=false;integratedSecurity=false;trustServerCertificate=true
|
||||
#datasource.sqlserver.driver=com.microsoft.sqlserver.jdbc.SQLServerDriver
|
||||
|
||||
datasource.nuodb.schema=test_user
|
||||
|
||||
Reference in new issue
Block a user