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


Java ScrollableResults.close方法代码示例

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


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

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

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

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

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

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

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

示例7: getGroupedCount

import org.hibernate.ScrollableResults; //导入方法依赖的package包/类
protected int getGroupedCount(Query countQuery) {
  int nRows = -1;
  ScrollableResults scrollableResults = countQuery.scroll();
  if (scrollableResults.last()) {
    nRows = scrollableResults.getRowNumber();
  }
  scrollableResults.close();
  return nRows + 1;
}
 
开发者ID:mauyr,项目名称:openbravo-brazil,代码行数:10,代码来源:HQLDataSourceService.java

示例8: updateElementValues

import org.hibernate.ScrollableResults; //导入方法依赖的package包/类
private void updateElementValues(Element _element, AcctSchema acctSchema, boolean assetPositive,
    boolean liabilityPositive, boolean ownersEquityPositive, boolean expensePositive,
    boolean revenuePositive) {
  StringBuffer where = new StringBuffer();
  final String ACCOUNTSIGN_CREDIT = "C";
  final String ACCOUNTSIGN_DEBIT = "D";
  final String ACCOUNTTYPE_MEMO = "M";
  Element element = OBDal.getInstance().get(Element.class, _element.getId());
  where.append(ElementValue.PROPERTY_ACCOUNTINGELEMENT + ".id = :element");
  OBQuery<ElementValue> elementValueQry = OBDal.getInstance().createQuery(ElementValue.class,
      where.toString());
  elementValueQry.setFilterOnActive(false);
  elementValueQry.setFilterOnReadableClients(false);
  elementValueQry.setFilterOnReadableOrganization(false);
  elementValueQry.setNamedParameter("element", element.getId());
  elementValueQry.setFetchSize(1000);

  ScrollableResults elementvalues = elementValueQry.scroll(ScrollMode.FORWARD_ONLY);
  try {
    // TODO: Review with Martin to see if flush is permitted in handlers
    // int i = 0;
    while (elementvalues.next()) {
      ElementValue elementValue = (ElementValue) elementvalues.get(0);
      boolean isCredit = getAccountSign(elementValue.getAccountType(), assetPositive,
          liabilityPositive, ownersEquityPositive, expensePositive, revenuePositive);
      if (!ACCOUNTTYPE_MEMO.equals(elementValue.getAccountType())) {
        elementValue.setAccountSign(isCredit ? ACCOUNTSIGN_CREDIT : ACCOUNTSIGN_DEBIT);
      }
      // if ((i % 100) == 0) {
      // OBDal.getInstance().flush();
      // OBDal.getInstance().getSession().clear();
      // element = OBDal.getInstance().get(Element.class, element.getId());
      // }
      // i++;
    }
  } finally {
    elementvalues.close();
  }
}
 
开发者ID:mauyr,项目名称:openbravo-brazil,代码行数:40,代码来源:AcctSchemaEventHandler.java

示例9: fixLegacyCostingCurrency

import org.hibernate.ScrollableResults; //导入方法依赖的package包/类
private void fixLegacyCostingCurrency() {
  StringBuffer where = new StringBuffer();
  where.append(" as c");
  where.append("   join c." + Costing.PROPERTY_CLIENT + " as cl");
  where.append(" where c." + Costing.PROPERTY_CURRENCY + " <> cl." + Client.PROPERTY_CURRENCY);
  final OBQuery<Costing> costQry = OBDal.getInstance().createQuery(Costing.class,
      where.toString());
  costQry.setFilterOnActive(false);
  costQry.setFilterOnReadableClients(false);
  costQry.setFilterOnReadableOrganization(false);
  costQry.setFetchSize(1000);

  final ScrollableResults costs = costQry.scroll(ScrollMode.FORWARD_ONLY);
  int i = 0;
  try {
    while (costs.next()) {
      Costing cost = (Costing) costs.get(0);
      cost.setCurrency(cost.getClient().getCurrency());
      OBDal.getInstance().save(cost);
      if ((i % 100) == 0) {
        OBDal.getInstance().flush();
        OBDal.getInstance().getSession().clear();
      }
      i++;
    }
  } finally {
    costs.close();
  }
}
 
开发者ID:mauyr,项目名称:openbravo-brazil,代码行数:30,代码来源:CostingMigrationProcess.java

示例10: testSerializationFailsOnAfterStatementAggressiveReleaseWithOpenResources

import org.hibernate.ScrollableResults; //导入方法依赖的package包/类
public void testSerializationFailsOnAfterStatementAggressiveReleaseWithOpenResources() throws Throwable {
	prepare();
	Session s = getSessionUnderTest();

	Silly silly = new Silly( "silly" );
	s.save( silly );

	// this should cause the CM to obtain a connection, and then release it
	s.flush();

	// both scroll() and iterate() cause the batcher to hold on
	// to resources, which should make aggresive-release not release
	// the connection (and thus cause serialization to fail)
	ScrollableResults sr = s.createQuery( "from Silly" ).scroll();

	try {
		SerializationHelper.serialize( s );
		fail( "Serialization allowed on connected session; or aggressive release released connection with open resources" );
	}
	catch( IllegalStateException e ) {
		// expected behavior
	}

	// Closing the ScrollableResults does currently force the batcher to
	// aggressively release the connection
	sr.close();
	SerializationHelper.serialize( s );

	s.delete( silly );
	s.flush();

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

示例11: testQueryScrolling

import org.hibernate.ScrollableResults; //导入方法依赖的package包/类
public void testQueryScrolling() throws Throwable {
	prepare();
	Session s = getSessionUnderTest();
	Silly silly = new Silly( "silly" );
	s.save( silly );
	s.flush();

	ScrollableResults sr = s.createQuery( "from Silly" ).scroll();
	assertTrue( sr.next() );
	Silly silly2 = ( Silly ) sr.get( 0 );
	assertEquals( silly, silly2 );
	sr.close();

	sr = s.createQuery( "from Silly" ).scroll();
	ScrollableResults sr2 = s.createQuery( "from Silly where name = 'silly'" ).scroll();

	assertTrue( sr.next() );
	assertEquals( silly, sr.get( 0 ) );
	assertTrue( sr2.next() );
	assertEquals( silly, sr2.get( 0 ) );

	sr.close();
	sr2.close();

	s.delete( silly );
	s.flush();

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

示例12: cacheExistingAttributeIdentities

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

  Logger.getLogger(getClass())
      .info("Loading Attribute Identities for terminology = " + terminology
          + ", name = " + name);

  final Session session =
      getService().getEntityManager().unwrap(Session.class);
  final org.hibernate.Query hQuery = session.createSQLQuery(
      "select id, componentId, componentTerminology, hashCode, terminologyId from attribute_identity "
          + "where terminology = :terminology and name = :name");
  hQuery.setParameter("terminology", terminology);
  hQuery.setParameter("name", name);
  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 componentId = (String) results.get()[1];
    final String componentTerminology = (String) results.get()[2];
    final String hashcode = (String) results.get()[3];
    final String terminologyId = (String) results.get()[4];
    final String identityCode = componentId + componentTerminology + hashcode
        + name + terminology + terminologyId;
    attributeIdentityCache.put(identityCode, id);
  }
  results.close();

  // Add this terminology and name to the cached set.
  attributeIdentityCachedTerms.add(terminology + name);
}
 
开发者ID:WestCoastInformatics,项目名称:UMLS-Terminology-Server,代码行数:33,代码来源:UmlsIdentifierAssignmentHandler.java

示例13: cacheExistingAtomIdentities

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

  Logger.getLogger(getClass())
      .info("Loading Atom Identities for terminology = " + terminology);

  final Session session =
      getService().getEntityManager().unwrap(Session.class);
  final org.hibernate.Query hQuery = session.createSQLQuery(
      "select id, stringClassId, terminologyId, termType, codeId, conceptId, descriptorId from atom_identity "
          + "where terminology = :terminology");
  hQuery.setParameter("terminology", terminology);
  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 stringClassId = (String) results.get()[1];
    final String terminologyId = (String) results.get()[2];
    final String termType = (String) results.get()[3];
    final String codeId = (String) results.get()[4];
    final String conceptId = (String) results.get()[5];
    final String descriptorId = (String) results.get()[6];
    final String identityCode = stringClassId + terminology + terminologyId
        + termType + codeId + conceptId + descriptorId;
    atomIdentityCache.put(identityCode, id);
  }
  results.close();

  // Add this terminology to the cached set.
  atomIdentityCachedTerms.add(terminology);
}
 
开发者ID:WestCoastInformatics,项目名称:UMLS-Terminology-Server,代码行数:33,代码来源:UmlsIdentifierAssignmentHandler.java

示例14: cacheExistingRelationshipIdentities

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

  Logger.getLogger(getClass()).info(
      "Loading Relationship Identities for terminology = " + terminology);

  final Session session =
      getService().getEntityManager().unwrap(Session.class);
  final org.hibernate.Query hQuery = session.createSQLQuery(
      "select id, additionalRelationshipType, fromId, fromTerminology, fromType, "
          + "relationshipType, terminologyId, toId, toTerminology, "
          + "toType from relationship_identity "
          + "where terminology = :terminology");
  hQuery.setParameter("terminology", terminology);
  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 additionalRelationshipType = (String) results.get()[1];
    final String fromId = (String) results.get()[2];
    final String fromTerminology = (String) results.get()[3];
    final String fromType = (String) results.get()[4];
    final String relationshipType = (String) results.get()[5];
    final String terminologyId = (String) results.get()[6];
    final String toId = (String) results.get()[7];
    final String toTerminology = (String) results.get()[8];
    final String toType = (String) results.get()[9];
    final String identityCode = additionalRelationshipType + fromId
        + fromTerminology + fromType + relationshipType + terminology
        + terminologyId + toId + toTerminology + toType;
    relationshipIdentityCache.put(identityCode, id);
  }
  results.close();

  // Add this terminology to the cached set.
  relationshipIdentityCachedTerms.add(terminology);
}
 
开发者ID:WestCoastInformatics,项目名称:UMLS-Terminology-Server,代码行数:39,代码来源:UmlsIdentifierAssignmentHandler.java

示例15: getRowCountOfDCRst

import org.hibernate.ScrollableResults; //导入方法依赖的package包/类
public Integer getRowCountOfDCRst(DetachedCriteria dc) {
	Session session = (Session) this.em.getDelegate();
	boolean needClose = false;
	if (!session.isOpen()) {
		session = session.getSessionFactory().openSession();
		needClose = true;
	}

	ScrollableResults sc = null;
	try {
		Criteria c = dc.getExecutableCriteria(session);
		sc = c.scroll(ScrollMode.FORWARD_ONLY);
		sc.last();
		int count = sc.getRowNumber() + 1;

		return count;
	} finally {
		if (sc != null) {
			sc.close();
			sc = null;
		}

		if (needClose) {
			session.close();
			session = null;
		}

	}
}
 
开发者ID:dynamo2,项目名称:tianma,代码行数:30,代码来源:AbstractBaseDAO.java


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