[JIRA] (HHH-13908) Hibernate makes incorrect assumption that TIME() function has type Date (should be String) [TEST CASE]
by Archie Cobbs (JIRA)
Archie Cobbs ( https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=557058%... ) *created* an issue
Hibernate ORM ( https://hibernate.atlassian.net/browse/HHH?atlOrigin=eyJpIjoiODBlNTZlNzE3... ) / Bug ( https://hibernate.atlassian.net/browse/HHH-13908?atlOrigin=eyJpIjoiODBlNT... ) HHH-13908 ( https://hibernate.atlassian.net/browse/HHH-13908?atlOrigin=eyJpIjoiODBlNT... ) Hibernate makes incorrect assumption that TIME() function has type Date (should be String) [TEST CASE] ( https://hibernate.atlassian.net/browse/HHH-13908?atlOrigin=eyJpIjoiODBlNT... )
Issue Type: Bug Affects Versions: 5.4.12 Assignee: Unassigned Components: hibernate-entitymanager Created: 25/Mar/2020 15:56 PM Labels: criteria Priority: Major Reporter: Archie Cobbs ( https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=557058%... )
The MySQL TIME() function returns a String, as is documented here ( https://dev.mysql.com/doc/refman/8.0/en/date-and-time-functions.html#func... ) :
>
>
>
> Extracts the time part of the time or datetime expression expr and returns
> it as a string.
>
>
Therefore, one would expect this CriteriaQuery logic, which is doing a comparison between two String values, to work:
cq.select(foo)
.where(cb.lessThanOrEqualTo(
cb.function("TIME", String.class, foo.get(Foo_.startTime)), "17:00:00"));
However, when executing that query Hibernate throws this exception:
java.lang.IllegalArgumentException: Parameter value [17:00:00] did not match expected type [java.util.Date (n/a)]
at org.hibernate.query.spi.QueryParameterBindingValidator.validate(QueryParameterBindingValidator.java:54)
at org.hibernate.query.spi.QueryParameterBindingValidator.validate(QueryParameterBindingValidator.java:27)
at org.hibernate.query.internal.QueryParameterBindingImpl.validate(QueryParameterBindingImpl.java:90)
at org.hibernate.query.internal.QueryParameterBindingImpl.setBindValue(QueryParameterBindingImpl.java:55)
at org.hibernate.query.internal.AbstractProducedQuery.setParameter(AbstractProducedQuery.java:489)
at org.hibernate.query.internal.AbstractProducedQuery.setParameter(AbstractProducedQuery.java:110)
at org.hibernate.query.criteria.internal.compile.CriteriaCompiler$1$1.bind(CriteriaCompiler.java:135)
at org.hibernate.query.criteria.internal.CriteriaQueryImpl$1.buildCompiledQuery(CriteriaQueryImpl.java:360)
at org.hibernate.query.criteria.internal.compile.CriteriaCompiler.compile(CriteriaCompiler.java:165)
at org.hibernate.internal.AbstractSharedSessionContract.createQuery(AbstractSharedSessionContract.java:742)
at org.hibernate.internal.AbstractSessionImpl.createQuery(AbstractSessionImpl.java:23)
at org.hibernate.bugs.JPAUnitTestCase.hhh123Test(JPAUnitTestCase.java:48)
Note that I've explicitly specified String.class as the function's return type. And in fact, if you replace the function name "TIME" with something else (e.g., "FOOBAR" ) the query compiles just fine. So Hibernate must have some built-in assumption that the TIME() function on every database returns a value of type Date , not String.
But obviously that's incorrect in the case of MySQL.
So it seems like one of the following fixes is needed here:
* Disable any built-in implicit assumptions about the TIME() function having type Date - i.e., always trust what the caller says is the function's return type in CriteriaBuilder.function().
* Move the TIME() function's return type assumption into the dialect
*I have a test case here:*
https://github.com/archiecobbs/hibernate-test-case-templates/tree/time-fu...
( https://hibernate.atlassian.net/browse/HHH-13908#add-comment?atlOrigin=ey... ) Add Comment ( https://hibernate.atlassian.net/browse/HHH-13908#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=EmailN... ) This message was sent by Atlassian Jira (v1001.0.0-SNAPSHOT#100122- sha1:092c6a7 )
4 years, 9 months
[JIRA] (HSEARCH-3871) Always enable delayed commits in the Lucene backend
by Yoann Rodière (JIRA)
Yoann Rodière ( https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=557058%... ) *created* an issue
Hibernate Search ( https://hibernate.atlassian.net/browse/HSEARCH?atlOrigin=eyJpIjoiY2RjZjQ3... ) / Improvement ( https://hibernate.atlassian.net/browse/HSEARCH-3871?atlOrigin=eyJpIjoiY2R... ) HSEARCH-3871 ( https://hibernate.atlassian.net/browse/HSEARCH-3871?atlOrigin=eyJpIjoiY2R... ) Always enable delayed commits in the Lucene backend ( https://hibernate.atlassian.net/browse/HSEARCH-3871?atlOrigin=eyJpIjoiY2R... )
Issue Type: Improvement Assignee: Yoann Rodière ( https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=557058%... ) Components: backend-lucene Created: 25/Mar/2020 09:50 AM Fix Versions: 6.0.0.Beta-backlog-high-priority Priority: Major Reporter: Yoann Rodière ( https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=557058%... )
Let's start by saying that delayed commits are nothing to be afraid of. When they are enabled, write operations that require an immediate commit (e.g. automatic indexing by default) are still committed immediately. The delayed commits are only effective when some write operations do *not* perform an immediate commit. In that case, the user already decided to take the chance of losing data in the event of a crash, so waiting 1 second before the commit will not change much to the data safety.
It does change much when it comes to performance, though. Instead of committing e.g. every 100 operations, we commit e.g. every second: maybe no additional operation will be performed by then, in which case which case performance is the same, but maybe thousands of write operations will have be performed by then, in which case we just reduced commits by a factor 10... and probably increased throughput by the same factor.
With that in mind... *not* enabling delayed commits is becoming a problem. Early numbers from the performance tests on HSEARCH-3822 ( https://hibernate.atlassian.net/browse/HSEARCH-3822 ) In Progress show that any improvement to the performance when delayed commits are enabled will probably lead to massive performance regressions when delayed commits are *not* enabled. We're talking about doubling the throughput when delayed commit are enabled, while dividing it by a factor 10 when delayed commits are disabled.
The reason for the regressions is that we have to commit after each batch of writes when delayed commits are disabled, and the improvements are about performing multiple, but smaller batche of writes in parallel. So when delayed commits are disabled, the "improvements" actually increase the amount of commits. When delayed commits are enabled, they do not.
( https://hibernate.atlassian.net/browse/HSEARCH-3871#add-comment?atlOrigin... ) Add Comment ( https://hibernate.atlassian.net/browse/HSEARCH-3871#add-comment?atlOrigin... )
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=EmailN... ) This message was sent by Atlassian Jira (v1001.0.0-SNAPSHOT#100122- sha1:092c6a7 )
4 years, 9 months