at net.sf.hibernate.loader.Loader.list(Loader.java:946)
at net.sf.hibernate.loader.SQLLoader.list(SQLLoader.java:92)
at net.sf.hibernate.impl.SessionImpl.findBySQL(SessionImpl.java:3797)
at net.sf.hibernate.impl.SQLQueryImpl.list(SQLQueryImpl.java:52)
at cn.com.hnkj.common.hibernate.HibernateDAOImpl$2.doInHibernate(HibernateDAOImpl.java:66)
at org.springframework.orm.hibernate.HibernateTemplate.execute(HibernateTemplate.java:150)
at org.springframework.orm.hibernate.HibernateTemplate.executeFind(HibernateTemplate.java:170)
at cn.com.hnkj.common.hibernate.HibernateDAOImpl.findSQLQuery(HibernateDAOImpl.java:5
at cn.com.hnkj.common.spring.CommonServiceImpl.findSQLQuery(CommonServiceImpl.java:29)
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:324)
at org.springframework.aop.framework.AopProxyUtils.invokeJoinpointUsingReflection(AopProxyUtils.java:59)
at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:149)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:118)
at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:191)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:138)
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:148)
at $Proxy0.findSQLQuery(Unknown Source)
at cn.com.hnkj.test.AllTests.test(AllTests.java:83)
at cn.com.hnkj.test.AllTests.suite(AllTests.java:74)
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:324)
at com.intellij.rt.execution.junit.TestRunnerUtil.getTestImpl(TestRunnerUtil.java:125)
at com.intellij.rt.execution.junit.TextTestRunner2.getTest(TextTestRunner2.java:36)
at junit.textui.TestRunner.start(TestRunner.java:171)
at com.intellij.rt.execution.junit.TextTestRunner2.startRunnerWithArgs(TextTestRunner2.java:23)
at com.intellij.rt.execution.junit2.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:97)
at com.intellij.rt.execution.junit2.JUnitStarter.main(JUnitStarter.java:31)
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:324)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:7
2004-09-22 13:14:57,971 INFO org.springframework.transaction.interceptor.TransactionInterceptor - Invoking rollback for transaction on method 'findSQLQuery' in class [cn.com.hnkj.common.spring.CommonService] due to throwable [org.springframework.jdbc.BadSqlGrammarException: Bad SQL grammar [null] in task 'HibernateAccessor'; nested exception is java.sql.SQLException: Invalid column name message_1_1_.]
Failed to invoke suite():org.springframework.jdbc.BadSqlGrammarException: Bad SQL grammar [null] in task 'HibernateAccessor'; nested exception is java.sql.SQLException: Invalid column name message_1_1_.
2004-09-22 13:14:57,991 ERROR
........................... 你的分析:
执行TestDAO.session.createSQLQuery(sql,as,c);出错了
标准的SQL语句
SELECT * FROM T_Sys_Message ms INNER JOIN T_Sys_Message_receiever mr ON mr.message_id = ms.message_id
WHERE (mr.user_id = 3) AND (DATEDIFF(Day, ms.end_time, GETDATE()) = 0)
在数据库已测试通过了,我不知道用在Hibernate中怎么对应它的格式?! "select distinct ms.message_id as message_id0_, ms.message_title as message_2_0_, ms.message_content as message_3_0_, ms.message_type as message_4_0_, ms.message_level as message_5_0_, ms.send_type as send_type0_, ms.user_id as user_id0_, ms.create_date as create_d8_0_, ms.remind as remind0_, ms.end_time as end_time0_ from T_Sys_Message as ms left join T_Sys_Message_receiever as mr on mr.message_id=mr.message_id where (DATEDIFF(Day, ms.end_time, GETDATE()) = 0) and (mr.user_id =3)"
我把它放在sql数据库里执行结果正常!!!
at net.sf.hibernate.loader.SQLLoader.list(SQLLoader.java:92)
at net.sf.hibernate.impl.SessionImpl.findBySQL(SessionImpl.java:3797)
at net.sf.hibernate.impl.SQLQueryImpl.list(SQLQueryImpl.java:52)
at cn.com.hnkj.common.hibernate.HibernateDAOImpl$2.doInHibernate(HibernateDAOImpl.java:66)
at org.springframework.orm.hibernate.HibernateTemplate.execute(HibernateTemplate.java:150)
at org.springframework.orm.hibernate.HibernateTemplate.executeFind(HibernateTemplate.java:170)
at cn.com.hnkj.common.hibernate.HibernateDAOImpl.findSQLQuery(HibernateDAOImpl.java:5
at cn.com.hnkj.common.spring.CommonServiceImpl.findSQLQuery(CommonServiceImpl.java:29)
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:324)
at org.springframework.aop.framework.AopProxyUtils.invokeJoinpointUsingReflection(AopProxyUtils.java:59)
at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:149)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:118)
at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:191)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:138)
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:148)
at $Proxy0.findSQLQuery(Unknown Source)
at cn.com.hnkj.test.AllTests.test(AllTests.java:83)
at cn.com.hnkj.test.AllTests.suite(AllTests.java:74)
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:324)
at com.intellij.rt.execution.junit.TestRunnerUtil.getTestImpl(TestRunnerUtil.java:125)
at com.intellij.rt.execution.junit.TextTestRunner2.getTest(TextTestRunner2.java:36)
at junit.textui.TestRunner.start(TestRunner.java:171)
at com.intellij.rt.execution.junit.TextTestRunner2.startRunnerWithArgs(TextTestRunner2.java:23)
at com.intellij.rt.execution.junit2.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:97)
at com.intellij.rt.execution.junit2.JUnitStarter.main(JUnitStarter.java:31)
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:324)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:7
2004-09-22 13:14:57,971 INFO org.springframework.transaction.interceptor.TransactionInterceptor - Invoking rollback for transaction on method 'findSQLQuery' in class [cn.com.hnkj.common.spring.CommonService] due to throwable [org.springframework.jdbc.BadSqlGrammarException: Bad SQL grammar [null] in task 'HibernateAccessor'; nested exception is java.sql.SQLException: Invalid column name message_1_1_.]
Failed to invoke suite():org.springframework.jdbc.BadSqlGrammarException: Bad SQL grammar [null] in task 'HibernateAccessor'; nested exception is java.sql.SQLException: Invalid column name message_1_1_.
2004-09-22 13:14:57,991 ERROR
........................... 你的分析:
执行TestDAO.session.createSQLQuery(sql,as,c);出错了
标准的SQL语句
SELECT * FROM T_Sys_Message ms INNER JOIN T_Sys_Message_receiever mr ON mr.message_id = ms.message_id
WHERE (mr.user_id = 3) AND (DATEDIFF(Day, ms.end_time, GETDATE()) = 0)
在数据库已测试通过了,我不知道用在Hibernate中怎么对应它的格式?! "select distinct ms.message_id as message_id0_, ms.message_title as message_2_0_, ms.message_content as message_3_0_, ms.message_type as message_4_0_, ms.message_level as message_5_0_, ms.send_type as send_type0_, ms.user_id as user_id0_, ms.create_date as create_d8_0_, ms.remind as remind0_, ms.end_time as end_time0_ from T_Sys_Message as ms left join T_Sys_Message_receiever as mr on mr.message_id=mr.message_id where (DATEDIFF(Day, ms.end_time, GETDATE()) = 0) and (mr.user_id =3)"
我把它放在sql数据库里执行结果正常!!!
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货