When I wish to use SQL queries in Java, I usually hold them in final String variables. Now, when the string is too large, it goes out of page breadth, and we either have to
Actually a really good question, I often wonder about that as well. One tip I can give you is using the following:
//@formatter:off
private static final String QUERY =
"SELECT t.* " +
"FROM table t " +
"WHERE t.age > 18";
//@formatter:on
It does not convert a SQL query into a Java String literal, but it keeps Eclipse from reformatting your String awkwardly unreadable.