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


Java SessionImpl类代码示例

本文整理汇总了Java中org.hibernate.impl.SessionImpl的典型用法代码示例。如果您正苦于以下问题:Java SessionImpl类的具体用法?Java SessionImpl怎么用?Java SessionImpl使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: getVotes

import org.hibernate.impl.SessionImpl; //导入依赖的package包/类
@Override
public List<VoteEntity> getVotes(Filter queryVote) {
    Session currentSession = sessionFactory.getCurrentSession();
    Criteria criteria = currentSession.createCriteria(VoteEntity.class);
    if(!isEmpty(queryVote)){

    if (queryVote.getTag() != null) {
        criteria.add(Expression.eq("tag", queryVote.getTag()));
    }
    if (queryVote.getMood() != null) {
        criteria.add(Expression.eq("mood", queryVote.getMood()));
    }
    if (queryVote.getTime() != null) {
        Interval interval = Utils.getIntervalFormTimeEnum(queryVote.getTime());
        criteria.add(Restrictions.between("time", interval.getStartMillis(), interval.getEndMillis()));
    }

    return criteria.list();
    }else{
        return ((SessionImpl)currentSession).find("from VoteEntity");
    }
}
 
开发者ID:mihai-chezan,项目名称:xpress,代码行数:23,代码来源:DBRepository.java

示例2: initializeCollection

import org.hibernate.impl.SessionImpl; //导入依赖的package包/类
/**
 * Initialize Collection (detached or not)
 * @param collection collection to initialize
 * @param session Session to use for initialization
 */
public static void initializeCollection(Collection collection, Session session) {
	if (collection instanceof AbstractPersistentCollection) {
		AbstractPersistentCollection ps = (AbstractPersistentCollection) collection;
		log.debug("Initalizing PersistentCollection of role: " + ps.getRole());	
		if (!ps.wasInitialized()) {
			SessionImpl source = (SessionImpl) session;
			PersistenceContext context = source.getPersistenceContext();
			CollectionPersister cp = source.getFactory().getCollectionPersister(ps.getRole());
			
			if (context.getCollectionEntry(ps) == null) {  // detached
				context.addUninitializedDetachedCollection(cp, ps);
			}
			
			ps.setCurrentSession(context.getSession());
			Hibernate.initialize(collection);
		}
	}
}
 
开发者ID:chelu,项目名称:jdal,代码行数:24,代码来源:HibernateUtils.java

示例3: testReplicate

import org.hibernate.impl.SessionImpl; //导入依赖的package包/类
public void testReplicate() throws Exception {
	Session s = openSession();
	Container baz = new Container();
	Contained f = new Contained();
	List list = new ArrayList();
	list.add(baz);
	f.setBag(list);
	List list2 = new ArrayList();
	list2.add(f);
	baz.setBag(list2);
	s.save(f);
	s.save(baz);
	s.flush();
	s.connection().commit();
	s.close();
	s = openSession();
	s.replicate(baz, ReplicationMode.OVERWRITE);
	
	// HHH-2378
	SessionImpl x = (SessionImpl)s;
	EntityEntry entry = x.getPersistenceContext().getEntry( baz );
	assertNull(entry.getVersion());
	
	s.flush();
	s.connection().commit();
	s.close();
	s = openSession();
	s.replicate(baz, ReplicationMode.IGNORE);
	s.flush();
	s.connection().commit();
	s.close();
	s = openSession();
	s.delete(baz);
	s.delete(f);
	s.flush();
	s.connection().commit();
	s.close();
}
 
开发者ID:cacheonix,项目名称:cacheonix-core,代码行数:39,代码来源:ParentChildTest.java

示例4: testBorrowedConnections

import org.hibernate.impl.SessionImpl; //导入依赖的package包/类
public void testBorrowedConnections() throws Throwable {
	prepare();
	Session s = getSessionUnderTest();

	Connection conn = s.connection();
	assertTrue( ( ( SessionImpl ) s ).getJDBCContext().getConnectionManager().hasBorrowedConnection() );
	conn.close();
	assertFalse( ( ( SessionImpl ) s ).getJDBCContext().getConnectionManager().hasBorrowedConnection() );

	release( s );
	done();
}
 
开发者ID:cacheonix,项目名称:cacheonix-core,代码行数:13,代码来源:AggressiveReleaseTest.java

示例5: isSameConnectionForEntireSession

import org.hibernate.impl.SessionImpl; //导入依赖的package包/类
/**
 * Return whether the given Hibernate Session will always hold the same
 * JDBC Connection. This is used to check whether the transaction manager
 * can safely prepare and clean up the JDBC Connection used for a transaction.
 * <p>Default implementation checks the Session's connection release mode
 * to be "on_close". Unfortunately, this requires casting to SessionImpl,
 * as of Hibernate 3.1. If that cast doesn't work, we'll simply assume
 * we're safe and return {@code true}.
 * @param session the Hibernate Session to check
 * @see org.hibernate.impl.SessionImpl#getConnectionReleaseMode()
 * @see org.hibernate.ConnectionReleaseMode#ON_CLOSE
 */
protected boolean isSameConnectionForEntireSession(Session session) {
	if (!(session instanceof SessionImpl)) {
		// The best we can do is to assume we're safe.
		return true;
	}
	ConnectionReleaseMode releaseMode = ((SessionImpl) session).getConnectionReleaseMode();
	return ConnectionReleaseMode.ON_CLOSE.equals(releaseMode);
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:21,代码来源:HibernateTransactionManager.java

示例6: getDatabaseConnection

import org.hibernate.impl.SessionImpl; //导入依赖的package包/类
/**
 * Get the underlying database connection from the JPA Entity Manager (DBUnit needs this connection).
 * @return Database Connection
 * @throws Exception
 */
private IDatabaseConnection getDatabaseConnection() throws Exception {
    return new DatabaseConnection(((SessionImpl) (bookManager.getEntityManager().getDelegate())).connection());
}
 
开发者ID:adrianmilne,项目名称:jpa-lucene-spring-demo,代码行数:9,代码来源:BookManagerDBUnitTest.java


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