Skip to content

Instantly share code, notes, and snippets.

@jklingsporn
Created August 29, 2017 15:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jklingsporn/c33527ecb16a7c31858ebe2f8b8bea4f to your computer and use it in GitHub Desktop.
Save jklingsporn/c33527ecb16a7c31858ebe2f8b8bea4f to your computer and use it in GitHub Desktop.
DAO maps into record and then into POJO
public abstract class DAOImpl<R extends UpdatableRecord<R>, P, T> implements DAO<R, P, T> {
// ...
@Override
public /* non-final */ <Z> P fetchOne(Field<Z> field, Z value) {
R record = using(configuration)
.selectFrom(table)
.where(field.equal(value))
.fetchOne();
return record == null ? null : mapper().map(record);
}
// ...
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment