Hi,
I work on an application using JPA and oracle. I have a class with a composite primary key :
Code:
@Entity
@Table(schema = "ACCOUNT", name = "RLOGTRACE", uniqueConstraints = @UniqueConstraint(columnNames = {"LOG_DT", "LOG_USER_ID", "LOG_TYPE"}))
public class RLogtrace implements java.io.Serializable {
private RLogtraceId id;
@EmbeddedId
public RLogtraceId getId() {
return this.id;
}
............
.............
............
and
Code:
@Embeddable
public class RLogtraceId implements java.io.Serializable {
private Date logDt;
private String logUserId;
private Character logType;
public RLogtraceId() {
}
public RLogtraceId(Date logDt, String logUserId, Character logType) {
this.logDt = logDt;
this.logUserId = logUserId;
this.logType = logType;
}
@Column(name = "LOG_DT")
@Temporal(TemporalType.TIMESTAMP)
public Date getLogDt() {
return this.logDt;
}
public void setLogDt(Date logDt) {
this.logDt = logDt;
}
@Column(name = "LOG_USER_ID", length = 30)
public String getLogUserId() {
return this.logUserId;
}
public void setLogUserId(String logUserId) {
this.logUserId = logUserId;
}
@Column(name = "LOG_TYPE", length = 1)
public Character getLogType() {
return this.logType;
}
..........
}
with the table RLOGTRACE following :
Code:
CREATE TABLE "ACCOUNT"."RLOGTRACE"
(
"LOG_DT" DATE,
"LOG_USER_ID" VARCHAR2(30 BYTE),
"LOG_TYPE" CHAR(1 BYTE),
.....................
.....................
)
TABLESPACE "ACCOUNT" ;
COMMENT ON COLUMN "ACCOUNT"."R_LOGTRACE"."LOG_DT"
IS
'Date and time of the logged event.';
COMMENT ON COLUMN "ACCOUNT"."R_LOGTRACE"."LOG_USER_ID"
IS
'Related user login.';
COMMENT ON COLUMN "ACCOUNT"."R_LOGTRACE"."LOG_TYPE"
IS
'TYPE OF event logged:
- I FOR login event,
- O FOR logout event,
CREATE UNIQUE INDEX "ACCOUNT"."PK_R_LOGTRACE" ON "ACCOUNT"."R_LOGTRACE"
(
"LOG_DT", "LOG_USER_ID", "LOG_TYPE"
)
When I try to create with hibernate a RLogtrace object into the data base, I have this error :
Code:
JDBCExceptionReporter [ERROR] ORA-00001: unique constraint (ACCOUNT.PK_R_LOGTRACE) violated
2010-08-19 14:39:49 AbstractFlushingEventListener [ERROR] 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:71)
I don't see where is the error. Thank you for your answer