aspose file tools*
The moose likes Object Relational Mapping and the fly likes How to insert a  new child record only. One to Many Relation. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "How to insert a  new child record only. One to Many Relation." Watch "How to insert a  new child record only. One to Many Relation." New topic
Author

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

Ajay Luthria
Greenhorn

Joined: Jul 15, 2009
Posts: 5
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.





Cameron Wallace McKenzie
author and cow tipper
Saloon Keeper

Joined: Aug 26, 2006
Posts: 4968
    
    1

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

 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to insert a new child record only. One to Many Relation.