BBS > ibatis2

Mapper sample

작성자 : 이창우 (x1wins) | 등록일 : 2012-01-22 | 목록
첨부 파일이 없습니다.
첨부 이미지가 없습니다.
	public interface ContactMapper {
		final String SELECT_ALL = "SELECT * FROM CONTACT";
		final String SELECT_BY_ID = "SELECT * FROM CONTACT WHERE CONTACT_ID = #{id}";
		final String UPDATE = "UPDATE CONTACT SET CONTACT_EMAIL = #{email}, CONTACT_NAME = #{name}, CONTACT_PHONE = #{phone} WHERE CONTACT_ID = #{id}";
		final String UPDATE_NAME = "UPDATE CONTACT SET CONTACT_NAME = #{name} WHERE CONTACT_ID = #{id}";
		final String DELETE = "DELETE FROM CONTACT WHERE CONTACT_ID = #{id}";
		final String INSERT = "INSERT INTO CONTACT (CONTACT_EMAIL, CONTACT_NAME, CONTACT_PHONE) VALUES (#{name}, #{phone}, #{email})";

		/**
		 * * Returns the list of all Contact instances from the database. * @return
		 * the list of all Contact instances from the database.
		 */
		@Select(SELECT_ALL)
		@Results(value = { @Result(property = "id", column = "CONTACT_ID"),
				@Result(property = "name", column = "CONTACT_NAME"),
				@Result(property = "phone", column = "CONTACT_PHONE"),
				@Result(property = "email", column = "CONTACT_EMAIL") })
		List selectAll();

		/**
		 * * Returns a Contact instance from the database. * @param id primary
		 * key value used for lookup. * @return A Contact instance with a
		 * primary key value equals to pk. null if there is no matching row.
		 */
		@Select(SELECT_BY_ID)
		@Results(value = { @Result(property = "id"),
				@Result(property = "name", column = "CONTACT_NAME"),
				@Result(property = "phone", column = "CONTACT_PHONE"),
				@Result(property = "email", column = "CONTACT_EMAIL") })
		Contact selectById(int id);

		/**
		 * * Updates an instance of Contact in the database. * @param contact
		 * the instance to be updated.
		 */
		@Update(UPDATE)
		void update(Contact contact);

		/**
		 * * Updates an instance of Contact in the database. * @param name name
		 * value to be updated. * @param id primary key value used for lookup.
		 */
		void updateName(@Param("name") String name, @Param("id") int id);

		/**
		 * * Delete an instance of Contact from the database. *
		 * 
		 * @param id
		 *            primary key value of the instance to be deleted.
		 */
		@Delete(DELETE)
		void delete(int id);

		/**
		 * * Insert an instance of Contact into the database. * @param contact
		 * the instance to be persisted.
		 */
		@Insert(INSERT)
		@Options(useGeneratedKeys = true, keyProperty = "id")
		void insert(Contact contact);
	}
로그인 하셔야 댓글을 사용하실수 있습니다.
댓글쓰기를 누르면 로그인 페이지로 이동 후 돌아옵니다.
총 댓글 겟수 0
번호 제목 등록일 작성자 조회수
-> Mapper sample (0) 2012-01-22 이창우 3554
228 한글깨짐문제 (0) 2011-07-18 이창우 3206
< 1 >
글쓰기 검색