JPA查询失败,嵌入类的链接属性

时间:2013-08-22 10:28:31

标签: hibernate jpa

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”有什么问题?

0 个答案:

没有答案