Skip to content

Instantly share code, notes, and snippets.

@nitindhar7
Created November 5, 2015 03:49
Show Gist options
  • Save nitindhar7/ab981051061f70e2255c to your computer and use it in GitHub Desktop.
Save nitindhar7/ab981051061f70e2255c to your computer and use it in GitHub Desktop.
@BindingAnnotation(BindPost.PostBinderFactory.class)
@Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.PARAMETER})
public @interface BindPost {
class PostBinderFactory implements BinderFactory {
public Binder build(Annotation annotation) {
return new Binder<BindPost, Post>() {
public void bind(SQLStatement q, BindPost bind, Post post) {
Array array = q.getContext().getConnection().createArrayOf("varchar", post.getTags());
q.bind("title", post.getTitle());
q.bindBySqlType("tags", array, Types.ARRAY);
}
};
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment