Search code examples
hibernategrailsdatabase-performance

Prepared Statements in Grails


Is this a prepared statement?

select
this_.col_id as col1_1_0_,
this_.col_label as col2_1_0_,
this_.col_definitionAsJSON as col4_1_0_ 
from
tbl_Rule this_ 
where
this_.class='org.rules.Table' 
and this_.col_label=?

If you remove the first "where" condition, then it is definitely a prepared statement and will be cached by the database. But what is about the first "where" condition? Does it prevent caching of this query by the database?


Solution

  • Hibernate always uses PreparedStatement for calls to the database.