Note that there are some explanatory texts on larger screens.

plurals
  1. POcriteria for left outer join in hibernate
    primarykey
    data
    text
    <p>I have two tables named as 'A' and 'B'. Table 'B' primary key is mapped as foreign key in 'A' table as 'b_id'(column name). In table 'A' the primary key of 'B'(b_id) may be null. i.e. In the 'B' table record doesn't exist. Table 'B' will have column 'del_flag'</p> <p>Now i need to select <strong>all rows</strong> from 'A' table(including which are having 'b_id' as null). if <strong>b_id</strong> is not null in table 'A' then i need to check the <strong>'del_flag'</strong> of table 'B' is '0'(zero or not). <strong>i.e</strong> if 'B' record exist i need to display only the records whose 'del_flag' is 0 .</p> <p>How to write the <strong>criteria</strong> for the above condition.</p> <p>I am trying with the following first two conditions. Based on my requirement it should work. </p> <pre><code> criteria.createAlias("b", "m"); -----&gt; (1) criteria.add(Restrictions.or(Restrictions.isNull("b"),Restrictions.eq("m.del_flag", "0"))); ---&gt;(2) //criteria.add(Restrictions.isNull("b")); -----&gt;(3) </code></pre> <p><strong>Let's come to the proble what i am facing.</strong></p> <p>The problem is with the '<strong>creatAlias</strong>'. I changed my requirement to select only which are having <strong>'b_id'</strong> as <strong>null</strong>. I executed only <strong>(1) (3)</strong> conditions (<strong>2 is commented</strong>). I got <strong>empty record</strong>.</p> <p>After struggling some time, i <strong>commented</strong> the condition <strong>(1)</strong> also . Now i <strong>got</strong> the result set.</p> <p>if i execute <strong>(1)</strong> and <strong>(3)</strong> i am getting not getting result set. only <strong>(3)</strong> is giving the result set. </p> <p>I am thinking that <strong>this might be the reason</strong> for my <strong>actual requirement</strong> . </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