I am trying to bind a list of tuples in JDBI:
@Data
@AllArgsConstructor
@NoArgsConstructor
@Builder
@EqualsAndHashCode(onlyExplicitlyIncluded = true)
public class AuthorBooks {
@EqualsAndHashCode.Include
public long authorId;
@EqualsAndHashCode.Include
public long bookId;
}
Using bindMethodsList():
List<AuthorBooks> allAuthorBooks = Arrays.asList(new AuthorBooks(4394, 9977));
handler.createUpdate("DELETE FROM TABLE WHERE (author_id, book_id)"
+ " IS NOT IN (<allAuthorBooks>)")
.bindMethodsList("allAuthorBooks", allAuthorBooks, List.of("getAuthorId, getBookId"))
.execute();
Using bindBeanList():
List<AuthorBooks> allAuthorBooks = Arrays.asList(new AuthorBooks(4394, 9977));
handler.createUpdate("DELETE FROM TABLE WHERE (author_id, book_id)"
+ " IS NOT IN (<allAuthorBooks>)")
.bindBeanList("allAuthorBooks", allAuthorBooks, List.of("authorId, bookId"))
.execute();
Both approach throws error
org.jdbi.v3.core.statement.UnableToCreateStatementException: Unable to get getAuthorId, getBookId argument for AuthorBooks(authorId=4394, bookId=9977)