DISQUS

DISQUS Hello! Adrian Smith's Blog is using DISQUS, a powerful comment system, to manage its comments. Learn more.

Community Page

Jump to original thread »
Author

Problem with Hibernate many-to-many association

Started by Adrian Smith · 8 months ago

This post is really a record for both myself and anyone else who ever comes across the same problem.
The Problem: Given two entities with a many-to-many association between them, the join table isn’t being populated when an association is made.
The Problem Set: Two persistent e ... Continue reading »

7 comments

  • Many many thanks for this... I was stuck on this for ages too!

    Great job
  • Hi there,

    same here, while in a different context:

    Using JPA with Hibernate populating an many-to-many Realtionship, where all Entities on both ends are already persistent. The JoinTable was empty, although no exception was thrown.

    Calling flush() befor calling a merge() did the job!

    Many thanks for this blog!
  • Excellent. Just what I needed to know. Have been sitting some hours scratching my head sore. Thanks :-)
  • We are facing the similar situation. When we create the entity, many to many association gets created but when we just try to create the association between already exisitng objects, we get no error and no association gets created. We tried it with flush before and after but of no use.

    -Shailesh
  • I've been stuck on this for 3 days now! Thank you so much for the solution! This should be mentioned in the Hibernate FAQ. I'll drop them a letter.. ;)
  • My GOD.... Thanks very much.. More than few days of reading official documentation and couldn't find a solution. Thanks again
  • Thank you! You are super!

Add New Comment

Returning? Login