-
-
Notifications
You must be signed in to change notification settings - Fork 3.7k
HHH-15942 introduce ForcedFlushMode #5851
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
Conversation
…ushes or not - replaces FlushModeType in the annotation package - much less confusing when applied to a Query * what do MANUAL and COMMIT mean for a Query? * how is AUTO useful for a Query? - also make Query.getHibernateFlushMode() obey its documented semantics by returning the session flush mode instead of null when unset
436e4bf to
6e0def0
Compare
| .setTimeout( namedNativeQuery.timeout() < 0 ? null : namedNativeQuery.timeout() ) | ||
| .setFetchSize( namedNativeQuery.fetchSize() < 0 ? null : namedNativeQuery.fetchSize() ) | ||
| .setFlushMode( getFlushMode( namedNativeQuery.flushMode() ) ) | ||
| .setFlushMode( getFlushMode( namedNativeQuery.flush(), namedNativeQuery.flushMode() ) ) |
Check notice
Code scanning / CodeQL
Deprecated method or constructor invocation
| .setTimeout( namedQuery.timeout() < 0 ? null : namedQuery.timeout() ) | ||
| .setFetchSize( namedQuery.fetchSize() < 0 ? null : namedQuery.fetchSize() ) | ||
| .setFlushMode( getFlushMode( namedQuery.flushMode() ) ) | ||
| .setFlushMode( getFlushMode( namedQuery.flush(), namedQuery.flushMode() ) ) |
Check notice
Code scanning / CodeQL
Deprecated method or constructor invocation
| * to flush, depending on its {@link FlushMode}. | ||
| */ | ||
| NO_FORCING | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Everyone, please take a look at this new thing!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Given that this is solely about queries, I'd be more inclined to name this QueryFlushMode or move it into o.h.query. For QueryFlushMode, I'd go with:
enum QueryFlushMode {
FLUSH,
SKIP,
/**
* Defer to {@link Session#getHibernateFlushMode}
*/
AUTO
}
I get why you named it as you did. I just find it confusing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
QueryFlushModeis fine by me, it was also my first thought.- You're right, I agree it belongs in
o.h.query. FLUSHis fine.SKIPI don't find extremely clear though I could live with it.- I don't like
AUTOhere because it doesn't have the same semantics asFlushMode.AUTO.
Both of those are pseudonyms for never wrt a Query
AUTO is actually the default for a Query. Not sure what you are asking there tbh |
|
So iiuc this basically adds a whole new enum that just limits the set of values from another enum for use in a specific context. |
Yes of course, I know that, but it's nonobvious to a casual onlooker.
What I'm saying is there's too many things there and it's hard for the user to pick the right one. If I'm going to set this at the level of a query (rather than at the level of the session, where all of the values are useful) then I'm setting it because I either want to:
|
| // covariant overrides - CommonQueryContract | ||
|
|
||
| @Override | ||
| Query<R> setHibernateFlushMode(FlushMode flushMode); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a reason this is not deprecated? It seems to me the intent here is to replace FlushMode when used in the context of a Query
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I could deprecate it if you prefer.
It replaces |
|
I mean, to clarify, my first draft of this was to just deprecate |
|
Should we clarify how and if such new options are affected by the configuration properties? For example we have property |
|
@Sanne you mean the query hint? That is unaffected by this proposal because it's mostly a JPA thing. When using Hibernate-native APIs we don't need hints. I think there's also a config property but IIRC it's just a default value for that hint. (And I don't consider it a useful thing.) This proposal is very much only affecting the native APIs. |
|
I'm referring to the configuration property If they have no relation that's totally fine, but I think that should be made clear. |
Yeah, OK, you're right, it is actually a session-level setting, not a query hint, even though:
Actually I think we should deprecate this thing, I don't see how it's useful, and honestly it almost looks like it got there by accident.
This proposal has no relation at all to the session-level flush mode, that's correct. |
Actually it's fine, as a |
|
superseded by #8954 |
for specifying whether a query flushes or not:
replaces
FlushModeTypein the annotation packagemuch less confusing when applied to a
QueryMANUALandCOMMITmean for aQuery?AUTOuseful for aQuery?also make
Query.getHibernateFlushMode()obey its documented semantics by returning the session flush mode instead of null when unset