|
|
@ -27,6 +27,7 @@ import org.springframework.cache.CacheManager; |
|
|
import org.springframework.cache.annotation.CacheEvict; |
|
|
import org.springframework.cache.annotation.CacheEvict; |
|
|
import org.springframework.cache.annotation.Cacheable; |
|
|
import org.springframework.cache.annotation.Cacheable; |
|
|
import org.springframework.cache.annotation.Caching; |
|
|
import org.springframework.cache.annotation.Caching; |
|
|
|
|
|
import org.springframework.dao.ConcurrencyFailureException; |
|
|
import org.springframework.stereotype.Service; |
|
|
import org.springframework.stereotype.Service; |
|
|
import org.springframework.util.StringUtils; |
|
|
import org.springframework.util.StringUtils; |
|
|
import org.thingsboard.server.common.data.id.EntityId; |
|
|
import org.thingsboard.server.common.data.id.EntityId; |
|
|
@ -201,6 +202,7 @@ public class BaseRelationService implements RelationService { |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
relationDao.deleteOutboundRelations(tenantId, entityId); |
|
|
relationDao.deleteOutboundRelations(tenantId, entityId); |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
@Override |
|
|
@Override |
|
|
@ -262,10 +264,13 @@ public class BaseRelationService implements RelationService { |
|
|
boolean delete(TenantId tenantId, Cache cache, EntityRelation relation, boolean deleteFromDb) { |
|
|
boolean delete(TenantId tenantId, Cache cache, EntityRelation relation, boolean deleteFromDb) { |
|
|
cacheEviction(relation, cache); |
|
|
cacheEviction(relation, cache); |
|
|
if (deleteFromDb) { |
|
|
if (deleteFromDb) { |
|
|
return relationDao.deleteRelation(tenantId, relation); |
|
|
try { |
|
|
} else { |
|
|
return relationDao.deleteRelation(tenantId, relation); |
|
|
return false; |
|
|
} catch (ConcurrencyFailureException e) { |
|
|
|
|
|
log.debug("Concurrency exception while deleting relations [{}]", relation, e); |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
return false; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
private void cacheEviction(EntityRelation relation, Cache cache) { |
|
|
private void cacheEviction(EntityRelation relation, Cache cache) { |
|
|
|