private void bindStatement(SQLStatement<?> q, String prefix, Map<String, Object> map) { for (Entry<String, Object> entry : map.entrySet()) { Object value = entry.getValue(); String name = prefix + entry.getKey(); if (value == null) { q.bind(name, (Object) null); } else { q.dynamicBind(value.getClass(), name, value); } } }
@Override public void bind(SQLStatement q, BindBean bind, Object arg) { final String prefix; if (BindBean.BARE_BINDING.equals(bind.value())) { prefix = ""; } else { prefix = bind.value() + "."; } try { BeanInfo infos = Introspector.getBeanInfo(arg.getClass()); PropertyDescriptor[] props = infos.getPropertyDescriptors(); for (PropertyDescriptor prop : props) { Method readMethod = prop.getReadMethod(); if (readMethod != null) { q.dynamicBind(readMethod.getReturnType(), prefix + prop.getName(), readMethod.invoke(arg)); } } } catch (Exception e) { throw new IllegalStateException("unable to bind bean properties", e); } } };
@Override public void bind(final SQLStatement q, final SmartBindBean bind, final Object arg) { final String prefix; if (BindBean.BARE_BINDING.equals(bind.value())) { prefix = null; } else { prefix = bind.value() + "."; } try { final BeanInfo infos = Introspector.getBeanInfo(arg.getClass()); final PropertyDescriptor[] props = infos.getPropertyDescriptors(); for (final PropertyDescriptor prop : props) { final Method readMethod = prop.getReadMethod(); if (readMethod != null) { // [OPTIMIZATION] Avoid implicit creation of StringBuilder (concatenation) when no custom annotation value is specified final String name = prefix == null ? prop.getName() : prefix + prop.getName(); q.dynamicBind(readMethod.getReturnType(), name, readMethod.invoke(arg)); } } } catch (final Exception e) { throw new IllegalStateException("unable to bind bean properties", e); } } };
public void bind(SQLStatement q, BindBean bind, Object arg) { final String prefix; if ("___jdbi_bare___".equals(bind.value())) { prefix = ""; } else { prefix = bind.value() + "."; } try { BeanInfo infos = Introspector.getBeanInfo(arg.getClass()); PropertyDescriptor[] props = infos.getPropertyDescriptors(); for (PropertyDescriptor prop : props) { Method readMethod = prop.getReadMethod(); if (readMethod != null) { q.dynamicBind(readMethod.getReturnType(), prefix + prop.getName(), readMethod.invoke(arg)); } } } catch (Exception e) { throw new IllegalStateException("unable to bind bean properties", e); } } };
c = r.getClass(); q.dynamicBind(c, prefix + prop.getName(), r);