Transaction t1 = Spring.createTransaction(); t1.begin(); try { //your first service method marked as @Transactional userService.saveUser(userDto); t1.commit(); } catch (Throwable t) { t1.rollback(); } finally { t1.close(); } Transaction t2 = Spring.createTransaction(); t2.begin(); try { //your second service method marked as @Transactional roleService.saveRole(roleDto); t2.commit(); } catch (Throwable t) { t2.rollback(); } finally { t2.close(); }
Transaction transaction = new transaction("insert"); try { SimpleFeatureStore featureStore = (SimpleFeatureStore) wfs.getFeatureSource( typeName ); featureStore.setTransaction( transaction ); featureStore.addFeatures( DataUtilities.collection( feature ) ); transaction.commit(); // get the final feature id WFSTransactionState wfsts = (WFSTransactionState) transaction.getState(wfs); // In this example there is only one fid. Get it. String result = wfsts.getFids( typeName )[0]; } finally { transaction.close(); }
transaction.rollback(); } finally { transaction.close();