mirror of
https://github.com/ebean-orm/ebean.git
synced 2024-04-21 10:51:47 +00:00
Merge branch 'master' into feature/redundant-local-var
This commit is contained in:
@@ -18,6 +18,7 @@ public class EbeanServerFactory_ServerConfigStart_Test {
|
||||
config.setName("h2");
|
||||
config.loadFromProperties();
|
||||
config.setName("h2other");
|
||||
config.setH2ProductionMode(true);
|
||||
config.setDdlGenerate(false);
|
||||
config.setDdlRun(false);
|
||||
config.setDefaultServer(false);
|
||||
|
||||
@@ -34,9 +34,11 @@ public class ServerConfigTest {
|
||||
props.setProperty("jdbcFetchSizeFindList", "43");
|
||||
props.setProperty("backgroundExecutorShutdownSecs", "98");
|
||||
props.setProperty("backgroundExecutorSchedulePoolSize", "4");
|
||||
props.setProperty("h2ProductionMode", "true");
|
||||
|
||||
serverConfig.loadFromProperties(props);
|
||||
|
||||
assertTrue(serverConfig.isH2ProductionMode());
|
||||
assertEquals(PersistBatch.INSERT, serverConfig.getPersistBatch());
|
||||
assertEquals(PersistBatch.INSERT, serverConfig.getPersistBatchOnCascade());
|
||||
assertEquals(ServerConfig.DbUuid.BINARY, serverConfig.getDbUuid());
|
||||
|
||||
@@ -31,6 +31,7 @@ public class ModelBuild_compoundKeyTest extends BaseTestCase {
|
||||
config.setName("h2");
|
||||
config.loadFromProperties();
|
||||
config.setName("h2other");
|
||||
config.setH2ProductionMode(true);
|
||||
config.setDdlGenerate(false);
|
||||
config.setDdlRun(false);
|
||||
config.setDefaultServer(false);
|
||||
|
||||
+1
@@ -25,6 +25,7 @@ public class ModelBuild_explicitSequencesTest extends BaseTestCase {
|
||||
config.setName("h2");
|
||||
config.loadFromProperties();
|
||||
config.setName("h2other");
|
||||
config.setH2ProductionMode(true);
|
||||
config.setDdlGenerate(false);
|
||||
config.setDdlRun(false);
|
||||
config.setDefaultServer(false);
|
||||
|
||||
@@ -73,6 +73,7 @@ public class BeanPersistControllerTest {
|
||||
ServerConfig config = new ServerConfig();
|
||||
|
||||
config.setName("h2ebasicver");
|
||||
config.setH2ProductionMode(true);
|
||||
config.loadFromProperties();
|
||||
config.setDdlGenerate(true);
|
||||
config.setDdlRun(true);
|
||||
|
||||
@@ -52,6 +52,7 @@ public class BeanPostLoadTest extends BaseTestCase {
|
||||
|
||||
config.setName("h2ebasicver");
|
||||
config.loadFromProperties();
|
||||
config.setH2ProductionMode(true);
|
||||
config.setDdlGenerate(true);
|
||||
config.setDdlRun(true);
|
||||
|
||||
|
||||
@@ -47,11 +47,6 @@ public class Order implements Serializable {
|
||||
COMPLETE
|
||||
}
|
||||
|
||||
public Order() {
|
||||
|
||||
}
|
||||
|
||||
|
||||
@Id
|
||||
Integer id;
|
||||
|
||||
|
||||
@@ -1,25 +1,22 @@
|
||||
package com.avaje.tests.model.converstation;
|
||||
|
||||
import com.avaje.ebean.annotation.History;
|
||||
import com.avaje.ebean.annotation.HistoryExclude;
|
||||
import com.avaje.tests.model.BaseModel;
|
||||
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.ManyToOne;
|
||||
import javax.persistence.Table;
|
||||
|
||||
import com.avaje.ebean.annotation.History;
|
||||
import com.avaje.ebean.annotation.HistoryExclude;
|
||||
import com.avaje.ebean.annotation.WhenModified;
|
||||
import com.avaje.tests.model.BaseModel;
|
||||
|
||||
import java.sql.Timestamp;
|
||||
|
||||
@History
|
||||
@Entity
|
||||
@Table(name="c_user")
|
||||
@Table(name = "c_user")
|
||||
public class User extends BaseModel {
|
||||
|
||||
boolean inactive;
|
||||
|
||||
|
||||
String name;
|
||||
|
||||
|
||||
String email;
|
||||
|
||||
@HistoryExclude
|
||||
@@ -28,12 +25,9 @@ public class User extends BaseModel {
|
||||
@ManyToOne
|
||||
Group group;
|
||||
|
||||
@WhenModified
|
||||
Timestamp whenModified;
|
||||
|
||||
public User() {
|
||||
}
|
||||
|
||||
|
||||
public boolean isInactive() {
|
||||
return inactive;
|
||||
}
|
||||
@@ -74,13 +68,4 @@ public class User extends BaseModel {
|
||||
this.passwordHash = passwordHash;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Timestamp getWhenModified() {
|
||||
return whenModified;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setWhenModified(Timestamp whenModified) {
|
||||
this.whenModified = whenModified;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@ import com.avaje.ebean.BaseTestCase;
|
||||
import com.avaje.ebean.Ebean;
|
||||
import com.avaje.ebean.RawSql;
|
||||
import com.avaje.ebean.RawSqlBuilder;
|
||||
import com.avaje.tests.model.basic.Customer;
|
||||
import com.avaje.tests.model.basic.EBasic;
|
||||
import com.avaje.tests.model.basic.Order;
|
||||
import com.avaje.tests.model.basic.OrderDetail;
|
||||
@@ -13,7 +14,7 @@ import org.junit.Test;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
import static org.assertj.core.api.StrictAssertions.assertThat;
|
||||
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;
|
||||
@@ -54,6 +55,72 @@ public class TestRawSqlMasterDetail extends BaseTestCase {
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testForeignKeyColumn() {
|
||||
|
||||
ResetBasicData.reset();
|
||||
|
||||
// billing_address_id fk column is automatically
|
||||
// mapped to the logical path: billingAddress.id
|
||||
|
||||
String rs = "select c.id, c.name, c.billing_address_id, c.updtime "+
|
||||
"from o_customer c " +
|
||||
"order by c.id";
|
||||
|
||||
RawSql rawSql = RawSqlBuilder.parse(rs).create();
|
||||
|
||||
List<Customer> customers = Ebean.find(Customer.class)
|
||||
.setRawSql(rawSql)
|
||||
.findList();
|
||||
|
||||
assertThat(customers).isNotEmpty();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSimpleNestedColumn() {
|
||||
|
||||
ResetBasicData.reset();
|
||||
|
||||
|
||||
String rs = "select c.id, c.name, c.billing_address_id, ba.line_1, ba.city, c.updtime "+
|
||||
"from o_customer c " +
|
||||
" left join o_address ba on ba.id = c.billing_address_id "+
|
||||
"order by c.id";
|
||||
|
||||
RawSql rawSql = RawSqlBuilder.parse(rs)
|
||||
.tableAliasMapping("ba", "billingAddress")
|
||||
.create();
|
||||
|
||||
List<Customer> customers = Ebean.find(Customer.class)
|
||||
.setRawSql(rawSql)
|
||||
.findList();
|
||||
|
||||
assertThat(customers).isNotEmpty();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDoubleJoinColumn() {
|
||||
|
||||
ResetBasicData.reset();
|
||||
|
||||
String rs = "select c.id, c.name, c.billing_address_id, ba.line_1, ba.city, c.updtime, sa.id, sa.line_1, sa.city "+
|
||||
"from o_customer c " +
|
||||
" left join o_address ba on ba.id = c.billing_address_id "+
|
||||
" left join o_address sa on sa.id = c.shipping_address_id "+
|
||||
"order by c.id";
|
||||
|
||||
RawSql rawSql = RawSqlBuilder.parse(rs)
|
||||
.tableAliasMapping("ba", "billingAddress")
|
||||
.tableAliasMapping("sa", "shippingAddress")
|
||||
.create();
|
||||
|
||||
List<Customer> customers = Ebean.find(Customer.class)
|
||||
.setRawSql(rawSql)
|
||||
.findList();
|
||||
|
||||
assertThat(customers).isNotEmpty();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testWithTableAliasMapping() {
|
||||
|
||||
|
||||
@@ -43,6 +43,7 @@ public class TestAutoCommitDataSource extends BaseTestCase {
|
||||
|
||||
ServerConfig config = new ServerConfig();
|
||||
config.setName("h2autocommit");
|
||||
config.setH2ProductionMode(true);
|
||||
config.loadFromProperties();
|
||||
config.setDataSource(pool);
|
||||
config.setDefaultServer(false);
|
||||
|
||||
Reference in New Issue
Block a user