no, you do not need the mappings to use the criteria.
well, you shouldn't need the mapping to use the criteria,
as the criteria works on properties and the properties could
be translatend in hql without worring about mapping:
you could build a criteria with something like cat.age = 'twenty', where is a numeric type, and the error shows during the qery execution, not during the translation of the criteria to the query. In other world, the criteria will build the hql neverthless, without checking the model.
with the query log you could see that the query is correctly built, and then the classcastexception raised during the execution
so you will need the mapping only once, in hibernate, or using custom solution, without losing the powerful criteria api.
In theory one could just build the query using the criterion, and pass the query to any ejb3 EntityManager
(the problem is that hibernate itself doesn't scale, and we're looking for alternative, but the criteria api is just too powerful to be left behind)
|