# Counting a collection

DO: If you want to count the number of batch control parameters that belong to a parent batch control, use the size() method as in the following example:

    			BatchControl someBatchControl = ...;
    			BatchControlParameters parms = someBatchControl.getParameters();
    			int count = parms.size();

The framework implementation code has an optimized implementation of the size() method, which either counts the existing in-memory collection elements, if they are already present, or issues a SQL count(*) query, if they aren't.

Parent topic: Object-Relational Mapping: Background