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

allow @NamedQuery and @NamedNativeQuery more control over query execution #473

Open
gavinking opened this issue Aug 19, 2023 · 0 comments · May be fixed by #662
Open

allow @NamedQuery and @NamedNativeQuery more control over query execution #473

gavinking opened this issue Aug 19, 2023 · 0 comments · May be fixed by #662
Labels
candidate-for-4 Good candidate for JPA 4

Comments

@gavinking
Copy link
Contributor

Currently, a @NamedQuery or @NamedNativeQuery may specify query hints using the verbose and stringly-typed annotation @QueryHint.

I propose making certain "hints" available in a typesafe way, for example:

public @interface NamedQuery {
    ...
    FlushModeType flushMode() default AUTO;
    CacheStoreMode cacheStoreMode() default USE;
    CacheRetrieveMode cacheRetrieveMode() default USE;
    int timeout() default -1;
}

In the case of @NamedNativeQuery, it might even be useful to add a way to specify the tables or entities affected by a native query, to allow auto-flush to work correctly:

public @interface NamedNativeQuery {
    ...
    FlushModeType flushMode() default AUTO;
    CacheStoreMode cacheStoreMode() default USE;
    CacheRetrieveMode cacheRetrieveMode() default USE;
    int timeout() default -1;

   // control over auto-flush

    String[] affectedTables() default {};
    Class<?>[] affectedEntities() default {};
}
@gavinking gavinking added the candidate-for-4 Good candidate for JPA 4 label Feb 28, 2024
gavinking added a commit to gavinking/jpa-api that referenced this issue Sep 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
candidate-for-4 Good candidate for JPA 4
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant