List of usage examples for org.hibernate LockMode NONE
LockMode NONE
To view the source code for org.hibernate LockMode NONE.
Click Source Link
From source file:net.firejack.platform.core.store.registry.SecuredRecordStore.java
License:Apache License
@Override @Transactional//w w w.j av a 2s . c o m public void delete(SecuredRecordModel securedRecord) { getHibernateTemplate().lock(securedRecord, LockMode.NONE); deleteRecursive(securedRecord, false); cacheProcessor.deleteSecuredRecord(securedRecord.getId()); }
From source file:no.abmu.common.persistence.hibernate3.AbstractBaseDaoImpl.java
License:Open Source License
public void reattach(Object obj) { Session session = SessionFactoryUtils.getSession(getSessionFactory(), true); try {//from www . j a v a2 s . com session.lock(obj, LockMode.NONE); } catch (HibernateException e) { throw new RuntimeException("Problem reattaching object " + obj.toString(), e); } }
From source file:org.archiviststoolkit.mydomain.DomainTableWorkSurface.java
License:Open Source License
private int addObjectToPrintList(InfiniteProgressPanel progressPanel, int count, int filteredListSize, DomainObject domainObject, ATReport report, ArrayList<DomainObject> listForPrinting) throws ReportExecutionException { if (progressPanel != null) { progressPanel.setTextLine("Loading records for printing " + count++ + " of " + filteredListSize, 1); }/*from w w w . ja v a 2s . com*/ // since resource components searvh results are not stored on the database then // not need to try to retrive them if (!(domainObject instanceof ResourcesComponentsSearchResult)) { longSessionForPrinting.lock(domainObject, LockMode.NONE); } initializeDomainObject(domainObject, report, progressPanel); listForPrinting.add(domainObject); return count; }
From source file:org.archiviststoolkit.mydomain.NamesDAO.java
License:Open Source License
public int merge(Collection<DomainObject> mergeFrom, DomainObject mergeTo, InfiniteProgressPanel progressPanel) throws MergeException { Session session = SessionFactory.getInstance().openSession(); Transaction tx = session.beginTransaction(); Names nameMergeTo = (Names) mergeTo; session.lock(nameMergeTo, LockMode.NONE); Names name;//from ww w. j av a2s . c o m String message; int totalCount = 0; int subjectsToMerge = mergeFrom.size() - 1; int subjectsMerged = 1; for (DomainObject domainObject : mergeFrom) { try { name = (Names) domainObject; if (!name.equals(nameMergeTo)) { session.lock(name, LockMode.NONE); progressPanel.setTextLine( "Merging (record " + subjectsMerged++ + " of " + subjectsToMerge + ")...", 1); progressPanel.setTextLine(name + " -> " + nameMergeTo, 1); int count = 1; int numberOfLinks = name.getArchDescriptionNames().size(); for (ArchDescriptionNames nameLink : name.getArchDescriptionNames()) { try { message = "relationship " + count++ + " of " + numberOfLinks; System.out.println(message); progressPanel.setTextLine(message, 3); nameMergeTo.addArchDesctiption(nameLink); totalCount++; } catch (DuplicateLinkException e) { //do nothing } } session.delete(name); } } catch (HibernateException e) { tx.rollback(); session.close(); throw new MergeException("Error merging names", e); } } session.update(nameMergeTo); try { tx.commit(); } catch (HibernateException e) { tx.rollback(); session.close(); throw new MergeException("Error merging names", e); } session.close(); return totalCount; }
From source file:org.archiviststoolkit.mydomain.ResourcesDAO.java
License:Open Source License
public int merge(Collection<DomainObject> mergeFrom, DomainObject mergeTo, InfiniteProgressPanel progressPanel) throws MergeException { Session session = getLongSession();/*from w w w. ja v a 2s . c om*/ Transaction tx = session.beginTransaction(); Resources resourceMergeTo = null; try { resourceMergeTo = (Resources) findByPrimaryKeyLongSession(mergeTo.getIdentifier()); } catch (LookupException e) { rollBackAndThrowMergeException(session, tx, e); } // session.lock(resourceMergeTo, LockMode.NONE); Resources resource; String message; int totalCount = 0; int resourcesToMerge = mergeFrom.size() - 1; int resourcesMerged = 1; ArrayList<ResourcesComponents> componentsToMove = new ArrayList<ResourcesComponents>(); for (DomainObject domainObject : mergeFrom) { try { resource = (Resources) domainObject; if (!resource.equals(resourceMergeTo)) { session.lock(resource, LockMode.NONE); progressPanel.setTextLine( "Merging (record " + resourcesMerged++ + " of " + resourcesToMerge + ")...", 1); progressPanel.setTextLine(resource + " -> " + resourceMergeTo, 2); totalCount += transferTopLevelComponents(progressPanel, session, tx, resourceMergeTo, resource, componentsToMove); deleteLongSession(resource, false); } } catch (HibernateException e) { rollBackAndThrowMergeException(session, tx, e); } catch (DeleteException e) { rollBackAndThrowMergeException(session, tx, e); } } // now add the componets to the mergeTo resource int count = 1; int numberOfLinks = componentsToMove.size(); resourceMergeTo.resequenceSequencedObjects(); int nextSequenceNumber = resourceMergeTo.getNextSequenceNumber(); for (ResourcesComponents component : componentsToMove) { progressPanel.setTextLine("Adding components " + count++ + " of " + numberOfLinks, 2); component.setSequenceNumber(nextSequenceNumber++); resourceMergeTo.addComponent(component); component.setResource(resourceMergeTo); } progressPanel.setTextLine("Saving record", 2); session.update(resourceMergeTo); tx.commit(); session.close(); return totalCount; }
From source file:org.archiviststoolkit.mydomain.SubjectsDAO.java
License:Open Source License
public int merge(Collection<DomainObject> mergeFrom, DomainObject mergeTo, InfiniteProgressPanel progressPanel) throws MergeException { Session session = SessionFactory.getInstance().openSession(); Transaction tx = session.beginTransaction(); Subjects subjectMergeTo = (Subjects) mergeTo; session.lock(subjectMergeTo, LockMode.NONE); Subjects subject;//from w ww .j a va 2 s. c om String message; int totalCount = 0; int subjectsToMerge = mergeFrom.size() - 1; int subjectsMerged = 1; for (DomainObject domainObject : mergeFrom) { try { subject = (Subjects) domainObject; if (!subject.equals(subjectMergeTo)) { session.lock(subject, LockMode.NONE); progressPanel.setTextLine( "Merging (record " + subjectsMerged++ + " of " + subjectsToMerge + ")...", 1); progressPanel.setTextLine(subject + " -> " + subjectMergeTo, 2); int count = 1; int numberOfLinks = subject.getArchDescriptionSubjects().size(); for (ArchDescriptionSubjects subjectLink : subject.getArchDescriptionSubjects()) { try { message = "relationship " + count++ + " of " + numberOfLinks; System.out.println(message); progressPanel.setTextLine(message, 3); subjectMergeTo.addArchDesctiption(subjectLink.getArchDescription()); totalCount++; } catch (DuplicateLinkException e) { //do nothing } } session.delete(subject); } } catch (HibernateException e) { throw new MergeException("Error merging subjects", e); } } session.update(subjectMergeTo); tx.commit(); session.close(); return totalCount; }
From source file:org.bedework.carddav.server.dirHandlers.db.HibSessionImpl.java
License:Apache License
public void reAttach(final UnversionedDbentity<?> val) throws WebdavException { if (exc != null) { // Didn't hear me last time? throw new WebdavException(exc); }//from ww w . j a v a 2 s . c o m try { if (!val.unsaved()) { sess.lock(val, LockMode.NONE); } } catch (Throwable t) { handleException(t); } }
From source file:org.bedework.dumprestore.HibSession.java
License:Apache License
/** * @param o// w ww . j av a 2 s . com * @throws CalFacadeException */ public void reAttach(Object o) throws CalFacadeException { if (exc != null) { // Didn't hear me last time? throw new CalFacadeException(exc); } try { sess.lock(o, LockMode.NONE); } catch (Throwable t) { handleException(t); } }
From source file:org.bedework.util.hibernate.HibSessionImpl.java
License:Apache License
@Override public void reAttach(final UnversionedDbentity<?, ?> val) throws HibException { if (exc != null) { // Didn't hear me last time? throw new HibException(exc); }// w ww. j a v a 2 s . c o m try { if (!val.unsaved()) { sess.lock(val, LockMode.NONE); } } catch (Throwable t) { handleException(t); } }
From source file:org.brekka.commons.persistence.dao.hibernate.AbstractIdentifiableEntityHibernateDAO.java
License:Apache License
/** * Borrowed from org.hibernate.ejb.util.LockModeTypeHelper * @param lockMode//from w w w . ja v a 2s. com * @return */ public static LockMode getLockMode(final LockModeType lockMode) { switch (lockMode) { case READ: case OPTIMISTIC: { return LockMode.OPTIMISTIC; } case OPTIMISTIC_FORCE_INCREMENT: case WRITE: { return LockMode.OPTIMISTIC_FORCE_INCREMENT; } case PESSIMISTIC_READ: { return LockMode.PESSIMISTIC_READ; } case PESSIMISTIC_WRITE: { return LockMode.PESSIMISTIC_WRITE; } case PESSIMISTIC_FORCE_INCREMENT: { return LockMode.PESSIMISTIC_FORCE_INCREMENT; } case NONE: { return LockMode.NONE; } default: { throw new IllegalStateException("Unknown LockModeType: " + lockMode); } } }