當前位置: 首頁>>代碼示例>>Java>>正文


Java HibernateProxy.getHibernateLazyInitializer方法代碼示例

本文整理匯總了Java中org.hibernate.proxy.HibernateProxy.getHibernateLazyInitializer方法的典型用法代碼示例。如果您正苦於以下問題:Java HibernateProxy.getHibernateLazyInitializer方法的具體用法?Java HibernateProxy.getHibernateLazyInitializer怎麽用?Java HibernateProxy.getHibernateLazyInitializer使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.hibernate.proxy.HibernateProxy的用法示例。


在下文中一共展示了HibernateProxy.getHibernateLazyInitializer方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: unproxyAndReassociate

import org.hibernate.proxy.HibernateProxy; //導入方法依賴的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: reassociateIfUninitializedProxy

import org.hibernate.proxy.HibernateProxy; //導入方法依賴的package包/類
@Override
public boolean reassociateIfUninitializedProxy(Object value) throws MappingException {
	if ( value instanceof ElementWrapper ) {
		value = ( (ElementWrapper) value ).getElement();
	}

	if ( !Hibernate.isInitialized( value ) ) {
		final HibernateProxy proxy = (HibernateProxy) value;
		final LazyInitializer li = proxy.getHibernateLazyInitializer();
		reassociateProxy( li, proxy );
		return true;
	}
	else {
		return false;
	}
}
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:17,代碼來源:StatefulPersistenceContext.java

示例3: unproxy

import org.hibernate.proxy.HibernateProxy; //導入方法依賴的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

示例4: reassociateIfUninitializedProxy

import org.hibernate.proxy.HibernateProxy; //導入方法依賴的package包/類
/**
 * Takes the given object and, if it represents a proxy, reassociates it with this event source.
 *
 * @param value The possible proxy to be reassociated.
 * @return Whether the passed value represented an actual proxy which got initialized.
 * @throws MappingException
 */
public boolean reassociateIfUninitializedProxy(Object value) throws MappingException {
	if ( value instanceof ElementWrapper ) {
		value = ( (ElementWrapper) value ).getElement();
	}
	
	if ( !Hibernate.isInitialized(value) ) {
		HibernateProxy proxy = (HibernateProxy) value;
		LazyInitializer li = proxy.getHibernateLazyInitializer();
		reassociateProxy(li, proxy);
		return true;
	}
	else {
		return false;
	}
}
 
開發者ID:cacheonix,項目名稱:cacheonix-core,代碼行數:23,代碼來源:StatefulPersistenceContext.java

示例5: unproxy

import org.hibernate.proxy.HibernateProxy; //導入方法依賴的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

示例6: unproxyAndReassociate

import org.hibernate.proxy.HibernateProxy; //導入方法依賴的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

示例7: getEntity

import org.hibernate.proxy.HibernateProxy; //導入方法依賴的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

示例8: write

import org.hibernate.proxy.HibernateProxy; //導入方法依賴的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

示例9: reassociateProxy

import org.hibernate.proxy.HibernateProxy; //導入方法依賴的package包/類
@Override
public void reassociateProxy(Object value, Serializable id) throws MappingException {
	if ( value instanceof ElementWrapper ) {
		value = ( (ElementWrapper) value ).getElement();
	}

	if ( value instanceof HibernateProxy ) {
		LOG.debugf( "Setting proxy identifier: %s", id );
		final HibernateProxy proxy = (HibernateProxy) value;
		final LazyInitializer li = proxy.getHibernateLazyInitializer();
		li.setIdentifier( id );
		reassociateProxy( li, proxy );
	}
}
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:15,代碼來源:StatefulPersistenceContext.java

示例10: getClass

import org.hibernate.proxy.HibernateProxy; //導入方法依賴的package包/類
/**
 * Hibernate makes {@link Class#getClass()} diffficult ...
 * @param example The class that we want to call {@link Class#getClass()} on
 * @return The type of the given object
 */
public Class getClass(Object example)
{
    if (example instanceof HibernateProxy)
    {
        HibernateProxy proxy = (HibernateProxy) example;
        LazyInitializer initializer = proxy.getHibernateLazyInitializer();
        SessionImplementor implementor = initializer.getSession();

        if (initializer.isUninitialized())
        {
            try
            {
                // getImplementation is going to want to talk to a session
                if (implementor.isClosed())
                {
                    // Give up and return example.getClass();
                    return example.getClass();
                }
            }
            catch (NoSuchMethodError ex)
            {
                // We must be using Hibernate 3.0/3.1 which doesn't have
                // this method
            }
        }

        return initializer.getImplementation().getClass();
    }
    else
    {
        return example.getClass();
    }
}
 
開發者ID:parabuild-ci,項目名稱:parabuild-ci,代碼行數:39,代碼來源:H3BeanConverter.java

示例11: getClass

import org.hibernate.proxy.HibernateProxy; //導入方法依賴的package包/類
/**
 * Hibernate makes {@link Class#getClass()} difficult ...
 * @param example The class that we want to call {@link Class#getClass()} on
 * @return The type of the given object
 */
public Class<?> getClass(Object example)
{
    if (example instanceof HibernateProxy)
    {
        HibernateProxy proxy = (HibernateProxy) example;
        LazyInitializer initializer = proxy.getHibernateLazyInitializer();
        SessionImplementor implementor = initializer.getSession();

        if (initializer.isUninitialized())
        {
            try
            {
                // getImplementation is going to want to talk to a session
                if (implementor.isClosed())
                {
                    // Give up and return example.getClass();
                    return example.getClass();
                }
            }
            catch (NoSuchMethodError ex)
            {
                // We must be using Hibernate 3.0/3.1 which doesn't have
                // this method
            }
        }

        return initializer.getImplementation().getClass();
    }
    else
    {
        return example.getClass();
    }
}
 
開發者ID:directwebremoting,項目名稱:dwr,代碼行數:39,代碼來源:H3BeanConverter.java

示例12: reassociateProxy

import org.hibernate.proxy.HibernateProxy; //導入方法依賴的package包/類
/**
 * If a deleted entity instance is re-saved, and it has a proxy, we need to
 * reset the identifier of the proxy 
 */
public void reassociateProxy(Object value, Serializable id) throws MappingException {
	if ( value instanceof ElementWrapper ) {
		value = ( (ElementWrapper) value ).getElement();
	}
	
	if ( value instanceof HibernateProxy ) {
		if ( log.isDebugEnabled() ) log.debug("setting proxy identifier: " + id);
		HibernateProxy proxy = (HibernateProxy) value;
		LazyInitializer li = proxy.getHibernateLazyInitializer();
		li.setIdentifier(id);
		reassociateProxy(li, proxy);
	}
}
 
開發者ID:cacheonix,項目名稱:cacheonix-core,代碼行數:18,代碼來源:StatefulPersistenceContext.java

示例13: getIdentifier

import org.hibernate.proxy.HibernateProxy; //導入方法依賴的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

示例14: findProxied

import org.hibernate.proxy.HibernateProxy; //導入方法依賴的package包/類
/**
 * Helper method for finding value being proxied, if it is available
 * or if it is to be forced to be loaded.
 */
protected Object findProxied(HibernateProxy proxy)
{
	LazyInitializer init = proxy.getHibernateLazyInitializer();
	if (!_forceLazyLoading && init.isUninitialized()) {
		return null;
	}
	return init.getImplementation();
}
 
開發者ID:RBGKew,項目名稱:eMonocot,代碼行數:13,代碼來源:HibernateProxySerializer.java

示例15: deproxy

import org.hibernate.proxy.HibernateProxy; //導入方法依賴的package包/類
/**
 * <p>Ensure a domain object is an actual persisted object and not a Hibernate proxy object by getting its real implementation.
 *
 * <p>This is primarily useful when retrieving a lazy loaded object that has been subclassed and you have the intention of casting it.
 *
 * @param t the domain object to deproxy
 * @return the actual persisted object or the passed in object if it is not a Hibernate proxy
 */
public static <T> T deproxy(T t) {
    if (t instanceof HibernateProxy) {
        HibernateProxy proxy = (HibernateProxy)t;
        LazyInitializer lazyInitializer = proxy.getHibernateLazyInitializer();
        return (T)lazyInitializer.getImplementation();
    }
    return t;
}
 
開發者ID:takbani,項目名稱:blcdemo,代碼行數:17,代碼來源:HibernateUtils.java


注:本文中的org.hibernate.proxy.HibernateProxy.getHibernateLazyInitializer方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。