fixed delete attributes query
This commit is contained in:
parent
6162060e88
commit
7fa7528546
@ -35,10 +35,10 @@ public interface AttributeKvRepository extends JpaRepository<AttributeKvEntity,
|
|||||||
|
|
||||||
@Transactional
|
@Transactional
|
||||||
@Modifying
|
@Modifying
|
||||||
@Query(value = "DELETE FROM attribute_kv WHERE entity_id = :entityId " +
|
@Query("DELETE FROM AttributeKvEntity a WHERE a.id.entityId = :entityId " +
|
||||||
"AND attribute_type = :attributeType " +
|
"AND a.id.attributeType = :attributeType " +
|
||||||
"AND attribute_key = :attributeKey RETURNING nextval('attribute_kv_version_seq')", nativeQuery = true)
|
"AND a.id.attributeKey = :attributeKey")
|
||||||
Long delete(@Param("entityId") UUID entityId,
|
void delete(@Param("entityId") UUID entityId,
|
||||||
@Param("attributeType") int attributeType,
|
@Param("attributeType") int attributeType,
|
||||||
@Param("attributeKey") int attributeKey);
|
@Param("attributeKey") int attributeKey);
|
||||||
|
|
||||||
|
|||||||
@ -206,12 +206,15 @@ public class JpaAttributeDao extends JpaAbstractDaoListeningExecutorService impl
|
|||||||
return futuresList;
|
return futuresList;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Transactional
|
||||||
@Override
|
@Override
|
||||||
public List<ListenableFuture<TbPair<String, Long>>> removeAllWithVersions(TenantId tenantId, EntityId entityId, AttributeScope attributeScope, List<String> keys) {
|
public List<ListenableFuture<TbPair<String, Long>>> removeAllWithVersions(TenantId tenantId, EntityId entityId, AttributeScope attributeScope, List<String> keys) {
|
||||||
List<ListenableFuture<TbPair<String, Long>>> futuresList = new ArrayList<>(keys.size());
|
List<ListenableFuture<TbPair<String, Long>>> futuresList = new ArrayList<>(keys.size());
|
||||||
for (String key : keys) {
|
for (String key : keys) {
|
||||||
futuresList.add(service.submit(() -> {
|
futuresList.add(service.submit(() -> {
|
||||||
Long version = attributeKvRepository.delete(entityId.getId(), attributeScope.getId(), keyDictionaryDao.getOrSaveKeyId(key));
|
Long version = jdbcTemplate.query("DELETE FROM attribute_kv WHERE entity_id = ? AND attribute_type = ? " +
|
||||||
|
"AND attribute_key = ? RETURNING nextval('attribute_kv_version_seq')",
|
||||||
|
rs -> rs.next() ? rs.getLong(1) : null, entityId.getId(), attributeScope.getId(), keyDictionaryDao.getOrSaveKeyId(key));
|
||||||
return TbPair.of(key, version);
|
return TbPair.of(key, version);
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user