I am using Spring Hibernate
How to Use restrictions like following in DAO
Criteria criteria = getSession().createCriteria(Inventory.class); Criterion itemCodeCriterion = Restrictions.eq("inventoryItem.itemCode",itemCode); Criterion itemDescriptionCriterion = Restrictions.like("inventoryItem.itemDescription", itemDescription, MatchMode.ANYWHERE); criteria.add(itemCodeCriterion); criteria.add(itemDescriptionCriterion); return criteria.list();
The Inventory Model has the following definition(Inventory.Java)
private long id; private InventoryItem inventoryItem; private StoreHouse storeHouse; private Organization organization;
and the InventoryItem(Inventoryitem.java) has the following
private long id; private InventoryItemGroup inventoryItemGroup; private String itemCode; private String itemDescription; private String itemSpecification;
when i ran the Restriction i am getting the error
org.hibernate.QueryException: could not resolve property: inventoryItem.itemCode of: com.realty.model.Inventory at rg.hibernate.persister.entity.AbstractPropertyMapping.propertyException(AbstractPropertyMapping.java:81) at org.hibernate.persister.entity.AbstractPropertyMapping.toColumns(AbstractPropertyMapping.java:96) at
|