hibernate报错:Column 'id' cannot be null

报错内容:

17:21:59,843  INFO org.hibernate.tool.hbm2ddl.SchemaExport:226 - Running hbm2ddl schema export

17:21:59,859 DEBUG org.hibernate.tool.hbm2ddl.SchemaExport:242 - import file not found: /import.sql

17:21:59,859  INFO org.hibernate.tool.hbm2ddl.SchemaExport:251 - exporting generated schema to database

17:21:59,859 DEBUG org.hibernate.tool.hbm2ddl.SchemaExport:377 - drop table LongMao if exists

17:21:59,859 DEBUG org.hibernate.tool.hbm2ddl.SchemaExport:362 - Unsuccessful: drop table LongMao if exists

17:21:59,859 DEBUG org.hibernate.tool.hbm2ddl.SchemaExport:363 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ‘if exists‘ at line 1

17:21:59,859 DEBUG org.hibernate.tool.hbm2ddl.SchemaExport:377 - create table LongMao (id integer generated by default as identity (start with 1), name varchar(255), primary key (id))

17:21:59,859 ERROR org.hibernate.tool.hbm2ddl.SchemaExport:348 - Unsuccessful: create table LongMao (id integer generated by default as identity (start with 1), name varchar(255), primary key (id))

17:21:59,859 ERROR org.hibernate.tool.hbm2ddl.SchemaExport:349 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ‘generated by default as identity (start with 1), name varchar(255),
primary key ‘ at line 1

17:21:59,859  INFO org.hibernate.tool.hbm2ddl.SchemaExport:268 - schema export complete

Hibernate: insert into LongMao (id, name) values (null, ?)

17:21:59,953  WARN org.hibernate.util.JDBCExceptionReporter:100 - SQL Error: 1048, SQLState: 23000

17:21:59,953 ERROR org.hibernate.util.JDBCExceptionReporter:101 - Column ‘id‘ cannot be null

----------------------------

修改为:

<!-- SQL dialect -->

<property name="dialect">org.hibernate.dialect.MySQLDialect</property>

注意:MySQL是这样拼的,第二个字母小写

建议直接去文档复制,不要再自己动手敲了

hibernate报错:Column 'id' cannot be null

时间: 2024-11-17 13:00:52

hibernate报错:Column 'id' cannot be null的相关文章

&gt;Hibernate 报错:this project is not a myeclipse hibernate project . assuming hibernate 3 cap

>Hibernate 报错:this project is not a myeclipse hibernate project . assuming hibernate 3 cap web 项目中 打开 hibernate.cfg.xml 文件时 提示:The project is not a myEclipse hibernate project. 并且:在 dbbrower中使用 hibernate reverse engineering 建立 表对应的bean 和 配置文件时:找不到可用的

tomcat启动时候报错Can&#39;t convert argument: null

一.启动报错: 为了避免导入的项目重名,我先修改了前一个项目的名称. 重新启动该项目至tomcat,报错:java.lang.IllegalArgumentException: Cant convert argum...... 一.启动报错:为了避免导入的项目重名,我先修改了前一个项目的名称.重新启动该项目至tomcat,报错:java.lang.IllegalArgumentException: Can't convert argument: null二.发现问题:因为MyEclipse在修改

【hibernate 报错】No serializer found for class org.hibernate.proxy.pojo.javassist.JavassistLazyInitializer 【get和load的区别】

报错: 1 HTTP Status 500 - Could not write content: No serializer found for class org.hibernate.proxy.pojo.javassist.JavassistLazyInitializer and no properties discovered 2 to create BeanSerializer (to avoid exception, disable SerializationFeature.FAIL_

Hibernate报错:org.hibernate.ObjectNotFoundException: No row with the given identifier exists 解决办法

报错信息: org.hibernate.event.internal.DefaultLoadEventListener onLoad INFO: HHH000327: Error performing load command : org.hibernate.ObjectNotFoundException: No row with the given identifier exists: [com.weixin.db.model.Adminusers#15] 报错分析: Hibernate的映射

hibernate报错:no currentsessioncontext configured!

使用hibernate框架时候报错:no currentsessioncontext configured! 这个错误是当我们使用getCurrentSession();时候引起的,原因是currentSession配置错误,与事务有关,当我们使用currentSession的时候需要在hibernate.cfg.xml中进行如下事务配置: 1.如果是本地事务: <property name="hibernate.current_session_context_class">

hibernate报错

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'userDao': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: priva

ACS报错INIT: Id ”S0” respawning too fast:disabled for 5 minutes

处理错误INIT: Id "S0" respawning too fast:disabled for 5 minutes安装完成后可能会报错,是因为启动进程中有一项把所有信息发送到串口,而安装在虚拟机中没有console口,故把这一项屏蔽可以解决此问题.HTTP服务无法启动和这个问题无关.        由于单用户模式被加密,所以要用系统光盘引导进入拯救模式                1.使用光盘引导,本例使用CentOS6.7                2.选择"R

微信小程序报错:id 属性值格式错误。如不能以数字开头。

出现这个报错时,相信很多人都排除过自己标签上写的id是否有以数字命名的,如果你排除了发现并没有,但是这个报错还是存在,那么我接下来分享的这个情况或者能报到你 这次我也遇到这个报错,最终找出问题所在 这里的scroll-into-view属性是scroll-view组件中的,这里涉及到锚点知识,根据下面文档的提示,toView值是不能以数字开头的,所以当时顺其自然就想到用‘#’符号作为初始值,没想到还是出现问题,虽然这个问题不影响程序运行,但是说明这里不仅不能使用数字开头,也不能使用符号(试过其他

Hibernate报错org.hibernate.MappingException: Unknown entity: 。。。。

这是因为Hibernate 4.x和5.x中的ServiceRegistry写法不同造成的Hibernate 4.x  //1.创建一个SessionFactory对象  SessionFactory sessionFactory=null;  //2.创建一个configuration对象,必须要根据你基本配置信息和映射关系  Configuration config=new Configuration().configure();  //3.要创建session对象  Session ses