• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

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

 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 86
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
I didn't like the taste of tongue and it didn't like the taste of me. I will now try this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic