2) IMAGE TABLE ===== CREATE TABLE "DB2INST1"."IMAGE" ( "IMAGE_ID" BIGINT NOT NULL GENERATED ALWAYS AS IDENTITY ( START WITH +1 INCREMENT BY +1 MINVALUE +1 MAXVALUE +9223372036854775807 NO CYCLE NO CACHE NO ORDER ) , "NAME" VARCHAR(80) NOT NULL , "PROJECT_ID" BIGINT NOT NULL)
ALTER TABLE "DB2INST1"."IMAGE" ADD PRIMARY KEY ("IMAGE_ID");
ALTER TABLE "DB2INST1"."IMAGE" ADD CONSTRAINT "SQL070320001132270" FOREIGN KEY ("PROJECT_ID") REFERENCES "DB2INST1"."PROJECTS" ("PROJECT_ID") ON DELETE CASCADE ON UPDATE NO ACTION ENFORCED ENABLE QUERY OPTIMIZATION;
I am using Spring-Hibernate combination in my J2EE application. In individual DAO classes for all these tables I am calling either Save() or update() method, depends on the scenario like
//For save first time
//For update object
Not everytime but sometime I get following error when ever I am saving all these objects in database
[3/28/07 9:20:42:099 PDT] 6d3b824c AbstractFlush E org.hibernate.event.def.AbstractFlushingEventListener Could not synchronize database state with session[3/28/07 9:20:42:100 PDT] 6d3b824c AbstractFlush E org.hibernate.event.def.AbstractFlushingEventListener TRAS0014I: The following exception was logged org.hibernate.exception.ConstraintViolationException: could not insert: [com.ed2.model.Palette]at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:63) at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43) .... ... .. ... ... .. Caused by: com.ibm.websphere.ce.cm.DuplicateKeyException: One or more values in the INSERT statement, UPDATE statement, or foreign key update caused by a DELETE statement are not valid because the primary key, unique constraint or unique index identified by "1" constrains table "DB2INST1.PALETTES" from having duplicate rows for those columns. ... ... ... org.hibernate.exception.ConstraintViolationException: could not insert: com.ed2.model.Palette
I am printing value of Palette_ID just before calling save method and it shows as null, as it should be, as this is a new obejct which I want to save in database.
I am not sure what is going wrong and why I am getting this error. I would like to know if you have any solution for this problem.
Please let me know if you need any further info. about these 4 tables or mappings.
Thanks in advance!
Just like you, struggeling to get the right solutions!<br /> <br />Sun Certified Java Programmer 1.5<br /> <br />Target - SCWCD
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to
run our stuff on 16 servers instead of 3.