ʹÓÃHibernate+MySql+native SQLµÄBUG,ÒÔ¼°½â¾ö°ì·¨
±¾À´ÊÇmssql+hibernate+native SQL Ó¦ÓõĺܺÍг
µ«Êǵ½ÁË°Ñmssql»»³Émysql£¬¾Í³öÁË´í(ͬÑùµÄÊý¾Ý½á¹¹ºÍÊý¾Ý)¡£
²éѯ·½·¨ÊÇ£º
String sql =
"select id XXX_ID from t_tab";
List<Map> list = session.createSQLQuery(sql)
.setResultTransformer(Transformers.ALIAS_TO_ENTITY_MAP)
.list();
´íÎóÐÅÏ¢£º
org.hibernate.exception.SQLGrammarException: could not execute query
at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:90)
at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:66)
at org.hibernate.loader.Loader.doList(Loader.java:2231)
at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2125)
at org.hibernate.loader.Loader.list(Loader.java:2120)
at org.hibernate.loader.custom.CustomLoader.list(CustomLoader.java:312)
at org.hibernate.impl.SessionImpl.listCustomQuery(SessionImpl.java:1722)
at org.hibernate.impl.AbstractSessionImpl.list(AbstractSessionImpl.java:165)
at org.hibernate.impl.SQLQueryImpl.list(SQLQueryImpl.java:175)
at com.exsun.common.dao.BasDaoImpl.findBySql(BasDaoImpl.java:173)
at com.exsun.arms.service.EmployeesalaryService.getList(EmployeesalaryService.java:32)
at com.exsun.arms.service.EmployeesalaryService$$FastClassByCGLIB$$2d81000f.invoke(<generated>)
at net.sf.cglib.proxy.MethodProxy.invoke(MethodProxy.java:149)
at org.springframework.aop.framework.Cglib2AopProxy$CglibMethodInvocation.invokeJoinpoint(Cglib2AopProxy.java:700)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:149)
at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:106)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:89)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(Reflective
Ïà¹ØÎĵµ£º
ÆäʵÄã¿ÉÒÔʹÓÃÊÂÎñ´¦Àí
±È·½ËµÔÚÒ»¸ö×Ö¶ÎÀïÃæÌí¼ÓÒ»¸öboolean µÄ×ֶε±ÄãÒª´¦Àí¸Ã×ֶεÄʱºò¾Í True ÄÄô±ðµÄÈ˶¼²»¿ÉÒÔ½øÐвÙ×÷
¡¡Èç¹ûÊÇFalse ÄÄô¾Í¿ÉÒÔ½øÐвÙ×÷¡«¡«ºÇ¿É¡«¡«ÎÒÊÇÕâÑùµÄ
¡¡¡¡²»¹ýÄã¿ÉÒÔ¿´¿´¡¡
¡¡SQLËø»úÖÆ
¡¡¡¡ÒÔÏÂÊÇÎÒÕÒµÄһЩÁÏ¡¡Èç¹ûÒªÀí½âSQLËø»úÖÆ ×îºÃ°ÑÏÂÀ´¿´ÍêŶ
ĬÈϵÄÊÂÎñ¸ôÀë¼ ......
ÎÒÃÇÒª×öµ½²»µ«»áдSQL,»¹Òª×öµ½Ð´³öÐÔÄÜÓÅÁ¼µÄSQL,ÒÔÏÂΪ±ÊÕßѧϰ¡¢ÕªÂ¼¡¢²¢»ã×ܲ¿·Ö×ÊÁÏÓë´ó¼Ò·ÖÏí£¡
£¨1£© Ñ¡Ôñ×îÓÐЧÂʵıíÃû˳Ðò(Ö»ÔÚ»ùÓÚ¹æÔòµÄÓÅ»¯Æ÷ÖÐÓÐЧ)£º
ORACLEµÄ½âÎöÆ÷°´ÕÕ´ÓÓÒµ½×óµÄ˳Ðò´¦Àífrom×Ó¾äÖеıíÃû£¬from×Ó¾äÖÐдÔÚ×îºóµÄ±í(»ù´¡±í driving table)½«±»×îÏÈ´¦Àí£ ......
½â¾ö·½·¨£º
1¡£ ¸Ä±í·¨¡£¿ÉÄÜÊÇÄãµÄÕʺŲ»ÔÊÐí´ÓÔ¶³ÌµÇ½£¬Ö»ÄÜÔÚlocalhost¡£Õâ¸öʱºòÖ»ÒªÔÚlocalhostµÄÄÇ̨µçÄÔ£¬µÇÈëmysqlºó£¬¸ü¸Ä "mysql" Êý¾Ý¿âÀïµÄ "user" ±íÀïµÄ "host" Ï´Ó"localhost"¸Ä³Æ"%"
mysql -u root -pvmwaremysql>use mysql;
mysql>update ......
²âÊÔ»·¾³£ºUbuntu 9.10 + MySQL 5.1.37-1ubuntu5
Ubuntu ÔÚÆô¶¯¹ÜÀí init.d
ÀïÃæ¹ØÓÚ MySQL µÄÃüÁîÓУº
/etc/init.d/mysql start|stop|restart|reload|force-reload|status
ÀýÈçÖØÆôMySQL·þÎñ£ºsudo /etc/init.d/mysql restart
......
ÎÊÌâÌá³ö:
ÔÚÓ¦ÓóÌÐòÖо³£ÐèÒª²éѯÊý¾Ý¡£µ±²éѯ½á¹ûÊý¾ÝÁ¿±È½Ï´óµÄʱºò£¬¼ìË÷½á¹û¡¢½çÃæÏÔʾ¶¼ÐèÒª»¨·Ñ´óÁ¿µÄʱ¼ä¡£ÎªÁ˱ÜÃâÕâ¸öÎÊÌ⣬Ӧ¸Ãÿ´ÎÖ»¼ìË÷²¿·ÖÊý¾Ý£¬Ò²¾ÍÊÇʹÓó£¼ûµÄ·ÖÒ³·½Ê½À´´¦Àí¡£·ÖÒ³µÄÎÊÌâÔÚasp.netÖкÃÏñ·Ç³£¼òµ¥£¬Ö»ÒªÔÚGridViewÖÐÆôÓ÷ÖÒ³¾Í¿ÉÒÔÁË¡£ÆôÓ÷ÖÒ³ºó£¬GridView¹ØÁªÊý¾ÝÔ´¿Ø¼þ£¬ÒÀ¾É»á¼ÓÔØ ......