JPA 2.0
下面带有可嵌入类的实体类
@Embeddable
public class Person {
private String name;
// accessors ...
}
@Entity
public class Employee {
@Id
private Integer id;
@Embedded
private Person person;
// accessors ...
}
下面的JPA查询,
String name = "myname";
String queryStr = "select e from Employee e where e.person.name = :name";
TypedQuery<Employee> query = entityManager.createQuery(queryStr, Employee.class);
query.setParameter("name", name);
query.getResultList();
以下抛出异常,
org.hibernate.QueryException:
could not resolve property:
person.name of: Employee [select e from Employee e where e.person.name = :name]
上面的JPA查询中嵌入类的链式属性“e.person.name”有什么问题?