[
https://issues.jboss.org/browse/WFLY-10520?page=com.atlassian.jira.plugin...
]
Gail Badner commented on WFLY-10520:
------------------------------------
[~smarlow], regarding {{setFirstResult( -1 )}}, I'd like to clarify what I've done
and why.
If (untransformed) {{org.hibernate.Query#setFirstResult( int )}} is called with a negative
argument...
In 5.1,
* {{org.hibernate.Query#getFirstResult( )}} will return the same negative value;
* when the query is executed, the first result retrieved will be at position 0 of the
query results.
In 5.3,
* {{IllegalArgumentException}} is thrown as specified by JPA.
I could not restore both 5.1 behaviors in 5.3 (at least not without an overly complicated
fix). I was able to restore the more important behavior (IMO) by calling
{{setHibernateFirstResult( 0 )}}. By doing that, when the query is executed, the first
result retrieved will be at position 0 of the query results.
I did this because I didn't think it should be necessary for an application to be
modified because it calls {{org.hibernate.Query#setFirstResult( int )}} with a negative
argument, when it is easy for the transformer to do the right thing with respect to
pagination.
After transforming, pagination will work the same as in 5.1, but
{{org.hibernate.Query#getFirstResult()}} will return 0, instead of the negative value the
application used when it called {{org.hibernate.Query#setFirstResult( int )}}.
I think it is unlikely that an application would even call
{{org.hibernate.Query#getFirstResult()}}, but if it does, it will get an unexpected
result, (0).
IMO, this can be handled by documenting this point
{org.hibernate.Query#setHibernateFirstResult}} in the migration guide, as well as in the
transformer documentation. It is already documented in the Javadoc. I suppose that
Hibernate could also log an INFO or WARNING message when {{setHibernateFirstResult}} is
called with a negative value.
Add Hibernate ORM 5.3 compatibility transformer
-----------------------------------------------
Key: WFLY-10520
URL:
https://issues.jboss.org/browse/WFLY-10520
Project: WildFly
Issue Type: Task
Components: JPA / Hibernate
Reporter: Gail Badner
Assignee: Scott Marlow
Fix For: 14.0.0.CR1
A compatibility transformer needs to be added to address Hibernate ORM 5.3 API methods
that are no longer compatible with 5.1.
From
https://docs.google.com/document/d/1cAVBdeQXQfpTwH0f_GKSahh_gRd7bKI6kII-w...
# Change call to org.hibernate.BasicQueryContract.getFlushMode() to instead call
BasicQueryContract.getHibernateFlushMode().
# Change call to org.hibernate.Session.getFlushMode, to instead call
Session.getHibernateFlushMode()
# Modify calls to org.hibernate.Query.getFirstResult() to convert returned int, to
Integer result.
# Modify calls to org.hibernate.Query.getMaxResults() to convert returned int, to Integer
result, if returned int value is <= 0, null should be used, if Integer.MAX_VALUE is,
the transformer should replace with null reference.
# App References to Enum org.hibernate.FlushMode.NEVER (0) should be transformed to
reference FlushMode.MANUAL (0) instead.
# For call to org.hibernate.Query.setMaxResults(int), instead call
org.hibernate.Query.setHibernateMaxResults(int) which will be added soon to ORM 5.3.
--
This message was sent by Atlassian JIRA
(v7.5.0#75005)