zoukankan      html  css  js  c++  java
  • 关于org.hibernate.exception.SQLGrammarException: could not insert:

             在部署hibernate项目时,出现如下错误:

    Exception in thread "main" org.hibernate.exception.SQLGrammarException: could not insert: [com.hibernate.domain.User]
    	at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:92)
    	at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:66)
    	at org.hibernate.id.insert.AbstractReturningDelegate.performInsert(AbstractReturningDelegate.java:64)
    	at org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:2327)
    	at org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:2834)
    	at org.hibernate.action.EntityIdentityInsertAction.execute(EntityIdentityInsertAction.java:71)
    	at org.hibernate.engine.ActionQueue.execute(ActionQueue.java:273)
    	at org.hibernate.event.def.AbstractSaveEventListener.performSaveOrReplicate(AbstractSaveEventListener.java:320)
    	at org.hibernate.event.def.AbstractSaveEventListener.performSave(AbstractSaveEventListener.java:203)
    	at org.hibernate.event.def.AbstractSaveEventListener.saveWithGeneratedId(AbstractSaveEventListener.java:129)
    	at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.saveWithGeneratedOrRequestedId(DefaultSaveOrUpdateEventListener.java:210)
    	at org.hibernate.event.def.DefaultSaveEventListener.saveWithGeneratedOrRequestedId(DefaultSaveEventListener.java:56)
    	at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.entityIsTransient(DefaultSaveOrUpdateEventListener.java:195)
    	at org.hibernate.event.def.DefaultSaveEventListener.performSaveOrUpdate(DefaultSaveEventListener.java:50)
    	at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.onSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:93)
    	at org.hibernate.impl.SessionImpl.fireSave(SessionImpl.java:713)
    	at org.hibernate.impl.SessionImpl.save(SessionImpl.java:701)
    	at org.hibernate.impl.SessionImpl.save(SessionImpl.java:697)
    	at com.hibernate.test.BaseTest.main(BaseTest.java:23)

              分析了下原来是在User.hbm.xml文件中我建表的时候

    <class name="com.hibernate.domain.User" table="user">

             在这里table="user",中user是关键字。这里是不能使用关键字的。

             Over!!!


     

  • 相关阅读:
    SpringBoot学习
    Matlab立体标定mat转换成Opencv的CvMat
    由lib引发的血案(opencv找不函数问题)
    C# 使用Epplus导出Excel [4]:合并指定行
    C# 使用Epplus导出Excel [3]:合并列连续相同数据
    C# 使用Epplus导出Excel [2]:导出动态列数据
    C# 使用Epplus导出Excel [1]:导出固定列数据
    C# Excel常用控件总结
    C# IsNullOrEmpty与IsNullOrWhiteSpace
    C# 读App.config配置文件[2]: .Net Core框架
  • 原文地址:https://www.cnblogs.com/oversea201405/p/3752263.html
Copyright © 2011-2022 走看看