Added: empire-db/site/legacy/documentation/tutorial.htm
URL:
http://svn.apache.org/viewvc/empire-db/site/legacy/documentation/tutorial.htm?rev=1898936&view=auto
==============================================================================
--- empire-db/site/legacy/documentation/tutorial.htm (added)
+++ empire-db/site/legacy/documentation/tutorial.htm Mon Mar 14 20:41:26 2022
@@ -0,0 +1,732 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-gb" lang="en-gb" >
+<!-- #BeginTemplate "../main.dwt" -->
+<head>
+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+ <meta http-equiv="language" content="en" />
+ <meta name="robots" content="index, follow" />
+ <meta name="keywords" content="java, jar, jdbc, sql, data, metadata,
persistence, rdbms, orm, mapping" />
+ <meta name="description" content="Open Source relational data
persistence component." />
+
+ <!-- #BeginEditable "doctitle" -->
+<title>Empire-db - Tutorials</title>
+ <!-- #EndEditable -->
+
+ <script type="text/javascript" src="../js/prototype.js"></script>
+ <script type="text/javascript" src="../js/menu.js"></script>
+ <!-- #BeginEditable "javascripts" -->
+ <!-- #EndEditable -->
+
+ <link rel="shortcut icon" href="../empire-db.ico" />
+ <link rel="stylesheet" href="../css/layout.css" type="text/css" />
+ <!-- #BeginEditable "stylesheets" -->
+ <style type="text/css">
+
+
+.style1 {
+ color: #0000FF;
+}
+.style2 {
+ color: #000000;
+}
+.style3 {
+ color: #800080;
+}
+</style>
+ <!-- #EndEditable -->
+</head>
+
+<body>
+<div id="wrapper">
+
+ <!-- Header -->
+ <div id="header">
+ <div id="logo">
+ <img src="../images/logos/empire-db-logo.gif"
alt="Empire-db: The relational data persistence component." />
+ </div>
+ <div id="asf">
+ <a id="asfhome" target="_blank"
href="https://www.apache.org"><img src="../images/logos/feather-small.gif"
alt="The Apache Software Foundation" /></a>
+ <label for="asfhome" >The Apache Software
Foundation</label>
+ </div>
+ <div style="clear:both"></div>
+ </div>
+
+ <!-- Top -->
+ <div id="top">
+ <div id="topbar"> </div>
+ </div>
+
+ <!-- Middle -->
+ <div id="middle">
+ <div id="left">
+ <div id="menuBox">
+ <ul id="mainMenu">
+ <li id="menu_home"><a
href="../index.html">Home</a></li>
+ <li id="menu_news"><a
href="../news.htm">News</a></li>
+ <li id="menu_empiredb"><a
href="../empiredb/empiredb.htm">Empire-db</a>
+ <ul
class="subMenu">
+ <li
id="menu_empiredb_extending_pattern"><a href="../empiredb/pattern.htm">The
Empire DAO-<br />pattern</a></li>
+ <li
id="menu_empiredb_handling_metadata"><a
href="../empiredb/metadata.htm">Handling data and metadata</a></li>
+ <li
id="menu_empiredb_wrong"><a href="../empiredb/hibernate.htm">What's wrong with
Hibernate and JPA</a></li>
+ <li
id="menu_empiredb_stringfree"><a href="../empiredb/stringfree.htm">The
principle of<br/>string-free coding</a></li>
+ <li
id="menu_empiredb_faq"><a href="../empiredb/faq.htm">FAQ</a></li>
+ </ul>
+ </li>
+ <li id="menu_struts2ext"><a
href="../struts2ext/struts2ext.htm">Empire-db and Struts2</a>
+ <ul class="subMenu">
+ <li
id="menu_struts2ext_forms_controls"><a
href="../struts2ext/forms_controls.htm">Forms and controls</a></li>
+ <li
id="menu_struts2ext_rendering_parsing"><a
href="../struts2ext/rendering_parsing.htm">Rendering and parsing</a></li>
+ <!--<li
id="menu_struts2ext_tag_reference"><a href="struts2ext/tag_reference.htm">Tag
reference</a></li>-->
+ <li
id="menu_struts2ext_input_controls"><a
href="../struts2ext/input_controls.htm">Input controls</a></li>
+ </ul>
+ </li>
+ <li id="menu_downloads"><a
href="../downloads/latest.htm">Downloads</a>
+ <ul
class="subMenu">
+ <li
id="menu_downloads_previous"><a href="../downloads/previous.htm">Previous
releases</a></li>
+ <li
id="menu_downloads_license"><a href="../downloads/license.htm">License</a></li>
+ </ul>
+ </li>
+ <li id="menu_documentation"><a
href="documentation.htm">Documentation</a>
+ <ul class="subMenu">
+ <li
id="menu_documentation_class_overview"><a href="class_overview.htm">Empire-db
class<br />overview</a></li>
+ <li
id="menu_documentation_tutorials"><a href="tutorial.htm">Tutorial</a></li>
+ <li
id="menu_documentation_getting_started"><a href="getting_started.htm">Getting
started</a></li>
+ <li
id="menu_documentation_reverse_engineering"><a
href="reverse_engineering.htm">Reverse Engineering</a></li>
+ <li
id="menu_documentation_api"><a href="api.htm">API</a></li>
+ </ul>
+ </li>
+ <li id="menu_community"><a
href="../community/community.htm">Community</a>
+ <ul class="subMenu">
+ <li
id="menu_community_mailing_lists"><a
href="../community/mailing_lists.htm">Mailing lists</a></li>
+ <li
id="menu_community_source_code"><a href="../community/source_code.htm">Source
code</a></li>
+ <li
id="menu_community_jira"><a href="../community/jira.htm">Ticketing &
Wiki</a></li>
+ <!--<li
id="menu_community_road_map"><a href="community/road_map.htm">Road
map</a></li>-->
+ <li
id="menu_community_contributors"><a
href="../community/contributors.htm">Contributors</a></li>
+ </ul>
+ </li>
+ <li id="menu_apache"><a
href="../apache.htm">About Apache</a>
+ <ul class="subMenu">
+ <li
id="menu_apache_home"><a href="https://www.apache.org">Apache home<span
class="asflink"> </span></a></li>
+ <li
id="menu_apache_donate"><a
href="https://www.apache.org/foundation/sponsorship.html">Sponsorship<span
class="asflink"> </span></a></li>
+ <li
id="menu_apache_thanks"><a
href="https://www.apache.org/foundation/thanks.html">Foundation thanks<span
class="asflink"> </span></a></li>
+ <li
id="menu_apache_security"><a
href="https://www.apache.org/security/">Security<span
class="asflink"> </span></a></li>
+ </ul>
+ </li>
+ <li id="menu_disclaimer"><a
href="https://www.apache.org/licenses/">License<span
class="asflink"> </span></a></li>
+ </ul>
+ </div>
+
+ </div>
+
+ <!-- #BeginEditable "menu" -->
+ <script type="text/javascript">
+ var menu = new Menu( 'mainMenu', 'menu_documentation',
'menu_documentation_tutorials' );
+ var prev_page = "class_overview.htm";
+ var next_page = "getting_started.htm";
+ </script>
+ <!-- #EndEditable -->
+ <script type="text/javascript">
+ /* <![CDATA[ */
+ if( menu ) {
+ // Menu fully opened (comment out if not wanted)
+ // menu.openAll();
+ /* ]]> */
+ }
+ </script>
+
+ <div id="main">
+
+ <div id="pathway">
+ <span style="float:left">
+ <!-- #BeginEditable "pathway" -->
+ <a href="documentation.htm">Documentation</a> »
Tutorial
+ <!-- #EndEditable -->
+ </span>
+ <a id="downloadLink" href="../downloads/latest.htm"
style="float:right">Download</a>
+ </div>
+
+ <div id="content">
+ <!-- #BeginEditable "content" -->
+ <!--<h1>Sample application SampleDB</h1>-->
+ <h1>Introduction</h1>
+ <p>
+ This tutorial demonstrates in
eight easy steps how to
+ work with Empire-db and perform
the most common tasks of
+ data persistence: inserting,
updating and deleting
+ records as well as performing
queries.</p>
+ <p>
+ The sample application used for
this tutorial is
+ provided with the Empire-db
distribution and can be
+ found in the
<i><b>examples/DBSample</b></i> directory.
+ If you are using the Eclipse
IDE there is also an
+ Eclipse project file that
allows you to open the project
+ straight away. In your IDE, set
a breakpoint on the first line
+ of the main method in
SampleApp.java and debug the sample.</p>
+ <p>
+ The sample works with a HSQL
database that is provided
+ with the distribution files,
and allows the application to run "off
+ the shelf". However it can
easily be reconfigured to
+ work with a Microsoft
SQL-Server or Oracle database
+ instead by altering the
<i><b>config.xml</b></i> file.</p>
+ <p>
+ In detail the tutorial shows
the following:</p>
+ <ul>
+ <li>How to declare your data
model using Java classes
+ and objects</li>
+ <li>How to generate a
DDL-Script from the data model
+ definition and create all
database objects on the server</li>
+ <li>How to insert, update and
delete individual records</li>
+ <li>How to perform a database
query including joins and
+ constraints</li>
+ <li>How to access the query
results either sequentially
+ row by row, as a bean list or
as an XML document.</li>
+ </ul>
+ <h1>Structure of the Sample
Application</h1>
+ <p>
+ The sample application is made
up of four files:</p>
+ <ol>
+ <li><b>SampleDB.java</b>: This
is the database definition file
+ which contains the database
layout with tables, indices, relations, views, etc.</li>
+ <li><b>SampleApp.java</b>: This
class includes the
+ application's main method
which calls other methods to
+ perform the individual tasks.
Set a breakpoint here to
+ step though the application
using your debugger.</li>
+ <li><b>SampleConfig.java</b>:
This class provides access
+ to configuration settings,
which are read from the
+ configuration file
config.xml.</li>
+ <li><b>SampleBean.java</b>:
This class is used to store
+ query results in a simple Plain
Old Java Object (POJO).
+ The properties of this class
only hold the fields of the
+ query and not all the fields of
a full database entity.</li>
+ </ol>
+ <p><em>Note:</em> In order to run the
sample on a database
+ system other than the HSQLDB provided,
first the
+ corresponding JDBC driver has to be
added to the classpath.
+ Afterwards the settings for the
database provider and the
+ JDBC connection have to be adjusted
accordingly in the file
+ config.xml.</p>
+<pre><span style="color: #0000FF; "><</span><span style="color: #800000;
">properties</span><span style="color: #0000FF; ">></span><span
style="color: #000000; ">
+</span><span style="color: #008000; "><!--</span><span style="color:
#008000; "> provider name must match the property-section containing the
connection data </span><span style="color: #008000; ">--></span><span
style="color: #000000; ">
+ </span><span style="color: #0000FF; "><</span><span style="color:
#800000; ">databaseProvider</span><span style="color: #0000FF;
">></span><span style="color: #000000; ">hsqldb</span><span style="color:
#0000FF; "></</span><span style="color: #800000;
">databaseProvider</span><span style="color: #0000FF; ">></span><span
style="color: #000000; ">
+</span><span style="color: #0000FF; "></</span><span style="color: #800000;
">properties</span><span style="color: #0000FF; ">></span><span
style="color: #000000; ">
+
+</span><span style="color: #0000FF; "><</span><span style="color: #800000;
">properties-hsqldb</span><span style="color: #0000FF; ">></span><span
style="color: #000000; ">
+ </span><span style="color: #008000; "><!--</span><span style="color:
#008000; "> jdbc properties </span><span style="color: #008000;
">--></span><span style="color: #000000; ">
+ </span><span style="color: #0000FF; "><</span><span style="color:
#800000; ">jdbcClass</span><span style="color: #0000FF; ">></span><span
style="color: #000000; ">org.hsqldb.jdbcDriver</span><span style="color:
#0000FF; "></</span><span style="color: #800000; ">jdbcClass</span><span
style="color: #0000FF; ">></span><span style="color: #000000; ">
+ </span><span style="color: #0000FF; "><</span><span style="color:
#800000; ">jdbcURL</span><span style="color: #0000FF; ">></span><span
style="color: #000000;
">jdbc:hsqldb:file:hsqldb/sample;shutdown=true</span><span style="color:
#0000FF; "></</span><span style="color: #800000; ">jdbcURL</span><span
style="color: #0000FF; ">></span><span style="color: #000000; ">
+ </span><span style="color: #0000FF; "><</span><span style="color:
#800000; ">jdbcUser</span><span style="color: #0000FF; ">></span><span
style="color: #000000; ">sa</span><span style="color: #0000FF;
"></</span><span style="color: #800000; ">jdbcUser</span><span style="color:
#0000FF; ">></span><span style="color: #000000; ">
+ </span><span style="color: #0000FF; "><</span><span style="color:
#800000; ">jdbcPwd</span><span style="color: #0000FF; ">></</span><span
style="color: #800000; ">jdbcPwd</span><span style="color: #0000FF;
">></span><span style="color: #000000; ">
+ </span><span style="color: #0000FF; "><</span><span style="color:
#800000; ">schemaName</span><span style="color: #0000FF; ">></span><span
style="color: #000000; ">DBSAMPLE</span><span style="color: #0000FF;
"></</span><span style="color: #800000; ">schemaName</span><span
style="color: #0000FF; ">></span><span style="color: #000000; ">
+</span><span style="color: #0000FF; "></</span><span style="color: #800000;
">properties-hsqldb</span><span style="color: #0000FF; ">></span></pre>
+ <p> Within the project you will also find a
subdirectory named âoutputâ
+ which contains
+ the console output of the individual steps of this
+ tutorial.</p>
+
+ <h1>Data model
definition (SampleDB.java)</h1>
+ <p>
+ For the
data model definition we first
+ create
a <font face="Courier New">«</font>database<font face="Courier New">»</font>
class
+ called
SampleDB, which inherits from
+
de.esteam.empire.db.DBDatabase.
+ All
tables (and possibly views) of the data
+ model
are
+
declared as <i><b>public final</b></i>
+ fields
which are assigned to the corresponding
+ table
or view object. Additionally in the constructor
+ a
foreign key relation from the employees
+ table
to departments table is added.
+ </p>
+
+<pre><font color="#0000FF">public class </font>SampleDB <font
color="#0000FF">extends</font> DBDatabase {
+
+<span style="color: #008000; "> //</span><span style="color: #008000; ">
Table class definition (see below)
+</span><font color="#0000FF"> public static class </font>Departments <font
color="#0000FF">extends</font> DBTable {... }
+<font color="#0000FF"> public static class </font>Employees <font
color="#0000FF">extends</font> DBTable {... }
+<span style="color: #008000; ">
+ //</span><span style="color: #008000; "> Table members</span><span
style="color: #008000; ">
+ </span><span style="color: #0000FF; ">public</span><span style="color:
#000000; "> </span><span style="color: #0000FF; ">final</span><span
style="color: #000000; "> Departments DEPARTMENTS </span><span style="color:
#000000; ">=</span><span style="color: #000000; "> </span><span style="color:
#0000FF; ">new</span><span style="color: #000000; "> Departments(</span><span
style="color: #0000FF; ">this</span><span style="color: #000000; ">);
+ </span><span style="color: #0000FF; ">public</span><span style="color:
#000000; "> </span><span style="color: #0000FF; ">final</span><span
style="color: #000000; "> Employees EMPLOYEES </span><span style="color:
#000000; ">=</span><span style="color: #000000; "> </span><span style="color:
#0000FF; ">new</span><span style="color: #000000; "> Employees(</span><span
style="color: #0000FF; ">this</span><span style="color: #000000; ">);
+
+ </span><span style="color: #008000; ">// SampleDB constructor
+</span> <span style="color: #0000FF; ">public</span><span style="color:
#000000; "> SampleDB()
+ {
+ </span><span style="color: #008000; ">//</span><span style="color:
#008000; "> Define foreign key relations</span><span style="color: #008000; ">
+ </span><span style="color: #000000; ">
addRelation(EMPLOYEES.DEPARTMENT_ID
+ .referenceOn(DEPARTMENTS.DEPARTMENT_ID ));
+ }
+</span><span style="color: #000000; ">}</span></pre>
+ <p>
+ In our
example we create an individual class
+ for
each of the two tables. Instead of
+ normal
classes however, we use nested classes
+ here.
While not necessary, this is a
+
convenient way of keeping the whole data
+ model
in one file.
+ This is
sensible since it contains no or
+ only
little logic.</p>
+
+<pre><span style="color: #0000FF; ">public</span><span style="color: #000000;
"> </span><span style="color: #0000FF; ">final</span><span style="color:
#000000; "> </span><span style="color: #0000FF; ">class</span><span
style="color: #000000; "> Employees </span><span style="color: #0000FF;
">extends</span><span style="color: #000000; "> DBTable
+{
+ </span><span style="color: #0000FF; ">public</span><span style="color:
#000000; "> DBTableColumn EMPLOYEE_ID;
+ </span><span style="color: #0000FF; ">public</span><span style="color:
#000000; "> DBTableColumn LASTNAME;
+ </span><span style="color: #0000FF; ">public</span><span style="color:
#000000; "> DBTableColumn GENDER;
+ ...
+ </span><span style="color: #008000; ">//</span><span style="color:
#008000; "> Constructor for the table</span><span style="color: #008000; ">
+</span><span style="color: #000000; "> </span><span style="color: #0000FF;
">public</span><span style="color: #000000; "> Employees(DBDatabase db)
+ {
+ </span><span class="style3">super</span><span style="color: #000000;
">(</span><span class="style1">"EMPLOYEES</span><span style="color:
#000000; ">", db);
+ </span><span style="color: #008000; ">//</span><span style="color:
#008000; "> ID</span><span style="color: #008000; ">
+</span><span style="color: #000000; "> </span><span
class="style2">EMPLOYEE_ID</span><span style="color: #000000; "> </span><span
style="color: #000000; ">=</span><span style="color: #000000; ">
addColumn(</span><span class="style1">"EMPLOYEE_ID"</span><span
style="color: #000000; ">, </span>DataType.<span
class="style1">AUTOINC</span><span style="color: #000000; ">, 0</span><span
style="color: #000000; ">, </span><span class="style3">true</span><span
style="color: #000000; ">, </span><span
class="style1">"EMPLOYEE_ID_SEQUENCE</span><span style="color: #000000;
">");
+ </span><span class="style2">LASTNAME</span><span style="color: #000000;
"> </span><span style="color: #000000; ">=</span><span style="color:
#000000; "> addColumn(</span><span class="style1">"LASTNAME</span><span
style="color: #000000; ">", DataType.</span><span
class="style1">TEXT</span><span style="color: #000000; ">, 40</span><span
style="color: #000000; ">, </span><span class="style3">true</span><span
style="color: #000000; ">);
+ </span><span class="style2">GENDER</span><span style="color: #000000;
"> = addColumn(</span><span class="style1">"GENDER"</span><span
style="color: #000000; ">, DataType.</span><span
class="style1">TEXT</span><span style="color: #000000; ">, 1</span><span
style="color: #000000; ">, </span><span class="style3">false</span><span
style="color: #000000; ">);
+ ...
+ </span><span style="color: #008000; ">//</span><span style="color:
#008000; "> Primary key</span><span style="color: #008000; ">
+</span><span style="color: #000000; "> setPrimaryKey(EMPLOYEE_ID);
+ </span><span style="color: #008000; ">//</span><span style="color:
#008000; "> Set other indeces</span><span style="color: #008000; ">
+</span><span style="color: #000000; "> addIndex(</span><span
class="style1">"EMPLOYEE_NAME_IDX</span><span style="color: #000000;
">", </span><span class="style3">true</span><span style="color: #000000;
">,
+ </span><span class="style3">new</span><span style="color: #000000;
"> DBColumn[] { FIRSTNAME, LASTNAME, DATE_OF_BIRTH });
+ </span><span style="color: #008000; ">//</span><span style="color:
#008000; "> Set timestamp column to save updates</span><span style="color:
#008000; ">
+</span><span style="color: #000000; ">
setTimestampColumn(UPDATE_TIMESTAMP);
+
+ </span><span style="color: #008000; ">//</span><span style="color:
#008000; "> Create Options for GENDER column</span><span style="color: #008000;
">
+</span><span style="color: #000000; "> Options genders </span><span
style="color: #000000; ">=</span><span style="color: #000000; "> </span><span
class="style3">new</span><span style="color: #000000; "> Options();
+ genders.set(</span><span class="style1">"M</span><span
style="color: #000000; ">", </span><span
class="style1">"Male"</span><span style="color: #000000; ">);
+ genders.set(</span><span class="style1">"F"</span><span
style="color: #000000; ">, </span><span class="style1">"Female</span><span
style="color: #000000; ">");
+ GENDER.setOptions(genders);
+ }
+}</span></pre>
+ <p>In the constructor
of each table class we add
+ the columns and
assign the column object to a <i>
+ <b>public
final</b></i> field. This will allow
+ us to browse
and access the column objects
+ directly from
our source code.</p>
+ <p>Afterwards we set the primary key, add other indices
and set a
+ timestamp field which is internally used for optimistic
locking.</p>
+ <p>Finally additional column metadata is added here,
which could
+ however also be added elsewhere.</p>
+ <p>
+
<i>Naming convention note:</i> Since we
+ declare
all table and column objects as <i>
+
<b>public final</b></i> fields we write them
+ in all
upper-case letters. In order to
+
simplify browsing of these properties using
+ code
completion and get them all well
+ grouped
together you might as well
+
additionally add a prefix like T_ for tables
+ and C_
for columns, which we recommend but
+ have
not done in this example. It's up to
+ you
whether you want to stick to these
+
conventions or not.<br/>
+ </p>
+ <h1>Empire-db
SampleApp - Step by step</h1>
+ <p>
+ When
running the sample application the
+ entry
point is the main method found in SampleApp.java.
+ This
will perform the following steps:</p>
+ <h2>Step 1 â Step 3: Set up a database connection and
open the database</h2>
+ <p>
+ First
the application needs to open a database connection to the database server.
+ For
this a jdbcClass, jdbcURL, jdbcUser and jdbcPwd
+ must be
provided with the configuration
+ in
config.xml.
+ The
configuration file is parsed and read by
+ calling
<code>config.init()</code>. To use a different configuration file, this
filename can be
+ passed
to the main method as an argument.
+
Afterwards a JDBC connection is created.</p>
+
+<pre><span style="color: #000000; "></span><span style="color: #008000;
">//</span><span style="color: #008000; "> Init Configuration</span><span
style="color: #008000; ">
+</span><span style="color: #000000; ">config.init((args.length </span><span
style="color: #000000; ">></span><span style="color: #000000; ">
</span><span style="color: #000000; ">0</span><span style="color: #000000; ">
</span><span style="color: #000000; ">?</span><span style="color: #000000; ">
args[</span><span style="color: #000000; ">0</span><span style="color: #000000;
">] : </span><span class="style1">"config.xml"</span><span
style="color: #000000; ">));
+</span><font color="#008000">// STEP 1: Get a JDBC Connection</font><span
style="color: #000000; ">
+Connection conn = getJDBCConnection();</span></pre>
+ <p>
+ In step
two the sample creates and initializes
+ a
database driver object for the target
+ DBMS.
This is HSQLDB by default.
+ </p>
+
+<pre><font color="#008000">// STEP 2: Choose a driver</font><span
style="color: #008000; ">
+</span>DBDatabaseDriver driver = getDatabaseDriver(<font
color="#0000FF">config</font>.getDatabaseProvider());</pre>
+ <p>
+ Then in
+ step
three the database object is opened
+ using
the driver. Only when opened, other methods of the database
+ object
may be used. Finally we check whether or not our database objects
+
exist.</p>
+
+<pre><font color="#008000">// STEP 3: Open Database and check if tables
exist</font><span style="color: #008000; ">
+</span>db.open(driver, conn);
+databaseExists(conn);</pre>
+ <p>
+ In
order to check existence of the database the sample
+ simply
performs a query on the Departments
+ table
(<code>"select count(*) from DEPARTMENTS"</code>) using
+ the
following code:</p>
+
+<pre><span style="color: #000000; ">DBCommand cmd = db.createCommand();
+cmd.select(db.DEPARTMENTS.count());
+db.querySingleInt(cmd.getSelect(), -1, conn);</span></pre>
+
+ <p>If the
select
+ succeeds then
the database is assumed to exist
+ and step 4 is
skipped. Otherwise step 4 will create all database objects.</p>
+ <h2>Step 4 â Create a DDL script and the database
objects</h2>
+ <p>
+ Based
on the database definition in the class SampleDB.java a DDL
+ script
for the whole database is
+
generated for the creation of all tables, sequences, indices and relations.</p>
+
+<pre><font color="#008000">// create DLL for Database Definition
+</font>String ddlScript = db.getCreateDDLScript(driver);</pre>
+
+ <p>
+ Now the
individual DDL commands are extracted and
+
executed line by line using the driver's
+
<code>executeSQL()</code> method.</p>
+ <p>
+
<i>Note: </i>If you want to create or delete
+
individual database objects such as tables,
+ views,
columns and relations you can obtain
+ the
corresponding SQL by calling the driver's <code>
+
driver.getDDLCommand()</code> method.</p>
+ <h2>Step 5 â Delete data records</h2>
+ <p>
+ This
step empties the two tables of the database by deleting all
+ data
records:
+ </p>
+
+<pre><span style="color: #000000; ">DBCommand cmd </span><span style="color:
#000000; ">=</span><span style="color: #000000; "> db.createCommand();
+</span><span style="color: #008000; ">//</span><span style="color: #008000; ">
Delete all Employees (no constraints)</span><span style="color: #008000; ">
+</span><span style="color: #000000;
">db.executeSQL(cmd.getDelete(db.EMPLOYEES), conn);
+</span><span style="color: #008000; ">//</span><span style="color: #008000; ">
Delete all Departments (no constraints)</span><span style="color: #008000; ">
+</span><span style="color: #000000;
">db.executeSQL(cmd.getDelete(db.DEPARTMENTS), conn);</span></pre>
+
+ <h2>Step 6 â
Insert data records</h2>
+ <p>
+ In this
step we add sample records for both
+ the
Departments and Employees table.</p>
+ <p>
+ The
code used in the sample is virtually
+
equivalent to this:</p>
+
+<pre><span style="color: #008000; ">//</span><span style="color: #008000; ">
Insert a Department</span><span style="color: #008000; ">
+</span><span style="color: #000000; ">DBRecord rec </span><span style="color:
#000000; ">=</span><span style="color: #000000; "> </span><span style="color:
#0000FF; ">new</span><span style="color: #000000; "> DBRecord();
+rec.create(db.DEPARTMENTS);
+rec.setValue(db.DEPARTMENTS.NAME, </span><span
class="style1">"Development</span><span style="color: #000000; ">");
+rec.setValue(db.DEPARTMENTS.BUSINESS_UNIT, </span><span
class="style1">"ITTK"</span><span style="color: #000000; ">);
+rec.update(conn);
+</span><span class="style1">int</span> depId =
rec.getInt(db.DEPARTMENTS.DEPARTMENT_ID); <span style="color: #000000; ">
+
+</span><span style="color: #008000; ">//</span><span style="color: #008000; ">
Insert an Employee</span><span style="color: #008000; ">
+</span><span style="color: #000000; ">DBRecord rec </span><span style="color:
#000000; ">=</span><span style="color: #000000; "> </span><span style="color:
#0000FF; ">new</span><span style="color: #000000; "> DBRecord();
+rec.create(db.EMPLOYEES);
+rec.setValue(db.EMPLOYEES.FIRSTNAME, </span><span
class="style1">"Peter</span><span style="color: #000000; ">");
+rec.setValue(db.EMPLOYEES.LASTNAME, </span><span
class="style1">"Sharp"</span><span style="color: #000000; ">);
+rec.setValue(db.EMPLOYEES.GENDER, </span><span
class="style1">"M</span><span style="color: #000000; ">");
+rec.setValue(db.EMPLOYEES.DEPARTMENT_ID, </span><span style="color: #000000;
">depId</span><span style="color: #000000; ">);
+rec.update(conn);
+</span></pre>
+ <p>For the above code Empire-db generates
+ and executes the following insert statements:</p>
+
+<pre><span style="color: #0000FF; ">INSERT</span><span style="color: #000000;
"> </span><span style="color: #0000FF; ">INTO</span><span style="color:
#000000; "> DEPARTMENTS( DEPARTMENT_ID, NAME, BUSINESS_UNIT, UPDATE_TIMESTAMP)
+</span><span style="color: #0000FF; ">VALUES</span><span style="color:
#000000; "> ( </span><span style="color: #800000; font-weight: bold;
">2</span><span style="color: #000000; ">, </span><span style="color: #FF0000;
">'</span><span style="color: #FF0000; ">Development</span><span style="color:
#FF0000; ">'</span><span style="color: #000000; ">, </span><span style="color:
#FF0000; ">'</span><span style="color: #FF0000; ">ITTK</span><span
style="color: #FF0000; ">'</span><span style="color: #000000; ">, </span><span
style="color: #FF0000; ">'</span><span style="color: #FF0000; ">2008-01-08
07:31:11.120</span><span style="color: #FF0000; ">'</span><span style="color:
#000000; ">)
+
+</span><span style="color: #0000FF; ">INSERT</span><span style="color:
#000000; "> </span><span style="color: #0000FF; ">INTO</span><span
style="color: #000000; "> EMPLOYEES( EMPLOYEE_ID, FIRSTNAME, LASTNAME,
DEPARTMENT_ID, GENDER, RETIRED, UPDATE_TIMESTAMP)
+</span><span style="color: #0000FF; ">VALUES</span><span style="color:
#000000; "> ( </span><span style="color: #800000; font-weight: bold;
">1</span><span style="color: #000000; ">, </span><span style="color: #FF0000;
">'</span><span style="color: #FF0000; ">Peter</span><span style="color:
#FF0000; ">'</span><span style="color: #000000; ">, </span><span style="color:
#FF0000; ">'</span><span style="color: #FF0000; ">Sharp</span><span
style="color: #FF0000; ">'</span><span style="color: #000000; ">, </span><span
style="color: #800000; font-weight: bold; ">1</span><span style="color:
#000000; ">, </span><span style="color: #FF0000; ">'</span><span style="color:
#FF0000; ">M</span><span style="color: #FF0000; ">'</span><span style="color:
#000000; ">, </span><span style="color: #800000; font-weight: bold;
">0</span><span style="color: #000000; ">, </span><span style="color: #FF0000;
">'</span><span style="color: #FF0000; ">2008-01-08 07:31:11.151</span><span
style="color: #FF0000; ">'
</span><span style="color: #000000; ">)
+</span></pre>
+ <p>
+ The
database driver creates the ID values
+
automatically using either sequences
+
provided by the target DBMS or by using a
+ special
internal table for sequence number
+
generation. The decision how sequence
+ numbers
are generated is the responsibility
+ of the
DBDatabaseDriver used.</p>
+ <p>
+ If an
update timestamp field has been
+
declared for the
+ table,
it is automatically managed by
+
Empire-db and used for optimistic locking.</p>
+
+ <h2>Step 7 â
Update data records</h2>
+ <p>
+ Step
seven demonstrates how to update records.
+ The
following code gives an example of how to update
+ an
employee's phone number.
+ </p>
+
+<pre><span style="color: #008000; ">//</span><span style="color: #008000; ">
Update an Employee</span><span style="color: #008000; ">
+</span><span style="color: #000000; ">DBRecord rec </span><span style="color:
#000000; ">=</span><span style="color: #000000; "> </span><span style="color:
#0000FF; ">new</span><span style="color: #000000; "> DBRecord();
+rec.read(db.EMPLOYEES, idPers, conn);
+rec.setValue(db.EMPLOYEES.PHONE_NUMBER, </span><span
class="style1">"+49-7531-457160"</span><span style="color: #000000;
">);
+rec.update(conn);</span></pre>
+
+ <p>For this
code Empire-db generates the following
+ update
statement:</p>
+
+<pre><span style="color: #0000FF; ">UPDATE</span><span style="color: #000000;
"> EMPLOYEES
+</span><span style="color: #0000FF; ">SET</span><span style="color: #000000;
"> PHONE_NUMBER</span><span style="color: #808080; ">=</span><span
style="color: #FF0000; ">'</span><span style="color: #FF0000;
">+49-7531-457160</span><span style="color: #FF0000; ">'</span><span
style="color: #000000; ">,
+ UPDATE_TIMESTAMP</span><span style="color: #808080; ">=</span><span
style="color: #FF0000; ">'</span><span style="color: #FF0000; ">2008-01-08
07:31:11.183</span><span style="color: #FF0000; ">'</span><span style="color:
#000000; ">
+</span><span style="color: #0000FF; ">WHERE</span><span style="color: #000000;
"> EMPLOYEE_ID</span><span style="color: #808080; ">=</span><span style="color:
#800000; font-weight: bold; ">1</span><span style="color: #000000; ">
</span><span style="color: #808080; ">AND</span><span style="color: #000000; ">
UPDATE_TIMESTAMP</span><span style="color: #808080; ">=</span><span
style="color: #FF0000; ">'</span><span style="color: #FF0000; ">2008-01-08
07:31:11.150</span><span style="color: #FF0000; ">'</span><span style="color:
#000000; "></span></pre>
+ <p>Important
issues to notice:</p>
+ <ol>
+ <li>
+
Only changed fields are updated in the database.
+
You may check the modification status of
+
the record or an individual field at any
+
time and react on it if necessary.</li>
+ <li>The
update timestamp is generated automatically.
+ By
using a constraint on the timestamp
+ column,
Empire-db
+ checks
whether the record has been
+
concurrently changed by another user. </li>
+ <li>
+
You may extend the DBRecord by creating
+
special entity record classes for your
+
database entities. This will not only
+
provide further type-safety but also
+
allows you to add new methods or
+
override existing ones for custom
+
behaviour.</li>
+ </ol>
+
+ <h2>Step 8 â
Perform a query and access the
+ results</h2>
+ <p>
+
Finally, this step shows how to perform a
+
database query and how to access the query
+
results.</p>
+ <p>
+ For
our example we query some
+
employee fields from the database. The
+
LASTNAME and FIRSTNAME fields are
+
concatenated to provide us with the full
+ name of
the employee. Additionally we join
+ the
Departments table in order to
+
retrieve the name of the department an employee
+ belongs
to. Finally we add constraints and
+ the
order in which we want the data to be
+
supplied from the DBMS.</p>
+ <p>
+ In
order to create this statement we need a DBCommand object. This can be obtained
from
+ our
database object. The command object
+ offers
methods whose names match those of the SQL keywords select, where,
+ group
by, having and order by. There is no
+ need to
specify which table we want to
+ access
our data from. However joins must be
+
manually declared using the join() method.
+ The
final code looks as follows:</p>
+
+<pre><span style="color: #008000; ">//</span><span style="color: #008000; ">
Define the query</span><span style="color: #008000; ">
+</span><span style="color: #000000; ">DBCommand cmd </span><span style="color:
#000000; ">=</span><span style="color: #000000; "> db.createCommand();
+DBColumnExpr EMPLOYEE_FULLNAME</span><span style="color: #000000;
">=</span><span style="color: #000000; ">
db.EMPLOYEES.LASTNAME.append(</span><span style="color: #000000;
">"</span><span style="color: #000000; ">, </span><span style="color:
#000000; ">"</span><span style="color: #000000; ">)
+ .append(db.EMPLOYEES.FIRSTNAME).as(</span><span
style="color: #000000; ">"</span><span style="color: #000000;
">FULL_NAME</span><span style="color: #000000; ">"</span><span
style="color: #000000; ">);
+</span><span style="color: #008000; ">//</span><span style="color: #008000; ">
Select required columns</span><span style="color: #008000; ">
+</span><span style="color: #000000; ">cmd.select(db.EMPLOYEES.EMPLOYEE_ID,
EMPLOYEE_FULLNAME);
+cmd.select(db.EMPLOYEES.GENDER, db.EMPLOYEES.PHONE_NUMBER);
+cmd.select(db.DEPARTMENTS.NAME.as(</span><span style="color: #000000;
">"</span><span style="color: #000000; ">DEPARTMENT</span><span
style="color: #000000; ">"</span><span style="color: #000000; ">));
+cmd.select(db.DEPARTMENTS.BUSINESS_UNIT);
+</span><span style="color: #008000; ">//</span><span style="color: #008000; ">
Set Joins</span><span style="color: #008000; ">
+</span><span style="color: #000000; ">cmd.join(db.EMPLOYEES.DEPARTMENT_ID,
db.DEPARTMENTS.DEPARTMENT_ID);
+</span><span style="color: #008000; ">//</span><span style="color: #008000; ">
Set contraints and order</span><span style="color: #008000; ">
+</span><span style="color: #000000;
">cmd.where(EMP.LASTNAME.length().isGreaterThan(</span><span style="color:
#000000; ">0</span><span style="color: #000000; ">));
+cmd.orderBy(EMP.LASTNAME);</span></pre>
+ <p>This
will then generate the following SQL
+ select
statement:</p>
+
+<pre><span style="color: #0000FF; ">SELECT</span><span style="color: #000000;
"> t2.EMPLOYEE_ID, t2.LASTNAME </span><span style="color: #808080;
">+</span><span style="color: #000000; "> </span><span style="color: #FF0000;
">'</span><span style="color: #FF0000; ">, </span><span style="color: #FF0000;
">'</span><span style="color: #000000; "> </span><span style="color: #808080;
">+</span><span style="color: #000000; "> t2.FIRSTNAME </span><span
style="color: #0000FF; ">AS</span><span style="color: #000000; "> FULL_NAME,
t2.GENDER, t2.PHONE_NUMBER,
+ t1.NAME </span><span style="color: #0000FF; ">AS</span><span style="color:
#000000; "> DEPARTMENT, t1.BUSINESS_UNIT
+</span><span style="color: #0000FF; ">FROM</span><span style="color: #000000;
"> EMPLOYEES t2 </span><span style="color: #0000FF; ">INNER</span><span
style="color: #000000; "> </span><span style="color: #0000FF;
">JOIN</span><span style="color: #000000; "> DEPARTMENTS t1 </span><span
style="color: #0000FF; ">ON</span><span style="color: #000000; ">
t1.DEPARTMENT_ID </span><span style="color: #808080; ">=</span><span
style="color: #000000; "> t2.DEPARTMENT_ID
+</span><span style="color: #0000FF; ">WHERE</span><span style="color: #000000;
"> </span><span style="color: #FF00FF; ">len</span><span style="color: #000000;
">(t2.LASTNAME)</span><span style="color: #808080; ">></span><span
style="color: #800000; font-weight: bold; ">0</span><span style="color:
#000000; ">
+</span><span style="color: #0000FF; ">ORDER</span><span style="color: #000000;
"> t2.LASTNAME</span></pre>
<p>Important
+ issues
+ to notice:</p>
+ <ol>
+ <li>
+
As you can see, except for column
+
renaming, no string literals are
+
necessary to create the query. This
+
ensures maximum compile-time safety. The
+
code is also portable and not tied to a
+
particular DBMS.
+ </li>
+ <li>
+
Constraints for filtering can easily be
+
added using the command's <code>where()</code> method,
+
which may be called any
+
number of times. This allows to easily
+
add constraints conditionally without affecting code
+
readability as with string operations.
+ </li>
+ <li>
+ When
creating your command all required
+ table
and column objects as well as SQL
+
functions can easily be added using the
+
IDE's code completion, which always gives you
+ a
selection of available objects. This
+
prevents you from making typing mistakes and improves
+ your
productivity.</li>
+ </ol>
+ <p>
+ Finally
we need to execute the query and
+ print
our query results. For the latter we
+ show
three different options for doing this:</p>
+ <ol>
+ <li>
+
Iterating through the results row by
+
row.</li>
+ <li>
+
Fetching a list of JavaBean / POJO
+
objects each containing the data of one
+
result row. For this we will use the SampleBean
+
class whose properties match
+
the query result (see SampleBean.java).</li>
+ <li>
+
Obtaining an XML document element that
+
contains the query results and even
+
includes column metadata.</li>
+ </ol>
+
<p>Option 1: This code shows how to iterate
+ and
print the results row by row:</p>
+
+<pre><font color="#008000">// Open the reader using command object
+</font><span style="color: #000000; ">DBReader reader = </span><span
style="color: #0000FF; ">new</span><span style="color: #000000; "> DBReader();
+</span>reader.open(cmd, conn);
+<font color="#008000">// Text-Output by iterating through all records.
+</font>while (reader.moveNext()) {
+ System.out.println(reader.getString(EMP.EMPLOYEE_ID)
+ + "\t" + reader.getString(EMPLOYEE_FULLNAME)
+ + "\t" +
EMP.GENDER.getOptions().get(reader.getString(EMP.GENDER))
+ + "\t" + reader.getString(DEP.NAME));
+}</pre>
+
<p>Option 2: This code shows how to fetch a
+ list of
sample beans:</p>
+
+<pre><font color="#008000">// Open the reader using command object
+</font><span style="color: #000000; ">DBReader reader = </span><span
style="color: #0000FF; ">new</span><span style="color: #000000; "> DBReader();
+</span>reader.open(cmd, conn);
+<font color="#008000">// Text-Output using a list of Java Beans supplied by
the DBReader
+</font>List<SampleBean> beanList = reader.getBeanList(SampleBean.class);
+for (SampleBean b : beanList) {
+ System.out.println(b.toString());
+}</pre>
+
<p>Option 3: To obtain the result as
+ an XML
document the following code is required:</p>
+ <pre><span style="color: #008000; ">// Open reader
+</span><span style="color: #000000; ">DBReader reader = </span><span
style="color: #0000FF; ">new</span><span style="color: #000000; "> DBReader();
+reader.open(cmd, conn);
+</span><span style="color: #008000; ">// XML output
+</span><span style="color: #000000; ">Document doc = reader.getXmlDocument();
+</span><span style="color: #008000; ">// Print XML document to System.out
+</span><span style="color: #000000; ">XMLWriter.debug(doc);</span></pre>
+ <p>
+ The XML
document obtained by the above code
+ looks
like this:
+ </p>
+
+<pre><span style="color: #0000FF; "><</span><span style="color: #800000;
">rowset</span><span style="color: #0000FF; ">></span><span style="color:
#000000; ">
+ </span><span style="color: #0000FF; "><</span><span style="color:
#800000; ">column </span><span style="color: #FF0000; ">key</span><span
style="color: #0000FF; ">="1"</span><span style="color: #FF0000; ">
mandatory</span><span style="color: #0000FF; ">="1"</span><span
style="color: #FF0000; "> name</span><span style="color: #0000FF;
">="EMPLOYEE_ID"</span><span style="color: #0000FF;
">></</span><span style="color: #800000; ">column</span><span
style="color: #0000FF; ">></span><span style="color: #000000; ">
+ </span><span style="color: #0000FF; "><</span><span style="color:
#800000; ">column </span><span style="color: #FF0000; ">mandatory</span><span
style="color: #0000FF; ">="1"</span><span style="color: #FF0000; ">
name</span><span style="color: #0000FF; ">="FULL_NAME"</span><span
style="color: #FF0000; "> size</span><span style="color: #0000FF;
">="40"</span><span style="color: #0000FF; ">></</span><span
style="color: #800000; ">column</span><span style="color: #0000FF;
">></span><span style="color: #000000; ">
+ </span><span style="color: #0000FF; "><</span><span style="color:
#800000; ">column </span><span style="color: #FF0000; ">name</span><span
style="color: #0000FF; ">="GENDER"</span><span style="color: #FF0000;
"> size</span><span style="color: #0000FF; ">="1"</span><span
style="color: #0000FF; ">></span><span style="color: #000000; ">
+ </span><span style="color: #0000FF; "><</span><span style="color:
#800000; ">option </span><span style="color: #FF0000; ">value</span><span
style="color: #0000FF; ">="M"</span><span style="color: #0000FF;
">></span><span style="color: #000000; ">Male</span><span style="color:
#0000FF; "></</span><span style="color: #800000; ">option</span><span
style="color: #0000FF; ">></span><span style="color: #000000; ">
+ </span><span style="color: #0000FF; "><</span><span style="color:
#800000; ">option </span><span style="color: #FF0000; ">value</span><span
style="color: #0000FF; ">="F"</span><span style="color: #0000FF;
">></span><span style="color: #000000; ">Female</span><span style="color:
#0000FF; "></</span><span style="color: #800000; ">option</span><span
style="color: #0000FF; ">></span><span style="color: #000000; ">
+ </span><span style="color: #0000FF; "></</span><span style="color:
#800000; ">column</span><span style="color: #0000FF; ">></span><span
style="color: #000000; ">
+ </span><span style="color: #0000FF; "><</span><span style="color:
#800000; ">column </span><span style="color: #FF0000; ">name</span><span
style="color: #0000FF; ">="PHONE_NUMBER"</span><span style="color:
#FF0000; "> size</span><span style="color: #0000FF;
">="40"</span><span style="color: #0000FF; ">></</span><span
style="color: #800000; ">column</span><span style="color: #0000FF;
">></span><span style="color: #000000; ">
+ </span><span style="color: #0000FF; "><</span><span style="color:
#800000; ">column </span><span style="color: #FF0000; ">mandatory</span><span
style="color: #0000FF; ">="1"</span><span style="color: #FF0000; ">
name</span><span style="color: #0000FF; ">="DEPARTMENT"</span><span
style="color: #FF0000; "> size</span><span style="color: #0000FF;
">="80"</span><span style="color: #0000FF; ">></</span><span
style="color: #800000; ">column</span><span style="color: #0000FF;
">></span><span style="color: #000000; ">
+ </span><span style="color: #0000FF; "><</span><span style="color:
#800000; ">column </span><span style="color: #FF0000; ">mandatory</span><span
style="color: #0000FF; ">="1"</span><span style="color: #FF0000; ">
name</span><span style="color: #0000FF;
">="BUSINESS_UNIT"</span><span style="color: #FF0000; ">
size</span><span style="color: #0000FF; ">="4"</span><span
style="color: #0000FF; ">></</span><span style="color: #800000;
">column</span><span style="color: #0000FF; ">></span><span style="color:
#000000; ">
+ </span><span style="color: #0000FF; "><</span><span style="color:
#800000; ">row</span><span style="color: #0000FF; ">></span><span
style="color: #000000; ">
+ </span><span style="color: #0000FF; "><</span><span style="color:
#800000; ">EMPLOYEE_ID</span><span style="color: #0000FF; ">></span><span
style="color: #000000; ">41</span><span style="color: #0000FF;
"></</span><span style="color: #800000; ">EMPLOYEE_ID</span><span
style="color: #0000FF; ">></span><span style="color: #000000; ">
+ </span><span style="color: #0000FF; "><</span><span style="color:
#800000; ">FULL_NAME</span><span style="color: #0000FF; ">></span><span
style="color: #000000; ">Bloggs, Fred</span><span style="color: #0000FF;
"></</span><span style="color: #800000; ">FULL_NAME</span><span
style="color: #0000FF; ">></span><span style="color: #000000; ">
+ </span><span style="color: #0000FF; "><</span><span style="color:
#800000; ">GENDER</span><span style="color: #0000FF; ">></span><span
style="color: #000000; ">M</span><span style="color: #0000FF;
"></</span><span style="color: #800000; ">GENDER</span><span style="color:
#0000FF; ">></span><span style="color: #000000; ">
+ </span><span style="color: #0000FF; "><</span><span style="color:
#800000; ">PHONE_NUMBER</span><span style="color: #0000FF; ">></span><span
style="color: #000000; ">+49-5555-505050</span><span style="color: #0000FF;
"></</span><span style="color: #800000; ">PHONE_NUMBER</span><span
style="color: #0000FF; ">></span><span style="color: #000000; ">
+ </span><span style="color: #0000FF; "><</span><span style="color:
#800000; ">DEPARTMENT</span><span style="color: #0000FF; ">></span><span
style="color: #000000; ">Development</span><span style="color: #0000FF;
"></</span><span style="color: #800000; ">DEPARTMENT</span><span
style="color: #0000FF; ">></span><span style="color: #000000; ">
+ </span><span style="color: #0000FF; "><</span><span style="color:
#800000; ">BUSINESS_UNIT</span><span style="color: #0000FF; ">></span><span
style="color: #000000; ">ITTK</span><span style="color: #0000FF;
"></</span><span style="color: #800000; ">BUSINESS_UNIT</span><span
style="color: #0000FF; ">></span><span style="color: #000000; ">
+ </span><span style="color: #0000FF; "></</span><span style="color:
#800000; ">row</span><span style="color: #0000FF; ">></span><span
style="color: #000000; ">
+ </span><span style="color: #0000FF; "><</span><span style="color:
#800000; ">row</span><span style="color: #0000FF; ">></span><span
style="color: #000000; ">
+ </span><span style="color: #0000FF; "><</span><span style="color:
#800000; ">EMPLOYEE_ID</span><span style="color: #0000FF; ">></span><span
style="color: #000000; ">40</span><span style="color: #0000FF;
"></</span><span style="color: #800000; ">EMPLOYEE_ID</span><span
style="color: #0000FF; ">></span><span style="color: #000000; ">
+ </span><span style="color: #0000FF; "><</span><span style="color:
#800000; ">FULL_NAME</span><span style="color: #0000FF; ">></span><span
style="color: #000000; ">Sharp, Peter</span><span style="color: #0000FF;
"></</span><span style="color: #800000; ">FULL_NAME</span><span
style="color: #0000FF; ">></span><span style="color: #000000; ">
+ </span><span style="color: #0000FF; "><</span><span style="color:
#800000; ">GENDER</span><span style="color: #0000FF; ">></span><span
style="color: #000000; ">M</span><span style="color: #0000FF;
"></</span><span style="color: #800000; ">GENDER</span><span style="color:
#0000FF; ">></span><span style="color: #000000; ">
+ </span><span style="color: #0000FF; "><</span><span style="color:
#800000; ">PHONE_NUMBER</span><span style="color: #0000FF; ">></span><span
style="color: #000000; ">+49-7531-457160</span><span style="color: #0000FF;
"></</span><span style="color: #800000; ">PHONE_NUMBER</span><span
style="color: #0000FF; ">></span><span style="color: #000000; ">
+ </span><span style="color: #0000FF; "><</span><span style="color:
#800000; ">DEPARTMENT</span><span style="color: #0000FF; ">></span><span
style="color: #000000; ">Development</span><span style="color: #0000FF;
"></</span><span style="color: #800000; ">DEPARTMENT</span><span
style="color: #0000FF; ">></span><span style="color: #000000; ">
+ </span><span style="color: #0000FF; "><</span><span style="color:
#800000; ">BUSINESS_UNIT</span><span style="color: #0000FF; ">></span><span
style="color: #000000; ">ITTK</span><span style="color: #0000FF;
"></</span><span style="color: #800000; ">BUSINESS_UNIT</span><span
style="color: #0000FF; ">></span><span style="color: #000000; ">
+ </span><span style="color: #0000FF; "></</span><span style="color:
#800000; ">row</span><span style="color: #0000FF; ">></span><span
style="color: #000000; ">
+ </span><span style="color: #0000FF; "><</span><span style="color:
#800000; ">row</span><span style="color: #0000FF; ">></span><span
style="color: #000000; ">
+ </span><span style="color: #0000FF; "><</span><span style="color:
#800000; ">EMPLOYEE_ID</span><span style="color: #0000FF; ">></span><span
style="color: #000000; ">42</span><span style="color: #0000FF;
"></</span><span style="color: #800000; ">EMPLOYEE_ID</span><span
style="color: #0000FF; ">></span><span style="color: #000000; ">
+ </span><span style="color: #0000FF; "><</span><span style="color:
#800000; ">FULL_NAME</span><span style="color: #0000FF; ">></span><span
style="color: #000000; ">White, Emma</span><span style="color: #0000FF;
"></</span><span style="color: #800000; ">FULL_NAME</span><span
style="color: #0000FF; ">></span><span style="color: #000000; ">
+ </span><span style="color: #0000FF; "><</span><span style="color:
#800000; ">GENDER</span><span style="color: #0000FF; ">></span><span
style="color: #000000; ">F</span><span style="color: #0000FF;
"></</span><span style="color: #800000; ">GENDER</span><span style="color:
#0000FF; ">></span><span style="color: #000000; ">
+ </span><span style="color: #0000FF; "><</span><span style="color:
#800000; ">PHONE_NUMBER</span><span style="color: #0000FF; ">></span><span
style="color: #000000; ">+49-040-125486</span><span style="color: #0000FF;
"></</span><span style="color: #800000; ">PHONE_NUMBER</span><span
style="color: #0000FF; ">></span><span style="color: #000000; ">
+ </span><span style="color: #0000FF; "><</span><span style="color:
#800000; ">DEPARTMENT</span><span style="color: #0000FF; ">></span><span
style="color: #000000; ">Sale</span><span style="color: #0000FF;
"></</span><span style="color: #800000; ">DEPARTMENT</span><span
style="color: #0000FF; ">></span><span style="color: #000000; ">
+ </span><span style="color: #0000FF; "><</span><span style="color:
#800000; ">BUSINESS_UNIT</span><span style="color: #0000FF; ">></span><span
style="color: #000000; ">ITTK</span><span style="color: #0000FF;
"></</span><span style="color: #800000; ">BUSINESS_UNIT</span><span
style="color: #0000FF; ">></span><span style="color: #000000; ">
+ </span><span style="color: #0000FF; "></</span><span style="color:
#800000; ">row</span><span style="color: #0000FF; ">></span><span
style="color: #000000; ">
+</span><span style="color: #0000FF; "></</span><span style="color: #800000;
">rowset</span><span style="color: #0000FF; ">></span></pre>
+ <p>
+ This XML can easily be transformed to another syntax by
applying
+ XSLT transformations. The metadata supplied here can be
crucial for
+ these transformations. Besides the metadata provided
here even more and custom metadata may easily be
+ added through column attributes.</p>
+
+ <h1>Download the code of this sample</h1>
+ <p> We hope you have enjoyed this tutorial and you now feel
+ confident that using Empire-db is simple and smart. If you have
not
+ already done so, you may now download and run the sample
application,
+ and play around with it.<br />
+ <a href="#">Download</a></p>
+ <!-- #EndEditable --></div>
+
+ <div id="nav">
+ <hr />
+ <div id="nav_prev">
+ <a id="prev" href=""><img
src="../images/prev.gif" alt="" /> Previous Page</a>
+
+ </div>
+ <div id="nav_next">
+
+ <a id="next" href="">Next Page <img
src="../images/next.gif" alt="" /></a>
+ </div>
+ <div style="clear: both;"></div>
+ </div>
+
+ <script type="text/javascript">
+ /* <![CDATA[ */
+ if( ( typeof(prev_page) == "undefined" ||
prev_page == "" ) &&
+ ( typeof(next_page) == "undefined" ||
next_page == "" ) )
+ {
+ $( 'nav' ).hide();
+ }
+ else
+ {
+ if( typeof(prev_page) != "undefined" &&
prev_page != "" ) {
+ $( 'prev' ).href = prev_page;
+ $( 'prev' ).show();
+ }
+ else {
+ $( 'prev' ).hide();
+ }
+
+ if( typeof(next_page) != "undefined" &&
next_page !="" ) {
+ $( 'next' ).href = next_page;
+ $( 'next' ).show();
+ }
+ else {
+ $( 'next' ).hide();
+ }
+ }
+ /* ]]> */
+ </script>
+
+ </div>
+
+ </div>
+
+ <!-- Footer -->
+ <div id="footer">
+ <div class="cr"><small>Copyright © 2008-2021, The Apache
Software Foundation</small></div>
+ <div class="tm"><small>Apache Empire-db, Empire-db, Apache, the
Apache feather logo, and the Apache Empire-db project logo are trademarks of
The Apache Software Foundation</small></div>
+ </div>
+
+</div>
+
+</body>
+<!-- #EndTemplate -->
+</html>
\ No newline at end of file
Propchange: empire-db/site/legacy/documentation/tutorial.htm
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: empire-db/site/legacy/downloads/latest.htm
URL:
http://svn.apache.org/viewvc/empire-db/site/legacy/downloads/latest.htm?rev=1898936&view=auto
==============================================================================
--- empire-db/site/legacy/downloads/latest.htm (added)
+++ empire-db/site/legacy/downloads/latest.htm Mon Mar 14 20:41:26 2022
@@ -0,0 +1,337 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-gb" lang="en-gb"
xmlns:o="urn:schemas-microsoft-com:office:office"
xmlns:v="urn:schemas-microsoft-com:vml" >
+<!-- #BeginTemplate "../main.dwt" -->
+<head>
+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+ <meta http-equiv="language" content="en" />
+ <meta name="robots" content="index, follow" />
+ <meta name="keywords" content="java, jar, jdbc, sql, data, metadata,
persistence, rdbms, orm, mapping" />
+ <meta name="description" content="Open Source relational data
persistence component." />
+
+ <!-- #BeginEditable "doctitle" -->
+<title>Empire-db - Downloads</title>
+ <!-- #EndEditable -->
+
+ <script type="text/javascript" src="../js/prototype.js"></script>
+ <script type="text/javascript" src="../js/menu.js"></script>
+ <!-- #BeginEditable "javascripts" -->
+ <!-- #EndEditable -->
+
+ <link rel="shortcut icon" href="../empire-db.ico" />
+ <link rel="stylesheet" href="../css/layout.css" type="text/css" />
+ <!-- #BeginEditable "stylesheets" -->
+<style type="text/css">
+
+
+
+
+table.downloads {
+ margin-left: 80px;
+ width: 600px;
+}
+
+table.downloads th {
+ white-space: nowrap;
+}
+
+table.downloads td {
+ white-space: nowrap;
+}
+
+table.downloads td.md5 {
+ text-align: center;
+}
+td.right {
+ text-align: right;
+}
+div.dependency {
+ padding-left: 80px;
+ width: 600px;
+}
+div.dependency pre {
+ margin: 0;
+}
+pre span.tag {
+ color: #0000FF;
+}
+</style>
+ <!-- #EndEditable -->
+</head>
+
+<body>
+<div id="wrapper">
+
+ <!-- Header -->
+ <div id="header">
+ <div id="logo">
+ <img src="../images/logos/empire-db-logo.gif"
alt="Empire-db: The relational data persistence component." />
+ </div>
+ <div id="asf">
+ <a id="asfhome" target="_blank"
href="https://www.apache.org"><img src="../images/logos/feather-small.gif"
alt="The Apache Software Foundation" /></a>
+ <label for="asfhome" >The Apache Software
Foundation</label>
+ </div>
+ <div style="clear:both"></div>
+ </div>
+
+ <!-- Top -->
+ <div id="top">
+ <div id="topbar"> </div>
+ </div>
+
+ <!-- Middle -->
+ <div id="middle">
+ <div id="left">
+ <div id="menuBox">
+ <ul id="mainMenu">
+ <li id="menu_home"><a
href="../index.html">Home</a></li>
+ <li id="menu_news"><a
href="../news.htm">News</a></li>
+ <li id="menu_empiredb"><a
href="../empiredb/empiredb.htm">Empire-db</a>
+ <ul
class="subMenu">
+ <li
id="menu_empiredb_extending_pattern"><a href="../empiredb/pattern.htm">The
Empire DAO-<br />pattern</a></li>
+ <li
id="menu_empiredb_handling_metadata"><a
href="../empiredb/metadata.htm">Handling data and metadata</a></li>
+ <li
id="menu_empiredb_wrong"><a href="../empiredb/hibernate.htm">What's wrong with
Hibernate and JPA</a></li>
+ <li
id="menu_empiredb_stringfree"><a href="../empiredb/stringfree.htm">The
principle of<br/>string-free coding</a></li>
+ <li
id="menu_empiredb_faq"><a href="../empiredb/faq.htm">FAQ</a></li>
+ </ul>
+ </li>
+ <li id="menu_struts2ext"><a
href="../struts2ext/struts2ext.htm">Empire-db and Struts2</a>
+ <ul class="subMenu">
+ <li
id="menu_struts2ext_forms_controls"><a
href="../struts2ext/forms_controls.htm">Forms and controls</a></li>
+ <li
id="menu_struts2ext_rendering_parsing"><a
href="../struts2ext/rendering_parsing.htm">Rendering and parsing</a></li>
+ <!--<li
id="menu_struts2ext_tag_reference"><a href="struts2ext/tag_reference.htm">Tag
reference</a></li>-->
+ <li
id="menu_struts2ext_input_controls"><a
href="../struts2ext/input_controls.htm">Input controls</a></li>
+ </ul>
+ </li>
+ <li id="menu_downloads"><a
href="latest.htm">Downloads</a>
+ <ul
class="subMenu">
+ <li
id="menu_downloads_previous"><a href="previous.htm">Previous releases</a></li>
+ <li
id="menu_downloads_license"><a href="license.htm">License</a></li>
+ </ul>
+ </li>
+ <li id="menu_documentation"><a
href="../documentation/documentation.htm">Documentation</a>
+ <ul class="subMenu">
+ <li
id="menu_documentation_class_overview"><a
href="../documentation/class_overview.htm">Empire-db class<br
/>overview</a></li>
+ <li
id="menu_documentation_tutorials"><a
href="../documentation/tutorial.htm">Tutorial</a></li>
+ <li
id="menu_documentation_getting_started"><a
href="../documentation/getting_started.htm">Getting started</a></li>
+ <li
id="menu_documentation_reverse_engineering"><a
href="../documentation/reverse_engineering.htm">Reverse Engineering</a></li>
+ <li
id="menu_documentation_api"><a href="../documentation/api.htm">API</a></li>
+ </ul>
+ </li>
+ <li id="menu_community"><a
href="../community/community.htm">Community</a>
+ <ul class="subMenu">
+ <li
id="menu_community_mailing_lists"><a
href="../community/mailing_lists.htm">Mailing lists</a></li>
+ <li
id="menu_community_source_code"><a href="../community/source_code.htm">Source
code</a></li>
+ <li
id="menu_community_jira"><a href="../community/jira.htm">Ticketing &
Wiki</a></li>
+ <!--<li
id="menu_community_road_map"><a href="community/road_map.htm">Road
map</a></li>-->
+ <li
id="menu_community_contributors"><a
href="../community/contributors.htm">Contributors</a></li>
+ </ul>
+ </li>
+ <li id="menu_apache"><a
href="../apache.htm">About Apache</a>
+ <ul class="subMenu">
+ <li
id="menu_apache_home"><a href="https://www.apache.org">Apache home<span
class="asflink"> </span></a></li>
+ <li
id="menu_apache_donate"><a
href="https://www.apache.org/foundation/sponsorship.html">Sponsorship<span
class="asflink"> </span></a></li>
+ <li
id="menu_apache_thanks"><a
href="https://www.apache.org/foundation/thanks.html">Foundation thanks<span
class="asflink"> </span></a></li>
+ <li
id="menu_apache_security"><a
href="https://www.apache.org/security/">Security<span
class="asflink"> </span></a></li>
+ </ul>
+ </li>
+ <li id="menu_disclaimer"><a
href="https://www.apache.org/licenses/">License<span
class="asflink"> </span></a></li>
+ </ul>
+ </div>
+
+ </div>
+
+ <!-- #BeginEditable "menu" -->
+ <script type="text/javascript">
+ var menu = new Menu( 'mainMenu', 'menu_downloads' );
+ </script>
+ <!-- #EndEditable -->
+ <script type="text/javascript">
+ /* <![CDATA[ */
+ if( menu ) {
+ // Menu fully opened (comment out if not wanted)
+ // menu.openAll();
+ /* ]]> */
+ }
+ </script>
+
+ <div id="main">
+
+ <div id="pathway">
+ <span style="float:left">
+ <!-- #BeginEditable "pathway" -->
+ Downloads
+ <!-- #EndEditable -->
+ </span>
+ <a id="downloadLink" href="latest.htm"
style="float:right">Download</a>
+ </div>
+
+ <div id="content">
+ <!-- #BeginEditable "content" -->
+ <!--<h1>Downloads</h1>-->
+ <h1>License & Disclaimer</h1>
+ <p>Releases of Apache Empire-db are made available to
the general
+ public at no charge, under the <a
href="https://apache.org/licenses/" target="_blank">
+ Apache License</a>.</p>
+
+ <h1>Apache-Empire-db 2.5.1</h1>
+ <p>This is our latest release of
<strong>22/Jan/2022</strong></p>
+ <table class="downloads">
+ <colgroup>
+ <col width="150px" />
+ <col width="99%" />
+ <col width="60px" align="right" />
+ <col width="60px" />
+ <col width="60px" />
+ </colgroup>
+ <thead>
+ <tr><th align="left">Description</th>
+ <th align="left">File</th>
+ <th align="center">Size</th>
+ <th>PGP</th>
+ <th>SHA256</th></tr>
+ </thead>
+ <tbody>
+ <tr>
+ <td
rowspan="2">combined<br/>source & binary</td>
+ <td><a
href="https://www.apache.org/dyn/closer.lua/empire-db/2.5.1/apache-empire-db-2.5.1-dist.tar.gz">apache-empire-db-2.5.1-dist.tar.gz</a></td>
+ <td class="right">4.3 MB</td>
+ <td class="md5"><a
href="https://downloads.apache.org/empire-db/2.5.1/apache-empire-db-2.5.1-dist.tar.gz.asc"
target="_blank"><img src="../images/key.gif"/></a></td>
+ <td class="md5"><a
href="https://downloads.apache.org/empire-db/2.5.1/apache-empire-db-2.5.1-dist.tar.gz.sha256"
target="_blank"><img src="../images/key.gif"/></a></td>
+ </tr>
+ <tr>
+ <td><a
href="https://www.apache.org/dyn/closer.lua/empire-db/2.5.1/apache-empire-db-2.5.1-dist.zip">apache-empire-db-2.5.1-dist.zip</a></td>
+ <td class="right">5.0 MB</td>
+ <td class="md5"><a
href="https://downloads.apache.org/empire-db/2.5.1/apache-empire-db-2.5.1-dist.zip.asc"
target="_blank"><img src="../images/key.gif"/></a></td>
+ <td class="md5"><a
href="https://downloads.apache.org/empire-db/2.5.1/apache-empire-db-2.5.1-dist.zip.sha256"
target="_blank"><img src="../images/key.gif"/></a></td>
+ </tr>
+ </tbody>
+ </table>
+
+ <p>In order to build and run the examples we recommend
using
+ <a href="https://maven.apache.org/"
target="_blank">Apache Maven</a>.</p>
+
+ <h1>Verifying downloads</h1>
+ <p style="line-height:1.4em">We recommend that you
verify the integrity of the downloaded files using the PGP or SHA
signatures.<br/>
+ The PGP signatures can be verified using PGP or GPG
after downloading the <strong><a
href="https://downloads.apache.org/empire-db/KEYS">KEYS</a></strong> file.
+ We recommend that you use a web of trust, if possible
to confirm the identity of these keys. For more information, please see the
Apache Release FAQ.</p>
+
+ <h1>Maven</h1>
+ <p>To use <strong>Apache empire-db</strong> in your
project add the
+ following dependency to your project's pom file:</p>
+ <div class="dependency">
+ <pre><span class="tag"> <dependency></span>
+<span class="tag"> <groupId></span>org.apache.empire-db<span
class="tag"></groupId></span>
+ <span class="tag"><artifactId></span>empire-db<span
class="tag"></artifactId></span>
+ <span class="tag"><version></span>2.5.1<span
class="tag"></version>
+ </dependency></span></pre>
+ </div>
+
+ <p>To use <strong>Apache empire-db-struts2
extensions</strong> in your project
+ add the following dependency to you project's pom
file:</p>
+ <div class="dependency">
+ <pre class="dependency"><span class="tag">
<dependency></span>
+<span class="tag"> <groupId></span>org.apache.empire-db<span
class="tag"></groupId></span>
+ <span class="tag"><artifactId></span>empire-db-struts2<span
class="tag"></artifactId></span>
+ <span class="tag"><version></span>2.5.1<span
class="tag"></version>
+ </dependency></span></pre>
+ </div>
+
+ <p>To use <strong>Apache empire-db-jsf2
extensions</strong> in your project
+ add the following dependency to you project's pom
file:</p>
+ <div class="dependency">
+ <pre class="dependency"><span class="tag">
<dependency></span>
+<span class="tag"> <groupId></span>org.apache.empire-db<span
class="tag"></groupId></span>
+ <span class="tag"><artifactId></span>empire-db-jsf2<span
class="tag"></artifactId></span>
+ <span class="tag"><version></span>2.5.1<span
class="tag"></version>
+ </dependency></span></pre>
+ </div>
+
+ <p>To use <strong>Apache empire-db-spring
extensions</strong> in your project
+ add the following dependency to you project's pom
file:</p>
+ <div class="dependency">
+ <pre class="dependency"><span class="tag">
<dependency></span>
+<span class="tag"> <groupId></span>org.apache.empire-db<span
class="tag"></groupId></span>
+ <span class="tag"><artifactId></span>empire-db-spring<span
class="tag"></artifactId></span>
+ <span class="tag"><version></span>2.5.1<span
class="tag"></version>
+ </dependency></span></pre>
+ </div>
+
+
+ <h1>Previous versions</h1>
+ <p>To download previous version of Apache Empire-db <a
href="previous.htm">click here!</a></p>
+
+ <!--<h1>API Specifications</h1>
+
+ <table class="downloads">
+ <thead>
+ <tr><th
class="package">Package</th><th>Version</th><th>Release date</th><th>Size</th>
+ <th
class="comment">Comment</th><th>MD5</th></tr>
+ </thead>
+ <tbody>
+ <tr><td><a
href="Empire-db-API.zip">Empire-db-API.zip</a></td><td>1.0</td><td>21.12.2007</td><td>627
KB</td><td></td><td class="md5"><a href="md5checksums.html"><img
src="../images/md5.gif" alt="MD5" /></a></td></tr>
+ <tr><td><a
href="Empire-db-API.zip">EmpireStruts2Ext-API.zip</a></td><td>1.0</td><td>21.12.2007</td><td>627
KB</td><td></td><td class="md5"><a href="md5checksums.html"><img
src="../images/md5.gif" alt="MD5" /></a></td></tr>
+ </tbody>
+ </table>-->
+
+ <script type="text/javascript">
+ $('downloadLink').hide();
+ </script>
+
+ <!-- #EndEditable --></div>
+
+ <div id="nav">
+ <hr />
+ <div id="nav_prev">
+ <a id="prev" href=""><img
src="../images/prev.gif" alt="" /> Previous Page</a>
+
+ </div>
+ <div id="nav_next">
+
+ <a id="next" href="">Next Page <img
src="../images/next.gif" alt="" /></a>
+ </div>
+ <div style="clear: both;"></div>
+ </div>
+
+ <script type="text/javascript">
+ /* <![CDATA[ */
+ if( ( typeof(prev_page) == "undefined" ||
prev_page == "" ) &&
+ ( typeof(next_page) == "undefined" ||
next_page == "" ) )
+ {
+ $( 'nav' ).hide();
+ }
+ else
+ {
+ if( typeof(prev_page) != "undefined" &&
prev_page != "" ) {
+ $( 'prev' ).href = prev_page;
+ $( 'prev' ).show();
+ }
+ else {
+ $( 'prev' ).hide();
+ }
+
+ if( typeof(next_page) != "undefined" &&
next_page !="" ) {
+ $( 'next' ).href = next_page;
+ $( 'next' ).show();
+ }
+ else {
+ $( 'next' ).hide();
+ }
+ }
+ /* ]]> */
+ </script>
+
+ </div>
+
+ </div>
+
+ <!-- Footer -->
+ <div id="footer">
+ <div class="cr"><small>Copyright © 2008-2021, The Apache
Software Foundation</small></div>
+ <div class="tm"><small>Apache Empire-db, Empire-db, Apache, the
Apache feather logo, and the Apache Empire-db project logo are trademarks of
The Apache Software Foundation</small></div>
+ </div>
+
+</div>
+
+</body>
+<!-- #EndTemplate -->
+</html>
\ No newline at end of file
Propchange: empire-db/site/legacy/downloads/latest.htm
------------------------------------------------------------------------------
svn:mime-type = text/plain