Skip to content

Instantly share code, notes, and snippets.

@collinvandyck
Created September 12, 2012 19:07
Show Gist options
  • Select an option

  • Save collinvandyck/3709166 to your computer and use it in GitHub Desktop.

Select an option

Save collinvandyck/3709166 to your computer and use it in GitHub Desktop.
public interface UserDAO {
@SqlQuery("SELECT u.id, u.email, u.password_hash, u.apikey, u.created_at, u.updated_at, u.name, u.id, u.admin, u.active from users u where u.apikey = :apiKey")
@RegisterMapper(UserMapper.class)
User getUserByApiKey(@Bind("apiKey") String apiKey);
static class UserMapper implements ResultSetMapper<User> {
@Override
public User map(int i, ResultSet rs, StatementContext statementContext) throws SQLException {
return new User(
rs.getString("id"),
rs.getString("email"),
new Date(rs.getTimestamp("created_at").getTime()),
new Date(rs.getTimestamp("updated_at").getTime()),
rs.getString("name"),
rs.getBoolean("admin"),
rs.getBoolean("active"));
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment