У меня есть класс Item и Category
Class Item
{
private long ItemId;
private String ItemName;
private String ItemDescription;
private String ItemWebSite;
private String Condition;
private long Price;
private String Brand;
private String AttributeDescription;
private Category ProductCategory;
private Set <Picture> Pictures= new HashSet <Picture>();
//getters and setters
}
Class Category
{
private long CategoryId;
private String CategoryName;
private Category ParentCategory;
private Set <Category> SubCategory=new HashSet <Category> ();
private Set <Attribute> AllAttributes= new HashSet <Attribute>();
//getters and setters
}
Но когда я делаю следующий запрос:
long id=841;
Criteria crit =session.createCriteria(Item.class).add(Restrictions.eq("ProductCategory",id));
Я получаю эту ошибку:
Caused by: org.hibernate.PropertyAccessException: IllegalArgumentException occurred calling getter of com.BiddingSystem.Models.Category.CategoryId
at org.hibernate.property.BasicPropertyAccessor$BasicGetter.get(BasicPropertyAccessor.java:198)
at org.hibernate.tuple.entity.AbstractEntityTuplizer.getIdentifier(AbstractEntityTuplizer.java:230)
at org.hibernate.persister.entity.AbstractEntityPersister.getIdentifier(AbstractEntityPersister.java:3852)
at org.hibernate.persister.entity.AbstractEntityPersister.isTransient(AbstractEntityPersister.java:3560)
at org.hibernate.engine.ForeignKeys.isTransient(ForeignKeys.java:204)
at org.hibernate.engine.ForeignKeys.getEntityIdentifierIfNotUnsaved(ForeignKeys.java:243)
at org.hibernate.type.EntityType.getIdentifier(EntityType.java:449)
at org.hibernate.type.ManyToOneType.nullSafeSet(ManyToOneType.java:141)
at org.hibernate.loader.Loader.bindPositionalParameters(Loader.java:1769)
at org.hibernate.loader.Loader.bindParameterValues(Loader.java:1740)
at org.hibernate.loader.Loader.prepareQueryStatement(Loader.java:1612)
at org.hibernate.loader.Loader.doQuery(Loader.java:717)
at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:270)
at org.hibernate.loader.Loader.doList(Loader.java:2294)
at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2172)
at org.hibernate.loader.Loader.list(Loader.java:2167)
at org.hibernate.loader.criteria.CriteriaLoader.list(CriteriaLoader.java:119)
at org.hibernate.impl.SessionImpl.list(SessionImpl.java:1706)
at org.hibernate.impl.CriteriaImpl.list(CriteriaImpl.java:347)
at com.BiddingSystem.server.ServiceImpl.UpdateCategory(ServiceImpl.java:799)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at net.sf.gilead.gwt.PersistentRemoteService.processCall(PersistentRemoteService.java:174)
... 21 more