'WITH deleted AS (DELETE FROM ts_kv WHERE entity_id IN (SELECT to_uuid(device.id) as entity_id FROM device WHERE tenant_id = %L and customer_id = %L) AND ts < %L::bigint RETURNING *) SELECT count(*) FROM deleted',
'WITH deleted AS (DELETE FROM ts_kv WHERE entity_id IN (SELECT device.id as entity_id FROM device WHERE tenant_id = %L and customer_id = %L) AND ts < %L::bigint RETURNING *) SELECT count(*) FROM deleted',
'WITH deleted AS (DELETE FROM ts_kv WHERE entity_id IN (SELECT to_uuid(asset.id) as entity_id FROM asset WHERE tenant_id = %L and customer_id = %L) AND ts < %L::bigint RETURNING *) SELECT count(*) FROM deleted',
'WITH deleted AS (DELETE FROM ts_kv WHERE entity_id IN (SELECT asset.id as entity_id FROM asset WHERE tenant_id = %L and customer_id = %L) AND ts < %L::bigint RETURNING *) SELECT count(*) FROM deleted',
'WITH deleted AS (DELETE FROM ts_kv WHERE entity_id IN (SELECT to_uuid(customer.id) as entity_id FROM customer WHERE tenant_id = %L and id = %L) AND ts < %L::bigint RETURNING *) SELECT count(*) FROM deleted',
'WITH deleted AS (DELETE FROM ts_kv WHERE entity_id IN (SELECT customer.id as entity_id FROM customer WHERE tenant_id = %L and id = %L) AND ts < %L::bigint RETURNING *) SELECT count(*) FROM deleted',
@ -205,14 +203,14 @@ public class DefaultEntityQueryRepository implements EntityQueryRepository {
caseRELATIONS_QUERY:
caseDEVICE_SEARCH_QUERY:
caseASSET_SEARCH_QUERY:
returnString.format("e.tenant_id='%s' and e.customer_id='%s'",UUIDConverter.fromTimeUUID(tenantId.getId()),UUIDConverter.fromTimeUUID(customerId.getId()));
returnString.format("e.tenant_id='%s' and e.customer_id='%s'",tenantId.getId(),customerId.getId());
returnString.format("e.tenant_id='%s' and e.id='%s'",UUIDConverter.fromTimeUUID(tenantId.getId()),UUIDConverter.fromTimeUUID(customerId.getId()));
returnString.format("e.tenant_id='%s' and e.id='%s'",tenantId.getId(),customerId.getId());
}else{
returnString.format("e.tenant_id='%s' and e.customer_id='%s'",UUIDConverter.fromTimeUUID(tenantId.getId()),UUIDConverter.fromTimeUUID(customerId.getId()));
returnString.format("e.tenant_id='%s' and e.customer_id='%s'",tenantId.getId(),customerId.getId());
}
}
}
@ -256,13 +254,14 @@ public class DefaultEntityQueryRepository implements EntityQueryRepository {
@ -30,9 +32,25 @@ public class HsqlRelationInsertRepository extends AbstractRelationInsertReposito
privatestaticfinalStringINSERT_ON_CONFLICT_DO_UPDATE="MERGE INTO relation USING (VALUES :fromId, :fromType, :toId, :toType, :relationTypeGroup, :relationType, :additionalInfo) R "+
"ON (relation.from_id = R.from_id AND relation.from_type = R.from_type AND relation.relation_type_group = R.relation_type_group AND relation.relation_type = R.relation_type AND relation.to_id = R.to_id AND relation.to_type = R.to_type) "+
"ON (relation.from_id = UUID(R.from_id) AND relation.from_type = R.from_type AND relation.relation_type_group = R.relation_type_group AND relation.relation_type = R.relation_type AND relation.to_id = UUID(R.to_id) AND relation.to_type = R.to_type) "+
"WHEN MATCHED THEN UPDATE SET relation.additional_info = R.additional_info "+
"WHEN NOT MATCHED THEN INSERT (from_id, from_type, to_id, to_type, relation_type_group, relation_type, additional_info) VALUES (R.from_id, R.from_type, R.to_id, R.to_type, R.relation_type_group, R.relation_type, R.additional_info)";
"WHEN NOT MATCHED THEN INSERT (from_id, from_type, to_id, to_type, relation_type_group, relation_type, additional_info) VALUES (UUID(R.from_id), R.from_type, UUID(R.to_id), R.to_type, R.relation_type_group, R.relation_type, R.additional_info)";