本文整理匯總了Java中org.hibernate.LockMode類的典型用法代碼示例。如果您正苦於以下問題:Java LockMode類的具體用法?Java LockMode怎麽用?Java LockMode使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
LockMode類屬於org.hibernate包,在下文中一共展示了LockMode類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: addUninitializedEntity
import org.hibernate.LockMode; //導入依賴的package包/類
/**
* Add an uninitialized instance of an entity class, as a placeholder to ensure object
* identity. Must be called before <tt>postHydrate()</tt>.
*
* Create a "temporary" entry for a newly instantiated entity. The entity is uninitialized,
* but we need the mapping from id to instance in order to guarantee uniqueness.
*
* @param key The entity key
* @param object The entity instance
* @param persister The entity persister
* @param lockMode The lock mode
* @param lazyPropertiesAreUnFetched Are lazy properties still un-fetched?
* @param session The Session
*/
public static void addUninitializedEntity(
final EntityKey key,
final Object object,
final EntityPersister persister,
final LockMode lockMode,
final boolean lazyPropertiesAreUnFetched,
final SessionImplementor session) {
session.getPersistenceContext().addEntity(
object,
Status.LOADING,
null,
key,
null,
lockMode,
true,
persister,
false,
lazyPropertiesAreUnFetched
);
}
示例2: getLockingStrategy
import org.hibernate.LockMode; //導入依賴的package包/類
@Override
public LockingStrategy getLockingStrategy(Lockable lockable, LockMode lockMode) {
// TimesTen has no known variation of a "SELECT ... FOR UPDATE" syntax...
if ( lockMode == LockMode.PESSIMISTIC_FORCE_INCREMENT ) {
return new PessimisticForceIncrementLockingStrategy( lockable, lockMode );
}
else if ( lockMode == LockMode.PESSIMISTIC_WRITE ) {
return new PessimisticWriteUpdateLockingStrategy( lockable, lockMode );
}
else if ( lockMode == LockMode.PESSIMISTIC_READ ) {
return new PessimisticReadUpdateLockingStrategy( lockable, lockMode );
}
else if ( lockMode == LockMode.OPTIMISTIC ) {
return new OptimisticLockingStrategy( lockable, lockMode );
}
else if ( lockMode == LockMode.OPTIMISTIC_FORCE_INCREMENT ) {
return new OptimisticForceIncrementLockingStrategy( lockable, lockMode );
}
else if ( lockMode.greaterThan( LockMode.READ ) ) {
return new UpdateLockingStrategy( lockable, lockMode );
}
else {
return new SelectLockingStrategy( lockable, lockMode );
}
}
示例3: handleDeleteProbandAddress
import org.hibernate.LockMode; //導入依賴的package包/類
@Override
protected ProbandAddressOutVO handleDeleteProbandAddress(
AuthenticationVO auth, Long probandAddressId) throws Exception {
ProbandAddressDao addressDao = this.getProbandAddressDao();
ProbandAddress address = CheckIDUtil.checkProbandAddressId(probandAddressId, addressDao);
Proband proband = address.getProband();
this.getProbandDao().lock(proband, LockMode.PESSIMISTIC_WRITE);
// Proband proband = ServiceUtil.checkProbandId(address.getProband().getId(), this.getProbandDao(), LockMode.PESSIMISTIC_WRITE); // address.getProband();
ProbandAddressOutVO result = addressDao.toProbandAddressOutVO(address);
if (!result.isDecrypted()) {
throw L10nUtil.initServiceException(ServiceExceptionCodes.CANNOT_DECRYPT_PROBAND_ADDRESS);
}
ServiceUtil.checkProbandLocked(proband);
if (address.isWireTransfer() && addressDao.getCount(address.getProband().getId(), null, null, null) > 1) { // proband.getAddresses().Xsize() > 1) {
throw L10nUtil.initServiceException(ServiceExceptionCodes.CANNOT_DELETE_WIRE_TRANSFER_PROBAND_ADDRESS);
}
proband.removeAddresses(address);
address.setProband(null);
addressDao.remove(address);
Timestamp now = new Timestamp(System.currentTimeMillis());
User user = CoreUtil.getUser();
ServiceUtil.logSystemMessage(proband, result.getProband(), now, user, SystemMessageCodes.PROBAND_ADDRESS_DELETED, result, null, this.getJournalEntryDao());
return result;
}
示例4: get
import org.hibernate.LockMode; //導入依賴的package包/類
@Override
public Object get(final String entityName, final Serializable id, final LockMode lockMode)
throws DataAccessException {
return executeWithNativeSession(new HibernateCallback<Object>() {
@Override
public Object doInHibernate(Session session) throws HibernateException {
if (lockMode != null) {
return session.get(entityName, id, new LockOptions(lockMode));
}
else {
return session.get(entityName, id);
}
}
});
}
示例5: handleUpdateFile
import org.hibernate.LockMode; //導入依賴的package包/類
/**
* @see org.phoenixctms.ctsms.service.shared.FileService#updateFile(FileInVO, FileContentInVO)
*/
@Override
protected FileOutVO handleUpdateFile(AuthenticationVO auth, FileInVO modifiedFile, FileContentInVO modifiedFileContent)
throws Exception
{
FileDao fileDao = this.getFileDao();
File originalFile = CheckIDUtil.checkFileId(modifiedFile.getId(), fileDao, LockMode.UPGRADE_NOWAIT);
checkFileInput(modifiedFile);
if (!fileDao.toFileOutVO(originalFile).isDecrypted()) {
throw L10nUtil.initServiceException(ServiceExceptionCodes.CANNOT_DECRYPT_FILE);
}
FileOutVO original = fileDao.toFileOutVO(originalFile);
fileDao.evict(originalFile);
File file = fileDao.fileInVOToEntity(modifiedFile);
Timestamp now = new Timestamp(System.currentTimeMillis());
User user = CoreUtil.getUser();
CoreUtil.modifyVersion(originalFile, file, now, user);
saveFileContent(file, modifiedFileContent);
fileDao.update(file);
return addFileUpdatedJournalEntry(file, original, now, user);
}
示例6: get
import org.hibernate.LockMode; //導入依賴的package包/類
@Override
public Object get(final String entityName, final Serializable id, final LockMode lockMode)
throws DataAccessException {
return executeWithNativeSession(new HibernateCallback<Object>() {
@Override
public Object doInHibernate(Session session) throws HibernateException {
if (lockMode != null) {
return session.get(entityName, id, lockMode);
}
else {
return session.get(entityName, id);
}
}
});
}
示例7: appendLockHint
import org.hibernate.LockMode; //導入依賴的package包/類
@Override
public String appendLockHint(LockOptions lockOptions, String tableName) {
final LockMode mode = lockOptions.getLockMode();
switch ( mode ) {
case UPGRADE:
case UPGRADE_NOWAIT:
case PESSIMISTIC_WRITE:
case WRITE:
return tableName + " with (updlock, rowlock)";
case PESSIMISTIC_READ:
return tableName + " with (holdlock, rowlock)";
case UPGRADE_SKIPLOCKED:
return tableName + " with (updlock, rowlock, readpast)";
default:
return tableName;
}
}
示例8: checkAddEcrfFieldInput
import org.hibernate.LockMode; //導入依賴的package包/類
private void checkAddEcrfFieldInput(ECRFFieldInVO ecrfFieldIn) throws ServiceException
{
InputField field = CheckIDUtil.checkInputFieldId(ecrfFieldIn.getFieldId(), this.getInputFieldDao(), LockMode.PESSIMISTIC_WRITE);
Trial trial = CheckIDUtil.checkTrialId(ecrfFieldIn.getTrialId(), this.getTrialDao());
ServiceUtil.checkTrialLocked(trial);
ECRF ecrf = CheckIDUtil.checkEcrfId(ecrfFieldIn.getEcrfId(), this.getECRFDao());
if (!trial.equals(ecrf.getTrial())) {
throw L10nUtil.initServiceException(ServiceExceptionCodes.ECRF_FIELD_WRONG_ECRF, CommonUtil.trialOutVOToString(this.getTrialDao().toTrialOutVO(trial)));
}
checkEcrfFieldInput(ecrfFieldIn);
ServiceUtil.checkLockedEcrfs(ecrf, this.getECRFStatusEntryDao(), this.getECRFDao());
if (ecrfFieldIn.getSeries()
&& this.getECRFFieldDao().getCount(null, ecrfFieldIn.getEcrfId(), ecrfFieldIn.getSection(), null, null) > 0 // optimization, bulk inserts
) {
if (this.getECRFFieldValueDao().getCount(ecrfFieldIn.getEcrfId(), ecrfFieldIn.getSection()) > 0) {
throw L10nUtil.initServiceException(ServiceExceptionCodes.ECRF_FIELD_SERIES_SECTION_WITH_VALUES, ecrfFieldIn.getSection());
}
if (this.getECRFFieldStatusEntryDao().getCount(ecrfFieldIn.getEcrfId(), ecrfFieldIn.getSection()) > 0) {
throw L10nUtil.initServiceException(ServiceExceptionCodes.ECRF_FIELD_SERIES_SECTION_WITH_STATUS_ENTRIES, ecrfFieldIn.getSection());
}
}
}
示例9: getLockingStrategy
import org.hibernate.LockMode; //導入依賴的package包/類
@Override
public LockingStrategy getLockingStrategy(Lockable lockable, LockMode lockMode) {
// RDMS has no known variation of a "SELECT ... FOR UPDATE" syntax...
if ( lockMode == LockMode.PESSIMISTIC_FORCE_INCREMENT ) {
return new PessimisticForceIncrementLockingStrategy( lockable, lockMode );
}
else if ( lockMode == LockMode.PESSIMISTIC_WRITE ) {
return new PessimisticWriteUpdateLockingStrategy( lockable, lockMode );
}
else if ( lockMode == LockMode.PESSIMISTIC_READ ) {
return new PessimisticReadUpdateLockingStrategy( lockable, lockMode );
}
else if ( lockMode == LockMode.OPTIMISTIC ) {
return new OptimisticLockingStrategy( lockable, lockMode );
}
else if ( lockMode == LockMode.OPTIMISTIC_FORCE_INCREMENT ) {
return new OptimisticForceIncrementLockingStrategy( lockable, lockMode );
}
else if ( lockMode.greaterThan( LockMode.READ ) ) {
return new UpdateLockingStrategy( lockable, lockMode );
}
else {
return new SelectLockingStrategy( lockable, lockMode );
}
}
示例10: getLockingStrategy
import org.hibernate.LockMode; //導入依賴的package包/類
@Override
public LockingStrategy getLockingStrategy(Lockable lockable, LockMode lockMode) {
if ( lockMode == LockMode.PESSIMISTIC_FORCE_INCREMENT ) {
return new PessimisticForceIncrementLockingStrategy( lockable, lockMode );
}
// else if ( lockMode==LockMode.PESSIMISTIC_WRITE ) {
// return new PessimisticWriteLockingStrategy( lockable, lockMode );
// }
else if ( lockMode == LockMode.PESSIMISTIC_READ ) {
return new IgnitePessimisticReadLockingStrategy( lockable, lockMode, provider );
}
else if ( lockMode == LockMode.OPTIMISTIC ) {
return new OptimisticLockingStrategy( lockable, lockMode );
}
else if ( lockMode == LockMode.OPTIMISTIC_FORCE_INCREMENT ) {
return new OptimisticForceIncrementLockingStrategy( lockable, lockMode );
}
else {
return null;
}
}
示例11: getLockingStrategy
import org.hibernate.LockMode; //導入依賴的package包/類
/**
* Get a strategy instance which knows how to acquire a database-level lock
* of the specified mode for this dialect.
*
* @param lockable The persister for the entity to be locked.
* @param lockMode The type of lock to be acquired.
* @return The appropriate locking strategy.
* @since 3.2
*/
public LockingStrategy getLockingStrategy(Lockable lockable, LockMode lockMode) {
switch ( lockMode ) {
case PESSIMISTIC_FORCE_INCREMENT:
return new PessimisticForceIncrementLockingStrategy( lockable, lockMode );
case PESSIMISTIC_WRITE:
return new PessimisticWriteSelectLockingStrategy( lockable, lockMode );
case PESSIMISTIC_READ:
return new PessimisticReadSelectLockingStrategy( lockable, lockMode );
case OPTIMISTIC:
return new OptimisticLockingStrategy( lockable, lockMode );
case OPTIMISTIC_FORCE_INCREMENT:
return new OptimisticForceIncrementLockingStrategy( lockable, lockMode );
default:
return new SelectLockingStrategy( lockable, lockMode );
}
}
示例12: handleUpdateStaff
import org.hibernate.LockMode; //導入依賴的package包/類
/**
* @see org.phoenixctms.ctsms.service.staff.StaffService#updateStaff(StaffInVO)
*/
@Override
protected StaffOutVO handleUpdateStaff(AuthenticationVO auth, StaffInVO modifiedStaff, Integer maxInstances, Integer maxParentDepth)
throws Exception
{
StaffDao staffDao = this.getStaffDao();
Staff originalStaff = CheckIDUtil.checkStaffId(modifiedStaff.getId(), staffDao, LockMode.PESSIMISTIC_WRITE);
checkStaffInput(modifiedStaff);
if (originalStaff.isPerson() != modifiedStaff.isPerson()) {
throw L10nUtil.initServiceException(ServiceExceptionCodes.STAFF_PERSON_FLAG_CHANGED);
}
StaffOutVO original = staffDao.toStaffOutVO(originalStaff, maxInstances, maxParentDepth);
staffDao.evict(originalStaff);
Staff staff = staffDao.staffInVOToEntity(modifiedStaff);
checkStaffLoop(staff);
Timestamp now = new Timestamp(System.currentTimeMillis());
User user = CoreUtil.getUser();
CoreUtil.modifyVersion(originalStaff, staff, now, user);
staffDao.update(staff);
StaffOutVO result = staffDao.toStaffOutVO(staff, maxInstances, maxParentDepth);
JournalEntryDao journalEntryDao = this.getJournalEntryDao();
logSystemMessage(staff, result, now, user, SystemMessageCodes.STAFF_UPDATED, result, original, journalEntryDao);
return result;
}
示例13: handleSetEcrfStatusEntry
import org.hibernate.LockMode; //導入依賴的package包/類
@Override
protected ECRFStatusEntryVO handleSetEcrfStatusEntry(AuthenticationVO auth, Long ecrfId, Long probandListEntryId, Long version, Long ecrfStatusTypeId,
Long probandListStatusTypeId)
throws Exception {
ProbandListEntry listEntry = CheckIDUtil.checkProbandListEntryId(probandListEntryId, this.getProbandListEntryDao(), LockMode.PESSIMISTIC_WRITE);
ECRF ecrf = CheckIDUtil.checkEcrfId(ecrfId, this.getECRFDao(), LockMode.PESSIMISTIC_WRITE); // lock order, field updates
ECRFStatusType statusType = CheckIDUtil.checkEcrfStatusTypeId(ecrfStatusTypeId, this.getECRFStatusTypeDao());
Timestamp now = new Timestamp(System.currentTimeMillis());
User user = CoreUtil.getUser();
ECRFStatusEntry originalStatusEntry = this.getECRFStatusEntryDao().findByEcrfListEntry(ecrf.getId(), listEntry.getId());
ECRFStatusEntryVO result;
if (originalStatusEntry != null) {
result = updateEcrfStatusEntry(originalStatusEntry, ecrf, listEntry, statusType, version, probandListStatusTypeId, now, user);
} else {
Object[] resultItems = addEcrfStatusEntry(ecrf, listEntry, statusType, probandListStatusTypeId, now, user);
result = (ECRFStatusEntryVO) resultItems[1];
}
return result;
}
示例14: getLockingStrategy
import org.hibernate.LockMode; //導入依賴的package包/類
@Override
public LockingStrategy getLockingStrategy(Lockable lockable, LockMode lockMode) {
// Frontbase has no known variation of a "SELECT ... FOR UPDATE" syntax...
if ( lockMode==LockMode.PESSIMISTIC_FORCE_INCREMENT) {
return new PessimisticForceIncrementLockingStrategy( lockable, lockMode);
}
else if ( lockMode==LockMode.PESSIMISTIC_WRITE) {
return new PessimisticWriteUpdateLockingStrategy( lockable, lockMode);
}
else if ( lockMode==LockMode.PESSIMISTIC_READ) {
return new PessimisticReadUpdateLockingStrategy( lockable, lockMode);
}
else if ( lockMode==LockMode.OPTIMISTIC) {
return new OptimisticLockingStrategy( lockable, lockMode);
}
else if ( lockMode==LockMode.OPTIMISTIC_FORCE_INCREMENT) {
return new OptimisticForceIncrementLockingStrategy( lockable, lockMode);
}
else if ( lockMode.greaterThan( LockMode.READ ) ) {
return new UpdateLockingStrategy( lockable, lockMode );
}
else {
return new SelectLockingStrategy( lockable, lockMode );
}
}
示例15: handleUpdateTrial
import org.hibernate.LockMode; //導入依賴的package包/類
@Override
protected TrialOutVO handleUpdateTrial(AuthenticationVO auth, TrialInVO modifiedTrial)
throws Exception {
TrialDao trialDao = this.getTrialDao();
Trial originalTrial = CheckIDUtil.checkTrialId(modifiedTrial.getId(), trialDao, LockMode.PESSIMISTIC_WRITE);
Timestamp now = new Timestamp(System.currentTimeMillis());
User user = CoreUtil.getUser();
checkUpdateTrialInput(originalTrial, modifiedTrial, user);
TrialStatusType originalTrialStatusType = originalTrial.getStatus();
TrialOutVO original = trialDao.toTrialOutVO(originalTrial);
this.getTrialStatusTypeDao().evict(originalTrialStatusType);
trialDao.evict(originalTrial);
Trial trial = trialDao.trialInVOToEntity(modifiedTrial);
// Timestamp now = new Timestamp(System.currentTimeMillis());
// User user = CoreUtil.getUser();
CoreUtil.modifyVersion(originalTrial, trial, now, user);
trialDao.update(trial);
execTrialStatusActions(originalTrialStatusType, trial, now, user);
TrialOutVO result = trialDao.toTrialOutVO(trial);
ServiceUtil.logSystemMessage(trial, result, now, user, SystemMessageCodes.TRIAL_UPDATED, result, original, this.getJournalEntryDao());
return result;
}