The largest Interview Solution Library on the web


« Previous | 1 | 2 | 3 | Next »

Ibatis - Writing Objects to the Database


We 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!
« Previous | 1 | 2 | 3 | Next »


copyright © 2014 - all rights riserved by javatechnologycenter.com