JDBC Helper. It generates all statements from Java classes and its variables.
java -jar statement-generator-{version}.jar yourClass.java
java -jar statement-generator-{version}.jar yourClass.class
java -jar statement-generator-{version}.jar ExampleModel.class
It will generate a directory: ExampleModel. Inside the directory, you will have files like:
pstm.setInt(1, exampleModel.getIntValue());
pstm.setString(2, exampleModel.getStringValue());
...
INSERT INTO exampleModelTable(int_value,string_value) VALUES (?,?);
exampleModel.setIntValue(resultSet.getInt("int_value"));
exampleModel.setStringValue(resultSet.getString("string_value"));
...
Just put a config.properties in the same path of the jar file. These are the available key properties and its values:
The PreparedStatement variable name. Default: pstm
- pstm - The PreparedStatement variable name
The ResultSet variable name. Default: resultSet
- resultSet - The ResultSet variable name
The fields to ignore. Example: ignore_fields=name,age
The SQLs for the classes. Default is all options.
- INSERT - Insert statement
The Java code for the classes. Default is all options.
- PSTM - Generates the PreparedStatement code for the classes.
- RESULTSET - Generates the ResultSet code for the classes.
See https://docs.jboss.org/hibernate/orm/4.2/javadocs/org/hibernate/cfg/NamingStrategy.html
Default: improved
- ejb3 - EJB3NamingStrategy
- improved - ImprovedNamingStrategy
It changes the default extension to search (changes the parser). Default: class
- java - Uses .java parser
- class - Uses .class parser
The output of the result. Default: file
- console - Prints the output to the console.
- file - Prints the output to files.