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

Provide better handling of incompatible visibilities between domain type and repository #2989

Open
rweisleder opened this issue Nov 27, 2023 · 0 comments
Assignees
Labels
type: enhancement A general enhancement

Comments

@rweisleder
Copy link
Contributor

Related to #2526

Given a package-private entity

@Entity
class Book {

    @Id
    private String isbn;

    // no-args-constructor, getter, setter etc.
}

and a public repository with a custom findBy method

public interface BookRepository extends CrudRepository<Book, String> {

    Book findByIsbn(String isbn);
}

then the invocation of the findBy method fails with an error message that is more cryptic than helpful:

java.lang.IllegalAccessError: failed to access class org.example.Book from class jdk.proxy2.$Proxy105 (org.example.Book is in unnamed module of loader 'app'; jdk.proxy2.$Proxy105 is in module jdk.proxy2 of loader 'app')

The cause comes from the different visibilities. If the entity is public or the repository is package-private, it works.

I would expect this construct to work out of the box, because if the repository is package-private, it works again. Or provide a helpful error message at startup indicating the incompatible visibilities.

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Nov 27, 2023
@mp911de mp911de added type: enhancement A general enhancement and removed status: waiting-for-triage An issue we've not yet triaged labels Nov 27, 2023
@mp911de mp911de self-assigned this Nov 27, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: enhancement A general enhancement
Projects
None yet
Development

No branches or pull requests

3 participants