From a8efa9008925d035b3bc90c7fc8936bbe6341a32 Mon Sep 17 00:00:00 2001 From: "jack.jia" Date: Thu, 21 May 2020 14:52:49 +0800 Subject: [PATCH] =?UTF-8?q?bug=207461,count=E6=97=B6=E5=8E=BB=E6=8E=89dist?= =?UTF-8?q?inct=E3=80=82Fix=20Bug=20#7461?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../i3plus/pojo/base/jpa/daoimpl/BaseRepositoryImpl.java | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/modules/i3plus-pojo-base/src/main/java/cn/estsh/i3plus/pojo/base/jpa/daoimpl/BaseRepositoryImpl.java b/modules/i3plus-pojo-base/src/main/java/cn/estsh/i3plus/pojo/base/jpa/daoimpl/BaseRepositoryImpl.java index b60d2e0..f1d9061 100644 --- a/modules/i3plus-pojo-base/src/main/java/cn/estsh/i3plus/pojo/base/jpa/daoimpl/BaseRepositoryImpl.java +++ b/modules/i3plus-pojo-base/src/main/java/cn/estsh/i3plus/pojo/base/jpa/daoimpl/BaseRepositoryImpl.java @@ -569,7 +569,7 @@ public class BaseRepositoryImpl extends SimpleJpaRep @Override public int listCount() { try{ - Long count = entityManager.createQuery("select count(distinct model) from " + persistentClass.getName() + " as model",Long.class) + Long count = entityManager.createQuery("select count(model) from " + persistentClass.getName() + " as model",Long.class) .getSingleResult(); return count == null ? 0 : count.intValue(); }catch(NoResultException e){ @@ -580,7 +580,7 @@ public class BaseRepositoryImpl extends SimpleJpaRep @Override public int findByPropertyCount(String propertyName, Object value) { try{ - String queryString = "select count(distinct model) from " + persistentClass.getName() + " as model where model." + propertyName + "= :" + propertyName; + String queryString = "select count(model) from " + persistentClass.getName() + " as model where model." + propertyName + "= :" + propertyName; Long count = entityManager.createQuery(queryString, Long.class) .setParameter(propertyName, value) .getSingleResult(); @@ -612,7 +612,7 @@ public class BaseRepositoryImpl extends SimpleJpaRep throw new IllegalArgumentException("参数名的数量和参数值不匹配!propertyNames:" + propertyNames.length + ",values:" + values.length); } StringBuffer queryString = new StringBuffer(); - queryString.append("select count(distinct model) from " + persistentClass.getName() + " as model"); + queryString.append("select count(model) from " + persistentClass.getName() + " as model"); int size = propertyNames.length; if (size > 0) { @@ -755,7 +755,7 @@ public class BaseRepositoryImpl extends SimpleJpaRep throw new IllegalArgumentException("参数名的数量和参数值不匹配!propertyNames:" + propertyNames.length + ",values:" + values.length); } StringBuffer queryString = new StringBuffer(); - queryString.append("select count(distinct model) from " + persistentClass.getSimpleName() + " as model where 1=1 "); + queryString.append("select count(model) from " + persistentClass.getSimpleName() + " as model where 1=1 "); if (hqlWhere != null && hqlWhere.length() > 0) { queryString.append(hqlWhere); @@ -859,7 +859,7 @@ public class BaseRepositoryImpl extends SimpleJpaRep @Override public int findByHqlWhereCount(String hqlWhere) { StringBuffer queryString = new StringBuffer(); - queryString.append("select count(distinct model) from " + persistentClass.getSimpleName() + " as model where 1=1 "); + queryString.append("select count(model) from " + persistentClass.getSimpleName() + " as model where 1=1 "); if (hqlWhere != null && hqlWhere.length() > 0) { queryString.append(hqlWhere); @@ -875,7 +875,7 @@ public class BaseRepositoryImpl extends SimpleJpaRep @Override public int findByHqlWhereCount(DdlPackBean packBean) { StringBuffer queryString = new StringBuffer(); - queryString.append("select count(distinct model) from " + persistentClass.getSimpleName() + queryString.append("select count(model) from " + persistentClass.getSimpleName() + " as model where 1=1 " + packBean.getWhereAppend()); Query query = entityManager.createQuery(queryString.toString(), Long.class);