我有一个Embeddable类,它嵌入在一个实体中。
@Embeddable
public class RawObservation{
@NotNull
@Column(name="RAW_CODE")
private String rawCode;
//吸气剂,设置器 }
@Entity
public class TankObservation{
@Embedded
private RawObservation rawObservation;
}
当我尝试使用" rawCode"进行GET查询时参数;
Hiberanate抛出异常[1];
我怎样才能克服这个?
Caused by: org.hibernate.QueryException: could not resolve property: rawCode of: com.abc.TankObservation
at org.hibernate.persister.entity.AbstractPropertyMapping.propertyException(AbstractPropertyMapping.java:62)
at org.hibernate.persister.entity.AbstractPropertyMapping.toType(AbstractPropertyMapping.java:56)
at org.hibernate.persister.entity.AbstractEntityPersister.getSubclassPropertyTableNumber(AbstractEntityPersister.java:1770)
at org.hibernate.persister.entity.BasicEntityPropertyMapping.toColumns(BasicEntityPropertyMapping.java:46)
at org.hibernate.persister.entity.AbstractEntityPersister.toColumns(AbstractEntityPersister.java:1745)
at org.hibernate.loader.criteria.CriteriaQueryTranslator.getColumns(CriteriaQueryTranslator.java:510)
at org.hibernate.loader.criteria.CriteriaQueryTranslator.findColumns(CriteriaQueryTranslator.java:525)
at org.hibernate.criterion.SimpleExpression.toSqlString(SimpleExpression.java:66)
at org.hibernate.loader.criteria.CriteriaQueryTranslator.getWhereCondition(CriteriaQueryTranslator.java:400)
at org.hibernate.loader.criteria.CriteriaJoinWalker.<init>(CriteriaJoinWalker.java:106)
at org.hibernate.loader.criteria.CriteriaJoinWalker.<init>(CriteriaJoinWalker.java:75)
at org.hibernate.loader.criteria.CriteriaLoader.<init>(CriteriaLoader.java:80)
at org.hibernate.internal.SessionImpl.list(SessionImpl.java:1760)
at org.hibernate.internal.CriteriaImpl.list(CriteriaImpl.java:363)
at com.cdi.crud.infra.Crud.list(Crud.java:437)
at com.cdi.crud.infra.CrudService.paginate(CrudService.java:128)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:497)
at org.jboss.as.ee.component.ManagedReferenceMethodInterceptor.processInvocation(ManagedReferenceMethodInterceptor.java:52)
修改:
public Criteria configPagination(Filter<TankObservation> filter) {
if (filter.getEntity() != null) {
if(filter.getEntity().getRawObservation().getRawCode() != null){
crud().eq("rawCode", filter.getEntity().getRawObservation().getRawCode());
}
if(filter.getEntity().getRawObservation().getProductCode() != null){
crud().eq("productCode", filter.getEntity().getRawObservation().getProductCode());
}
}
return crud().getCriteria();
}
答案 0 :(得分:2)
rawCode
中没有属性TankObservation
。请用
rawObservation.rawCode
从rawCode
引用TankObservation
。