sqlserver中用了user关键子出现的问题

王朝java/jsp·作者佚名  2006-04-03
窄屏简体版  字體: |||超大  

sqlserver中用了user关键子出现的问题

将tomcat+struts+hibernate+mysql的一个小项目移植到sqlserver2000中,发现出现错误.

[DEBUG] SessionImpl - opened session

[DEBUG] SessionImpl - Flushed: 0 insertions, 0 updates, 0 deletions to 0 objects

[DEBUG] SessionImpl - Flushed: 0 (re)creations, 0 updates, 0 removals to 0 collections

[DEBUG] QueryTranslator - HQL: select user from com.shjinbang.hibernate.User user

[DEBUG] QueryTranslator - SQL: select user0_.userid as x0_0_ from user user0_

[DEBUG] SessionFactoryImpl - prepared statement get: select user0_.userid as x0_0_ from user user0_

Hibernate: select user0_.userid as x0_0_ from user user0_

[DEBUG] JDBCExceptionReporter - SQL Exception <com.jnetdirect.jsql.JSQLException: 在关键字 'user' 附近有语法错误。>com.jnetdirect.jsql.JSQLException: 在关键字 'user' 附近有语法错误。

査google发现sqlserver竟然将user作为关键字,不让用户建立以user命名的表或字段,除非写成[user],而mysql没有这个情况.

将user改成employees后运行成功.当然,HQL语句中的相关user的名称也要同时修改.

总结经验,以后数据库命名要适当的复杂点,不要和关键子撞车.这个问题査了我半天时间.

 
 
 
免责声明:本文为网络用户发布,其观点仅代表作者个人观点,与本站无关,本站仅提供信息存储服务。文中陈述内容未经本站证实,其真实性、完整性、及时性本站不作任何保证或承诺,请读者仅作参考,并请自行核实相关内容。
 
 
© 2005- 王朝網路 版權所有 導航