Skip to content

Commit

Permalink
Revert "leave entities attached"
Browse files Browse the repository at this point in the history
This reverts commit 4be7001.
  • Loading branch information
andrewazores committed Oct 6, 2022
1 parent b5b3a61 commit fcb67be
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/main/java/io/cryostat/discovery/PluginInfoDao.java
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ public PluginInfo update(UUID id, EnvironmentNode subtree) {
plugin.setSubtree(gson.toJson(subtree));
entityManager.merge(plugin);
transaction.commit();
entityManager.detach(plugin);

return plugin;
} catch (Exception e) {
Expand Down Expand Up @@ -129,6 +130,7 @@ public PluginInfo update(UUID id, Collection<? extends AbstractNode> children) {
plugin.setSubtree(gson.toJson(subtree));
entityManager.merge(plugin);
transaction.commit();
entityManager.detach(plugin);

return plugin;
} catch (Exception e) {
Expand Down
4 changes: 4 additions & 0 deletions src/main/java/io/cryostat/storage/AbstractDao.java
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ public final T save(T t) {
transaction.begin();
entityManager.persist(t);
transaction.commit();
entityManager.detach(t);
return t;
} catch (Exception e) {
if (transaction != null) {
Expand Down Expand Up @@ -102,6 +103,9 @@ public final Optional<T> get(I id) {
EntityTransaction transaction = entityManager.getTransaction();
try {
T t = entityManager.find(klazz, id);
if (t != null) {
entityManager.detach(t);
}
return Optional.ofNullable(t);
} catch (Exception e) {
if (transaction != null) {
Expand Down

0 comments on commit fcb67be

Please sign in to comment.