Can not refer to attribute for the target type that has inheritance

Hi, I am trying to use EntityGraph to avoid n+1 problem, but currently can not refer to the target property that has inheritance. Here is my entity class definition:

@NamedEntityGraph(
        name = "module.full",
        attributeNodes = {
                @NamedAttributeNode(value = "units", subgraph = "module-unit.full")     
        },
        subgraphs = {
                @NamedSubgraph(
                        name = "module-unit.full",
                        attributeNodes = { @NamedAttributeNode("contents") }
                )
        }
)
public class Module extends AbstractUuidAuditable {

    @Serial
    private static final long serialVersionUID = 1639445282116842021L;

    @OneToMany(fetch = FetchType.LAZY, mappedBy = "module", cascade = CascadeType.ALL, orphanRemoval = true)
    private Set<ModuleUnit> units = new HashSet<>();

}

Error is happening with attribute “contents” which defined in class that extends ModuleUnit.

Please share the full entity mappings, including this ModeuleUnit class and the entity which defines the contents property. This might be a bug, have you tried with Hibernate’s latest stable version? If you’re still getting an error, please try to create a reproducer with our test case template and if you are able to reproduce the issue, create a new ticket in our issue tracker and attach that reproducer.

Hi, sorry for being late. I am currently getting the error with hibernate 6.4.4.Final. Also tried with version 6.6.0.Final - nothing changed.
Here is module unit class definition and class that’s inherit it:

@Entity
@Getter
@Setter
@NoArgsConstructor
@AllArgsConstructor
@Table(name = "module_unit")
@DiscriminatorColumn(name = "type")
@Inheritance(strategy = InheritanceType.SINGLE_TABLE)
public abstract class ModuleUnit extends AbstractUuidAuditable {

    @Serial
    private static final long serialVersionUID = -3729255696302813236L;

    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "module_id")
    private Module module;

    @Column(name = "type", nullable = false, insertable = false, updatable = false)
    private String type;

    @Column(name = "ordinal_number", nullable = false)
    private Integer ordinalNumber;
}
@Entity
@Getter
@Setter
@NoArgsConstructor
@AllArgsConstructor
@DiscriminatorValue(value = "EXTENDER")
public class ModuleUnitExtender extends ModuleUnit {

    @Serial
    private static final long serialVersionUID = -8386189605145250660L;

    @OneToMany(mappedBy = "content", fetch = FetchType.LAZY, cascade = CascadeType.ALL, orphanRemoval = true)
    private Set<Content> contents = new HashSet<>()
}

I still don’t see the full picture, is the content attribute defined in the AbstractUuidAuditable class?

Also tried with version 6.6.0.Final - nothing changed.

This means there might be a bug in the current version as well. As I suggested previously, please create a reproducer and attach it to a new Jira issue and someone will look into it if possible.

Propperty contents is defined in ModuleUnitExtender.class. Ok I will try to create reproducer later