@SuppressWarnings("rawtypes") public QueryImpl(PersistenceManagerImpl pm, Extent ext, String filter) { this(pm); this.ext = ext; setClass( this.ext.getCandidateClass() ); this.filter = filter; this.subClasses = ext.hasSubclasses(); }
@Override public Iterator<E> iterator() { return ext.iterator(); }
public void closeAll() { ext.closeAll(); } }
assertEquals(pm, ext.getPersistenceManager()); assertEquals(TestClass.class, ext.getCandidateClass()); assertTrue(ext.hasSubclasses()); assertFalse( ext.iterator().hasNext() ); assertFalse(ext.hasSubclasses()); assertFalse( ext.iterator().hasNext() ); assertTrue(ext.hasSubclasses()); pm.setIgnoreCache(false); ext = pm.getExtent(TestClass.class); assertTrue( ext.iterator().hasNext() ); ext.closeAll(); assertFalse( ext.iterator().hasNext() ); ext.iterator().next(); fail(); } catch (NoSuchElementException e) { pm.currentTransaction().begin(); ext = pm.getExtent(TestClass.class); Iterator<?> iter = ext.iterator(); assertTrue( iter.hasNext() ); assertEquals(tc, iter.next()); iter = ext.iterator(); assertTrue( iter.hasNext() );
@Override public void run() { Extent<TestSuper> ext = pm.getExtent(TestSuper.class); Iterator<TestSuper> iter = ext.iterator(); while (iter.hasNext() && n < N/2) { pm.deletePersistent(iter.next()); n++; if (n % COMMIT_INTERVAL == 0) { pm.currentTransaction().commit(); pm.currentTransaction().begin(); ext = pm.getExtent(TestSuper.class); iter = ext.iterator(); } } ext.closeAll(); } });
@SuppressWarnings("rawtypes") @Override public void setCandidates(Extent pcs) { checkUnmodifiable(); this.ext = pcs; if (pcs.getCandidateClass() != candCls) { setClass( pcs.getCandidateClass() ); resetQuery(); } }
assertEquals(pm, ext.getPersistenceManager()); assertFalse( ext.iterator().hasNext() ); Iterator<TestClass> iter = ext.iterator(); assertEquals(pm, ext.getPersistenceManager()); assertTrue( iter.hasNext() ); TestClass tc2 = iter.next();
/** * Accessor for the fetch plan * @return The fetch plan */ public FetchPlan getFetchPlan() { return extent.getFetchPlan(); }
private void deleteAllBatched(PersistenceManager pm, Class<?> clazz) { int batchSize = 10000; int commitctr = 0; Extent<?> extent = pm.getExtent(clazz,false); Iterator<?> it = extent.iterator(); while(it.hasNext()){ pm.deletePersistent(it.next()); if ( batchSize > 0 && ++commitctr >= batchSize){ commitctr = 0; pm.currentTransaction().commit(); pm.currentTransaction().begin(); } } extent.closeAll(); }
/** * Construct a query instance with the candidate Extent specified; the * candidate class is taken from the Extent. * @param cln The extent to query * @return The query */ public synchronized Query newQuery(Extent cln) { Query query = newQuery(); query.setClass(cln.getCandidateClass()); query.setCandidates(cln); return query; }
((Extent)candidates).getFetchPlan().setGroups(fetchPlan.getGroups());
@Test public void testBarcelonaDelete(){ PersistenceManager pm = TestTools.openPM(); pm.currentTransaction().begin(); Extent<TC4> extent = pm.getExtent(TC4.class, false); Iterator<TC4> it = extent.iterator(); while(it.hasNext()){ pm.deletePersistent(it.next()); //addToCheckSum(5); } extent.closeAll(); pm.currentTransaction().commit(); TestTools.closePM(); }
@Programmatic @Override public void deleteAll(final Class<?>... pcClasses) { for (final Class<?> pcClass : pcClasses) { final Extent<?> extent = getJdoPersistenceManager().getExtent(pcClass); final List<Object> instances = Lists.newArrayList(extent.iterator()); // temporarily disable concurrency checking while this method is performed try { ConcurrencyChecking.executeWithConcurrencyCheckingDisabled(new Callable<Void>() { @Override public Void call() { getJdoPersistenceManager().deletePersistentAll(instances); return null; } }); } catch (final Exception ex) { throw new FatalException(ex); } } }
/** * Set the candidate Extent to query. * * @param pcs the Candidate Extent. * @see javax.jdo.Query#setCandidates(javax.jdo.Extent) */ public void setCandidates(Extent pcs) { discardCompiled(); assertIsModifiable(); if (pcs == null) { JPOXLogger.JDO_QUERY.warn(LOCALISER.msg("Candidates.ExtentCantBeNull")); return; } if (!(pcs instanceof Queryable)) { throw new JDOUnsupportedOptionException(LOCALISER.msg("JDOQL.ExtentNotQueryableError",pcs.getClass().getName())); } setSubclasses(pcs.hasSubclasses()); setClass(pcs.getCandidateClass()); candidateExtent = pcs; candidateCollection = null; // We have an Extent, so remove any collection }
/** * Construct a query instance with the candidate Extent specified; the * candidate class is taken from the Extent. * @param cln The extent to query * @return The query * @param <T> Candidate type for the query */ public <T> Query<T> newQuery(Extent<T> cln) { Query query = newQuery(); query.setClass(cln.getCandidateClass()); query.setCandidates(cln); return query; }
System.out.println("Person found: " + p.getName()); ext.closeAll();
ext2 = ext.iterator(); } else {
checkUnmodifiable(); ext = new CollectionExtent(pcs, pm, ignoreCache); if (ext.getCandidateClass() != candCls) { setClass(ext.getCandidateClass()); resetQuery();
ext3.closeAll();