CRUD-code for all data tables/views in 5 minutes

Step 1. Generate declarations of DTO classes for CRUD access (plug-in GUI > tab 'DTO' > local tool-bar > DTO CRUD assistant):

<dto-class name="Product" ref="products" />
<dto-class name="Customer" ref="customers" />
<!-- ... -->

Step 2. Generate CRUD declarations for DAO classes (plug-in GUI > tab 'DAO' > local tool-bar > DAO CRUD assistant):

<crud-auto dto="Product" table="products" />
<crud-auto dto="Customer" table="customers" />
<!-- ... -->

Step 3. Copy-paste generated XML-tags to XML meta-program.

Step 4. Run code generator to obtain data access code.

Fast generation of code to query the data through foreign keys

Step 1. Open plug-in GUI: tab 'DAO' > local tool-bar > FK access assistant. You will obtain a set of XML tags like these:

<query-dto-list method="get_orders_by_customer(customer_id)" dto="Order" ref="Orders(CustomerID)" />
<query-dto-list method="get_products_by_supplier(supplier_id)" dto="Product" ref="Products(SupplierID)" />
<!-- ... -->

Step 2. Copy-paste generated XML-tags to XML meta-program.

Step 3. Run code generator to obtain data access code.

Error logging

There is a possibility to display errors of code generation in IDE console.

Update XSD-files from the tab 'Admin' and add <ide event-log='true' /> to 'settings.xml'.

Automated validation of generated code

In many situations, generated code may become not valid:

  • changed DB-schema
  • changed SQL statement(s)
  • changed connection parameters
  • etc.

Code validation tool provided by the plug-ins allows you to see the whole picture of problems and create a plan of fixes. It is much better than total code-regeneration and infinite amount of compiler/run-time errors as result.

Automation of XML coding

By default, IDE provides code completion for XML-tags (CTRL+Space). Plug-in extends this functionality with two features: 1) code completion/navigation for SQL-files, 2) code completion/navigation for the names of DTO-classes.

IDE tool-bar button

All plug-ins provide a navigation drop-down button. By selecting drop-down items, you can easily switch between XML meta-programs of your project/workspace. The button is located in IDE tool-bar.

Compatibility of DTO and DAO

For example, you need to fetch some record from data table and represent it as DTO.

File 'getOrder.sql' contains SQL statement like: 'select * from orders where o_id=?'.

Step 1. Generate DTO class:

<dto-class name="Order" ref="getOrder.sql" />

Step 2. Generate the code to fill DTO:

<query-dto method="getOrder(o_id)" ref="getOrder.sql" dto="Order" />

In both steps, code generator uses the same database meta-data, so compatibility between fetched record and DTO is 100%.

Similar principle works in CRUD scenario.

Step 1. Generate DTO class:

<dto-class name="Product" ref="products" />

Step 2. Generate the code to fill DTO and use DTO as data source for SQL parameters:

<crud-auto dto="Product" table="products" />

Android

  1. A database with exactly the same schema as in your Android application must be located on development PC.
  2. To generate the code, use JDBC driver for SQLite. Successfully tested with Xerial sqlite-jdbc-3.8.9.jar.
  3. Sample implementation of 'DataStore' for Android is shipped with the plug-ins (tab 'Admin').
  4. JDBC drivers for SQLite do not provide type information for columns and parameters. If you need strongly-typed data access code, provide type names in XML meta-program.

External VM-files

There is a possibility to change VM templates used for code generation. Open internal VM-file: plug-in GUI, the tab 'Admin'. Copy paste VM-file to the project tree. Specify the path to VM-file in 'setting.xml', tag 'external-vm-file'. Change VM-file according to you needs.

Stored procedures and functions

...are not supported because working with them differs significantly depending on database provider.

For example, you obtain exception if you try to extract database meta-data from

SELECT INVENTORY_IN_STOCK(?)

(MySQL). At the same time, this one works:

SELECT INVENTORY_IN_STOCK(10)

Etc. etc. etc.