注解 entity hibernate oracle 违反唯一约束条件 (SYSMAN.SYS_C0051
严重: Could not synchronize database state with session
org.hibernate.exception.ConstraintViolationException: Could not execute JDBC batch update
at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:96)
Caused by: java.sql.BatchUpdateException: ORA-00001: 违反唯一约束条件 (SYSMAN.SYS_C005168)
at oracle.jdbc.driver.DatabaseError.throwBatchUpdateException(DatabaseError.java:343)
at oracle.jdbc.driver.OraclePreparedStatement.executeBatch(OraclePreparedStatement.java:10656)
at org.hibernate.jdbc.BatchingBatcher.doExecuteBatch(BatchingBatcher.java:70)
at org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:268)
... 95 more
ENTITY java
@Entity
@Table(name="ISM_USER_BASE")
public class UserBase implements Serializable {
@Id
@GeneratedValue(strategy= GenerationType.AUTO)
请问这个该怎么设置?
oracle不支持IDENTITY,如果我将此属性去掉也会报这个错。
求解。
------解决方案--------------------------------------------------------
@Id
@GeneratedValue(generator="seq_id",strategy=GenerationType.SEQUENCE)
@SequenceGenerator(name="seq_id",sequenceName="seq_exam_item_id")
private Integer id;
------解决方案--------------------------------------------------------
答案
@Id
@GeneratedValue(strategy= GenerationType.AUTO)
改成
@Id
@GeneratedValue(strategy= GenerationType.SEQUENCE)
oracle不支持IDENTITY,使用AUTO需要其它的配置