use of org.seasar.doma.jdbc.Reference in project doma by domaframework.
the class ScalarInOutParameterTest method testGetDomainClass_optional.
@Test
public void testGetDomainClass_optional() {
DomainType<String, PhoneNumber> domainType = DomainTypeFactory.getDomainType(PhoneNumber.class, new ClassHelper() {
});
Scalar<String, Optional<PhoneNumber>> scalar = domainType.createOptionalScalar();
Reference<Optional<PhoneNumber>> ref = new Reference<>();
ScalarInOutParameter<String, Optional<PhoneNumber>> parameter = new ScalarInOutParameter<>(scalar, ref);
Optional<Class<?>> optional = parameter.getDomainClass();
assertEquals(PhoneNumber.class, optional.get());
}
use of org.seasar.doma.jdbc.Reference in project doma by domaframework.
the class AutoProcedureTest method testIn_InOut_Out.
@Test
public void testIn_InOut_Out(Config config) throws Exception {
ProcedureDao dao = new ProcedureDaoImpl(config);
Integer param1 = 10;
Reference<Integer> param2 = new Reference<>(20);
Reference<Integer> param3 = new Reference<>();
dao.proc_dto_param(param1, param2, param3);
assertEquals(Integer.valueOf(10), param1);
assertEquals(Integer.valueOf(30), param2.get());
assertEquals(Integer.valueOf(10), param3.get());
}
use of org.seasar.doma.jdbc.Reference in project doma by domaframework.
the class FunctionCommandTest method testExecute.
@Test
public void testExecute() {
List<Object> outParameters = runtimeConfig.dataSource.connection.callableStatement.outParameters;
outParameters.add(10);
outParameters.add(null);
outParameters.add(20);
outParameters.add(30);
IntegerWrapper aaa = new IntegerWrapper(40);
IntegerWrapper bbb = new IntegerWrapper(50);
IntegerWrapper ccc = new IntegerWrapper(60);
AutoFunctionQuery<Integer> query = new AutoFunctionQuery<>();
query.setConfig(runtimeConfig);
query.setCatalogName("xxx");
query.setSchemaName("yyy");
query.setFunctionName("aaa");
query.setResultParameter(new BasicSingleResultParameter<>(IntegerWrapper::new));
query.addParameter(new BasicInParameter<>(() -> aaa));
query.addParameter(new BasicOutParameter<>(() -> bbb, new Reference<>()));
query.addParameter(new BasicInOutParameter<>(() -> ccc, new Reference<>()));
query.setCallerClassName("aaa");
query.setCallerMethodName("bbb");
query.setSqlLogType(SqlLogType.FORMATTED);
query.prepare();
Integer result = new FunctionCommand<>(query).execute();
query.complete();
assertNotNull(result);
assertEquals(new Integer(10), result);
assertEquals(new Integer(40), aaa.get());
assertEquals(new Integer(20), bbb.get());
assertEquals(new Integer(30), ccc.get());
String sql = runtimeConfig.dataSource.connection.callableStatement.sql;
assertEquals("{? = call xxx.yyy.aaa(?, ?, ?)}", sql);
}
use of org.seasar.doma.jdbc.Reference in project doma by domaframework.
the class ScalarInOutParameterTest method testGetDomainClass.
@Test
public void testGetDomainClass() {
DomainType<String, PhoneNumber> domainType = DomainTypeFactory.getDomainType(PhoneNumber.class, new ClassHelper() {
});
Scalar<String, PhoneNumber> scalar = domainType.createScalar();
Reference<PhoneNumber> ref = new Reference<>();
ScalarInOutParameter<String, PhoneNumber> parameter = new ScalarInOutParameter<>(scalar, ref);
Optional<Class<?>> optional = parameter.getDomainClass();
assertEquals(PhoneNumber.class, optional.get());
}
use of org.seasar.doma.jdbc.Reference in project doma by domaframework.
the class AutoProcedureTest method testResultSet_Out.
@Test
public void testResultSet_Out(Config config) throws Exception {
ProcedureDao dao = new ProcedureDaoImpl(config);
List<Employee> employees = new ArrayList<>();
Reference<Integer> count = new Reference<>();
dao.proc_resultset_out(employees, 1, count);
assertEquals(13, employees.size());
assertEquals(Integer.valueOf(14), count.get());
}
Aggregations