This seems to be the standard problem when using foreign key integrity
constraints in a database: you cannot delete a record if other records refer
to it using a foreign key. Nothing really wrong here, just the database
doing its job: making sure your data stays sane. I would recommend you keep
the integrity constraint as long as it is valid and you really do have a
relationship between the two objects.

Now on to the interesting bit: deletion. Question is when you delete object
1 that is referred to by object 2, do you want to delete object 2 as well?
If yes then the solution is in this thread: http://tinyurl.com/2sw9j4.

Mike

On 9/19/07, phamvubinh <[EMAIL PROTECTED]> wrote:
>
>
> Hi Matt,
>
> My problem is, I have just create Appfuse project (with JSF framework).
> Then
> I create 2 POJOs Obj1 and Obj2. The primary key of Obj2 is the foreign key
> of Obj1. After that, I run mvn jetty:run-war, Appfuse will test 2 POJOs
> for
> me. But when it testRemove, my database will throws an Exception:
> integrity
> constraint (...) violated - child record found. I think because there
> is  a
> constraint between the 2 POJOs, so appfuse can not remove one of them.
>
> Can you tell me how to modify the test of appfuse or disable integrity
> constraint of database server or any thing else? I tried your suggestion
> at
> http://raibledesigns.com/rd/entry/dbunit_tip_turn_off_foreign, I put the
> attribute sessionVariables="FOREIGN_KEY_CHECKS=0" to jdbc.url tag in my
> pom.xml file like this:
> <jdbc.url sessionVariables="FOREIGN_KEY_CHECKS=0">
> <![CDATA[jdbc:oracle:thin:@10.0.0.125:1521:wgdulich]]>
> </jdbc.url>
> but it didn't work
>
> thanks
> Binh
>
>
> mraible wrote:
> >
> > Use a try/catch in your managed bean and return "error" (or something
> > like that) when an exception is thrown. Then in faces-config.xml, map
> > error to a page that displays the error.
> >
> > Matt
> >
> > On 9/18/07, phamvubinh <[EMAIL PROTECTED]> wrote:
> >>
> >> So, do you have any suggestion for me. I spent one day but can not
> solve
> >> it.
> >>
> >> Thanks,
> >> Binh Pham
> >>
> >>
> >> mraible wrote:
> >> >
> >> > Unfortunately, JSF doesn't have a concept of global exceptions - at
> >> > least not one that I know of.
> >> >
> >> > Matt
> >> >
> >> > On 9/18/07, phamvubinh <[EMAIL PROTECTED]> wrote:
> >> >>
> >> >> Hi, I'm using JSF framwork and got the same error. Can you tell me
> the
> >> >> way to
> >> >> config my app.
> >> >>
> >> >> Thanks in advance.
> >> >>
> >> >> Binh Pham
> >> >>
> >> >>
> >> >>
> >> >> Matt Raible-3 wrote:
> >> >> >
> >> >> > You should be able to use the "global-exceptions" concept in
> Struts
> >> to
> >> >> > configure your app to render a particular JSP when this exception
> >> >> > happens.
> >> >> >
> >> >> > Just modify metadata/web/global-exceptions.xml.  Here's an example
> >> from
> >> >> > Equinox:
> >> >> >
> >> >> >     <global-exceptions>
> >> >> >        <exception key="error.required"
> >> >> > type="org.springframework.dao.DataAccessException"
> >> >> >                   path="/dataAccessFailure.jsp"/>
> >> >> >     </global-exceptions>
> >> >> >
> >> >> > dataAccessFailure.jsp:
> >> >> >
> >> >> > <%@ include file="/taglibs.jsp" %>
> >> >> >
> >> >> > <h3>Data Access Failure</h3>
> >> >> > <p>
> >> >> >     <c:out
> >> >> >
> >> value="${requestScope['org.apache.struts.action.EXCEPTION'].message}"/>
> >> >> > </p>
> >> >> >
> >> >> > <!--
> >> >> > <%
> >> >> > Exception ex = (Exception)
> >> >> > request.getAttribute("org.apache.struts.action.EXCEPTION");
> >> >> > ex.printStackTrace(new java.io.PrintWriter(out));
> >> >> > %>
> >> >> > -->
> >> >> >
> >> >> >  "<c:url value='/' " onclick="history.back(); return
> >> >> > false">&#171; Back
> >> >> >
> >> >> >
> >> >> > Matt
> >> >> >
> >> >> > On 7/26/05, Phil <[EMAIL PROTECTED]> wrote:
> >> >> >> Hi All,
> >> >> >>
> >> >> >> I'm using Struts, Hibernate and Spring in the middle.
> >> >> >>
> >> >> >> I have a FK integrity constraint on a table. When I try to delete
> >> the
> >> >> >> parent
> >> >> >> row, I get this error message displayed in the browser:
> >> >> >>
> >> >> >> The process did not complete. Details should follow.
> >> >> >> Warning ORA-02292: integrity constraint
> >> (ESOL_DEV.FK611A9037BCD2024F)
> >> >> >> violated - child record found
> >> >> >>
> >> >> >> The error is correct but is there a standard way or a way already
> >> >> built
> >> >> >> into
> >> >> >> appfuse to intercept this or intercept the
> >> >> >> org.springframework.dao.DataIntegrityViolationException and send
> a
> >> >> pretty
> >> >> >> error message to the browser?
> >> >> >>
> >> >> >> Coding a bunch of try catch throw stuff for my data access would
> >> seem
> >> >> to
> >> >> >> be
> >> >> >> not taking advantage of Spring.
> >> >> >>
> >> >> >> Thanks For Any Help,
> >> >> >> Phil Hersh
> >> >> >>
> >> >> >>
> >> >> >>
> >> ---------------------------------------------------------------------
> >> >> >> To unsubscribe, e-mail: [EMAIL PROTECTED]
> >> >> >> For additional commands, e-mail: [EMAIL PROTECTED]
> >> >> >>
> >> >> >>
> >> >> >
> >> >> >
> >> ---------------------------------------------------------------------
> >> >> > To unsubscribe, e-mail: [EMAIL PROTECTED]
> >> >> > For additional commands, e-mail: [EMAIL PROTECTED]
> >> >> >
> >> >> >
> >> >> >
> >> >>
> >> >> --
> >> >> View this message in context:
> >> >>
> >>
> http://www.nabble.com/-appfuse-user--Appfuse-Database-Error-Message-Handling-tf176396s2369.html#a12769905
> >> >> Sent from the AppFuse - User mailing list archive at Nabble.com.
> >> >>
> >> >>
> ---------------------------------------------------------------------
> >> >> To unsubscribe, e-mail: [EMAIL PROTECTED]
> >> >> For additional commands, e-mail: [EMAIL PROTECTED]
> >> >>
> >> >>
> >> >
> >> >
> >> > --
> >> > http://raibledesigns.com
> >> >
> >> > ---------------------------------------------------------------------
> >> > To unsubscribe, e-mail: [EMAIL PROTECTED]
> >> > For additional commands, e-mail: [EMAIL PROTECTED]
> >> >
> >> >
> >> >
> >>
> >> --
> >> View this message in context:
> >>
> http://www.nabble.com/-appfuse-user--Appfuse-Database-Error-Message-Handling-tf176396s2369.html#a12770585
> >>
> >> Sent from the AppFuse - User mailing list archive at Nabble.com.
> >>
> >> ---------------------------------------------------------------------
> >> To unsubscribe, e-mail: [EMAIL PROTECTED]
> >> For additional commands, e-mail: [EMAIL PROTECTED]
> >>
> >>
> >
> >
> > --
> > http://raibledesigns.com
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: [EMAIL PROTECTED]
> > For additional commands, e-mail: [EMAIL PROTECTED]
> >
> >
> >
>
> --
> View this message in context:
> http://www.nabble.com/-appfuse-user--Appfuse-Database-Error-Message-Handling-tf176396s2369.html#a12772021
> Sent from the AppFuse - User mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>

Reply via email to