LazyQueryContainer loads all records

Hi Guys, I’m attempting to implement the LazyQueryContainer in my application. I want to load records via a business service.

I am following the details on the wiki more or less, with the exception of some changes to the API.

The behavior I am seeing, is:
a) Properties from the set of beans are not being set in the LazyQueryContainer (i.e getPropertyIds() returns an empty set)
b) Setting the properties for the LazyQueryContainer results in all the records being fetched from the db.
c) Setting the properties for the LazyQueryContainer seems to get the “first batch” of results multiple times.

Here is some logs:
StaffEditor Container Property Ids: [firstname, lastname]

Initial Setup
Loading Beans 0 1
[DEBUG]
StaffService # Active Staff (Paged): 1
[DEBUG]
StaffEditor Container Size: 120
Loading Beans 0 20
[DEBUG]
StaffService # Active Staff (Paged): 19
Loading Beans 0 20
[DEBUG]
StaffService # Active Staff (Paged): 19
Loading Beans 0 20
[DEBUG]
StaffService # Active Staff (Paged): 19
Loading Beans 20 20
[DEBUG]
StaffService # Active Staff (Paged): 20
Loading Beans 40 20
[DEBUG]
StaffService # Active Staff (Paged): 20
Loading Beans 60 20
[DEBUG]
StaffService # Active Staff (Paged): 20
Loading Beans 80 20
[DEBUG]
StaffService # Active Staff (Paged): 20
Loading Beans 100 20
[DEBUG]
StaffService # Active Staff (Paged): 20

The setup code is as follows


QueryDefinition definition = new LazyQueryDefinition(true, 20);
        log.debug("Adding Item Properties")
        definition.addProperty("firstname", String.class, null, true, true)
        definition.addProperty("lastname", String.class, null, true, true)

        BeanQueryFactory<LazyServiceBeanQuery> queryFactory = new BeanQueryFactory<LazyServiceBeanQuery>(LazyServiceBeanQuery.class);

        Map<String,Object> queryConfiguration=new HashMap<String,Object>();
        queryConfiguration.put("service",instanceService); // this is the StaffService
        queryFactory.setQueryConfiguration(queryConfiguration);

        LazyQueryContainer container=new LazyQueryContainer(definition, queryFactory);
        log.debug("Container Property Ids: ${container.getContainerPropertyIds()}")
        log.debug("Container Size: ${container.size()}")

        list.setContainerDataSource(container);

The query class looks like this


public class LazyServiceBeanQuery <T> extends AbstractBeanQuery <T> {

    PagedResultList results;

    public LazyServiceBeanQuery(QueryDefinition definition, Map<String, Object> queryConfiguration, Object[] sortPropertyIds, boolean[]
 sortStates) {
        super(definition, queryConfiguration, sortPropertyIds, sortStates);

        System.out.println("Initial Setup");
        loadBeans(0,1);
    }

    @Override
    protected T constructBean() {
        throw new UnsupportedOperationException();
    }

    @Override
    public int size() {
       if(results==null){
           return 0;
       }
       return results.getTotalCount();
    }

    protected List<T> loadBeans(int startIndex, int count) {
        System.out.println("Loading Beans " + startIndex + " " + count);
        LazyBeanService service= (LazyBeanService) getQueryConfiguration().get("service");
        results = service.getPagedResults(startIndex, count, null, null);
        return results;
    }

    @Override
    protected void saveBeans(List<T> addedTasks, List<T> modifiedTasks, List<T> removedTasks) {
        throw new UnsupportedOperationException();
    }
}

If I do not set the properties on the container, the system loads the first 20 records, as it should, however there are no properties set on the container, so I cannot “view” anything. Any attempt to add properties, either by the QueryDefinition or manually causes the whole set to be loaded.

I am on Vaadin 6 and running version 1.2.11 of the plugin.

Thank you for your help.

~Ben