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


Java LazyInitializer.getIdentifier方法代码示例

本文整理汇总了Java中org.hibernate.proxy.LazyInitializer.getIdentifier方法的典型用法代码示例。如果您正苦于以下问题:Java LazyInitializer.getIdentifier方法的具体用法?Java LazyInitializer.getIdentifier怎么用?Java LazyInitializer.getIdentifier使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.hibernate.proxy.LazyInitializer的用法示例。


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

示例1: getIdentifier

import org.hibernate.proxy.LazyInitializer; //导入方法依赖的package包/类
@Override
public Serializable getIdentifier(Object object) throws HibernateException {
	errorIfClosed();
	checkTransactionSynchStatus();
	if ( object instanceof HibernateProxy ) {
		LazyInitializer li = ( (HibernateProxy) object ).getHibernateLazyInitializer();
		if ( li.getSession() != this ) {
			throw new TransientObjectException( "The proxy was not associated with this session" );
		}
		return li.getIdentifier();
	}
	else {
		EntityEntry entry = persistenceContext.getEntry(object);
		if ( entry == null ) {
			throw new TransientObjectException( "The instance was not associated with this session" );
		}
		return entry.getId();
	}
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:20,代码来源:SessionImpl.java

示例2: getIdentifier

import org.hibernate.proxy.LazyInitializer; //导入方法依赖的package包/类
public Serializable getIdentifier(Object object) throws HibernateException {
	errorIfClosed();
	checkTransactionSynchStatus();
	if ( object instanceof HibernateProxy ) {
		LazyInitializer li = ( (HibernateProxy) object ).getHibernateLazyInitializer();
		if ( li.getSession() != this ) {
			throw new TransientObjectException( "The proxy was not associated with this session" );
		}
		return li.getIdentifier();
	}
	else {
		EntityEntry entry = persistenceContext.getEntry(object);
		if ( entry == null ) {
			throw new TransientObjectException( "The instance was not associated with this session" );
		}
		return entry.getId();
	}
}
 
开发者ID:cacheonix,项目名称:cacheonix-core,代码行数:19,代码来源:SessionImpl.java

示例3: getIdentifier

import org.hibernate.proxy.LazyInitializer; //导入方法依赖的package包/类
@Override
public Object getIdentifier(Object entity) {
    if (entity instanceof org.hibernate.proxy.HibernateProxy) {
        LazyInitializer initializer
            = ((org.hibernate.proxy.HibernateProxy)entity).getHibernateLazyInitializer();
        return initializer.getIdentifier();
    } else {
        return persistenceUnitUtil.getIdentifier(entity);
    }
}
 
开发者ID:ArneLimburg,项目名称:jpasecurity,代码行数:11,代码来源:SecurePersistenceUnitUtil.java

示例4: reassociateProxy

import org.hibernate.proxy.LazyInitializer; //导入方法依赖的package包/类
/**
 * Associate a proxy that was instantiated by another session with this session
 *
 * @param li The proxy initializer.
 * @param proxy The proxy to reassociate.
 */
private void reassociateProxy(LazyInitializer li, HibernateProxy proxy) {
	if ( li.getSession() != this.getSession() ) {
		EntityPersister persister = session.getFactory().getEntityPersister( li.getEntityName() );
		EntityKey key = new EntityKey( li.getIdentifier(), persister, session.getEntityMode() );
	  	// any earlier proxy takes precedence
		if ( !proxiesByKey.containsKey( key ) ) {
			proxiesByKey.put( key, proxy );
		}
		proxy.getHibernateLazyInitializer().setSession( session );
	}
}
 
开发者ID:cacheonix,项目名称:cacheonix-core,代码行数:18,代码来源:StatefulPersistenceContext.java

示例5: getIdentifier

import org.hibernate.proxy.LazyInitializer; //导入方法依赖的package包/类
/**
 * Get the identifier value of an instance or proxy.
 * <p/>
 * Intended only for loggin purposes!!!
 *
 * @param object The object from which to extract the identifier.
 * @param persister The entity persister
 * @param entityMode The entity mode
 * @return The extracted identifier.
 */
private static Serializable getIdentifier(Object object, EntityPersister persister, EntityMode entityMode) {
	if (object instanceof HibernateProxy) {
		HibernateProxy proxy = (HibernateProxy) object;
		LazyInitializer li = proxy.getHibernateLazyInitializer();
		return li.getIdentifier();
	}
	else {
		return persister.getIdentifier( object, entityMode );
	}
}
 
开发者ID:cacheonix,项目名称:cacheonix-core,代码行数:21,代码来源:EntityType.java

示例6: getId

import org.hibernate.proxy.LazyInitializer; //导入方法依赖的package包/类
/**
 * extract the id from the proxy without initializing it
 */
public static Long getId(AbstractModel model) {
	if (model instanceof HibernateProxy) {
		LazyInitializer lazyInitializer = ((HibernateProxy) model).getHibernateLazyInitializer();
		if (lazyInitializer.isUninitialized()) {
			return (Long) lazyInitializer.getIdentifier();
		}
	}
	return model.getId();
}
 
开发者ID:Athou,项目名称:commafeed,代码行数:13,代码来源:Models.java


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