毕设问题小记——HSQL查询异常

  刚刚在完成一个查询功能时遇到这样的异常:

org.springframework.orm.hibernate3.HibernateQueryException: unexpected token: * near line 1, column 8 [select * from com.sxpt.model.Usertopro where isusing=1 and tuser.uloginid='0010']; nested exception is org.hibernate.hql.ast.QuerySyntaxException: unexpected token: * near line 1, column 8 [select * from com.sxpt.model.Usertopro where isusing=1 and uloginid='0010']

  之前也遇到过这样的问题,主要原因是由于使用getHibernateTemplate()进行数据操作时,应该使用hsql语句查询,而不应该是sql,其最典型的区别就是hsql查询的应该是对象而不是表名。这里检查了一下发现from后的确是对象名没有问题。所以到网上搜了下资料,发现在hsql中不支持select *这样的操作,可以直接from......即可,修改后Junit通过。

  这样面向对象的方式操作表真心感觉不习惯,还是喜欢直接用sql和和存储过程,一句话可以搞定很多事,特别在表关联比较复杂的情况下。前几天看了下拘束ibatis似乎用着比较方便,过几天抽空学习一下。

posted @ 2013-04-06 20:43  oO脾气不坏Oo  阅读(391)  评论(0编辑  收藏  举报