This solution provides an easy way to build the data access layer for RDBMS.
Screencast: utils4dal-eclipse-ide.flv (5 min.; 27MB).
Preconditions:
- the database is accessible through JDBC
- database structure is ready to use (or partially ready), so
there is possibility to execute/test required SQL statements at
design time
Scenario:
Provide SQL statements. For each SQL statement, provide XML instruction. For example:
For standard CRUD operations, provide only instructions: SQL statements are built automatically. For example:
Run the code generator and obtain java code.
In XML instructions, you provide only minimal info like the names of generated classes and methods. The rest of info required for code generation is obtained from JDBC meta-data.
Current version of code generator creates DTO and DAO classes. Resulting code does not contain any JDBC calls or JDBC-specific data types. It is completely framework-independent and can be used in
- Java projects based on JDBC (Spring JDBC, Apache DbUtils, Groovy Sql)
- not-JDBC Java projects (Android)
Tested with:
PostgresSQL, MySQL, Oracle XE, H2, HSQLDB, Derby, SQL Server 2008, IBM DB2, IBM Informix, Firebird, SQLite, CUBRID.