aspose file tools*
The moose likes Object Relational Mapping and the fly likes hibernate:many-to-many   the association table is not getting populated Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "hibernate:many-to-many   the association table is not getting populated" Watch "hibernate:many-to-many   the association table is not getting populated" New topic
Author

hibernate:many-to-many the association table is not getting populated

Matthew Tripp
Greenhorn

Joined: Jul 15, 2009
Posts: 5
I have searched high and low, and I cannot find an answer on this that fixes my problem. I am hoping that someone else has run across this issue and can offer some guidance.

I've got 2 tables, plus an association table. When hibernate updates the first 2 tables, it should be updating the association table as well. But its not. obviously I am doing something wrong, but I can not figure out what. I'm not sure where to begin, because, as far as I can tell, I've done everything correct, and it should work.

So I'm going to do a dump of everything.

1st, the environment

hibernate 3.3.1
mysql 5.0.41

developing in eclipse (ganymede), java 1.5 on a mac

2nd, the database

I have 2 tables

test and test2


then the association table


3rd, the mappings
I have the following config and mapping files


4th here is the test and test2 classes


I have a test that creates an instance of test, and one of test2, adds the test2 to test, and saves.


hibernate spits out this in the logs


It inserts into test and test2 just fine. But for some reason it is not inserting a record in the association table (test_test2_join). What am I missing?

Thanks in advance for any help y'all can provide

trippy


I hate signatures.
Aurelian Tutuianu
Ranch Hand

Joined: May 13, 2004
Posts: 86
I am not sure about answer, I will give one which happens in EJB.
You should try to add both entities in each other relation. Like:



http://javasign.blogspot.com/
Matthew Tripp
Greenhorn

Joined: Jul 15, 2009
Posts: 5


that was it, of course.

if you only knew how long this has plagued me.

thank you, thank you, thank you.



you are in my will.
 
 
subject: hibernate:many-to-many the association table is not getting populated