本文整理汇总了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();
}
}
示例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");
}
}
示例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;
}
}
}
示例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;
}
}
}