Results 1 to 2 of 2

Thread: Best practice for many-to-many hibernate relationships

  1. #1
    Join Date
    Jun 2007
    Posts
    16

    Default Best practice for many-to-many hibernate relationships

    In current project there are a lot of many-to-many relationships via a link(join) table. Not sure if these should be or not but I'm working with it for now. The thing is I'm not quite sure what the best practice is so far all the link tables I've set the associations one-to-many lazy to false. However to get to the link table from an object I'll use a join in a hibernate query. This is to avoid massive performance problems that happened with setting to many associations to false with hibernate eager loading domino effect. With our many-to-one associations we are using left join fetches in queries to load them up. This seems to perform the best with less verbose queries in small amount of performance testing I've done. Not really sure if there is a best practice for all the different associations types with spring/hibernate integration. What is the fastest way? We can't use OpenSessionInView pattern as web tier will probably be on a different machine in next iteration.

  2. #2
    Join Date
    Sep 2006
    Location
    UK
    Posts
    8,424

    Default

    Is it possible to see an example of the problem you are having and the hbm files for the mapping? I'm not quite sure what you mean when you talk about retrieving the join table, isn't this a detail of the association rather than an entity in it's own right?
    Last edited by karldmoore; Aug 30th, 2007 at 05:30 AM.
    Barracuda Networks SSL VPN Lead Developer
    http://pramatr.wordpress.com
    http://twitter.com/karldmoore
    http://www.linkedin.com/in/karldmoore
    Any postings are my own opinion, and should not be attributed to my employer or clients.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •