This commit is contained in:
2023-09-11 21:33:34 +08:00
parent 81d33b2ef4
commit 12f6a50232

View File

@@ -19,6 +19,8 @@ import jakarta.persistence.criteria.Predicate;
import jakarta.persistence.criteria.Root;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.hibernate.Cache;
import org.hibernate.Session;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.convert.ConversionService;
import org.springframework.data.domain.Page;
@@ -61,8 +63,9 @@ public class ResourceService extends BaseService<ResourceEntity, ResourceReposit
ResourceEntity entity = mapper.toEntity(request);
this.repository.save(entity);
entityManager.unwrap(Session.class).getSessionFactory().getCache().evictCollectionData("cn.lihongjie.coal.resource.entity.ResourceEntity.children");
return getById(entity.getId());
}
@@ -73,15 +76,22 @@ public class ResourceService extends BaseService<ResourceEntity, ResourceReposit
this.mapper.updateEntity(entity, request);
this.repository.save(entity);
entityManager.unwrap(Session.class).getSessionFactory().getCache().evictCollectionData("cn.lihongjie.coal.resource.entity.ResourceEntity.children");
return getById(entity.getId());
}
public void delete(IdRequest request) {
this.repository.deleteAllById(request.getIds());
Cache cache = entityManager.unwrap(Session.class).getSessionFactory().getCache();
cache.evictCollectionData("cn.lihongjie.coal.resource.entity.ResourceEntity.children");
}