Commit 3c9b9808ace781300b6579fb5cb8b0f7a812be75

Authored by Andrew Shvayka
2 parents f555f007 73f51659

Merge branch 'master' of github.com:thingsboard/thingsboard

@@ -21,6 +21,8 @@ import org.springframework.beans.factory.annotation.Autowired; @@ -21,6 +21,8 @@ import org.springframework.beans.factory.annotation.Autowired;
21 import org.thingsboard.server.common.data.id.EntityId; 21 import org.thingsboard.server.common.data.id.EntityId;
22 import org.thingsboard.server.dao.relation.RelationService; 22 import org.thingsboard.server.dao.relation.RelationService;
23 23
  24 +import java.util.concurrent.ExecutionException;
  25 +
24 @Slf4j 26 @Slf4j
25 public abstract class AbstractEntityService { 27 public abstract class AbstractEntityService {
26 28
@@ -29,7 +31,11 @@ public abstract class AbstractEntityService { @@ -29,7 +31,11 @@ public abstract class AbstractEntityService {
29 31
30 protected void deleteEntityRelations(EntityId entityId) { 32 protected void deleteEntityRelations(EntityId entityId) {
31 log.trace("Executing deleteEntityRelations [{}]", entityId); 33 log.trace("Executing deleteEntityRelations [{}]", entityId);
32 - relationService.deleteEntityRelations(entityId); 34 + try {
  35 + relationService.deleteEntityRelations(entityId).get();
  36 + } catch (InterruptedException | ExecutionException e) {
  37 + throw new RuntimeException(e);
  38 + }
33 } 39 }
34 40
35 41
@@ -18,8 +18,14 @@ package org.thingsboard.server.dao.sql; @@ -18,8 +18,14 @@ package org.thingsboard.server.dao.sql;
18 import com.google.common.util.concurrent.ListeningExecutorService; 18 import com.google.common.util.concurrent.ListeningExecutorService;
19 import com.google.common.util.concurrent.MoreExecutors; 19 import com.google.common.util.concurrent.MoreExecutors;
20 20
  21 +import javax.annotation.PreDestroy;
21 import java.util.concurrent.Executors; 22 import java.util.concurrent.Executors;
22 23
23 public abstract class JpaAbstractDaoListeningExecutorService { 24 public abstract class JpaAbstractDaoListeningExecutorService {
24 protected ListeningExecutorService service = MoreExecutors.listeningDecorator(Executors.newFixedThreadPool(10)); 25 protected ListeningExecutorService service = MoreExecutors.listeningDecorator(Executors.newFixedThreadPool(10));
  26 +
  27 + @PreDestroy
  28 + void onDestroy() {
  29 + service.shutdown();
  30 + }
25 } 31 }
@@ -50,5 +50,11 @@ public interface RelationRepository @@ -50,5 +50,11 @@ public interface RelationRepository
50 String fromType); 50 String fromType);
51 51
52 @Transactional 52 @Transactional
  53 + RelationEntity save(RelationEntity entity);
  54 +
  55 + @Transactional
  56 + void delete(RelationCompositeKey id);
  57 +
  58 + @Transactional
53 void deleteByFromIdAndFromType(String fromId, String fromType); 59 void deleteByFromIdAndFromType(String fromId, String fromType);
54 } 60 }