I am using Hibernate for a few years but am not sure about the usage of Query and Criteria.
I understood, that one of Hibernate strengths are to control the field name in one place. If I have the following code:
List cats = sess.createCriteria(Cat.class)
.add( Restrictions.like("name", "Fritz%") )
.add( Restrictions.between("weight", minWeight, maxWeight) )
.list();
What if I change "name" of the Cat in the java object?
Even when using refactor replace (like in Elipse) it will not detect the element as something that needs to be changed!
If so , how do you maintain the field names in Java?
I believe type safe queries are not supported in Hibernate specific api. JPA 2 however has support for it. Read this: Dynamic, typesafe queries in JPA 2.0
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With