List of usage examples for org.hibernate Session merge
Object merge(Object object);
From source file:org.nuxeo.ecm.platform.jbpm.core.service.JbpmServiceImpl.java
License:Open Source License
@Override public void saveTaskInstances(final List<TaskInstance> taskInstances) throws NuxeoJbpmException { executeJbpmOperation(new JbpmOperation() { private static final long serialVersionUID = 1L; @Override/* w w w . j a v a 2s. c om*/ public Serializable run(JbpmContext context) throws NuxeoJbpmException { Session session = context.getSession(); for (TaskInstance ti : taskInstances) { session.merge(ti); } return null; } }); }
From source file:org.openebiz.dao.common.cac.RoadTransportTypeDAOImpl.java
public RoadTransportType merge(RoadTransportType value) { RoadTransportType newValue = null;// w w w. j av a 2s . co m Session session = getSession(); newValue = (RoadTransportType) session.merge(value); if (log.isDebugEnabled()) log.debug("merging document: " + value); return newValue; }
From source file:org.openebiz.dao.common.cbc.LicensePlateIDTypeDAOImpl.java
License:Open Source License
public LicensePlateIDType merge(LicensePlateIDType value) { LicensePlateIDType newValue = null;/* w w w . j a v a 2 s .c o m*/ Session session = getSession(); newValue = (LicensePlateIDType) session.merge(value); if (log.isDebugEnabled()) log.debug("merging document: " + value); return newValue; }
From source file:org.opengoss.dao.hibernate.DataAccessor.java
License:Apache License
public Object merge(final Object entity) throws DaoException { return execute(new IAccessorCallback() { public Object call(Session session) throws HibernateException { return session.merge(entity); }// ww w .j av a 2 s. c o m }); }
From source file:org.openhie.openempi.dao.hibernate.DatasetDaoHibernate.java
License:Apache License
public Dataset updateDataset(final Dataset dataset) { log.debug("Updating a dataset."); dataset.referenceThisInChildEntities(); Dataset updatedDataset = (Dataset) getHibernateTemplate().execute(new HibernateCallback() { public Object doInHibernate(Session session) { Dataset result = (Dataset) session.merge(dataset); session.flush();//from ww w .ja va2 s .c o m hydrateColumnInformation(result); log.debug("Finished updating the dataset."); return result; } }); return updatedDataset; }
From source file:org.openhie.openempi.dao.hibernate.PersonDaoHibernate.java
License:Open Source License
@SuppressWarnings("unchecked") public void updatePersonIdentifiers(final Person person) { getHibernateTemplate().execute(new HibernateCallback() { @Override/*from ww w . ja va 2s .c om*/ public Object doInHibernate(Session session) throws HibernateException, SQLException { String query = "from PersonIdentifier as pi where pi.dateVoided is null and pi.person.personId = ?"; List<PersonIdentifier> curr = (List<PersonIdentifier>) getHibernateTemplate().find(query, person.getPersonId()); log.debug("Found list of identifiers: " + curr); Map<String, PersonIdentifier> currIdMap = buildMap(curr); Map<String, PersonIdentifier> newIdMap = buildMap(person.getPersonIdentifiers()); for (PersonIdentifier id : person.getPersonIdentifiers()) { PersonIdentifier found = currIdMap.get(getIdentifierKey(id)); if (found == null) { // The id is the new list but not in the old; it needs to be added id.setDateCreated(new Date()); id.setPerson(person); id.setUserCreatedBy(Context.getUserContext().getUser()); // log.debug("Adding new ID: " + id); session.saveOrUpdate(id); } else if (id.getDateVoided() != null && found.getDateVoided() == null) { // The id has been voided in the new list but was not previously void id.setDateVoided(new Date()); id.setUserVoidedBy(Context.getUserContext().getUser()); id.setPerson(person); // log.debug("ID is explicitly voided: " + id); session.merge(id); } else if (id.getDateVoided() == null && found.getDateVoided() != null) { id.setDateCreated(new Date()); id.setPerson(person); id.setUserCreatedBy(Context.getUserContext().getUser()); // log.debug("Updating ID: " + id); session.merge(id); } } // Go through the list of current identifiers for (PersonIdentifier id : curr) { PersonIdentifier found = newIdMap.get(getIdentifierKey(id)); if (found == null) { if (id.getDateVoided() == null) { id.setDateVoided(new Date()); id.setUserVoidedBy(Context.getUserContext().getUser()); session.merge(id); // log.debug("Old ID is implicitly voided: " + id); } } } // removed voided identifiers removeDeletedIdentifiersBySet(person); return null; } }); }
From source file:org.openhie.openempi.dao.hibernate.PersonMatchDaoHibernate.java
License:Apache License
public PersonMatch updatePersonMatch(final PersonMatch personMatch) { log.debug("Updating a person match."); PersonMatch updatedPersonMatch = (PersonMatch) getHibernateTemplate().execute(new HibernateCallback() { public Object doInHibernate(Session session) { PersonMatch result = (PersonMatch) session.merge(personMatch); session.flush();//w w w.jav a 2 s. c om if (result != null) hydrateColumnMatchInformation(result); log.debug("Finished updating the person match."); return result; } }); return updatedPersonMatch; }
From source file:org.openmrs.cwf.api.util.OpenMRSUtil.java
License:Mozilla Public License
public static void loadIfNecessary(Object domainObject) { Session session = null; try {/*from w w w .j ava 2 s . c o m*/ session = getSessionFactory().getCurrentSession(); if (!session.contains(domainObject)) { LockRequest lr = session.buildLockRequest(LockOptions.NONE); lr.lock(domainObject); } } catch (org.hibernate.NonUniqueObjectException exc) { session.merge(domainObject); } catch (org.hibernate.LazyInitializationException exc) { session.merge(domainObject); } }
From source file:org.openmrs.module.sync.api.db.hibernate.HibernateSyncDAO.java
License:Open Source License
/** * @see org.openmrs.module.sync.api.db.SyncDAO#updateSyncImportRecord(org.openmrs.module.sync.engine.SyncImportRecord) *///from w w w . j a v a 2s. c om public void updateSyncImportRecord(SyncImportRecord record) throws DAOException { Session session = sessionFactory.getCurrentSession(); session.merge(record); }
From source file:org.openmrs.module.sync.api.db.hibernate.HibernateSyncDAO.java
License:Open Source License
/** * @see org.openmrs.module.sync.api.db.SyncDAO#setGlobalProperty(String propertyName, String * propertyValue)/*w w w. ja v a2 s. co m*/ */ public void setGlobalProperty(String propertyName, String propertyValue) throws DAOException { if (propertyName == null) throw new DAOException("Cannot set property with null property name."); Session session = sessionFactory.getCurrentSession(); // try to look up the global property first so we use the same uuid for the gp GlobalProperty gp = (GlobalProperty) session.get(GlobalProperty.class, propertyName); if (gp == null) { // the gp doesn't exist, create a new one with a new uuid now gp = new GlobalProperty(propertyName, propertyValue); gp.setUuid(SyncUtil.generateUuid()); } else { gp.setPropertyValue(propertyValue); } session.merge(gp); }