java连接mysql 用hibernate怎么写查询语句

以前用的是sqlserver,现在该为mysql,数据库连接上了,但是以前写的查询报错了
——————————————————
select userinfo0_.id as id0_, userinfo0_.company_name as company2_0_, userinfo0_.user_name as user3_0_,
userinfo0_.mobile_number as mobile4_0_ from Demo.dbo.user_info userinfo0_,Demo.dbo.user_info去掉dbo就可以查询出来,请问要如何解决呢?
[code="java"]
public int queryAll() {
// TODO Auto-generated method stub
String hql="from UserInfo";
List list = getHibernateTemplate().find(hql);
[/code]
[code="java"]
org.springframework.dao.InvalidDataAccessResourceUsageException: could not execute query; SQL [select userinfo0_.id as id0_, userinfo0_.company_name as company2_0_, userinfo0_.user_name as user3_0_, userinfo0_.mobile_number as mobile4_0_ from Demo.dbo.user_info userinfo0_]; nested exception is org.hibernate.exception.SQLGrammarException: could not execute query
org.springframework.orm.hibernate3.SessionFactoryUtils.convertHibernateAccessException(SessionFactoryUtils.java:629)
org.springframework.orm.hibernate3.HibernateAccessor.convertHibernateAccessException(HibernateAccessor.java:412)
org.springframework.orm.hibernate3.HibernateTemplate.doExecute(HibernateTemplate.java:411)
org.springframework.orm.hibernate3.HibernateTemplate.executeWithNativeSession(HibernateTemplate.java:374)
org.springframework.orm.hibernate3.HibernateTemplate.find(HibernateTemplate.java:912)
org.springframework.orm.hibernate3.HibernateTemplate.find(HibernateTemplate.java:904)
com.seamoon.demo.dao.impl.UserInfoDAOImpl.queryAll(UserInfoDAOImpl.java:181)

[/code]

查看全部
love_zongming
龙西庄庄主
2013/04/30 20:09
  • it技术
  • 互联网问答
  • IT行业问题
  • 编程语言问答
  • 计算机技术
  • 点赞
  • 收藏
  • 回答
    私信
满意答案
查看全部

0个回复