Skip to content

Commit 50bbc80

Browse files
committed
HHH-16048 add 'hibernate.query.hql.portable_integer_division'
update doc
1 parent d7fe316 commit 50bbc80

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

documentation/src/main/asciidoc/querylanguage/Expressions.adoc

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -323,7 +323,15 @@ When both operands of a binary numeric operator have the same type, the result t
323323

324324
[WARNING]
325325
====
326-
Thus, `3/2` performs integer division and evaluates to `1`.
326+
By default, the semantics of integer division depend on the database:
327+
328+
- On most databases, division of an integer by an integer evaluates to an integer, just like in Java.
329+
Thus, `3/2` evaluates to `1`.
330+
- But on some databases, including Oracle, MySQL, and MariaDB, integer division may result in a non-integral value.
331+
So `3/2` evaluates to `1.5` on these databases.
332+
333+
This default behavior may be changed using configuration property `hibernate.query.hql.portable_integer_division`.
334+
Setting this property to `true` instructs Hibernate to produce SQL that emulates Java-style integer division (that is, `3/2 = 1`) on platforms where that is not the native semantics.
327335
====
328336

329337
When the operands are of different type, one of the operands is implicitly converted to _wider_ type, with wideness given, in decreasing order, by the list below:

0 commit comments

Comments
 (0)