Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>here is the author of question. </p> <p>After several days of research, I found the way to satisfied my require somehow.</p> <p><strong>Maping <code>Message</code></strong></p> <pre><code>&lt;class name="cn.edu.scau.librarica.dao.Message" table="message"&gt; &lt;id name="id" type="long"&gt; &lt;generator class="identity" /&gt; &lt;/id&gt; &lt;many-to-one name="ms" class="cn.edu.scau.librarica.dao.MessageSession" column="msid" not-null="true" insert="false" update="false" /&gt; &lt;property name="s" type="long" /&gt; &lt;property name="t" type="timestamp" /&gt; &lt;property name="m" type="string" /&gt; &lt;/class&gt; </code></pre> <p><strong>Mapping <code>MessageSession</code></strong></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;property name="latest" type="timestamp" /&gt; &lt;list name="msgs" table="msg_session_msgs" cascade="all"&gt; &lt;key column="msid" update="false" not-null="true"/&gt; &lt;list-index column="list_index"/&gt; &lt;one-to-many class="cn.edu.scau.librarica.dao.Message" /&gt; &lt;/list&gt; &lt;/class&gt; </code></pre> <p>Among them, the unimportant are neglected. </p> <p>Things go quite well while I can find the "one" with restrictions of "many" or inversely. just like this: </p> <pre><code> DetachedCriteria dc = DetachedCriteria.forClass(Message.class) .createCriteria("ms") .add(Restrictions.eq("msid", msid)); if (after != null) dc.add(Restrictions.gt("t", after)); if (before != null) dc.add(Restrictions.lt("t", before)); </code></pre> <p>...can search out <code>Message</code> during the specified period from specified <code>MessageSession</code>. </p> <p>So the trick is <strong>objects can't be returned by Criteria unless match them as entity.</strong></p> <p>On the underlaying database, it will be a little redundant, since <code>Message</code> can be uniquely identified by <code>(msid,list_index)</code>, so I am finding a way to match &lt;-this as the primary key for <code>Message</code>.</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.
    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