Java Code Examples for org.hibernate.HibernateException#getLocalizedMessage()
The following examples show how to use
org.hibernate.HibernateException#getLocalizedMessage() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: BIObjectParameterDAOHibImpl.java From Knowage-Server with GNU Affero General Public License v3.0 | 6 votes |
@Override public BIObjectParameter loadBiObjParameterById(Integer id) throws HibernateException { BIObjectParameter objPar = null; Session aSession = null; Transaction tx = null; try { aSession = getSession(); tx = aSession.beginTransaction(); SbiObjPar hibObjPar = (SbiObjPar) aSession.load(SbiObjPar.class, id); if (hibObjPar != null) objPar = toBIObjectParameter(hibObjPar); 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 objPar; }
Example 2
Source File: ObjTemplate.java From Knowage-Server with GNU Affero General Public License v3.0 | 6 votes |
/** * Tries to load binary content from database for this ObjTemplate instance, given its binary content identifier, if content field is null. * * @return The binary content of this instance; if it is null, it tries to load it from database if binary content identifier is available * * @throws EMFUserError * if some errors while reading from db occurs * @throws EMFInternalError * if some errors while reading from db occurs */ public byte[] getContent() throws HibernateException { if (content == null) { if (binId != null) { // reads from database try { content = DAOFactory.getBinContentDAO().getBinContent(binId); } catch (HibernateException e) { logger.error("Error while recovering content of template with id = [" + id + "], binary content id = [" + binId + "], " + "name = [" + name + "] of biobject with id = [" + biobjId + "]" + e); throw new HibernateException(e.getLocalizedMessage(), e); } } else { logger.warn("Both content field of this istance and binary identifier are null. Cannot load content from database."); } } return content; }
Example 3
Source File: BIMetaModelParameterDAOHibImpl.java From Knowage-Server with GNU Affero General Public License v3.0 | 6 votes |
@Override public SbiMetaModelParameter loadById(Integer id) throws HibernateException { SbiMetaModelParameter metaModel = null; Session session = null; Transaction transaction = null; try { session = getSession(); transaction = session.beginTransaction(); metaModel = (SbiMetaModelParameter) session.load(SbiMetaModelParameter.class, id); } catch (HibernateException he) { logException(he); if (transaction != null) transaction.rollback(); throw new SpagoBIRuntimeException(he.getLocalizedMessage(), he); } finally { if (session != null) { if (session.isOpen()) session.close(); } } return metaModel; }
Example 4
Source File: ObjParviewDAOHibImpl.java From Knowage-Server with GNU Affero General Public License v3.0 | 5 votes |
/** * Erase obj parview. * * @param aObjParview the a obj parview * * @throws EMFUserError the EMF user error * * @see it.eng.spagobi.behaviouralmodel.analyticaldriver.dao.IObjParviewDAO#eraseObjParview(ObjParview) */ @Override public void eraseObjParview(ObjParview aObjParview) throws HibernateException { Session aSession = null; Transaction tx = null; try { aSession = getSession(); tx = aSession.beginTransaction(); eraseObjParview(aObjParview, aSession); 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(); } } /* * Criterion aCriterion = Expression.and( Expression.eq("id.sbiObjPar.objParId", aObjParuse.getObjParId()), Expression.eq("id.sbiParuse.useId", * aObjParuse.getParuseId())); Criteria aCriteria = aSession.createCriteria(SbiObjParuse.class); aCriteria.add(aCriterion); SbiObjParuse sbiObjParuse = * (SbiObjParuse)aCriteria.uniqueResult(); */ }
Example 5
Source File: ObjParuseDAOHibImpl.java From Knowage-Server with GNU Affero General Public License v3.0 | 5 votes |
@Override public List loadObjParusesFather(Integer objParId) throws HibernateException { List toReturn = new ArrayList(); Session aSession = null; Transaction tx = null; try { aSession = getSession(); tx = aSession.beginTransaction(); // String hql = "from SbiObjParuse s where s.id.sbiObjPar.objParId = " + objParId + " order by s.prog"; String hql = "from SbiObjParuse s where s.sbiObjParFather.objParId = ? order by s.prog"; Query hqlQuery = aSession.createQuery(hql); hqlQuery.setInteger(0, objParId.intValue()); List sbiObjParuses = hqlQuery.list(); Iterator it = sbiObjParuses.iterator(); while (it.hasNext()) { toReturn.add(toObjParuse((SbiObjParuse) it.next())); } 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 toReturn; }
Example 6
Source File: MetaModelParuseDAOHibImpl.java From Knowage-Server with GNU Affero General Public License v3.0 | 5 votes |
@Override public List loadMetaModelParusesFather(Integer metaModelParId) throws HibernateException { List toReturn = new ArrayList(); Session aSession = null; Transaction tx = null; try { aSession = getSession(); tx = aSession.beginTransaction(); String hql = "from SbiMetamodelParuse s where s.sbiMetaModelParFather.metaModelParId = ? order by s.prog"; Query hqlQuery = aSession.createQuery(hql); hqlQuery.setInteger(0, metaModelParId.intValue()); List sbiMetaModelParuses = hqlQuery.list(); Iterator it = sbiMetaModelParuses.iterator(); while (it.hasNext()) { toReturn.add(toMetaModelParuse((SbiMetamodelParuse) it.next())); } 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 toReturn; }
Example 7
Source File: MetaModelParuseDAOHibImpl.java From Knowage-Server with GNU Affero General Public License v3.0 | 5 votes |
@Override public List loadAllParuses(Integer metaModelParId) { List toReturn = new ArrayList(); Session aSession = null; Transaction tx = null; try { aSession = getSession(); tx = aSession.beginTransaction(); String hql = "from SbiMetamodelParuse s where s.sbiMetaModelPar.metaModelParId = ? order by s.prog"; Query hqlQuery = aSession.createQuery(hql); hqlQuery.setInteger(0, metaModelParId.intValue()); List sbiMetaModelParuses = hqlQuery.list(); Iterator it = sbiMetaModelParuses.iterator(); while (it.hasNext()) { toReturn.add(toMetaModelParuse((SbiMetamodelParuse) it.next())); } 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 toReturn; }
Example 8
Source File: MetaModelParuseDAOHibImpl.java From Knowage-Server with GNU Affero General Public License v3.0 | 5 votes |
@Override public void eraseMetaModelParuse(MetaModelParuse aMetaModelParuse) throws HibernateException { Session aSession = null; Transaction tx = null; try { aSession = getSession(); tx = aSession.beginTransaction(); String hql = "from SbiMetamodelParuse s where s.id = ? "; Query hqlQuery = aSession.createQuery(hql); hqlQuery.setInteger(0, aMetaModelParuse.getId().intValue()); SbiMetamodelParuse sbiMetamodelParuse = (SbiMetamodelParuse) hqlQuery.uniqueResult(); if (sbiMetamodelParuse == null) { SpagoBITracer.major(SpagoBIConstants.NAME_MODULE, this.getClass().getName(), "eraseMetaModelParuse", "the MetaModelParuse with " + "id=" + aMetaModelParuse.getId() + " does not exist."); } aSession.delete(sbiMetamodelParuse); 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(); } } }
Example 9
Source File: MetaModelParuseDAOHibImpl.java From Knowage-Server with GNU Affero General Public License v3.0 | 5 votes |
/** * Load obj paruse. * * @param objParId * the obj par id * @param paruseId * the paruse id * * @return the list * * @throws EMFUserError * the EMF user error * * @see it.eng.spagobi.behaviouralmodel.analyticaldriver.dao.IObjParuseDAO#loadObjParuse(java.lang.Integer, java.lang.Integer) */ @Override public List loadMetaModelParuse(Integer metaModelParId, Integer paruseId) throws HibernateException { List metaModelParuses = new ArrayList(); MetaModelParuse toReturn = null; Session aSession = null; Transaction tx = null; try { aSession = getSession(); tx = aSession.beginTransaction(); String hql = "from SbiMetamodelParuse s where s.sbiMetaModelPar.metaModelParId=? " + " and s.sbiParuse.useId=? " + " order by s.prog"; Query query = aSession.createQuery(hql); query.setInteger(0, metaModelParId.intValue()); query.setInteger(1, paruseId.intValue()); List sbiMetaModelParuses = query.list(); if (sbiMetaModelParuses == null) return metaModelParuses; Iterator itersbiOP = sbiMetaModelParuses.iterator(); while (itersbiOP.hasNext()) { SbiMetamodelParuse sbiop = (SbiMetamodelParuse) itersbiOP.next(); MetaModelParuse op = toMetaModelParuse(sbiop); metaModelParuses.add(op); } 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 metaModelParuses; }
Example 10
Source File: BinContentDAOHibImpl.java From Knowage-Server with GNU Affero General Public License v3.0 | 5 votes |
@Override public byte[] getBinContent(Integer binId) throws HibernateException { logger.debug("IN"); if (binId != null) logger.debug("binId=" + binId.toString()); byte[] content = new byte[0]; Session aSession = null; Transaction tx = null; try { aSession = getSession(); tx = aSession.beginTransaction(); SbiBinContents hibBinCont = (SbiBinContents) aSession.load(SbiBinContents.class, binId); content = hibBinCont.getContent(); tx.commit(); } catch (HibernateException he) { logger.error("HibernateException", he); if (tx != null) tx.rollback(); throw new HibernateException(he.getLocalizedMessage(), he); } finally { if (aSession != null) { if (aSession.isOpen()) aSession.close(); } logger.debug("OUT"); } return content; }
Example 11
Source File: MetaModelParviewDAOHibImpl.java From Knowage-Server with GNU Affero General Public License v3.0 | 5 votes |
@Override public List loadMetaModelParviewsFather(Integer metaModelParId) { List<MetaModelParview> toReturn = new ArrayList(); Session aSession = null; Transaction tx = null; try { aSession = getSession(); tx = aSession.beginTransaction(); String hql = "from SbiMetaModelParview s where s.sbiMetaModelFather.metaModelParId = ? order by s.prog"; Query hqlQuery = aSession.createQuery(hql); hqlQuery.setInteger(0, metaModelParId.intValue()); List sbiMetaModelParviews = hqlQuery.list(); Iterator it = sbiMetaModelParviews.iterator(); while (it.hasNext()) { toReturn.add(toMetaModelParview((SbiMetaModelParview) it.next())); } 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 toReturn; }
Example 12
Source File: MetaModelParviewDAOHibImpl.java From Knowage-Server with GNU Affero General Public License v3.0 | 5 votes |
@Override public List loadMetaModelParviews(Integer metaModelParId) { List<MetaModelParview> toReturn = new ArrayList(); Session aSession = null; Transaction tx = null; try { aSession = getSession(); tx = aSession.beginTransaction(); String hql = "from SbiMetaModelParview s where s.sbiMetaModelPar.metaModelParId = ? order by s.prog"; Query hqlQuery = aSession.createQuery(hql); hqlQuery.setInteger(0, metaModelParId.intValue()); List sbiMetaModelParviews = hqlQuery.list(); Iterator it = sbiMetaModelParviews.iterator(); while (it.hasNext()) { toReturn.add(toMetaModelParview((SbiMetaModelParview) it.next())); } 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 toReturn; }
Example 13
Source File: MetaModelParviewDAOHibImpl.java From Knowage-Server with GNU Affero General Public License v3.0 | 5 votes |
@Override public List loadMetaModelParviewsByMetaModelParameterId(Integer MetaModelParameterId) { List<MetaModelParview> toReturn = new ArrayList(); Session aSession = null; Transaction tx = null; try { aSession = getSession(); tx = aSession.beginTransaction(); String hql = "from SbiMetaModelParview s where s.sbiMetaModelPar.metaModelParId = ? order by s.prog"; Query hqlQuery = aSession.createQuery(hql); hqlQuery.setInteger(0, MetaModelParameterId.intValue()); List sbiMetaModelParviews = hqlQuery.list(); Iterator it = sbiMetaModelParviews.iterator(); while (it.hasNext()) { toReturn.add(toMetaModelParview((SbiMetaModelParview) it.next())); } 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 toReturn; }
Example 14
Source File: BIMetaModelParameterDAOHibImpl.java From Knowage-Server with GNU Affero General Public License v3.0 | 4 votes |
@Override public void modifyBIMetaModelParameter(BIMetaModelParameter aBIMetaModelParameter) { Session session = null; Transaction transaction = null; try { session = getSession(); transaction = session.beginTransaction(); SbiMetaModelParameter hibBIMetaModelParameter = (SbiMetaModelParameter) session.load(SbiMetaModelParameter.class, aBIMetaModelParameter.getId()); if (hibBIMetaModelParameter == null) { logger.error("The MetaModelParameter with id=" + aBIMetaModelParameter.getId() + " does not exist."); } SbiMetaModel hibMetaModel = (SbiMetaModel) session.load(SbiMetaModel.class, aBIMetaModelParameter.getBiMetaModelID()); SbiParameters aSbiParameter = (SbiParameters) session.load(SbiParameters.class, aBIMetaModelParameter.getParID()); hibBIMetaModelParameter.setSbiMetaModel(hibMetaModel); hibBIMetaModelParameter.setSbiParameter(aSbiParameter); hibBIMetaModelParameter.setLabel(aBIMetaModelParameter.getLabel()); if (aBIMetaModelParameter.getRequired() != null) hibBIMetaModelParameter.setReqFl(new Short(aBIMetaModelParameter.getRequired().shortValue())); if (aBIMetaModelParameter.getModifiable() != null) hibBIMetaModelParameter.setModFl(new Short(aBIMetaModelParameter.getModifiable().shortValue())); if (aBIMetaModelParameter.getVisible() != null) hibBIMetaModelParameter.setViewFl(new Short(aBIMetaModelParameter.getVisible().shortValue())); if (aBIMetaModelParameter.getMultivalue() != null) hibBIMetaModelParameter.setMultFl(new Short(aBIMetaModelParameter.getMultivalue().shortValue())); hibBIMetaModelParameter.setParurlNm(aBIMetaModelParameter.getParameterUrlName()); Integer colSpan = aBIMetaModelParameter.getColSpan(); Integer thickPerc = aBIMetaModelParameter.getThickPerc(); Integer oldPriority = hibBIMetaModelParameter.getPriority(); Integer newPriority = aBIMetaModelParameter.getPriority(); if (!oldPriority.equals(newPriority)) { Query query = null; if (oldPriority.intValue() > newPriority.intValue()) { String hqlUpdateShiftRight = "update SbiMetaModelParameter s set s.priority = (s.priority + 1) where s.priority >= " + newPriority + " and s.priority < " + oldPriority + "and s.sbiMetaModel.id = " + hibMetaModel.getId(); query = session.createQuery(hqlUpdateShiftRight); } else { String hqlUpdateShiftLeft = "update SbiMetaModelParameter s set s.priority = (s.priority - 1) where s.priority > " + oldPriority + " and s.priority <= " + newPriority + "and s.sbiMetaModel.id = " + hibMetaModel.getId(); query = session.createQuery(hqlUpdateShiftLeft); } query.executeUpdate(); } hibBIMetaModelParameter.setPriority(newPriority); hibBIMetaModelParameter.setProg(new Integer(1)); hibBIMetaModelParameter.setColSpan(colSpan); hibBIMetaModelParameter.setThickPerc(thickPerc); updateSbiCommonInfo4Update(hibBIMetaModelParameter); transaction.commit(); } catch (HibernateException he) { logException(he); if (transaction != null) transaction.rollback(); throw new HibernateException(he.getLocalizedMessage(), he); } finally { if (session != null) { if (session.isOpen()) session.close(); } } }
Example 15
Source File: BIMetaModelParameterDAOHibImpl.java From Knowage-Server with GNU Affero General Public License v3.0 | 4 votes |
@Override public List loadBIMetaModelParameterByMetaModelId(Integer metaModelID) { Session session = getSession(); Transaction transaction = session.beginTransaction(); List resultList = new ArrayList(); try { String hql = "from SbiMetaModelParameter s where s.sbiMetaModel.id = " + metaModelID + " order by s.priority asc"; Query hqlQuery = session.createQuery(hql); List hibMetaModelParameters = hqlQuery.list(); Iterator it = hibMetaModelParameters.iterator(); int count = 1; while (it.hasNext()) { BIMetaModelParameter metaModelParameter = toBIMetaModelParameter((SbiMetaModelParameter) it.next()); // ***************************************************************** // **************** START PRIORITY CONTROL ************************* // ***************************************************************** Integer priority = metaModelParameter.getPriority(); // if the priority is different from the value expected, // recalculates it for all the parameter of the document if (priority == null || priority.intValue() != count) { logger.error( "The priorities of the biparameters for the document with id = " + metaModelID + " are not sorted. Priority recalculation starts."); recalculateBiParametersPriority(metaModelID, session); // restarts this method in order to load updated priorities metaModelParameter.setPriority(new Integer(count)); } count++; // ***************************************************************** // **************** END PRIORITY CONTROL *************************** // ***************************************************************** resultList.add(metaModelParameter); } transaction.commit(); } catch (HibernateException he) { logException(he); if (transaction != null) transaction.rollback(); throw new SpagoBIRuntimeException(he.getLocalizedMessage(), he); } finally { if (session != null) { if (session.isOpen()) session.close(); } } return resultList; }
Example 16
Source File: BIObjectParameterDAOHibImpl.java From Knowage-Server with GNU Affero General Public License v3.0 | 4 votes |
/** * Load bi object parameters by id. * * @param biObjectID * the bi object id * * @return the list * * @throws EMFUserError * the EMF user error * * @see it.eng.spagobi.behaviouralmodel.analyticaldriver.dao.IBIObjectParameterDAO#loadBIObjectParametersById(java.lang.Integer) */ @Override public List loadBIObjectParametersById(Integer biObjectID) throws HibernateException { Session aSession = null; Transaction tx = null; List resultList = new ArrayList(); try { aSession = getSession(); tx = aSession.beginTransaction(); String hql = "from SbiObjPar s where s.sbiObject.biobjId = " + biObjectID + " order by s.priority asc"; Query hqlQuery = aSession.createQuery(hql); List hibObjectPars = hqlQuery.list(); Iterator it = hibObjectPars.iterator(); int count = 1; while (it.hasNext()) { BIObjectParameter aBIObjectParameter = toBIObjectParameter((SbiObjPar) it.next()); // ***************************************************************** // **************** START PRIORITY CONTROL ************************* // ***************************************************************** Integer priority = aBIObjectParameter.getPriority(); // if the priority is different from the value expected, // recalculates it for all the parameter of the document if (priority == null || priority.intValue() != count) { logger.error( "The priorities of the biparameters for the document with id = " + biObjectID + " are not sorted. Priority recalculation starts."); recalculateBiParametersPriority(biObjectID, aSession); // restarts this method in order to load updated priorities aBIObjectParameter.setPriority(new Integer(count)); } count++; // ***************************************************************** // **************** END PRIORITY CONTROL *************************** // ***************************************************************** resultList.add(aBIObjectParameter); } 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 resultList; }
Example 17
Source File: MetaModelParuseDAOHibImpl.java From Knowage-Server with GNU Affero General Public License v3.0 | 4 votes |
@Override public void insertMetaModelParuse(MetaModelParuse aMetaModelParuse) throws HibernateException { Session aSession = null; Transaction tx = null; try { aSession = getSession(); tx = aSession.beginTransaction(); SbiMetaModelParameter sbiMetamodelPar = (SbiMetaModelParameter) aSession.load(SbiMetaModelParameter.class, aMetaModelParuse.getParId()); SbiParuse sbiParuse = (SbiParuse) aSession.load(SbiParuse.class, aMetaModelParuse.getUseModeId()); SbiMetaModelParameter sbiMetamodelParFather = (SbiMetaModelParameter) aSession.load(SbiMetaModelParameter.class, aMetaModelParuse.getParFatherId()); if (sbiMetamodelParFather == null) { SpagoBITracer.major(SpagoBIConstants.NAME_MODULE, this.getClass().getName(), "modifyMetaModelParuse", "the BIMetaModelParameter with " + "id=" + aMetaModelParuse.getParFatherId() + " does not exist."); } SbiMetamodelParuse newHibMetaModel = new SbiMetamodelParuse(); newHibMetaModel.setSbiMetaModelPar(sbiMetamodelPar); newHibMetaModel.setSbiParuse(sbiParuse); newHibMetaModel.setSbiMetaModelParFather(sbiMetamodelParFather); newHibMetaModel.setFilterOperation(aMetaModelParuse.getFilterOperation()); newHibMetaModel.setProg(aMetaModelParuse.getProg()); newHibMetaModel.setFilterColumn(aMetaModelParuse.getFilterColumn()); newHibMetaModel.setPreCondition(aMetaModelParuse.getPreCondition()); newHibMetaModel.setPostCondition(aMetaModelParuse.getPostCondition()); newHibMetaModel.setLogicOperator(aMetaModelParuse.getLogicOperator()); updateSbiCommonInfo4Insert(newHibMetaModel); Integer paruseId = (Integer) aSession.save(newHibMetaModel); aMetaModelParuse.setId(paruseId); 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(); } } }
Example 18
Source File: ObjParviewDAOHibImpl.java From Knowage-Server with GNU Affero General Public License v3.0 | 4 votes |
/** * Modify obj parview. * * @param aObjParview the a obj parview * * @throws EMFUserError the EMF user error * * @see it.eng.spagobi.behaviouralmodel.analyticaldriver.dao.IObjParviewDAO#modifyObjParview(it.eng.spagobi.behaviouralmodel.analyticaldriver.bo.ObjParview) */ @Override public void modifyObjParview(ObjParview aObjParview) throws HibernateException { Session aSession = null; Transaction tx = null; try { aSession = getSession(); tx = aSession.beginTransaction(); // get the existing object String hql = "from SbiObjParview s where s.id = ? "; Query hqlQuery = aSession.createQuery(hql); hqlQuery.setInteger(0, aObjParview.getId().intValue()); SbiObjParview sbiObjParview = (SbiObjParview) hqlQuery.uniqueResult(); if (sbiObjParview == null) { SpagoBITracer.major(SpagoBIConstants.NAME_MODULE, this.getClass().getName(), "modifyObjParview", "the ObjParview relevant to BIObjectParameter with " + "id=" + aObjParview.getParId() + " does not exist."); } // delete the existing object // aSession.delete(sbiObjParview); // create the new object 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 " + " does not exist."); } sbiObjParview.setSbiObjPar(sbiObjPar); sbiObjParview.setSbiObjParFather(sbiObjParFather); sbiObjParview.setOperation(aObjParview.getOperation()); sbiObjParview.setCompareValue(aObjParview.getCompareValue()); sbiObjParview.setId(aObjParview.getId()); sbiObjParview.setProg(aObjParview.getProg()); sbiObjParview.setViewLabel(aObjParview.getViewLabel()); // save new object updateSbiCommonInfo4Insert(sbiObjParview); aSession.update(sbiObjParview); 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(); } } /* * Criterion aCriterion = Expression.and( Expression.eq("id.sbiObjPar.objParId", aObjParuse.getObjParId()), Expression.eq("id.sbiParuse.useId", * aObjParuse.getParuseId())); Criteria aCriteria = aSession.createCriteria(SbiObjParuse.class); aCriteria.add(aCriterion); SbiObjParuse sbiObjParuse = * (SbiObjParuse) aCriteria.uniqueResult(); */ }
Example 19
Source File: ObjParuseDAOHibImpl.java From Knowage-Server with GNU Affero General Public License v3.0 | 4 votes |
/** * Insert obj paruse. * * @param aObjParuse the a obj paruse * * @throws EMFUserError the EMF user error * * @see it.eng.spagobi.behaviouralmodel.analyticaldriver.dao.IObjParuseDAO#insertObjParuse(it.eng.spagobi.behaviouralmodel.analyticaldriver.bo.ObjParuse) */ @Override public Integer insertObjParuse(ObjParuse aObjParuse) throws HibernateException { Session aSession = null; Transaction tx = null; SbiObjParuse correlation = new SbiObjParuse(); try { aSession = getSession(); tx = aSession.beginTransaction(); SbiObjPar sbiObjPar = (SbiObjPar) aSession.load(SbiObjPar.class, aObjParuse.getParId()); SbiParuse sbiParuse = (SbiParuse) aSession.load(SbiParuse.class, aObjParuse.getUseModeId()); SbiObjPar sbiObjParFather = (SbiObjPar) aSession.load(SbiObjPar.class, aObjParuse.getParFatherId()); if (sbiObjParFather == null) { SpagoBITracer.major(SpagoBIConstants.NAME_MODULE, this.getClass().getName(), "modifyObjParuse", "the BIObjectParameter with " + "id=" + aObjParuse.getParFatherId() + " does not exist."); } correlation.setSbiObjPar(sbiObjPar); correlation.setSbiParuse(sbiParuse); correlation.setSbiObjParFather(sbiObjParFather); correlation.setFilterOperation(aObjParuse.getFilterOperation()); correlation.setProg(aObjParuse.getProg()); correlation.setFilterColumn(aObjParuse.getFilterColumn()); correlation.setPreCondition(aObjParuse.getPreCondition()); correlation.setPostCondition(aObjParuse.getPostCondition()); correlation.setLogicOperator(aObjParuse.getLogicOperator()); updateSbiCommonInfo4Insert(correlation); correlation.setId((Integer) aSession.save(correlation)); 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 correlation.getId(); } } return correlation.getId(); }
Example 20
Source File: MetaModelParviewDAOHibImpl.java From Knowage-Server with GNU Affero General Public License v3.0 | 4 votes |
@Override public void modifyMetaModelParview(MetaModelParview metaModelParview) { Session aSession = null; Transaction tx = null; try { aSession = getSession(); tx = aSession.beginTransaction(); // get the existing object String hql = "from SbiMetaModelParview s where s.parviewId= ? "; Query hqlQuery = aSession.createQuery(hql); hqlQuery.setInteger(0, metaModelParview.getId().intValue()); SbiMetaModelParview sbiMetaModelParview = (SbiMetaModelParview) hqlQuery.uniqueResult(); if (sbiMetaModelParview == null) { SpagoBITracer.major(SpagoBIConstants.NAME_MODULE, this.getClass().getName(), "modifyMetaModelParview", "the MetaModelParview with " + "id=" + metaModelParview.getId() + " does not exist."); } // delete the existing object aSession.delete(sbiMetaModelParview); // create the new object SbiMetaModelParameter sbiMetaModelPar = (SbiMetaModelParameter) aSession.load(SbiMetaModelParameter.class, metaModelParview.getParId()); SbiMetaModelParameter sbiMetaModelParFather = (SbiMetaModelParameter) aSession.load(SbiMetaModelParameter.class, metaModelParview.getParFatherId()); if (sbiMetaModelParFather == null) { SpagoBITracer.major(SpagoBIConstants.NAME_MODULE, this.getClass().getName(), "modifyMetaModelParview", "the BIMetaModelParameter with " + " does not exist."); } SbiMetaModelParview view = new SbiMetaModelParview(); view.setParviewId(metaModelParview.getId()); view.setSbiMetaModelPar(sbiMetaModelPar); view.setSbiMetaModelFather(sbiMetaModelParFather); view.setOperation(metaModelParview.getOperation()); view.setCompareValue(metaModelParview.getCompareValue()); view.setProg(metaModelParview.getProg()); view.setViewLabel(metaModelParview.getViewLabel()); // save new object updateSbiCommonInfo4Insert(view); 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(); } } }