本文整理汇总了Java中org.hibernate.ScrollableResults类的典型用法代码示例。如果您正苦于以下问题:Java ScrollableResults类的具体用法?Java ScrollableResults怎么用?Java ScrollableResults使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ScrollableResults类属于org.hibernate包,在下文中一共展示了ScrollableResults类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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
示例16: 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
示例17: 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
示例18: getPaymentsWithCredit
import org.hibernate.ScrollableResults; //导入依赖的package包/类
/**
* Get all the payment details with available credit
*/
public static ScrollableResults getPaymentsWithCredit(String businessPartnerId, String currencyId) {
StringBuilder hql = new StringBuilder();
hql.append(" SELECT t1." + FIN_Payment.PROPERTY_ID);
hql.append(" FROM " + FIN_Payment.ENTITY_NAME + " as t1");
hql.append(" WHERE t1." + FIN_Payment.PROPERTY_BUSINESSPARTNER + ".id = :businessPartnerId");
hql.append(" AND t1." + FIN_Payment.PROPERTY_CURRENCY + ".id = :currencyId");
hql.append(" AND t1." + FIN_Payment.PROPERTY_GENERATEDCREDIT + " <> 0");
hql.append(" AND t1." + FIN_Payment.PROPERTY_GENERATEDCREDIT + " <> t1."
+ FIN_Payment.PROPERTY_USEDCREDIT);
final Query query = OBDal.getInstance().getSession().createQuery(hql.toString());
query.setParameter("businessPartnerId", businessPartnerId);
query.setParameter("currencyId", currencyId);
ScrollableResults scroll = query.scroll(ScrollMode.SCROLL_SENSITIVE);
return scroll;
}
开发者ID:mauyr,项目名称:openbravo-brazil,代码行数:19,代码来源:FinancialUtils.java
示例19: 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
示例20: 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
注:本文中的org.hibernate.ScrollableResults类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论