Blog信息 |
blog名称:小鸟吹烟 日志总数:157 评论数量:424 留言数量:-1 访问次数:1252695 建立时间:2006年10月23日 |

| |
[Hibernate 专区]hibernate报错 心得体会, 软件技术
tone 发表于 2007/1/30 18:01:15 |
List jobCri= session.createCriteria(JobTransportList.class) .setProjection(
Projections.distinct(
Property.forName (JobTransportList._OrderID)))
.add(
Restrictions.and(
Property.forName(JobTransportList._OrderID).isNotEmpty(), Property.forName(JobTransportList._OrderID).isNotNull())
) .list();
因为查询语句中没有使用到OrderID,所以如果使用到isNotEmpty,isNotNull
就会报如下错误,改成
.add(Restrictions.and(Property.forName(JobTransportList._OrderID).ne(new BigDecimal(0)), Property.forName(JobTransportList._OrderID).isNotNull())) 即没此问题了
org.hibernate.MappingException: Property path [pglms.j2ee.domain.tms.JobTransportList.OrderID] does not reference a collection at org.hibernate.criterion.AbstractEmptinessExpression.getQueryableCollection(AbstractEmptinessExpression.java:61) at org.hibernate.criterion.AbstractEmptinessExpression.toSqlString(AbstractEmptinessExpression.java:40) at org.hibernate.criterion.LogicalExpression.toSqlString(LogicalExpression.java:39) at org.hibernate.loader.criteria.CriteriaQueryTranslator.getWhereCondition(CriteriaQueryTranslator.java:333) at org.hibernate.loader.criteria.CriteriaJoinWalker.<init>(CriteriaJoinWalker.java:71) at org.hibernate.loader.criteria.CriteriaLoader.<init>(CriteriaLoader.java:67) at org.hibernate.impl.SessionImpl.list(SessionImpl.java:1532) at org.hibernate.impl.CriteriaImpl.list(CriteriaImpl.java:283) at pglms.j2ee.service.tms.CalControlCostTest.testJob(CalControlCostTest.java:36) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) at junit.framework.TestCase.runTest(TestCase.java:154) at junit.framework.TestCase.runBare(TestCase.java:127) at junit.framework.TestResult$1.protect(TestResult.java:106) at junit.framework.TestResult.runProtected(TestResult.java:124) at junit.framework.TestResult.run(TestResult.java:109) at junit.framework.TestCase.run(TestCase.java:118) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:478) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:344) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196)
|
|
|