<html>
<head>
<meta content="text/html; charset=windows-1252"
http-equiv="Content-Type">
</head>
<body bgcolor="#FFFFFF" text="#000000">
<div class="moz-cite-prefix">Hello,<br>
<br>
atm we don't support multiple transactions for the same session.
If we would ever support it, we will need to traverse the
"afterCompletion" list in DefaultKeycloakTransactionManager.begin
(and also similarly in
DefaultKeycloakTransactionManager.isRollbackOnly() ). Maybe you
can create JIRA and we can take a look later? Another thing is
that all enlisted transactions would also need to support multiple
transactions per session (for example in case of JPA it is
multiple transactions per single EntityManager, which JPA
supports, but there might be some performance issues with it)<br>
<br>
Note that until than, you can use pattern where each transaction
will run in it's own KeycloakSession. So defacto multiple
KeycloakSession per request. If you already have any
KeycloakSession you can retrieve KeycloakSessionFactory with: <br>
KeycloakSessionFactory factory =
session.getKeycloakSessionFactory();<br>
<br>
And then you can use for example:
KeycloakModelUtils.runJobInTransaction to use separate
KeycloakSession and transaction for your task. Does it work for
your usecase?<br>
<br>
Marek<br>
<br>
On 19.9.2014 00:13, Rodrigo Sasaki wrote:<br>
</div>
<blockquote
cite="mid:CANLOgwCdS3urv9Yk-wwuqX2++gqEeDqNQPiBq0bpDz+OKU=dxQ@mail.gmail.com"
type="cite">
<div dir="ltr">Hello,
<div><br>
</div>
<div>I have created some custom endpoints for my project, and in
one of them I need to use multiple transactions on a single
request. I ran into some issues, even though I call </div>
<div><br>
</div>
<div><font face="courier new, monospace">session.getTransaction().begin()</font></div>
<div><br>
</div>
<div>It didn't work correctly saying that I didn't have an
opened transaction. I look a little deeper and saw that there
are 2 lists of transactions inside <font face="courier new,
monospace">org.keycloak.services.DefaultKeycloakTransactionManager.</font></div>
<div><br>
</div>
<div>One is called <font face="courier new, monospace"><b>transactions</b></font>
and the other is <font face="courier new, monospace"><b>afterCompletion</b></font></div>
<div><br>
</div>
<div>when <font face="courier new, monospace">commit()</font>
is called, both lists are traversed committing every single
transaction in them, but when <font face="courier new,
monospace">begin()</font> is called, only the <font
face="courier new, monospace"><b>transactions</b></font>
list is traversed, and the one I needed was inside <font
face="courier new, monospace"><b>afterCompletion</b></font>,
which remained closed.</div>
<div><br>
</div>
<div>Is this supposed to be this way? I'm not sure what these
lists do, but maybe the other one should be opened too.</div>
<div><br>
</div>
<div>Is there a problem on opening the transactions on <font
face="courier new, monospace"><b>afterCompletion</b></font>
list as well?</div>
<div><br>
</div>
<div>Thanks!<br clear="all">
<div><br>
</div>
-- <br>
<div dir="ltr"><font face="Times New Roman">Rodrigo Sasaki</font></div>
</div>
</div>
<br>
<fieldset class="mimeAttachmentHeader"></fieldset>
<br>
<pre wrap="">_______________________________________________
keycloak-user mailing list
<a class="moz-txt-link-abbreviated" href="mailto:keycloak-user@lists.jboss.org">keycloak-user@lists.jboss.org</a>
<a class="moz-txt-link-freetext" href="https://lists.jboss.org/mailman/listinfo/keycloak-user">https://lists.jboss.org/mailman/listinfo/keycloak-user</a></pre>
</blockquote>
<br>
</body>
</html>