Ignite-spring-data_2.0 not working

classic Classic list List threaded Threaded
7 messages Options
Humphrey Humphrey
Reply | Threaded
Open this post in threaded view
|

Ignite-spring-data_2.0 not working

Hello, I'm getting the following error when trying to use the Query in
IgniteRepository:



I've tried adding the lookup strategy but also no effect:



I've created a reproducable project (see attachment)
spring-data-bug.zip
<http://apache-ignite-users.70518.x6.nabble.com/file/t1004/spring-data-bug.zip>  

Some code snippet below:

@Data
@AllArgsConstructor
public class Person {

    @QuerySqlField
    private String firstname;
    @QuerySqlField
    private String lastname;
    @QuerySqlField
    private int age;

}

@RepositoryConfig(cacheName = "PersonCache")
public interface PersonRepository extends IgniteRepository<Person, Long> {

    @Query("SELECT * FROM person WHERE lastname = ?")
    List<Person> findByLastname(String lastname);

}

When omitting the @Query and List<Person> lines it starts up without any
error.

@Configuration
@EnableIgniteRepositories(basePackageClasses = {PersonRepository.class},
queryLookupStrategy = QueryLookupStrategy.Key.CREATE_IF_NOT_FOUND)
public class AppConfig {

    @Bean
    public Ignite igniteInstance() {
        IgniteConfiguration igniteConfiguration = new IgniteConfiguration()
                .setGridLogger(new Slf4jLogger())
                .setMetricsLogFrequency(0);

        CacheConfiguration cacheConfiguration = new
CacheConfiguration("PersonCache")
                .setIndexedTypes(Long.class, Person.class);

        igniteConfiguration.setCacheConfiguration(cacheConfiguration);

        return Ignition.start(igniteConfiguration);
    }
}

Thanks Humphrey




--
Sent from: http://apache-ignite-users.70518.x6.nabble.com/
Humphrey Humphrey
Reply | Threaded
Open this post in threaded view
|

Re: Ignite-spring-data_2.0 not working

I see that some text went missing after the post:

Here the stack trace log:

Error starting ApplicationContext. To display the conditions report re-run
your application with 'debug' enabled.
2019-11-02 13:16:56.482 ERROR 13627 --- [           main]
o.s.boot.SpringApplication               : Application run failed

org.springframework.beans.factory.BeanCreationException: Error creating bean
with name 'personRepository': Invocation of init method failed; nested
exception is java.lang.IllegalStateException: You have defined query method
in the repository but you don't have any query lookup strategy defined. The
infrastructure apparently does not support query methods!
        at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1803)
~[spring-beans-5.2.0.RELEASE.jar:5.2.0.RELEASE]
        at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:595)
~[spring-beans-5.2.0.RELEASE.jar:5.2.0.RELEASE]
        at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:517)
~[spring-beans-5.2.0.RELEASE.jar:5.2.0.RELEASE]
        at
org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:323)
~[spring-beans-5.2.0.RELEASE.jar:5.2.0.RELEASE]
        at
org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
~[spring-beans-5.2.0.RELEASE.jar:5.2.0.RELEASE]
        at
org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:321)
~[spring-beans-5.2.0.RELEASE.jar:5.2.0.RELEASE]
        at
org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:202)
~[spring-beans-5.2.0.RELEASE.jar:5.2.0.RELEASE]
        at
org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:860)
~[spring-beans-5.2.0.RELEASE.jar:5.2.0.RELEASE]
        at
org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:878)
~[spring-context-5.2.0.RELEASE.jar:5.2.0.RELEASE]
        at
org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:550)
~[spring-context-5.2.0.RELEASE.jar:5.2.0.RELEASE]
        at
org.springframework.boot.SpringApplication.refresh(SpringApplication.java:747)
~[spring-boot-2.2.0.RELEASE.jar:2.2.0.RELEASE]
        at
org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:397)
~[spring-boot-2.2.0.RELEASE.jar:2.2.0.RELEASE]
        at
org.springframework.boot.SpringApplication.run(SpringApplication.java:315)
~[spring-boot-2.2.0.RELEASE.jar:2.2.0.RELEASE]
        at
org.springframework.boot.SpringApplication.run(SpringApplication.java:1226)
~[spring-boot-2.2.0.RELEASE.jar:2.2.0.RELEASE]
        at
org.springframework.boot.SpringApplication.run(SpringApplication.java:1215)
~[spring-boot-2.2.0.RELEASE.jar:2.2.0.RELEASE]
        at
org.bug.ignite.springdatabug.SpringDataBugApplication.main(SpringDataBugApplication.java:10)
~[classes/:na]
Caused by: java.lang.IllegalStateException: You have defined query method in
the repository but you don't have any query lookup strategy defined. The
infrastructure apparently does not support query methods!
        at
org.springframework.data.repository.core.support.RepositoryFactorySupport$QueryExecutorMethodInterceptor.<init>(RepositoryFactorySupport.java:553)
~[spring-data-commons-2.2.0.RELEASE.jar:2.2.0.RELEASE]
        at
org.springframework.data.repository.core.support.RepositoryFactorySupport.getRepository(RepositoryFactorySupport.java:332)
~[spring-data-commons-2.2.0.RELEASE.jar:2.2.0.RELEASE]
        at
org.springframework.data.repository.core.support.RepositoryFactoryBeanSupport.lambda$afterPropertiesSet$5(RepositoryFactoryBeanSupport.java:297)
~[spring-data-commons-2.2.0.RELEASE.jar:2.2.0.RELEASE]
        at org.springframework.data.util.Lazy.getNullable(Lazy.java:212)
~[spring-data-commons-2.2.0.RELEASE.jar:2.2.0.RELEASE]
        at org.springframework.data.util.Lazy.get(Lazy.java:94)
~[spring-data-commons-2.2.0.RELEASE.jar:2.2.0.RELEASE]
        at
org.springframework.data.repository.core.support.RepositoryFactoryBeanSupport.afterPropertiesSet(RepositoryFactoryBeanSupport.java:300)
~[spring-data-commons-2.2.0.RELEASE.jar:2.2.0.RELEASE]
        at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1862)
~[spring-beans-5.2.0.RELEASE.jar:5.2.0.RELEASE]
        at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1799)
~[spring-beans-5.2.0.RELEASE.jar:5.2.0.RELEASE]
        ... 15 common frames omitted



--
Sent from: http://apache-ignite-users.70518.x6.nabble.com/
ilya.kasnacheev ilya.kasnacheev
Reply | Threaded
Open this post in threaded view
|

Re: Ignite-spring-data_2.0 not working

Hello!

Please try the following dependency:
<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-commons</artifactId>
<version>2.0.9.RELEASE</version>
<!-- Exclude slf4j logging in favor of log4j -->
<exclusions>
<exclusion>
<groupId>org.slf4j</groupId>
<artifactId>jcl-over-slf4j</artifactId>
</exclusion>
</exclusions>
</dependency>

It seems that they have changed API in 2.2 (which you get by default) and we're not compatible with that.

Regards,
--
Ilya Kasnacheev


сб, 2 нояб. 2019 г. в 20:50, Humphrey <[hidden email]>:
I see that some text went missing after the post:

Here the stack trace log:

Error starting ApplicationContext. To display the conditions report re-run
your application with 'debug' enabled.
2019-11-02 13:16:56.482 ERROR 13627 --- [           main]
o.s.boot.SpringApplication               : Application run failed

org.springframework.beans.factory.BeanCreationException: Error creating bean
with name 'personRepository': Invocation of init method failed; nested
exception is java.lang.IllegalStateException: You have defined query method
in the repository but you don't have any query lookup strategy defined. The
infrastructure apparently does not support query methods!
        at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1803)
~[spring-beans-5.2.0.RELEASE.jar:5.2.0.RELEASE]
        at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:595)
~[spring-beans-5.2.0.RELEASE.jar:5.2.0.RELEASE]
        at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:517)
~[spring-beans-5.2.0.RELEASE.jar:5.2.0.RELEASE]
        at
org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:323)
~[spring-beans-5.2.0.RELEASE.jar:5.2.0.RELEASE]
        at
org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
~[spring-beans-5.2.0.RELEASE.jar:5.2.0.RELEASE]
        at
org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:321)
~[spring-beans-5.2.0.RELEASE.jar:5.2.0.RELEASE]
        at
org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:202)
~[spring-beans-5.2.0.RELEASE.jar:5.2.0.RELEASE]
        at
org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:860)
~[spring-beans-5.2.0.RELEASE.jar:5.2.0.RELEASE]
        at
org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:878)
~[spring-context-5.2.0.RELEASE.jar:5.2.0.RELEASE]
        at
org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:550)
~[spring-context-5.2.0.RELEASE.jar:5.2.0.RELEASE]
        at
org.springframework.boot.SpringApplication.refresh(SpringApplication.java:747)
~[spring-boot-2.2.0.RELEASE.jar:2.2.0.RELEASE]
        at
org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:397)
~[spring-boot-2.2.0.RELEASE.jar:2.2.0.RELEASE]
        at
org.springframework.boot.SpringApplication.run(SpringApplication.java:315)
~[spring-boot-2.2.0.RELEASE.jar:2.2.0.RELEASE]
        at
org.springframework.boot.SpringApplication.run(SpringApplication.java:1226)
~[spring-boot-2.2.0.RELEASE.jar:2.2.0.RELEASE]
        at
org.springframework.boot.SpringApplication.run(SpringApplication.java:1215)
~[spring-boot-2.2.0.RELEASE.jar:2.2.0.RELEASE]
        at
org.bug.ignite.springdatabug.SpringDataBugApplication.main(SpringDataBugApplication.java:10)
~[classes/:na]
Caused by: java.lang.IllegalStateException: You have defined query method in
the repository but you don't have any query lookup strategy defined. The
infrastructure apparently does not support query methods!
        at
org.springframework.data.repository.core.support.RepositoryFactorySupport$QueryExecutorMethodInterceptor.<init>(RepositoryFactorySupport.java:553)
~[spring-data-commons-2.2.0.RELEASE.jar:2.2.0.RELEASE]
        at
org.springframework.data.repository.core.support.RepositoryFactorySupport.getRepository(RepositoryFactorySupport.java:332)
~[spring-data-commons-2.2.0.RELEASE.jar:2.2.0.RELEASE]
        at
org.springframework.data.repository.core.support.RepositoryFactoryBeanSupport.lambda$afterPropertiesSet$5(RepositoryFactoryBeanSupport.java:297)
~[spring-data-commons-2.2.0.RELEASE.jar:2.2.0.RELEASE]
        at org.springframework.data.util.Lazy.getNullable(Lazy.java:212)
~[spring-data-commons-2.2.0.RELEASE.jar:2.2.0.RELEASE]
        at org.springframework.data.util.Lazy.get(Lazy.java:94)
~[spring-data-commons-2.2.0.RELEASE.jar:2.2.0.RELEASE]
        at
org.springframework.data.repository.core.support.RepositoryFactoryBeanSupport.afterPropertiesSet(RepositoryFactoryBeanSupport.java:300)
~[spring-data-commons-2.2.0.RELEASE.jar:2.2.0.RELEASE]
        at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1862)
~[spring-beans-5.2.0.RELEASE.jar:5.2.0.RELEASE]
        at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1799)
~[spring-beans-5.2.0.RELEASE.jar:5.2.0.RELEASE]
        ... 15 common frames omitted



--
Sent from: http://apache-ignite-users.70518.x6.nabble.com/
Humphrey Humphrey
Reply | Threaded
Open this post in threaded view
|

Re: Ignite-spring-data_2.0 not working

Thanks,

I've tried it with version 2.0.14 and it works, but version 2.1.0 it
doesn't.

<dependency>
  <groupId>org.springframework.data</groupId>
  <artifactId>spring-data-commons</artifactId>
  <version>2.0.14.RELEASE</version>
</dependency>

Humphrey



--
Sent from: http://apache-ignite-users.70518.x6.nabble.com/
ilya.kasnacheev ilya.kasnacheev
Reply | Threaded
Open this post in threaded view
|

Re: Ignite-spring-data_2.0 not working

Hello!

Well, I guess that's how it is currently.

Regards,
--
Ilya Kasnacheev


пт, 8 нояб. 2019 г. в 17:17, Humphrey <[hidden email]>:
Thanks,

I've tried it with version 2.0.14 and it works, but version 2.1.0 it
doesn't.

<dependency>
  <groupId>org.springframework.data</groupId>
  <artifactId>spring-data-commons</artifactId>
  <version>2.0.14.RELEASE</version>
</dependency>

Humphrey



--
Sent from: http://apache-ignite-users.70518.x6.nabble.com/
Humphrey Humphrey
Reply | Threaded
Open this post in threaded view
|

Re: Ignite-spring-data_2.0 not working

Thanks, is there a way to use IgnoreCase as well?

IgnoreCase findByFirstnameIgnoreCase … where UPPER(x.firstame) = UPPER(?1)

https://docs.spring.io/spring-data/jpa/docs/1.5.1.RELEASE/reference/html/jpa.repositories.html#jpa.query-methods.query-creation

Or another way to do accomplish that with spring-data?

Humphrey



--
Sent from: http://apache-ignite-users.70518.x6.nabble.com/
ilya.kasnacheev ilya.kasnacheev
Reply | Threaded
Open this post in threaded view
|

Re: Ignite-spring-data_2.0 not working

Hello!

I don't recommend this since index can't be use in this case. Better introduce firstNameInUpper field.

Regards,
--
Ilya Kasnacheev


пт, 8 нояб. 2019 г. в 18:32, Humphrey <[hidden email]>:
Thanks, is there a way to use IgnoreCase as well?

IgnoreCase      findByFirstnameIgnoreCase       … where UPPER(x.firstame) = UPPER(?1)

https://docs.spring.io/spring-data/jpa/docs/1.5.1.RELEASE/reference/html/jpa.repositories.html#jpa.query-methods.query-creation

Or another way to do accomplish that with spring-data?

Humphrey



--
Sent from: http://apache-ignite-users.70518.x6.nabble.com/