Hibernate is used widely for data access. It is great to release developer from tons of sql scripts. However, the performance is about 50% less than pure jdbc access. For core function, my current project is still using the pure jdbc to access. The pain part is the current code is all write down by stringbuilder which is easy to make a mistake in syntax and missing space between key sql words.
The implementation will be simple as well:
After that, we add support of "WHERE" "UPDATE" as well as all other SQL key words, always have the unittest firstly and then implementation:
Based on code above, the sql builder can create sql with incorrect sql syntax. for example, where().where().select()... The next step is to add possible syntax support.
Firstly, we draw the sql syntax state change diagram:
Support syntax of select, update, and delete Support syntax of from:
See https://github.com/LeiZheng/sql-utils for more detail
My purpose is trying to create simple java class which help build sql prepared statement.
The class should be working in the following feature as the first version:
1. Support select, Update, delete sql generation.
1. Support select, Update, delete sql generation.
2. Code usage should go with the flow feature
3. Support where, join, and, or key words.
4. support parameters for prepared statement.
Let's start from simple simple select/delete statement, the unit test will be as following at first:
3. Support where, join, and, or key words.
4. support parameters for prepared statement.
Let's start from simple simple select/delete statement, the unit test will be as following at first:
The implementation will be simple as well:
After that, we add support of "WHERE" "UPDATE" as well as all other SQL key words, always have the unittest firstly and then implementation:
Based on code above, the sql builder can create sql with incorrect sql syntax. for example, where().where().select()... The next step is to add possible syntax support.
Firstly, we draw the sql syntax state change diagram:
Support syntax of select, update, and delete Support syntax of from:
See https://github.com/LeiZheng/sql-utils for more detail
Comments
Post a Comment