package dao; import java.sql.resultset; import java.sql.sqlexception; import org.krams.tutorial.oxm.subscriptionrequest; import org.springframework.jdbc.core.rowmapper; import org.springframework.jdbc.core.simple.simplejdbcdaosupport; public class mymapper implements rowmapper<subscriptionrequest> { public subscriptionrequest maprow(resultset rs, int rownum) throws sqlexception { subscriptionrequest subscription = new subscriptionrequest(); subscription.setid(rs.getint(1)); subscription.setcity(rs.getstring(2)); return subscription; } } this class @ moment, mapper 1 table
how can use same mapper class other database tables? or each table, must create new mapper class?
as rowmapper contains no state, same instance of class used table/select. question if these tables/selects can converted subscriptionrequest object , contain first int , second string column.
if not, must create new rowmapper each object want generate. or use "generic" row mapper produce map each row instead of concrete object.
Comments
Post a Comment