HHH-7959 gracefully handle non-transactional entity cache

This commit is contained in:
Brett Meyer 2013-08-07 11:44:44 -04:00
parent a745f93bfa
commit 90532087d5
1 changed files with 23 additions and 13 deletions

View File

@ -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