use of org.springframework.cache.annotation.CacheEvict in project ontrack by nemerosa.
the class PropertyJdbcRepository method saveProperty.
@Override
@CacheEvict(cacheNames = "properties", key = "#typeName + #entityType.name() + #entityId.value")
public void saveProperty(String typeName, ProjectEntityType entityType, ID entityId, JsonNode data, String searchKey) {
MapSqlParameterSource params = params("type", typeName).addValue("entityId", entityId.getValue());
// Any previous value?
Integer propertyId = getFirstItem(String.format("SELECT ID FROM PROPERTIES WHERE TYPE = :type AND %s = :entityId", entityType.name()), params, Integer.class);
// Data parameters
params.addValue("json", writeJson(data)).addValue("searchKey", searchKey);
// Update
if (propertyId != null) {
getNamedParameterJdbcTemplate().update("UPDATE PROPERTIES SET JSON = :json, SEARCHKEY = :searchKey WHERE ID = :id", params.addValue("id", propertyId));
} else // Creation
{
getNamedParameterJdbcTemplate().update(String.format("INSERT INTO PROPERTIES(TYPE, %s, SEARCHKEY, JSON) " + "VALUES(:type, :entityId, :searchKey, :json)", entityType.name()), params);
}
}
use of org.springframework.cache.annotation.CacheEvict in project metacat by Netflix.
the class ConnectorTableServiceProxy method update.
/**
* Calls the connector table service update method.
* @param name table name
* @param tableInfo table object
* @return true if errors after this should be ignored.
*/
@CacheEvict(key = "'table.' + #name")
public boolean update(final QualifiedName name, final TableInfo tableInfo) {
final MetacatRequestContext metacatRequestContext = MetacatContextManager.getContext();
final ConnectorTableService service = connectorManager.getTableService(name);
boolean result = false;
try {
log.info("Updating table {}", name);
final ConnectorRequestContext connectorRequestContext = converterUtil.toConnectorContext(metacatRequestContext);
service.update(connectorRequestContext, tableInfo);
result = connectorRequestContext.isIgnoreErrorsAfterUpdate();
} catch (UnsupportedOperationException ignored) {
// Ignore if the operation is not supported, so that we can at least go ahead and save the user metadata.
log.debug("Catalog {} does not support the table update operation.", name.getCatalogName());
}
return result;
}
use of org.springframework.cache.annotation.CacheEvict in project cu-kfs by CU-CommunityApps.
the class ParameterRepositoryServiceImpl method createParameter.
@CacheEvict(value = Parameter.CACHE_NAME, allEntries = true)
@Override
public Parameter createParameter(Parameter parameter) {
if (parameter == null) {
throw new IllegalArgumentException("parameter is null");
}
final ParameterKey key = ParameterKey.create(parameter.getNamespaceCode(), parameter.getComponentCode(), parameter.getName());
final Parameter existing = getParameter(key);
if (existing != null) {
throw new IllegalStateException("the parameter to create already exists: " + parameter);
}
return businessObjectService.save(parameter);
}
use of org.springframework.cache.annotation.CacheEvict in project cu-kfs by CU-CommunityApps.
the class ParameterRepositoryServiceImpl method updateParameter.
@CacheEvict(value = Parameter.CACHE_NAME, allEntries = true)
@Override
public Parameter updateParameter(Parameter parameter) {
if (parameter == null) {
throw new IllegalArgumentException("parameter is null");
}
final ParameterKey key = ParameterKey.create(parameter.getNamespaceCode(), parameter.getComponentCode(), parameter.getName());
final Parameter existing = getParameter(key);
if (existing == null) {
throw new IllegalStateException("the parameter does not exist: " + parameter);
}
return businessObjectService.save(parameter);
}
use of org.springframework.cache.annotation.CacheEvict in project fw-cloud-framework by liuweijw.
the class RoleServiceImpl method saveRoleAndDept.
@Override
@Transactional
@CacheEvict(allEntries = true)
public Role saveRoleAndDept(Role role) {
if (null == role || null == role.getDeptId() || role.getDeptId() < 0)
return null;
Role dbRole = this.roleRepository.saveAndFlush(role);
// 删除之前保存的部门角色关系
QRoleDept qRoleDept = QRoleDept.roleDept;
this.queryFactory.delete(qRoleDept).where(qRoleDept.roleId.eq(dbRole.getRoleId())).execute();
RoleDept roleDept = new RoleDept();
roleDept.setDeptId(role.getDeptId());
roleDept.setRoleId(dbRole.getRoleId());
roleDeptRepository.saveAndFlush(roleDept);
return dbRole;
}
Aggregations