标签:rate date cat oracle主键 ror stand bsp values strategy
Hibernate: insert into test1.WarnWeather (WAREA, wdate, WDAYS, WINFO, WTYPE, WNO) values (?, ?, ?, ?, ?, ?)
Hibernate: select weathers0_.WNO as WNO1_0_, weathers0_.WAREA as WAREA2_0_, weathers0_.wdate as wdate3_0_, weathers0_.WDAYS as WDAYS4_0_, weathers0_.WINFO as WINFO5_0_, weathers0_.WTYPE as WTYPE6_0_ from test1.WarnWeather weathers0_
Hibernate: insert into test1.WarnWeather (WAREA, wdate, WDAYS, WINFO, WTYPE, WNO) values (?, ?, ?, ?, ?, ?)
ERROR SqlExceptionHelper ORA-00001: 违反唯一约束条件 (TEST1.SYS_C0011549)
ERROR ExceptionMapperStandardImpl HHH000346: Error during managed flush [org.hibernate.exception.ConstraintViolationException: could not execute statement]
异常问题:
客户端只能插入一条数据,当插入第二条数据时出现异常 ERROR SqlExceptionHelper ORA-00001: 违反唯一约束条件 (TEST1.SYS_C0011549)
原因:在实体类中没有配置Oracle的id主键导致Oracle主键的冲突
解决方案:在实体类中添加注解的序列
//@GeneratedValue中generator里面的值对应@SequenceGenerator中name里面的值(可以随便定义但一定要相同),
//sequenceName是创建的sequence名字(对应数据库中创建的序列名),allocationSize表示序列自增长的大小为1
@GeneratedValue(strategy = GenerationType.SEQUENCE, generator="seq")
@SequenceGenerator(name="seq", sequenceName="SEQ_WEATHER",allocationSize = 1)
标签:rate date cat oracle主键 ror stand bsp values strategy
原文地址:http://www.cnblogs.com/xuanwang/p/6508769.html