use of example.entity.Emp in project doma by domaframework.
the class AutoUpdateQueryTest method testOption_default.
@Test
public void testOption_default() {
Emp emp = new Emp();
emp.setId(10);
emp.setName("aaa");
emp.setVersion(100);
emp.originalStates = new Emp();
AutoUpdateQuery<Emp> query = new AutoUpdateQuery<>(_Emp.getSingletonInternal());
query.setMethod(method);
query.setConfig(runtimeConfig);
query.setEntity(emp);
query.setCallerClassName("aaa");
query.setCallerMethodName("bbb");
query.setSqlLogType(SqlLogType.FORMATTED);
query.prepare();
PreparedSql sql = query.getSql();
assertEquals("update EMP set NAME = ?, VERSION = ? + 1 where ID = ? and VERSION = ?", sql.getRawSql());
List<InParameter<?>> parameters = sql.getParameters();
assertEquals(4, parameters.size());
assertEquals("aaa", parameters.get(0).getWrapper().get());
assertEquals(100, parameters.get(1).getWrapper().get());
assertEquals(10, parameters.get(2).getWrapper().get());
assertEquals(100, parameters.get(3).getWrapper().get());
}
use of example.entity.Emp in project doma by domaframework.
the class AutoUpdateQueryTest method testOption_exclude.
@Test
public void testOption_exclude() {
Emp emp = new Emp();
emp.setId(10);
emp.setName("aaa");
emp.setSalary(new BigDecimal(200));
emp.setVersion(100);
AutoUpdateQuery<Emp> query = new AutoUpdateQuery<>(_Emp.getSingletonInternal());
query.setMethod(method);
query.setConfig(runtimeConfig);
query.setEntity(emp);
query.setExcludedPropertyNames("name");
query.setCallerClassName("aaa");
query.setCallerMethodName("bbb");
query.setSqlLogType(SqlLogType.FORMATTED);
query.prepare();
PreparedSql sql = query.getSql();
assertEquals("update EMP set SALARY = ?, VERSION = ? + 1 where ID = ? and VERSION = ?", sql.getRawSql());
List<InParameter<?>> parameters = sql.getParameters();
assertEquals(4, parameters.size());
assertEquals(new BigDecimal(200), parameters.get(0).getWrapper().get());
assertEquals(100, parameters.get(1).getWrapper().get());
assertEquals(10, parameters.get(2).getWrapper().get());
assertEquals(100, parameters.get(1).getWrapper().get());
}
use of example.entity.Emp in project doma by domaframework.
the class AutoUpdateQueryTest method testOption_ignoreVersion.
@Test
public void testOption_ignoreVersion() {
Emp emp = new Emp();
emp.setId(10);
emp.setName("aaa");
emp.setVersion(100);
emp.originalStates = new Emp();
AutoUpdateQuery<Emp> query = new AutoUpdateQuery<>(_Emp.getSingletonInternal());
query.setMethod(method);
query.setConfig(runtimeConfig);
query.setEntity(emp);
query.setVersionIgnored(true);
query.setCallerClassName("aaa");
query.setCallerMethodName("bbb");
query.setSqlLogType(SqlLogType.FORMATTED);
query.prepare();
PreparedSql sql = query.getSql();
assertEquals("update EMP set NAME = ?, VERSION = ? where ID = ?", sql.getRawSql());
List<InParameter<?>> parameters = sql.getParameters();
assertEquals(3, parameters.size());
assertEquals("aaa", parameters.get(0).getWrapper().get());
assertEquals(100, parameters.get(1).getWrapper().get());
assertEquals(10, parameters.get(2).getWrapper().get());
}
use of example.entity.Emp in project doma by domaframework.
the class AutoUpdateQueryTest method testOption_include.
@Test
public void testOption_include() {
Emp emp = new Emp();
emp.setId(10);
emp.setName("aaa");
emp.setSalary(new BigDecimal(200));
emp.setVersion(100);
AutoUpdateQuery<Emp> query = new AutoUpdateQuery<>(_Emp.getSingletonInternal());
query.setMethod(method);
query.setConfig(runtimeConfig);
query.setEntity(emp);
query.setIncludedPropertyNames("name");
query.setCallerClassName("aaa");
query.setCallerMethodName("bbb");
query.setSqlLogType(SqlLogType.FORMATTED);
query.prepare();
PreparedSql sql = query.getSql();
assertEquals("update EMP set NAME = ?, VERSION = ? + 1 where ID = ? and VERSION = ?", sql.getRawSql());
List<InParameter<?>> parameters = sql.getParameters();
assertEquals(4, parameters.size());
assertEquals("aaa", parameters.get(0).getWrapper().get());
assertEquals(100, parameters.get(1).getWrapper().get());
assertEquals(10, parameters.get(2).getWrapper().get());
assertEquals(100, parameters.get(3).getWrapper().get());
}
use of example.entity.Emp in project doma by domaframework.
the class AutoUpdateQueryTest method testPrepare.
@Test
public void testPrepare() {
Emp emp = new Emp();
emp.setId(10);
emp.setName("aaa");
emp.setVersion(100);
AutoUpdateQuery<Emp> query = new AutoUpdateQuery<>(_Emp.getSingletonInternal());
query.setMethod(method);
query.setConfig(runtimeConfig);
query.setEntity(emp);
query.setCallerClassName("aaa");
query.setCallerMethodName("bbb");
query.setSqlLogType(SqlLogType.FORMATTED);
query.prepare();
assertNotNull(((UpdateQuery) query).getSql());
}
Aggregations