List of usage examples for org.hibernate Session merge
Object merge(Object object);
From source file:org.jcvi.ometa.hibernate.dao.EventMetaAttributeDAO.java
License:Open Source License
public void update(EventMetaAttribute model, Date transactionDate, Session session) throws DAOException { try {/* w w w . ja v a 2s. c o m*/ prepareForWriteback(model, null, transactionDate, session); session.merge(model); } catch (Exception ex) { throw new DAOException(ex); } }
From source file:org.jcvi.ometa.hibernate.dao.ProjectDAO.java
License:Open Source License
/** * update to database, but assumes session and possible transaction already established. * * @param project to be saved.//from w w w .ja va2s . co m * @param session for hibernate action. * @throws DAOException thrown in place of any received exception. */ public void update(Project project, Date transactionDate, Session session) throws DAOException { try { if (project.getModifiedDate() == null) { project.setModifiedDate(transactionDate); } session.merge(project); } catch (Exception ex) { throw new DAOException(ex); } }
From source file:org.jcvi.ometa.hibernate.dao.ProjectMetaAttributeDAO.java
License:Open Source License
public void update(ProjectMetaAttribute model, Date transactionDate, Session session) throws DAOException { try {// w w w . j av a2s . com prepareForWriteback(model, null, transactionDate, session); session.merge(model); } catch (Exception ex) { throw new DAOException(ex); } }
From source file:org.jcvi.ometa.hibernate.dao.SampleDAO.java
License:Open Source License
public void update(Sample sample, Date transactionDate, Session session) throws DAOException { try {/* w ww.ja va2 s. c o m*/ if (sample.getModifiedDate() == null) { sample.setModifiedDate(transactionDate); } session.merge(sample); } catch (Exception ex) { throw new DAOException(ex); } }
From source file:org.jcvi.ometa.hibernate.dao.SampleMetaAttributeDAO.java
License:Open Source License
public void update(SampleMetaAttribute model, Date transactionDate, Session session) throws DAOException { try {//from www. j a v a 2 s . c om prepareForWriteback(model, null, transactionDate, session); session.merge(model); } catch (Exception ex) { throw new DAOException(ex); } }
From source file:org.jity.server.instructions.UpdateTaskStatus.java
License:Open Source License
public JityResponse launch(String xmlInputData) { JityResponse response = new JityResponse(); Session databaseSession = null; try {//www . j a v a2 s .c o m databaseSession = HibernateSessionFactory.getInstance().getSession(); ExecTask task = (ExecTask) XMLUtil.XMLStringToObject(xmlInputData); // Saving ExecTask state Transaction transaction = databaseSession.beginTransaction(); databaseSession.merge(task); transaction.commit(); logger.debug("Exec task " + task.getId() + " updated in db (status: " + task.getStatus() + ")"); databaseSession.close(); response.setInstructionResultOK(true); } catch (Exception e) { response.setException(e); if (databaseSession != null) databaseSession.close(); } return response; }
From source file:org.jvending.provisioning.dao.impl.ClientBundleDAOImpl.java
License:Apache License
public void store(List<ClientBundle> clientBundles) throws IOException { if (clientBundles == null) throw new IOException("No client bundles to store"); Session session = null; Transaction transaction = null;/* ww w .ja va2 s . c o m*/ try { logger.finest("Opening session from data source = " + dataSource); try { session = getSessionFactoryByName(dataSource).getCurrentSession(); } catch (Exception e) { // e.printStackTrace(); } if (session == null) { try { session = getSessionFactoryByName(dataSource).openSession(); } catch (Exception e) { e.printStackTrace(); } } transaction = session.beginTransaction(); for (ClientBundle clientBundle : clientBundles) { logger.info("Content Id = " + clientBundle.getContentId() + ", Primary Id = " + clientBundle.getPrimaryId()); session.merge(clientBundle); } transaction.commit(); } catch (Exception e) { try { if (transaction != null) transaction.rollback(); } catch (HibernateException he) { logger.log(Level.INFO, "Failed to roll back transaction", he); } e.printStackTrace(); throw new IOException(); } finally { try { if (session != null) session.close(); } catch (HibernateException e) { logger.log(Level.INFO, "Failed to close session", e); } } }
From source file:org.jvending.provisioning.dao.impl.FulfillmentTaskDAOImpl.java
License:Apache License
public void store(FulfillmentTaskObject fulfillmentTaskObject) throws IOException { Transaction transaction = null;// w w w . jav a 2 s . c om Session session = null; try { session = getSessionFactoryByName(dataSource).openSession(); transaction = session.beginTransaction(); session.merge(fulfillmentTaskObject); transaction.commit(); } catch (Exception e) { try { if (transaction != null) transaction.rollback(); } catch (HibernateException he) { logger.log(Level.INFO, "Failed to roll back transaction", he); } logger.log(Level.INFO, "Failed to save fulfillment task: " + fulfillmentTaskObject.toString(), e); throw new IOException("Failed to save fulfillment task: " + fulfillmentTaskObject.toString()); } finally { try { if (session != null) session.close(); } catch (HibernateException e) { logger.log(Level.INFO, "Failed to close session", e); } } }
From source file:org.kaaproject.kaa.server.common.dao.impl.sql.HibernateAbstractDao.java
License:Apache License
@Override public T save(T object, boolean flush) { LOG.debug("Saving {} entity {}", getEntityClass(), object); Session session = getSession(); object = (T) session.merge(object); if (flush) {/*w w w . j a v a 2 s . com*/ session.flush(); } if (LOG.isTraceEnabled()) { LOG.trace("Saving result: {}", object); } else { LOG.debug("Saving result: {}", object != null); } return object; }
From source file:org.musicrecital.dao.hibernate.GenericDaoHibernate.java
License:Apache License
/** * {@inheritDoc}//w w w . jav a 2 s . c o m */ @SuppressWarnings("unchecked") public T save(T object) { Session sess = getSession(); return (T) sess.merge(object); }