stainlessai / micronaut-jupyter

A Micronaut configuration that integrates your app with an existing Jupyter installation.
https://stainlessai.github.io/micronaut-jupyter
Apache License 2.0
9 stars 5 forks source link

MJ-2 ⁃ Access GORM functionality in Jupyter script #20

Closed stainlessbot closed 4 years ago

stainlessbot commented 4 years ago

The POC (MJ-1) demonstrates the ability to access GORM functionality inside a Jupyter script. This is accomplished by subclassing a few of the classes in the BeakerX Groovy kernel project so that a new hibernate session is created whenever a script is run. The new session is created using an instance of hibernate datastore. I believe this can be accessed via the application context (in both Grails and presumably Micronaut).

However, not all applications will be using GORM, so some checks may have to be put in place before using it. Figure out if there is a way to detect whether or not GORM is included in the application. Alternatively, the configuration could declare a dependency on GORM and always use GORM (regardless of whether the application uses it). Find out how that worked in Grails plugins.

┆Issue Type: Story ┆Priority: Medium ┆Status: Resolved ┆Fix Versions: v0.2.0 ┆Issue Number: MJ-2 ┆Epic: Kernel

stainlessbot commented 4 years ago

➤ Joshua Carter commented:

Without any special functionality in place, using dynamic finders will also result in a HibernateException: no session in current thread exception when trying to save or find a domain.

stainlessbot commented 4 years ago

➤ Joshua Carter commented:

Using the same method as the POC doesn't prevent the LazyInitializationException when using the micronaut-groovy gorm implementation. It is stated for other configurations, like micronaut-sql and micronaut-data, that lazy initialization is not supported and that the queries should use joins instead. I am thinking that the same also applies to micronaut gorm even when using dynamic finders.

stainlessbot commented 4 years ago

➤ Joshua Carter commented:

From what I can tell, lazy initialization is not supported in Micronaut, so any domains with collections that need to be fetched need to have the collections mapped with fetch: 'join'.