update TousseDefinition set haveDisposableMaterial=1 where (select count(*) from DiposableGoodsInstance where tousseDefinition_id=TousseDefinition.id) > 0;
update TousseDefinition set haveDisposableMaterial=0 where (select count(*) from DiposableGoodsInstance where tousseDefinition_id=TousseDefinition.id) = 0;
update IDCardInstance set lastTousseInstanceId=(select max(id) from TousseInstance where idCardInstanceID=IDCardInstance.id) where lastTousseInstanceId is null;
update IDCardDefinition set lastTousseInstanceId=(select max(lastTousseInstanceId) from IDCardInstance where idCardDefinitionID=IDCardDefinition.id) where lastTousseInstanceId is null;