org.hibernate.exception.ConstraintViolationException: could not insert:
org.hibernate.exception.ConstraintViolationException: could not insert:
报错原由于xxx.hbm.xml文件里的主键类型设置有问题;
当我们的数据库表没实用自增长的int型id。而用的varchar就可能报上面的错误,
假设,主键的生成类型设置为identity或者native的时候底层数据库会自己主动生成一个long,short或者是int,假设ID设计的是用String,数据库就无法插入的,所以假设你的数据库的ID设计的是用String型的,最好是用assigned.
比如:
<id name="userId" type="java.lang.String">
<column name="UserId" length="32" />
<generator class="assigned" />
</id>
org.hibernate.exception.ConstraintViolationException: could not insert:的更多相关文章
- Hibernate: org.hibernate.exception.SQLGrammarException: could not insert: 错误
最近在学习Java Web,今天刚接触Hibernate.学习的书籍是<轻量级Java EE企业应用实战(第3版)>.书中367页5.2.2中给予的Hibernate例子中的代码运行有以下 ...
- org.hibernate.exception.ConstraintViolationException
1.错误描述 Caused by:org.hibernate.exception.ConstraintViolationException:Could not execute JDBC batch u ...
- 在使用Hibernate save()方法的时候 报错: org.hibernate.exception.ConstraintViolationException:could not perform addBath
org.hibernate.exception.ConstraintViolationException:could not perform addBath 错误可能原因:实体属性的值与数据库字段类型 ...
- org.hibernate.exception.ConstraintViolationException: could not delete:
转自:http://fireinwind.iteye.com/blog/848515 异常描述: org.hibernate.exception.ConstraintViolationExceptio ...
- SpringBoot保存数据报错:could not execute statement; SQL [n/a]; constraint [PRIMARY];nested exception is org.hibernate.exception.ConstraintViolationException: could not execute statement
使用SpringBoot做JAVA开发时,用Repository.save();保存数据的时候遇到了报错: could not execute statement; SQL [n/a]; constr ...
- 解决org.hibernate.exception.SQLGrammarException:could not insert
今天在使用hibernate搭建项目时碰到了这个错误,找了好半天没能发现错误的原因, 上网求助了一下 发现出现这个bug的原因是因为数据表使用了数据库的关键字(保留字) 然后检查了一下,发现字段名称都 ...
- 用hibernate自动创建mysql表,添加失败org.hibernate.exception.SQLGrammarException
今天遇到了一个很坑人的问题,从昨晚一直搞到今天早上,终于发现了,先整理下: [背景]:利用hibernate自动给mysql创建一个表,然后为表里面添加一行记录,非常的简单(当然其中还涉及到sprin ...
- 严重: Could not synchronize database state with session org.hibernate.exception.DataException: Could not execute JDBC batch update
p.p1 { margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Monaco; color: #ff2600 } p.p2 { margin: 0.0px 0 ...
- HTTP Status 500 - Request processing failed; nested exception is org.hibernate.exception.GenericJDBCException: could not execute statement
1.什么操作出现:当我在项目中添加产品或者修改时,浏览器出现HTTP Status 500 - Request processing failed; nested exception is org.h ...
随机推荐
- android中RecyclerView控件实现点击事件
RecyclerView控件实现点击事件跟ListView控件不同,并没有提供类似setOnItemClickListener()这样的注册监听器方法,而是需要自己给子项具体的注册点击事件. 本文的例 ...
- 【转载】TypeScript学习笔记——var与let
var 与 let 都是TypeScript里的变量声明方式 两者非常相似,在语法不存在很大的差异,而在语义上存在很大的区别 块作用域 var有着些奇怪的作用域规则 例如 function f(ru ...
- 第七周 Word文档修订
come from:http://www.sxszjzx.com/~c20/12-2/office-gj/ 第七周 Word文档修订 教学时间 2013-4-8 教学课时 2 教案序号 12 教学目标 ...
- SpringBoot启动器详解pom.xml
Spring Boot应用启动器基本的一共有44种,具体如下: 1)spring-boot-starter 这是Spring Boot的核心启动器,包含了自动配置.日志和YAML. 2)spring- ...
- oracle 根据字段查询重复数据
1.情景展示 由上图可知,APPUSERID字段和VIRTUAL_CARDID字段存在一对多的关系,如何将重复的APPUSERID字段的数据查询出来呢? 2.原因分析 先查出重复的APPUSERI ...
- 〖Android〗屏幕触屏事件录制与回放
需求: 不管是做自动化测试的,还是传媒技术的,自动化操作Android App是一种操作需求: 自动化的操作可以节省很多的人力资源投入: 实现: Android UI界面的自动化,通常有两个方法: 1 ...
- 【Linux】条件判断eq、ne、gt、lt、ge、le
整数比较: -eq(equal) 相等 -ne(inequality) 不相等 -gt(greater than) 大于 -lt(less than) 小于 -ge(greater equal) 大于 ...
- V-rep学习笔记:Reflexxes Motion Library 2
VREP中的simRMLMoveToPosition函数可以将静态物体按照设定的运动规律移动到指定的目标位置/姿态.If your object is dynamically enabled, it ...
- logback-spring.xml配置示例
<?xml version="1.0" encoding="UTF-8"?> <configuration> <include r ...
- 如何取消Excel中的自动超链接
步骤:文件按钮→Excel选项-校对-自动更正选项→键入时自动套用格式→Internet及网络路径替换为超链接,对其不要勾选即可.