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


Java SessionImplementor.isOpen方法代码示例

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


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

示例1: getReplacement

import org.hibernate.engine.SessionImplementor; //导入方法依赖的package包/类
private Object getReplacement() {

		final SessionImplementor session = getSession();
		if ( isUninitialized() && session != null && session.isOpen()) {
			final EntityKey key = new EntityKey(
					getIdentifier(),
			        session.getFactory().getEntityPersister( getEntityName() ),
			        session.getEntityMode()
				);
			final Object entity = session.getPersistenceContext().getEntity(key);
			if (entity!=null) setImplementation( entity );
		}

		if ( isUninitialized() ) {
			if (replacement==null) {
				replacement = serializableProxy();
			}
			return replacement;
		}
		else {
			return getTarget();
		}

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

示例2: throwLazyInitializationExceptionIfNotConnected

import org.hibernate.engine.SessionImplementor; //导入方法依赖的package包/类
protected void throwLazyInitializationExceptionIfNotConnected() {
	SessionImplementor session = getSession();
	if ( !(session!=null && session.isOpen() && session.getPersistenceContext().containsCollection(this)) )  {
		throwLazyInitializationException("no session or session was closed");
	}
	if ( !session.isConnected() ) {
           throwLazyInitializationException("session is disconnected");
	}		
}
 
开发者ID:webdsl,项目名称:webdsl,代码行数:10,代码来源:PersistentOwnedSet.java

示例3: getValue

import org.hibernate.engine.SessionImplementor; //导入方法依赖的package包/类
public Object getValue(Object bean) throws MarshallException
{
    if (!(bean instanceof HibernateProxy))
    {
        // This is not a hibernate dynamic proxy, just use it
        return super.getValue(bean);
    }
    else
    {
        // If the property is already initialized, use it
        boolean initialized = Hibernate.isPropertyInitialized(bean, descriptor.getName());
        if (initialized)
        {
            // This might be a lazy-collection so we need to double check
            Object reply = super.getValue(bean);
            initialized = Hibernate.isInitialized(reply);
        }

        if (initialized)
        {
            return super.getValue(bean);
        }
        else
        {
            // If the session bound to the property is live, use it
            HibernateProxy proxy = (HibernateProxy) bean;
            LazyInitializer initializer = proxy.getHibernateLazyInitializer();
            SessionImplementor implementor = initializer.getSession();
            if (implementor.isOpen())
            {
                return super.getValue(bean);
            }

            // So the property needs database access, and the session is closed
            // We'll need to try get another session
            ServletContext context = WebContextFactory.get().getServletContext();
            Session session = H3SessionAjaxFilter.getCurrentSession(context);

            if (session != null)
            {
                session.update(bean);
                return super.getValue(bean);
            }

            return null;
        }
    }
}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:49,代码来源:H3PropertyDescriptorProperty.java

示例4: getValue

import org.hibernate.engine.SessionImplementor; //导入方法依赖的package包/类
@Override
public Object getValue(Object bean) throws ConversionException
{
    if (!(bean instanceof HibernateProxy))
    {
        // This is not a hibernate dynamic proxy, just use it
        return super.getValue(bean);
    }
    else
    {
        // If the property is already initialized, use it
        boolean initialized = Hibernate.isPropertyInitialized(bean, descriptor.getName());
        if (initialized)
        {
            // This might be a lazy-collection so we need to double check
            Object reply = super.getValue(bean);
            initialized = Hibernate.isInitialized(reply);
        }

        if (initialized)
        {
            return super.getValue(bean);
        }
        else
        {
            // If the session bound to the property is live, use it
            HibernateProxy proxy = (HibernateProxy) bean;
            LazyInitializer initializer = proxy.getHibernateLazyInitializer();
            SessionImplementor implementor = initializer.getSession();
            if (implementor.isOpen())
            {
                return super.getValue(bean);
            }

            // So the property needs database access, and the session is closed
            // We'll need to try get another session
            ServletContext context = WebContextFactory.get().getServletContext();
            Session session = H3SessionAjaxFilter.getCurrentSession(context);

            if (session != null)
            {
                session.update(bean);
                return super.getValue(bean);
            }

            return null;
        }
    }
}
 
开发者ID:directwebremoting,项目名称:dwr,代码行数:50,代码来源:H3PropertyDescriptorProperty.java


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