Ibatis - Reading Objects from the DatabaseNow that the SqlMap instance is initialized and easily accessible, we can make use of it. Let’s first use it to get a Person object from the database. (For this example, let’s assume there’s 10 PERSON records in the database ranging from PER_ID 1 to 10). To get a Person object from the database, we simply need the SqlMap instance, the name of the mapped statement and a Person ID. Let’s load Person #5.
…
SqlMapClient sqlMap = MyAppSqlMapConfig.getSqlMapInstance(); // as coded abov … Integer personPk = new Integer(5); Person person = (Person) sqlMap.queryForObject (“getPerson”, personPk); … |