Skip Headers

# Specifying a Collection Class

Previous

Next

By default, a `ReadAllQuery` returns its result objects in a vector. You can configure the query to return the results in any collection class that implements the `Collection` or `Map` interface, as shown in Example: Specifying the Collection Class for a Collection.

Specifying the Collection Class for a Collection

    ReadAllQuery query = new ReadAllQuery(Employee.class);
    query.useCollectionClass(LinkedList.class);
    LinkedList employees = (LinkedList) getSession().executeQuery(query);

Specifying the Collection Class for a Map

    ReadAllQuery query = new ReadAllQuery(Employee.class);
    query.useMapClass(HashMap.class, "getFirstName");
    HashMap employees = (HashMap) getSession().executeQuery(query);