spring-projects / spring-projects/spring-data-relational

More clear error message when `select` entities with Builder but no default constructors [DATAJDBC-298]

Open
#523 0 comments 0 reactions 1 assignee View on GitHub

@schauder is already working on this.

Since Dec 31, 2020.

type: enhancement
Dominant language
Java
Stars
827
Forks
394
PR merge metrics
No merged PRs in 30d

Description

Yuxin Bai opened DATAJDBC-298 and commented

This is a many-to-many relationship that use IDs in a reference table to link two entities, Mirror and MirrorRequester. One of the entities MirrorRequester has a Set to represent one-to-many relationship with the reference table MirrorReference.

We are using Lombok @Builder in our codebase. When we do findAll() on MirrorRequester, we are getting this error: java.lang.IllegalStateException: Required identifier property not found for class com.sample.springdatajdbcschema.MirrorReference!.

This error goes away when we add @NoArgsConstructor(needed by spring-data-jdbc I assume) and @AllArgsConstructor(needed by lombok builder) to MirrorRequester alongside with @Builder.

 

Sample project here: https://github.com/LittleBaiBai/spring-data-jdbc-sample

Instead of adding lombok to the dependencies, I used the generated code in the sample project.

There are two commits, first one is the failing test commit without default constructor, and second one is passing with default constructor. 


Reference URL: https://github.com/LittleBaiBai/spring-data-jdbc-sample

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.