EasySQL

EclipseWork uses the EasySQL plugin to get a database connection, and do Database Reverse Engineering.

EclipseWork will always use the current EasySQL connection to open the database wizards. To create a new Connection using EasySQL, use the ConnectionView, just right-click and select "New Connection"

Wizard

Let's take a look in the "model-page" element.



If you use it with the type="table", all the tables of the selected Connection will be shown in the wizard.



After selected the Finish button, all the velocity templates will be created for each selected Table.



Wizards - Template

You just have to create two files: table.xml (wizard configuration file), table.vm (Velocity template)

Create the table.xml file:


<?xml version="1.0" encoding="UTF-8"?>
<EclipseWork>
    <wizard>
        <title>HelloWorld EclipseWork</title>

		<model-page type="table" required="true">
			<description>Select some Table</description>
		</model-page>

        <component-page >
        	<description>Some description here</description>

			<container name="folder" label="Folder Output: " type="folder" />

	     </component-page>

        <output>
        	<template component="." expression="${model.name}" velocity="table.vm" extension="txt" container="folder" />
		</output>
    </wizard>
</EclipseWork>

Create the table.vm Template:


$model
$model.name
-----------------------
#foreach($f in $model.fields)
	$f.name $f.type $f.javaType
#end



The wizard will create a new file for each Table. And the Velocity template just prints all the columns of the current Table.

The expression="${model.name}" is used to choose the output file name. The $model variable is automatically put in the Velocity Context, and it contains a reference to the current table. So ${model.name} will print the table name

Note that the other examples don't use the expression attribute, just the "component". The componente represents the output file name (when the expression is not present).

Note that you can create entire CRUD applications for your database in few minutes.



POJO vs Table

The POJO and Table Velocity templates are almost the same. This is because internally EclipseWork uses interfaces, so doesn't matter if the current object is a POJO or a Table.