@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); } } };
@SqlUpdate ( "UPDATE thumbnail " + "SET x = :thumbnail.x, " + " y = :thumbnail.y, " + " width = :thumbnail.width, " + " height = :thumbnail.height," + " ratio = :thumbnail.ratio " + "WHERE thumbnail.attachment_id = :thumbnail.attachmentId " + " AND thumbnail.source = :thumbnail.source " + " AND thumbnail.hint = :thumbnail.hint" ) Integer updateThumbnail(@BindBean("thumbnail") Thumbnail thumbnail);
@SqlQuery // Magic value to force MySQL to stream from the database // See http://dev.mysql.com/doc/refman/5.0/en/connector-j-reference-implementation-notes.html (ResultSet) @FetchSize(Integer.MIN_VALUE) public Iterator<AuditLogModelDao> getAuditLogsForAccountRecordId(@BindBean final InternalTenantContext context);
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); } } };
@SqlUpdate("insert into dependency (name, timestamp, tenacity_configuration, username, service) values " + "(:dependency.dependencyId, :dependency.dateTime, :dependency.tenacityConfiguration," + " :dependency.user, :dependency.serviceId)") int insert(@BindBean("dependency") DependencyModel dependencyModel);