mirror of
https://github.com/ebean-orm/ebean.git
synced 2024-04-21 10:51:47 +00:00
52 lines
1.3 KiB
Java
52 lines
1.3 KiB
Java
package org.tests.query;
|
|
|
|
import io.ebean.BaseTestCase;
|
|
import io.ebean.Ebean;
|
|
import io.ebean.annotation.ForPlatform;
|
|
import io.ebean.annotation.Platform;
|
|
import org.ebeantest.LoggedSqlCollector;
|
|
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;
|
|
|
|
public class TestQueryBaseTable extends BaseTestCase {
|
|
|
|
@ForPlatform({Platform.H2, Platform.POSTGRES})
|
|
@Test
|
|
public void test() {
|
|
|
|
ResetBasicData.reset();
|
|
|
|
LoggedSqlCollector.start();
|
|
|
|
Customer one = Ebean.find(Customer.class)
|
|
.setBaseTable("O_CUSTOMER")
|
|
.where().startsWith("name", "Rob")
|
|
.findOne();
|
|
|
|
Customer two = Ebean.find(Customer.class)
|
|
.where().startsWith("name", "Rob")
|
|
.findOne();
|
|
|
|
Customer three = Ebean.find(Customer.class)
|
|
.setBaseTable("O_CUSTOMER")
|
|
.where().startsWith("name", "Fiona")
|
|
.findOne();
|
|
|
|
assertThat(one.getName()).isEqualTo(two.getName());
|
|
assertThat(three.getName()).isEqualTo("Fiona");
|
|
|
|
List<String> sql = LoggedSqlCollector.stop();
|
|
|
|
assertThat(sql).hasSize(3);
|
|
assertThat(sql.get(0)).contains("from O_CUSTOMER");
|
|
assertThat(sql.get(1)).contains("from o_customer");
|
|
assertThat(sql.get(2)).contains("from O_CUSTOMER");
|
|
|
|
}
|
|
}
|