本文整理汇总了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();
}
}
示例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();
}
}
示例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();
}
}
示例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();
}
}
示例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();
}
}
示例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();
}
}
}
示例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();
}
}
示例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();
}
}
示例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();
}
示例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;
}
示例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();
}
示例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;
}
示例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");
}