简体   繁体   English

频繁更改查询的Jdbc模板和MySql交互

[英]Jdbc Template and MySql interaction for Frequently Changing Queries

There are some queries used by a DAO layer that is implemented in JDBC Template JDBC模板中实现的DAO层使用了一些查询

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. longQuery将会经常更改,但是我不想在源代码中对其进行正确的管理。 How do you go about handling this? 您如何处理呢? I need jdbc template source code, and at least the basics of setting it up in mysql. 我需要jdbc模板源代码,至少需要在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 需要查询同一服务器上的其他mysql数据库
  • Needs to return a list of Ids, which could many, several thousand possibly 需要返回ID列表,该列表可能很多,几千

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. 您可以将它们存储为文件(DAO_NNN.sql,其中NNN是特定SQL语句的ID)或将它们存储在XML文件中。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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