no class entity with id exists for relation fix
This commit is contained in:
parent
77b9a8c1af
commit
3f6fb04949
@ -19,6 +19,7 @@ import com.google.common.util.concurrent.ListenableFuture;
|
|||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.dao.ConcurrencyFailureException;
|
import org.springframework.dao.ConcurrencyFailureException;
|
||||||
|
import org.springframework.dao.DataAccessException;
|
||||||
import org.springframework.data.jpa.domain.Specification;
|
import org.springframework.data.jpa.domain.Specification;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
import org.thingsboard.server.common.data.EntityType;
|
import org.thingsboard.server.common.data.EntityType;
|
||||||
@ -159,7 +160,7 @@ public class JpaRelationDao extends JpaAbstractDaoListeningExecutorService imple
|
|||||||
if (relationExistsBeforeDelete) {
|
if (relationExistsBeforeDelete) {
|
||||||
try {
|
try {
|
||||||
relationRepository.deleteById(key);
|
relationRepository.deleteById(key);
|
||||||
} catch (ConcurrencyFailureException e) {
|
} catch (DataAccessException e) {
|
||||||
log.debug("[{}] Concurrency exception while deleting relation", key, e);
|
log.debug("[{}] Concurrency exception while deleting relation", key, e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -200,7 +201,7 @@ public class JpaRelationDao extends JpaAbstractDaoListeningExecutorService imple
|
|||||||
return (root, criteriaQuery, criteriaBuilder) -> {
|
return (root, criteriaQuery, criteriaBuilder) -> {
|
||||||
List<Predicate> predicates = new ArrayList<>();
|
List<Predicate> predicates = new ArrayList<>();
|
||||||
if (from != null) {
|
if (from != null) {
|
||||||
Predicate fromIdPredicate = criteriaBuilder.equal(root.get("fromId"), from.getId());
|
Predicate fromIdPredicate = criteriaBuilder.equal(root.get("fromId"), from.getId());
|
||||||
predicates.add(fromIdPredicate);
|
predicates.add(fromIdPredicate);
|
||||||
Predicate fromEntityTypePredicate = criteriaBuilder.equal(root.get("fromType"), from.getEntityType().name());
|
Predicate fromEntityTypePredicate = criteriaBuilder.equal(root.get("fromType"), from.getEntityType().name());
|
||||||
predicates.add(fromEntityTypePredicate);
|
predicates.add(fromEntityTypePredicate);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user