Skip Headers

# Using DatabaseQuery Finders

Previous

Next

TopLink provides a predefined finder that takes a `DatabaseQuery` such as a `ReadAllQuery`. To use this feature in a bean, add the following finder definition to the `Home` interface of your bean:

    public Collection findManyByQuery(ReadAllQuery query) throws RemoteException, FinderException;

    public <EJBLocal/Remote> findOneByQuery(ReadObjectQuery query) throws RemoteException, FinderException;

To execute a `ReadAllQuery` finder, create the query on the client, as Example: A ReadAllQuery Finder shows.

A ReadAllQuery Finder

    {
        ReadAllQuery query = new ReadAllQuery(Employee.class);
        query.addJoinedAttribute("address");
        Enumeration employees = getEmployeeHome().findManyByQuery(query);
    }