use of com.tangosol.util.TransactionMap in project teiid by teiid.
the class CoherenceConnectionImpl method update.
public void update(Object key, Object object) throws ResourceException {
NamedCache sourceCache = getCache();
if (!sourceCache.containsKey(key)) {
throw new ResourceException("Unable to update object for key: " + key + " to cache " + this.cacheName + ", because it already exist");
}
TransactionMap tmap = CacheFactory.getLocalTransaction(sourceCache);
tmap.setTransactionIsolation(TransactionMap.TRANSACTION_REPEATABLE_GET);
tmap.setConcurrency(TransactionMap.CONCUR_PESSIMISTIC);
tmap.begin();
try {
tmap.put(key, object);
tmap.prepare();
tmap.commit();
} catch (Exception e) {
throw new ResourceException(e);
}
sourceCache = getCache();
if (!sourceCache.containsKey(key)) {
throw new ResourceException("Problem updating object for key: " + key + " to the cache " + this.cacheName + ", object not found after add");
}
}
use of com.tangosol.util.TransactionMap in project teiid by teiid.
the class CoherenceConnectionImpl method add.
public void add(Object key, Object value) throws ResourceException {
NamedCache sourceCache = getCache();
if (sourceCache.containsKey(key)) {
throw new ResourceException("Unable to add object for key: " + key + " to cache " + this.cacheName + ", because it already exist");
}
TransactionMap tmap = CacheFactory.getLocalTransaction(sourceCache);
tmap.setTransactionIsolation(TransactionMap.TRANSACTION_REPEATABLE_GET);
tmap.setConcurrency(TransactionMap.CONCUR_PESSIMISTIC);
tmap.begin();
try {
tmap.put(key, value);
tmap.prepare();
tmap.commit();
} catch (Exception e) {
throw new ResourceException(e);
}
sourceCache = getCache();
if (!sourceCache.containsKey(key)) {
throw new ResourceException("Problem adding object for key: " + key + " to the cache " + this.cacheName + ", object not found after add");
}
}
use of com.tangosol.util.TransactionMap in project teiid by teiid.
the class CoherenceConnectionImpl method remove.
public void remove(Object key) throws ResourceException {
System.out.println("Remove: " + key);
NamedCache sourceCache = getCache();
if (!sourceCache.containsKey(key)) {
throw new ResourceException("Unable to remove object for key: " + key + " from cache " + this.cacheName + ", because it doesn't exist");
}
TransactionMap tmap = CacheFactory.getLocalTransaction(sourceCache);
tmap.setTransactionIsolation(TransactionMap.TRANSACTION_REPEATABLE_GET);
tmap.setConcurrency(TransactionMap.CONCUR_OPTIMISTIC);
tmap.begin();
try {
tmap.remove(key);
tmap.prepare();
tmap.commit();
} catch (Exception e) {
throw new ResourceException(e);
}
if (getCache().containsKey(key)) {
throw new ResourceException("Unable to remove object for key: " + key + " from the cache " + this.cacheName);
}
}
Aggregations