class ContextualPreferenceDao extends NamedParameterJdbcDaoSupport {

    public Optional<ContextualPreference> load(final String name,
                                               final ContextualPreferenceExternalResource externalResource) {
        return getNamedParameterJdbcTemplate()
                .query(loadContextualPreferenceQuery, 
                        Parameters.getParameters(name, externalResource), 
                        Parameters.getRowMapper())
                .stream()
                .findFirst();
    }

}