Hi Henning,
First, it's recommended that you don't use EntityManager directly in your
RealmResourceProvider, but rather create a facade class to encapsulate JPA operations.
examples/providers/domain-extension is a nice example of the above (look for
ExampleService and its implementation).
Second, generally you should retrieve an EntityManager before each new transaction. As
long as it's in a local variable, it will be finalized and closed automatically, so
normally you don't need to bother.
Cheers,
Dmitry Telegin
CTO, Acutus s.r.o.
Keycloak Consulting and Training
Pod lipami street 339/52, 130 00 Prague 3, Czech Republic
+42 (022) 888-30-71
E-mail: info(a)acutus.pro
On Fri, 2018-07-27 at 10:17 +0200, Henning Waack wrote:
Hi.
I am implementing a RealmResourceProvider (KC 4.0) in which I use an
EntityManager provided by the KeycloakSession to access the KC DB:
EntityManager em =
((KeycloakSession)session).getProvider(JpaConnectionProvider.class).getEntityManager();
In my class which extends
org.keycloak.services.resource.RealmResourceProvider and uses this
EntityManager, do I have to close the EM instance after using it? Or do I
have to close it in my RealmResourceProviderFactory.close() method where I
obtain it from the session?
Thanks & greetings
Henning
_______________________________________________
keycloak-user mailing list
keycloak-user(a)lists.jboss.org
https://lists.jboss.org/mailman/listinfo/keycloak-user