| Using FlushModeType.AUTO, I would expect the persistence context to get flushed, whenever I have some pending updates on related entities contained in an entityGraphHinted HQL-query. The entities are not themselves within the named query definition string, but because the NamedEntityGraph has includeAllAttributes set to true, all related entities are joined (and they are). I found out by debugging however, that the QuerySpace only contained the toplevel entity (XBV_KLANT in the example below), and not the related ones (KlantrelatieJpa e.g.). This resulted in the persistence context NOT getting flushed before query execution, even if there is a pending update on KlantrelatieJpa within the persistence context. See autoFlushIfRequired method in org.hibernate.internal.SessionImpl This seems a bug to me. All related entities should have been added to the QuerySpace in the process of creating and analyzing the AST, right? Correct? Example code: @Table(name = "XBV_KLANT") @Entity @NamedQueries( { @NamedQuery(name = "KlantJpa.getById", query = "select DISTINCT k from KlantJpa k WHERE k.identificatie = :klantIdentificatie ") } ) public class KlantJpa extends AbstractEntityJpa { @Id @Column(name = "KLT_IDENTIFICATIE", nullable = false) private Long identificatie; @Column(name = "KLT_SOUNDEXNAAM", nullable = false) private String soundexnaam; @OneToMany(mappedBy = "van", cascade = {CascadeType.ALL }, orphanRemoval = true) private final Set<KlantrelatieJpa> vanKlantrelatie = new HashSet<KlantrelatieJpa>(); @OneToOne(mappedBy = "klant", cascade = {CascadeType.ALL } , orphanRemoval = true) private PersoonsGegevensGbaJpa persoonsGegevensGBA; @OneToOne(mappedBy = "klant", cascade = {CascadeType.ALL }, orphanRemoval = true) private PersoonsGegevensNietGbaJpa persoonsGegevensNietGBA; @OneToOne(mappedBy = "klant", cascade = {CascadeType.ALL } , orphanRemoval = true) private AdresGegevensGbaJpa adresGegevensGBA; @OneToOne(mappedBy = "klant", cascade = {CascadeType.ALL }, orphanRemoval = true) private AdresGegevensNietGbaJpa adresGegevensNietGBA; @OneToOne(mappedBy = "klant", cascade = {CascadeType.ALL } , orphanRemoval = true) private AdresGegevensBuitenlandJpa adresGegevensBuitenlandJpa; ... |