public Object doInJdo(PersistenceManager pm) throws JDOException { pm.refresh(entity); return null; } }, true);
assertEquals(ObjectState.PERSISTENT_DELETED, JDOHelper.getObjectState(tc2)); pm.refresh(tc1); assertEquals(ObjectState.PERSISTENT_DELETED, JDOHelper.getObjectState(tc1));
public void refresh(Object obj) { getPM().refresh(obj); }
String test = "\u0627\u0644\u0633\u0644\u0627\u0645"; PersistenceManager manager = PMF.get().getPersistenceManager(); Category category = new Category(test); manager.makePersistent(category); manager.refresh(category); manager.close();
/** * Forces a reload (refresh in JDO terminology) of the domain object wrapped in the {@link ObjectAdapter}. */ public void refreshRoot(final ObjectAdapter adapter) { final Object domainObject = adapter.getObject(); if (domainObject == null) { // REVIEW: is this possible? throw new PojoRefreshException(adapter.getOid()); } try { persistenceManager.refresh(domainObject); } catch (final RuntimeException e) { throw new PojoRefreshException(adapter.getOid(), e); } // possibly redundant because also called in the post-load event // listener, but (with JPA impl) found it was required if we were ever to // get an eager left-outer-join as the result of a refresh (sounds possible). initializeMapAndCheckConcurrency((Persistable) domainObject); }
pm.refresh(t1); checkCall(ZooInstanceEvent.LOAD, t1); assertTrue(calls.isEmpty());
@Test public void testNonPersistentObject() { Properties props = new ZooJdoProperties(DB_NAME); pmf = JDOHelper.getPersistenceManagerFactory(props); pm = pmf.getPersistenceManager(); pm.currentTransaction().begin(); TestClass tc = new TestClass(); try { pm.deletePersistent(tc); fail(); } catch (JDOUserException e) { //good } pm.refresh(tc); assertEquals(ObjectState.TRANSIENT, JDOHelper.getObjectState(tc)); pm.currentTransaction().commit(); pm.close(); }
for (int i = 0; i < 5; i++) { pm.refresh(tc);
@Test public void testDoubleDelete() { Properties props = new ZooJdoProperties(DB_NAME); pmf = JDOHelper.getPersistenceManagerFactory(props); pm = pmf.getPersistenceManager(); pm.currentTransaction().begin(); TestClass tc = new TestClass(); pm.makePersistent(tc); pm.currentTransaction().commit(); pm.currentTransaction().begin(); pm.deletePersistent(tc); assertEquals(ObjectState.PERSISTENT_DELETED, JDOHelper.getObjectState(tc)); try { pm.deletePersistent(tc); fail(); } catch (JDOUserException e) { //good } assertEquals(ObjectState.PERSISTENT_DELETED, JDOHelper.getObjectState(tc)); pm.refresh(tc); assertEquals(ObjectState.PERSISTENT_DELETED, JDOHelper.getObjectState(tc)); pm.currentTransaction().commit(); pm.close(); }