HHH-7959 gracefully handle non-transactional entity cache
This commit is contained in:
parent
a745f93bfa
commit
90532087d5
|
@ -74,6 +74,15 @@ public class Caches {
|
|||
public static <T> T withinTx(
|
||||
TransactionManager tm,
|
||||
Callable<T> c) throws Exception {
|
||||
if ( tm == null ) {
|
||||
try {
|
||||
return c.call();
|
||||
}
|
||||
catch (Exception e) {
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
else {
|
||||
tm.begin();
|
||||
try {
|
||||
return c.call();
|
||||
|
@ -91,6 +100,7 @@ public class Caches {
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Transform a given cache into a local cache
|
||||
|
|
Loading…
Reference in New Issue