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


Java ScrollableResults类代码示例

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


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

示例1: executeDataMigration

import org.hibernate.ScrollableResults; //导入依赖的package包/类
@Override
protected void executeDataMigration(HibernateMigrationHelper helper, MigrationResult result, Session session)
{
	session.createQuery("UPDATE BaseEntity SET disabled = false").executeUpdate();
	result.incrementStatus();

	ScrollableResults scroll = session
		.createQuery(
			"FROM BaseEntity be LEFT JOIN be.attributes att WHERE att.key = :archived AND att.value = :true")
		.setParameter("archived", KEY_ARCHIVED).setParameter("true", "true").scroll();
	while( scroll.next() )
	{
		FakeBaseEntity be = (FakeBaseEntity) scroll.get(0);
		be.disabled = true;
		session.save(be);
		session.flush();
		session.clear();
		result.incrementStatus();
	}
}
 
开发者ID:equella,项目名称:Equella,代码行数:21,代码来源:EntityDisabledFieldMigration.java

示例2: runStatelessHql

import org.hibernate.ScrollableResults; //导入依赖的package包/类
private static void runStatelessHql() throws Exception {
  Stopwatch watch = Stopwatch.createStarted();
  StatelessSession statelessSession = sessionFactory.openStatelessSession();
  try {
    statelessSession.getTransaction().begin();
    Query query = statelessSession
        .createQuery(
            " SELECT d.id, d.firstName, d.lastName, c.id, c.make " + " FROM Driver d "
                + " LEFT JOIN d.cars c WHERE index(c) LIKE 'Good'").setFetchSize(0).setReadOnly(true);

    ScrollableResults scroll = query.scroll(ScrollMode.FORWARD_ONLY);
    while (scroll.next()) {
      LOG.info("Entry " + scroll.get(0));
    }
    statelessSession.getTransaction().commit();
  } catch (Exception ex) {
    statelessSession.getTransaction().rollback();
    throw ex;
  } finally {
    statelessSession.close();
  }
  LOG.info("StatelessHql:=" + watch.toString());
}
 
开发者ID:AndreasKl,项目名称:java-classic-playground,代码行数:24,代码来源:Program.java

示例3: executeDataMigration

import org.hibernate.ScrollableResults; //导入依赖的package包/类
@Override
protected void executeDataMigration(HibernateMigrationHelper helper, MigrationResult result, Session session)
	throws Exception
{
	ScrollableResults results = session.createQuery(
		"FROM MimeEntryAttributes WHERE element LIKE '%.gif' AND mapkey = 'PluginIconPath' ").scroll();

	while( results.next() )
	{
		Object[] resultEntry = results.get();
		FakeMimeEntryAttributes fmeAttr = (FakeMimeEntryAttributes) resultEntry[0];
		fmeAttr.element = fmeAttr.element.replaceAll(".gif", ".png");

		session.save(fmeAttr);
		session.flush();
		session.clear();
	}
}
 
开发者ID:equella,项目名称:Equella,代码行数:19,代码来源:UpdateDefaultMimeTypeIcons.java

示例4: getIterator

import org.hibernate.ScrollableResults; //导入依赖的package包/类
@Override
public Iterator<QtiAssessmentResult> getIterator()
{
	final ScrollableResults cinnamonScroll = (ScrollableResults) getHibernateTemplate()
		.execute(new HibernateCallback()
		{
			@Override
			public Object doInHibernate(Session session) throws HibernateException, SQLException
			{
				final Query query = getAllQuery(session);
				query.setReadOnly(true);
				return query.scroll(ScrollMode.FORWARD_ONLY);
			}
		});
	return new ScrollableResultsIterator<QtiAssessmentResult>(cinnamonScroll);
}
 
开发者ID:equella,项目名称:Equella,代码行数:17,代码来源:QtiAssessmentResultDaoImpl.java

示例5: getIterator

import org.hibernate.ScrollableResults; //导入依赖的package包/类
@Override
public Iterator<QtiItemResult> getIterator()
{
	final ScrollableResults cinnamonScroll = (ScrollableResults) getHibernateTemplate()
		.execute(new HibernateCallback()
		{
			@Override
			public Object doInHibernate(Session session) throws HibernateException, SQLException
			{
				final Query query = getAllQuery(session);
				query.setReadOnly(true);
				return query.scroll(ScrollMode.FORWARD_ONLY);
			}
		});
	return new ScrollableResultsIterator<QtiItemResult>(cinnamonScroll);
}
 
开发者ID:equella,项目名称:Equella,代码行数:17,代码来源:QtiItemResultDaoImpl.java

示例6: getIterator

import org.hibernate.ScrollableResults; //导入依赖的package包/类
@Override
public Iterator<QtiAssessmentItem> getIterator()
{
	final ScrollableResults cinnamonScroll = (ScrollableResults) getHibernateTemplate()
		.execute(new HibernateCallback()
		{
			@Override
			public Object doInHibernate(Session session) throws HibernateException, SQLException
			{
				final Query query = session.createQuery("FROM QtiAssessmentItem WHERE institution = :institution");
				query.setParameter("institution", CurrentInstitution.get());
				query.setReadOnly(true);
				return query.scroll(ScrollMode.FORWARD_ONLY);
			}
		});
	return new ScrollableResultsIterator<QtiAssessmentItem>(cinnamonScroll);
}
 
开发者ID:equella,项目名称:Equella,代码行数:18,代码来源:QtiAssessmentItemDaoImpl.java

示例7: executeDataMigration

import org.hibernate.ScrollableResults; //导入依赖的package包/类
@Override
protected void executeDataMigration(HibernateMigrationHelper helper, MigrationResult result, Session session)
{
	ScrollableResults scroll = session.createQuery(QUERY).scroll();
	while( scroll.next() )
	{
		FakeWorkflowItemStatus item = (FakeWorkflowItemStatus) scroll.get(0);
		if( item.dateDue != null )
		{
			item.started = new Date(item.dateDue.getTime() - TimeUnit.DAYS.toMillis(item.wnode.escalationdays));
		}
		else
		{
			item.started = new Date();
		}
		session.save(item);
		session.flush();
		session.clear();
		result.incrementStatus();
	}
}
 
开发者ID:equella,项目名称:Equella,代码行数:22,代码来源:AddTaskStartDate.java

示例8: executeDataMigration

import org.hibernate.ScrollableResults; //导入依赖的package包/类
@Override
protected void executeDataMigration(HibernateMigrationHelper helper, MigrationResult result, Session session)
{
	Query query = session
		.createQuery("select i.id, i.moderation.id from Item i where moderating = true or status = 'rejected'");
	ScrollableResults results = query.scroll();
	while( results.next() )
	{
		Query upQuery = session
			.createQuery("update ModerationStatus m set lastAction = "
				+ "(select max(h.date) from Item i join i.history h where i.id = ? and h.type in ('approved','rejected', 'comment') group by i.id) "
				+ "where m.id = ?");
		upQuery.setParameter(0, results.get(0));
		upQuery.setParameter(1, results.get(1));
		upQuery.executeUpdate();
	}
}
 
开发者ID:equella,项目名称:Equella,代码行数:18,代码来源:AddLastActionDate.java

示例9: executeDataMigration

import org.hibernate.ScrollableResults; //导入依赖的package包/类
@Override
protected void executeDataMigration(HibernateMigrationHelper helper, MigrationResult result, Session session)
{
	ScrollableResults scroll = session.createQuery("from Notification").scroll();
	while( scroll.next() )
	{
		FakeNotification note = (FakeNotification) scroll.get(0);
		if( note.reason.equals("review") )
		{
			session.delete(note);
		}
		else
		{
			note.itemidOnly = note.itemid;
			note.processed = true;
			note.batched = false;
			session.save(note);
		}
		session.flush();
		session.clear();
		result.incrementStatus();
	}
}
 
开发者ID:equella,项目名称:Equella,代码行数:24,代码来源:MigrateNotifications2.java

示例10: executeDataMigration

import org.hibernate.ScrollableResults; //导入依赖的package包/类
@Override
protected void executeDataMigration(HibernateMigrationHelper helper, MigrationResult result, Session session)
{
	// Find dupes and kill them (keep the latest one)
	final ScrollableResults dupes = session.createQuery(getDupesFrom() + " ORDER BY n.date DESC").scroll(
		ScrollMode.FORWARD_ONLY);
	final Set<String> visited = Sets.newHashSet();
	while( dupes.next() )
	{
		final FakeNotification dupe = (FakeNotification) dupes.get(0);
		final String key = dupe.itemid + dupe.reason + dupe.userTo + dupe.institution.id;
		// Ignore the most recent notification, we'll keep this one
		if( !visited.contains(key) )
		{
			visited.add(key);
		}
		else
		{
			session.delete(dupe);
			session.flush();
			session.clear();
		}
		result.incrementStatus();
	}
}
 
开发者ID:equella,项目名称:Equella,代码行数:26,代码来源:ConstraintToAvoidDuplicateNotificationsMigration.java

示例11: performScroll

import org.hibernate.ScrollableResults; //导入依赖的package包/类
/**
 * Coordinates the efforts to perform a scroll across all the included query translators.
 *
 * @param queryParameters The query parameters
 * @param session The session
 *
 * @return The query result iterator
 *
 * @throws HibernateException Indicates a problem performing the query
 */
public ScrollableResults performScroll(
		QueryParameters queryParameters,
		SessionImplementor session) throws HibernateException {
	if ( TRACE_ENABLED ) {
		LOG.tracev( "Iterate: {0}", getSourceQuery() );
		queryParameters.traceParameters( session.getFactory() );
	}
	if ( translators.length != 1 ) {
		throw new QueryException( "implicit polymorphism not supported for scroll() queries" );
	}
	if ( queryParameters.getRowSelection().definesLimits() && translators[0].containsCollectionFetches() ) {
		throw new QueryException( "firstResult/maxResults not supported in conjunction with scroll() of a query containing collection fetches" );
	}

	return translators[0].scroll( queryParameters, session );
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:27,代码来源:HQLQueryPlan.java

示例12: scroll

import org.hibernate.ScrollableResults; //导入依赖的package包/类
@Override
public ScrollableResults scroll(Criteria criteria, ScrollMode scrollMode) {
	// TODO: Is this guaranteed to always be CriteriaImpl?
	CriteriaImpl criteriaImpl = (CriteriaImpl) criteria;
	
	errorIfClosed();
	checkTransactionSynchStatus();
	String entityName = criteriaImpl.getEntityOrClassName();
	CriteriaLoader loader = new CriteriaLoader(
			getOuterJoinLoadable(entityName),
			factory,
			criteriaImpl,
			entityName,
			getLoadQueryInfluencers()
	);
	autoFlushIfRequired( loader.getQuerySpaces() );
	dontFlushFromFind++;
	try {
		return loader.scroll(this, scrollMode);
	}
	finally {
		delayedAfterCompletion();
		dontFlushFromFind--;
	}
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:26,代码来源:SessionImpl.java

示例13: scrollCustomQuery

import org.hibernate.ScrollableResults; //导入依赖的package包/类
@Override
public ScrollableResults scrollCustomQuery(CustomQuery customQuery, QueryParameters queryParameters)
throws HibernateException {
	errorIfClosed();
	checkTransactionSynchStatus();

	if ( LOG.isTraceEnabled() ) {
		LOG.tracev( "Scroll SQL query: {0}", customQuery.getSQL() );
	}

	CustomLoader loader = new CustomLoader( customQuery, getFactory() );

	autoFlushIfRequired( loader.getQuerySpaces() );

	dontFlushFromFind++; //stops flush being called multiple times if this method is recursively called
	try {
		return loader.scroll(queryParameters, this);
	}
	finally {
		delayedAfterCompletion();
		dontFlushFromFind--;
	}
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:24,代码来源:SessionImpl.java

示例14: scroll

import org.hibernate.ScrollableResults; //导入依赖的package包/类
public ScrollableResults scroll(ScrollMode scrollMode) throws HibernateException {
	verifyParameters();
	before();

	Map namedParams = getNamedParams();
	NativeSQLQuerySpecification spec = generateQuerySpecification( namedParams );

	QueryParameters qp = getQueryParameters( namedParams );
	qp.setScrollMode( scrollMode );

	try {
		return getSession().scroll( spec, qp );
	}
	finally {
		after();
	}
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:18,代码来源:SQLQueryImpl.java

示例15: scroll

import org.hibernate.ScrollableResults; //导入依赖的package包/类
@Override
public ScrollableResults scroll(Criteria criteria, ScrollMode scrollMode) {
	// TODO: Is this guaranteed to always be CriteriaImpl?
	CriteriaImpl criteriaImpl = (CriteriaImpl) criteria;
	
	errorIfClosed();
	String entityName = criteriaImpl.getEntityOrClassName();
	CriteriaLoader loader = new CriteriaLoader(
			getOuterJoinLoadable( entityName ),
	        factory,
	        criteriaImpl,
	        entityName,
	        getLoadQueryInfluencers()
	);
	return loader.scroll(this, scrollMode);
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:17,代码来源:StatelessSessionImpl.java


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