net.sf.hibernate.QueryException: could not resolve property: employees [where ? in elements(this.employees)]

Hibernate JIRA | Alessandro Vernet | 1 decade ago
tip
Your exception is missing from the Samebug knowledge base.
Here are the best solutions we found on the Internet.
Click on the to mark the helpful solution and get rewards for you help.
  1. 0

    I am doing a: session.filter(regions, "where ? in elements(this.employees)", employee, Hibernate.entity(Employee.class)); Where Region.hbm.xml defines employees as: <hibernate-mapping> <class name="bean.Region" table="owf_region" mutable="false"> ... <set name="employees" table="owf_employee_region"> <key column="region_id"/> <many-to-many class="bean.Employee" column="employee_id"/> </set> </class> </hibernate-mapping> I get: net.sf.hibernate.QueryException: could not resolve property: employees [where ? in elements(this.employees)] at net.sf.hibernate.persister.AbstractPropertyMapping.getPropertyType(AbstractPropertyMapping.java:33) at net.sf.hibernate.hql.PathExpressionParser.getPropertyType(PathExpressionParser.java:242) at net.sf.hibernate.hql.PathExpressionParser.token(PathExpressionParser.java:122) at net.sf.hibernate.hql.WhereParser.doPathExpression(WhereParser.java:333) at net.sf.hibernate.hql.WhereParser.doToken(WhereParser.java:365) at net.sf.hibernate.hql.WhereParser.token(WhereParser.java:250) at net.sf.hibernate.hql.ClauseParser.token(ClauseParser.java:87) at net.sf.hibernate.hql.PreprocessingParser.end(PreprocessingParser.java:142) at net.sf.hibernate.hql.ParserHelper.parse(ParserHelper.java:30) at net.sf.hibernate.hql.QueryTranslator.compile(QueryTranslator.java:148) at net.sf.hibernate.hql.QueryTranslator.compile(QueryTranslator.java:135) at net.sf.hibernate.hql.FilterTranslator.compile(FilterTranslator.java:25) at net.sf.hibernate.impl.SessionFactoryImpl.getFilter(SessionFactoryImpl.java:269) at net.sf.hibernate.impl.SessionImpl.getFilterTranslator(SessionImpl.java:3149) at net.sf.hibernate.impl.SessionImpl.filter(SessionImpl.java:3169) at net.sf.hibernate.impl.SessionImpl.filter(SessionImpl.java:3109) I expected this to work. Pretty much the same HQL works just fine when used in a session.createQuery(), e.g.: session.createQuery("from Region as r where ? in elements(r.employees)").setEntity(0, employee).list() Alex

    Hibernate JIRA | 1 decade ago | Alessandro Vernet
    net.sf.hibernate.QueryException: could not resolve property: employees [where ? in elements(this.employees)]
  2. 0

    I am doing a: session.filter(regions, "where ? in elements(this.employees)", employee, Hibernate.entity(Employee.class)); Where Region.hbm.xml defines employees as: <hibernate-mapping> <class name="bean.Region" table="owf_region" mutable="false"> ... <set name="employees" table="owf_employee_region"> <key column="region_id"/> <many-to-many class="bean.Employee" column="employee_id"/> </set> </class> </hibernate-mapping> I get: net.sf.hibernate.QueryException: could not resolve property: employees [where ? in elements(this.employees)] at net.sf.hibernate.persister.AbstractPropertyMapping.getPropertyType(AbstractPropertyMapping.java:33) at net.sf.hibernate.hql.PathExpressionParser.getPropertyType(PathExpressionParser.java:242) at net.sf.hibernate.hql.PathExpressionParser.token(PathExpressionParser.java:122) at net.sf.hibernate.hql.WhereParser.doPathExpression(WhereParser.java:333) at net.sf.hibernate.hql.WhereParser.doToken(WhereParser.java:365) at net.sf.hibernate.hql.WhereParser.token(WhereParser.java:250) at net.sf.hibernate.hql.ClauseParser.token(ClauseParser.java:87) at net.sf.hibernate.hql.PreprocessingParser.end(PreprocessingParser.java:142) at net.sf.hibernate.hql.ParserHelper.parse(ParserHelper.java:30) at net.sf.hibernate.hql.QueryTranslator.compile(QueryTranslator.java:148) at net.sf.hibernate.hql.QueryTranslator.compile(QueryTranslator.java:135) at net.sf.hibernate.hql.FilterTranslator.compile(FilterTranslator.java:25) at net.sf.hibernate.impl.SessionFactoryImpl.getFilter(SessionFactoryImpl.java:269) at net.sf.hibernate.impl.SessionImpl.getFilterTranslator(SessionImpl.java:3149) at net.sf.hibernate.impl.SessionImpl.filter(SessionImpl.java:3169) at net.sf.hibernate.impl.SessionImpl.filter(SessionImpl.java:3109) I expected this to work. Pretty much the same HQL works just fine when used in a session.createQuery(), e.g.: session.createQuery("from Region as r where ? in elements(r.employees)").setEntity(0, employee).list() Alex

    Hibernate JIRA | 1 decade ago | Alessandro Vernet
    net.sf.hibernate.QueryException: could not resolve property: employees [where ? in elements(this.employees)]

    Root Cause Analysis

    1. net.sf.hibernate.QueryException

      could not resolve property: employees [where ? in elements(this.employees)]

      at net.sf.hibernate.persister.AbstractPropertyMapping.getPropertyType()
    2. net.sf.hibernate
      SessionImpl.filter
      1. net.sf.hibernate.persister.AbstractPropertyMapping.getPropertyType(AbstractPropertyMapping.java:33)
      2. net.sf.hibernate.hql.PathExpressionParser.getPropertyType(PathExpressionParser.java:242)
      3. net.sf.hibernate.hql.PathExpressionParser.token(PathExpressionParser.java:122)
      4. net.sf.hibernate.hql.WhereParser.doPathExpression(WhereParser.java:333)
      5. net.sf.hibernate.hql.WhereParser.doToken(WhereParser.java:365)
      6. net.sf.hibernate.hql.WhereParser.token(WhereParser.java:250)
      7. net.sf.hibernate.hql.ClauseParser.token(ClauseParser.java:87)
      8. net.sf.hibernate.hql.PreprocessingParser.end(PreprocessingParser.java:142)
      9. net.sf.hibernate.hql.ParserHelper.parse(ParserHelper.java:30)
      10. net.sf.hibernate.hql.QueryTranslator.compile(QueryTranslator.java:148)
      11. net.sf.hibernate.hql.QueryTranslator.compile(QueryTranslator.java:135)
      12. net.sf.hibernate.hql.FilterTranslator.compile(FilterTranslator.java:25)
      13. net.sf.hibernate.impl.SessionFactoryImpl.getFilter(SessionFactoryImpl.java:269)
      14. net.sf.hibernate.impl.SessionImpl.getFilterTranslator(SessionImpl.java:3149)
      15. net.sf.hibernate.impl.SessionImpl.filter(SessionImpl.java:3169)
      16. net.sf.hibernate.impl.SessionImpl.filter(SessionImpl.java:3109)
      16 frames