hibernate 핸드폰 sql 문장 코드 레코드
15689 단어 자바
package com.zzy.cowhide.service;
import java.text.ParseException;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import org.hibernate.SessionFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springside.modules.orm.hibernate.Page;
import org.springside.modules.orm.hibernate.SimpleHibernateTemplate;
import com.zzy.cowhide.bean.OrderReportBean;
import com.zzy.cowhide.entity.OrderOd;
import com.zzy.cowhide.utils.StringUtilsEx;
@Service
@Transactional
public class OrderReportService {
private SimpleHibernateTemplate orderDao;
@Autowired
public void setSessionFactory(SessionFactory sessionFactory) {
orderDao = new SimpleHibernateTemplate(sessionFactory, OrderOd.class);
}
/**
*
* @Title: find
* @Description: TODO( type == 0)
* @param page
* @return
* @throws ParseException
* List
* @throws
* @author oftoo
*/
@SuppressWarnings("unchecked")
public List findByDay(Page page) throws ParseException {
Map parameters = page.getQueryMap();
String startDate = null, endDate =null, shopName = null;
if (parameters.containsKey("startDate") && !StringUtilsEx.isNullOrEmpty(parameters.get("startDate"))) {
startDate = parameters.get("startDate") + " 00:00:00";
}
if (parameters.containsKey("endDate") && !StringUtilsEx.isNullOrEmpty(parameters.get("endDate"))) {
endDate = parameters.get("endDate") + " 23:59:59";
}
if (parameters.containsKey("shopName") && !StringUtilsEx.isNullOrEmpty(parameters.get("shopName"))) {
shopName = parameters.get("shopName");
}
StringBuilder sb = new StringBuilder();
List listBean = new ArrayList();
sb.append(" SELECT shop.company_name AS name , SUM( order_od.total) AS total, count(order_od.id) AS ods, 0 AS TYPE, DATE_FORMAT(order_od.create_time,'%Y-%m-%d') AS time");
sb.append(" FROM order_od ");
sb.append(" LEFT JOIN shop on order_od.saler_member_id = shop.id ");
sb.append(" LEFT JOIN member on shop.member_id = member.id ");
sb.append(" WHERE ");
sb.append(" 1 = 1");
sb.append(" AND order_od.status IN (3,4) ");//
if (shopName != null && shopName.equals("")) {
sb.append(" AND shop.shop_name LIKE = '%+" + shopName + "%'");
}
if (startDate !=null && endDate != null) {
sb.append(" AND order_od.create_time >= " + "'" + startDate + "'");//
sb.append(" AND order_od.create_time < " + "'" + endDate + "'");//
}
sb.append(" GROUP BY saler_member_id,DATE_FORMAT(order_od.create_time,'%Y-%m-%d') ");
List
코드 필름 2:
/**
*
*/
public List findPageNo(int pageNo) {
Criteria criteria = chemicalCategoryDao.createCriteria();
criteria.addOrder(Order.asc("level"));
criteria.add(Restrictions.eq("status", 1));
criteria.addOrder(Order.asc("sort"));
if (pageNo==1) {
criteria.setFirstResult(0);
} else {
criteria.setFirstResult(5*(pageNo-1));
}
criteria.setMaxResults(15);
return chemicalCategoryDao.findByCriteria(criteria);
}
이 내용에 흥미가 있습니까?
현재 기사가 여러분의 문제를 해결하지 못하는 경우 AI 엔진은 머신러닝 분석(스마트 모델이 방금 만들어져 부정확한 경우가 있을 수 있음)을 통해 가장 유사한 기사를 추천합니다:
Is Eclipse IDE dying?In 2014 the Eclipse IDE is the leading development environment for Java with a market share of approximately 65%. but ac...
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
CC BY-SA 2.5, CC BY-SA 3.0 및 CC BY-SA 4.0에 따라 라이센스가 부여됩니다.