简体   繁体   中英

Jdbc Template and MySql interaction for Frequently Changing Queries

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

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM