Disable crashing the server when Hibernate panics after oopsing
This commit is contained in:
parent
2eeb55ed52
commit
fccd7e70b1
@ -341,15 +341,36 @@ public final class PersistenceManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void persist(Object obj) {
|
private void persist(Object obj) {
|
||||||
transaction(() -> entityManager.persist(obj));
|
try {
|
||||||
|
transaction(() -> entityManager.persist(obj));
|
||||||
|
} catch (EntityExistsException e) {
|
||||||
|
if (transaction.isActive())
|
||||||
|
transaction.rollback();
|
||||||
|
EnvoyLog.getLogger(PersistenceManager.class).log(Level.WARNING,
|
||||||
|
String.format("Could not persist %s: entity exists already.", obj));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void merge(Object obj) {
|
private void merge(Object obj) {
|
||||||
transaction(() -> entityManager.merge(obj));
|
try {
|
||||||
|
transaction(() -> entityManager.merge(obj));
|
||||||
|
} catch (IllegalArgumentException e) {
|
||||||
|
if (transaction.isActive())
|
||||||
|
transaction.rollback();
|
||||||
|
EnvoyLog.getLogger(PersistenceManager.class).log(Level.WARNING,
|
||||||
|
String.format("Could not merge %s: entity doesn't exist.", obj));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void remove(Object obj) {
|
private void remove(Object obj) {
|
||||||
transaction(() -> entityManager.remove(obj));
|
try {
|
||||||
|
transaction(() -> entityManager.remove(obj));
|
||||||
|
} catch (IllegalArgumentException e) {
|
||||||
|
if (transaction.isActive())
|
||||||
|
transaction.rollback();
|
||||||
|
EnvoyLog.getLogger(PersistenceManager.class).log(Level.WARNING,
|
||||||
|
String.format("Could not remove %s: entity didn't exist (for the database).", obj));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Reference in New Issue
Block a user