Browse Source
Merge pull request #9751 from YevhenBondarenko/fix/kv-dictionary
fixed getOrSaveKeyId in transaction
pull/9770/head
Andrew Shvayka
3 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with
6 additions and
2 deletions
-
dao/src/main/java/org/thingsboard/server/dao/sqlts/BaseAbstractSqlTimeseriesDao.java
|
|
|
@ -53,11 +53,15 @@ public abstract class BaseAbstractSqlTimeseriesDao extends JpaAbstractDaoListeni |
|
|
|
if (keyId == null) { |
|
|
|
Optional<TsKvDictionary> tsKvDictionaryOptional; |
|
|
|
tsKvDictionaryOptional = dictionaryRepository.findById(new TsKvDictionaryCompositeKey(strKey)); |
|
|
|
if (!tsKvDictionaryOptional.isPresent()) { |
|
|
|
if (tsKvDictionaryOptional.isEmpty()) { |
|
|
|
tsCreationLock.lock(); |
|
|
|
try { |
|
|
|
keyId = tsKvDictionaryMap.get(strKey); |
|
|
|
if (keyId != null) { |
|
|
|
return keyId; |
|
|
|
} |
|
|
|
tsKvDictionaryOptional = dictionaryRepository.findById(new TsKvDictionaryCompositeKey(strKey)); |
|
|
|
if (!tsKvDictionaryOptional.isPresent()) { |
|
|
|
if (tsKvDictionaryOptional.isEmpty()) { |
|
|
|
TsKvDictionary tsKvDictionary = new TsKvDictionary(); |
|
|
|
tsKvDictionary.setKey(strKey); |
|
|
|
try { |
|
|
|
|