/** * Binds public fields of the specified object as arguments for the query. * * @param object source of the public fields to bind. * * @return modified statement */ public This bindFields(Object object) { return bindNamedArgumentFinder(new ObjectFieldArguments(null, object)); }
/** * Binds named parameters from JavaBean properties on the argument. * * @param bean source of named parameter values to use as arguments * * @return modified statement */ @SuppressWarnings("deprecation") public This bindBean(Object bean) { return bindNamedArgumentFinder(new BeanPropertyArguments(null, bean)); }
/** * Binds methods with no parameters on the argument. * * @param object source of methods to use as arguments * * @return modified statement */ public This bindMethods(Object object) { return bindNamedArgumentFinder(new ObjectMethodArguments(null, object)); }
/** * Binds methods with no parameters on the argument, with the given prefix. * * @param prefix a prefix to apply to all property names. * @param object source of methods to use as arguments * * @return modified statement */ public This bindMethods(String prefix, Object object) { return bindNamedArgumentFinder(new ObjectMethodArguments(prefix, object)); }
/** * Binds public fields of the specified object as arguments for the query. * * @param prefix a prefix to apply to all field names. * @param object source of the public fields to bind. * * @return modified statement */ public This bindFields(String prefix, Object object) { return bindNamedArgumentFinder(new ObjectFieldArguments(prefix, object)); }
/** * Binds named parameters from a map of String to Object instances * * @param map map where keys are matched to named parameters in order to bind arguments. * Can be null, in which case the binding has no effect. * * @return modified statement */ public This bindMap(Map<String, ?> map) { return map == null ? typedThis : bindNamedArgumentFinder(new MapArguments(map)); }
/** * Binds named parameters from JavaBean properties on the bean argument, with the given prefix. * * Example: the prefix {@code foo} applied to a bean property {@code bar} will be bound as {@code foo.bar}. * * @param prefix a prefix to apply to all property names. * @param bean source of named parameter values to use as arguments * * @return modified statement */ @SuppressWarnings("deprecation") public This bindBean(String prefix, Object bean) { return bindNamedArgumentFinder(new BeanPropertyArguments(prefix, bean)); }
/** * Binds named parameters from object properties on the bean argument, with the given prefix. * The type must have been registered with pojo type mapping functionality first, usually * by a plugin or configuration. * * @param prefix a prefix to apply to all property names. * @param pojo source of named parameter values to use as arguments * * @return modified statement * @see JdbiImmutables an example method of registering a type */ @Beta public This bindPojo(String prefix, Object pojo) { return bindNamedArgumentFinder(new PojoPropertyArguments(prefix, pojo, getContext())); }
@Override public SqlStatementParameterCustomizer createForParameter(Annotation annotation, Class<?> sqlObjectType, Method method, Parameter param, int index, Type type) { String bindingName = ((BindNameSpecifying) annotation).value(); assertThat(bindingName).isEqualTo("breakfast"); return (stmt, specifier) -> stmt.bindNamedArgumentFinder((paramName, context) -> { assertThat(paramName).isEqualTo("breakfast.waffle.topping"); SyrupSpecifying syrupSpecifier = (SyrupSpecifying) specifier; return Optional.of((position, statement, ctx) -> statement.setObject(position, syrupSpecifier.getNameValue())); }); } }
/** * Binds named parameters from JavaBean properties on the argument. * * @param bean source of named parameter values to use as arguments * * @return modified statement */ public This bindBean(Object bean) { return bindNamedArgumentFinder(new BeanPropertyArguments(null, bean)); }
/** * Binds named parameters from a map of String to Object instances * * @param map map where keys are matched to named parameters in order to bind arguments. * Can be null, in which case the binding has no effect. * * @return modified statement */ public This bindMap(Map<String, ?> map) { return map == null ? typedThis : bindNamedArgumentFinder(new MapArguments(map)); }
/** * Binds named parameters from JavaBean properties on the bean argument, with the given prefix. * * Example: the prefix {@code foo} applied to a bean property {@code bar} will be bound as {@code foo.bar}. * * @param prefix a prefix to apply to all property names. * @param bean source of named parameter values to use as arguments * * @return modified statement */ public This bindBean(String prefix, Object bean) { return bindNamedArgumentFinder(new BeanPropertyArguments(prefix, bean)); }
@Override public SqlStatementParameterCustomizer createForParameter(Annotation annotation, Class<?> sqlObjectType, Method method, Parameter param, int index, Type type) { String bindingName = ((BindNameSpecifying) annotation).value(); assertThat(bindingName).isEqualTo("breakfast"); return (stmt, specifier) -> stmt.bindNamedArgumentFinder((paramName, context) -> { assertThat(paramName).isEqualTo("breakfast.waffle.topping"); SyrupSpecifying syrupSpecifier = (SyrupSpecifying) specifier; return Optional.of((position, statement, ctx) -> statement.setObject(position, syrupSpecifier.getNameValue())); }); } }