我有两个对象
Person(long id, String name, PersonInfo info)
和
PersonInfo(long id, String email, String lastname, in age)
现在我尝试创建javax.persistence.Query
我尝试创建select to person where personinfo.email="somemail"
我试试
String queryString="select Person from Person p where p.PersonInfo._email='somemail'";
Query query=emf.createQuery(queryString);
List resultList = query.getResultList();
但我得到了这个例外:
java.lang.IllegalArgumentException: org.hibernate.QueryException: could not resolve property: PersonInfo of: Entities.Person [select Person from Entities.Person p where p.PersonInfo._email='somemail'] [Ljava.lang.StackTraceElement;@748e6591
我错了什么?
答案 0 :(得分:0)
以下查询字符串如何:
String queryString="select p from Person p where p.personInfo.email='somemail'";