abdera-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Remy Gendron" <r...@arrova.ca>
Subject Need hook in AbstractEntityCollectionAdapter for paging
Date Tue, 20 May 2008 18:00:45 GMT
Hello all,

 

To make paging as much an orthogonal feature as possible, w/r to the
application code, I am not using the very good proposition from our friends
Chris and Bryon
(http://www.mail-archive.com/abdera-user@incubator.apache.org/msg00525.html)
. I may not always have to possibility to use an update sequence as I will
quite often work on legacy/existing database schemas.

 

I am relying instead on the native paging features of the underlying
database, not requiring any injection into the SQL where clause. For
instance, with Oracle I have this call to add paging:

 

    /**

     * @see
http://www.oracle.com/technology/oramag/oracle/06-sep/o56asktom.html

     */

    @Override

    protected void addPaging(StringBuilder sql, MapSqlParameterSource
params, ServiceContext context) {

        params.addValue("startIndex", context.getStartIndex()); 

        params.addValue("endIndex", context.getStartIndex() +
context.getMaxResults() - 1);

 

        String prefix = "select * from ( select /*+ FIRST_ROWS(" +
context.getMaxResults() + ") */ a.*, rownum r from ( ";

        

        sql.insert(0, prefix);

        sql.append(" ) a where rownum <= :endIndex ) where r >=
:startIndex");

    }

 

My request:

 

I follow Tom Kyte (asktom) recommendation about paging. My Abdera glue code
alters my service layer context so that the application code believes it
must retrieve n+1 entries instead of n. That way, I can easily know (with a
very low database cost) if there is the need for a next page link to be
inserted into the feed.

 

I have overridden AbstractEntityCollectionAdapter.addFeedDetails() to insert
the paging links if necessary.

 

However, the FOM for a feed does not allow to remove entries from the
collection (Feed.getEntries()). Remember, my glue code had the adapter
retrieve one too many entries in getEntries().

 

Hence, I would need an afterGetEntries(request, entries) called in the
addFeedDetails() prior to the iteration to alter the returned pojo entries
(in my case remove the additional entry).

 

I don’t want to require the application developer to call some method in his
getEntries().

 

For now, I have copied and modified addFeedDetails() in its entirety in my
AbstractEntittyCollectionAdapter class to implement the afterGetEntries
hook.

 

Can anyone recommend a better approach? If not, I will enter a JIRA for this
request.

 

Thank you again,

 

Rémy


Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message