Data provider returns Incompatible types error

so i followed the documentation on how to make a vaadin flow dataprovider here : https://vaadin.com/docs/flow/binding-data/tutorial-flow-data-provider.html

but i have a problem cuz it keeps returning this weird error : Incompatible types.

Required CallbackDataProvider<Person, Void> but ‘fromCallbacks’ was inferred to CallbackDataProvider< I, Void>: no instance(s) of type variable(s) T exist so that CallbackDataProvider<T, Void> conforms to CallbackDataProvider<Person, Void>

this is a dummy dataprovider as basic as i can think of that also doesnt work :

    dataProvider = DataProvider.fromCallbacks(
	
            query -> {
			
                List<Person> people = new ArrayList<>();
				
                return people;
				
            },
			
            query -> {
			
                int i = 0;
				
                return i;
				
            });

any ideas? if i use the normal vaadin dataprovider(thats not flow) it works just fine but then the problem is that all my components are flow and i cant set the dataprovider for them.

What type is your dataProvider variable?

Olli Tietäväinen:
What type is your dataProvider variable?

com.vaadin.flow.data.provider.CallbackDataProvider<Person, Void> dataProvider;

included the vaadin flow import as well, if theres a problem there, i tried doing it without flow and the same code works, but all my other components are flow so i cant set the normal vaadin data provider then

I’m not sure I understand what you mean “without flow” or “normal vaadin data provider”. Are you using Vaadin 13?

Olli Tietäväinen:
I’m not sure I understand what you mean “without flow” or “normal vaadin data provider”. Are you using Vaadin 13?

agh im sorry for not being clear, com.vaadin.data.provider.CallbackDataProvider this is the other callbackdataprovider that i cant use with flow components, and yes im using vaadin13

If you have a Vaadin 13 app, you should be only using DataProvider from com.vaadin.flow.data.provider.*. com.vaadin.data.provider.* is the package for Vaadin 8 DataProvider, and that won’t mix with Vaadin 13 apps at all.

Olli Tietäväinen:
If you have a Vaadin 13 app, you should be only using DataProvider from com.vaadin.flow.data.provider.*. com.vaadin.data.provider.* is the package for Vaadin 8 DataProvider, and that won’t mix with Vaadin 13 apps at all.

i agree, thats why im trying with com.vaadin.flow.data.provider.* , and i get the error that i posted in this thread

If you’re even able to compile with imports from com.vaadin.data.provider, and you’re only working with V13, that sounds like you might have a messed up project setup. Here’s a very simple example from my test project that works:

import com.vaadin.flow.data.provider.DataProvider;
import com.vaadin.flow.data.provider.Query;
/* ... */ 
    DataProvider<Person, Void> dataProvider = DataProvider.fromCallbacks(
                query -> fetch(query, false),
                query -> count(query, false));

I tried declaring it with just :

DataProvider<Person, Void> dataProvider

instead of

CallBackDataProvider<Person, Void> dataProvider

and it works now, but its weird, my colleague has CallBackDataProvider in declaration and it works just fine. Thank you for your help, i’ve been stomped on this for way too long.

Good to hear it works, at least!