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