Created
November 5, 2015 03:49
-
-
Save nitindhar7/ab981051061f70e2255c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@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