Hi Simone,
Simone Gianni wrote:
Hi Patrick,
this is absolutely a good solution, but we should find a way to do this
in an abstract manner from a repeater, that means not to use an
hibernate specific system. Actually nearly every database abstraction
provides a way to retrieve only part of a result set, but the "flow"
should be this :
- The repeater binds only the object specific to the current page
- The Collection behind the form is wise enought to retrieve/save only
objects getted/setted by the repeater.
So, given a repeater that binds only the specific page, then an
Implementation of List that uses your code would integrate it with
Hibernate.
Yes, I fully agree to all of the above, in fact the hereafter code was
extracted from:
Hibenate specific implementation:
public class HibernateDataStoreImpl extends ServiceBase implements
DataStore {
(...)
public List queryData(String namedQuery, int start, int max)
throws DataStoreException {
try {
Query query = session.getNamedQuery(namedQuery);
query.setFirstResult(start);
query.setMaxResults(max);
return query.list();
}
catch (Exception e) {
log.error(e);
throw new DataStoreException(
this.getClass().getName() +
" - Could not execute query successfully, see logs for details.");
}
}
(...)
}
Supporting Java Interface serving as persistence layer facade:
public interface DataStore {
(...)
List queryData(String namedQuery, int start, int max)
throws DataStoreException;
(...)
}
The interface return a standard List we could bind to a repeater.
I had not time to integrate this with Cocoon yet...
I am also looking forward to test Spring Framework integration into
Cocoon (replacing Avalon isn't it) This looks like a great opportunitiy
to benefit from many services together with a good design, persistence
layer being amoung them.
Patrick
Simone
Patrick Refondini wrote:
werner wrote:
Dear List,
I'm looking for a solution to create a repeater with paging support.
The repeater is usually connected to some database via OJB or
Hibernate. I think that this is a common problem, so I hope that
somebody out there has already done this before ;-)
In short the problems I want to solve are:
- create a DAO that returns only the records that should be displayed
(that's not easy with OJB. looks like there is no real paging
support in OJB.
I don't know Hibernate.)
I did some paging tests with Hibernate using the Query interface which
might be what you are looking for. Looks like:
Query query = session.getNamedQuery(namedQuery);
query.setFirstResult(start);
query.setMaxResults(max);
return query.list();
Just a hint as w're not on a Hibernate list here ;-)
the DAO should also return the number of overall records to be able to
calculate the number of pages
- create a widget that displays the links to the pages (no idea how
to do that)
Any suggestions ?
Werner
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]