org.hibernate.QueryException - could not resolve property
hibernate, hibernate-criteria, mapping
Solution
Try to change all `int` to `Integer` and `double` to `Double` in your mapping files `MainRecord` and `MainRecordKey`.
UPDATE Try this:
Restrictions.eq("lqk.field3", e);
Problem
I am trying to connect using Hibernate to a database. This current table has the following layout: ``` (field1, field2, field3, optional1, optional2...) ``` where field1, field2, field3 are all foreign keys, and together make up a composite key. I have the following classes: ``` @Entity @Table(name = "db_table_mainRecords") public class MainRecord implements Serializable{ @EmbeddedId private MainRecordKey lqk; @Transient private String field1; @Transient private int field2; @Transient private int field3; @Column(name = "optional_1") private double optional1; @Column(name = "optional_2") private double optional2; .... // Getters and setters for all fields, including fields within MainClassKey .... } ``` And this accompanying it: ``` @Embeddable @Table(name = "db_table_mainRecords") public class MainRecordKey implements Serializable{ @Column(name = "field1") private String field_1; @Column(name = "field_2") private int field2; @Column(name = "field_3") private int field3; } ``` I am getting the following error: org.hibernate.QueryException - could not resolve property: field3 of: path.MainRecord at org.hibernate.persister.entity.AbstractPropertyMapping.propertyException(AbstractPropertyMapping.java:67) Here is my Bo /dao code: ``` public List<MainRecord> getMainRecords(int e){ Criterion crit1 = Restrictions.eq("field3", e); ArrayList<MainRecord> list = (ArrayList<MainRecord>) dao.getMainRecords(crit1); } public List<MainRecord> getMainRecords(Criterion criteria){ if(criteria == null) return new ArrayList<MainReocrd>(); return (List<MainRecord>) getHibernateTemplate().findByCriteria(DetachedCriteria.forClass(MainRecord.class).add(criteria)); } ```