How to get only parent without children in Hibernate and without lazy exception?
<p>How to get only parent without children in Hibernate and without lazy exception, when you trying to access chidlren filed after closing session?
<br/>I mean, a kind of pure parent obtainingm but I beed to be sure, that somebody will not obtain them with getter or will not catch a lazy exception.</p>

<pre><code>    &lt;class name="com.electronic.commerce.models.Category" table="Category"&gt;
    &lt;id name="id" type="long" access="property"&gt;
        &lt;column name="categoryId" length="20"/&gt;
        &lt;generator class="native"/&gt;
    &lt;/id&gt;
    &lt;property name="name" column="categoryName" type="string"/&gt;
    &lt;property name="parentId" column="categoryParentId" type="long"/&gt;
    &lt;bag name="children" table="Category" inverse="true" lazy="true" fetch="select"&gt;
        &lt;key&gt;
            &lt;column name="categoryParentId" not-null="true"/&gt;
        &lt;/key&gt;
        &lt;one-to-many class="com.electronic.commerce.models.Category"/&gt;
    &lt;/bag&gt;
&lt;/class&gt;
</code></pre>