Win a copy of Real-World Software Development: A Project-Driven Guide to Fundamentals in Java this week in the Agile and Other Processes forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Liutauras Vilda
  • Knute Snortum
  • Bear Bibeault
Sheriffs:
  • Devaka Cooray
  • Jeanne Boyarsky
  • Junilu Lacar
Saloon Keepers:
  • Ron McLeod
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
  • salvin francis
Bartenders:
  • Tim Holloway
  • Piet Souris
  • Frits Walraven

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

 
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
 
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.
 
I think I'll just lie down here for a second. And ponder this tiny ad:
Java file APIs (DOC, XLS, PDF, and many more)
https://products.aspose.com/total/java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!