// First we need to insert a record into the database. // Define the data elements of the record to insert HashMap hm = new HashMap(); hm.put("ID", new Integer(102)); hm.put("FIRST_NAME","JP"); hm.put("LAST_NAME","LEIBUNDGUTH"); hm.put("ZIP_CODE","22182"); hm.put("PHONE","571-633-8645"); UniversumHome home; // Lookup home interface for Universum Bean with appropriate JNDI string // Convert our HashMap of data to the Value object for Universum Bean UniversumData ebd = new UniversumData(hm); // Use the create method on the home interface to insert the record Universum user = home.create(ebd, UserPK.getInstance()); // Next, retrieve the first name of the user we just created. UniversumData data = user.getBeanAttributes()); String name = (String) data.get("FIRST_NAME"); // Finally, change the user's phone number and update the record HashMap hm = new HashMap(); hm.put("PHONE","703-770-3000"); user.setBeanAttributes(new UniversumData(hm));
Example 4: Client access to Universum Bean.