I am using STruts. In which case, I should put the form in session. What does
that mean? I noticed that in the form there are some hidden inputs like
<form:hidden path="accountExpired"/>
Should I do the same for my personList?
thanks.
Matt Raible-3 wrote:
>
> On 2/14/07, 23455432 <[EMAIL PROTECTED]> wrote:
>>
>> I have a user object that contains many persons in a one-to-many bag
>> relationship.
>>
>> The relationship is set up as follows:
>>
>> // USER class
>> /**
>> * @hibernate.bag name="persons" lazy="false" cascade="save-update"
>> * @hibernate.collection-key column="user_id"
>> * @hibernate.collection-one-to-many class="org.appfuse.model.Person"
>> */
>> public List getPersons(){.....
>>
>>
>> private Long userId;
>>
>> /**
>> * @hibernate.property column="user_id"
>> */
>> public Long getUserId(){
>> return userId;
>>
>>
>> So the person table has a user_id column that tells me what user the
>> person
>> belongs to.
>>
>> Whenever I edit the profile of the user, the persons disappear from the
>> users person list because in the DB the user_id column for the person
>> gets
>> set to NULL. I am not sure why this is happening. I think it may be the
>> cascade options.
>
> This happens likely because you're not holding the nested persons as
> hidden fields. Since the form is in request scope, anything not in
> hidden fields gets set to null. If you're not using Struts 1.x, other
> frameworks have ways of repopulating the object before setting its
> values from request parameters. If you're are using Struts 1.x, you
> can put the form in the session, or programmatically refetch the
> object from your database and reset the persons on your user.
>
>>
>> Also, if I make changes to the user object, how can I get those changes
>> in
>> the DAO, SERVICE and WEB layer without changing whats already there...
>> using
>> appgen.
>
> The DAO, Service and Web layers don't contain a whole lot of
> fine-grained details about your User object. You should be able to
> add/remove properties and make changes in your JSP. If you use a good
> IDE and its refactoring capabilities, it should let you know when
> changes need to be made in your Java code. If nothing else, the
> existing unit tests should tell you if you broke something.
>
> Hope this helps,
>
> Matt
>
>>
>> Any direction would be appreciated.
>>
>> Thanks.
>>
>> ~rk
>> --
>> View this message in context:
>> http://www.nabble.com/Parent-object-updates-child-object-in-one-to-many-tf3229257s2369.html#a8972104
>> 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/Parent-object-updates-child-object-in-one-to-many-tf3229257s2369.html#a8972237
Sent from the AppFuse - User mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]