Thanks Cameron - I did go through the link .
Still working on the mapping examples and thanks for all the examples you have posted .
I still have a couple of questions ::
1 >
Looks like JPA does not support One to Many Unidirection Mapping .
Let me explain ::
From the DB model ::
Have a Master table and a child table
Foreign key resides in child table
There will be multiple children belonging to the same parent .
From the OO model ::
Parent class and Child class
Parent class contains a "Set" attribute which will contain the "Child" Objects
This is unidirection ( from Parent >> Child )
Now I want to ensure that when I save the parent the child gets saved too
From one of the earlier posts ::
(
https://coderanch.com/t/218539/ORM/java/one-one-unidirectional-mapping-jpa )
It looks like to make this possible there are two options ::
a >Compose the child with parent and then save the child
b >Make it a bidirectional mapping :: i.e make the child aware of the parent by providing a parent attribute in child object .
Here are my questions / doubts ::
1 >To me option A is not intuitive / doesnt flow with the way I think !
To me ( I am used to working in JDBC
) ::
" I would compose the parent with children and pass the parent to whoever takes care of the persistence - who then does the necessary insert "
Am I incorrect in my thinking ?
To me the child to contain the Parent doesnt "flow"
2 >Option B seems unnecessary increased work if I want to drive the inserts using "Parent"
3 >Assuming I go ahead with unidirection mapping ( Child containing parent object - Many to One ) ::
I have a parent and three children :; " A , B , C "
If I use this technique - then I can only save one child at a time
Other wise I will have to make a call to persist each child
Is there a way ( using unidirection mapping from child to parent )
that I can take the collection of children and in only one call ensure all children get saved along with parent .
Thanks ,
~satish
[ June 25, 2008: Message edited by: satish bodas ]
[ June 25, 2008: Message edited by: satish bodas ]