当前位置: 首页>>代码示例>>Java>>正文


Java StaleStateException类代码示例

本文整理汇总了Java中org.hibernate.StaleStateException的典型用法代码示例。如果您正苦于以下问题:Java StaleStateException类的具体用法?Java StaleStateException怎么用?Java StaleStateException使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


StaleStateException类属于org.hibernate包,在下文中一共展示了StaleStateException类的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: checkBatched

import org.hibernate.StaleStateException; //导入依赖的package包/类
private void checkBatched(int rowCount, int batchPosition) {
          if (rowCount == -2) LOG.debugf("Success of batch update unknown: %s", batchPosition);
          else if (rowCount == -3) throw new BatchFailedException("Batch update failed: " + batchPosition);
	else {
              if (expectedRowCount > rowCount) throw new StaleStateException(
                                                                             "Batch update returned unexpected row count from update ["
                                                                             + batchPosition + "]; actual row count: " + rowCount
                                                                             + "; expected: " + expectedRowCount);
		if ( expectedRowCount < rowCount ) {
			String msg = "Batch update returned unexpected row count from update [" +
			             batchPosition + "]; actual row count: " + rowCount +
			             "; expected: " + expectedRowCount;
			throw new BatchedTooManyRowsAffectedException( msg, expectedRowCount, rowCount, batchPosition );
		}
	}
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:17,代码来源:Expectations.java

示例2: nextId

import org.hibernate.StaleStateException; //导入依赖的package包/类
public synchronized long nextId() {
	if (lastId < nextId) {
		for (int attempts = maxAttempts; (attempts > 0); attempts--) {
			try {
				AcquireDbidCommand command = new AcquireDbidCommand(blockSize);
				nextId = commandService.executeCommandInNewTransaction(command);
				lastId = nextId + blockSize - 1;
				break;
			} catch (StaleStateException e) {
				attempts--;
				if (attempts == 0) {
					throw new IllegalStateException("couldn't acquire block of ids, tried "+ maxAttempts + " times");
				}
				// if there are still attempts left, first wait a bit
				int millis = 20 + random.nextInt(200);
				log.debug("optimistic locking failure while trying to acquire id block.  retrying in "+ millis + " millis");
				try {
					Thread.sleep(millis);
				} catch (InterruptedException e1) {
					log.debug("waiting after id block locking failure got interrupted");
				}
			}
		}
	}
	return nextId++;
}
 
开发者ID:youseries,项目名称:uflo,代码行数:27,代码来源:IDGenerator.java

示例3: checkBatched

import org.hibernate.StaleStateException; //导入依赖的package包/类
private void checkBatched(int rowCount, int batchPosition) {
	if ( rowCount == -2 ) {
		if ( log.isDebugEnabled() ) {
			log.debug( "success of batch update unknown: " + batchPosition );
		}
	}
	else if ( rowCount == -3 ) {
		throw new BatchFailedException( "Batch update failed: " + batchPosition );
	}
	else {
		if ( expectedRowCount > rowCount ) {
			throw new StaleStateException(
					"Batch update returned unexpected row count from update [" + batchPosition +
					"]; actual row count: " + rowCount +
					"; expected: " + expectedRowCount
			);
		}
		if ( expectedRowCount < rowCount ) {
			String msg = "Batch update returned unexpected row count from update [" +
			             batchPosition + "]; actual row count: " + rowCount +
			             "; expected: " + expectedRowCount;
			throw new BatchedTooManyRowsAffectedException( msg, expectedRowCount, rowCount, batchPosition );
		}
	}
}
 
开发者ID:cacheonix,项目名称:cacheonix-core,代码行数:26,代码来源:Expectations.java

示例4: rememberMeLogin

import org.hibernate.StaleStateException; //导入依赖的package包/类
/**
 * http://jaspan.com/improved_persistent_login_cookie_best_practice
 */
@Override
@Transactional(isolation=Isolation.READ_UNCOMMITTED, rollbackFor=StaleStateException.class)
public Login rememberMeLogin(String token, String series, String ip) {
    Login existingLogin = getDao().getLoginFromAuthToken(token, series);
    if (existingLogin == null) {
        Login loginBySeries = getDao().getByPropertyValue(Login.class, "series", series);
        // if a login series exists, assume the previous token was stolen, so deleting all persistent logins
        // an exception is a request made within a few seconds from the last login time
        // which may mean request from the same browser that is not yet aware of the renewed cookie
        if (loginBySeries != null && new Period(loginBySeries.getLastLoginTime(), new DateTime()).getSeconds() < 5) {
            log.info("Assuming login cookies theft; deleting all sessions for user " + loginBySeries.getUser());
            getDao().deleteLogins(loginBySeries.getUser().getId());
        } else if (log.isDebugEnabled()) {
            log.debug("No existing login found for token=" + token + ", series=" + series);
        }
        return null;
    }
    if (log.isDebugEnabled()) {
        log.debug("Existing login found for token=" + token + " and series=" + series);
    }

    Login newLogin = createLoginAndUpdateUserData(existingLogin.getUser(), existingLogin.getSeries(), true, ip);
    delete(existingLogin);
    return newLogin;
}
 
开发者ID:Glamdring,项目名称:welshare,代码行数:29,代码来源:UserServiceImpl.java

示例5: rememberMeLogin

import org.hibernate.StaleStateException; //导入依赖的package包/类
/**
 * http://jaspan.com/improved_persistent_login_cookie_best_practice
 */
@Transactional(rollbackFor=StaleStateException.class)
public User rememberMeLogin(String token, String series) {
    User existingLogin = userDao.getLoginFromAuthToken(token, series);
    if (existingLogin == null) {
        User loginBySeries = userDao.getByPropertyValue(User.class, "loginSeries", series);
        // if a login series exists, assume the previous token was stolen, so deleting all persistent logins.
        // An exception is a request made within a few seconds from the last login time
        // which may mean request from the same browser that is not yet aware of the renewed cookie
        if (loginBySeries != null && new Period(loginBySeries.getLastLoginTime(), new DateTime()).getSeconds() < 5) {
            logger.info("Assuming login cookies theft; deleting all sessions for user " + loginBySeries);
            loginBySeries.setLoginSeries(null);
            loginBySeries.setLoginToken(null);
            userDao.persist(loginBySeries);
        } else if (logger.isDebugEnabled()) {
            logger.debug("No existing login found for token=" + token + ", series=" + series);
        }
        return null;
    }
    if (logger.isDebugEnabled()) {
        logger.debug("Existing login found for token=" + token + " and series=" + series);
    }
    fillUserWithNewTokens(existingLogin, series);
    return existingLogin;
}
 
开发者ID:Glamdring,项目名称:computoser,代码行数:28,代码来源:UserService.java

示例6: checkNonBatched

import org.hibernate.StaleStateException; //导入依赖的package包/类
private void checkNonBatched(int rowCount) {
	if ( expectedRowCount > rowCount ) {
		throw new StaleStateException(
				"Unexpected row count: " + rowCount + "; expected: " + expectedRowCount
		);
	}
	if ( expectedRowCount < rowCount ) {
		String msg = "Unexpected row count: " + rowCount + "; expected: " + expectedRowCount;
		throw new TooManyRowsAffectedException( msg, expectedRowCount, rowCount );
	}
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:12,代码来源:Expectations.java

示例7: configure

import org.hibernate.StaleStateException; //导入依赖的package包/类
@Override
protected void configure() {
	super.configure();
	
	bind(WicketServlet.class).to(DefaultWicketServlet.class);
	bind(WicketFilter.class).to(DefaultWicketFilter.class);
	bind(WebSocketPolicy.class).toInstance(WebSocketPolicy.newServerPolicy());
	bind(EditSupportRegistry.class).to(DefaultEditSupportRegistry.class);
	bind(WebSocketManager.class).to(DefaultWebSocketManager.class);

	contribute(CommitMessageTransformer.class, PatternCommitMessageTransformer.class);
	
	contributeFromPackage(EditSupport.class, EditSupport.class);
	
	bind(WebApplication.class).to(GitPlexWebApplication.class);
	bind(Application.class).to(GitPlexWebApplication.class);
	bind(AvatarManager.class).to(DefaultAvatarManager.class);
	bind(WebSocketManager.class).to(DefaultWebSocketManager.class);
	
	contributeFromPackage(EditSupport.class, EditSupportLocator.class);
	
	bind(CommitIndexedBroadcaster.class);
	
	contributeFromPackage(DiffRenderer.class, DiffRenderer.class);
	contributeFromPackage(BlobRendererContribution.class, BlobRendererContribution.class);

	contribute(Extension.class, new EmojiExtension());
	contribute(Extension.class, new SourcePositionTrackExtension());
	contribute(HtmlTransformer.class, new MentionTransformer());
	contribute(HtmlTransformer.class, new PullRequestTransformer());

	contribute(ResourcePackScopeContribution.class, new ResourcePackScopeContribution() {
		
		@Override
		public Collection<Class<?>> getResourcePackScopes() {
			return Lists.newArrayList(WebModule.class);
		}
		
	});
	contribute(ExpectedExceptionContribution.class, new ExpectedExceptionContribution() {
		
		@SuppressWarnings("unchecked")
		@Override
		public Collection<Class<? extends Exception>> getExpectedExceptionClasses() {
			return Sets.newHashSet(ConstraintViolationException.class, EntityNotFoundException.class, 
					ObjectNotFoundException.class, StaleStateException.class, UnauthorizedException.class, 
					GitException.class, PageExpiredException.class, StalePageException.class);
		}
		
	});

	bind(UrlManager.class).to(DefaultUrlManager.class);
	bind(CodeCommentChangeBroadcaster.class);
	bind(PullRequestChangeBroadcaster.class);
	bind(TaskChangeBroadcaster.class);
}
 
开发者ID:jmfgdev,项目名称:gitplex-mit,代码行数:57,代码来源:WebModule.java

示例8: isLockingException

import org.hibernate.StaleStateException; //导入依赖的package包/类
private static boolean isLockingException(Throwable throwable) {
	for (Throwable t = throwable; t != null; t = t.getCause()) {
		if (t instanceof StaleStateException || t instanceof LockAcquisitionException) {
			return true;
		}
	}
	return false;
}
 
开发者ID:GovernIB,项目名称:helium,代码行数:9,代码来源:JobExecutorThread.java

示例9: rememberMeLogin

import org.hibernate.StaleStateException; //导入依赖的package包/类
/**
 * http://jaspan.com/improved_persistent_login_cookie_best_practice
 */
@Transactional(rollbackFor = StaleStateException.class)
public User rememberMeLogin(String token, String series) {
    User existingLogin = dao.getLoginFromAuthToken(token, series);
    if (existingLogin == null) {
        User loginBySeries = dao.getByPropertyValue(User.class, "loginSeries", series);
        // if a login series exists, assume the previous token was stolen, so deleting all persistent logins.
        // An exception is a request made within a few seconds from the last login time
        // which may mean request from the same browser that is not yet aware of the renewed cookie
        // Note: fallback to joda-time, as java.time is insufficient 
        if (loginBySeries != null && new Period(new DateTime(loginBySeries.getLastLoginTime().toInstant(ZoneOffset.UTC).toEpochMilli()), 
                DateTime.now()).getSeconds() < 5) {
            logger.info("Assuming login cookies theft; deleting all sessions for user " + loginBySeries);
            loginBySeries.setLoginSeries(null);
            loginBySeries.setLoginToken(null);
            dao.persist(loginBySeries);
        } else if (logger.isDebugEnabled()) {
            logger.debug("No existing login found for token=" + token + ", series=" + series);
        }
        return null;
    }
    if (logger.isDebugEnabled()) {
        logger.debug("Existing login found for token=" + token + " and series=" + series);
    }
    fillUserWithNewTokens(existingLogin, series);
    return existingLogin;
}
 
开发者ID:Glamdring,项目名称:scientific-publishing,代码行数:30,代码来源:UserService.java

示例10: hasTCI

import org.hibernate.StaleStateException; //导入依赖的package包/类
public Boolean hasTCI(Booking_AppointmentRefVo appointment)
{
	if (appointment == null)
		return Boolean.FALSE;
	
	long count = 0;
	
	String query = "SELECT COUNT (tci.id) FROM TCIForPatientElectiveList AS tci LEFT JOIN tci.appointment AS appt WHERE appt.id = :APPT_ID and tci.isRIE is null";
	
	//WDEV-23321
	try
	{
		count = getDomainFactory().countWithHQL(query, new String[] {"APPT_ID"}, new Object[] {appointment.getID_Booking_Appointment()});
	}
	catch (RuntimeException e) {
		if (e instanceof LockAcquisitionException) 
		{
			try
			{
				count = getDomainFactory().countWithHQL(query, new String[] {"APPT_ID"}, new Object[] {appointment.getID_Booking_Appointment()});
			}
			catch (RuntimeException e1) 
			{
				if (e1 instanceof LockAcquisitionException) 
				{
					throw new StaleStateException(ConfigFlag.UI.STALE_OBJECT_MESSAGE.getValue());
				}
			}
		}
	}
	//WDEV-23321 ends here
	if (count > 0)
		return Boolean.TRUE;
	
	return Boolean.FALSE;
}
 
开发者ID:IMS-MAXIMS,项目名称:openMAXIMS,代码行数:37,代码来源:AppointmentOutcomeDialogImpl.java

示例11: HibernateOptimisticLockingFailureException

import org.hibernate.StaleStateException; //导入依赖的package包/类
public HibernateOptimisticLockingFailureException(StaleStateException ex) {
	super(ex.getMessage(), ex);
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:4,代码来源:HibernateOptimisticLockingFailureException.java

示例12: getBedSpaceState

import org.hibernate.StaleStateException; //导入依赖的package包/类
public BedSpaceStateLiteVo getBedSpaceState(BedSpaceRefVo bed) 
{
	if(bed == null )
		throw new DomainRuntimeException("Invalid BedRefVo");
	
	String hql = "select bs,(select adm.healthyLodger from AdmissionDetail as adm where adm.pasEvent.id = bs.inpatientEpisode.pasEvent.id) from BedSpaceState as bs left join bs.bedSpace as bed where bed.id = " + bed.getID_BedSpace();
	
	List<?> bedState = null;
	
	//WDEV-23014 - Catch the Lock error and retry the entire transaction. After two retries, throw a SOE message. 

	try
	{
		bedState = getDomainFactory().find(hql);
	}
	catch (RuntimeException e) {
		if (e instanceof LockAcquisitionException) 
		{
			try
			{
				bedState = getDomainFactory().find(hql);
			}
			catch (RuntimeException e1) 
			{
				if (e1 instanceof LockAcquisitionException) 
				{
					throw new StaleStateException(ConfigFlag.UI.STALE_OBJECT_MESSAGE.getValue());
				}
			}
		}
	}
	//WDEV-23014 ends here
	
	//WDEV-11039
	boolean hasAlerts = false;
	BedSpaceStateLiteVoCollection voColl  = new BedSpaceStateLiteVoCollection();
	if (bedState != null && bedState.size() > 0 && bedState.get(0) instanceof Object[])
	{
		Object[] recordDO = (Object[]) bedState.get(0);
		BedSpaceStateLiteVo bs = null;
		for (int i =0;i<recordDO.length;i++)
		{				
			if (recordDO[0] instanceof BedSpaceState)
			{	
				BedSpaceState doBed = (BedSpaceState)recordDO[0];
				if(doBed.getInpatientEpisode() != null && doBed.getInpatientEpisode().getPasEvent() != null && doBed.getInpatientEpisode().getPasEvent().getPatient() != null && doBed.getInpatientEpisode().getPasEvent().getPatient().getPatientAlerts() != null)
					if(doBed.getInpatientEpisode().getPasEvent().getPatient().getPatientAlerts().size() > 0 && isOneActive(doBed.getInpatientEpisode().getPasEvent().getPatient().getPatientAlerts(), true))
						hasAlerts = true;

				bs  = BedSpaceStateLiteVoAssembler.create((BedSpaceState)recordDO[0]);
			}	
			if (bs.getInpatientEpisodeIsNotNull() && recordDO[1] != null && recordDO[1] instanceof HealthyLodger)
				bs.getInpatientEpisode().setHealthyLodgerDetails(HealthyLodgerVoAssembler.create((HealthyLodger)recordDO[1]));
		}
		if (bs != null)
			voColl.add(bs);

	}
	//BedSpaceStateLiteVoCollection voColl = BedSpaceStateLiteVoAssembler.createBedSpaceStateLiteVoCollectionFromBedSpaceState(bedState);
	
	if (voColl != null && voColl.size() > 0)
	{
		if(voColl.get(0).getInpatientEpisodeIsNotNull() && voColl.get(0).getInpatientEpisode().getPasEventIsNotNull() && voColl.get(0).getInpatientEpisode().getPasEvent().getPatientIsNotNull())
			voColl.get(0).getInpatientEpisode().getPasEvent().getPatient().setHasAlerts(hasAlerts);
		
		return voColl.get(0);		
	}
	return null;
}
 
开发者ID:IMS-MAXIMS,项目名称:openMAXIMS,代码行数:70,代码来源:WardViewImpl.java


注:本文中的org.hibernate.StaleStateException类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。