Are you using annotations or hbm.xml files to define your POJO ->
table metadata? Can you post the code for your persisted object? I
don't think a child object should be persisted if there's no
relationship specified.
Matt
On 4/11/07, Jong Hian Zin <[EMAIL PROTECTED]> wrote:
I disabled OpenSessionInViewFilter, and it seems to work as I
expected. Can anyone explain how this OpenSessionInViewFilter actually
affect saving?
Basically I have a form bean;
public class FormBean {
private Parent parent;
private List<Child> children;
// with getters and setters
}
In my form, I actually have something like this:
<form action="editParentChild" method="post">
<input type="hidden" name="parent.parentId" value="1">
<input type="input" name="children[0].name" value="Child 1">
<input type="input" name="children[1].name" value="Child 2">
<input type="submit" value="Submit">
</form>
In the controller's onSubmit() method, I save the parent:
FormBean bean = (FormBean) command;
Parent parent = bean.getParent();
parentManager.save(parent);
If OpenSessionInViewFilter is enabled, the children also got saved. Why?
On 4/11/07, Gary White <[EMAIL PROTECTED]> wrote:
>
> You'll probably need to post your code in order to receive help.
>
>
> ----- Original Message ----
> From: Jong Hian Zin <[EMAIL PROTECTED]>
> To: [email protected]
> Sent: Tuesday, April 10, 2007 11:57:03 PM
> Subject: Re: [appfuse-user] Child records get saved by only saving parent
> record?
>
> I have checked the hibernate mapping files, there is no relationship
> defined at all.
>
> On 4/11/07, Luke McLean <[EMAIL PROTECTED]> wrote:
> >
> > Check your mapping (I think that 1.9.4 uses XDoclet tags in the classes to
> > define the relationships), it sounds like hibernate has been set up to
> > cascade updates through a relationship between the two classes
> > (parent/child). Therefore when you update the parent it will
> automatically
> > cascade that update to the related children.
> >
> >
> > Jong Hian Zin wrote:
> > >
> > > 1.9.4
> > >
> > > On 4/11/07, Matt Raible <[EMAIL PROTECTED]> wrote:
> > >> What version of AppFuse are you using?
> > >>
> > >> On 4/10/07, Jong Hian Zin <[EMAIL PROTECTED]> wrote:
> > >> > Hi all,
> > >> >
> > >> > I did not specify any relationship between tables, but only relate
> > >> > them in the form bean. In the onSubmit() method, I only want to save
> > >> > the parent record, but all the child records get saved as well. I
> > >> > wonder how does Spring MVC know the relationship? Is it through the
> > >> > form bean?
> > >> >
> > >> > Thanks,
> > >> >
> > >> > --
> > >> > Jong Hian Zin
> > >> >
> > >> >
> ---------------------------------------------------------------------
> > >> > 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]
> > >>
> > >>
> > >
> > >
> > > --
> > > Jong Hian Zin
> > >
> > >
> ---------------------------------------------------------------------
> > > To unsubscribe, e-mail:
> [EMAIL PROTECTED]
> > > For additional commands, e-mail: [EMAIL PROTECTED]
> > >
> > >
> > >
> >
> > --
> > View this message in context:
>
http://www.nabble.com/Child-records-get-saved-by-only-saving-parent-record--tf3556909s2369.html#a9932619
> > Sent from the AppFuse - User mailing list archive at Nabble.com.
> >
> >
> ---------------------------------------------------------------------
> > To unsubscribe, e-mail:
> [EMAIL PROTECTED]
> > For additional commands, e-mail: [EMAIL PROTECTED]
> >
> >
>
>
> --
> Jong Hian Zin
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail:
> [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>
>
> ________________________________
> 8:00? 8:25? 8:40? Find a flick in no time
> with theYahoo! Search movie showtime shortcut.
--
Jong Hian Zin
---------------------------------------------------------------------
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]