zhouhao пре 7 година
родитељ
комит
e1261e86be

+ 5 - 11
hsweb-commons/hsweb-commons-service/hsweb-commons-service-simple/src/main/java/org/hswebframework/web/service/EnableCacheGenericEntityService.java

@@ -18,12 +18,6 @@ import java.util.List;
  */
 public abstract class EnableCacheGenericEntityService<E extends GenericEntity<PK>, PK> extends GenericEntityService<E, PK> {
 
-    @Override
-    @Cacheable(key = "'ids:'+#id.hashCode()", condition = "#id!=null")
-    public List<E> selectByPk(List<PK> id) {
-        return super.selectByPk(id);
-    }
-
     @Override
     @Cacheable(key = "'id:'+#pk")
     public E selectByPk(PK pk) {
@@ -37,31 +31,31 @@ public abstract class EnableCacheGenericEntityService<E extends GenericEntity<PK
     }
 
     @Override
-    @CacheEvict(allEntries = true)
+    @CacheEvict(key = "'id:'+#pk")
     public int updateByPk(PK pk, E entity) {
         return super.updateByPk(pk, entity);
     }
 
     @Override
-    @CacheEvict(allEntries = true)
+    @CacheEvict(key = "'id:'+#entity.id")
     protected int updateByPk(E entity) {
         return super.updateByPk(entity);
     }
 
     @Override
-    @CacheEvict(allEntries = true)
+    @CacheEvict(key = "'id:'+#result")
     public PK insert(E entity) {
         return super.insert(entity);
     }
 
     @Override
-    @CacheEvict(allEntries = true)
+    @CacheEvict(key = "'id:'+#pk")
     public int deleteByPk(PK pk) {
         return super.deleteByPk(pk);
     }
 
     @Override
-    @CacheEvict(allEntries = true)
+    @CacheEvict(key = "'id:'+#result")
     public PK saveOrUpdate(E entity) {
         return super.saveOrUpdate(entity);
     }