I'm trying to externalize SQL statements for usage with spring
, as advised in https://stackoverflow.com/a/24141382/1194415.
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE properties SYSTEM "http://java.sun.com/dtd/properties.dtd">
<properties>
<entry key="SQL_MAX_ID">
<![CDATA[
SELECT MAX(id) FROM mytable
]]>
</entry>
</properties>
Question: when having multiple sql statements, it would be nice to define mytable
only once, and then refer to it as some kind of variable.
Is that possible in a simple properties file?
I'm loading the file as follows:
@Bean
public PropertiesFactoryBean sql() {
PropertiesFactoryBean bean = new PropertiesFactoryBean();
bean.setLocation(new ClassPathResource("sql.xml"));
return bean;
}