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

Quarkus Spring JPA Repository query methods is not working, at least like in Spring Boot #10581

Closed
nebrass opened this issue Jul 8, 2020 · 6 comments · Fixed by #10619
Closed
Labels
area/spring Issues relating to the Spring integration kind/bug Something isn't working
Milestone

Comments

@nebrass
Copy link

nebrass commented Jul 8, 2020

Describe the bug
I have these Java classes:
A MappedSuperclass AbstractEntity that is a superclass for all JPA entities:

@MappedSuperclass
public abstract class AbstractEntity implements Serializable {

    private static final long serialVersionUID = 1L;

    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    private Long id;
...
}

And these JPA entity classes:

The Order class:

@Entity
@Table(name = "orders")
public class Order extends AbstractEntity {
...
    @OneToOne
    @JsonIgnore
    private Cart cart;
...
}

The Cart class:

@Entity
@Table(name = "carts")
public class Cart extends AbstractEntity {

    @ManyToOne
    private Customer customer;
...
}

And finally the Customer class:

@Entity
@Table(name = "customers")
public class Customer extends AbstractEntity {

...
}

I have a JpaRepository to find orders using the Customer Id:

@Repository
public interface OrderRepository extends JpaRepository<Order, Long> {
    List<Order> findByCartCustomerId(Long customerId);
}

Expected behavior
This Query Method needs to be working as it is actually working in Spring Boot framework with Spring Data JPA.

Actual behavior
Runtime exception is thrown:

2020-07-08 18:34:00,858 ERROR [io.qua.dep.dev.DevModeMain] (main) Failed to start Quarkus: java.lang.RuntimeException: io.quarkus.builder.BuildException: Build failure: Build failed due to errors
	[error]: Build step io.quarkus.spring.data.deployment.SpringDataJPAProcessor#build threw an exception: io.quarkus.spring.data.deployment.UnableToParseMethodException: Entity com.targa.labs.quarkus.myboutique.domain.Order does not contain a field named: CartCustomerId. Offending method is findByCartCustomerId

To Reproduce
Steps to reproduce the behavior:

  1. Create new Quarkus app with: Hibernate ORM and Quarkus Extension for Spring Data JPA API dependencies. For DB I used Postgresql
  2. Add these classes
  3. run mvn quarkus:dev

Configuration

quarkus.datasource.db-kind=postgresql
quarkus.hibernate-orm.dialect=org.hibernate.dialect.PostgreSQL10Dialect
quarkus.hibernate-orm.log.sql=true
quarkus.datasource.username=developer
quarkus.datasource.password=p4SSW0rd
quarkus.datasource.jdbc.url=jdbc:postgresql://localhost:5432/demo
quarkus.hibernate-orm.database.generation=drop-and-create

Screenshots
None

Environment (please complete the following information):

  • Output of uname -a or ver: Darwin MacBook-Pro-de-Nebrass.local 19.5.0 Darwin Kernel Version 19.5.0: Tue May 26 20:41:44 PDT 2020; root:xnu-6153.121.2~2/RELEASE_X86_64 x86_64
  • Output of java -version: OpenJDK 64-Bit Server VM GraalVM CE 20.1.0 (build 11.0.7+10-jvmci-20.1-b02, mixed mode, sharing)
  • GraalVM version (if different from Java):
  • Quarkus version or git rev: 1.5.2.Final
  • Build tool (ie. output of mvnw --version or gradlew --version): 3.6.3

Additional context
(Add any other context about the problem here.)

@nebrass nebrass added the kind/bug Something isn't working label Jul 8, 2020
@quarkusbot quarkusbot added the area/spring Issues relating to the Spring integration label Jul 8, 2020
@quarkusbot
Copy link

/cc @geoand

@geoand
Copy link
Contributor

geoand commented Jul 8, 2020

Thanks for reporting, I'll take a look next week

@nebrass
Copy link
Author

nebrass commented Jul 8, 2020

Thank you @geoand 😊

@geoand
Copy link
Contributor

geoand commented Jul 8, 2020

@ebullient in the meantime if you want to have a look, I won't stop you :)

@nebrass
Copy link
Author

nebrass commented Jul 9, 2020

@geoand I made a try for the fix 😁 can you take a look please ?

@geoand
Copy link
Contributor

geoand commented Jul 9, 2020

Thanks! I'm on PTO, so I'll check when I get back

@gsmet gsmet added this to the 1.7.0 - master milestone Jul 17, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/spring Issues relating to the Spring integration kind/bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants