Skip to content
This repository has been archived by the owner on Nov 11, 2022. It is now read-only.

Allow subclasses to override query-templates used #1

Open
fabianbuch opened this issue Jun 20, 2012 · 1 comment
Open

Allow subclasses to override query-templates used #1

fabianbuch opened this issue Jun 20, 2012 · 1 comment

Comments

@fabianbuch
Copy link
Contributor

Currently the queries are defined as constants within @JdbcMessageProvider@:


    private static final String QUERY_INSERT = "INSERT INTO %s (%s, %s, %s, %s, %s, %s) VALUES (?, ?, ?, ?, ?, ?)";
    private static final String QUERY_DELETE = "DELETE FROM %s WHERE %s = ?";
    private static final String QUERY_SELECT_BASENAMES = "SELECT DISTINCT %s from %s";
    private static final String QUERY_SELECT_MESSAGES = "SELECT %s,%s,%s,%s,%s FROM %s WHERE %s = ?";

Reading those should be wrapped in protected metods like:


protected String getSelectMessagesQuery() {
  return QUERY_SELECT_MESSAGES;
}

So users could customize the queries by doing the following in a subclass:


@Override
protected String getSelectMessagesQuery() {
  return super.getSelectMessagesQuery() + " WHERE account = 2";
}
@fabianbuch
Copy link
Contributor Author

Comment of Marc Kannegiesser: I introduced the needed methods:


protected String getSelectMessagesQuery();
protected String getSelectBasenamesQuery();
protected String getInsertMessageQuery();
protected String getDeleteMessagesQuery();

There is still some documentation (WIKI) to be done so ill leave the ticket open for now.
The feature is available from the latest snapshot-build if anyone wants to try... (0.7-SNAPSHOT).

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant