• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

How to insert a new child record only. One to Many Relation.

 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
a).I have a Trade object which can have multiple status's. One to Many relationship



b.Now,I have inserted a new record with a status of 'New' in the parent(Trade) and child (TradeDetails) tables.
This works fine.(Code is attached below).

c.My Query is:

Now 3 days later, I want to enter a new record in the child table with the same 'parent id'
and status set to 'Verified'.

How can I insert a new record only in the child table with the status set to 'Verified'
and then another with the status set to 'Executed' for the same parent?

i.e 1 Parent - 3 Children entered on different times.

I hope I am clear in my query.

My code to create a new record in Parent and child is below.





 
author and cow tipper
Posts: 5009
1
Hibernate Spring Tomcat Server
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Load the Parent, add the child to the parent, save them both.

The use of terms "parent" and "child" always seem awkward with their different meaning from parent and child in object models.

-Cameron McKenzie

 
reply
    Bookmark Topic Watch Topic
  • New Topic