Does the Criteria API use PreparedStatements by default?
I've looked through the manual, but couldn't find any information about criteria vs PreparedStatements.
I currently create a DetachedCriteria on every DAO call, because I need to set a parameter on it:
Code:
public List<A> loadAll(String currentName) {
DetachedCriteria loadAllCriteria = DetachedCriteria.forClass(aClass);
loadAllCriteria.add(Restrictions.eq("name", currentName));
return getHibernateTemplate().findByCriteria(loadAllCriteria);
}
aClass I know at construction time (not at compile time) so I should be able to prepare it at contstruction time (I doens't change between method invokations).
currentName changes between method invokations.
It's hard (impossible?) to write a prepared query because I don't know aClass at compile time.
Is the code above using a prepared statement?
Is there any way to reuse DetachedCriteria 's and still use a parameter?