org.hibernate.Session#load ( )源码实例Demo

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

源代码1 项目: Knowage-Server   文件: ObjTemplateDAOHibImpl.java
@Override
public void deleteBIObjectTemplate(Integer tempId) throws EMFInternalError {
	Session aSession = null;
	Transaction tx = null;
	try {
		aSession = getSession();
		tx = aSession.beginTransaction();
		SbiObjTemplates hibObjTemp = (SbiObjTemplates) aSession.load(SbiObjTemplates.class, tempId);
		SbiBinContents hibBinCont = hibObjTemp.getSbiBinContents();
		aSession.delete(hibBinCont);
		aSession.delete(hibObjTemp);
		tx.commit();
	} catch (HibernateException he) {
		logException(he);
		if (tx != null)
			tx.rollback();
		throw new EMFInternalError(EMFErrorSeverity.ERROR, "100");
	} finally {
		if (aSession != null) {
			if (aSession.isOpen())
				aSession.close();
		}
	}
}
 
源代码2 项目: document-management-system   文件: CronTabDAO.java
/**
 * Set end time
 */
public static void setLastEnd(long ctId) throws DatabaseException {
	log.debug("setLastEnd({})", ctId);
	Session session = null;
	Transaction tx = null;

	try {
		session = HibernateUtil.getSessionFactory().openSession();
		tx = session.beginTransaction();
		CronTab ct = (CronTab) session.load(CronTab.class, ctId);
		ct.setLastEnd(Calendar.getInstance());
		session.update(ct);
		HibernateUtil.commit(tx);
	} catch (HibernateException e) {
		HibernateUtil.rollback(tx);
		throw new DatabaseException(e.getMessage(), e);
	} finally {
		HibernateUtil.close(session);
	}

	log.debug("setLastEnd: void");
}
 
/**
 * Delete received proposed query
 */
public static void deleteReceived(long pqId) throws DatabaseException {
	log.debug("deleteReceived({})", pqId);
	Session session = null;
	Transaction tx = null;

	try {
		session = HibernateUtil.getSessionFactory().openSession();
		tx = session.beginTransaction();
		ProposedQueryReceived pq = (ProposedQueryReceived) session.load(ProposedQueryReceived.class, pqId);
		session.delete(pq);
		HibernateUtil.commit(tx);
	} catch (HibernateException e) {
		HibernateUtil.rollback(tx);
		throw new DatabaseException(e.getMessage(), e);
	} finally {
		HibernateUtil.close(session);
	}

	log.debug("deleteReceived: void");
}
 
源代码4 项目: document-management-system   文件: SearchTest.java
public void testUpdate() {
	log.info("testUpdate()");
	Session session = null;
	Transaction tx = null;
	
	try {
		session = HibernateUtil.getSessionFactory().openSession();
		tx = session.beginTransaction();
		Document doc = (Document) session.load(Document.class, uuid);
		assertNotNull(doc);
		
		doc.getKeywords().add("alfa");
		doc.getKeywords().add("beta");
		session.update(doc);
		HibernateUtil.commit(tx);
	} catch (HibernateException e) {
		log.error(e.getMessage(), e);
		HibernateUtil.rollback(tx);
		throw e;
	} finally {
		HibernateUtil.close(session);
	}
}
 
源代码5 项目: java-course-ee   文件: HibernateSimple.java
public static void main(String[] args) {
    HibernateSimple hs = new HibernateSimple();

    SessionFactory sf = hs.getSessionFactory();

    Session s = sf.getCurrentSession();
    s.beginTransaction();

    // Получить список через SQL-запрос
    List<Region> regionList = s.createQuery("from Region").list();
    for (Region r : regionList) {
        System.out.println(r);
    }

    // Добавить через SQL-запрос
    Region newRegion = new Region();
    newRegion.setRegionName("Simple Region");
    Serializable id = s.save(newRegion);
    // Изменить через SQL-запрос
    regionList.get(0).setRegionName("Other Region");

    s = restartSession(s, sf);

    // Загрузить через SQL-запрос
    //Region load = (Region) s.get(Region.class, id);
    Region load = (Region) s.load(Region.class, id);

    // Удалить через SQL-запрос
    s.delete(load);

    s.getTransaction().commit();
}
 
/**
 * Insert viewpoint.
 *
 * @param viewpoint
 *            the viewpoint
 *
 * @throws EMFUserError
 *             the EMF user error
 *
 * @see it.eng.spagobi.analiticalmodel.document.dao.IMetaModelViewpointDAO#insertViewpoint(it.eng.spagobi.analiticalmodel.document.bo.Viewpoint)
 */
@Override
public void insertMetaModelViewpoint(Viewpoint viewpoint) throws EMFUserError {
	Session aSession = null;
	Transaction tx = null;
	try {
		aSession = getSession();
		tx = aSession.beginTransaction();
		SbiMetaModelViewpoints hibViewpoint = new SbiMetaModelViewpoints();

		// hibViewpoint.setVpId(vpId);
		SbiMetaModel aSbiMetaModel = (SbiMetaModel) aSession.load(SbiMetaModel.class, viewpoint.getBiobjId());
		hibViewpoint.setSbiMetaModel(aSbiMetaModel);
		hibViewpoint.setVpDesc(viewpoint.getVpDesc());
		hibViewpoint.setVpOwner(viewpoint.getVpOwner());
		hibViewpoint.setVpName(viewpoint.getVpName());
		hibViewpoint.setVpScope(viewpoint.getVpScope());
		hibViewpoint.setVpValueParams(viewpoint.getVpValueParams());
		hibViewpoint.setVpCreationDate(viewpoint.getVpCreationDate());
		updateSbiCommonInfo4Insert(hibViewpoint);
		aSession.save(hibViewpoint);
		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();
		}

	}

}
 
源代码7 项目: Knowage-Server   文件: ObjNoteDAOHibImpl.java
@Override
public void saveExecutionNotes(Integer biobjId, ObjNote objNote) throws Exception {
	Session aSession = null;
	Transaction tx = null;
	try {
		aSession = getSession();
		tx = aSession.beginTransaction();
		Date now = new Date();
		String execReq = objNote.getExecReq();
		SbiObjects hibBIObject = (SbiObjects) aSession.load(SbiObjects.class, biobjId);
		SbiBinContents hibBinContent = new SbiBinContents();
		hibBinContent.setContent(objNote.getContent());
		Integer idBin = (Integer) aSession.save(hibBinContent);
		// recover the saved binary hibernate object
		hibBinContent = (SbiBinContents) aSession.load(SbiBinContents.class, idBin);
		// store the object note
		SbiObjNotes hibObjNote = new SbiObjNotes();
		hibObjNote.setExecReq(execReq);
		hibObjNote.setSbiBinContents(hibBinContent);
		hibObjNote.setSbiObject(hibBIObject);
		hibObjNote.setOwner(objNote.getOwner());
		hibObjNote.setIsPublic(objNote.getIsPublic());
		hibObjNote.setCreationDate(now);
		hibObjNote.setLastChangeDate(now);
		updateSbiCommonInfo4Insert(hibObjNote);
		aSession.save(hibObjNote);
		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();
		}
	}
}
 
源代码8 项目: scheduling   文件: SchedulerDBManager.java
private TaskResultData saveTaskResult(TaskData.DBTaskId taskId, TaskResultImpl result, Session session) {
    TaskData taskRuntimeData = session.load(TaskData.class, taskId);

    TaskResultData resultData = TaskResultData.createTaskResultData(taskRuntimeData, result);
    session.save(resultData);

    return resultData;
}
 
源代码9 项目: Knowage-Server   文件: ObjMetadataDAOHibImpl.java
/**
 * Load object's metadata by id.
 *
 * @param id the identifier
 *
 * @return the metadata
 *
 * @throws EMFUserError the EMF user error
 *
 * @see it.eng.spagobi.tools.objmetadata.dao.IObjMetadataDAO#loadObjMetaDataByID(java.lang.Integer)
 */
@Override
public ObjMetadata loadObjMetaDataByID(Integer id) throws EMFUserError {

	logger.debug("IN");
	ObjMetadata toReturn = null;
	Session aSession = null;
	Transaction tx = null;

	try {
		aSession = getSession();
		tx = aSession.beginTransaction();
		SbiObjMetadata hibDataSource = (SbiObjMetadata) aSession.load(SbiObjMetadata.class, id);
		toReturn = toObjMetadata(hibDataSource);
		tx.commit();

	} catch (HibernateException he) {
		logger.error("Error while loading the metadata with id " + id.toString(), he);

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

		throw new EMFUserError(EMFErrorSeverity.ERROR, 100);

	} finally {
		if (aSession != null) {
			if (aSession.isOpen())
				aSession.close();
			logger.debug("OUT");
		}
	}
	logger.debug("OUT");
	return toReturn;
}
 
源代码10 项目: Knowage-Server   文件: ObjParviewDAOHibImpl.java
/**
 * Insert obj parview.
 *
 * @param aObjParview the a obj parview
 *
 * @throws EMFviewrError the EMF user error
 *
 * @see it.eng.spagobi.behaviouralmodel.analyticaldriver.dao.IObjParuseDAO#insertObjParuse(it.eng.spagobi.behaviouralmodel.analyticaldriver.bo.ObjParuse)
 */
@Override
public Integer insertObjParview(ObjParview aObjParview) throws HibernateException {
	SbiObjParview view = new SbiObjParview();
	Session aSession = null;
	Transaction tx = null;
	try {
		aSession = getSession();
		tx = aSession.beginTransaction();
		SbiObjPar sbiObjPar = (SbiObjPar) aSession.load(SbiObjPar.class, aObjParview.getParId());
		SbiObjPar sbiObjParFather = (SbiObjPar) aSession.load(SbiObjPar.class, aObjParview.getParFatherId());
		if (sbiObjParFather == null) {
			SpagoBITracer.major(SpagoBIConstants.NAME_MODULE, this.getClass().getName(), "modifyObjParview",
					"the BIObjectParameter with " + "id=" + aObjParview.getParFatherId() + " does not exist.");

		}

		view.setSbiObjPar(sbiObjPar);
		view.setSbiObjParFather(sbiObjParFather);
		view.setOperation(aObjParview.getOperation());
		view.setCompareValue(aObjParview.getCompareValue());
		view.setProg(aObjParview.getProg());
		view.setViewLabel(aObjParview.getViewLabel());
		updateSbiCommonInfo4Insert(view);
		view.setId((Integer) aSession.save(view));
		tx.commit();
	} catch (HibernateException he) {
		logException(he);
		if (tx != null)
			tx.rollback();
		throw new HibernateException(he.getLocalizedMessage(), he);
	} finally {
		if (aSession != null) {
			if (aSession.isOpen())
				aSession.close();
		}
	}
	return view.getId();
}
 
源代码11 项目: Knowage-Server   文件: ObjMetacontentDAOHibImpl.java
/**
 * Load object's metadata content by id.
 *
 * @param id
 *            the identifier
 *
 * @return the metadata content
 *
 * @throws EMFUserError
 *             the EMF user error
 *
 * @see it.eng.spagobi.tools.objmetadata.dao.IObjMetacontentDAO#loadObjMetaContentByID(java.lang.Integer)
 */
@Override
public ObjMetacontent loadObjMetaContentByID(Integer id) throws EMFUserError {
	logger.debug("IN");

	ObjMetacontent toReturn = null;
	Session aSession = null;
	Transaction tx = null;

	try {
		aSession = getSession();
		tx = aSession.beginTransaction();
		SbiObjMetacontents hibContent = (SbiObjMetacontents) aSession.load(SbiObjMetacontents.class, id);
		toReturn = toObjMetacontent(hibContent);
		tx.rollback();
	} catch (HibernateException he) {
		logger.error("Error while loading the metadata content with id = " + id, 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 toReturn;
}
 
源代码12 项目: Knowage-Server   文件: LovDAOHibImpl.java
/**
 * Erase modalities value.
 *
 * @param aModalitiesValue
 *            the a modalities value
 *
 * @throws EMFUserError
 *             the EMF user error
 *
 * @see it.eng.spagobi.behaviouralmodel.lov.dao.IModalitiesValueDAO#eraseModalitiesValue(it.eng.spagobi.behaviouralmodel.lov.bo.ModalitiesValue)
 */
@Override
public void eraseModalitiesValue(ModalitiesValue aModalitiesValue) throws EMFUserError {
	logger.debug("IN");
	Session aSession = null;
	Transaction tx = null;
	try {
		aSession = getSession();
		tx = aSession.beginTransaction();
		SbiLov hibLov = (SbiLov) aSession.load(SbiLov.class, aModalitiesValue.getId());
		aSession.delete(hibLov);
		tx.commit();
	} catch (HibernateException he) {
		logger.debug("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");
	}
}
 
源代码13 项目: scheduling   文件: SchedulerDBManager.java
@SuppressWarnings("unchecked")
private List<TaskResult> loadTaskResultAllAttempts(Session session, TaskId taskId) {
    DBTaskId dbTaskId = taskId(taskId);

    TaskData task = session.load(TaskData.class, dbTaskId);
    Query query = session.getNamedQuery("loadTasksResultByTaskAsc").setParameter("task", task);

    return ((List<TaskResultData>) query.list()).stream()
                                                .map(resultData -> resultData.toTaskResult(taskId))
                                                .collect(Collectors.toList());
}
 
源代码14 项目: Knowage-Server   文件: ParameterDAOHibImpl.java
/**
 * Modify parameter.
 *
 * @param aParameter
 *            the a parameter
 *
 * @throws EMFUserError
 *             the EMF user error
 *
 * @see it.eng.spagobi.behaviouralmodel.analyticaldriver.dao.IParameterDAO#modifyParameter(it.eng.spagobi.behaviouralmodel.analyticaldriver.bo.Parameter)
 */
@Override
public void modifyParameter(Parameter aParameter) throws EMFUserError {
	Session aSession = null;
	Transaction tx = null;

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

		String[] info = aParameter.getModality().split(",");
		List<String> list = Arrays.asList(info);
		String input_type_cd = null;
		String input_type_id = null;

		Iterator<String> iterator = list.iterator();
		while (iterator.hasNext()) {
			input_type_cd = iterator.next();
			input_type_id = iterator.next();

		}

		Integer typeId = Integer.valueOf(input_type_id);
		SbiDomains parameterType = (SbiDomains) aSession.load(SbiDomains.class, typeId);

		SbiParameters hibParameters = (SbiParameters) aSession.load(SbiParameters.class, aParameter.getId());
		updateSbiCommonInfo4Update(hibParameters);
		hibParameters.setDescr(aParameter.getDescription());
		hibParameters.setLength(new Short(aParameter.getLength().shortValue()));
		hibParameters.setLabel(aParameter.getLabel());
		hibParameters.setName(aParameter.getName());
		hibParameters.setParameterTypeCode(input_type_cd);
		hibParameters.setMask(aParameter.getMask());
		hibParameters.setParameterType(parameterType);
		hibParameters.setValueSelection(aParameter.getValueSelection());
		hibParameters.setSelectedLayer(aParameter.getSelectedLayer());
		hibParameters.setSelectedLayerProp(aParameter.getSelectedLayerProp());

		if (aParameter.isFunctional())
			hibParameters.setFunctionalFlag(new Short((short) 1));
		else
			hibParameters.setFunctionalFlag(new Short((short) 0));

		if (aParameter.isTemporal())
			hibParameters.setTemporalFlag(new Short((short) 1));
		else
			hibParameters.setTemporalFlag(new Short((short) 0));

		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();
		}
	}

}
 
源代码15 项目: cacheonix-core   文件: ProxyTest.java
public void testProxy() {
	Session s = openSession();
	Transaction t = s.beginTransaction();
	DataPoint dp = new DataPoint();
	dp.setDescription("a data point");
	dp.setX( new BigDecimal(1.0) );
	dp.setY( new BigDecimal(2.0) );
	s.persist(dp);
	s.flush();
	s.clear();

	dp = (DataPoint) s.load( DataPoint.class, new Long(dp.getId() ));
	assertFalse( Hibernate.isInitialized(dp) );
	DataPoint dp2 = (DataPoint) s.get( DataPoint.class, new Long(dp.getId()) );
	assertSame(dp, dp2);
	assertTrue( Hibernate.isInitialized(dp) );
	s.clear();

	dp = (DataPoint) s.load( DataPoint.class, new Long( dp.getId() ) );
	assertFalse( Hibernate.isInitialized(dp) );
	dp2 = (DataPoint) s.load( DataPoint.class, new Long( dp.getId() ), LockMode.NONE );
	assertSame(dp, dp2);
	assertFalse( Hibernate.isInitialized(dp) );
	s.clear();

	dp = (DataPoint) s.load( DataPoint.class, new Long( dp.getId() ) );
	assertFalse( Hibernate.isInitialized(dp) );
	dp2 = (DataPoint) s.load( DataPoint.class, new Long( dp.getId() ), LockMode.READ );
	assertSame(dp, dp2);
	assertTrue( Hibernate.isInitialized(dp) );
	s.clear();

	dp = (DataPoint) s.load( DataPoint.class, new Long (dp.getId() ));
	assertFalse( Hibernate.isInitialized(dp) );
	dp2 = (DataPoint) s.get( DataPoint.class, new Long ( dp.getId() ) , LockMode.READ );
	assertSame(dp, dp2);
	assertTrue( Hibernate.isInitialized(dp) );
	s.clear();

	dp = (DataPoint) s.load( DataPoint.class, new Long  ( dp.getId() ) );
	assertFalse( Hibernate.isInitialized(dp) );
	dp2 = (DataPoint) s.createQuery("from DataPoint").uniqueResult();
	assertSame(dp, dp2);
	assertTrue( Hibernate.isInitialized(dp) );
	s.delete( dp );
	t.commit();
	s.close();
}
 
/**
 * Erase low functionality.
 *
 * @param aLowFunctionality
 *            the a low functionality
 * @param profile
 *            the profile
 *
 * @throws EMFUserError
 *             the EMF user error
 *
 * @see it.eng.spagobi.analiticalmodel.functionalitytree.dao.ILowFunctionalityDAO#eraseLowFunctionality(it.eng.spagobi.analiticalmodel.functionalitytree.bo.LowFunctionality,
 *      it.eng.spago.security.IEngUserProfile)
 */
@Override
public void eraseLowFunctionality(LowFunctionality aLowFunctionality, IEngUserProfile profile) throws EMFUserError {
	logger.debug("IN");
	Session aSession = null;
	Transaction tx = null;
	try {
		if (hasChild(aLowFunctionality.getId())) {
			HashMap params = new HashMap();
			params.put(PAGE, "BIObjectsPage");
			// params.put(SpagoBIConstants.ACTOR,
			// SpagoBIConstants.ADMIN_ACTOR);
			params.put(SpagoBIConstants.OPERATION, SpagoBIConstants.FUNCTIONALITIES_OPERATION);
			throw new EMFUserError(EMFErrorSeverity.ERROR, 1000, new Vector(), params);
		}
		aSession = getSession();
		tx = aSession.beginTransaction();
		SbiFunctions hibFunct = (SbiFunctions) aSession.load(SbiFunctions.class, aLowFunctionality.getId());
		Set oldRoles = hibFunct.getSbiFuncRoles();
		Iterator iterOldRoles = oldRoles.iterator();
		while (iterOldRoles.hasNext()) {
			SbiFuncRole role = (SbiFuncRole) iterOldRoles.next();
			aSession.delete(role);
		}

		// update prog column in other functions
		// String hqlUpdateProg =
		// "update SbiFunctions s set s.prog = (s.prog - 1) where s.prog > "
		// + hibFunct.getProg() + " and s.parentFunct.functId = " +
		// hibFunct.getParentFunct().getFunctId();
		if (hibFunct.getParentFunct() != null) {
			String hqlUpdateProg = "update SbiFunctions s set s.prog = (s.prog - 1) where s.prog > ? " + " and s.parentFunct.functId = ?";
			Query query = aSession.createQuery(hqlUpdateProg);
			query.setInteger(0, hibFunct.getProg().intValue());
			query.setInteger(1, hibFunct.getParentFunct().getFunctId().intValue());
			query.executeUpdate();
		}

		aSession.delete(hibFunct);

		tx.commit();
	} catch (HibernateException he) {
		logger.error("HibernateException", he);

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

		throw new EMFUserError(EMFErrorSeverity.ERROR, 100);

	} catch (EMFUserError emfue) {
		if (tx != null)
			tx.rollback();
		throw emfue;
	} catch (Exception e) {
		logException(e);
		if (tx != null)
			tx.rollback();
		throw new EMFUserError(EMFErrorSeverity.ERROR, 100);
	} finally {
		if (aSession != null)
			if (aSession != null) {
				if (aSession.isOpen()) {
					aSession.close();
					logger.debug("The [eraseLowFunctionality] occurs. LowFunctionality cache will be cleaned.");
					this.clearCache();
				}
				logger.debug("OUT");
			}
	}
}
 
源代码17 项目: Knowage-Server   文件: ParameterUseDAOHibImpl.java
/**
 * Erase from hibSession all things related to parameter with parId
 *
 * @param parId
 *            the par id
 * @param sSession
 *            the hibernate session
 *
 * @throws EMFUserError
 *             the EMF user error
 *
 * @see it.eng.spagobi.behaviouralmodel.analyticaldriver.dao.IParameterUseDAO#eraseParameterUseByParId(java.lang.Integer)
 */
@Override
public void eraseParameterUseByParIdSameSession(Integer parId, Session sessionCurrDB) throws EMFUserError {
	logger.debug("IN");
	List parUseList = null;
	IParameterUseDAO parUseDAO = DAOFactory.getParameterUseDAO();
	parUseList = parUseDAO.loadParametersUseByParId(parId);
	Iterator i = parUseList.iterator();
	// run all parameters Use related to Parameter
	try {

		for (Iterator iterator = parUseList.iterator(); iterator.hasNext();) {

			Object o = iterator.next();
			ParameterUse parameterUse = (ParameterUse) o;
			SbiParuse sbiParuse = (SbiParuse) sessionCurrDB.load(SbiParuse.class, parameterUse.getUseID());

			Set checks = sbiParuse.getSbiParuseCks();
			Set dets = sbiParuse.getSbiParuseDets();

			logger.debug("Delete details");

			for (Iterator iterator2 = dets.iterator(); iterator2.hasNext();) {
				SbiParuseDet det = (SbiParuseDet) iterator2.next();
				sessionCurrDB.delete(det);
			}
			logger.debug("Delete checks");
			for (Iterator iterator2 = checks.iterator(); iterator2.hasNext();) {
				SbiParuseCk check = (SbiParuseCk) iterator2.next();
				sessionCurrDB.delete(check);
			}

			logger.debug("Delete obj Paruse used on correlation parameters");
			eraseParameterObjUseByParuseIdSameSession(sbiParuse.getUseId(), sessionCurrDB);

			sessionCurrDB.delete(sbiParuse);
			sessionCurrDB.flush();
			logger.debug("OUT");

		}
	} catch (Exception ex) {
		logException(ex);
		throw new EMFUserError(EMFErrorSeverity.ERROR, 100);
	}
}
 
源代码18 项目: Knowage-Server   文件: ObjMetadataDAOHibImpl.java
/**
 * Modify metadata.
 *
 * @param aObjMetadata the metadata
 *
 * @throws EMFUserError the EMF user error
 *
 * @see it.eng.spagobi.tools.objmetadata.dao.IObjMetadataDAO#modifyObjMetadata(it.eng.spagobi.tools.objmetadata.bo.ObjMetadata)
 */
@Override
public void modifyObjMetadata(ObjMetadata aObjMetadata) throws EMFUserError {
	logger.debug("IN");

	Session aSession = null;
	Transaction tx = null;
	try {
		aSession = getSession();
		tx = aSession.beginTransaction();
		Criterion aCriterion = Expression.eq("valueId", aObjMetadata.getDataType());
		Criteria criteria = aSession.createCriteria(SbiDomains.class);
		criteria.add(aCriterion);

		SbiDomains dataType = (SbiDomains) criteria.uniqueResult();

		if (dataType == null) {
			logger.error("The Domain with value_id= " + aObjMetadata.getDataType() + " does not exist.");
			throw new EMFUserError(EMFErrorSeverity.ERROR, 1035);
		}

		SbiObjMetadata hibMeta = (SbiObjMetadata) aSession.load(SbiObjMetadata.class, aObjMetadata.getObjMetaId());
		hibMeta.setLabel(aObjMetadata.getLabel());
		hibMeta.setName(aObjMetadata.getName());
		hibMeta.setDescription(aObjMetadata.getDescription());
		hibMeta.setDataType(dataType);
		updateSbiCommonInfo4Update(hibMeta);
		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();
		}
		logger.debug("OUT");
	}

}
 
@Override
public void moveDownLowFunctionality(Integer functionalityID) throws EMFUserError {
	logger.debug("IN");
	Session aSession = null;
	Transaction tx = null;
	try {
		aSession = getSession();
		tx = aSession.beginTransaction();
		SbiFunctions hibFunct = (SbiFunctions) aSession.load(SbiFunctions.class, functionalityID);

		Integer oldProg = hibFunct.getProg();
		Integer newProg = new Integer(oldProg.intValue() + 1);

		// String upperFolderHql = "from SbiFunctions s where s.prog = " +
		// newProg.toString() +
		// " and s.parentFunct.functId = " +
		// hibFunct.getParentFunct().getFunctId().toString();
		String upperFolderHql = "from SbiFunctions s where s.prog = ? " + " and s.parentFunct.functId = ?";
		Query query = aSession.createQuery(upperFolderHql);
		query.setInteger(0, newProg.intValue());
		query.setInteger(1, hibFunct.getParentFunct().getFunctId().intValue());
		SbiFunctions hibUpperFunct = (SbiFunctions) query.uniqueResult();
		if (hibUpperFunct == null) {
			logger.error("The function with prog [" + newProg + "] does not exist.");
			return;
		}

		hibFunct.setProg(newProg);
		hibUpperFunct.setProg(oldProg);

		updateSbiCommonInfo4Update(hibFunct);
		updateSbiCommonInfo4Update(hibUpperFunct);

		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("The [moveDownLowFunctionality] occurs. LowFunctionality cache will be cleaned.");
				this.clearCache();
			}
			logger.debug("OUT");
		}
	}
}
 
public void deleteFederatedDatasetById(Integer id, Session aSession) throws Exception {
	logger.debug("IN");
	SbiFederationDefinition federationToDelete = (SbiFederationDefinition) aSession.load(SbiFederationDefinition.class, id);
	aSession.delete(federationToDelete);
}