aspose file tools*
The moose likes Object Relational Mapping and the fly likes hibernate one-to-many mapping, inserting associated objects in collection along with parent Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "hibernate one-to-many mapping, inserting associated objects in collection along with parent" Watch "hibernate one-to-many mapping, inserting associated objects in collection along with parent" New topic
Author

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

Abhishek Reddy
Ranch Hand

Joined: Mar 28, 2006
Posts: 259
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
Abhishek Reddy
Ranch Hand

Joined: Mar 28, 2006
Posts: 259
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

Joined: Mar 28, 2006
Posts: 259
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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: hibernate one-to-many mapping, inserting associated objects in collection along with parent
 
Similar Threads
Hibernate - multiple collection with restrictions mapping problem
Error Creating SessionFactory
Hibernate Repeated column mapping problem
@PrimaryKeyJoinColumn: no insertable and no updatable
Hibernate for Teradata