jpaQuery.setParameter的使用教程
问题描述
JOOQ的新手。遇到这篇文章:https://thoughts-on-java.org/hibernate-jooq-a-match-made-in-heaven/
SelectConditionStep> jooqQuery = ctx.select(AUTHOR.FIRSTNAME, AUTHOR.LASTNAME, BOOK.TITLE) .from(AUTHOR) .leftJoin(BOOK_AUTHOR).on(AUTHOR.ID.eq(BOOK_AUTHOR.AUTHORS_ID)) .leftJoin(BOOK).on(BOOK_AUTHOR.BOOKS_ID.eq(BOOK.ID)) .where(AUTHOR.FIRSTNAME.like("Thor%")); Query q = em.createNativeQuery(jooqQuery.getSQL()); setBindParameterValues(q, jooqQuery); private static void setBindParameterValues(javax.persistence.Query jpaQuery, org.jooq.Query jooqQuery) { Listvalues = jooqQuery.getBindValues(); for (int i = 0; i
jpaQuery.setParameter()方法本身不是类型安全的,因为它接受'Object'。
问题: jooqQuery.getBindValues()是否返回[每个参数类型安全的List?
思路:
// This stuff is type safe var jooqQuery = ctx.select(AUTHOR.FIRSTNAME, AUTHOR.LASTNAME, BOOK.TITLE) .from(AUTHOR) .leftJoin(BOOK_AUTHOR).on(AUTHOR.ID.eq(BOOK_AUTHOR.AUTHORS_ID)) .leftJoin(BOOK).on(BOOK_AUTHOR.BOOKS_ID.eq(BOOK.ID)) .where(AUTHOR.FIRSTNAME.like("Thor%")); // This stuff isn't, and there is no need Query q = em.createNativeQuery(jooqQuery.getSQL()); setBindParameterValues(q, jooqQuery);
关于:jpaQuery.setParameter的使用教程的内容,小编都给大家分享出来了。对此还有疑问的,欢迎来我们爱站技术频道网站留言。