vladmihalcea / hypersistence-optimizer

Hypersistence Optimizer allows you to get the most out of JPA and Hibernate. By scanning your application configuration and mappings, Hypersistence Optimizer can tell you what changes you need to do to speed up your data access layer.
https://vladmihalcea.com/hypersistence-optimizer/
Apache License 2.0
306 stars 43 forks source link

Support for Micronaut #206

Closed heyimMarc closed 9 months ago

heyimMarc commented 1 year ago

Hi there, it would be cool to support Micronaut.

First I thought the integration of the hypersistence-optimizer would be no issue because its using hibernate 5, but I'm getting strange errors until I add the dependency via gradle.

Could not obtain transaction-synchronized Session for current thread org.hibernate.HibernateException: Could not obtain transaction-synchronized Session for current thread at app//io.micronaut.transaction.hibernate5.MicronautSessionContext.currentSession(MicronautSessionContext.java:91)

I'm using Micronaut 3.8.0.

Maybe it's just a simple change to fix this, but at this time it's not working for me. Any ideas?

Let me know if you need more input.

vladmihalcea commented 1 year ago

I haven't tested it on Micronaut, but I'll add support for it in the next versions.

Ar the moment, you can disable the Runtime Scanner like this:

HypersistenceOptimizer hypersistenceOptimizer = new HypersistenceOptimizer(
    new JpaConfig(entityManagerFactory)
        .setRuntimeScannerEnabled(false)
);

This way, you will still get to scan the mappings and configurations, but you will avoid the errors you're seeing until this issue is resolved.

vladmihalcea commented 9 months ago

Fixed.