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

ONE_TO_MANY with cutom join columns should not require ID #3266

Open
erik-sab opened this issue Dec 16, 2024 · 0 comments
Open

ONE_TO_MANY with cutom join columns should not require ID #3266

erik-sab opened this issue Dec 16, 2024 · 0 comments

Comments

@erik-sab
Copy link

Issue description

With structure like:

@MappedEntity("foo")
public record Foo(
    @Id String id,
    @Nullable
        @Relation(Relation.Kind.ONE_TO_MANY)
        @JoinColumns({
          @JoinColumn(name = ID_COL, referencedColumnName = "foo_id")
        })
        List<Bar> bars,
@MappedEntity("bar")
public record Bar(
    @NonNull String anotherReferenceId,
    @NonNull String yetAnotherReferenceId,
    @NonNull String fooId,

The goal is to list Bar instances by fooId.

When trying to use this structure, it fails compilation with an error:

Unable to implement Repository method: FooRepository.getById(String id). Associated entity [Bar] defines no ID. Cannot join.

However join column is explicitly specified, therefore it should not be required.

Workaround: Create composite ID from all 3 reference fields in Bar - then join works as expected.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant