How to take items from Data Base?

I’m using grid.getGenericDataView().getItems().toList() but soon as I reorder the items and save them in a reordered line in db then I call again grid.getGenericDataView().getItems().toList() it gives me the unorderd list which is really strange.

Which setItems method are you calling?

If it’s inmemory grid you need to reorder the list then call grid#setItems(orderedItems). Since the grid.getGenericDataView().getItems().toList() is a copy of the list.

default V setItems(Collection items) {
return setItems(DataProvider.ofCollection(items));
}

Well I reorder every time the data base and this grid.getGenericDataView().getItems().toList() says that is taking the data from the db and it doesn’t…

I would recommend to sort on the database and use a lazy dataprovider: Binding Items to Components | Data Binding | Vaadin Docs

That’s not applicable for my project

Can you tell me how can I update current id of an element. I’m trying to reorder the elements in the database and i want to swap their id’s

But when I use the crudService from vaadin it just increments the ids and doesn’t swap them which is really strange …

Swap? And why can’t you use database sorting?

Because I want to order them in my own way

Sorting is only asc and desc

I can’t imagine a case that you can’t do on the database

Ok so how do you do it ?

how does your db table look like and how do you want to sort?

You have 3 items

Item1
Item2
Item3

And I want to make them

Item2
Item1
Item3

But in the db …