Pages

Thursday, November 12, 2009

New features of the EJB Datatcontrol, Query panel and Range size

With Patch Set 1 of JDeveloper 11G R1 Oracle improved the ADF EJB Datacontrol with two important features. We can now use this EJB Datacontrol in a Querypanel, this makes searching with EJB's a lot easier and the second big improvement is the range size option, so you don't get all the rows in one time, this can improve the performance of your ADF application and will generate less network traffic.
With JDeveloper you can generate an EJB datacontol on an EJB session bean and this Datacontol can be used in ADF. In this blog entry I will show you what the new features are and how you can do it yourself.

First we start with an entity, this is a normal entity on the country table in the HR schema ( I use the eclipselink persistence implementation, which supported very well in JDeveloper )


Next step is to create a Session Bean where we add some Facade Methods.

Here you can see that JDeveloper adds a queryByRange Facade method which we be used by ADF for the range size option.

Here you can see the Session Bean code with the queryByRange method

Generate a Datacontrol on this Session Bean,


If we now go the viewcontroller project we can use this Country EJB datacontrol ( add the EJB model project to the viewcontroller project dependency or add the EJB ADF library to the project) . In the Data Controls window you can see the Named Criteria folder in the countriesFindAll method. Drag the All Queriable Attributes on the JSF page and select the Query Panel option.
With this as result, a customizable search panel and when you configure MDS you can even save the user queries in the MDS repository.

The last feature of the EJB Datacontrol is the Range Set option. Default the ADF iterator get the data in set of 25 records ( this is a pagedef option on the iterator ). When the ADF table on the JSF view is full with rows then it won't get the rest of the rows unles you use the scrollbar or use the Next Set Operation. The Next and Previous Set are new options for the EJB Datacontrol.

Use the scrollbar or the next / previous Set button to get all the rows.


Here some eclipselink logging to let you see that is really works.

[EL Fine]: 2009-11-12 14:03:47.375--ServerSession(22965561)--SELECT COUNT(COUNTRY_ID) FROM COUNTRIES

[EL Fine]: 2009-11-12 14:03:47.39 --SELECT * FROM (SELECT /*+ FIRST_ROWS */ a.*, ROWNUM rnum FROM (SELECT COUNTRY_ID AS COUNTRY_ID1
, COUNTRY_NAME AS COUNTRY_NAME2, REGION_ID AS REGION_ID3 FROM COUNTRIES) a WHERE ROWNUM <= ?) WHERE rnum > ?
bind => [5, 0]
[EL Fine]: 2009-11-12 14:03:49.953 --SELECT * FROM (SELECT /*+ FIRST_ROWS */ a.*, ROWNUM rnum FROM (SELECT COUNTRY_ID AS COUNTRY_ID1
, COUNTRY_NAME AS COUNTRY_NAME2, REGION_ID AS REGION_ID3 FROM COUNTRIES) a WHERE ROWNUM <= ?) WHERE rnum > ?
bind => [10, 5]
[EL Fine]: 2009-11-12 14:04:39.281 --SELECT * FROM (SELECT /*+ FIRST_ROWS */ a.*, ROWNUM rnum FROM (SELECT COUNTRY_ID AS COUNTRY_ID1
, COUNTRY_NAME AS COUNTRY_NAME2, REGION_ID AS REGION_ID3 FROM COUNTRIES) a WHERE ROWNUM <= ?) WHERE rnum > ?
bind => [15, 10]

2 comments:

  1. can u please guide on how to create a inputListOfValues using EJB ? i know how to create a inputListOfValues using a VO. Please advise.

    ReplyDelete
  2. Hi,

    you have to do it manually, you can't create a lov on a viewobject attribute.

    first display your form or table and replace an inputtext with inputListOfValues , use the same binding for the value.

    then add the methodaction + its iterator to the pagedef of that page , add a tree binding on that iterator.

    in the jspx page inside in the inputListOfValues add the values based on this tree.

    like this

    <af:selectOneChoice value="#{bindings.deptIdLocal.inputValue}"
    label="Dept">
    <af:forEach items="#{bindings.DeptLOV1.rangeSet}"
    var="li">
    <af:selectItem label="#{li.DepartmentName}"
    value="#{li.DepartmentId}"/>
    </af:forEach>
    </af:selectOneChoice>

    ReplyDelete