Commit 3c9b9808ace781300b6579fb5cb8b0f7a812be75
Merge branch 'master' of github.com:thingsboard/thingsboard
Showing
3 changed files
with
19 additions
and
1 deletions
... | ... | @@ -21,6 +21,8 @@ import org.springframework.beans.factory.annotation.Autowired; |
21 | 21 | import org.thingsboard.server.common.data.id.EntityId; |
22 | 22 | import org.thingsboard.server.dao.relation.RelationService; |
23 | 23 | |
24 | +import java.util.concurrent.ExecutionException; | |
25 | + | |
24 | 26 | @Slf4j |
25 | 27 | public abstract class AbstractEntityService { |
26 | 28 | |
... | ... | @@ -29,7 +31,11 @@ public abstract class AbstractEntityService { |
29 | 31 | |
30 | 32 | protected void deleteEntityRelations(EntityId entityId) { |
31 | 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 | 18 | import com.google.common.util.concurrent.ListeningExecutorService; |
19 | 19 | import com.google.common.util.concurrent.MoreExecutors; |
20 | 20 | |
21 | +import javax.annotation.PreDestroy; | |
21 | 22 | import java.util.concurrent.Executors; |
22 | 23 | |
23 | 24 | public abstract class JpaAbstractDaoListeningExecutorService { |
24 | 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 | 50 | String fromType); |
51 | 51 | |
52 | 52 | @Transactional |
53 | + RelationEntity save(RelationEntity entity); | |
54 | + | |
55 | + @Transactional | |
56 | + void delete(RelationCompositeKey id); | |
57 | + | |
58 | + @Transactional | |
53 | 59 | void deleteByFromIdAndFromType(String fromId, String fromType); |
54 | 60 | } | ... | ... |