Hibernate placeholder? And: And JPA, hibernate occupies jpa
A summary of hibernate placeholders.
1. What is the most common? Placeholder.
String hql = "select a from Apple a where a. color =? A. weight>? "; Query query = session. createQuery (hql); query. setParameter (0," red "); query. setParameter (1," 10 ");
Subscript starts from 0. The most common problem is the number? Number...
2. placeholder in the form of a variable name.
String hql = "select a from Apple a where. color =: pcolor. weight>: pweight "; Query query = session. createQuery (hql); query. setParameter ("pcolor", "red"); query. setParameter ("pweight", "10 ");
Does this exist? The number is incorrect. It should be a convenient method.
3. JPA method. This method is an improved version of 1 ..
String hql = "select a from Apple a where a. color =? 2 a. weight>? 5 "; Query query = session. createQuery (hql); query. setParameter (" 2 "," red "); query. setParameter (" 5 "," 10 ");
In method 1? The index can be appointed at will ..