Search in sources :

Example 1 with JpaClass

use of org.jdbi.v3.jpa.internal.JpaClass in project jdbi by jdbi.

the class BindJpaFactory method createForParameter.

@Override
public SqlStatementParameterCustomizer createForParameter(Annotation annotation, Class<?> sqlObjectType, Method method, Parameter param, int index, Type type) {
    BindJpa bind = (BindJpa) annotation;
    final String prefix;
    if (bind.value().isEmpty()) {
        prefix = "";
    } else {
        prefix = bind.value() + ".";
    }
    return (stmt, arg) -> {
        JpaClass<?> jpaClass = JpaClass.get(arg.getClass());
        for (JpaMember member : jpaClass.members()) {
            stmt.bindByType(prefix + member.getColumnName(), readMember(arg, member), member.getType());
        }
    };
}
Also used : EntityMemberAccessException(org.jdbi.v3.jpa.EntityMemberAccessException) BindJpa(org.jdbi.v3.jpa.BindJpa) Type(java.lang.reflect.Type) Parameter(java.lang.reflect.Parameter) SqlStatementCustomizerFactory(org.jdbi.v3.sqlobject.customizer.SqlStatementCustomizerFactory) Annotation(java.lang.annotation.Annotation) SqlStatementParameterCustomizer(org.jdbi.v3.sqlobject.customizer.SqlStatementParameterCustomizer) Method(java.lang.reflect.Method) InvocationTargetException(java.lang.reflect.InvocationTargetException) BindJpa(org.jdbi.v3.jpa.BindJpa)

Aggregations

Annotation (java.lang.annotation.Annotation)1 InvocationTargetException (java.lang.reflect.InvocationTargetException)1 Method (java.lang.reflect.Method)1 Parameter (java.lang.reflect.Parameter)1 Type (java.lang.reflect.Type)1 BindJpa (org.jdbi.v3.jpa.BindJpa)1 EntityMemberAccessException (org.jdbi.v3.jpa.EntityMemberAccessException)1 SqlStatementCustomizerFactory (org.jdbi.v3.sqlobject.customizer.SqlStatementCustomizerFactory)1 SqlStatementParameterCustomizer (org.jdbi.v3.sqlobject.customizer.SqlStatementParameterCustomizer)1