Syntax error near hibernate--keyword ' user '

Source: Internet
Author: User
Tags log4j

Just learning hibernate, there are always problems. Now give everyone some advice, so as not to waste time, where the constant tune Ah, tune AH.

There is a syntax error near the keyword ' user '

Getgeneratedkeysdelegate.executeandextract (identitygenerator.java:73)

Log4j:warn No Appenders could is found for logger (org.hibernate.cfg.Environment).
Log4j:warn Initialize the log4j system properly.
Hibernate:insert to User-addr.dbo.user (user_name, age) VALUES (?,?)
Org.hibernate.exception.SQLGrammarException:could not insert: [Com.h1.dao.User]
At Org.hibernate.exception.SQLStateConverter.convert (sqlstateconverter.java:67)
At Org.hibernate.exception.JDBCExceptionHelper.convert (jdbcexceptionhelper.java:43)
At Org.hibernate.id.insert.AbstractReturningDelegate.performInsert (abstractreturningdelegate.java:40)
At Org.hibernate.persister.entity.AbstractEntityPersister.insert (abstractentitypersister.java:2158)
At Org.hibernate.persister.entity.AbstractEntityPersister.insert (abstractentitypersister.java:2638)
At Org.hibernate.action.EntityIdentityInsertAction.execute (entityidentityinsertaction.java:48)
At Org.hibernate.engine.ActionQueue.execute (actionqueue.java:250)
At Org.hibernate.event.def.AbstractSaveEventListener.performSaveOrReplicate (abstractsaveeventlistener.java:298)
At Org.hibernate.event.def.AbstractSaveEventListener.performSave (abstractsaveeventlistener.java:181)
At Org.hibernate.event.def.AbstractSaveEventListener.saveWithGeneratedId (abstractsaveeventlistener.java:107)
At Org.hibernate.event.def.DefaultSaveOrUpdateEventListener.saveWithGeneratedOrRequestedId ( defaultsaveorupdateeventlistener.java:187)
At Org.hibernate.event.def.DefaultSaveEventListener.saveWithGeneratedOrRequestedId ( DEFAULTSAVEEVENTLISTENER.JAVA:33)
At Org.hibernate.event.def.DefaultSaveOrUpdateEventListener.entityIsTransient ( defaultsaveorupdateeventlistener.java:172)
At Org.hibernate.event.def.DefaultSaveEventListener.performSaveOrUpdate (defaultsaveeventlistener.java:27)
At Org.hibernate.event.def.DefaultSaveOrUpdateEventListener.onSaveOrUpdate ( DEFAULTSAVEORUPDATEEVENTLISTENER.JAVA:70)
At Org.hibernate.impl.SessionImpl.fireSave (sessionimpl.java:535)
At Org.hibernate.impl.SessionImpl.save (sessionimpl.java:523)
At Org.hibernate.impl.SessionImpl.save (sessionimpl.java:519)
At Com.h1.dao.UserDAO.save (userdao.java:34)
At Com.h1.dao.UserDAO.main (userdao.java:165)
Caused by:com.microsoft.sqlserver.jdbc.SQLServerException: There is a syntax error near the keyword ' user '.
At Com.microsoft.sqlserver.jdbc.SQLServerException.makeFromDatabaseError (sqlserverexception.java:196)
At Com.microsoft.sqlserver.jdbc.SQLServerStatement.getNextResult (sqlserverstatement.java:1454)
At Com.microsoft.sqlserver.jdbc.SQLServerPreparedStatement.doExecutePreparedStatement ( sqlserverpreparedstatement.java:388)
At Com.microsoft.sqlserver.jdbc.sqlserverpreparedstatement$prepstmtexeccmd.doexecute ( sqlserverpreparedstatement.java:338)
At Com.microsoft.sqlserver.jdbc.TDSCommand.execute (iobuffer.java:4026)
At Com.microsoft.sqlserver.jdbc.SQLServerConnection.executeCommand (sqlserverconnection.java:1416)
At Com.microsoft.sqlserver.jdbc.SQLServerStatement.executeCommand (sqlserverstatement.java:185)
At Com.microsoft.sqlserver.jdbc.SQLServerStatement.executeStatement (sqlserverstatement.java:160)
At Com.microsoft.sqlserver.jdbc.SQLServerPreparedStatement.executeUpdate (sqlserverpreparedstatement.java:306)
At Org.hibernate.id.identitygenerator$getgeneratedkeysdelegate.executeandextract (IdentityGenerator.java:73)
At Org.hibernate.id.insert.AbstractReturningDelegate.performInsert (abstractreturningdelegate.java:33)

Note that your database name is not related to user, user seems to be the database of what keyword, can not use keywords. My database name is USER-ADDR, and a *.hbm.xml file uses the following notation

<class name= "com.h1.dao.Client" table= "Client" schema= "dbo" catalog= "USER-ADDR" >

...

Is the configuration file is wrong, using the keyword

Note that user can not use (will error, the keyword ' user ' near the syntax error),-also can not use (will error, '-' There is a syntax error nearby. )。


Source: http://blog.csdn.net/cocodehouse/archive/2010/06/26/5695306.aspx

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.