My application needs to have queries externalized, so to make use of default resourcebundle, I've decided to go with queries in properties files. So, here's what a properties file looks like now:
SELECT_USER_QUERY = Select username, userid from user where userid=?
INSERT_USER_QUERY = insert into user values (?,?)
The problem here obviously is not a showstopper - this properties file gets picked up and gets processed nicely, but for somebody to edit in the near future, it looks ugly. I would like something like this:
SELECT_USER_QUERY = select username, userid
from user
where userid=?
I want to see that formatting in my properties file. I think one way to go about it would be to introduce a "\" (as per some answers on SO) at the end of each line. Are there any other ways to retain formatting in the properties file and still load it successfully?
Ok. I think one way to go about it (and most likely I would) is to write all queries in a properties file, but each query value spanning multiple formatted rows. I will be using a custom ResourceBundle to load these properties in a custom way. This way, I can ensure that there is formatting in properties file and also code wise load properties using ResourceBundle.