Marcus Klimstra (
https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=557058%...
) *updated* an issue
Hibernate ORM (
https://hibernate.atlassian.net/browse/HHH?atlOrigin=eyJpIjoiYWNmMTU0OTNm...
) / Bug (
https://hibernate.atlassian.net/browse/HHH-16737?atlOrigin=eyJpIjoiYWNmMT...
) HHH-16737 (
https://hibernate.atlassian.net/browse/HHH-16737?atlOrigin=eyJpIjoiYWNmMT...
) Interpretation of numeric literals without explicit type suffix (
https://hibernate.atlassian.net/browse/HHH-16737?atlOrigin=eyJpIjoiYWNmMT...
)
Change By: Marcus Klimstra (
https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=557058%...
)
This could be either a documentation or implementation issue.
Section “16.3.3. Numeric literals” of the documentation shows some examples of numeric
literals, with and without explicit type suffixes:
* “1” is indicated as a “simple integer literal”;
* “1L” is a “simple integer literal, typed as a long”;
* “100.5” is “decimal notation”;
* “100.5F” is “decimal notation, typed as a float”;
* “1e+2” is “scientific notation”;
* “1e+2F” is “scientific notation, typed as a float”.
It also states that “It’s not usually necessary to specify the precision explicitly.”
The problem I have with this is that it does not state how literals are interpreted when
the type suffix is not specified.
My initial reading was that “100.5” would be interpreted as a BigDecimal. This is because
the term “decimal” itself is a bit ambiguous, and the example is distinguished from the
next one, which is indicated as “typed as float”.
However, it seems that it is in fact interpreted as float. I ran into this with a value
that cannot be exactly represented as a float:
{{SELECT b.isbn, b.title, b.score , b.author.firstName FROM Book b WHERE b.score =
199999.99}}
Is translated to:
{{select b1_0.ISBN_,b1_0.TITLE_,b1_0.SCORE_ ,a1_0.FIRST_NAME_ from BOOK b1_0 join AUTHOR
a1_0 on a1_0.id=b1_0.author_id where b1_0.SCORE_=199999.98}}
(Note that Book.score is a BigDecimal in the Java model class)
So IMO it would help if the documentation would explicitly state how such literals are
interpreted. One might also wonder if float (rather than say, double) is a good default
representation.
(
https://hibernate.atlassian.net/browse/HHH-16737#add-comment?atlOrigin=ey...
) Add Comment (
https://hibernate.atlassian.net/browse/HHH-16737#add-comment?atlOrigin=ey...
)
Get Jira notifications on your phone! Download the Jira Cloud app for Android (
https://play.google.com/store/apps/details?id=com.atlassian.android.jira....
) or iOS (
https://itunes.apple.com/app/apple-store/id1006972087?pt=696495&ct=Em...
) This message was sent by Atlassian Jira (v1001.0.0-SNAPSHOT#100225- sha1:40c4da4 )