Ibatis - Writing Objects to the DatabaseWe now have a Person object from the database. Let’s modify some data. We’ll change the person’s height and weight.
…
person.setHeightInMeters(1.83); // person as read above person.setWeightInKilograms(86.36); … sqlMap.update(“updatePerson”, person); … If we wanted to delete this Person, it’s just as easy. … sqlMap.delete (“deletePerson”, person); … Inserting a new Person is similar. Person newPerson = new Person(); newPerson.setId(11); // you would normally get the ID from a sequence or custom table newPerson.setFirstName(“Clinton”); newPerson.setLastName(“Begin”); newPerson.setBirthDate (null); newPerson.setHeightInMeters(1.83); newPerson.setWeightInKilograms(86.36); … sqlMap.insert (“insertPerson”, newPerson); … That’s all there is to it! |