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

[ISSUE] spring-data-jpa-simple has failing test #17777

Open
simbo1905 opened this issue Oct 8, 2024 · 1 comment
Open

[ISSUE] spring-data-jpa-simple has failing test #17777

simbo1905 opened this issue Oct 8, 2024 · 1 comment
Labels
on-jira triaged Issues reviewed by a dev and considered valid. Will be added in Jira.

Comments

@simbo1905
Copy link
Contributor

The article Introduction to Spring Data JPA which links to the code persistence-modules/spring-data-jpa-simple has a runtime bug.

Describe the Issue

Running all the tests has one failure for JpaProjectionIntegrationTest which is:

Error starting ApplicationContext. To display the condition evaluation report re-run your application with 'debug' enabled.
[2024-10-08 05:36:57,830]-[main] ERROR org.springframework.boot.SpringApplication - Application run failed
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'personRepository' defined in com.baeldung.jpa.projection.repository.PersonRepository defined in @EnableJpaRepositories declared on JpaRepositoriesRegistrar.EnableJpaRepositoriesConfiguration: Could not create query for public abstract com.baeldung.jpa.projection.view.PersonDto com.baeldung.jpa.projection.repository.PersonRepository.findByFirstName(java.lang.String); Reason: Failed to create query for method public abstract com.baeldung.jpa.projection.view.PersonDto com.baeldung.jpa.projection.repository.PersonRepository.findByFirstName(java.lang.String); Source must not be null or empty

To Reproduce

Steps to reproduce the behavior:

mvn -Dpmd.skip=true -Dtest=JpaProjectionIntegrationTest test

Expected Behavior

The test should pass.

Environment (please complete the following information):

mvn --version
Apache Maven 3.9.9 (8e8579a9e76f7d015ee5ec7bfcdc97d260186937)
Maven home: /usr/local/Cellar/maven/3.9.9/libexec
Java version: 23, vendor: GraalVM Community, runtime: /Users/consensussolutions/.sdkman/candidates/java/23-graalce
Default locale: en_GB, platform encoding: UTF-8
OS name: "mac os x", version: "15.0.1", arch: "x86_64", family: "mac"
@simbo1905
Copy link
Contributor Author

If i add the following @Query annotation:

@Query("SELECT new com.baeldung.jpa.projection.view.PersonDto(p.firstName, p.lastName) FROM Person p WHERE p.firstName = :firstName")
    PersonDto findByFirstName(@Param("firstName") String firstName);

Then four out of the five failing test methods pass.

@apeterlic apeterlic added the triaged Issues reviewed by a dev and considered valid. Will be added in Jira. label Oct 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
on-jira triaged Issues reviewed by a dev and considered valid. Will be added in Jira.
Projects
None yet
Development

No branches or pull requests

3 participants