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


Java LazyInitializer.getImplementation方法代码示例

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


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

示例1: unproxyAndReassociate

import org.hibernate.proxy.LazyInitializer; //导入方法依赖的package包/类
@Override
public Object unproxyAndReassociate(Object maybeProxy) throws HibernateException {
	if ( maybeProxy instanceof ElementWrapper ) {
		maybeProxy = ( (ElementWrapper) maybeProxy ).getElement();
	}

	if ( maybeProxy instanceof HibernateProxy ) {
		final HibernateProxy proxy = (HibernateProxy) maybeProxy;
		final LazyInitializer li = proxy.getHibernateLazyInitializer();
		reassociateProxy( li, proxy );
		//initialize + unwrap the object and return it
		return li.getImplementation();
	}
	else {
		return maybeProxy;
	}
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:18,代码来源:StatefulPersistenceContext.java

示例2: unproxy

import org.hibernate.proxy.LazyInitializer; //导入方法依赖的package包/类
@Override
public Object unproxy(Object maybeProxy) throws HibernateException {
	if ( maybeProxy instanceof ElementWrapper ) {
		maybeProxy = ( (ElementWrapper) maybeProxy ).getElement();
	}

	if ( maybeProxy instanceof HibernateProxy ) {
		final HibernateProxy proxy = (HibernateProxy) maybeProxy;
		final LazyInitializer li = proxy.getHibernateLazyInitializer();
		if ( li.isUninitialized() ) {
			throw new PersistentObjectException(
					"object was an uninitialized proxy for " + li.getEntityName()
			);
		}
		//unwrap the object and return
		return li.getImplementation();
	}
	else {
		return maybeProxy;
	}
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:22,代码来源:StatefulPersistenceContext.java

示例3: isPropertyInitialized

import org.hibernate.proxy.LazyInitializer; //导入方法依赖的package包/类
/**
 * Check if the property is initialized. If the named property does not exist
 * or is not persistent, this method always returns <tt>true</tt>.
 *
 * @param proxy The potential proxy
 * @param propertyName the name of a persistent attribute of the object
 * @return true if the named property of the object is not listed as uninitialized; false otherwise
 */
public static boolean isPropertyInitialized(Object proxy, String propertyName) {
	final Object entity;
	if ( proxy instanceof HibernateProxy ) {
		final LazyInitializer li = ( (HibernateProxy) proxy ).getHibernateLazyInitializer();
		if ( li.isUninitialized() ) {
			return false;
		}
		else {
			entity = li.getImplementation();
		}
	}
	else {
		entity = proxy;
	}

	if ( FieldInterceptionHelper.isInstrumented( entity ) ) {
		final FieldInterceptor interceptor = FieldInterceptionHelper.extractFieldInterceptor( entity );
		return interceptor == null || interceptor.isInitialized( propertyName );
	}
	else {
		return true;
	}
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:32,代码来源:Hibernate.java

示例4: bestGuessEntityName

import org.hibernate.proxy.LazyInitializer; //导入方法依赖的package包/类
@Override
public String bestGuessEntityName(Object object) {
	if (object instanceof HibernateProxy) {
		LazyInitializer initializer = ( ( HibernateProxy ) object ).getHibernateLazyInitializer();
		// it is possible for this method to be called during flush processing,
		// so make certain that we do not accidentally initialize an uninitialized proxy
		if ( initializer.isUninitialized() ) {
			return initializer.getEntityName();
		}
		object = initializer.getImplementation();
	}
	EntityEntry entry = persistenceContext.getEntry(object);
	if (entry==null) {
		return guessEntityName(object);
	}
	else {
		return entry.getPersister().getEntityName();
	}
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:20,代码来源:SessionImpl.java

示例5: returnNarrowedProxy

import org.hibernate.proxy.LazyInitializer; //导入方法依赖的package包/类
/**
 * Given a proxy, initialize it and/or narrow it provided either
 * is necessary.
 *
 * @param event The initiating load request event
 * @param persister The persister corresponding to the entity to be loaded
 * @param keyToLoad The key of the entity to be loaded
 * @param options The defined load options
 * @param persistenceContext The originating session
 * @param proxy The proxy to narrow
 *
 * @return The created/existing proxy
 */
private Object returnNarrowedProxy(
		final LoadEvent event,
		final EntityPersister persister,
		final EntityKey keyToLoad,
		final LoadEventListener.LoadType options,
		final PersistenceContext persistenceContext,
		final Object proxy) {
	LOG.trace( "Entity proxy found in session cache" );
	LazyInitializer li = ( (HibernateProxy) proxy ).getHibernateLazyInitializer();
	if ( li.isUnwrap() ) {
		return li.getImplementation();
	}
	Object impl = null;
	if ( !options.isAllowProxyCreation() ) {
		impl = load( event, persister, keyToLoad, options );
		if ( impl == null ) {
			event.getSession()
					.getFactory()
					.getEntityNotFoundDelegate()
					.handleEntityNotFound( persister.getEntityName(), keyToLoad.getIdentifier() );
		}
	}
	return persistenceContext.narrowProxy( proxy, persister, keyToLoad, impl );
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:38,代码来源:DefaultLoadEventListener.java

示例6: unproxy

import org.hibernate.proxy.LazyInitializer; //导入方法依赖的package包/类
/**
 * Get the entity instance underlying the given proxy, throwing
 * an exception if the proxy is uninitialized. If the given object
 * is not a proxy, simply return the argument.
 */
public Object unproxy(Object maybeProxy) throws HibernateException {
	if ( maybeProxy instanceof ElementWrapper ) {
		maybeProxy = ( (ElementWrapper) maybeProxy ).getElement();
	}
	
	if ( maybeProxy instanceof HibernateProxy ) {
		HibernateProxy proxy = (HibernateProxy) maybeProxy;
		LazyInitializer li = proxy.getHibernateLazyInitializer();
		if ( li.isUninitialized() ) {
			throw new PersistentObjectException(
					"object was an uninitialized proxy for " +
					li.getEntityName()
			);
		}
		return li.getImplementation(); //unwrap the object
	}
	else {
		return maybeProxy;
	}
}
 
开发者ID:cacheonix,项目名称:cacheonix-core,代码行数:26,代码来源:StatefulPersistenceContext.java

示例7: unproxyAndReassociate

import org.hibernate.proxy.LazyInitializer; //导入方法依赖的package包/类
/**
 * Possibly unproxy the given reference and reassociate it with the current session.
 *
 * @param maybeProxy The reference to be unproxied if it currently represents a proxy.
 * @return The unproxied instance.
 * @throws HibernateException
 */
public Object unproxyAndReassociate(Object maybeProxy) throws HibernateException {
	if ( maybeProxy instanceof ElementWrapper ) {
		maybeProxy = ( (ElementWrapper) maybeProxy ).getElement();
	}
	
	if ( maybeProxy instanceof HibernateProxy ) {
		HibernateProxy proxy = (HibernateProxy) maybeProxy;
		LazyInitializer li = proxy.getHibernateLazyInitializer();
		reassociateProxy(li, proxy);
		return li.getImplementation(); //initialize + unwrap the object
	}
	else {
		return maybeProxy;
	}
}
 
开发者ID:cacheonix,项目名称:cacheonix-core,代码行数:23,代码来源:StatefulPersistenceContext.java

示例8: isPropertyInitialized

import org.hibernate.proxy.LazyInitializer; //导入方法依赖的package包/类
/**
 * Check if the property is initialized. If the named property does not exist
 * or is not persistent, this method always returns <tt>true</tt>.
 *
 * @param proxy The potential proxy
 * @param propertyName the name of a persistent attribute of the object
 * @return true if the named property of the object is not listed as uninitialized
 * @return false if the object is an uninitialized proxy, or the named property is uninitialized
 */
public static boolean isPropertyInitialized(Object proxy, String propertyName) {
	
	Object entity;
	if ( proxy instanceof HibernateProxy ) {
		LazyInitializer li = ( ( HibernateProxy ) proxy ).getHibernateLazyInitializer();
		if ( li.isUninitialized() ) {
			return false;
		}
		else {
			entity = li.getImplementation();
		}
	}
	else {
		entity = proxy;
	}

	if ( FieldInterceptionHelper.isInstrumented( entity ) ) {
		FieldInterceptor interceptor = FieldInterceptionHelper.extractFieldInterceptor( entity );
		return interceptor == null || interceptor.isInitialized( propertyName );
	}
	else {
		return true;
	}
	
}
 
开发者ID:cacheonix,项目名称:cacheonix-core,代码行数:35,代码来源:Hibernate.java

示例9: returnNarrowedProxy

import org.hibernate.proxy.LazyInitializer; //导入方法依赖的package包/类
/**
 * Given that there is a pre-existing proxy.
 * Initialize it if necessary; narrow if necessary.
 */
private Object returnNarrowedProxy(
		final LoadEvent event, 
		final EntityPersister persister, 
		final EntityKey keyToLoad, 
		final LoadEventListener.LoadType options, 
		final PersistenceContext persistenceContext, 
		final Object proxy
) {
	log.trace("entity proxy found in session cache");
	LazyInitializer li = ( (HibernateProxy) proxy ).getHibernateLazyInitializer();
	if ( li.isUnwrap() ) {
		return li.getImplementation();
	}
	Object impl = null;
	if ( !options.isAllowProxyCreation() ) {
		impl = load( event, persister, keyToLoad, options );
		if ( impl == null ) {
			event.getSession().getFactory().getEntityNotFoundDelegate().handleEntityNotFound( persister.getEntityName(), keyToLoad.getIdentifier());
		}
	}
	return persistenceContext.narrowProxy( proxy, persister, keyToLoad, impl );
}
 
开发者ID:cacheonix,项目名称:cacheonix-core,代码行数:27,代码来源:DefaultLoadEventListener.java

示例10: bestGuessEntityName

import org.hibernate.proxy.LazyInitializer; //导入方法依赖的package包/类
public String bestGuessEntityName(Object object) {
	if (object instanceof HibernateProxy) {
		LazyInitializer initializer = ( ( HibernateProxy ) object ).getHibernateLazyInitializer();
		// it is possible for this method to be called during flush processing,
		// so make certain that we do not accidently initialize an uninitialized proxy
		if ( initializer.isUninitialized() ) {
			return initializer.getEntityName();
		}
		object = initializer.getImplementation();
	}
	EntityEntry entry = persistenceContext.getEntry(object);
	if (entry==null) {
		return guessEntityName(object);
	}
	else {
		return entry.getPersister().getEntityName();
	}
}
 
开发者ID:cacheonix,项目名称:cacheonix-core,代码行数:19,代码来源:SessionImpl.java

示例11: initializeProperty

import org.hibernate.proxy.LazyInitializer; //导入方法依赖的package包/类
/**
 *
 * @param o Set the object
 * @param association Set the association to initialize
 */
protected Object initializeProperty(final Object o, final String association) {
	Object object;
	try {
		object = PropertyUtils.getProperty(o, association);
	} catch (Exception e) {
		logger.debug("Cannot get proxy " + association + " for class " + o.getClass());
		return null;
	}
	if (object == null) {
		return null;
	} else if (object instanceof HibernateProxy) {
		((HibernateProxy) object).getHibernateLazyInitializer().initialize();
		LazyInitializer lazyInitializer = ((HibernateProxy) object)
				.getHibernateLazyInitializer();
		return lazyInitializer.getImplementation();
	} else if (object instanceof PersistentCollection) {
		((PersistentCollection) object).forceInitialization();
		return object;
	} else {
		return object;
	}
}
 
开发者ID:RBGKew,项目名称:eMonocot,代码行数:28,代码来源:DaoImpl.java

示例12: initializeProperty

import org.hibernate.proxy.LazyInitializer; //导入方法依赖的package包/类
/**
 *
 * @param o Set the object
 * @param association Set the association to initialize
 */
protected Object initializeProperty(final Object o, final String association) {
	Object object;
	try {
		object = PropertyUtils.getProperty(o, association);
	} catch (Exception e) {
		logger.debug("Cannot get proxy " + association + " for class " + o.getClass());
		return null;
	}
	if (object == null) {
		return null;
	} else if (object instanceof HibernateProxy) {
		logger.debug("Initializing {}.{}", object.getClass().getName(), association);
		((HibernateProxy) object).getHibernateLazyInitializer().initialize();
		LazyInitializer lazyInitializer = ((HibernateProxy) object).getHibernateLazyInitializer();
		return lazyInitializer.getImplementation();
	} else if (object instanceof PersistentCollection) {
		((PersistentCollection) object).forceInitialization();
		return object;
	} else {
		return object;
	}
}
 
开发者ID:RBGKew,项目名称:powop,代码行数:28,代码来源:DaoImpl.java

示例13: getEntity

import org.hibernate.proxy.LazyInitializer; //导入方法依赖的package包/类
/**
 * Gets entity.
 *
 * @param entityName
 *     the entity name
 * @param id
 *     the id
 * @return the entity
 */
@SuppressWarnings("unchecked")
protected IEntity getEntity(String entityName, Serializable id) {
  IEntity registeredEntity = null;
  try {
    if (getBackendController().isUnitOfWorkActive()) {
      registeredEntity = getBackendController().getUnitOfWorkEntity((Class<? extends IEntity>) Class.forName(
          entityName), id);
    } else {
      registeredEntity = getBackendController().getRegisteredEntity((Class<? extends IEntity>) Class.forName(
          entityName), id);
      if (registeredEntity instanceof HibernateProxy) {
        HibernateProxy proxy = (HibernateProxy) registeredEntity;
        LazyInitializer li = proxy.getHibernateLazyInitializer();
        registeredEntity = (IEntity) li.getImplementation();
      }
    }
  } catch (ClassNotFoundException ex) {
    LOG.error("Class for entity {} was not found", entityName, ex);
  }
  return registeredEntity;
}
 
开发者ID:jspresso,项目名称:jspresso-ce,代码行数:31,代码来源:JspressoMongoEventListener.java

示例14: write

import org.hibernate.proxy.LazyInitializer; //导入方法依赖的package包/类
@SuppressWarnings({"rawtypes", "unchecked"})
  @Override
  public void write(JsonWriter out, HibernateProxy value) throws IOException {
      if (value == null) {
          out.nullValue();
          return;
      }

LazyInitializer initializer =  value.getHibernateLazyInitializer();
if (initializer.isUninitialized()) {
	out.nullValue();
	return;
} else {
       // Retrieve the original (not proxy) class
       Class<?> baseType = Hibernate.getClass(value);
       // Get the TypeAdapter of the original class, to delegate the serialization
       TypeAdapter delegate = context.getAdapter(TypeToken.get(baseType));
       // Get a filled instance of the original class
       Object unproxiedValue = initializer.getImplementation();
       // Serialize the value
       delegate.write(out, unproxiedValue);
}
  }
 
开发者ID:Breeze,项目名称:breeze.server.java,代码行数:24,代码来源:HibernateProxyTypeAdapter.java

示例15: contains

import org.hibernate.proxy.LazyInitializer; //导入方法依赖的package包/类
@Override
public boolean contains(Object object) {
	errorIfClosed();
	checkTransactionSynchStatus();
	if ( object instanceof HibernateProxy ) {
		//do not use proxiesByKey, since not all
		//proxies that point to this session's
		//instances are in that collection!
		LazyInitializer li = ( (HibernateProxy) object ).getHibernateLazyInitializer();
		if ( li.isUninitialized() ) {
			//if it is an uninitialized proxy, pointing
			//with this session, then when it is accessed,
			//the underlying instance will be "contained"
			return li.getSession()==this;
		}
		else {
			//if it is initialized, see if the underlying
			//instance is contained, since we need to
			//account for the fact that it might have been
			//evicted
			object = li.getImplementation();
		}
	}
	// A session is considered to contain an entity only if the entity has
	// an entry in the session's persistence context and the entry reports
	// that the entity has not been removed
	EntityEntry entry = persistenceContext.getEntry( object );
	delayedAfterCompletion();
	return entry != null && entry.getStatus() != Status.DELETED && entry.getStatus() != Status.GONE;
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:31,代码来源:SessionImpl.java


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