Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update artifacts for Lucene, Hibernate, and Spring #3000

Closed
wants to merge 17 commits into from

Conversation

jballanc
Copy link
Contributor

@jballanc jballanc commented Sep 2, 2014

Pull Request 3000!

This updates:

  • Lucene from v2.4.1 to v3.6.2
  • Hibernate from v3.5.6 to v4.3.6
  • Spring from v3.0.1 to v4.0.6

Please see individual commit messages for detailed descriptions of all the changes made...

@qidane
Copy link
Contributor

qidane commented Sep 3, 2014

Wow, PR 3000, we should have cake!

@mtbc
Copy link
Member

mtbc commented Sep 4, 2014

Is this aiming for any particular milestone? Hibernate 4 might make my http://trac.openmicroscopy.org.uk/ome/ticket/11779 reimplementation perform better if I can do things in HQL like SELECT o.id, type(o) FROM SomeClass o instead of having to load it as a HibernateProxy and do Hibernate.getClass on it.

@jballanc
Copy link
Contributor Author

jballanc commented Sep 4, 2014

My understanding is that the tentative goal is to get this merged in for v.5.1.

@mtbc if I'm understanding your question correctly, the Hibernate docs seem to imply that you can do this now: http://docs.jboss.org/hibernate/orm/4.2/devguide/en-US/html/ch11.html#d5e2812

@mtbc
Copy link
Member

mtbc commented Sep 4, 2014

@mtbc
Copy link
Member

mtbc commented Sep 30, 2014

If this is merged, the version of query syntax and of Luke at https://www.openmicroscopy.org/private/ome-internal/testing_scenarios/Search.html (in "see also") will need updating.

This diff updates OMERO from Lucene v2.4.1 to v3.6.2. The most recent
stable version of Lucene (as of this commit) is v4.9.0, however v4.7.2
is that last version to still support Java 6 and v3.6.2 is the latest
version still supported by Hibernate-Search. If/when OMERO drops
support for Java 6, and after Hibernate-Search v5 reaches general
release, we should update Lucene again.

Aside from updating the library version, the following additional
changes were required for the server to compile:

* Renamed a few imports that were relocated
* Updated `CharTokenizer` subclass to handle `int`s instead of `char`s
* Changed `FullTextAnalyzer` to use updated `createComponents` API
* Added back-compat arguments (`LUCENE_30`) to a few constructors (note:
  this enum name has changed in v4.9.0 to `LUCENE_3_0`)
* Rewrote `SimilarTerms#do` method to use new `FuzzyTermsEnum` technique

Note: With this commit the server and client will build, but will not
run. The reason for this is that the version of Hibernate Search we
build with uses the old strategy for subclassing `Analyzer`.
This commit includes the required changes to update hibernate-orm from
v3.5.6 to v4.3.5 and hibernate-search from v3.1.1 to v4.5.1. This also
includes most of the required changes to package names.

Note: THIS COMMIT WILL NOT BUILD. More changes are required to adapt to
changes in Hibernate's event listener registry and sessions.
This updates the following components:

* spring-framework from v3.0.1 to v4.0.6
* spring-ldap from v1.3.0 to v2.0.2
* spring-security from v3.0.2 to v3.2.4

Note: OMERO still does not build at this stage.
Prior to this change, OMERO was injecting a custom fork of the
`org.hibernate.stat.ConcurrentStatisticsImpl` class used by Hibernate.
It is not clear if the original issue leading to the need for this fork
remains, but regardless the fork is now out of date. It is missing a
number of methods in the Hibernate v4.3.6 version of the class.
This class is no longer used anywhere in OMERO and is not compatible
with the most recent versions of Spring and Hibernate.
This commit contains a handful of "simpler" updates moving from
hibernate3 support in Spring to hibernate4. Specifically:

* `HibernateCallback`, `HibernateTemplate`, and `HibernateDaoSupport`
  work mostly the same in hibernate4, so import statements were simply
  updated (the `doInHibernate` method no longer throws `SQLException`s,
  though). Note: it is recommended to replace
  `HibernateCallback`/`HibernateTemplate` code with "plain" Hibernate
  style calls using the new `SessionFactory.getCurrentSession()` method
  introduced in Hibernate v3.0.1.
* The `allowCreate` parameter from the `HibernateTemplate` constructor
  was removed, as `HibernateTemplate` is now using `getCurrentSession()`
  under the covers.
* `SessionFactoryUtils` has been severely trimmed down in hibernate4. In
  particular, the `getSession()` method (along with the `allowCreate`
  parameter) has been removed in favor of `getCurrentSession()`.
* One instance where `HibernateInterceptor` was imported but not used
  was removed (`HibernateInterceptor` no longer exists in hibernate4).
* Import statements for a few exception classes were updated.
* Spring's `LocalSessionFactoryBean` now fulfills the role of both the
  hibernate3 version of the same bean and the hibernate3
  `AnnotationSessionFactoryBean`.
* The method signatures on some `UserType` methods that were overridden
  has changed.
Due to a change in how Hibernate manages per-thread Sessions and
Spring's integration with this, the `HibernateInterceptor` is not
strictly necessary any longer.

More information on this ticket: https://jira.spring.io/browse/SPR-9028
Spring is no longer supporting `FilterDefinitionFactoryBean` for
hibernate4, and the `filterDefinitions` property has been removed from
the `LocalSessionFactoryBean`. However, the same mechanisms using in the
`FilterDefinitionFactoryBean` and the various custom OMERO subclasses
should work. So this pulls the implementation of that bean into OMERO
and updates it for hibernate4 compatibility.
The Spring team have stated that they will no longer be supporting the
`IdTransferringMergeEventListener` for hibernate4. However, the code
still works, so this just merges the (relatively small) implementation
of that listener with OMERO's `MergeEventListener`, which was the only
subclass in use.

See here for more info: https://jira.spring.io/browse/SPR-9634
The hibernate4 version of Spring's `LocalSessionFactoryBean` has removed
support for specifying `eventListeners`, `filterDefinitions`, and
`lobHandler`. This is a simple custom subclass that adds back these
properties and wires them up appropriately. Notably, since Hibernate has
moved management of `eventListeners` to the `EventListenerRegistry`
which must be retrieved from the `ServiceRegistry`, we must call the
`buildSessionFactory` method *before* registering event listeners.

Note: It is still not clear to me how the `lobHandler` should be hooked
in, so it remains in the implementation as a property that can be
specified, but more work needs to go into connecting it appropriately.
In Hibernate-Search for Hibernate 4, the mechanism for accessing an
index reader has changed. This updates the `SimilarTerms` class for the
new mechanism.
The new mechanism in Hibernate 4 for registering event listeners
requires retrieving an `EventListenerRegistry` instance and then
registering listeners with it. So, this changes the implementation of
`EventListenersFactoryBean` from generating a map of event listeners to
directly registering them with the `EventListenerRegistry`, which is
passed in during session factory creation in the
`LocalSessionFactoryBean`.
Since `StatisticsService` was removed from Hibernate 4, we now need to
provide our own bean to pull `Statistics` from the current session
factory.

See here for more: https://hibernate.atlassian.net/browse/HHH-6190
This change replicates the previous changes made to update package
names, remove the SqlException signature for `HibernateCallback`, and
add the Lucene version constants in some of the tests.
The `TokenStream` in Lucene no longer operates like a vanilla iterator
with `next()`. Instead we need to retrieve the `Token` using the
`getAttributes()` method and advance the stream using the
`incrementToken()` method.
This should make Lucene happy...
@joshmoore
Copy link
Member

Closing until this can be worked on further.

@joshmoore joshmoore closed this Mar 3, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants