[EJB 3.0] - Cascade Persist - integrity contraint violated - parent key
by siew_edward
Hi Seam experts,
I have a common problem which I am not able to solve despite referring to some good references. Kindly let me know what went wrong. I am using seam 2.0.2CR1 with Oracle XE. Thanks in advance.
I have 2 simple tables with a parent-child relationships:-
CREATE TABLE "TEST" ( "TEST_ID" NUMBER(18,0), "TEST_NAME" VARCHAR2(50), CONSTRAINT "TEST_PK" PRIMARY KEY ("TEST_ID") ENABLE )
|
| CREATE TABLE "TEST_ITEM" ( "TEST_ITEM_ID" NUMBER(18,0), "TEST_ITEM_NAME" VARCHAR2(50), "TEST_ID" NUMBER(18,0) NOT NULL ENABLE, CONSTRAINT "TEST_ITEM_PK" PRIMARY KEY ("TEST_ITEM_ID") ENABLE, CONSTRAINT "TEST_ITEM_CON" FOREIGN KEY ("TEST_ID") REFERENCES "TEST" ("TEST_ID") ON DELETE CASCADE ENABLE )
In the Test.java entity, I have the following declaration:-
@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "test") public Set<TestItem> getTestItems() { return this.testItems; }
|
In the TestItem.java entity, I have the following declaration:-
@ManyToOne(cascade = CascadeType.ALL, fetch = FetchType.EAGER) @JoinColumn(name = "TEST_ID", nullable = false) @NotNull public Test getTest() { return this.test; }
In the TestHome.java entity home, I have the following code:-
@Override public String persist(){ Test test = getInstance(); TestItem item = new TestItem(); item.setTestItemName("testing"); item.setTest(test); test.getTestItems().add(item); return super.persist(); }
And finally, I am getting the following common error:-
00:19:25,156 INFO [STDOUT] Hibernate: select * from ( select test0_.TEST_ID as TEST1_11_, test0_.TEST_NAME as TEST2_11_ from IMPORTSTS.TEST test0_ ) where rownum <= ? 00:19:30,343 INFO [Authenticator] authenticating demo 00:19:36,484 INFO [STDOUT] Hibernate: select IMPORTSTS.SHIPMENT_SEQ.nextval from dual 00:19:36,515 INFO [STDOUT] Hibernate: select IMPORTSTS.SHIPMENT_VARIABLE_SEQ.nextval from dual 00:19:36,546 INFO [STDOUT] Hibernate: insert into IMPORTSTS.TEST (TEST_NAME, TEST_ID) values (?, ?) 00:19:36,546 INFO [STDOUT] Hibernate: insert into IMPORTSTS.TEST_ITEM (TEST_ID, TEST_ITEM_NAME, TEST_ITEM_ID) values (?, ?, ?) 00:19:36,562 WARN [JDBCExceptionReporter] SQL Error: 2291, SQLState: 23000 00:19:36,562 ERROR [JDBCExceptionReporter] ORA-02291: integrity constraint (IMPO RTSTS.TEST_ITEM_CON) violated - parent key not found
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4145347#4145347
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4145347
18 years, 3 months
[Installation, Configuration & DEPLOYMENT] - Re: Jboss and log4j
by jaikiran
"roberto.k" wrote :
|
| For a misterious reason, JBoss logging must be declared in jboss-log4j.xml (I don't understand why I can't use log4j.xml in my war, like any other AS in the world...)
|
Since you mention jboss-log4j.xml, i believe you are using JBoss-4.2.x. In which case, you can definitely use your own log4j.xml in the WAR.
"roberto.k" wrote :
| Then, I removed log4j.xml form my ear/war and I moved appenders in jboss-log4j.xml. And... There is a problem... ONLY for my classes, a question mark appears in place of line number:
|
| [14:04:46,226 INFO] it.web.controller.security.Login.execute(?) - Inizio
| Login
|
I don't know how the %L option of log4j works. But i guess, for the line number of a java class to be outputted, you have to compile the class using the -g option. Have you tried that?
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4145343#4145343
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4145343
18 years, 3 months