// TODO lock or switch the cache
sms = _cache.getStateManagers();
_cache.clear();
}
if (sms != null && !sms.isEmpty()) {
storeManager.retainConnection();
storeManager.begin();
errors = storeManager.flush(sms);
if(errors != null && !errors.isEmpty() ) {
for(Exception e : errors) {
// TODO add error handling.