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


Java ScrollableResults.get方法代码示例

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


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

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

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

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

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

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

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

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

示例10: getNthElement

import org.hibernate.ScrollableResults; //导入方法依赖的package包/类
/**
 * @param query
 *            The query.
 * @param n
 *            The n'th element.
 * @param logPerformance
 *            True, if the performance should be logged.
 * @param class1
 * @param <T>
 *            Return type of this method.
 * @return The n'th element or null.
 */
private <T> T getNthElement(org.hibernate.Query query, int n, boolean logPerformance) {
    StopWatch stopWatch = new StopWatch();
    if (logPerformance) {
        stopWatch.start();
    }
    query.setMaxResults(n);
    ScrollableResults scrollableResults = query.scroll(ScrollMode.SCROLL_INSENSITIVE);

    stopStopWatches(logPerformance, stopWatch, "QueryHelper#query.scroll");
    resetAndStartStopWatch(logPerformance, stopWatch);
    if (scrollableResults.last()) {
        stopStopWatches(logPerformance, stopWatch, "QueryHelper#scrollableResults.setRowNumber"
                + n);
        resetAndStartStopWatch(logPerformance, stopWatch);
        return (T) scrollableResults.get(0);
    }
    return null;
}
 
开发者ID:Communote,项目名称:communote-server,代码行数:31,代码来源:QueryHelperDaoImpl.java

示例11: testScrollCriteria

import org.hibernate.ScrollableResults; //导入方法依赖的package包/类
public void testScrollCriteria() {
	Session session = openSession();
	Transaction t = session.beginTransaction();

	Course course = new Course();
	course.setCourseCode("HIB");
	course.setDescription("Hibernate Training");
	session.persist(course);
	session.flush();
	session.clear();
	ScrollableResults sr = session.createCriteria(Course.class).scroll();
	assertTrue( sr.next() );
	course = (Course) sr.get(0);
	assertNotNull(course);
	sr.close();
	session.delete(course);
	
	t.commit();
	session.close();
	
}
 
开发者ID:cacheonix,项目名称:cacheonix-core,代码行数:22,代码来源:CriteriaQueryTest.java

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

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

示例14: loadProbes

import org.hibernate.ScrollableResults; //导入方法依赖的package包/类
private int loadProbes(ArrayDesignDetails details, Map<String, LogicalProbe> logicalProbes,
        ScrollableResults results) throws IOException {
    int count = 0;
    results.beforeFirst();
    String lastSeqId = null;
    while (results.next()) {
        final Object[] values = results.get();
        final Map<String, Object> vals = new HashMap<String, Object>();
        vals.put(PROBE_ID, values[0]);
        vals.put(SEQ_ID, values[1]);
        vals.put(CONTAINER2, values[2]);
        vals.put(X, values[3]);
        vals.put(Y, values[4]);

        if (lastSeqId != null && !vals.get(SEQ_ID).equals(lastSeqId)) {
            logicalProbes.clear();
            flushAndClearSession();
        }
        lastSeqId = (String) vals.get(SEQ_ID);

        final PhysicalProbe p = createPhysicalProbe(details, vals, logicalProbes);
        getArrayDao().save(p);
        ++count;
    }
    return count;
}
 
开发者ID:NCIP,项目名称:caarray,代码行数:27,代码来源:NdfHandler.java

示例15: geraRelatorioHibernateCursor

import org.hibernate.ScrollableResults; //导入方法依赖的package包/类
@Path("/hibernate-cursor")
public void geraRelatorioHibernateCursor() throws IOException{
	long antes = System.currentTimeMillis();
	ScrollableResults results = sessionFactory.openStatelessSession().createCriteria(Transacao.class).setMaxResults(QTD_REGISTROS).scroll();
	System.out.printf("Pesquisa feita em %dms%n", System.currentTimeMillis()-antes);
	PrintWriter writer = response.getWriter();
	SimpleDateFormat dateFormat = new SimpleDateFormat("dd/MM/yyyy");
	int i=0;
	while(results.next()){
		if(i++%20000==0){
			System.out.println(i);
		}
		Transacao t = (Transacao) results.get()[0];
		writer.write(t.toFile(dateFormat)+"\n");
	}
	writer.close();
	result.use(Results.nothing());
	System.out.println(System.currentTimeMillis()-antes+" milisegundos");
}
 
开发者ID:tiarebalbi,项目名称:caelum-fj91-projeto,代码行数:20,代码来源:RelatorioDeTransacoesController.java


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