package tutorial.jdo; import java.io.*; import java.util.*; import javax.jdo.*; /** * Populates the database with an initial set of values for the * tutorial. */ public class SeedDatabase { public static void main(String[] args) { List objects = new LinkedList(); objects.add(new Dog("Binney", 80)); objects.add(new Dog("Fido", 50)); objects.add(new Dog("Odie", 30)); objects.add(new Dog("Tasha", 75)); objects.add(new Dog("Rusty", 25)); // write the new objects to the database PersistenceManagerFactory pmf = JDOHelper.getPersistenceManagerFactory ("META-INF/jdo.properties"); PersistenceManager pm = pmf.getPersistenceManager(); Transaction transaction = pm.currentTransaction(); transaction.begin(); pm.makePersistentAll(objects); transaction.commit(); System.out.println("Created " + objects.size() + " new dogs."); pm.close(); pmf.close(); } }