Note that there are some explanatory texts on larger screens.

plurals
  1. POhibernate how to select the many-side from an one-to-many relation
    primarykey
    data
    text
    <p>everyone. I'm brand new using Hibernate. </p> <p>So here I face a question, I have an entity like below:</p> <pre><code>&lt;class name="cn.edu.scau.librarica.dao.MessageSession" table="msg_session"&gt; &lt;id name="msid" type="long" unsaved-value="null"&gt; &lt;generator class="identity"/&gt; &lt;/id&gt; &lt;list name="msgs" cascade="all"&gt; &lt;key column="msid" update="false" unique="true" not-null="true"/&gt; &lt;list-index column="list_index"/&gt; &lt;one-to-many class="Message" /&gt; &lt;/list&gt; &lt;/class&gt; </code></pre> <p>And now what I want to achieve is:</p> <pre><code> select Message m where msid=# and m.t&lt;## and m.t&gt;### </code></pre> <p>How can I represent it with Criteria?<br> Thank you for your attentions and advices, in advance.</p> <hr> <p><strong>UPDATE</strong><br> As one of the answer guide, I have got the point that composite-element is not queryable, so I made a both-sid one-to-many map(changed are above) And now I can query but now I found another problem:<br> <strong>How can I mapped the composite-id with foreign-key</strong><br> <code>Message</code> are map like this:</p> <pre><code>&lt;class name="Message"&gt; &lt;composite-id&gt; &lt;generator class="foreign"&gt; &lt;!-- What here??? --&gt; &lt;/generator&gt; &lt;/composite-id&gt; &lt;/class&gt; </code></pre> <p>As instructed, one-to-many may use <code>set</code> rather than <code>list</code>, so I can hardly find sample meets my need(due to Message should be ordered).<br> Any advice? I am still searching for that. Thanks for help.</p>
    singulars
    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