On Feb 1, Tom Cook quoth:
> On Thu, 01 Feb 2001, you wrote:
> > On Jan 31, Kimpton,C (Chris) quoth:
> >
> > > I want to find out how many entities I have of a particular bean, eg I have
> > > a CompanyBean, is
> > > there a standard countAll CompanyHome method - or can I define a custom
> > > finder with jbossCMP, or
> > > do I need to go under the covers and talk directly to the DB?
> > >
> > > The info is for a summary page and thus I want to avoid loading up all the
> > > companies just to find the total.
> >
> > The Home.findAll() method returns a Collection. Collection.size() returns
> > an int with the number of items in the collection. This implies a limit
> > of Integer.MAX_VALUE to the number of objects you can iterate over in a
> > collection but I don't know what the boundary behavior of the beans and
> > the Collection implementations are.
>
> Poor practice I know, but the source for the class library comes with the JDK,
> so you could have a look at how it's implemented...
>
> My guess is that most Collection implementations will use a linked list, so
> you're limited by memory, even if .size() will not be able to report extremely
> large sizes.
It would be interesting to see what happens because upon some further
research it turns out the JVM is 32bit. 32bit instruction addresses,
32bit words and 32bit heap/stack alignment. However, there are databases
that aren't limited to 4G in records.
Given the object overhead (IIRC of about 16 bytes per object minimum) it
wouldn't be theoretically possible to get more than 2**28 records in
memory. Whether or not you could actually achieve a 4G process size is an
OS specific issue.
The whole thing is academic anyway but we can rest assured that other Bad
Things(tm) will happen long before Collection.size() returns an inaccurate
number.
C=)
--------------------------------------------------------------------------
If you want to build a ship, don't drum up people together to collect wood
and don't assign them tasks and work, but rather teach them to long for
the endless immensity of the sea. -- Antoine de Saint Exupery
--------------------------------------------------------------------------
Caskey <caskey*technocage.com> /// TechnoCage Inc.
--------------------------------------------------------------------------
It's not an optical illusion, it just looks like one. -- Phil White
--
--------------------------------------------------------------
To subscribe: [EMAIL PROTECTED]
To unsubscribe: [EMAIL PROTECTED]
List Help?: [EMAIL PROTECTED]