Skip to content

asOf() bean caching #3713

@dragkes

Description

@dragkes

Hello. I have encountered what appears to be an issue with query caching behavior when using asOf() in combination with lazy loading.

When lazily loading associations of beans fetched via asOf(), the lazy loading queries appear to consult the bean cache. As a result, the returned beans may reflect the current state rather than the historical state defined by asOf(). This leads to incorrect results, since the bean cache only contains the latest versions of entities and not their historical snapshots. This behavior seems unintended for temporal queries.

It also appears that lazy loading queries do not propagate cache-related settings from the original query. Even when the original query explicitly disables bean caching using:

query.setBeanCacheMode(CacheMode.OFF);

the corresponding lazy loading queries still execute with CacheMode.AUTO (the default).

Conceptually, it seems safer to completely disable the bean cache for asOf() queries and ignore related cache configuration options, as caching and temporal consistency are fundamentally at odds in this case.

Additionally, there currently seems to be no way to explicitly configure caching behavior for lazy loading queries. Would it make sense to propagate cache-related options from the parent query to all lazy loading queries?

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