jooq sql 生成器输出给出“?”在 WHERE 子句中的 eq()
jooq sql builder output give "?" at eq() in WHERE clause
我复制示例代码here:
整个代码块如下所示
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import org.jooq.DSLContext;
import org.jooq.SQLDialect;
import static org.jooq.impl.DSL.*;
public static String sampleSql() {
DSLContext create = DSL.using(SQLDialect.MYSQL);
String sql = create.select(field("BOOK.TITLE"), field("AUTHOR.FIRST_NAME"), field("AUTHOR.LAST_NAME"))
.from(table("BOOK"))
.join(table("AUTHOR"))
.on(field("BOOK.AUTHOR_ID").eq(field("AUTHOR.ID")))
.where(field("BOOK.PUBLISHED_IN").eq(1948))
.getSQL();
return sql;
}
sampleSql()
的输出是
select BOOK.TITLE, AUTHOR.FIRST_NAME, AUTHOR.LAST_NAME from BOOK join AUTHOR on BOOK.AUTHOR_ID = AUTHOR.ID where BOOK.PUBLISHED_IN = ?
但是为什么问号“?”,问号应该是1948。我漏掉了什么?
getSQL()
returns 带有 ?作为参数占位符。
如果要内联必须调用的参数:
getSQL(ParamType.INLINED);
请在此处找到 API 文档:https://www.jooq.org/javadoc/latest/org.jooq/org/jooq/Query.html
我复制示例代码here:
整个代码块如下所示
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import org.jooq.DSLContext;
import org.jooq.SQLDialect;
import static org.jooq.impl.DSL.*;
public static String sampleSql() {
DSLContext create = DSL.using(SQLDialect.MYSQL);
String sql = create.select(field("BOOK.TITLE"), field("AUTHOR.FIRST_NAME"), field("AUTHOR.LAST_NAME"))
.from(table("BOOK"))
.join(table("AUTHOR"))
.on(field("BOOK.AUTHOR_ID").eq(field("AUTHOR.ID")))
.where(field("BOOK.PUBLISHED_IN").eq(1948))
.getSQL();
return sql;
}
sampleSql()
的输出是
select BOOK.TITLE, AUTHOR.FIRST_NAME, AUTHOR.LAST_NAME from BOOK join AUTHOR on BOOK.AUTHOR_ID = AUTHOR.ID where BOOK.PUBLISHED_IN = ?
但是为什么问号“?”,问号应该是1948。我漏掉了什么?
getSQL()
returns 带有 ?作为参数占位符。
如果要内联必须调用的参数:
getSQL(ParamType.INLINED);
请在此处找到 API 文档:https://www.jooq.org/javadoc/latest/org.jooq/org/jooq/Query.html