I am implementing the CRM list in my website and got this error

There was an exception while trying to navigate to ‘admin’ with the root cause ‘org.h2.jdbc.JdbcSQLSyntaxErrorException: Syntax error in SQL statement “select user0_.id as id1_0_, user0_.email as email2_0_, user0_.first_name as first_na3_0_, user0_.last_name as last_nam4_0_ from [*]user user0_”; expected “identifier”; SQL statement: select user0_.id as id1_0_, user0_.email as email2_0_, user0_.first_name as first_na3_0_, user0_.last_name as last_nam4_0_ from user user0_ [42001-214]’

Here is my code:

Here is my AdminView Code

@PageTitle("Admin Page")
//@RolesAllowed("ADMIN")
@AnonymousAllowed
@Route("admin")
public class AdminView extends VerticalLayout {

    private final WebService service;
    Grid<User> grid = new Grid<>(User.class);
    TextField filterText = new TextField();
    UserForm form;

    AdminView(WebService service) {

        this.service = service;
        addClassName("List-view");
        setSizeFull();

        configureGrid();
        configureForm();

        add(
          getToolbar(),
          getContent()
        );

        updateList();
    }

    private void updateList() {
        grid.setItems(service.findAllUsers(filterText.getValue()));
    }


    private Component getContent() {
        HorizontalLayout content = new HorizontalLayout(grid, form);
        content.setFlexGrow(2, grid);
        content.setFlexGrow(1, form);
        content.addClassName("content");
        content.setSizeFull();

        return content;
    }

    private void configureForm() {
        form = new UserForm();
        form.setWidth("25em");
    }

    private Component getToolbar() {

        filterText.setPlaceholder("Filter by name");
        filterText.setClearButtonVisible(true);
        filterText.setValueChangeMode(ValueChangeMode.LAZY);
        filterText.addValueChangeListener(e -> updateList());

        Button addUserButton = new Button("Add new user");

        HorizontalLayout toolbar = new HorizontalLayout(filterText, addUserButton);
        toolbar.addClassName("toolbar");

        return toolbar;
    }

    private void configureGrid() {
        grid.addClassName("user-grid");
        grid.setSizeFull();
        grid.setColumns("firstName", "lastName", "email");
        grid.getColumns().forEach(col -> col.setAutoWidth(true));
    }
}

And here is the complete error on the website at localhost:8080/admin
https://pastebin.com/AgMCQYGc

It also says that constructor is never being used??
unknown.png

I think I know the error I just need help with the syntax: the error is in the updateList() method

private void updateList() { grid.setItems(service.findAllUsers(filterText.getValue())); }

my database is empty because I am not implementing the dataGenerator form the tutorial how do I prevent calling updateList() when the database is empty?

Hi, what does your service.findAllUsers() method look like. According to the stacktrace, the error is that SQL select statement is incorrect (that’s why I ask your findAllUsers() method). By the way, you can store your service response in a vriable (I guess List<…> users = service.findAllUsers(…)) and if the size of the list is 0, then prevent to call grid.setItems(users) method.

OK thanks a ton i will try that

Another question: If a list is empty does the .findAll() method still work?

if(!(service.findAllUsers(filterText.getValue()).isEmpty()))
        { grid.setItems(service.findAllUsers(filterText.getEmptyValue())); }
    }```

Therefore will this work?

I don’t know your service.findAllUsers() method implementation, but it uses a JPARepository or something similar then it returns an empty List (or Collection).
…if you thought .findAll() is the .findAllUsers() method.
It isn’t clear for me why do you setItems with an empty filtering value search when the search is not empty with the filtering text … but maybe I lost the focus.