org.hibernate.criterion.Expression#eq ( )源码实例Demo

下面列出了org.hibernate.criterion.Expression#eq ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: Knowage-Server   文件: SbiMetaSourceDAOHibImpl.java
@Override
public SbiMetaSource loadSourceByName(Session session, String name) throws EMFUserError {
	logger.debug("IN");

	SbiMetaSource toReturn = null;
	Session tmpSession = session;

	try {

		Criterion labelCriterrion = Expression.eq("name", name);
		Criteria criteria = tmpSession.createCriteria(SbiMetaSource.class);
		criteria.add(labelCriterrion);
		toReturn = (SbiMetaSource) criteria.uniqueResult();
		if (toReturn == null)
			return null;

	} catch (HibernateException he) {
		logException(he);
		throw new EMFUserError(EMFErrorSeverity.ERROR, 100);
	} finally {
		logger.debug("OUT");
	}

	return toReturn;
}
 
@Override
public SbiMetaTableColumn loadTableColumnByName(Session session, String name) throws EMFUserError {
	logger.debug("IN");

	SbiMetaTableColumn toReturn = null;
	Session tmpSession = session;
	try {
		Criterion labelCriterrion = Expression.eq("name", name);
		Criteria criteria = tmpSession.createCriteria(SbiMetaTableColumn.class);
		criteria.add(labelCriterrion);
		toReturn = (SbiMetaTableColumn) criteria.uniqueResult();
		if (toReturn == null)
			return null;
	} catch (HibernateException he) {
		logException(he);
		throw new HibernateException(he);
	} finally {
		logger.debug("OUT");
	}
	return toReturn;
}
 
源代码3 项目: Knowage-Server   文件: SbiMetaJobDAOHibImpl.java
@Override
public SbiMetaJob loadJobByName(Session session, String name) throws EMFUserError {
	logger.debug("IN");

	SbiMetaJob toReturn = null;
	Session tmpSession = session;

	try {
		Criterion labelCriterrion = Expression.eq("name", name);
		Criteria criteria = tmpSession.createCriteria(SbiMetaJob.class);
		criteria.add(labelCriterrion);
		toReturn = (SbiMetaJob) criteria.uniqueResult();
		if (toReturn == null)
			return null;

	} catch (HibernateException he) {
		logException(he);
		throw new EMFUserError(EMFErrorSeverity.ERROR, 100);
	} finally {
		logger.debug("OUT");
	}

	return toReturn;
}
 
源代码4 项目: Knowage-Server   文件: SbiMetaBcDAOHibImpl.java
/**
 * Load source by the unique name.
 *
 * @param session
 *            the session
 *
 * @param name
 *            the unique name
 *
 * @return the meta bc
 *
 * @throws EMFUserError
 *             the EMF user error
 *
 * @see it.eng.spagobi.metadata.dao.ISbiMetaBcDAOHibImpl#loadBcByUniqueName(session, string)
 */
@Override
public SbiMetaBc loadBcByUniqueName(Session session, String uniqueName) throws EMFUserError {
	logger.debug("IN");

	SbiMetaBc toReturn = null;

	try {
		Criterion labelCriterrion = Expression.eq("uniqueName", uniqueName);
		Criteria criteria = session.createCriteria(SbiMetaBc.class);
		criteria.add(labelCriterrion);
		toReturn = (SbiMetaBc) criteria.uniqueResult();
	} catch (HibernateException he) {
		logException(he);
		throw new HibernateException(he);
	} finally {
		logger.debug("OUT");
	}
	return toReturn;
}
 
源代码5 项目: Knowage-Server   文件: SbiMetaBcDAOHibImpl.java
@Override
public List<SbiMetaBc> loadAllBCFromTable(int tableId) throws EMFUserError {
	logger.debug("IN");

	List toReturn = null;
	Session tmpSession = null;
	Transaction tx = null;

	try {
		tmpSession = getSession();
		tx = tmpSession.beginTransaction();

		Criterion labelCriterrion = Expression.eq("tableId", tableId);
		Criteria criteria = tmpSession.createCriteria(SbiMetaTable.class);
		criteria.add(labelCriterrion);

		toReturn = criteria.list();
		if (toReturn == null)
			return null;
		tx.commit();

	} catch (HibernateException he) {
		logException(he);
		if (tx != null)
			tx.rollback();
		throw new EMFUserError(EMFErrorSeverity.ERROR, 100);
	} finally {
		if (tmpSession != null) {
			if (tmpSession.isOpen())
				tmpSession.close();
		}
	}

	logger.debug("OUT");
	return toReturn;
}
 
源代码6 项目: Knowage-Server   文件: DistributionListDaoImpl.java
@Override
public DistributionList loadDistributionListByName(String name) throws EMFUserError {
	logger.debug("IN");
	DistributionList biDL = null;
	Session tmpSession = null;
	Transaction tx = null;
	try {
		tmpSession = getSession();
		tx = tmpSession.beginTransaction();
		Criterion nameCriterrion = Expression.eq("name", name);
		Criteria criteria = tmpSession.createCriteria(SbiDistributionList.class);
		criteria.add(nameCriterrion);
		SbiDistributionList hibDL = (SbiDistributionList) criteria.uniqueResult();
		if (hibDL == null)
			return null;
		biDL = toDistributionList(hibDL);
		tx.commit();
	} catch (HibernateException he) {
		logger.error("Error while loading the Distribution List with name " + name, he);
		if (tx != null)
			tx.rollback();
		throw new EMFUserError(EMFErrorSeverity.ERROR, 9104);
	} finally {
		if (tmpSession != null) {
			if (tmpSession.isOpen())
				tmpSession.close();
		}
	}
	logger.debug("OUT");
	return biDL;
}
 
@Override
public List<SbiMetaBcAttribute> loadAllBCAttributeFromTableColumn(int columnId) throws EMFUserError {
	logger.debug("IN");

	List toReturn = null;
	Session tmpSession = null;
	Transaction tx = null;

	try {
		tmpSession = getSession();
		tx = tmpSession.beginTransaction();

		Criterion labelCriterrion = Expression.eq("columnId", columnId);
		Criteria criteria = tmpSession.createCriteria(SbiMetaTableColumn.class);
		criteria.add(labelCriterrion);

		toReturn = criteria.list();
		if (toReturn == null)
			return null;
		tx.commit();

	} catch (HibernateException he) {
		logException(he);
		if (tx != null)
			tx.rollback();
		throw new EMFUserError(EMFErrorSeverity.ERROR, 100);
	} finally {
		if (tmpSession != null) {
			if (tmpSession.isOpen())
				tmpSession.close();
		}
	}

	logger.debug("OUT");
	return toReturn;
}
 
源代码8 项目: Knowage-Server   文件: DataSourceDAOHibImpl.java
private SbiDataSource loadSbiDataSourceWriteDefault(Session aSession) {
	Criterion labelCriterrion = Expression.eq("writeDefault", true);
	Criteria criteria = aSession.createCriteria(SbiDataSource.class);
	criteria.add(labelCriterrion);
	SbiDataSource hibDataSource = (SbiDataSource) criteria.uniqueResult();
	logger.debug("Hibernate datasource write default found in session: " + hibDataSource);
	return hibDataSource;
}
 
@Override
public BIObjectParameter loadBiObjParameterByObjIdAndLabel(Integer objId, String label) throws EMFUserError {
	BIObjectParameter objPar = null;
	Session aSession = null;
	Transaction tx = null;
	try {
		aSession = getSession();
		tx = aSession.beginTransaction();

		Criterion idCriterrion = Expression.eq("sbiObject.biobjId", objId);
		Criterion labelCriterrion = Expression.eq("label", label);
		Criteria criteria = aSession.createCriteria(SbiObjPar.class);
		criteria.add(idCriterrion);
		criteria.add(labelCriterrion);

		SbiObjPar hibObjPar = (SbiObjPar) criteria.uniqueResult();
		if (hibObjPar != null)
			objPar = toBIObjectParameter(hibObjPar);

		tx.commit();
	} catch (HibernateException he) {
		logException(he);
		if (tx != null)
			tx.rollback();
		throw new EMFUserError(EMFErrorSeverity.ERROR, 100);
	} finally {
		if (aSession != null) {
			if (aSession.isOpen())
				aSession.close();
		}
	}
	return objPar;
}
 
源代码10 项目: Knowage-Server   文件: SbiMetaTableDAOHibImpl.java
@Override
public List<SbiMetaTable> loadTablesFromSource(int sourceId) throws EMFUserError {
	logger.debug("IN");

	List toReturn = null;
	Session tmpSession = null;
	Transaction tx = null;

	try {
		tmpSession = getSession();
		tx = tmpSession.beginTransaction();

		Criterion labelCriterrion = Expression.eq("sourceid", sourceId);
		Criteria criteria = tmpSession.createCriteria(SbiMetaTable.class);
		criteria.add(labelCriterrion);

		toReturn = criteria.list();
		if (toReturn == null)
			return null;
		tx.commit();

	} catch (HibernateException he) {
		logException(he);
		if (tx != null)
			tx.rollback();
		throw new EMFUserError(EMFErrorSeverity.ERROR, 100);
	} finally {
		if (tmpSession != null) {
			if (tmpSession.isOpen())
				tmpSession.close();
		}
	}

	logger.debug("OUT");
	return toReturn;
}
 
@Override
public void modifyTableColumn(Session session, SbiMetaTableColumn aMetaTableColumn) throws EMFUserError {
	logger.debug("IN");

	Session tmpSession = session;

	try {
		SbiMetaTableColumn hibMeta = (SbiMetaTableColumn) tmpSession.load(SbiMetaTableColumn.class, aMetaTableColumn.getColumnId());

		hibMeta.setName(aMetaTableColumn.getName());
		hibMeta.setType(aMetaTableColumn.getType());
		hibMeta.setDeleted(aMetaTableColumn.isDeleted());

		SbiMetaTable metaTable = null;
		if (aMetaTableColumn.getSbiMetaTable().getTableId() < 0) {
			Criterion aCriterion = Expression.eq("valueId", aMetaTableColumn.getSbiMetaTable().getTableId());
			Criteria criteria = tmpSession.createCriteria(SbiMetaSource.class);
			criteria.add(aCriterion);
			metaTable = (SbiMetaTable) criteria.uniqueResult();
			if (metaTable == null) {
				throw new SpagoBIDAOException("The SbiMetaTable with id= " + aMetaTableColumn.getSbiMetaTable().getTableId() + " does not exist");
			}
			hibMeta.setSbiMetaTable(metaTable);
		}

		updateSbiCommonInfo4Update(hibMeta);

	} catch (HibernateException he) {
		logException(he);
		throw new HibernateException(he);
	} finally {
		logger.debug("OUT");
	}
}
 
源代码12 项目: Knowage-Server   文件: MenuDAOImpl.java
/**
 * Load menu by id.
 *
 * @param menuID the menu id
 * @param roleId the user's role id
 *
 * @return the menu
 *
 * @throws EMFUserError the EMF user error
 *
 * @see it.eng.spagobi.wapp.dao.IMenuDAO#loadMenuByID(integer)
 */
@Override
public Menu loadMenuByID(Integer menuID, Integer roleID) throws EMFUserError {
	Menu toReturn = null;
	Session tmpSession = null;
	Transaction tx = null;

	try {
		tmpSession = getSession();
		tx = tmpSession.beginTransaction();

		Criterion domainCdCriterrion = Expression.eq("menuId", menuID);
		Criteria criteria = tmpSession.createCriteria(SbiMenu.class);
		criteria.add(domainCdCriterrion);
		SbiMenu hibMenu = (SbiMenu) criteria.uniqueResult();
		if (hibMenu == null)
			return null;

		// SbiMenu hibMenu = (SbiMenu)tmpSession.load(SbiMenu.class,
		// menuID);
		toReturn = toMenu(hibMenu, roleID);

	} catch (HibernateException he) {
		logException(he);

		if (tx != null)
			tx.rollback();

		throw new EMFUserError(EMFErrorSeverity.ERROR, 100);

	} finally {
		if (tmpSession != null) {
			if (tmpSession.isOpen())
				tmpSession.close();

		}
	}
	return toReturn;
}
 
源代码13 项目: Knowage-Server   文件: MenuDAOImpl.java
@Override
public SbiMenu loadSbiMenubyName(String name) {
	Session tmpSession = null;
	Transaction tx = null;

	try {
		tmpSession = getSession();
		tx = tmpSession.beginTransaction();

		Criterion domainCdCriterrion = Expression.eq("name", name);
		Criteria criteria = tmpSession.createCriteria(SbiMenu.class);
		criteria.add(domainCdCriterrion);
		SbiMenu hibMenu = (SbiMenu) criteria.uniqueResult();

		return hibMenu;
	} catch (HibernateException he) {
		logException(he);
		if (tx != null)
			tx.rollback();

	} finally {
		if (tmpSession != null) {
			if (tmpSession.isOpen())
				tmpSession.close();
		}
	}
	return null;
}
 
@Override
public List<SbiMetaBcAttribute> loadAllBCAttributeFromBC(int bcId) throws EMFUserError {
	logger.debug("IN");

	List toReturn = null;
	Session tmpSession = null;
	Transaction tx = null;

	try {
		tmpSession = getSession();
		tx = tmpSession.beginTransaction();

		Criterion labelCriterrion = Expression.eq("bcId", bcId);
		Criteria criteria = tmpSession.createCriteria(SbiMetaBcAttribute.class);
		criteria.add(labelCriterrion);

		toReturn = criteria.list();
		if (toReturn == null)
			return null;
		tx.commit();

	} catch (HibernateException he) {
		logException(he);
		if (tx != null)
			tx.rollback();
		throw new EMFUserError(EMFErrorSeverity.ERROR, 100);
	} finally {
		if (tmpSession != null) {
			if (tmpSession.isOpen())
				tmpSession.close();
		}
	}

	logger.debug("OUT");
	return toReturn;
}
 
源代码15 项目: Knowage-Server   文件: ObjMetacontentDAOHibImpl.java
/**
 * Insert object's metadata content.
 *
 * @param aObjMetacontent
 *            the metadata content
 *
 * @throws EMFUserError
 *             the EMF user error
 *
 * @see it.eng.spagobi.tools.objmetadata.dao.IObjMetadataDAO#insertObjMetacontent(it.eng.spagobi.tools.objmetadata.bo.ObjMetacontent)
 */
@Override
public void insertObjMetacontent(ObjMetacontent aObjMetacontent) throws EMFUserError {

	logger.debug("IN");
	Session aSession = null;
	Transaction tx = null;
	Criterion aCriterion = null;
	Criteria criteria = null;
	try {
		aSession = getSession();
		tx = aSession.beginTransaction();

		SbiObjMetacontents hibContents = new SbiObjMetacontents();

		// get biobject reference
		aCriterion = Expression.eq("biobjId", aObjMetacontent.getBiobjId());
		criteria = aSession.createCriteria(SbiObjects.class);
		criteria.add(aCriterion);
		SbiObjects biobj = (SbiObjects) criteria.uniqueResult();
		hibContents.setSbiObjects(biobj);

		// get subobject reference
		if (aObjMetacontent.getSubobjId() == null) {
			hibContents.setSbiSubObjects(null);
		} else {
			aCriterion = Expression.eq("subObjId", aObjMetacontent.getSubobjId());
			criteria = aSession.createCriteria(SbiSubObjects.class);
			criteria.add(aCriterion);
			SbiSubObjects subobj = (SbiSubObjects) criteria.uniqueResult();
			hibContents.setSbiSubObjects(subobj);
		}

		SbiBinContents binaryContent = new SbiBinContents();
		binaryContent.setContent(aObjMetacontent.getContent());
		updateSbiCommonInfo4Insert(binaryContent);
		aSession.save(binaryContent);
		hibContents.setSbiBinContents(binaryContent);

		hibContents.setObjmetaId(aObjMetacontent.getObjmetaId());

		hibContents.setCreationDate(aObjMetacontent.getCreationDate());

		hibContents.setLastChangeDate(aObjMetacontent.getLastChangeDate());

		hibContents.setAdditionalInfo(aObjMetacontent.getAdditionalInfo());

		updateSbiCommonInfo4Insert(hibContents);
		aSession.save(hibContents);
		tx.commit();
	} catch (HibernateException he) {
		logger.error(
				"Error while inserting the metadata content with id "
						+ ((aObjMetacontent == null) ? "" : String.valueOf(aObjMetacontent.getObjMetacontentId())), he);

		if (tx != null)
			tx.rollback();

		throw new EMFUserError(EMFErrorSeverity.ERROR, 100);

	} finally {
		if (aSession != null) {
			if (aSession.isOpen())
				aSession.close();
			logger.debug("OUT");
		}
	}

}
 
/**
 * Load sub low functionalities.
 *
 * @param initialPath
 *            the initial path
 * @param recoverBIObjects
 *            the recover bi objects
 *
 * @return the list
 *
 * @throws EMFUserError
 *             the EMF user error
 *
 * @see it.eng.spagobi.analiticalmodel.functionalitytree.dao.ILowFunctionalityDAO#loadSubLowFunctionalities(java.lang.String, boolean)
 */
@Override
public List loadSubLowFunctionalities(String initialPath, boolean recoverBIObjects) throws EMFUserError {
	logger.debug("IN");
	Session aSession = null;
	Transaction tx = null;
	List realResult = new ArrayList();
	try {
		aSession = getSession();
		tx = aSession.beginTransaction();

		// loads folder corresponding to initial path
		Criterion domainCdCriterrion = Expression.eq("path", initialPath);
		Criteria criteria = aSession.createCriteria(SbiFunctions.class);
		criteria.add(domainCdCriterrion);
		SbiFunctions hibFunct = (SbiFunctions) criteria.uniqueResult();
		if (hibFunct == null) {
			return null;
		}
		LowFunctionality funct = toLowFunctionality(hibFunct, recoverBIObjects);
		putIntoCache(String.valueOf(funct.getId()), funct);
		realResult.add(funct);

		// loads sub functionalities

		/* ********* start luca changes *************** */
		// Query hibQuery =
		// aSession.createQuery(" from SbiFunctions s where s.path like '" +
		// initialPath + "/%' order by s.parentFunct.functId, s.prog");
		Query hibQuery = aSession.createQuery(" from SbiFunctions s where s.path like ? order by s.parentFunct.functId, s.prog");
		// Query hibQuery =
		// aSession.createQuery(" from SbiFunctions s where s.functTypeCd = 'LOW_FUNCT' and s.path like '"
		// + initialPath +
		// "/%' order by s.parentFunct.functId, s.prog");
		/* ********* end luca changes ***************** */
		hibQuery.setString(0, initialPath + "/%");
		List hibList = hibQuery.list();
		Iterator it = hibList.iterator();
		while (it.hasNext()) {
			funct = toLowFunctionality((SbiFunctions) it.next(), recoverBIObjects);
			putIntoCache(String.valueOf(funct.getId()), funct);
			realResult.add(funct);
		}
		tx.commit();
	} catch (HibernateException he) {
		logger.error("HibernateException", he);

		if (tx != null)
			tx.rollback();

		throw new EMFUserError(EMFErrorSeverity.ERROR, 100);

	} finally {
		if (aSession != null) {
			if (aSession.isOpen())
				aSession.close();
		}
	}
	logger.debug("OUT");
	return realResult;
}
 
源代码17 项目: Knowage-Server   文件: SbiMetaTableDAOHibImpl.java
/**
 * Modify a metatable.
 *
 * @param aMetaTable
 *            the sbimetatable changed
 *
 * @throws EMFUserError
 *             the EMF user error
 *
 * @see it.eng.spagobi.metadata.dao.ISbiMetaTableDAOHibImpl#modifyTable(SbiMetaTable)
 */
@Override
public void modifyTable(SbiMetaTable aMetaTable) throws EMFUserError {
	logger.debug("IN");

	Session tmpSession = null;
	Transaction tx = null;

	try {
		tmpSession = getSession();
		tx = tmpSession.beginTransaction();

		SbiMetaTable hibMeta = (SbiMetaTable) tmpSession.load(SbiMetaTable.class, aMetaTable.getTableId());

		hibMeta.setName(aMetaTable.getName());
		hibMeta.setDeleted(aMetaTable.isDeleted());

		SbiMetaSource metaSource = null;
		if (aMetaTable.getSbiMetaSource().getSourceId() < 0) {
			Criterion aCriterion = Expression.eq("valueId", aMetaTable.getSbiMetaSource().getSourceId());
			Criteria criteria = tmpSession.createCriteria(SbiMetaSource.class);
			criteria.add(aCriterion);
			metaSource = (SbiMetaSource) criteria.uniqueResult();
			if (metaSource == null) {
				throw new SpagoBIDAOException("The Domain with value_id= " + aMetaTable.getSbiMetaSource().getSourceId() + " does not exist");
			}
			hibMeta.setSbiMetaSource(metaSource);
		}

		updateSbiCommonInfo4Update(hibMeta);
		tx.commit();

	} catch (HibernateException he) {
		logException(he);

		if (tx != null)
			tx.rollback();

		throw new EMFUserError(EMFErrorSeverity.ERROR, 100);

	} finally {
		if (tmpSession != null) {
			if (tmpSession.isOpen())
				tmpSession.close();
		}
	}
	logger.debug("OUT");

}
 
源代码18 项目: Knowage-Server   文件: SbiGeoLayersDAOHibImpl.java
/**
 * Load layer by name.
 *
 * @param name
 *            the name
 *
 * @return the geo layer
 *
 * @throws EMFUserError
 *             the EMF user error
 *
 * @see it.eng.spagobi.mapcatalogue.dao.geo.bo.dao.ISbiGeoLayersDAO#loadLayerByName(string)
 */
@Override
public GeoLayer loadLayerByLabel(String label) throws EMFUserError {
	GeoLayer biLayer = null;
	Session tmpSession = null;
	// Transaction tx = null;

	try {
		tmpSession = getSession();
		// tx = tmpSession.beginTransaction();
		Criterion labelCriterrion = Expression.eq("label", label);
		Criteria criteria = tmpSession.createCriteria(SbiGeoLayers.class);
		criteria.add(labelCriterrion);
		SbiGeoLayers hibLayer = (SbiGeoLayers) criteria.uniqueResult();
		if (hibLayer == null)
			return null;
		biLayer = hibLayer.toGeoLayer();

		String resourcePath = SpagoBIUtilities.getResourcePath();
		if (biLayer.getPathFile() != null) {
			if (biLayer.getPathFile().startsWith(resourcePath)) {
				// biLayer.setPathFile(biLayer.getPathFile());
			} else {
				biLayer.setPathFile(resourcePath + File.separator + biLayer.getPathFile());
			}
		}

		// tx.commit();
	} catch (HibernateException he) {
		logException(he);
		// if (tx != null)
		// tx.rollback();
		throw new EMFUserError(EMFErrorSeverity.ERROR, 100);
	} finally {

		if (tmpSession != null) {
			if (tmpSession.isOpen())
				tmpSession.close();
		}

	}
	return biLayer;
}
 
源代码19 项目: sakai   文件: AssessmentGradingFacadeQueries.java
public Map<Long, List<ItemGradingData>> getItemScores(final Long itemId, List<AssessmentGradingData> scores, boolean loadItemGradingAttachment) {
    try {
        HashMap<Long, List<ItemGradingData>> map = new HashMap<>();

        HibernateCallback<List<ItemGradingData>> hcb = session -> {
            Criteria criteria = session.createCriteria(ItemGradingData.class);
            Disjunction disjunction = Expression.disjunction();

            /** make list from AssessmentGradingData ids */
            List<Long> gradingIdList = scores.stream()
                    .map(AssessmentGradingData::getAssessmentGradingId)
                    .collect(Collectors.toList());

            /** create or disjunctive expression for (in clauses) */
            List tempList;
            for (int i = 0; i < gradingIdList.size(); i += 50) {
                if (i + 50 > gradingIdList.size()) {
                    tempList = gradingIdList.subList(i, gradingIdList.size());
                    disjunction.add(Expression.in("assessmentGradingId", tempList));
                } else {
                    tempList = gradingIdList.subList(i, i + 50);
                    disjunction.add(Expression.in("assessmentGradingId", tempList));
                }
            }

            if (itemId.equals(Long.valueOf(0))) {
                criteria.add(disjunction);
                //criteria.add(Expression.isNotNull("submittedDate"));
            } else {

                /** create logical and between the pubCriterion and the disjunction criterion */
                //Criterion pubCriterion = Expression.eq("publishedItem.itemId", itemId);
                Criterion pubCriterion = Expression.eq("publishedItemId", itemId);
                criteria.add(Expression.and(pubCriterion, disjunction));
                //criteria.add(Expression.isNotNull("submittedDate"));
            }
            criteria.addOrder(Order.asc("agentId"));
            criteria.addOrder(Order.desc("submittedDate"));
            return criteria.list();
            //large list cause out of memory error (java heap space)
            //return criteria.setMaxResults(10000).list();
        };
        List<ItemGradingData> temp = getHibernateTemplate().execute(hcb);

        Map<Long, Set<ItemGradingAttachment>> attachmentMap = new HashMap<>();
        if (loadItemGradingAttachment) {
            attachmentMap = getItemGradingAttachmentMap(itemId);
        }
        for (ItemGradingData data : temp) {
            if (loadItemGradingAttachment) {
                if (attachmentMap.get(data.getItemGradingId()) != null) {
                    data.setItemGradingAttachmentSet(attachmentMap.get(data.getItemGradingId()));
                } else {
                    data.setItemGradingAttachmentSet(new HashSet<>());
                }
            }
            List<ItemGradingData> thisone = map.get(data.getPublishedItemId());
            if (thisone == null) {
                thisone = new ArrayList<>();
            }
            thisone.add(data);
            map.put(data.getPublishedItemId(), thisone);
        }
        return map;
    } catch (Exception e) {
        log.warn(e.getMessage(), e);
        return new HashMap<>();
    }
}
 
源代码20 项目: Knowage-Server   文件: SbiMetaTableDAOHibImpl.java
/**
 * Insert a metatable.
 *
 * @param aMetaSource
 *            the sbimetatable to insert
 *
 * @throws EMFUserError
 *             the EMF user error
 *
 * @see it.eng.spagobi.metadata.dao.ISbiMetaTableDAOHibImpl#insertSource(SbiMetaTable)
 */
@Override
public Integer insertTable(SbiMetaTable aMetaTable) throws EMFUserError {
	logger.debug("IN");

	Session tmpSession = null;
	Transaction tx = null;
	Integer idToReturn = null;

	try {
		tmpSession = getSession();
		tx = tmpSession.beginTransaction();

		SbiMetaTable hibMeta = new SbiMetaTable();
		hibMeta.setName(aMetaTable.getName());
		hibMeta.setDeleted(aMetaTable.isDeleted());

		SbiMetaSource metaSource = null;
		if (aMetaTable.getSbiMetaSource() != null) {
			Criterion aCriterion = Expression.eq("sourceId", aMetaTable.getSbiMetaSource().getSourceId());
			Criteria criteria = tmpSession.createCriteria(SbiMetaSource.class);
			criteria.add(aCriterion);
			metaSource = (SbiMetaSource) criteria.uniqueResult();
			if (metaSource == null) {
				throw new SpagoBIDAOException("The Domain with value_id= " + aMetaTable.getSbiMetaSource().getSourceId() + " does not exist");
			}
			hibMeta.setSbiMetaSource(metaSource);
		}

		updateSbiCommonInfo4Insert(hibMeta);
		idToReturn = (Integer) tmpSession.save(hibMeta);
		tx.commit();

	} catch (HibernateException he) {
		logException(he);

		if (tx != null)
			tx.rollback();

		throw new EMFUserError(EMFErrorSeverity.ERROR, 100);

	} finally {

		if (tmpSession != null) {
			if (tmpSession.isOpen())
				tmpSession.close();
		}

	}
	logger.debug("OUT");
	return idToReturn;
}
 
 同类方法