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


Java ScrollableResults.next方法代码示例

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


在下文中一共展示了ScrollableResults.next方法的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: 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

示例5: 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

示例6: 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

示例7: 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

示例8: converteerToegangLeveringsautorisaties

import org.hibernate.ScrollableResults; //导入方法依赖的package包/类
void converteerToegangLeveringsautorisaties() {
    final Session session = (Session) entityManager.getDelegate();
    final ScrollableResults scResults = session.createCriteria(ToegangLeveringsAutorisatie.class).scroll(ScrollMode.FORWARD_ONLY);
    while (scResults.next()) {
        final ToegangLeveringsAutorisatie toegang = (ToegangLeveringsAutorisatie) scResults.get(0);
        if (Stelsel.GBA == toegang.getLeveringsautorisatie().getStelsel()) {

            if (toegang.getLeveringsautorisatie().getDatumEinde() != null) {
                LOGGER.warn("ToegangLeveringsAutorisatie met id {} wordt niet geconverteerd, "
                                + "want leveringsautorisatie '{}' met id {} is niet geldig",
                        toegang.getId(),
                        toegang.getLeveringsautorisatie().getNaam(),
                        toegang.getLeveringsautorisatie().getId());
                continue;
            }
            converteerToegangLeveringsAutorisatie(toegang);
            entityManager.flush();
            entityManager.clear();
        }
    }
}
 
开发者ID:MinBZK,项目名称:OperatieBRP,代码行数:22,代码来源:ToegangLeveringsAutorisatieConversie.java

示例9: getRowNumber

import org.hibernate.ScrollableResults; //导入方法依赖的package包/类
/**
 * Computes the row number of a record which has the id which is passed in as a parameter. The
 * rownumber computation takes into account the filter and sorting settings of the the OBQuery
 * object.
 * 
 * @param targetId
 *          the record id
 * @return the row number or -1 if not found
 */
public int getRowNumber(String targetId) {
  String qryStr = createQueryString();
  if (qryStr.toLowerCase().contains(FROM_SPACED)) {
    final int index = qryStr.indexOf(FROM_SPACED) + FROM_SPACED.length();
    qryStr = qryStr.substring(index);
  }
  final Query qry = getSession()
      .createQuery("select " + usedAlias + "id " + FROM_SPACED + qryStr);
  setParameters(qry);

  final ScrollableResults results = qry.scroll(ScrollMode.FORWARD_ONLY);
  try {
    while (results.next()) {
      final String id = results.getString(0);
      if (id.equals(targetId)) {
        return results.getRowNumber();
      }
    }
  } finally {
    results.close();
  }
  return -1;
}
 
开发者ID:mauyr,项目名称:openbravo-brazil,代码行数:33,代码来源:OBQuery.java

示例10: deleteProductCharacteristicValue

import org.hibernate.ScrollableResults; //导入方法依赖的package包/类
private void deleteProductCharacteristicValue(ProductCharacteristic productCharacteristic) {
  ScrollableResults scroll = null;
  try {
    OBCriteria<ProductCharacteristicValue> criteria = OBDal.getInstance().createCriteria(
        ProductCharacteristicValue.class);
    criteria.add(Restrictions.eq(ProductCharacteristicValue.PROPERTY_CHARACTERISTIC,
        productCharacteristic.getCharacteristic()));
    criteria.add(Restrictions.eq(ProductCharacteristicValue.PROPERTY_PRODUCT,
        productCharacteristic.getProduct()));
    scroll = criteria.scroll(ScrollMode.FORWARD_ONLY);
    int i = 0;
    while (scroll.next()) {
      ProductCharacteristicValue productCharacteristicValue = (ProductCharacteristicValue) scroll
          .get(0);
      OBDal.getInstance().remove(productCharacteristicValue);
      i++;
      if (i % 100 == 0) {
        OBDal.getInstance().flush();
        OBDal.getInstance().getSession().clear();
      }
    }
  } finally {
    scroll.close();
  }
}
 
开发者ID:mauyr,项目名称:openbravo-brazil,代码行数:26,代码来源:ProductCharacteristicEventHandler.java

示例11: initializeLines

import org.hibernate.ScrollableResults; //导入方法依赖的package包/类
private void initializeLines(CostAdjustment costAdjustment) {
  // initialize is related transaction adjusted flag to false
  OBCriteria<CostAdjustmentLine> critLines = OBDal.getInstance().createCriteria(
      CostAdjustmentLine.class);
  critLines.add(Restrictions.eq(CostAdjustmentLine.PROPERTY_COSTADJUSTMENT, costAdjustment));
  critLines.add(Restrictions.eq(CostAdjustmentLine.PROPERTY_ISRELATEDTRANSACTIONADJUSTED, true));
  ScrollableResults lines = critLines.scroll(ScrollMode.FORWARD_ONLY);
  long count = 1L;
  try {
    while (lines.next()) {
      CostAdjustmentLine line = (CostAdjustmentLine) lines.get(0);
      line.setRelatedTransactionAdjusted(false);
      OBDal.getInstance().save(line);

      if (count % 1000 == 0) {
        OBDal.getInstance().flush();
        OBDal.getInstance().getSession().clear();
      }
      count++;
    }
    OBDal.getInstance().flush();
    OBDal.getInstance().getSession().clear();
  } finally {
    lines.close();
  }
}
 
开发者ID:mauyr,项目名称:openbravo-brazil,代码行数:27,代码来源:CostAdjustmentProcess.java

示例12: updateInitInventoriesTrxDate

import org.hibernate.ScrollableResults; //导入方法依赖的package包/类
private void updateInitInventoriesTrxDate(Date startingDate, String ruleId) {
  StringBuffer where = new StringBuffer();
  where.append(" as trx");
  where.append("   join trx." + MaterialTransaction.PROPERTY_PHYSICALINVENTORYLINE + " as il");
  where.append(" where il." + InventoryCountLine.PROPERTY_PHYSINVENTORY + ".id IN (");
  where.append("    select cri." + CostingRuleInit.PROPERTY_INITINVENTORY + ".id");
  where.append("    from " + CostingRuleInit.ENTITY_NAME + " as cri");
  where.append("    where cri." + CostingRuleInit.PROPERTY_COSTINGRULE + ".id = :cr");
  where.append("    )");
  OBQuery<MaterialTransaction> trxQry = OBDal.getInstance().createQuery(
      MaterialTransaction.class, where.toString());
  trxQry.setNamedParameter("cr", ruleId);
  trxQry.setFetchSize(1000);
  ScrollableResults trxs = trxQry.scroll(ScrollMode.FORWARD_ONLY);
  int i = 0;
  while (trxs.next()) {
    MaterialTransaction trx = (MaterialTransaction) trxs.get(0);
    trx.setTransactionProcessDate(startingDate);
    OBDal.getInstance().save(trx);
    if ((i % 100) == 0) {
      OBDal.getInstance().flush();
      OBDal.getInstance().getSession().clear();
    }
  }
  trxs.close();
}
 
开发者ID:mauyr,项目名称:openbravo-brazil,代码行数:27,代码来源:CostingRuleProcess.java

示例13: cacheExistingStringClassIdentities

import org.hibernate.ScrollableResults; //导入方法依赖的package包/类
private void cacheExistingStringClassIdentities() throws Exception {

    Logger.getLogger(getClass()).info("Loading String Class Identities");

    final Session session =
        getService().getEntityManager().unwrap(Session.class);
    final org.hibernate.Query hQuery = session
        .createSQLQuery("select id, name, language from string_class_identity");
    hQuery.setReadOnly(true).setFetchSize(100000).setCacheable(false);
    final ScrollableResults results = hQuery.scroll(ScrollMode.FORWARD_ONLY);
    while (results.next()) {

      final Long id = ((BigInteger) results.get()[0]).longValue();
      final String name = (String) results.get()[1];
      final String language = (String) results.get()[2];
      final String identityCode = name + language;
      stringClassIdentityCache.put(identityCode, id);
    }
    results.close();
  }
 
开发者ID:WestCoastInformatics,项目名称:UMLS-Terminology-Server,代码行数:21,代码来源:UmlsIdentifierAssignmentHandler.java

示例14: cacheExistingLexicalClassIdentities

import org.hibernate.ScrollableResults; //导入方法依赖的package包/类
private void cacheExistingLexicalClassIdentities() throws Exception {

    Logger.getLogger(getClass()).info("Loading Lexical Class Identities");

    final Session session =
        getService().getEntityManager().unwrap(Session.class);
    final org.hibernate.Query hQuery = session.createSQLQuery(
        "select id, language, normalizedName from lexical_class_identity");
    hQuery.setReadOnly(true).setFetchSize(100000).setCacheable(false);
    final ScrollableResults results = hQuery.scroll(ScrollMode.FORWARD_ONLY);
    while (results.next()) {

      final Long id = ((BigInteger) results.get()[0]).longValue();
      final String language = (String) results.get()[1];
      final String normalizedName = (String) results.get()[2];
      final String identityCode = language + normalizedName;
      lexicalClassIdentityCache.put(identityCode, id);
    }
    results.close();
  }
 
开发者ID:WestCoastInformatics,项目名称:UMLS-Terminology-Server,代码行数:21,代码来源:UmlsIdentifierAssignmentHandler.java

示例15: doGetAll

import org.hibernate.ScrollableResults; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
@Override
protected <T extends OriannaObject<?>> List<T> doGetAll(final Class<T> type) {
    final Class<? extends OriannaDto> clazz = getDtoClass(type);

    final ScrollableResults result = hibernateGetAll(clazz);
    if(result == null) {
        return Collections.emptyList();
    }

    try {
        final List<T> response = new ArrayList<>();
        while(result.next()) {
            response.add((T)type.getDeclaredConstructors()[0].newInstance(result.get(0)));
        }
        result.close();
        return response;
    }
    catch(InstantiationException | IllegalAccessException | IllegalArgumentException | InvocationTargetException | SecurityException e) {
        throw new OriannaException("Couldn't load data from DB");
    }
}
 
开发者ID:meraki-analytics,项目名称:orianna-hibernate,代码行数:23,代码来源:HibernateDB.java


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