Alias locking updates #3979
Replies: 2 comments 8 replies
-
I think this is fine, as long as we detect and produce a meaningful error ourselves, instead of just passing it through to the database and getting a nasty error that looks like we have a bug. |
Beta Was this translation helpful? Give feedback.
-
I added the checks as part of the following PR, so I'll lock and close this discussion: #4009 |
Beta Was this translation helpful? Give feedback.
-
In Hibernate 5 a query like
select a.value from Entity a
will never apply an alias lock fora
to the SQL. The logic in 5 only applies the locking to the SQL if the entity is actually selected e.g.select a.value, a from Entity a
orselect a from Entity a
which is kind of limiting.In 6 we could fix this and apply the locks. There is one backwards compatibility concern though. Since no database supports applying locks if an aggregate function is involved, a query like
select sum(a.value) from Entity a
could suddenly fail if it uses an alias lock fora
. In 5, the lock mode is just ignored, but for 6 we would render it through and the database will complain.Steve and I were discussing this a bit and we generally agree that this is a "fix" rather than a possible regression, but wanted to start a discussion so that others can participate as well.
Any thoughts on this topic?
Beta Was this translation helpful? Give feedback.
All reactions