Announcement Announcement Module
No announcement yet.
Updating Child entity with Parent and GrandChild references Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • Updating Child entity with Parent and GrandChild references

    Stack: RESTful JSON JQuery Spring Hibernate


    I'm using the above stack, so sending and receiving JSON between client (JQuery) and server in RESTful implementation using Spring.

    I have a simple object graph Parent -> Child -> GrandChild

    I wish to edit the child so sending json of the child to Spring controller like so

    public void editChild(Child child){...}

    Now the Child object normally will have a reference to Parent (bi-directional) and GrandChild but when submitted for edit the child object I'm submitting does not have these object included so when doing:


    I'm of course disconnecting the child from Parent and GrandChild in DB.

    The question is this, what are my options?

    I'm thinking of:

    - When I submit the child from JQuery I should include the parent and grandChild object data. But what if you have a very big object graph.

    - When the controller receives the child the method looks up the the parent and grandChild and attaches them to the child before the merge. But in this case I need to use a something like ChildDTO data transfer object that holds only the Id's of the object dependencies, seems like a lot of work.

    - Another option is emmm well this where you come in, please make me aware of a better way of doing this.

    Thanks in advance.