package org.artgasmator.data.rowmapper;

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

import org.artgasmator.model.Member;
import org.springframework.jdbc.core.RowMapper;
import org.springframework.jdbc.support.lob.LobHandler;

public class MemberRowMapper implements RowMapper<Member> {

	private LobHandler lobHandler;
	
	public MemberRowMapper(LobHandler lobHandler) {
		this.lobHandler = lobHandler;
	}
	
	public Member mapRow(ResultSet rs, int rowIndex) throws SQLException {
		Member member = new Member();
		member.setMemberId(rs.getInt(1));
		member.setMemberName(rs.getString(2));
		member.setMemberOccupation(rs.getString(6));
		member.setPhoto(lobHandler.getBlobAsBytes(rs, 9));
		return member;
	}

}
