import org.apache.cayenne.access.DataContext;
import org.apache.cayenne.unit.CayenneCase;
public class StatementFetchSizeTest extends CayenneCase {
public void test() {
DataContext dataContext = createDataContext();
SelectQuery query = new SelectQuery(Artist.class);
query.setStatementFetchSize(10);
assertEquals(10, query.getMetaData(dataContext.getEntityResolver()).getStatementFetchSize());
dataContext.performQuery(query);
SQLTemplate template = new SQLTemplate(Artist.class, "SELECT ARTIST_ID FROM ARTIST");
template.setStatementFetchSize(10);
assertEquals(10, template.getMetaData(dataContext.getEntityResolver()).getStatementFetchSize());
dataContext.performQuery(template);
EJBQLQuery ejbql = new EJBQLQuery("select a from Artist a");
ejbql.setStatementFetchSize(10);
assertEquals(10, ejbql.getMetaData(dataContext.getEntityResolver()).getStatementFetchSize());
dataContext.performQuery(ejbql);
ObjectId id = new ObjectId("Artist", Artist.ARTIST_ID_PK_COLUMN, 1);
RelationshipQuery relationshipQuery = new RelationshipQuery(id, Artist.PAINTING_ARRAY_PROPERTY, true);
relationshipQuery.setStatementFetchSize(10);
assertEquals(10, relationshipQuery.getMetaData(dataContext.getEntityResolver()).getStatementFetchSize());
dataContext.performQuery(relationshipQuery);
}