facebook

How to edit parent child relationship

  1. MyEclipse IDE
  2.  > 
  3. Spring Development
Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #319067 Reply

    Greg Soulsby
    Member

    I often get a feeling of total bewilderment, confusion and helplessness. I have it now.

    I have a parent child relationship and want to edit the foreign key on the child. The CRUD scaffolding builds a child domain class that has as an attribute the parent object. Thats fine as far as it goes, but I want to change the integer value of the foreign key to another one.

    If I go in through the front end the form for the child does not have anything about the parent on it at all.

    I wont bore you with all the useless things I have tried – can you just tell me what I need to do to get an edit of the foreign key working?

    Thanks

    #319270 Reply

    jkennedy
    Member

    You would need to use the relationship methods to add or remove the child from the parent relationship.

    You can’t just change the foreign key, the JPA layer will be looking at the activity on the getter/setter methods to determine what it persists etc.

    So if you have a form and you want to break the parent child relationship with one entity, and create one with a second entity, remove the child entity from the parent relationship, and then set the relationship with a new entity.

    Hope that helps.
    Jack

Viewing 2 posts - 1 through 2 (of 2 total)
Reply To: How to edit parent child relationship

You must be logged in to post in the forum log in