Marc,
We could sure use a standard mechanism for checking the existence of a
record. Perhaps you could raise an enhancement request in Scarab.
In the mean time, here is what I do:
public boolean checkExists() {
Criteria criteria = new Criteria();
criteria.addSelectColumn(MyPeer.RANDOM_SMALL_COLUMN);
// Add anything else to the criteria to limit the selection
criteria.setLimit(1);
List queryReault = BasePeer.doSelect(criteria);
return queryResult.size() == 0;
}
Obviously this is along the lines of what you were suggesting, but it will
be quicker to limit the selection to a single row and to only retrieve a
single column.
Cheers,
Scott
--
Scott Eade
Backstage Technologies Pty. Ltd.
http://www.backstagetech.com.au
> From: "Marc Lustig" <[EMAIL PROTECTED]>
>
> Hi,
>
> I'm wondering what is the most convenient way to check whether a table-row
> exists or not (using a criteria as condition).
> I was looking for a special method (something like exists() in the Peer
> classes but couldn't find.
> So I guess I have either to build my own method or do the usual doSelect and
> then check whether mylist.size() is 0 or not.
> Or did I miss something?
>
> TIA.
> Marc
--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>