mirror of
https://github.com/ebean-orm/ebean.git
synced 2024-04-21 10:51:47 +00:00
#919 - io.ebean package initial
This commit is contained in:
@@ -0,0 +1,44 @@
|
||||
package org.tests.rawsql;
|
||||
|
||||
import io.ebean.BaseTestCase;
|
||||
import io.ebean.Ebean;
|
||||
import io.ebean.FetchConfig;
|
||||
import io.ebean.Query;
|
||||
import io.ebean.RawSql;
|
||||
import io.ebean.RawSqlBuilder;
|
||||
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 TestRawSqlOrmQueryDistinct extends BaseTestCase {
|
||||
|
||||
@Test
|
||||
public void test() {
|
||||
|
||||
ResetBasicData.reset();
|
||||
|
||||
RawSql rawSql0 = RawSqlBuilder.parse(" select distinct r.id, r.name from o_customer r ")
|
||||
.create();
|
||||
|
||||
Query<Customer> query0 = Ebean.find(Customer.class);
|
||||
query0.setRawSql(rawSql0);
|
||||
query0.where().ilike("name", "r%");
|
||||
|
||||
RawSql rawSql = RawSqlBuilder.parse(" select distinct r.id, r.name from o_customer r ")
|
||||
.columnMapping("r.id", "id").columnMapping("r.name", "name").create();
|
||||
|
||||
Query<Customer> query = Ebean.find(Customer.class);
|
||||
query.setRawSql(rawSql);
|
||||
query.where().ilike("name", "r%");
|
||||
|
||||
query.fetch("contacts", new FetchConfig().query());
|
||||
query.filterMany("contacts").gt("lastName", "b");
|
||||
|
||||
List<Customer> list = query.findList();
|
||||
Assert.assertNotNull(list);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user