public static <X, Y> Y getNullSafeValue(X target, String propertyPath) { return getNullSafeValue(target, propertyPath, null); }
public static <X, Y> Y getNullSafeValue(Class<X> source, X target, String propertyPath) { return getNullSafeValue(source, target, propertyPath, (Class<Y>) null); }
public Hibernate5TransactionSynchronizationStrategy(EntityManager em) { try { this.tx = em.getTransaction(); } catch (IllegalStateException e) { throw new IllegalStateException("Could not access entity transaction!", e); } try { Object s = em.unwrap(Class.forName("org.hibernate.Session")); this.synchronizationRegistry = ExpressionUtils.getNullSafeValue(s, "transactionCoordinator.localSynchronizations"); this.registerSynchronization = ReflectionUtils.getMethod(synchronizationRegistry.getClass(), "registerSynchronization", Synchronization.class); } catch (ClassNotFoundException e) { throw new RuntimeException(e); } }
public Hibernate4TransactionSynchronizationStrategy(EntityManager em) { try { this.tx = em.getTransaction(); } catch (IllegalStateException e) { throw new IllegalStateException("Could not access entity transaction!", e); } try { Object s = em.unwrap(Class.forName("org.hibernate.Session")); this.synchronizationRegistry = ExpressionUtils.getNullSafeValue(s, "transactionCoordinator.synchronizationRegistry"); this.registerSynchronization = ReflectionUtils.getMethod(synchronizationRegistry.getClass(), "registerSynchronization", Synchronization.class); } catch (ClassNotFoundException e) { throw new RuntimeException(e); } }