数据库Sybase 用hibernate里的hql语句不能正确解析?

数据库Sybase 用hibernate里的hql语句不能正确解析?
环境:
Hibernate2
Jdbc:com.sybase.jdbc3.jdbc.SybDataSource
状态:
在hibernate或者spring的template用load/delete/update都可以正常执行唯独用有带条件的hql语句来查询时候会提示条件foreignId解析出错,没有带条件则会正常执行
----------------------------代码
Query query = session.createQuery("from UserRight where foreignId=?");
query.setString(0,"1");
List list = query.list();
assertEquals(3,list.size());
---------------------------异常信息:
net.sf.hibernate.exception.GenericJDBCException: Could not execute query
at net.sf.hibernate.exception.SQLStateConverter.handledNonSpecificException(SQLStateConverter.java:80)
at net.sf.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:69)
at net.sf.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:29)
at net.sf.hibernate.impl.SessionImpl.convert(SessionImpl.java:4131)
at net.sf.hibernate.impl.SessionImpl.find(SessionImpl.java:1557)
at net.sf.hibernate.impl.QueryImpl.list(QueryImpl.java:49)
at hibernate.HibernateDaoTestCase.testAddRightInfo(HibernateDaoTestCase.java:50)
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:585)
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 junit.framework.TestSuite.runTest(TestSuite.java:208)
at junit.framework.TestSuite.run(TestSuite.java:203)
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)
Caused by: com.sybase.jdbc3.jdbc.SybSQLException: Invalid column name 'foreignId'.

at com.sybase.jdbc3.tds.Tds.processEed(Tds.java:3069)
at com.sybase.jdbc3.tds.Tds.nextResult(Tds.java:2373)
at com.sybase.jdbc3.jdbc.ResultGetter.nextResult(ResultGetter.java:69)
at com.sybase.jdbc3.jdbc.SybStatement.nextResult(SybStatement.java:220)
at com.sybase.jdbc3.jdbc.SybStatement.nextResult(SybStatement.java:203)
at com.sybase.jdbc3.jdbc.SybStatement.queryLoop(SybStatement.java:1705)
at com.sybase.jdbc3.jdbc.SybStatement.executeQuery(SybStatement.java:1690)
at com.sybase.jdbc3.jdbc.SybPreparedStatement.executeQuery(SybPreparedStatement.java:92)
at net.sf.hibernate.impl.BatcherImpl.getResultSet(BatcherImpl.java:89)
at net.sf.hibernate.loader.Loader.getResultSet(Loader.java:880)
at net.sf.hibernate.loader.Loader.doQuery(Loader.java:273)
at net.sf.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:138)
at net.sf.hibernate.loader.Loader.doList(Loader.java:1063)
at net.sf.hibernate.loader.Loader.list(Loader.java:1054)
at net.sf.hibernate.hql.QueryTranslator.list(QueryTranslator.java:854)
at net.sf.hibernate.impl.SessionImpl.find(SessionImpl.java:1554)
... 17 more

-----------------配置文件
<class name="UserRight" table="t_userRight">
<id name="id" column="id" type="java.lang.Long">
<generator class="native"/>
</id>

<property name="state" column="state" type="java.lang.Long" />
<property name="foreignId" column="userId" type="java.lang.String" />
<property name="inputdate" column="inputDate" type="java.util.Date" />
<property name="version" column="version" type="java.lang.String" />
<property name="rightId" column="rightId"
type="java.lang.Long" />
</class>
---------------javabean getter/setter自动生成的
private java.lang.Long id;
private java.lang.Long state;
private java.lang.String foreignId;
private java.util.Date inputdate;
private java.lang.String version;
private Long rightId;
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值