[hibernate-commits] [hibernate/hibernate-search] 38fc9b: HSEARCH-2382 Merge the JPA and Hibernate-native Fu...

GitHub noreply at github.com
Thu Apr 13 08:59:08 EDT 2017


  Branch: refs/heads/master
  Home:   https://github.com/hibernate/hibernate-search
  Commit: 38fc9b864e6a279eccb84a15c14002dce61df4fa
      https://github.com/hibernate/hibernate-search/commit/38fc9b864e6a279eccb84a15c14002dce61df4fa
  Author: Yoann Rodière <yoann at hibernate.org>
  Date:   2017-04-13 (Thu, 13 Apr 2017)

  Changed paths:
    M orm/src/main/java/org/hibernate/search/FullTextQuery.java
    M orm/src/main/java/org/hibernate/search/jpa/FullTextQuery.java
    M orm/src/main/java/org/hibernate/search/jpa/impl/FullTextEntityManagerImpl.java
    R orm/src/main/java/org/hibernate/search/jpa/impl/FullTextQueryImpl.java
    R orm/src/main/java/org/hibernate/search/jpa/impl/OptimisticLockingCompatibilityHelper.java
    M orm/src/main/java/org/hibernate/search/query/hibernate/impl/FullTextQueryImpl.java
    M orm/src/test/java/org/hibernate/search/test/query/timeout/TimeoutTest.java

  Log Message:
  -----------
  HSEARCH-2382 Merge the JPA and Hibernate-native FullTextQuery implementations

This doesn't change the interfaces, but may change the exception
handling.

Why? Hibernate ORM and JPA haven't always had consistent behaviors, but
it used not to matter because there were different APIs that could be
implemented differently anyway. Now that the two implementations are
merged, there has some choice to be made, and unfortunately this hasn't
been done in a fully consistent way in Hibernate ORM.

Here are some quirks in Hibernate ORM:

 * Some JPA methods behave according to the JPA spec, unless Hibernate
was booted using its native booting mode
(getProducer().getFactory().getSessionFactoryOptions().isJpaBootstrap()
returns false), in which case they may throw Hibernate exceptions.
This is the case for getSingleResult() in particular.
 * Some Hibernate native methods behave according to the JPA spec,
regardless of the booting mode. For instance list() will always convert
Hibernate exceptions to JPA ones.

With that in mind, it's not easy to find a consistent behavior for our
own methods.

Here are some rules I followed:

 * For methods that were already implemented in Hibernate ORM, and whose
implementation was suitable for Hibernate Search, I just delegated to the
Hibernate ORM implementation and didn't override anything.
 * For methods that we have to re-implement in Hibernate Search (e.g.
list()), I replicated the exact same exception handling and delegated to
Hibernate ORM when possible (e.g. for exception conversion), even if we
used to have our own exception conversion code. That's because I suspect
this code had been copied over from an older Hibernate ORM
implementation.
 * For Hibernate Search-specific methods that used to have different
behaviors in the native and JPA implementations, I tried to favor the
JPA behavior regardless of the booting mode. For instance getResultSize()
will throw JPA exceptions, not native ones. If we must break stuff, we
may as well do it in a standard way.


  Commit: 8cb676fb6c357e230d1107aa5b88c46ab363b653
      https://github.com/hibernate/hibernate-search/commit/8cb676fb6c357e230d1107aa5b88c46ab363b653
  Author: Yoann Rodière <yoann at hibernate.org>
  Date:   2017-04-13 (Thu, 13 Apr 2017)

  Changed paths:
    M orm/src/main/java/org/hibernate/search/FullTextSession.java
    M orm/src/main/java/org/hibernate/search/impl/FullTextSessionImpl.java
    M orm/src/main/java/org/hibernate/search/jpa/FullTextEntityManager.java
    M orm/src/main/java/org/hibernate/search/jpa/Search.java
    R orm/src/main/java/org/hibernate/search/jpa/impl/FullTextEntityManagerImpl.java
    R orm/src/main/java/org/hibernate/search/jpa/impl/ImplementationFactory.java

  Log Message:
  -----------
  HSEARCH-2382 Merge the FullTextSession and FullTextEntityManager implementations

Main gotchas:

 * Search.getFullTextEntityManager now eagerly checks that the passed
EntityManager wraps an actual Hibernate ORM implementations. I don't
think we can do otherwise without reimplementing
SessionDelegatorBaseImpl ourselves.
 * FullTextEntityManager.getDelegate() now returns the actual delegate
whereas it used to return the delegate's delegate.
 * FullTextSession.unwrap( FullTextSession.class ) now works correctly
(it used to simply throw an exception).


  Commit: d86ed889208e1d6cdfe46b54e795154c65c1edbc
      https://github.com/hibernate/hibernate-search/commit/d86ed889208e1d6cdfe46b54e795154c65c1edbc
  Author: Yoann Rodière <yoann at hibernate.org>
  Date:   2017-04-13 (Thu, 13 Apr 2017)

  Changed paths:
    M orm/src/main/java/org/hibernate/search/jpa/Search.java

  Log Message:
  -----------
  HSEARCH-2382 Remove over-complicated code unwrapping the EntityManager to a Session

This was JPA 1.0 code, I think...


Compare: https://github.com/hibernate/hibernate-search/compare/2ccfb9d59c3d...d86ed889208e


More information about the hibernate-commits mailing list