[hibernate-dev] Usage of Session#getTransaction() being banned from the Hibernate Search code
steve at hibernate.org
Tue Sep 13 10:54:48 EDT 2016
NIce! I never knew of this plugin, but there is a Gradle plugin for it as
On Tue, Sep 13, 2016 at 9:33 AM Sanne Grinovero <sanne at hibernate.org> wrote:
> Since Hibernate ORM 5.2, the method getTransaction() on Session needs
> to behave according to EntityManager spec, which implies that it has
> to throw an exception in certain circumstances which depend on the
> Hibernate Search used this method in various places, for example to
> integrate with the current transaction's events, or even to control
> the transaction explicitly in the case of the MassIndexer.
> Since we want Hibernate Search to work fine with Hibernate ORM no
> matter what configuration is being used, we need to avoid invoking
> this method.
> The solution is extremely simple: use its SPI level replacement, which
> is SessionImplementor#accessTransaction().
> Unfortunately most of our Search/ORM tests happen to run without a
> Transaction Manager so if you happen to use the old method, the tests
> would pass and everything would seem fine - however your shiny new
> feature would not work in certain configurations.
> One solution to verify we're not using it, is to ban this method using
> the "forbiddenapi" plugin:
> A more comprehensive integration test would be to re-run all tests
> from the Search/ORM using a proper JTA configuration; not rushing to
> refactor our testsuite now since we have the forbidden-apis plugin but
> opening a JIRA task for 5.7, as this version will support ORM 5.7:
> - https://hibernate.atlassian.net/browse/HSEARCH-2344
> hibernate-dev mailing list
> hibernate-dev at lists.jboss.org
More information about the hibernate-dev