为什么hibernate查询会报Column 'id0_' not found

lolicn 发布于 2013/04/03 09:51
阅读 2K+
收藏 0

我是用c-jdbc 集群多个mysql数据库,插入没问题,用单个mysql连接的时候也没问题。

在hibernate查询的时候会报出: 

org.springframework.jdbc.UncategorizedSQLException: Hibernate operation: could not execute query; uncategorized SQLException for SQL [select test0_.id as id0_, test0_.name as name0_, test0_.password as password0_ from test test0_]; SQL state [null]; error code [0]; Column 'id0_' not found.; nested exception is java.sql.SQLException: Column 'id0_' not found.

at org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:83)
at org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:80)
at org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:80)
at org.springframework.orm.hibernate3.HibernateAccessor.convertJdbcAccessException(HibernateAccessor.java:424)
at org.springframework.orm.hibernate3.HibernateAccessor.convertHibernateAccessException(HibernateAccessor.java:410)
at org.springframework.orm.hibernate3.HibernateTemplate.doExecute(HibernateTemplate.java:411)
at org.springframework.orm.hibernate3.HibernateTemplate.executeWithNativeSession(HibernateTemplate.java:374)
at org.springframework.orm.hibernate3.HibernateTemplate.find(HibernateTemplate.java:912)
at org.springframework.orm.hibernate3.HibernateTemplate.find(HibernateTemplate.java:904)
at com.dao.TestDAO.findAll(TestDAO.java:106)
at com.biz.TestBiz.findAll(TestBiz.java:20)
at com.biz.TestBiz$$FastClassByCGLIB$$31e80039.invoke(<generated>)
at net.sf.cglib.proxy.MethodProxy.invoke(MethodProxy.java:191)
at org.springframework.aop.framework.Cglib2AopProxy$CglibMethodInvocation.invokeJoinpoint(Cglib2AopProxy.java:692)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:150)
at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:108)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:89)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
at org.springframework.aop.framework.Cglib2AopProxy$DynamicAdvisedInterceptor.intercept(Cglib2AopProxy.java:625)
at com.biz.TestBiz$$EnhancerByCGLIB$$2b7ec131.findAll(<generated>)

at test11.TestDB.main(TestDB.java:21)

后台生成sql语句在数据库能用

Hibernate: select test0_.id as id0_, test0_.name as name0_, test0_.password as password0_ from test test0_  

加载中
0
CrazyMole
CrazyMole
hql贴一下啊,估计就是语句不对吧
0
l
lolicn
public List findAll() {
log.debug("finding all Test instances");
try {
String queryString = "from Test";
return getHibernateTemplate().find(queryString);
} catch (RuntimeException re) {
log.error("find all failed", re);
throw re;
}
}
0
levis999
levis999
是里面的数据不对吧。
返回顶部
顶部