Paging concept in EJB

Discussions

EJB programming & troubleshooting: Paging concept in EJB

  1. Paging concept in EJB (3 messages)

    Hello sir,

    As i am new in EJB so can any one tell me how to make the paging concept in EJB with JSP

    what i did is i have the records in Collection from the finder method after that i use the paging code but the records fetch from the data base on the basis of some SQL but we use CMP so we define EJBQL so thats why i cant understand how to do it
    and if i define my parameter in EJBQL then how the data retrieve for the next set of records i mean how to retrieve the next set of data throught EJBQL because the data comes from the SQL in one time in collection so how get next time

    if u have any code which helps me than i shall be thank ful to you

    thanks in advance
    byeeeeeeeeeeeeeeeeeeee

    Threaded Messages (3)

  2. Paging concept in EJB[ Go to top ]

    It is not a good Idea to do paging using CMP.
    I doubt that in EJBQL you can restrict the number of rows retrieved to your Page size. I mean, can you restrict the # of rows returned to be 10 rows from EJBQL.

    If that is possible then do this:
    Select o from tableName as o
    where o.PK > X
    and <order by PK

    ***PK = Primary Key of the table.
    ***X = last PK in Last Page or SPACE or 0 for 1st page.

    If you are accessing a local CMP then the Collection returned by your finder method will not work in JSP(Local instances do not work outside the EJB Container). So make sure that you convert the CMP objects to Value Objects before sending it to web tier.

    I would advice you to think at least 100 times before using CMP beans for this purpose. Better you use WebRowSet for this purpose using DAO. I am sure, you will regret latter for using CMP for this purpose.

    regards,
    Rajesh Kumar Ilango
  3. Paging concept in EJB[ Go to top ]

    Hello,
          It depends how many record we are talking about. If there are not many records and you don't expect the numbers to grow then getting the records in one go will make sense and then you can iterate on the collection returned. You may want to check out the html-table component that will make the pagination much simpler.

    If the records are many then what Rajesh is telling is good. You can restrict the number of records returned bu the query based on some criteria and then can display the records.

    It depends you want to get all the data in one SQL or with limited data with one SQL and on each page navigation fire the SQl to get the next records.

    Hope this helps.
  4. Hi

    i solved the paging problem but for that i have to use ROWNUM in the EJB QL but when i try to run it then it shows error on rownum so can any one help me to solve it


    and another thing when i user LIKE statement in EJBQL then it will not search on the basis of parameter that comes from the JSP page

    so any one help me to solve this problem
    i shall be thank ful to you

    byeeeeeeeeee