Search in sources :

Example 1 with ClassHelper

use of org.seasar.doma.jdbc.ClassHelper in project doma by domaframework.

the class PreparedSqlBuilderTest method testAppendParameter_domain.

@Test
public void testAppendParameter_domain() {
    PreparedSqlBuilder builder = new PreparedSqlBuilder(config, SqlKind.SELECT, SqlLogType.FORMATTED);
    builder.appendSql("select * from aaa where phoneNumber = ");
    DomainType<String, PhoneNumber> phoneNumberType = DomainTypeFactory.getDomainType(PhoneNumber.class, new ClassHelper() {
    });
    PhoneNumber phoneNumber = new PhoneNumber("03-1234-5678");
    builder.appendParameter(new DomainInParameter<>(phoneNumberType, phoneNumber));
    PreparedSql sql = builder.build(Function.identity());
    assertEquals("select * from aaa where phoneNumber = ?", sql.toString());
}
Also used : ClassHelper(org.seasar.doma.jdbc.ClassHelper) PreparedSql(org.seasar.doma.jdbc.PreparedSql) PhoneNumber(example.domain.PhoneNumber) Test(org.junit.jupiter.api.Test)

Example 2 with ClassHelper

use of org.seasar.doma.jdbc.ClassHelper 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());
}
Also used : ClassHelper(org.seasar.doma.jdbc.ClassHelper) Optional(java.util.Optional) Reference(org.seasar.doma.jdbc.Reference) PhoneNumber(example.domain.PhoneNumber) Test(org.junit.jupiter.api.Test)

Example 3 with ClassHelper

use of org.seasar.doma.jdbc.ClassHelper in project doma by domaframework.

the class ScalarInParameterTest 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();
    ScalarInParameter<String, Optional<PhoneNumber>> parameter = new ScalarInParameter<>(scalar);
    Optional<Class<?>> optional = parameter.getDomainClass();
    assertEquals(PhoneNumber.class, optional.get());
}
Also used : ClassHelper(org.seasar.doma.jdbc.ClassHelper) Optional(java.util.Optional) PhoneNumber(example.domain.PhoneNumber) Test(org.junit.jupiter.api.Test)

Example 4 with ClassHelper

use of org.seasar.doma.jdbc.ClassHelper in project doma by domaframework.

the class StringArrayTest method testGetExternalDomainType.

@Test
public void testGetExternalDomainType(Config config) throws Exception {
    DomainType<Object, String[]> domainType = DomainTypeFactory.getExternalDomainType(String[].class, new ClassHelper() {
    });
    Scalar<Object, String[]> scalar = domainType.createScalar();
    assertNotNull(scalar);
}
Also used : ClassHelper(org.seasar.doma.jdbc.ClassHelper) Test(org.junit.jupiter.api.Test)

Example 5 with ClassHelper

use of org.seasar.doma.jdbc.ClassHelper 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());
}
Also used : ClassHelper(org.seasar.doma.jdbc.ClassHelper) Reference(org.seasar.doma.jdbc.Reference) PhoneNumber(example.domain.PhoneNumber) Test(org.junit.jupiter.api.Test)

Aggregations

Test (org.junit.jupiter.api.Test)7 ClassHelper (org.seasar.doma.jdbc.ClassHelper)7 PhoneNumber (example.domain.PhoneNumber)5 Optional (java.util.Optional)2 Reference (org.seasar.doma.jdbc.Reference)2 PreparedSql (org.seasar.doma.jdbc.PreparedSql)1