Corporate Application Templates , 2012 edition. A question about code examples in the Data Mapper chapter.
The same load () method of the AbstractMapper class in the chapter is presented three times with one change, which is confusing.
So, the code on page 194:
protected DomainObject load(ResultSet rs) throws SQLException { Long id = new Long(rs.getLong(1)); if (loadedMap.containsKey(id)) return (DomainObject) loadedMap.get(id); DomainObject result = doLoad(id, rs); loadedMap.put(id, result); return result; } The same method (but with "id" instead of one) on page 200:
protected DomainObject load(ResultSet rs) throws SQLException { Long id = new Long(rs.getLong("id")); //... } On page 201 (within the book reversal) the unit is again:
protected DomainObject load(ResultSet rs) throws SQLException { Long id = new Long(rs.getLong(1)); //... } What should be passed to the rs.getLong () method?