我读"Dynamic, typesafe queries in JPA 2.0"文章,偶然发现了这个例子:连接到类名的下划线是什么意思?
EntityManager em = ...
CriteriaBuilder qb = em.getCriteriaBuilder();
CriteriaQuery<Person> c = qb.createQuery(Person.class);
Root<Person> p = c.from(Person.class);
Predicate condition = qb.gt(p.get(Person_.age), 20);
// ^^ --- this one
c.where(condition);
TypedQuery<Person> q = em.createQuery(c);
List<Person> result = q.getResultList();
我想知道,究竟是什么意思这里的底线?
由于下划线它是类名的有效部分,我不明白为什么可以在JPA中使用它。 我在我的代码中检查了一个现有的实体,当然我的班级无法解析为ClassName_
你也可以问这篇文章的作者:)这个问题 – Jayy 2012-02-21 14:51:02