use of org.seasar.doma.jdbc.criteria.entity.Emp_ in project doma by domaframework.
the class NativeSqlSelectTest method union.
@Test
void union() {
Emp_ e = new Emp_();
Dept_ d = new Dept_();
SetOperand<String> stmt1 = nativeSql.from(e).select(e.name);
SetOperand<String> stmt2 = nativeSql.from(d).select(d.name);
SetOperand<String> stmt3 = stmt1.union(stmt2);
Sql<?> sql1 = stmt1.asSql();
assertEquals("select t0_.NAME from EMP t0_", sql1.getFormattedSql());
Sql<?> sql2 = stmt2.asSql();
assertEquals("select t0_.NAME from CATA.DEPT t0_", sql2.getFormattedSql());
Sql<?> sql3 = stmt3.asSql();
assertEquals("select t0_.NAME from EMP t0_ union select t0_.NAME from CATA.DEPT t0_", sql3.getFormattedSql());
}
use of org.seasar.doma.jdbc.criteria.entity.Emp_ in project doma by domaframework.
the class NativeSqlSelectTest method forUpdate_mssql_nowait.
@Test
void forUpdate_mssql_nowait() {
NativeSql nativeSql = new NativeSql(new MockConfig() {
@Override
public Dialect getDialect() {
return new MssqlDialect();
}
});
Emp_ e = new Emp_();
Buildable<?> stmt = nativeSql.from(e).where(c -> c.eq(e.id, 1)).forUpdate(ForUpdateOption.noWait()).select(e.id);
Sql<?> sql = stmt.asSql();
assertEquals("select t0_.ID from EMP t0_ with (updlock, rowlock, nowait) where t0_.ID = 1", sql.getFormattedSql());
}
use of org.seasar.doma.jdbc.criteria.entity.Emp_ in project doma by domaframework.
the class NativeSqlSelectTest method where_exist.
@Test
void where_exist() {
Emp_ e = new Emp_();
Dept_ d = new Dept_();
Buildable<?> stmt = nativeSql.from(e).where(c -> c.exists(c.from(d).select(d.id))).select(e.id);
Sql<?> sql = stmt.asSql();
assertEquals("select t0_.ID from EMP t0_ where exists (select t1_.ID from CATA.DEPT t1_)", sql.getFormattedSql());
}
use of org.seasar.doma.jdbc.criteria.entity.Emp_ in project doma by domaframework.
the class NativeSqlSelectTest method orderBy_empty.
@Test
void orderBy_empty() {
Emp_ e = new Emp_();
Buildable<?> stmt = nativeSql.from(e).orderBy(c -> {
}).select(e.id);
Sql<?> sql = stmt.asSql();
assertEquals("select t0_.ID from EMP t0_", sql.getFormattedSql());
}
use of org.seasar.doma.jdbc.criteria.entity.Emp_ in project doma by domaframework.
the class NativeSqlSelectTest method distinct.
@Test
void distinct() {
Emp_ e = new Emp_();
Buildable<?> stmt = nativeSql.from(e).distinct().where(c -> c.eq(e.name, "a"));
Sql<?> sql = stmt.asSql();
assertEquals("select distinct t0_.ID, t0_.NAME, t0_.SALARY, t0_.VERSION from EMP t0_ where t0_.NAME = 'a'", sql.getFormattedSql());
}
Aggregations