You can use jOOQ, a lightweight ORM framework
Depending on your needs, you can just use the sql builder(doc)
// Fetch a SQL string from a jOOQ Query in order to manually execute it with another tool.
String sql = create.select(field("BOOK.TITLE"), field("AUTHOR.FIRST_NAME"), field("AUTHOR.LAST_NAME"))
.from(table("BOOK"))
.join(table("AUTHOR"))
.on(field("BOOK.AUTHOR_ID").equal(field("AUTHOR.ID")))
.where(field("BOOK.PUBLISHED_IN").equal(1948))
.getSQL();
This kind of user/interface driven combined query, I have handled it in a previous project and implemented it using Hibernate's Criteria Query.
The program processing is actually relatively simple. The focus is on the performance optimization of this type of real custom combination query. This is the key.
Hope it helps you.
P.S. In any situation, please do not assemble SQL directly. You may accidentally introduce a SQL injection point and make an irreparable mistake.
You can use jOOQ, a lightweight ORM framework
Depending on your needs, you can just use the sql builder(doc)
This kind of user/interface driven combined query, I have handled it in a previous project and implemented it using Hibernate's Criteria Query.
The program processing is actually relatively simple. The focus is on the performance optimization of this type of real custom combination query. This is the key.
Hope it helps you.
P.S. In any situation, please do not assemble SQL directly. You may accidentally introduce a SQL injection point and make an irreparable mistake.
Adopt builder mode
How come your code is as bad as mine?
It is recommended to use a template engine to do complex SQL, see my article: http://blog.csdn.net/rocks_le...