// Collection of code snippets by Arne Vajhøj 
// (likely posted to comp.os.vms/INFO-VAX, INFO-TPU, MACRO32, eksperten.dk, newz.dk, LinkedIn or other place sometime between 1990 and now) 
package test;

import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Types;

import javax.sql.DataSource;

import org.springframework.jdbc.core.SqlParameter;
import org.springframework.jdbc.object.MappingSqlQuery;

public class T1Gateway extends MappingSqlQuery {

    public T1Gateway(DataSource ds) {
        super(ds, "SELECT f1,f2 FROM t1 WHERE f1 = ?");
        declareParameter(new SqlParameter(Types.INTEGER));
        compile();
    }

    protected Object mapRow(ResultSet rs, int rownum) throws SQLException {
        return new T1(rs.getInt(1), rs.getString(2));
    }

    public T1 findT1(int f1) {
        return (T1)findObject(f1);
    }
}
