[ 
https://issues.apache.org/jira/browse/OPENJPA-168?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12481235
 ] 

Ritika Maheshwari commented on OPENJPA-168:
-------------------------------------------

Abe I do not understand how the SelectImpl.hasEagerJoin method is implemented.I 
have EmpBean and DeptBean entities as follows

 public class DeptBean2 implements Serializable {

           @Id
         private Integer no;
           @Column(name="cdname",length=80)
     private String name;
     @OneToMany(fetch=FetchType.EAGER , mappedBy="dept")
     private List<EmpBean2> emps;
     @OneToOne
     private EmpBean2 mgr;

public class EmpBean2 implements Serializable {

        @Id
         Integer empid;

        @Column(name="cesalary",columnDefinition="_double")
         Double salary;

       
        @Column(name="cename",columnDefinition="_varchar")
         String name;
        
       @Column(name="cehireDate")
         Date hireDate;

       @Column(name="ceismanager" , columnDefinition="_boolean")
         Boolean isManager;

       @Column(name="ceemp_ts")
         Timestamp emp_ts;

        @ManyToOne()
        //@ForeignKey(name="deptno")
         DeptBean2 dept;
        

Now I set the EagerFetchMode to parallel and run the following query

 OpenJPAQuery qryE = OpenJPAPersistence.cast(em.createQuery("select d from 
DeptBean2 d"));
                               qryE.setHint("openjpa.hint.OptimizeResultCount", 
new Integer(1));
                              List rsE = qryE.getResultList();
These are the selects which are generated 
42902  dwtest  TRACE  [main] openjpa.jdbc.SQL - <t 1094730048, conn 685648094> 
executing prepstmnt 808464432 SELECT t0.no, t1.empid, t1.dept_no, t1.ceemp_ts, 
t1.cehireDate, t1.ceismanager, t1.cename, t1.cesalary, t0.cdname FROM deptab2 
t0 LEFT OUTER JOIN emptab2 t1 ON t0.mgr_empid = t1.empid optimize for 1 row 
42902  dwtest  TRACE  [main] openjpa.jdbc.SQL - <t 1094730048, conn 685648094> 
[0 ms] spent
65474  dwtest  TRACE  [main] openjpa.jdbc.SQL - <t 1094730048, conn 685648094> 
executing prepstmnt 1509579258 SELECT t0.no, t1.empid, t2.no, t2.mgr_empid, 
t2.cdname, t1.ceemp_ts, t1.cehireDate, t1.ceismanager, t1.cename, t1.cesalary 
FROM deptab2 t0 INNER JOIN emptab2 t1 ON t0.no = t1.dept_no LEFT OUTER JOIN 
deptab2 t2 ON t1.dept_no = t2.no ORDER BY t0.no ASC
65474  dwtest  TRACE  [main] openjpa.jdbc.SQL - <t 1094730048, conn 685648094> 
[0 ms] spent
105963  dwtest  TRACE  [main] openjpa.jdbc.SQL - <t 1094730048, conn 685648094> 
executing prepstmnt 1725589210 SELECT t0.empid, t1.no, t1.cdname, t0.ceemp_ts, 
t0.cehireDate, t0.ceismanager, t0.cename, t0.cesalary FROM emptab2 t0 LEFT 
OUTER JOIN deptab2 t1 ON t0.dept_no = t1.no WHERE t0.dept_no = ? [params=(int) 
2]
106003  dwtest  TRACE  [main] openjpa.jdbc.SQL - <t 1094730048, conn 685648094> 
[40 ms] spent

when I am executing the 1st select I see 3 eagerKeys in the eagerKey map in the 
debugger (dept,mgr,emps) but the selectImpl.hasEagerJoin(toMany) method returns 
false.So my question is that inspite of seeing emps in the eagerKey map how 
come this method returns false.The same holds true for the second select.So 
when is the hasEagerJoin method going to return true

> sql optimize n rows query hint
> ------------------------------
>
>                 Key: OPENJPA-168
>                 URL: https://issues.apache.org/jira/browse/OPENJPA-168
>             Project: OpenJPA
>          Issue Type: New Feature
>            Reporter: David Wisneski
>         Assigned To: David Wisneski
>
> There werre various comments from Patrick, Abe and Kevin Sutter about the 
> code that I checked related to Optimize hint.  So I have gone back and 
> relooked at this and wil be making some changes.  At Kevin's suggestion I 
> will do this through a JIRA feature so that folks will have opportunity to 
> comment on this before the code is actually done and checked in.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply via email to