mirror of
https://github.com/ebean-orm/ebean.git
synced 2024-04-21 10:51:47 +00:00
Change tests for better portability - Internal changes for DB Migration / DDL generation #369
This commit is contained in:
@@ -67,11 +67,6 @@ public class TestBatchLazyWithCacheHits extends BaseTestCase {
|
||||
.order("name")
|
||||
.findList();
|
||||
|
||||
int count0 = Ebean.createSqlQuery("select t0.id c0 from uuone t0 where t0.name like ? order by t0.name").setParameter(1,"testBLWCH%").findList().size();
|
||||
int count1 = Ebean.createSqlQuery("select t0.id c0 from uuone t0 where t0.name like ? escape'x' order by t0.name").setParameter(1,"testBLWCH%").findList().size();
|
||||
int count2 = Ebean.createSqlQuery("select t0.id c0 from uuone t0 where t0.name like ? escape'/' order by t0.name").setParameter(1,"testBLWCH%").findList().size();
|
||||
int count3 = Ebean.createSqlQuery("select t0.id c0 from uuone t0 where t0.name like ? escape'' order by t0.name").setParameter(1,"testBLWCH%").findList().size();
|
||||
System.out.println("count0:" + count0 + " count1:" + count1 + " count2:" + count2 + " count3:" + count3 + " List:" + list);
|
||||
for (UUOne uuOne : list) {
|
||||
System.out.println(uuOne.getName());
|
||||
}
|
||||
|
||||
@@ -24,7 +24,7 @@ public class EInvoice {
|
||||
@Version
|
||||
Long version;
|
||||
|
||||
Date date;
|
||||
Date invoiceDate;
|
||||
|
||||
State state;
|
||||
|
||||
@@ -66,12 +66,12 @@ public class EInvoice {
|
||||
this.state = state;
|
||||
}
|
||||
|
||||
public Date getDate() {
|
||||
return date;
|
||||
public Date getInvoiceDate() {
|
||||
return invoiceDate;
|
||||
}
|
||||
|
||||
public void setDate(Date date) {
|
||||
this.date = date;
|
||||
public void setInvoiceDate(Date invoiceDate) {
|
||||
this.invoiceDate = invoiceDate;
|
||||
}
|
||||
|
||||
public EPerson getPerson() {
|
||||
|
||||
@@ -32,7 +32,7 @@ public class TestMultipleEmbeddedLoading extends BaseTestCase {
|
||||
bill.setCity("Auckland");
|
||||
|
||||
EInvoice invoice = new EInvoice();
|
||||
invoice.setDate(new Date(System.currentTimeMillis()));
|
||||
invoice.setInvoiceDate(new Date(System.currentTimeMillis()));
|
||||
invoice.setState(State.New);
|
||||
invoice.setShipAddress(ship);
|
||||
invoice.setBillAddress(bill);
|
||||
@@ -47,7 +47,7 @@ public class TestMultipleEmbeddedLoading extends BaseTestCase {
|
||||
// assert fetched bean populated as expected
|
||||
Assert.assertEquals(invoice.getId(), invoice2.getId());
|
||||
Assert.assertEquals(invoice.getState(), invoice2.getState());
|
||||
Assert.assertEquals(invoice.getDate(), invoice2.getDate());
|
||||
Assert.assertEquals(invoice.getInvoiceDate(), invoice2.getInvoiceDate());
|
||||
Assert.assertEquals("2 Apple St", invoice.getBillAddress().getStreet());
|
||||
Assert.assertEquals("2 Apple St", invoice2.getBillAddress().getStreet());
|
||||
|
||||
|
||||
@@ -36,9 +36,9 @@ public class ParentQueryTest extends BaseTestCase {
|
||||
c.setData(exampleData);
|
||||
Ebean.save(c);
|
||||
|
||||
List<Parent> partial = Ebean.find(Parent.class).where().ge("number", 1).findList();
|
||||
List<Parent> partial = Ebean.find(Parent.class).where().ge("val", 1).findList();
|
||||
assertNotNull(partial.get(0).getData());
|
||||
assertEquals(partial.get(0).getData().get(0).getNumber().intValue(), 0);
|
||||
assertEquals(partial.get(0).getData().get(0).getVal().intValue(), 0);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -41,7 +41,7 @@ public class ParentRawSqlTest extends BaseTestCase {
|
||||
Ebean.save(c);
|
||||
|
||||
RawSql rawSql = RawSqlBuilder
|
||||
.parse("select type, id, number from rawinherit_parent where number > 1")
|
||||
.parse("select type, id, val from rawinherit_parent where val > 1")
|
||||
.create();
|
||||
|
||||
List<Parent> partial = Ebean.find(Parent.class)
|
||||
@@ -49,7 +49,7 @@ public class ParentRawSqlTest extends BaseTestCase {
|
||||
.findList();
|
||||
|
||||
assertNotNull(partial.get(0).getData());
|
||||
assertEquals(partial.get(0).getData().get(0).getNumber().intValue(), 0);
|
||||
assertEquals(partial.get(0).getData().get(0).getVal().intValue(), 0);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -85,7 +85,7 @@ public class ParentRawSqlTest extends BaseTestCase {
|
||||
private void useColumnMappingWithDiscriminator() {
|
||||
|
||||
RawSql rawSql = RawSqlBuilder
|
||||
.unparsed("select type, id from rawinherit_parent where number > 1")
|
||||
.unparsed("select type, id from rawinherit_parent where val > 1")
|
||||
.columnMapping("type", "parent.type") // can map the discriminator column 'type'
|
||||
.columnMapping("id", "parent.id")
|
||||
.create();
|
||||
@@ -100,7 +100,7 @@ public class ParentRawSqlTest extends BaseTestCase {
|
||||
}
|
||||
|
||||
assertNotNull(partial.get(0).getData());
|
||||
assertEquals(partial.get(0).getData().get(0).getNumber().intValue(), 0);
|
||||
assertEquals(partial.get(0).getData().get(0).getVal().intValue(), 0);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -109,7 +109,7 @@ public class ParentRawSqlTest extends BaseTestCase {
|
||||
private void useColumnMappingIgnore() {
|
||||
|
||||
RawSql rawSql = RawSqlBuilder
|
||||
.unparsed("select type, id from rawinherit_parent where number > 1")
|
||||
.unparsed("select type, id from rawinherit_parent where val > 1")
|
||||
.columnMappingIgnore("type") // can ignore the discriminator 'type'
|
||||
.columnMapping("id", "parent.id")
|
||||
.create();
|
||||
@@ -124,7 +124,7 @@ public class ParentRawSqlTest extends BaseTestCase {
|
||||
}
|
||||
|
||||
assertNotNull(partial.get(0).getData());
|
||||
assertEquals(partial.get(0).getData().get(0).getNumber().intValue(), 0);
|
||||
assertEquals(partial.get(0).getData().get(0).getVal().intValue(), 0);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -133,7 +133,7 @@ public class ParentRawSqlTest extends BaseTestCase {
|
||||
private void useExtraColumnMappingIgnore() {
|
||||
|
||||
RawSql rawSql = RawSqlBuilder
|
||||
.unparsed("select 'a', type, id, 'b' from rawinherit_parent where number > 1")
|
||||
.unparsed("select 'a', type, id, 'b' from rawinherit_parent where val > 1")
|
||||
.columnMappingIgnore("a") // extra ignore before
|
||||
.columnMappingIgnore("type")
|
||||
.columnMapping("id", "parent.id")
|
||||
@@ -149,7 +149,7 @@ public class ParentRawSqlTest extends BaseTestCase {
|
||||
partial.add(aggregate.parent);
|
||||
}
|
||||
assertNotNull(partial.get(0).getData());
|
||||
assertEquals(partial.get(0).getData().get(0).getNumber().intValue(), 0);
|
||||
assertEquals(partial.get(0).getData().get(0).getVal().intValue(), 0);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -13,15 +13,12 @@ import com.avaje.tests.sp.model.car.Wheel;
|
||||
|
||||
public class TestManyToManySaveTwice extends BaseTestCase {
|
||||
|
||||
@Test
|
||||
public void testNothing() {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testInsertCarTwice() {
|
||||
|
||||
Ebean.deleteAll(Ebean.find(Car.class).findList());
|
||||
Ebean.deleteAll(Ebean.find(Wheel.class).findList());
|
||||
Ebean.createSqlUpdate("delete from sp_car_car_wheels").execute();
|
||||
Ebean.createSqlUpdate("delete from sp_car_wheel").execute();
|
||||
Ebean.createSqlUpdate("delete from sp_car_car").execute();
|
||||
|
||||
List<Wheel> wheels = new LinkedList<Wheel>();
|
||||
wheels.add(new Wheel());
|
||||
|
||||
@@ -14,21 +14,21 @@ public class Data {
|
||||
@Id
|
||||
private Long id;
|
||||
|
||||
private Integer number;
|
||||
private Integer val;
|
||||
|
||||
@ManyToMany(mappedBy = "data")
|
||||
public List<Parent> parents = new ArrayList<Parent>();
|
||||
|
||||
public Data(int number) {
|
||||
this.number = number;
|
||||
this.val = number;
|
||||
}
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public Integer getNumber() {
|
||||
return number;
|
||||
public Integer getVal() {
|
||||
return val;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -20,13 +20,13 @@ public abstract class Parent {
|
||||
@Id
|
||||
private Long id;
|
||||
|
||||
private Integer number;
|
||||
private Integer val;
|
||||
|
||||
@ManyToMany(cascade = CascadeType.PERSIST)
|
||||
private List<Data> data = new ArrayList<Data>();
|
||||
|
||||
protected Parent(Integer number) {
|
||||
this.number = number;
|
||||
protected Parent(Integer val) {
|
||||
this.val = val;
|
||||
}
|
||||
|
||||
public abstract String getName();
|
||||
@@ -35,8 +35,8 @@ public abstract class Parent {
|
||||
return id;
|
||||
}
|
||||
|
||||
public Integer getNumber() {
|
||||
return number;
|
||||
public Integer getVal() {
|
||||
return val;
|
||||
}
|
||||
|
||||
public List<Data> getData() {
|
||||
|
||||
Reference in New Issue
Block a user