Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Exception creating count queries for Spring repositories #617

Closed
heruan opened this issue Aug 1, 2018 · 0 comments
Closed

Exception creating count queries for Spring repositories #617

heruan opened this issue Aug 1, 2018 · 0 comments

Comments

@heruan
Copy link
Collaborator

heruan commented Aug 1, 2018

Description

Using BlazePersistenceRepositoryFactory with Spring Boot 2.0.4.RELEASE and Hibernate 5.2 integration, a repository with a count query throws an exception at app startup.

Expected behavior

No exception is thrown and the app starts with a working repository.

Actual behavior

Using BlazePersistenceRepositoryFactory with Spring Boot 2.0.4.RELEASE and Hibernate 5.2 integration, a repository with a count query such as

interface MyRepository extends Repository<MyEntity, String> {

   long countByAttribute(String attribute);

}

throws the following exception on app startup:

java.lang.IllegalArgumentException: Could not create query metamodel for method public abstract long UserRepository.countByPrimaryEmailAddress(java.lang.String)!
    at com.blazebit.persistence.spring.data.impl.repository.BlazePersistenceRepositoryFactory$CreateQueryLookupStrategy.resolveQuery(BlazePersistenceRepositoryFactory.java:190)
    at com.blazebit.persistence.spring.data.impl.repository.BlazePersistenceRepositoryFactory$CreateIfNotFoundQueryLookupStrategy.resolveQuery(BlazePersistenceRepositoryFactory.java:229)
    at org.springframework.data.repository.core.support.RepositoryFactorySupport$QueryExecutorMethodInterceptor.lookupQuery(RepositoryFactorySupport.java:553)
    at org.springframework.data.repository.core.support.RepositoryFactorySupport$QueryExecutorMethodInterceptor.lambda$mapMethodsToQuery$1(RepositoryFactorySupport.java:546)
Caused by: java.lang.IllegalArgumentException: DynamicSort must not be null!
    at org.springframework.util.Assert.notNull(Assert.java:193)
    at org.springframework.data.repository.query.parser.AbstractQueryCreator.createQuery(AbstractQueryCreator.java:94)
    at com.blazebit.persistence.spring.data.base.query.AbstractPartTreeBlazePersistenceQuery$CountQueryPreparer.invokeQueryCreator(AbstractPartTreeBlazePersistenceQuery.java:435)
    at com.blazebit.persistence.spring.data.base.query.AbstractPartTreeBlazePersistenceQuery$QueryPreparer.<init>(AbstractPartTreeBlazePersistenceQuery.java:224)
    at com.blazebit.persistence.spring.data.base.query.AbstractPartTreeBlazePersistenceQuery$CountQueryPreparer.<init>(AbstractPartTreeBlazePersistenceQuery.java:400)
    at com.blazebit.persistence.spring.data.base.query.AbstractPartTreeBlazePersistenceQuery.<init>(AbstractPartTreeBlazePersistenceQuery.java:82)
    at com.blazebit.persistence.spring.data.impl.query.PartTreeBlazePersistenceQuery.<init>(PartTreeBlazePersistenceQuery.java:38)
    at com.blazebit.persistence.spring.data.impl.repository.BlazePersistenceRepositoryFactory$CreateQueryLookupStrategy.resolveQuery(BlazePersistenceRepositoryFactory.java:187)
    ... 154 more

Steps to reproduce

  1. Create a new Spring project and add Blaze deps.
  2. Configure the app to use BlazePersistenceRepositoryFactory for repositories.
  3. Create a repository interface with a count query.
  4. Start the app.

Example project: https://github.com/heruan/spring-blaze

Environment

Version: 1.3.0-Alpha2
JPA-Provider: Hibernate 5.2
Spring Boot: 2.0.4.RELEASE

Worth noting that with Spring Boot 2.1.0.M1 and Hibernate 5.3 integration, the exception is not thrown.

@beikov beikov self-assigned this Aug 1, 2018
@beikov beikov added this to the 1.3.0 milestone Aug 1, 2018
heruan pushed a commit to heruan/blaze-persistence that referenced this issue Aug 1, 2018
heruan pushed a commit to heruan/blaze-persistence that referenced this issue Aug 1, 2018
heruan pushed a commit to heruan/blaze-persistence that referenced this issue Aug 1, 2018
@beikov beikov assigned heruan and unassigned beikov Aug 1, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants