• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

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

 
Matthew Tripp
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Aurelian Tutuianu
Ranch Hand
Posts: 86
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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:

 
Matthew Tripp
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic