There isn't really any substantial difference between these three:
- Hardcoded in business objects
- Embedded in SQLJ clauses
- Encapsulate in separate classes e.g. Data Access Objects
I'm assuming that you're going to embed SQL code in a string form directly into your Java code. While 1 and 3 will probably use JDBC directly (or some tool like Apache DbUtils), 2 adds a preprocessor technology to the stack, generating the relevant JDBC code prior to compilation.
So, essentially, if these solutions involve embedding SQL, you might as well use any of these technologies:
- JPA Criteria API, modelling JPQL as an internal domain-specific language in Java
- jOOQ, modelling SQL as an internal domain-specific language in Java
There might also be other tools to help you embed SQL in Java in a more typesafe manner than through SQLJ or through actual string concatenation.