Note that there are some explanatory texts on larger screens.

plurals
  1. POIs this approach for many-to-many mapping possible in Hibernate?
    primarykey
    data
    text
    <p>I've got three tables: <strong>item</strong>, <strong>node</strong> and <strong>item_node</strong> as linking table, which of course contains IDs of item and node. </p> <p>Can I map the linking table (<strong>item_node</strong>) in such a way that corresponding class ItemNode holds somehow references to Item and Node classes? Is there any known practice for mapping link tables in m:n relationships? </p> <p>I would imagine something like this:</p> <pre><code>&lt;class name="test.model.ItemNode" table="ITEM_NODE"&gt; &lt;composite-id name="ID" class="test.model.INCompID"&gt; &lt;key-property name="item" column="ITEM_ID" /&gt; &lt;key-property name="node" column="NODE_ID"/&gt; &lt;/composite-id&gt; &lt;/class&gt; </code></pre> <p>where <strong>INCompID</strong> is class for composite ID:</p> <pre><code>public class INCompID { private Item item; private Node node; //getters, setters and overriden //equals() and hashCode() methodes } </code></pre> <p><strong>Item</strong> and <strong>Node</strong> are already mapped and working properly by themselves. </p> <p>I know that this is not usual approach for dealing with many-to many relationships, but I'm having quite annoying problem with standard set/bag-based approach, because of the lousy lazy initialization exception, and there is no way to load these collections eagerly, because they would contain enormous amount of data (hundreds of thousands of rows in DB tables).<br> Spring AOP is used for transaction management. OpenSessionInViewFilter/Interceptor doesn't seem to be helpful for this particular problem either, so...</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload