micronaut-projects / micronaut-data

Ahead of Time Data Repositories
Apache License 2.0
459 stars 195 forks source link

Missing documentation for micronaut-jdbc-hikari dependency #2627

Open sergey-morenets opened 7 months ago

sergey-morenets commented 7 months ago

Expected Behavior

1) Official documentation should contain information that micronaut-jdbc-hikari is required dependency for Micronaut Data JPA. It would be better to explain why it's required. Why can't we use Micronaut Data without connection pools? 2) The exception message should more informative and ask to add micronaut-jdbc-hikari dependency. Otherwise it's absolutely unclear how to resolve that.

Actual Behaviour

Hi

We tried to update to update our Micronaut application and use Micronaut Data JPA using official documentation(https://micronaut-projects.github.io/micronaut-data/latest/guide/#hibernate) but faced the following exception at runtime:

Caused by: io.micronaut.context.exceptions.NoSuchBeanException: No bean of type [io.micronaut.data.operations.PrimaryRepositoryOperations] exists. 
    at io.micronaut.context.DefaultBeanContext.newNoSuchBeanException(DefaultBeanContext.java:2766)
    at io.micronaut.context.DefaultApplicationContext.newNoSuchBeanException(DefaultApplicationContext.java:303)
    at io.micronaut.context.DefaultBeanContext.resolveBeanRegistration(DefaultBeanContext.java:2735)
    at io.micronaut.context.DefaultBeanContext.getBean(DefaultBeanContext.java:1693)
    at io.micronaut.context.DefaultBeanContext.getBean(DefaultBeanContext.java:840)
    at io.micronaut.context.DefaultBeanContext.getBean(DefaultBeanContext.java:832)
    at io.micronaut.data.runtime.operations.DefaultRepositoryOperationsRegistry.provide(DefaultRepositoryOperationsRegistry.java:53)

The only topic about this issue is here: https://stackoverflow.com/questions/59777918/how-do-i-resolve-error-no-bean-of-type-io-micronaut-data-operations-primaryrep But we couldn't find solution in the discussions there.

So we used Micronaut Data JPA application generated at micronaut.io/launch to compare with our application. After long investigation absence of this dependency caused the issue:

        <dependency>
            <groupId>io.micronaut.sql</groupId>
            <artifactId>micronaut-jdbc-hikari</artifactId>
        </dependency>

The official documentation contains information about this dependency but only in Micronaut Data JDBC section:

You should also ensure you have the JDBC driver and connection pool dependencies configured:

Nothing similar is in the Micronaut Data JPA section.

Steps To Reproduce

No response

Environment Information

No response

Example Application

No response

Version

4.1.6

dstepanov commented 7 months ago

The documentation is included in https://micronaut-projects.github.io/micronaut-sql/latest/guide/ (it is a bit confusing) You can use different pools like Tomcat etc. The JDBC always needs to be pooled for a good performance.

sergey-morenets commented 7 months ago

The documentation is included in https://micronaut-projects.github.io/micronaut-sql/latest/guide/ (it is a bit confusing) You can use different pools like Tomcat etc. The JDBC always needs to be pooled for a good performance.

This guide is about Micronaut SQL and we're using Micronaut Data JPA.

dstepanov commented 7 months ago

Please refer to this section https://micronaut-projects.github.io/micronaut-sql/latest/guide/#hibernate Hibernate also needs JDBC driver configured.

tgkprog commented 1 month ago

Over all the docs could be clearer. Also what would be much appreciated is an example with dynamo db and Kotlin. Not straight forward to go from Java to Kotlin without a template or a good guide