DEBUG ProductDaoImpl__MapperGenerated - [s0] Initializing new instance for keyspace = ks_0 and table = null
DEBUG ProductHelper__MapperGenerated - [s0] Entity Product will be mapped to ks_0.product
DEBUG ProductDaoImpl__MapperGenerated - [s0] Preparing query
`SELECT id,description,dimensions FROM ks_0.product WHERE id=:id`
for method findById(java.util.UUID)
// During application initialization:
Select selectUser = selectFrom("user").all().whereColumn("id").isEqualTo(bindMarker());
// SELECT * FROM user WHERE id=?
PreparedStatement preparedSelectUser = session.prepare(selectUser.build());
// At runtime:
session.execute(preparedSelectUser.bind(userId));
1条答案
按热度按时间5cnsuln71#
是的,Map器也准备语句。如果你观察Map器生成的日志,你可以看到它为我们准备语句。例如,当你configure logging时,你会注意到如下构造Map器代码时的情况:
可选/附加:正如本文DataStax Java Driver文档中所建议的那样,您可以并且一定要在使用
QueryBuilder
时利用PreparedStatement
,以便为经常使用的查询使用绑定语句。您仍然可以使用查询构建器并准备结果: