Skip to content

Instantly share code, notes, and snippets.

@theopendle
Created February 10, 2019 14:56
Show Gist options
  • Save theopendle/b5e65fa806d425491358cd45e4bb3379 to your computer and use it in GitHub Desktop.
Save theopendle/b5e65fa806d425491358cd45e4bb3379 to your computer and use it in GitHub Desktop.
@Mapper
public interface ClientMapper {
@Select("SELECT id as id, first_name as firstName, last_name as lastName FROM spring_demo.clients WHERE id = #{id}")
Client selectOne(long id);
@Select("SELECT id as id, first_name as firstName, last_name as lastName FROM spring_demo.clients")
List<Client> findAll();
@Insert("INSERT INTO spring_demo.clients (id, first_name, last_name) VALUES (#{id}, #{firstName}, #{lastName})")
// Sets the object id to the id generated in database
@Options(useGeneratedKeys = true, keyColumn = "id", keyProperty = "id")
void insertClient(Client client);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment