views:

50

answers:

1

There are some queries used by a DAO layer that is implemented in JDBC Template

String longQuery = ".....";
public List<AnObject> findObjectsBySomething(Something s) {
    return getJdbcTemplate().queryForObjects(longQuery, myRowMapper, s);
}

longQuery is going to frequently change, but I don't want to have to manage it right in the source code. How do you go about handling this? I need jdbc template source code, and at least the basics of setting it up in mysql.

Other requirements:

  • Cannot be a View, I already tried this and my query is too complicated (derived tables)
  • Needs to query across other mysql databases on the same server
  • Needs to return a list of Ids, which could many, several thousand possibly
A: 

How different is this query? You can store them as files(DAO_NNN.sql where NNN is an id to a specific SQL statement) or store them in an XML file.

adrian.tarau
I'd really prefer having it stored in the database, something more along the lines of a stored procedure
walnutmon
you want keep in db SQL statements to access the db :) not a very good idea I would say :)
adrian.tarau
I still don't have a big picture... can you give me an examples?
adrian.tarau
My application uses a query that may need to change in the future, I don't want it stored in the application code AT ALL, I don't want the SQL in a string, I don't want it in a text file, I don't want it stored in any way that is not managed by the database. I'm not saying I want to store it in a table in the database, I want it stored in a function/view/stored procedure that way the code references it by name and I can change it on the fly later in the DB
walnutmon