File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/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 Android Security Essentials Live Lessons this week in the Android 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.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: hibernate one-to-many mapping, inserting associated objects in collection along with parent
 
Similar Threads
Hibernate for Teradata
Hibernate Repeated column mapping problem
Hibernate - multiple collection with restrictions mapping problem
@PrimaryKeyJoinColumn: no insertable and no updatable
Error Creating SessionFactory