• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java ObjectDeletedException类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: getCurrentLockMode

import org.hibernate.ObjectDeletedException; //导入依赖的package包/类
@Override
public LockMode getCurrentLockMode(Object object) throws HibernateException {
	errorIfClosed();
	checkTransactionSynchStatus();
	if ( object == null ) {
		throw new NullPointerException( "null object passed to getCurrentLockMode()" );
	}
	if ( object instanceof HibernateProxy ) {
		object = ( (HibernateProxy) object ).getHibernateLazyInitializer().getImplementation(this);
		if ( object == null ) {
			return LockMode.NONE;
		}
	}
	EntityEntry e = persistenceContext.getEntry(object);
	if ( e == null ) {
		throw new TransientObjectException( "Given object not associated with the session" );
	}
	if ( e.getStatus() != Status.MANAGED ) {
		throw new ObjectDeletedException(
				"The given object was deleted",
				e.getId(),
				e.getPersister().getEntityName()
			);
	}
	return e.getLockMode();
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:27,代码来源:SessionImpl.java


示例2: forceFlush

import org.hibernate.ObjectDeletedException; //导入依赖的package包/类
@Override
public void forceFlush(EntityEntry entityEntry) throws HibernateException {
	errorIfClosed();
	if ( LOG.isDebugEnabled() ) {
		LOG.debugf( "Flushing to force deletion of re-saved object: %s",
				MessageHelper.infoString( entityEntry.getPersister(), entityEntry.getId(), getFactory() ) );
	}

	if ( persistenceContext.getCascadeLevel() > 0 ) {
		throw new ObjectDeletedException(
			"deleted object would be re-saved by cascade (remove deleted object from associations)",
			entityEntry.getId(),
			entityEntry.getPersister().getEntityName()
		);
	}

	flush();
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:19,代码来源:SessionImpl.java


示例3: performSaveOrUpdate

import org.hibernate.ObjectDeletedException; //导入依赖的package包/类
protected Serializable performSaveOrUpdate(SaveOrUpdateEvent event) {
	// this implementation is supposed to tolerate incorrect unsaved-value
	// mappings, for the purpose of backward-compatibility
	EntityEntry entry = event.getSession().getPersistenceContext().getEntry( event.getEntity() );
	if ( entry!=null ) {
		if ( entry.getStatus()== Status.DELETED ) {
			throw new ObjectDeletedException( "deleted instance passed to update()", null, event.getEntityName() );
		}
		else {
			return entityIsPersistent(event);
		}
	}
	else {
		entityIsDetached(event);
		return null;
	}
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:18,代码来源:DefaultUpdateEventListener.java


示例4: performSaveOrUpdate

import org.hibernate.ObjectDeletedException; //导入依赖的package包/类
protected Serializable performSaveOrUpdate(SaveOrUpdateEvent event) {
	// this implementation is supposed to tolerate incorrect unsaved-value
	// mappings, for the purpose of backward-compatibility
	EntityEntry entry = event.getSession().getPersistenceContext().getEntry( event.getEntity() );
	if ( entry!=null ) {
		if ( entry.getStatus()==Status.DELETED ) {
			throw new ObjectDeletedException( "deleted instance passed to update()", null, event.getEntityName() );
		}
		else {
			return entityIsPersistent(event);
		}
	}
	else {
		entityIsDetached(event);
		return null;
	}
}
 
开发者ID:cacheonix,项目名称:cacheonix-core,代码行数:18,代码来源:DefaultUpdateEventListener.java


示例5: getCurrentLockMode

import org.hibernate.ObjectDeletedException; //导入依赖的package包/类
public LockMode getCurrentLockMode(Object object) throws HibernateException {
	errorIfClosed();
	checkTransactionSynchStatus();
	if ( object == null ) {
		throw new NullPointerException( "null object passed to getCurrentLockMode()" );
	}
	if ( object instanceof HibernateProxy ) {
		object = ( (HibernateProxy) object ).getHibernateLazyInitializer().getImplementation(this);
		if ( object == null ) {
			return LockMode.NONE;
		}
	}
	EntityEntry e = persistenceContext.getEntry(object);
	if ( e == null ) {
		throw new TransientObjectException( "Given object not associated with the session" );
	}
	if ( e.getStatus() != Status.MANAGED ) {
		throw new ObjectDeletedException( 
				"The given object was deleted", 
				e.getId(), 
				e.getPersister().getEntityName() 
			);
	}
	return e.getLockMode();
}
 
开发者ID:cacheonix,项目名称:cacheonix-core,代码行数:26,代码来源:SessionImpl.java


示例6: forceFlush

import org.hibernate.ObjectDeletedException; //导入依赖的package包/类
public void forceFlush(EntityEntry entityEntry) throws HibernateException {
	errorIfClosed();
	if ( log.isDebugEnabled() ) {
		log.debug(
			"flushing to force deletion of re-saved object: " +
			MessageHelper.infoString( entityEntry.getPersister(), entityEntry.getId(), getFactory() )
		);
	}

	if ( persistenceContext.getCascadeLevel() > 0 ) {
		throw new ObjectDeletedException(
			"deleted object would be re-saved by cascade (remove deleted object from associations)",
			entityEntry.getId(),
			entityEntry.getPersister().getEntityName()
		);
	}

	flush();
}
 
开发者ID:cacheonix,项目名称:cacheonix-core,代码行数:20,代码来源:SessionImpl.java


示例7: removeItem

import org.hibernate.ObjectDeletedException; //导入依赖的package包/类
public void removeItem(Item item) {
    try {

        if (item == null) {
            throw new IllegalArgumentException("item cannot be null");
        }

        if (item instanceof HomeCollectionItem) {
            throw new IllegalArgumentException("cannot remove root item");
        }

        removeItemInternal(item);
        getSession().flush();

    } catch (ObjectNotFoundException onfe) {
        throw new ItemNotFoundException("item not found");
    } catch (ObjectDeletedException ode) {
        throw new ItemNotFoundException("item not found");
    } catch (UnresolvableObjectException uoe) {
        throw new ItemNotFoundException("item not found");
    } catch (HibernateException e) {
        getSession().clear();
        throw SessionFactoryUtils.convertHibernateAccessException(e);
    }
}
 
开发者ID:1and1,项目名称:cosmo,代码行数:26,代码来源:ItemDaoImpl.java


示例8: upgradeLock

import org.hibernate.ObjectDeletedException; //导入依赖的package包/类
/**
 * Performs a pessimistic lock upgrade on a given entity, if needed.
 *
 * @param object The entity for which to upgrade the lock.
 * @param entry The entity's EntityEntry instance.
 * @param lockOptions contains the requested lock mode.
 * @param source The session which is the source of the event being processed.
 */
protected void upgradeLock(Object object, EntityEntry entry, LockOptions lockOptions, EventSource source) {

	LockMode requestedLockMode = lockOptions.getLockMode();
	if ( requestedLockMode.greaterThan( entry.getLockMode() ) ) {
		// The user requested a "greater" (i.e. more restrictive) form of
		// pessimistic lock

		if ( entry.getStatus() != Status.MANAGED ) {
			throw new ObjectDeletedException(
					"attempted to lock a deleted instance",
					entry.getId(),
					entry.getPersister().getEntityName()
			);
		}

		final EntityPersister persister = entry.getPersister();

		if ( log.isTraceEnabled() ) {
			log.tracev(
					"Locking {0} in mode: {1}",
					MessageHelper.infoString( persister, entry.getId(), source.getFactory() ),
					requestedLockMode
			);
		}

		final SoftLock lock;
		final CacheKey ck;
		if ( persister.hasCache() ) {
			ck = source.generateCacheKey( entry.getId(), persister.getIdentifierType(), persister.getRootEntityName() );
			lock = persister.getCacheAccessStrategy().lockItem( ck, entry.getVersion() );
		}
		else {
			ck = null;
			lock = null;
		}

		try {
			if ( persister.isVersioned() && requestedLockMode == LockMode.FORCE  ) {
				// todo : should we check the current isolation mode explicitly?
				Object nextVersion = persister.forceVersionIncrement(
						entry.getId(), entry.getVersion(), source
				);
				entry.forceLocked( object, nextVersion );
			}
			else {
				persister.lock( entry.getId(), entry.getVersion(), object, lockOptions, source );
			}
			entry.setLockMode(requestedLockMode);
		}
		finally {
			// the database now holds a lock + the object is flushed from the cache,
			// so release the soft lock
			if ( persister.hasCache() ) {
				persister.getCacheAccessStrategy().unlockItem( ck, lock );
			}
		}

	}
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:68,代码来源:AbstractLockUpgradeEventListener.java


示例9: onPersist

import org.hibernate.ObjectDeletedException; //导入依赖的package包/类
/** 
 * Handle the given create event.
 *
 * @param event The create event to be handled.
 * @throws HibernateException
 */
public void onPersist(PersistEvent event, Map createCache) throws HibernateException {
		
	final SessionImplementor source = event.getSession();
	final Object object = event.getObject();
	
	final Object entity;
	if (object instanceof HibernateProxy) {
		LazyInitializer li = ( (HibernateProxy) object ).getHibernateLazyInitializer();
		if ( li.isUninitialized() ) {
			if ( li.getSession()==source ) {
				return; //NOTE EARLY EXIT!
			}
			else {
				throw new PersistentObjectException("uninitialized proxy passed to persist()");
			}
		}
		entity = li.getImplementation();
	}
	else {
		entity = object;
	}
	
	int entityState = getEntityState( 
			entity, 
			event.getEntityName(), 
			source.getPersistenceContext().getEntry(entity), 
			source 
		);
	
	switch (entityState) {
		case DETACHED: 
			throw new PersistentObjectException( 
					"detached entity passed to persist: " + 
					getLoggableName( event.getEntityName(), entity ) 
				);
		case PERSISTENT:
			entityIsPersistent(event, createCache);
			break;
		case TRANSIENT:
			entityIsTransient(event, createCache);
			break;
		default: 
			throw new ObjectDeletedException( 
					"deleted entity passed to persist", 
					null, 
					getLoggableName( event.getEntityName(), entity )
				);
	}

}
 
开发者ID:cacheonix,项目名称:cacheonix-core,代码行数:57,代码来源:DefaultPersistEventListener.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java ITextureStateListener类代码示例发布时间:2022-05-22
下一篇:
Java Buffer类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap