1 18 package org.objectweb.speedo.runtime.odis; 19 20 import org.objectweb.speedo.SpeedoTestHelper; 21 import org.objectweb.speedo.pobjects.odis.Concurrent; 22 23 import javax.jdo.PersistenceManager; 24 import javax.jdo.Query; 25 import javax.jdo.Extent; 26 import java.util.Collection ; 27 import java.util.Iterator ; 28 import java.util.Calendar ; 29 import java.sql.Time ; 30 31 35 public class TestConcurrent extends SpeedoTestHelper { 36 37 public TestConcurrent(String s) { 38 super(s); 39 } 40 41 protected String getLoggerName() { 42 return LOG_NAME + "rt.odis.TestConcurrent"; 43 } 44 45 public void testA() { 46 PersistenceManager pm = pmf.getPersistenceManager(); 47 int nbobj = 10; 48 Concurrent[] cs = new Concurrent[nbobj]; 49 for(int i=0; i<nbobj ; i++) { 50 cs[i] = new Concurrent(i + 10, "d" + i, 51 new Time (Calendar.getInstance().getTimeInMillis())); 52 } 53 pm.makePersistentAll(cs); 54 pm.close(); 55 56 pm = pmf.getPersistenceManager(); 57 Query q = pm.newQuery(Concurrent.class); 58 q.setFilter("(dossard==p1)"); 59 q.declareParameters("String p1"); 60 Collection col = (Collection ) q.execute("d3"); 61 Iterator it = col.iterator(); 62 while(it.hasNext()) { 63 Concurrent c = (Concurrent) it.next(); 64 System.out.println("concurrent : cid=" + c.getCid() 65 + ", dossard=" + c.getDossard() 66 + ", temps=" + c.getTemps()); 67 } 68 q.closeAll(); 69 pm.close(); 70 71 pm = pmf.getPersistenceManager(); 72 pm.currentTransaction().begin(); 73 Extent e = pm.getExtent(Concurrent.class, false); 74 it = e.iterator(); 75 while(it.hasNext()) { 76 pm.deletePersistent(it.next()); 77 } 78 pm.currentTransaction().commit(); 79 pm.close(); 80 } 81 82 } 83 | Popular Tags |