select count(*) generally wont perform as well as select
count(some_column_with_index) - so I would suggest doing select
count(o.barid) from ... in any case... which I'd guess would do the trick.
cheers
dim
On Tue, 25 Sep 2001, Cyril INARDDARGENCE wrote:
> Hi,
>
> Sorry for a bit technical posting :-)
>
> A recent patch in castor source caused oql query containing a 'count(*)' select to
>fail.
>
> A oql query like "SELECT count ( * ) FROM org.foo.Bar o" leads to a
>HsqlQueryExpression
> having its _select property set to " count(*) " and its _cols property having a
>zero size, so
> when the addColumnList method is called a '1' is appended to the sql query buffer and
> the method returns, the code that should be called (if ( _select != null ) ...) has
>no chance
> to be called.
>
> private void addColumnList(StringBuffer buffer, HsqlAliasInfo aliasInfo)
> {
> if ( _cols.size() == 0 ) // ? (Preserved from superclass)
> {
> buffer.append("1");
> return;
> }
>
> // code skipped...
>
> if ( _select != null ) // ? (Preserved from superclass)
> if ( i > 0 )
> buffer.append( JDBCSyntax.ColumnSeparator ).append( _select );
> else
> buffer.append( _select );
> }
>
>
>
>
> Former version of HsqlQueryExpression.addSelectClause() (revision 1.3) worked
>because
> the _select property was appended anyway :
>
>
> private void addSelectClause(StringBuffer buffer, HsqlAliasInfo aliasInfo)
> {
> buffer.append( JDBCSyntax.Select );
> if ( _distinct ) buffer.append( JDBCSyntax.Distinct );
> if ( _select == null )
> addColumnList(buffer, aliasInfo);
> else
> buffer.append( _select ).append(" ");
> }
>
> but latest cvs version (revision 1.4) does not append the _select anymore :
>
> private void addSelectClause(StringBuffer buffer, HsqlAliasInfo aliasInfo)
> {
> buffer.append( JDBCSyntax.Select );
> if ( _distinct )
> buffer.append( JDBCSyntax.Distinct );
>
> addColumnList(buffer, aliasInfo);
> }
>
>
> Is there a better way to perform count(*) using castor-jdo or will this be fixed in
> next castor release.
>
> Thanks.
>
> Cyril.
>
> -----------------------------------------------------------
> If you wish to unsubscribe from this mailing, send mail to
> [EMAIL PROTECTED] with a subject of:
> unsubscribe castor-dev
>
>
-----------------------------------------------------------
If you wish to unsubscribe from this mailing, send mail to
[EMAIL PROTECTED] with a subject of:
unsubscribe castor-dev