AW: [OJB-developers] Select count(x)
Brought to you by:
thma
From: Mahler T. <tho...@it...> - 2001-11-13 17:02:47
|
Hi Charles, > > 1. When my RowReader returns null, > RSIterator.getObjectFromResultSet still > tries to create an Identity, look it up in the cache etc. Creating an > Indentity from a null reference results a NullPointer > exception. This is > easily fixable, I believe, just by changeing the appropriate > part of the > method to > Object result = > m_mif.getRowReader().readObjectFrom(m_rs, m_mif); > if(result!=null) { > ... > } I will at this to the todo-list! > > 2. I'm a little concerned about the ClassDescriptor.setRowReader in a > multi-threaded environment. What would happen if one thread > was using a > RowReaderDefaultImpl, and another was using my > PagingRowReader - on the same > class ? I think that would cause problems. > There will be no problems if different threads are using different RowReaders for the same class. But: there my be problems if to threads are manipulating a ClassDescriptor simultaneously. thread 1 says: use RowReaderDefaultImpl, thread 2 says: use PagingRowReader thread 1 acquires a ResultSetIterator an will be using a PagingRowreader although it asked for a default RowReader. You'll have to implement some additional access management to avoid such errors. A general remark: I'm not quite sure what you want to to with your paging component. My concept of a paging display is as follows. You a ResultSetIterator which may produce any number of Objects. You don't want to display all those objects immediately, but in pages of say 20 objects. The Paging component should support forward and backward navigation ("show last 20 items", "show next 20 items"). I would implement this as follows: public class Pager { private ResultSetIterator iter; private Vector items = new Vector(); private int offset = 0; private int pagesize; public Pager(ResultSetIterator i, int size) { iter = i; pagesize = size; } public Collection getNextPage() { Collection page = new Vector() for (int i = 0; i<pagesize; i++) { page.add(iter.next()); offset++; } items.addAll(page); return page; } public Collection getPreviousPage() { Collection page = new Vector(); int oldoffset = offset; offset = offset - pagesize; if (offset < 0) offset = 0; for (int i = offset; i < oldoffset; i++) { page.add(items.get(i)); } return page; } } cheers, Thomas > Thanks, and sorry to keep bothering you, > > > Charles. > > > This email and any attachments are strictly confidential and > are intended > solely for the addressee. If you are not the intended > recipient you must > not disclose, forward, copy or take any action in reliance on > this message > or its attachments. If you have received this email in error > please notify > the sender as soon as possible and delete it from your > computer systems. > Any views or opinions presented are solely those of the > author and do not > necessarily reflect those of HPD Software Limited or its affiliates. > > At present the integrity of email across the internet cannot > be guaranteed > and messages sent via this medium are potentially at risk. > All liability > is excluded to the extent permitted by law for any claims > arising as a re- > sult of the use of this medium to transmit information by or to > HPD Software Limited or its affiliates. > > |