-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 11 posts ] 
Author Message
 Post subject: MS SQL Server generated SQL failure
PostPosted: Wed Aug 11, 2004 1:56 pm 
Newbie

Joined: Wed Aug 11, 2004 1:29 pm
Posts: 5
I am running Roller (http://www.rollerweblogger.org) on WebSphere Application Server 5.1.1 using MS SQL Server as the roller datasource. One of the roller tables is named rolleruser, but the Java object related to this table is just called user. SQL Server is complaining about the use of the name "user" as a table identifier in the Hibernate-generated SQL (see below); if I manually try to run the SQL generated by Hibernate and change user to usr, userX or any other word besides "user", the SQL runs fine. I don't want to change Roller source code and/or object names ... is there any Hibernate parameter that I can set to keep Hibernate from generating SQL using what appears to be a reserved word??

Hibernate version: 2.1

Hibernate properties:
hibernate.connection.datasource = java:comp/env/jdbc/rollerdb
hibernate.dialect = net.sf.hibernate.dialect.SQLServerDialect
#hibernate.dialect = net.sf.hibernate.dialect.MySQLDialect
#hibernate.dialect = net.sf.hibernate.dialect.PostgreSQLDialect
#hibernate.dialect = net.sf.hibernate.dialect.HSQLDialect
#hibernate.dialect = org.roller.persistence.hibernate.HSQLDialect
hibernate.show_sql=true

Mapping documents:

Code between sessionFactory.openSession() and session.close():

Full stack trace of any exception that occurs:

[8/11/04 9:35:31:151 PDT] 60c3a775 WebGroup I SRVE0180I: [Roller Weblogger] [/blogs] [Servlet.LOG]: Application 1860740989 requests WikiEngine.
[8/11/04 9:35:31:167 PDT] 60c3a775 WebGroup I SRVE0180I: [Roller Weblogger] [/blogs] [Servlet.LOG]: Application 1860740989 requests WikiEngine.
[8/11/04 9:35:31:167 PDT] 60c3a775 WebGroup I SRVE0180I: [Roller Weblogger] [/blogs] [Servlet.LOG]: Application 1860740989 requests WikiEngine.
[8/11/04 9:35:31:667 PDT] 60c3a775 PropertyMessa I org.apache.struts.util.PropertyMessageResources Initializing, config='org.apache.struts.taglib.logic.LocalStrings', returnNull=true
[8/11/04 9:36:02:371 PDT] 2129e775 SystemOut O Hibernate: select this.id as id3_, this.name as name3_, this.description as descript3_3_, this.userid as userid3_, this.defaultpageid as defaultp5_3_, this.weblogdayid as weblogda6_3_, this.enablebloggerapi as enablebl7_3_, this.bloggercatid as bloggerc8_3_, this.defaultcatid as defaultc9_3_, this.editorpage as editorpage3_, this.ignorewords as ignorew11_3_, this.allowcomments as allowco12_3_, this.emailcomments as emailco13_3_, this.emailfromaddress as emailfr14_3_, this.editortheme as editort15_3_, this.locale as locale3_, this.timezone as timezone3_, this.defaultplugins as default18_3_, this.isenabled as isenabled3_, user.id as id0_, user.username as username0_, user.passphrase as passphrase0_, user.fullname as fullname0_, user.emailaddress as emailadd5_0_, user.datecreated as datecrea6_0_, weblogcate2_.id as id1_, weblogcate2_.name as name1_, weblogcate2_.description as descript3_1_, weblogcate2_.image as image1_, weblogcate2_.websiteid as websiteid1_, weblogcate3_.id as id2_, weblogcate3_.name as name2_, weblogcate3_.description as descript3_2_, weblogcate3_.image as image2_, weblogcate3_.websiteid as websiteid2_ from website this inner join rolleruser user on this.userid=user.id left outer join weblogcategory weblogcate2_ on this.bloggercatid=weblogcate2_.id left outer join weblogcategory weblogcate3_ on this.defaultcatid=weblogcate3_.id where (user.username=? and this.isenabled=?)
[8/11/04 9:36:02:558 PDT] 2129e775 JDBCException W net.sf.hibernate.util.JDBCExceptionReporter SQL Error: 170, SQLState: HY000
[8/11/04 9:36:02:574 PDT] 2129e775 JDBCException E net.sf.hibernate.util.JDBCExceptionReporter [IBM][SQLServer JDBC Driver][SQLServer]Line 1: Incorrect syntax near '.'.
[8/11/04 9:36:02:574 PDT] 2129e775 JDBCException W net.sf.hibernate.util.JDBCExceptionReporter SQL Error: 8180, SQLState: HY000
[8/11/04 9:36:02:574 PDT] 2129e775 JDBCException E net.sf.hibernate.util.JDBCExceptionReporter [IBM][SQLServer JDBC Driver][SQLServer]Statement(s) could not be prepared.
[8/11/04 9:36:02:590 PDT] 2129e775 JDBCException W net.sf.hibernate.util.JDBCExceptionReporter SQL Error: 170, SQLState: HY000
[8/11/04 9:36:02:590 PDT] 2129e775 JDBCException E net.sf.hibernate.util.JDBCExceptionReporter [IBM][SQLServer JDBC Driver][SQLServer]Line 1: Incorrect syntax near '.'.
[8/11/04 9:36:02:590 PDT] 2129e775 JDBCException W net.sf.hibernate.util.JDBCExceptionReporter SQL Error: 8180, SQLState: HY000
[8/11/04 9:36:02:590 PDT] 2129e775 JDBCException E net.sf.hibernate.util.JDBCExceptionReporter [IBM][SQLServer JDBC Driver][SQLServer]Statement(s) could not be prepared.
[8/11/04 9:36:02:590 PDT] 2129e775 JDBCException E net.sf.hibernate.util.JDBCExceptionReporter SQLException occurred
[8/11/04 9:36:02:605 PDT] 2129e775 JDBCException E net.sf.hibernate.util.JDBCExceptionReporter TRAS0014I: The following exception was logged java.sql.SQLException: [IBM][SQLServer JDBC Driver][SQLServer]Line 1: Incorrect syntax near '.'.
at com.ibm.websphere.jdbc.base.BaseExceptions.createException(Unknown Source)
at com.ibm.websphere.jdbc.base.BaseExceptions.getException(Unknown Source)
at com.ibm.websphere.jdbc.sqlserver.tds.TDSRequest.processErrorToken(Unknown Source)
at com.ibm.websphere.jdbc.sqlserver.tds.TDSRequest.processReplyToken(Unknown Source)
at com.ibm.websphere.jdbc.sqlserver.tds.TDSRPCRequest.processReplyToken(Unknown Source)
at com.ibm.websphere.jdbc.sqlserver.tds.TDSRequest.processReply(Unknown Source)
at com.ibm.websphere.jdbc.sqlserver.SQLServerImplStatement.getNextResultType(Unknown Source)
at com.ibm.websphere.jdbc.base.BaseStatement.commonTransitionToState(Unknown Source)
at com.ibm.websphere.jdbc.base.BaseStatement.postImplExecute(Unknown Source)
at com.ibm.websphere.jdbc.base.BasePreparedStatement.postImplExecute(Unknown Source)
at com.ibm.websphere.jdbc.base.BaseStatement.commonExecute(Unknown Source)
at com.ibm.websphere.jdbc.base.BaseStatement.executeQueryInternal(Unknown Source)
at com.ibm.websphere.jdbc.base.BasePreparedStatement.executeQuery(Unknown Source)
at com.ibm.websphere.jdbcx.base.BasePreparedStatementWrapper.executeQuery(Unknown Source)
at com.ibm.ws.rsadapter.jdbc.WSJdbcPreparedStatement.executeQuery(WSJdbcPreparedStatement.java:426)
at net.sf.hibernate.impl.BatcherImpl.getResultSet(BatcherImpl.java:87)
at net.sf.hibernate.loader.Loader.getResultSet(Loader.java:800)
at net.sf.hibernate.loader.Loader.doQuery(Loader.java:189)
at net.sf.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:133)
at net.sf.hibernate.loader.Loader.doList(Loader.java:955)
at net.sf.hibernate.loader.Loader.list(Loader.java:946)
at net.sf.hibernate.loader.CriteriaLoader.list(CriteriaLoader.java:121)
at net.sf.hibernate.impl.SessionImpl.find(SessionImpl.java:3604)
at net.sf.hibernate.impl.CriteriaImpl.list(CriteriaImpl.java:238)
at org.roller.business.hibernate.HibernateUserManagerImpl.getWebsite(HibernateUserManagerImpl.java:111)
at org.roller.business.UserManagerImpl.getWebsite(UserManagerImpl.java:79)
at org.roller.presentation.RollerRequest.parseRequestParams(RollerRequest.java:278)
at org.roller.presentation.RollerRequest.init(RollerRequest.java:151)
at org.roller.presentation.RollerRequest.<init>(RollerRequest.java:108)
at org.roller.presentation.RollerRequest.getRollerRequest(RollerRequest.java:347)
at org.roller.presentation.filters.RequestFilter.doFilter(RequestFilter.java:109)
at com.ibm.ws.webcontainer.filter.FilterInstanceWrapper.doFilter(FilterInstanceWrapper.java:132)
at com.ibm.ws.webcontainer.filter.WebAppFilterChain.doFilter(WebAppFilterChain.java:71)
at org.roller.presentation.filters.CloseSessionFilter.doFilter(CloseSessionFilter.java:59)
at com.ibm.ws.webcontainer.filter.FilterInstanceWrapper.doFilter(FilterInstanceWrapper.java:132)
at com.ibm.ws.webcontainer.filter.WebAppFilterChain.doFilter(WebAppFilterChain.java:71)
at com.ibm.ws.webcontainer.webapp.WebAppRequestDispatcher.handleWebAppDispatch(WebAppRequestDispatcher.java:974)
at com.ibm.ws.webcontainer.webapp.WebAppRequestDispatcher.dispatch(WebAppRequestDispatcher.java:564)
at com.ibm.ws.webcontainer.webapp.WebAppRequestDispatcher.forward(WebAppRequestDispatcher.java:200)
at com.ibm.ws.webcontainer.srt.WebAppInvoker.doForward(WebAppInvoker.java:119)
at com.ibm.ws.webcontainer.srt.WebAppInvoker.handleInvocationHook(WebAppInvoker.java:276)
at com.ibm.ws.webcontainer.cache.invocation.CachedInvocation.handleInvocation(CachedInvocation.java:71)
at com.ibm.ws.webcontainer.cache.invocation.CacheableInvocationContext.invoke(CacheableInvocationContext.java:116)
at com.ibm.ws.webcontainer.srp.ServletRequestProcessor.dispatchByURI(ServletRequestProcessor.java:186)
at com.ibm.ws.webcontainer.oselistener.OSEListenerDispatcher.service(OSEListener.java:334)
at com.ibm.ws.webcontainer.http.HttpConnection.handleRequest(HttpConnection.java:56)
at com.ibm.ws.http.HttpConnection.readAndHandleRequest(HttpConnection.java:618)
at com.ibm.ws.http.HttpConnection.run(HttpConnection.java:443)
at com.ibm.ws.util.ThreadPool$Worker.run(ThreadPool.java:672)



Name and version of the database you are using: MS SQL Server

Debug level Hibernate log excerpt:


Top
 Profile  
 
 Post subject:
PostPosted: Wed Aug 11, 2004 1:58 pm 
Hibernate Team
Hibernate Team

Joined: Thu Dec 18, 2003 9:55 am
Posts: 1977
Location: France
'user' is a SQLServer protected keyword no?

_________________
Anthony,
Get value thanks to your skills: http://www.redhat.com/certification


Top
 Profile  
 
 Post subject:
PostPosted: Wed Aug 11, 2004 2:00 pm 
Newbie

Joined: Wed Aug 11, 2004 1:29 pm
Posts: 5
Well, I guess that's my question: is there any way to keep Hibernate from using it without me going into the Roller product and making changes to their code??


Top
 Profile  
 
 Post subject:
PostPosted: Wed Aug 11, 2004 2:02 pm 
Hibernate Team
Hibernate Team

Joined: Thu Dec 18, 2003 9:55 am
Posts: 1977
Location: France
in my opinion, you have to change the name... or the db ;(

_________________
Anthony,
Get value thanks to your skills: http://www.redhat.com/certification


Top
 Profile  
 
 Post subject:
PostPosted: Wed Aug 11, 2004 2:05 pm 
Newbie

Joined: Wed Aug 11, 2004 1:29 pm
Posts: 5
The table name is already called "rolleruser", so I am assuming that you mean that you have to rename the associated Java object, which (again, assuming here!) one would think would be pretty integral to the entire application. Is there a way to force this by just using a Hibernate mapping document without altering the core Java code?


Top
 Profile  
 
 Post subject:
PostPosted: Wed Aug 11, 2004 2:09 pm 
Hibernate Team
Hibernate Team

Joined: Thu Dec 18, 2003 9:55 am
Posts: 1977
Location: France
this is not really an hibernate problem....

_________________
Anthony,
Get value thanks to your skills: http://www.redhat.com/certification


Top
 Profile  
 
 Post subject:
PostPosted: Wed Aug 11, 2004 2:13 pm 
Newbie

Joined: Wed Aug 11, 2004 1:29 pm
Posts: 5
Thanks, anyway ... just thought it was worth asking! I was just hoping for an easy answer ...


Top
 Profile  
 
 Post subject:
PostPosted: Wed Aug 11, 2004 2:14 pm 
Hibernate Team
Hibernate Team

Joined: Thu Dec 18, 2003 9:55 am
Posts: 1977
Location: France
sorry... good luck

_________________
Anthony,
Get value thanks to your skills: http://www.redhat.com/certification


Top
 Profile  
 
 Post subject:
PostPosted: Wed Aug 11, 2004 4:30 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 3:00 pm
Posts: 1816
Location: Austin, TX
Which 2.1.x version of Hibernate are you using? I think it was 2.1.3 that changed that behaviour such that user supplied aliases in queries get replaced to avoid these types of issues.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Aug 11, 2004 4:51 pm 
Newbie

Joined: Wed Aug 11, 2004 1:29 pm
Posts: 5
I'm not exactly sure how to tell which version it is ... the hibernate2.jar came bundled with the rest of Roller, and I opened it up to look at the elements, but I really didn't see anything that looked like it might tell me which specific version I had in my hands. The only thing in the manifest was this:

Manifest-Version: 1.0
Ant-Version: Apache Ant 1.5.4
Created-By: 1.4.2_03-b02 (Sun Microsystems Inc.)

Is there something specific that I could look at inside the .jar to get the Hibernate version information?


Top
 Profile  
 
 Post subject:
PostPosted: Wed Aug 11, 2004 10:02 pm 
Hibernate Team
Hibernate Team

Joined: Mon Aug 25, 2003 9:11 pm
Posts: 4592
Location: Switzerland
Environment.VERSION

_________________
JAVA PERSISTENCE WITH HIBERNATE
http://jpwh.org
Get the book, training, and consulting for your Hibernate team.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 11 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.