Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

hibernate one-to-many mapping, inserting associated objects in collection along with parent

 
Abhishek Reddy
Ranch Hand
Posts: 259
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi everyone,

I created a one-to-many mapping between two table for example employee and emptechnologies, its like an employee knows many technologies

here are the respective mapping files
employee table



emptechnologies table



Here is the access Code..........



When i try to run this code it is giving the following error......

error
 
Abhishek Reddy
Ranch Hand
Posts: 259
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i have modified the mapping file for emptechnologies



Now, there are no errors, but failed to save the collection of childs in the database.

what is the workaround? did i miss anything?
do i need to iterate through each and every child in collection and save them separately?

 
Abhishek Reddy
Ranch Hand
Posts: 259
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Its working, i have to add cascade="all" in the employee mapping file



Actually i tried for uni-directional mapping, but it forced to have bi-directional mapping.

I would like to know the reason to opt for bi-directional mapping.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic