Fixes for cases when asset/device deleted but has entity view assigned

This commit is contained in:
Volodymyr Babak 2018-10-03 13:12:23 +03:00
parent 321d4f1cb2
commit b1f9ffb3b8
2 changed files with 12 additions and 1 deletions

View File

@ -67,3 +67,14 @@ CREATE MATERIALIZED VIEW IF NOT EXISTS thingsboard.entity_view_by_tenant_and_cus
AND id IS NOT NULL
PRIMARY KEY (tenant_id, customer_id, search_text, id, entity_id)
WITH CLUSTERING ORDER BY (customer_id DESC, search_text ASC, id DESC);
CREATE MATERIALIZED VIEW IF NOT EXISTS thingsboard.entity_view_by_tenant_and_entity_id AS
SELECT *
from thingsboard.entity_views
WHERE tenant_id IS NOT NULL
AND customer_id IS NOT NULL
AND entity_id IS NOT NULL
AND search_text IS NOT NULL
AND id IS NOT NULL
PRIMARY KEY (tenant_id, entity_id, customer_id, search_text, id)
WITH CLUSTERING ORDER BY (entity_id DESC, customer_id DESC, search_text ASC, id DESC);

View File

@ -115,7 +115,7 @@ public class CassandraEntityViewDao extends CassandraAbstractSearchTextDao<Entit
log.debug("Try to find entity views by tenantId [{}] and entityId [{}]", tenantId, entityId);
Select.Where query = select().from(ENTITY_VIEW_BY_TENANT_AND_ENTITY_ID_CF).where();
query.and(eq(TENANT_ID_PROPERTY, tenantId));
query.and(eq(ENTITY_ID_COLUMN, entityId));dr
query.and(eq(ENTITY_ID_COLUMN, entityId));
return findListByStatementAsync(query);
}
}