Skip to content

Entity graph is not created for entity that has @EmbeddedId as an inner static class #264

@Disteonne

Description

@Disteonne

What steps will reproduce the problem ?

Steps to reproduce the behavior:

  1. Create an entity class with appropriate structure that has inner static class that's used as @EmbeddedId;
  2. Build the project to see the graph is generated

What is the expected output ?

Graphs for entity and composed entity id are generated

What happens instead ?

Build failed. Graph is not generated. Issue: package CompositeIdEntityGraph does not exists in CustomEntityGraph

Environment

  • spring-boot-starter-data-jpa: 3.5.4
  • hibernate-core: 6.6.22.Final
  • spring-data-jpa-entity-graph: 3.5.0

Additional context

Real case example:

@Entity
@Setter
public class Custom {

    @EmbeddedId
    CompositeId id;

    @ManyToOne
    @MapsId("firstObjectId")
    @JoinColumn(...)
    FirstObject fo;

    @ManyToOne
    @MapsId("seconfObjectId")
    @JoinColumn(...)
    SecondObject so;

    @Embeddable
    @Getter
    public static class CompositeId implements Serializable {
        UUID firstObjectId;
        UUID seconfObjectId;
    }
}

WA: It works if class is not static and placed outside it's root entity.

According to documentation, static classes are allowed to be used with @Embedded/@Embeddable annotations
https://docs.jboss.org/hibernate/orm/7.1/userguide/html_single/Hibernate_User_Guide.html#_component_embedded

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions