Hibernate错误坚决办法?

util.JDBCExceptionReporter          77  ) SQL Error: 156, SQLState: S1000
(util.JDBCExceptionReporter          78  ) 在关键字 'user' 附近有语法错误。
Exception in thread "main" org.hibernate.exception.GenericJDBCException: could not insert: [hib.com.Tuser]
 at org.hibernate.exception.SQLStateConverter.handledNonSpecificException(SQLStateConverter.java:103)
 at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:91)
 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:2108)
 at org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:2588)
 at org.hibernate.action.EntityIdentityInsertAction.execute(EntityIdentityInsertAction.java:48)
 at org.hibernate.engine.ActionQueue.execute(ActionQueue.java:248)
 at org.hibernate.event.def.AbstractSaveEventListener.performSaveOrReplicate(AbstractSaveEventListener.java:290)
 at org.hibernate.event.def.AbstractSaveEventListener.performSave(AbstractSaveEventListener.java:180)
 at org.hibernate.event.def.AbstractSaveEventListener.saveWithGeneratedId(AbstractSaveEventListener.java:108)
 at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.saveWithGeneratedOrRequestedId(DefaultSaveOrUpdateEventListener.java:186)
 at org.hibernate.event.def.DefaultSaveEventListener.saveWithGeneratedOrRequestedId(DefaultSaveEventListener.java:33)
 at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.entityIsTransient(DefaultSaveOrUpdateEventListener.java:175)
 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 hib.com.one.main(one.java:28)
Caused by: java.sql.SQLException: 在关键字 'user' 附近有语法错误。
 at net.sourceforge.jtds.jdbc.SQLDiagnostic.addDiagnostic(SQLDiagnostic.java:365)
 at net.sourceforge.jtds.jdbc.TdsCore.tdsErrorToken(TdsCore.java:2781)
 at net.sourceforge.jtds.jdbc.TdsCore.nextToken(TdsCore.java:2224)
 at net.sourceforge.jtds.jdbc.TdsCore.getMoreResults(TdsCore.java:628)
 at net.sourceforge.jtds.jdbc.JtdsStatement.processResults(JtdsStatement.java:525)
 at net.sourceforge.jtds.jdbc.JtdsStatement.executeSQL(JtdsStatement.java:487)
 at net.sourceforge.jtds.jdbc.JtdsPreparedStatement.executeUpdate(JtdsPreparedStatement.java:421)
 at org.hibernate.id.IdentityGenerator$GetGeneratedKeysDelegate.executeAndExtract(IdentityGenerator.java:73)
 at org.hibernate.id.insert.AbstractReturningDelegate.performInsert(AbstractReturningDelegate.java:33)
 ... 16 more

原因是由于用的 一些值与sql2000中的关键字段  重名引起的。
只要把如user-------》users就可以了。

你可能感兴趣的:(Hibernate错误坚决办法?)