diff --git a/hsweb-commons/hsweb-commons-service/hsweb-commons-service-simple/src/main/java/org/hswebframework/web/service/GenericEntityService.java b/hsweb-commons/hsweb-commons-service/hsweb-commons-service-simple/src/main/java/org/hswebframework/web/service/GenericEntityService.java index c3863f6ba..6f7db4695 100644 --- a/hsweb-commons/hsweb-commons-service/hsweb-commons-service-simple/src/main/java/org/hswebframework/web/service/GenericEntityService.java +++ b/hsweb-commons/hsweb-commons-service/hsweb-commons-service-simple/src/main/java/org/hswebframework/web/service/GenericEntityService.java @@ -29,6 +29,7 @@ import org.hswebframework.web.validator.group.UpdateGroup; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.transaction.annotation.Transactional; import org.springframework.util.Assert; +import org.springframework.util.CollectionUtils; import org.springframework.util.StringUtils; import javax.annotation.PostConstruct; @@ -142,7 +143,7 @@ public abstract class GenericEntityService, PK> @Override @Transactional(readOnly = true) public E selectByPk(PK pk) { - if (null == pk) { + if (StringUtils.isEmpty(pk)) { return null; } return createQuery().where(GenericEntity.id, pk).single(); @@ -151,7 +152,7 @@ public abstract class GenericEntityService, PK> @Override @Transactional(readOnly = true) public List selectByPk(List id) { - if (id == null || id.isEmpty()) { + if (CollectionUtils.isEmpty(id)) { return new ArrayList<>(); } return createQuery().where().in(GenericEntity.id, id).listNoPaging();