当前位置: 首页>>代码示例>>Java>>正文


Java Session.createSQLQuery方法代码示例

本文整理汇总了Java中com.liferay.portal.kernel.dao.orm.Session.createSQLQuery方法的典型用法代码示例。如果您正苦于以下问题:Java Session.createSQLQuery方法的具体用法?Java Session.createSQLQuery怎么用?Java Session.createSQLQuery使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.liferay.portal.kernel.dao.orm.Session的用法示例。


在下文中一共展示了Session.createSQLQuery方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: findByWorkingUnit

import com.liferay.portal.kernel.dao.orm.Session; //导入方法依赖的package包/类
public List<AppRole2Employee> findByWorkingUnit(long workingUnitId, int startIndex, int endIndex, ServiceContext serviceContext) {
	List<Object> params = new ArrayList<Object>();
	Session session = openSession();
	String sql = CustomSQLUtil.get(AppRole2EmployeeFinder.class.getName(), FIND_BY_WORKING_UNIT);		
	sql = sql.replace("[$COMPANY_FILTER$]", " AND companyId = ?");
	params.add(serviceContext.getCompanyId());
	
	sql = sql.replace("[$GROUP_FILTER$]", "");
	if (workingUnitId != 0) {
		sql = sql.replace("[$WORKINGUNIT_FILTER$]", " AND employeeId IN (SELECT oep_usermgt_employee.employeeId FROM oep_usermgt_employee INNER JOIN oep_usermgt_workingunit ON oep_usermgt_employee.workingUnitId = oep_usermgt_workingunit.workingUnitId WHERE oep_usermgt_workingunit.workingUnitId = ?)");
		params.add(workingUnitId);			
	}
	else {
		sql = sql.replace("[$WORKINGUNIT_FILTER$]", "");
	}
	
	SQLQuery query = session.createSQLQuery(sql);
	query.addEntity("AppRole2Employee", AppRole2EmployeeImpl.class);
	if (params != null && params.size() > 0) {
		for (int index = 0; index < params.size(); index++) {
			query.setString(index, String.valueOf(params.get(index)));
		}
	}
	
	return (List<AppRole2Employee>) QueryUtil.list(query, getDialect(), startIndex, endIndex);
}
 
开发者ID:openegovplatform,项目名称:OEPv2,代码行数:27,代码来源:AppRole2EmployeeFinderImpl.java

示例2: findRoleByJobPosId

import com.liferay.portal.kernel.dao.orm.Session; //导入方法依赖的package包/类
public List<Role> findRoleByJobPosId(long jobPosId) {
	List<Object> params = new ArrayList<Object>();
	Session session = openSession();
	String sql = CustomSQLUtil.get(FIND_BY_JOBPOSID);
	params.add(jobPosId);		
	System.out.println(sql);
	System.out.println(FIND_BY_JOBPOSID);
	SQLQuery query = session.createSQLQuery(sql);
	query.addEntity("Role_", Role.class);
	if (params != null && params.size() > 0) {
		for (int index = 0; index < params.size(); index++) {
			query.setString(index, String.valueOf(params.get(index)));
		}
	}
	if (query.list() != null){
		return (List<Role>) query.list();
	}
	return new ArrayList<Role>();
	//return (List<WorkingUnit>) query.list();
}
 
开发者ID:openegovplatform,项目名称:OEPv2,代码行数:21,代码来源:JobPos2RoleFinderImpl.java

示例3: countByApplicationSync

import com.liferay.portal.kernel.dao.orm.Session; //导入方法依赖的package包/类
public int countByApplicationSync(long applicationId, boolean isSync, ServiceContext serviceContext) {
	List<Object> params = new ArrayList<Object>();
	Session session = openSession();
	String sql = CustomSQLUtil.get(UserSyncFinder.class.getName(), COUNT_BY_APPLICATION_SYNC);		
	sql = sql.replace("[$COMPANY_FILTER$]", "");
	sql = sql.replace("[$GROUP_FILTER$]", "");
	
	if (applicationId != 0) {
		sql = sql.replace("[$APPLICATION_FILTER$]", " AND applicationId=?");
		params.add(applicationId);
	}
	else {
		sql = sql.replace("[$APPLICATION_FILTER$]", "");
	}
	
	if (isSync) {
		sql = sql.replace("[$SYNCTIME_FILTER$]", "AND (UNIX_TIMESTAMP(syncTime)!=0 OR syncTime IS NOT NULL)");
	}
	else {
		sql = sql.replace("[$SYNCTIME_FILTER$]", " AND (UNIX_TIMESTAMP(syncTime)=0 OR syncTIME IS NULL)");
	}
			
	System.out.println("SQL: " +sql);

	SQLQuery query = session.createSQLQuery(sql);
	query.addScalar("total", Type.LONG);
	
	if (params != null && params.size() > 0) {
		for (int index = 0; index < params.size(); index++) {
			query.setString(index, String.valueOf(params.get(index)));
		}
	}
	
	List temps = query.list();
	if (temps != null && temps.size() > 0) {
		Long total = (Long) temps.get(0);
		return total.intValue();
	}
	return 0;
}
 
开发者ID:openegovplatform,项目名称:OEPv2,代码行数:41,代码来源:UserSyncFinderImpl.java

示例4: getApplicationsSize

import com.liferay.portal.kernel.dao.orm.Session; //导入方法依赖的package包/类
/**
 * Returns the number of applications associated with the language.
 *
 * @param pk the primary key of the language
 * @return the number of applications associated with the language
 * @throws SystemException if a system exception occurred
 */
public int getApplicationsSize(long pk) throws SystemException {
    Object[] finderArgs = new Object[] { pk };

    Long count = (Long) FinderCacheUtil.getResult(FINDER_PATH_GET_APPLICATIONS_SIZE,
            finderArgs, this);

    if (count == null) {
        Session session = null;

        try {
            session = openSession();

            SQLQuery q = session.createSQLQuery(_SQL_GETAPPLICATIONSSIZE);

            q.addScalar(COUNT_COLUMN_NAME,
                com.liferay.portal.kernel.dao.orm.Type.LONG);

            QueryPos qPos = QueryPos.getInstance(q);

            qPos.add(pk);

            count = (Long) q.uniqueResult();
        } catch (Exception e) {
            throw processException(e);
        } finally {
            if (count == null) {
                count = Long.valueOf(0);
            }

            FinderCacheUtil.putResult(FINDER_PATH_GET_APPLICATIONS_SIZE,
                finderArgs, count);

            closeSession(session);
        }
    }

    return count.intValue();
}
 
开发者ID:fraunhoferfokus,项目名称:govapps,代码行数:46,代码来源:LanguagePersistenceImpl.java

示例5: findByLikeName

import com.liferay.portal.kernel.dao.orm.Session; //导入方法依赖的package包/类
public List<Employee> findByLikeName(String textSearch, long workingUnitId, int startIndex, int endIndex) {
	List<Object> params = new ArrayList<Object>();
	Session session = openSession();
	String sql = CustomSQLUtil.get(FIND_BY_LIKENAME);
	if (textSearch != null && !"".equals(textSearch)) {
		sql = sql.replace("[$NAME_FILTER$]", " AND (LOWER(FULLNAME) LIKE ? OR LOWER(PERSONELDOCNO) LIKE ?)");
		params.add("%" + textSearch.toLowerCase() + "%");		
		params.add("%" + textSearch.toLowerCase() + "%");	
	}
	else {
		sql = sql.replace("[$NAME_FILTER$]", "");
	}
	
	if (workingUnitId > 0) {
		sql = sql.replace("[$WORKINGUNIT_FILTER$]", " AND WORKINGUNITID = ?");
		params.add(workingUnitId);						
	}
	else {
		sql = sql.replace("[$WORKINGUNIT_FILTER$]", "");			
	}
	//System.out.println(" kkkkkkkkkkkkkkkkkkkk " + sql);
	SQLQuery query = session.createSQLQuery(sql);
	query.addEntity("Employee", EmployeeImpl.class);
	if (params != null && params.size() > 0) {
		for (int index = 0; index < params.size(); index++) {
			query.setString(index, String.valueOf(params.get(index)));
		}
	}
	if (query.list() != null){
		return (List<Employee>) QueryUtil.list(query, getDialect(), startIndex, endIndex);
	}
	return new ArrayList<Employee>();
	//return (List<WorkingUnit>) query.list();
}
 
开发者ID:openegovplatform,项目名称:OEPv2,代码行数:35,代码来源:EmployeeFinderImpl.java

示例6: countByLikeName

import com.liferay.portal.kernel.dao.orm.Session; //导入方法依赖的package包/类
public int countByLikeName(String name, ServiceContext serviceContext) {
	List<Object> params = new ArrayList<Object>();
	Session session = openSession();
	String sql = CustomSQLUtil.get(COUNT_BY_LIKE_NAME);		
	sql = sql.replace("[$COMPANY_FILTER$]", " AND COMPANYID = ?");
	params.add(serviceContext.getCompanyId());
	
	if (name != null && !"".equals(name)) {
		sql = sql.replace("[$NAME_FILTER$]", " AND (LOWER(NAME) LIKE ? OR LOWER(TITLE) LIKE ?)");
		params.add("%" + name.toLowerCase() + "%");	
		params.add("%" + name.toLowerCase() + "%");	
	}
	else {
		sql = sql.replace("[$NAME_FILTER$]", "");
	}
	
	SQLQuery query = session.createSQLQuery(sql);
	query.addScalar("total", Type.LONG);
	
	if (params != null && params.size() > 0) {
		for (int index = 0; index < params.size(); index++) {
			query.setString(index, String.valueOf(params.get(index)));
		}
	}
	
	List temps = query.list();
	if (temps != null && temps.size() > 0) {
		Long total = (Long) temps.get(0);
		return total.intValue();
	}
	return 0;
}
 
开发者ID:openegovplatform,项目名称:OEPv2,代码行数:33,代码来源:DictCollectionFinderImpl.java

示例7: countByAppRoleWorkingUnit

import com.liferay.portal.kernel.dao.orm.Session; //导入方法依赖的package包/类
public int countByAppRoleWorkingUnit(long appRoleId, long workingUnitId, ServiceContext serviceContext) {
	List<Object> params = new ArrayList<Object>();
	Session session = openSession();
	String sql = CustomSQLUtil.get(AppRole2EmployeeFinder.class.getName(), COUNT_BY_APPROLE_WORKING_UNIT);		
	sql = sql.replace("[$COMPANY_FILTER$]", " AND companyId = ?");
	params.add(serviceContext.getCompanyId());
	
	sql = sql.replace("[$GROUP_FILTER$]", "");
	if (appRoleId != 0) {
		sql = sql.replace("[$APPROLE_FILTER$]", " AND appRoleId = ?");
		params.add(appRoleId);						
	}
	else {
		sql = sql.replace("[$APPROLE_FILTER$]", "");			
	}
	if (workingUnitId != 0) {
		sql = sql.replace("[$WORKINGUNIT_FILTER$]", " AND employeeId IN (SELECT oep_usermgt_employee.employeeId FROM oep_usermgt_employee INNER JOIN oep_usermgt_workingunit ON oep_usermgt_employee.workingUnitId = oep_usermgt_workingunit.workingUnitId WHERE oep_usermgt_workingunit.workingUnitId = ?)");
		params.add(workingUnitId);			
	}
	else {
		sql = sql.replace("[$WORKINGUNIT_FILTER$]", "");
	}
	_log.info("SQL:" + sql);
	
	SQLQuery query = session.createSQLQuery(sql);
	query.addScalar("total", Type.LONG);
	
	if (params != null && params.size() > 0) {
		for (int index = 0; index < params.size(); index++) {
			query.setString(index, String.valueOf(params.get(index)));
		}
	}
	
	List temps = query.list();
	if (temps != null && temps.size() > 0) {
		Long total = (Long) temps.get(0);
		return total.intValue();
	}
	return 0;
}
 
开发者ID:openegovplatform,项目名称:OEPv2,代码行数:41,代码来源:AppRole2EmployeeFinderImpl.java

示例8: countByParam

import com.liferay.portal.kernel.dao.orm.Session; //导入方法依赖的package包/类
/** 
 * This method count UserActivity by parameter with custom sql
 * 
 * Version: OEP 2.0
 *  
 * History: 
 *   DATE        AUTHOR      DESCRIPTION 
 *  ------------------------------------------------- 
 *  20-September-2015  ThongDV    Create new
 * @param action
 * @param fromDate
 * @param toDate
 * @param begin
 * @param end
 * @return Integer
 */
public int countByParam(long companyId,long groupId,String action, Date fromDate, Date toDate) throws SystemException{
	Session session = null;
	try {
		session= openSession();
		String strQuery = getQuery(CustomSQLUtil.get(COUNT_USERACTIVITY_BY_PARAM), action, fromDate, toDate);
		log.info("SQL query: "+strQuery);
		log.info("fromDate: "+fromDate+"--toDate: "+toDate);
		SQLQuery query = session.createSQLQuery(strQuery);
		query.addScalar("total", Type.LONG);
		QueryPos queryPos = QueryPos.getInstance(query);
		setParam(companyId,groupId,queryPos, action, fromDate, toDate);
		Long total= (Long) query.uniqueResult();
		log.info("result: total="+total);
		
		Iterator<Long> itr = query.iterate();
		if (itr.hasNext()){
			Long count = (Long)itr.next();
			if (count != null) {
				return count.intValue();
			}
		}
		return 0;
	} catch (Exception e) {
		  throw new SystemException(e);
	}finally{
		closeSession(session);
	}
	
}
 
开发者ID:openegovplatform,项目名称:OEPv2,代码行数:46,代码来源:UserActivityFinderImpl.java

示例9: getDownApplication

import com.liferay.portal.kernel.dao.orm.Session; //导入方法依赖的package包/类
public Application getDownApplication(Application app, ServiceContext serviceContext) {
	List<Object> params = new ArrayList<Object>();
	Session session = openSession();
	try {
		String sql = CustomSQLUtil.get(ApplicationFinder.class.getName(), GET_DOWN_APPLICATION);		
		sql = sql.replace("[$COMPANY_FILTER$]", " AND companyId = ?");
		params.add(serviceContext.getCompanyId());
		sql = sql.replace("[$GROUP_FILTER$]", "");
		
		if (app != null) {
			sql = sql.replace("[$SEQUENCENO_FILTER$]", " AND sequenceNo > ?");
			params.add(app.getSequenceNo());			
		}
		else {
			sql = sql.replace("[$SEQUENCENO_FILTER$]", "");
		}

		SQLQuery query = session.createSQLQuery(sql);
		query.addEntity("Application", ApplicationImpl.class);
		if (params != null && params.size() > 0) {
			for (int index = 0; index < params.size(); index++) {
				query.setString(index, String.valueOf(params.get(index)));
			}
		}
		
		List<Application> list = query.list();
		list = new UnmodifiableList<Application>(list);
		
		if (list.size() > 0) {
			return (Application)list.get(0);
		}
		else {
			return null;
		}
	}
	finally {
		closeSession(session);
	}
}
 
开发者ID:openegovplatform,项目名称:OEPv2,代码行数:40,代码来源:ApplicationFinderImpl.java

示例10: getDistinctCourseGroups

import com.liferay.portal.kernel.dao.orm.Session; //导入方法依赖的package包/类
public List<Group> getDistinctCourseGroups(long companyId){
	Session session = null;
	List<Group> distinctCourseGroups = new ArrayList<Group>();
	
	try{
		
		session = openSessionLiferay();
		
		String sql = CustomSQLUtil.get(GET_DISTINCT_COURSE_GROUPS);
		if(log.isDebugEnabled()){
			log.debug("sql: " + sql);
		}
		SQLQuery q = session.createSQLQuery(sql);
		q.addEntity("Group_",PortalClassLoaderUtil.getClassLoader().loadClass("com.liferay.portal.model.impl.GroupImpl"));
		
		QueryPos qPos = QueryPos.getInstance(q);			
		qPos.add(companyId);				
		distinctCourseGroups = (List<Group>)q.list();
		
		
		
	} catch (Exception e) {
       e.printStackTrace();
    } finally {
        closeSessionLiferay(session);
    }

	return distinctCourseGroups;
}
 
开发者ID:TelefonicaED,项目名称:liferaylms-portlet,代码行数:30,代码来源:CourseFinderImpl.java

示例11: countByApplicationUser

import com.liferay.portal.kernel.dao.orm.Session; //导入方法依赖的package包/类
public int countByApplicationUser(String fromApplication, String toUser, ServiceContext serviceContext) {
	List<Object> params = new ArrayList<Object>();
	Session session = openSession();
	String sql = CustomSQLUtil.get(AppMessageFinder.class.getName(), COUNT_BY_APPLICATION_USER);		
	sql = sql.replace("[$COMPANY_FILTER$]", " AND companyId = ?");
	params.add(serviceContext.getCompanyId());
	sql = sql.replace("[$GROUP_FILTER$]", "");
	
	if (!StringUtil.isNullOrEmpty(fromApplication)) {
		sql = sql.replace("[$FROMAPPLICATION_FILTER$]", " AND fromApplication = ?");
		params.add(fromApplication);			
	}
	else {
		sql = sql.replace("[$FROMAPPLICATION_FILTER$]", "");
	}
	if (!StringUtil.isNullOrEmpty(toUser)) {
		sql = sql.replace("[$TOUSER_FILTER$]", " AND toUser = ?");
		params.add(toUser);			
	}
	else {
		sql = sql.replace("[$TOUSER_FILTER$]", "");
	}
			
	SQLQuery query = session.createSQLQuery(sql);
	query.addScalar("total", Type.LONG);
	
	if (params != null && params.size() > 0) {
		for (int index = 0; index < params.size(); index++) {
			query.setString(index, String.valueOf(params.get(index)));
		}
	}
	
	List temps = query.list();
	if (temps != null && temps.size() > 0) {
		Long total = (Long) temps.get(0);
		return total.intValue();
	}
	return 0;
}
 
开发者ID:openegovplatform,项目名称:OEPv2,代码行数:40,代码来源:AppMessageFinderImpl.java

示例12: countByCustomCondition

import com.liferay.portal.kernel.dao.orm.Session; //导入方法依赖的package包/类
public int countByCustomCondition(String dataCode, String collectionName,String dataCodeParent, int datalevel, Date validatedFrom, Date validatedTo, int status, ServiceContext serviceContext) {
	List<Object> params = new ArrayList<Object>();
	Session session = openSession();
	String sql = CustomSQLUtil.get(COUNT_BY_CUSTOMCONDITION);		
	sql = sql.replace("[$COMPANY_FILTER$]", " AND COMPANYID = ?");
	params.add(serviceContext.getCompanyId());
	
	if (dataCode != null && !"".equals(dataCode)) {
		sql = sql.replace("[$DATACODE_FILTER$]", " AND (LOWER(DATACODE) LIKE ? OR LOWER(TITLE) LIKE ?)");
		params.add("%" + dataCode.toLowerCase() + "%");		
		params.add("%" + dataCode.toLowerCase() + "%");	
	}
	else {
		sql = sql.replace("[$DATACODE_FILTER$]", "");
	}
	if (collectionName != null && !"".equals(collectionName)) {
		sql = sql.replace("[$COLLECTIONNAME_FILTER$]", " AND COLLECTIONNAME = ?");
		params.add(collectionName);			
	}
	else {
		sql = sql.replace("[$COLLECTIONNAME_FILTER$]", "");
	}		
	DateFormat df = new SimpleDateFormat("yyyy-MM-dd");
	if (validatedFrom != null) {
		sql = sql.replace("[$VALIDATEDFROM_FILTER$]", " AND VALIDATEDFROM >= ?");
		params.add(df.format(validatedFrom));			
	}
	else {
		sql = sql.replace("[$VALIDATEDFROM_FILTER$]", "");
	}		
	if (validatedTo != null) {
		sql = sql.replace("[$VALIDATEDTO_FILTER$]", " AND VALIDATEDTO <= ?");
		params.add(df.format(validatedTo));			
	}
	else {
		sql = sql.replace("[$VALIDATEDTO_FILTER$]", "");
	}		
	if (status != -1 && status <= 3 && status >= 0) {
		sql = sql.replace("[$STATUS_FILTER$]", " AND STATUS = ?");
		params.add(status);						
	}
	else {
		sql = sql.replace("[$STATUS_FILTER$]", "");			
	}
	if (datalevel != -1 && datalevel <= 5 && datalevel >= 1) {
		String node = "NODE_" + datalevel;
		sql = sql.replace("[$NODE_FILTER$]", " AND " + node + " = ?");
		params.add(dataCodeParent);						
	}
	else {
		sql = sql.replace("[$NODE_FILTER$]", "");			
	}
	
	SQLQuery query = session.createSQLQuery(sql);
	query.addScalar("total", Type.LONG);
	
	if (params != null && params.size() > 0) {
		for (int index = 0; index < params.size(); index++) {
			query.setString(index, String.valueOf(params.get(index)));
		}
	}
	
	List temps = query.list();
	if (temps != null && temps.size() > 0) {
		Long total = (Long) temps.get(0);
		return total.intValue();
	}
	return 0;
}
 
开发者ID:openegovplatform,项目名称:OEPv2,代码行数:70,代码来源:DictDataFinderImpl.java

示例13: countByCustomCondition

import com.liferay.portal.kernel.dao.orm.Session; //导入方法依赖的package包/类
public int countByCustomCondition(String name, Date effectDate, Date expireDate, int active, ServiceContext serviceContext) {
	List<Object> params = new ArrayList<Object>();
	Session session = openSession();
	String sql = CustomSQLUtil.get(DossierProcFinder.class.getName(), COUNT_BY_CUSTOMCONDITION);		
	sql = sql.replace("[$COMPANY_FILTER$]", " AND COMPANYID = ?");
	params.add(serviceContext.getCompanyId());
	
	if (!StringUtil.isNullOrEmpty(name)) {
		sql = sql.replace("[$NAME_FILTER$]", " AND LOWER(NAME) LIKE ?");
		params.add("%" + name.toLowerCase() + "%");			
	}
	else {
		sql = sql.replace("[$NAME_FILTER$]", "");
	}
	DateFormat df = new SimpleDateFormat("yyyy-MM-dd");
	if (effectDate != null) {
		sql = sql.replace("[$EFFECTDATE_FILTER$]", " AND EFFECTDATE >= ?");
		params.add(df.format(effectDate));			
	}
	else {
		sql = sql.replace("[$EFFECTDATE_FILTER$]", "");
	}		
	if (expireDate != null) {
		sql = sql.replace("[$EXPIREDATE_FILTER$]", " AND EXPIREDATE <= ?");
		params.add(df.format(expireDate));			
	}
	else {
		sql = sql.replace("[$EXPIREDATE_FILTER$]", "");
	}		
	if (active != -1) {
		sql = sql.replace("[$ACTIVE_FILTER$]", " AND STATUSACTIVE = ?");
		params.add(active);						
	}
	else {
		sql = sql.replace("[$ACTIVE_FILTER$]", "");			
	}
	
	SQLQuery query = session.createSQLQuery(sql);
	query.addScalar("total", Type.LONG);
	
	if (params != null && params.size() > 0) {
		for (int index = 0; index < params.size(); index++) {
			query.setString(index, String.valueOf(params.get(index)));
		}
	}
	
	List temps = query.list();
	if (temps != null && temps.size() > 0) {
		Long total = (Long) temps.get(0);
		return total.intValue();
	}
	return 0;
}
 
开发者ID:openegovplatform,项目名称:OEPv2,代码行数:54,代码来源:DossierProcFinderImpl.java

示例14: findByGroupCustomCondition

import com.liferay.portal.kernel.dao.orm.Session; //导入方法依赖的package包/类
public List<DictData> findByGroupCustomCondition(String dataCode, String collectionName,String dataCodeParent, int datalevel, Date validatedFrom, Date validatedTo, int status, int startIndex, int endIndex, ServiceContext serviceContext) {
	List<Object> params = new ArrayList<Object>();
	Session session = openSession();
	String sql = CustomSQLUtil.get(FIND_BY_CUSTOMCONDITION);
	sql = sql.replace("[$COMPANY_FILTER$]", " AND GROUPID = ?");
	params.add(serviceContext.getScopeGroupId());
	if (dataCode != null && !"".equals(dataCode)) {
		sql = sql.replace("[$DATACODE_FILTER$]", " AND (LOWER(DATACODE) LIKE ? OR LOWER(TITLE) LIKE ?)");
		params.add("%" + dataCode.toLowerCase() + "%");		
		params.add("%" + dataCode.toLowerCase() + "%");	
	}
	else {
		sql = sql.replace("[$DATACODE_FILTER$]", "");
	}
	if (collectionName != null && !"".equals(collectionName)) {
		sql = sql.replace("[$COLLECTIONNAME_FILTER$]", " AND COLLECTIONNAME = ?");
		params.add(collectionName);			
	}
	else {
		sql = sql.replace("[$COLLECTIONNAME_FILTER$]", "");
	}		
	DateFormat df = new SimpleDateFormat("yyyy-MM-dd");
	if (validatedFrom != null) {
		sql = sql.replace("[$VALIDATEDFROM_FILTER$]", " AND VALIDATEDFROM >= ?");
		params.add(df.format(validatedFrom));			
	}
	else {
		sql = sql.replace("[$VALIDATEDFROM_FILTER$]", "");
	}		
	if (validatedTo != null) {
		sql = sql.replace("[$VALIDATEDTO_FILTER$]", " AND VALIDATEDTO <= ?");
		params.add(df.format(validatedTo));			
	}
	else {
		sql = sql.replace("[$VALIDATEDTO_FILTER$]", "");
	}		
	if (status != -1 && status <= 3 && status >= 0) {
		sql = sql.replace("[$STATUS_FILTER$]", " AND STATUS = ?");
		params.add(status);						
	}
	else {
		sql = sql.replace("[$STATUS_FILTER$]", "");			
	}
	if (datalevel != -1 && datalevel <= 5 && datalevel >= 1) {
		String node = "NODE_" + datalevel;
		sql = sql.replace("[$NODE_FILTER$]", " AND " + node + " = ?");
		params.add(dataCodeParent);						
	}
	else {
		sql = sql.replace("[$NODE_FILTER$]", "");			
	}
	SQLQuery query = session.createSQLQuery(sql);
	query.addEntity("DictData", DictDataImpl.class);
	if (params != null && params.size() > 0) {
		for (int index = 0; index < params.size(); index++) {
			query.setString(index, String.valueOf(params.get(index)));
		}
	}
	
	return (List<DictData>) QueryUtil.list(query, getDialect(), startIndex, endIndex);
}
 
开发者ID:openegovplatform,项目名称:OEPv2,代码行数:62,代码来源:DictDataFinderImpl.java

示例15: findByCustomCondition

import com.liferay.portal.kernel.dao.orm.Session; //导入方法依赖的package包/类
public List<DossierProc> findByCustomCondition(String name, Date effectDate, Date expireDate, int active, int startIndex, int endIndex, ServiceContext serviceContext) {
	List<Object> params = new ArrayList<Object>();
	Session session = openSession();
	String sql = CustomSQLUtil.get(DossierProcFinder.class.getName(), FIND_BY_CUSTOMCONDITION);
	sql = sql.replace("[$COMPANY_FILTER$]", " AND COMPANYID = ?");
	params.add(serviceContext.getCompanyId());
	if (!StringUtil.isNullOrEmpty(name)) {
		sql = sql.replace("[$NAME_FILTER$]", " AND LOWER(NAME) LIKE ?");
		params.add("%" + name.toLowerCase() + "%");			
	}
	else {
		sql = sql.replace("[$NAME_FILTER$]", "");
	}
	DateFormat df = new SimpleDateFormat("yyyy-MM-dd");
	if (effectDate != null) {
		sql = sql.replace("[$EFFECTDATE_FILTER$]", " AND EFFECTDATE >= ?");
		params.add(df.format(effectDate));			
	}
	else {
		sql = sql.replace("[$EFFECTDATE_FILTER$]", "");
	}		
	if (expireDate != null) {
		sql = sql.replace("[$EXPIREDATE_FILTER$]", " AND EXPIREDATE <= ?");
		params.add(df.format(expireDate));			
	}
	else {
		sql = sql.replace("[$EXPIREDATE_FILTER$]", "");
	}		
	if (active != -1) {
		sql = sql.replace("[$ACTIVE_FILTER$]", " AND ACTIVE_ = ?");
		params.add(active);						
	}
	else {
		sql = sql.replace("[$ACTIVE_FILTER$]", "");			
	}
	SQLQuery query = session.createSQLQuery(sql);
	query.addEntity("DossierProc", DossierProcImpl.class);
	if (params != null && params.size() > 0) {
		for (int index = 0; index < params.size(); index++) {
			query.setString(index, String.valueOf(params.get(index)));
		}
	}
	
	return (List<DossierProc>) QueryUtil.list(query, getDialect(), startIndex, endIndex);
}
 
开发者ID:openegovplatform,项目名称:OEPv2,代码行数:46,代码来源:DossierProcFinderImpl.java


注:本文中的com.liferay.portal.kernel.dao.orm.Session.createSQLQuery方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。