Re: Fetching record counts.
Re: Fetching record counts.
- Subject: Re: Fetching record counts.
- From: PA <email@hidden>
- Date: Tue, 1 Feb 2005 20:45:51 +0100
On Feb 01, 2005, at 20:10, Chuck Hill wrote:
Here are some other counting implementation that I have gleaned from
the list. Perhaps they are of interest?
Perhaps... or perhaps you could use the hidden power of raw
<gasp>JDBC</gasp> instead:
public class EFCount extends EFSelect
{
//
========================================================================
===
// Constant(s)
//
------------------------------------------------------------------------
---
private static final String Count = "COUNT(*)";
//
========================================================================
===
// Class variable(s)
//
------------------------------------------------------------------------
---
//
========================================================================
===
// Instance variable(s)
//
------------------------------------------------------------------------
---
//
========================================================================
===
// Constructor method(s)
//
------------------------------------------------------------------------
---
public EFCount(final DataSource aDataSource, final Class
anEntity, final SZQualifier aQualifier)
{
super( aDataSource, anEntity, aQualifier, null );
}
//
========================================================================
===
// Class method(s)
//
------------------------------------------------------------------------
---
//
========================================================================
===
// Instance method(s)
//
------------------------------------------------------------------------
---
//
========================================================================
===
// EFAction method(s)
//
------------------------------------------------------------------------
---
protected String attributesDescription()
{
return EFCount.Count;
}
public int count() throws SQLException
{
Iterator anIterator = this.execute();
int aCount = 0;
if ( anIterator.hasNext() == true )
{
Map someValues = (Map) anIterator.next();
Number aNumber = (Number)
someValues.values().iterator().next();
if ( aNumber.intValue() > 0 )
{
aCount = aNumber.intValue();
}
}
this.close();
return aCount;
}
}
Cheers
--
PA, Onnay Equitursay
http://alt.textdrive.com/
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden