public void persist(Object obj); // Save obj to the data store. public Object load(Class c, Object pK); // Read obj with a given PRimary key. public void update(Object obj); // Update the modified object obj. public void delete(Object obj); // Delete obj from the database.
public Collection find(Query q); // Find objects that satisfy conditions of our query.
PersistenceManager pm =PMFactory.initialize(..); Company co = new Company("MyCompany"); Location l1 = new Location1 ("Boston"); Location l2 = new Location("New York");
// Create users.
User u1 = new User("Mark"); User u2 = new User("Tom"); User u3 = new User("Mary");
// Add users. A user can only "belong" to one location.
L1.addUser(u1); L1.addUser(u2); L2.addUser(u3);
// Add locations to the company.
co.addLocation(l1); co.addLocation(l2);
// And finally, store the whole tree to the database.
About the author Jacek Kruszelnicki is president of Numatica Corporation, an information technology consulting firm providing eXPertise in information-systems strategy development, analysis, and planning; software development; and training. Jacek (pronounced Yatsek) received his master´s degree in computer science from Northeastern University in Boston, Mass., and has more than 15 years´ experience delivering maintainable, large-scale, distributed enterprise solutions.