|
|
|
@ -5,10 +5,12 @@ import org.slf4j.Logger;
|
|
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
import org.springframework.util.CollectionUtils;
|
|
|
|
|
|
|
|
|
|
import javax.persistence.EntityManager;
|
|
|
|
|
import javax.persistence.Query;
|
|
|
|
|
import java.util.List;
|
|
|
|
|
import java.util.Map;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @Description :
|
|
|
|
@ -26,17 +28,28 @@ public class ReportDaoImpl implements IReportDao {
|
|
|
|
|
private EntityManager entityManager;
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public List<Object[]> findByHqlObjects(String hql, String[] paramName, Object[] paramValue) throws Exception {
|
|
|
|
|
LOGGER.info(" find HQL:{} paramName:{} paramValue:{}", hql, paramName, paramValue);
|
|
|
|
|
public List<Object[]> findByHqlObjects(String hql, Map<String,Object> findParam) throws Exception {
|
|
|
|
|
LOGGER.info(" find HQL:{} find params :{}", hql, findParam);
|
|
|
|
|
Query queryObject = entityManager.createQuery(hql);
|
|
|
|
|
if(paramName != null && paramValue != null){
|
|
|
|
|
for (int i = 0; i < paramName.length; i++) {
|
|
|
|
|
if (paramValue[i] != null) {
|
|
|
|
|
queryObject.setParameter(paramName[i], paramValue[i].toString());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(CollectionUtils.isEmpty(findParam)){
|
|
|
|
|
findParam.forEach((K, V) -> queryObject.setParameter(K, V));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
entityManager.clear();
|
|
|
|
|
return queryObject.getResultList();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public Long findByHqlCount(String hql, Map<String, Object> findParam) throws Exception {
|
|
|
|
|
LOGGER.info(" find HQL:{} find params :{}", hql, findParam);
|
|
|
|
|
Query queryObject = entityManager.createQuery(hql);
|
|
|
|
|
|
|
|
|
|
if(CollectionUtils.isEmpty(findParam)){
|
|
|
|
|
findParam.forEach((K, V) -> queryObject.setParameter(K, V));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
entityManager.clear();
|
|
|
|
|
return (Long)queryObject.getSingleResult();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|