/** * Bind an argument dynamically by the generic type passed in. * * @param name token name to bind the parameter to * @param value to bind * @param argumentType type token for value argument * * @return the same Query instance */ public final This bindByType(String name, Object value, GenericType<?> argumentType) { return bindByType(name, value, argumentType.getType()); }
/** * Bind an argument dynamically by the generic type passed in. * * @param position position to bind the parameter at, starting at 0 * @param value to bind * @param argumentType type token for value argument * * @return the same Query instance */ public final This bindByType(int position, Object value, GenericType<?> argumentType) { return bindByType(position, value, argumentType.getType()); }
@Override public SqlStatementParameterCustomizer createForParameter(Annotation annotation, Class<?> sqlObjectType, Method method, Parameter param, int index, Type type) { Bind b = (Bind) annotation; String nameFromAnnotation = b == null ? Bind.NO_VALUE : b.value(); Optional<String> name = ParameterUtil.findParameterName(nameFromAnnotation, param); QualifiedType<?> qualifiedType = QualifiedType.of(type).with(getQualifiers(param)); return (stmt, arg) -> { stmt.bindByType(index, arg, qualifiedType); name.ifPresent(n -> stmt.bindByType(n, arg, qualifiedType)); }; } }
@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.getQualifiedType()); } }; }
/** * Bind an argument dynamically by the generic type passed in. * * @param position position to bind the parameter at, starting at 0 * @param value to bind * @param argumentType type token for value argument * * @return the same Query instance */ public final This bindByType(int position, Object value, GenericType<?> argumentType) { return bindByType(position, value, argumentType.getType()); }
/** * Bind an argument dynamically by the generic type passed in. * * @param name token name to bind the parameter to * @param value to bind * @param argumentType type token for value argument * * @return the same Query instance */ public final This bindByType(String name, Object value, GenericType<?> argumentType) { return bindByType(name, value, argumentType.getType()); }