You are viewing a plain text version of this content. The canonical link for it is here.
Posted to ojb-dev@db.apache.org by ar...@apache.org on 2003/08/08 16:57:41 UTC
cvs commit: db-ojb/xdocs jdbc-types.xml howto-build-mappings.xml
arminw 2003/08/08 07:57:40
Modified: xdocs jdbc-types.xml howto-build-mappings.xml
Log:
update by Brian McCallister
Revision Changes Path
1.8 +11 -10 db-ojb/xdocs/jdbc-types.xml
Index: jdbc-types.xml
===================================================================
RCS file: /home/cvs/db-ojb/xdocs/jdbc-types.xml,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- jdbc-types.xml 6 Jan 2003 14:09:20 -0000 1.7
+++ jdbc-types.xml 8 Aug 2003 14:57:40 -0000 1.8
@@ -1,4 +1,5 @@
<?xml version="1.0"?>
+<!-- @version $Id$ -->
<document>
<properties>
@@ -127,12 +128,12 @@
</table>
</section>
-<section name="defining type- and value conversions">
+<section name="Defining type and value conversions">
-<subsection name="introduction">
+<subsection name="Introduction">
<P>
- A typical problem with O/R tools are mismatching datatypes: a
- class of the domain model has an attribute of type boolean but the
+ A typical problem with O/R tools is mismatching datatypes: a
+ class from the domain model has an attribute of type boolean but the
corresponding database table stores this attribute in a column of
type bit or int.
</P>
@@ -147,10 +148,10 @@
</P>
</subsection>
-<subsection name="the problem">
+<subsection name="The problem">
<P>
- The test class org.apache.ojb.broker.Article contains an attribute
- isSelloutArticle of type boolean:
+ The test class <code>org.apache.ojb.broker.Article</code> contains an attribute
+ <code>isSelloutArticle</code> of type boolean:
</P>
<source><![CDATA[
@@ -187,7 +188,7 @@
]]></source>
</subsection>
-<subsection name="the solution">
+<subsection name="The Solution">
<P>
OJB allows to use predefined (or self-written) FieldConversions that do
the appropiate mapping. The <code>FieldConversion</code> interface declares two
@@ -228,8 +229,8 @@
</P>
<P>
- The method sqlToJava is a callback that is called within the OJB broker
- when Object attributes are read in from JDBC resultsets.
+ The method <code>FieldConversion.sqlToJava()</code> is a callback that is called
+ within the OJB broker when Object attributes are read in from JDBC result sets.
If OJB detects that a FieldConversion is declared for a persistent classes
attributes, it uses the FieldConversion to do the marshalling of this attribute.
</P>
1.4 +120 -110 db-ojb/xdocs/howto-build-mappings.xml
Index: howto-build-mappings.xml
===================================================================
RCS file: /home/cvs/db-ojb/xdocs/howto-build-mappings.xml,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- howto-build-mappings.xml 28 Jul 2003 21:17:12 -0000 1.3
+++ howto-build-mappings.xml 8 Aug 2003 14:57:40 -0000 1.4
@@ -1,4 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
+<!-- @version $Id$ -->
<document>
<properties>
@@ -11,12 +12,12 @@
<section name="How to build O/R mapping files">
<p>
Writing the repository.xml file for only a few classes
- can easily be done manually with a text- or xml-editor of your choice.
- <br/>
+ can easily be done manually with the text or xml editor of your choice.
+</p><p>
But keeping the repository in sync with the java codebase and the database
gets more difficult if several hundred classes and large developer teams
are involved.
- <br/>
+</p><p>
This page contains tips how to integrate mapping tools and code-generators
into your build process.
</p>
@@ -24,74 +25,75 @@
<section name="classification of O/R related transformations">
<p>
- Let's start with a classification of the source transformation problems
+ Let's start with a classification of the source transformation problems
that developers have to face in an O/R environment.
-
- Typical developments environments contain some or all of the following
+</p>
+<p>
+ Typical development environments contain some or all of the following
artefacts:
<ul>
<li>
- An UML model containing at least class diagrams of the persistent classes.
+ A UML model containing at least class diagrams of the persistent classes.
All modern UML tools can export to the XMI standard format.
</li>
<li>
- Other tools like Torque also have a model based approach
+ Other tools, such as Torque, also use a model based approach
but use different model file formats (typically XML based)
</li>
<li>
- Java source code for the persistent classes.
+ Java source code for the persistent classes.
The Java source code can possibly be enhanced with xdoclet tags.
</li>
<li>
- The OJB repository.xml file. This file contains all the
+ The OJB repository.xml file. This file contains all the
class-descriptors for the persistent classes.
</li>
<li>
- The database. could be an online DB or a DDL script representing
+ The database. This could be an online DB or a DDL script representing
the database tables. The database contains all tables used to
- store instance of the persistent classes.
+ store instances of the persistent classes.
</li>
</ul>
-
- It depends a lot on the problem you have to solve, on the methodoly and
- the tool chain you have in use, which of transformations between those
- artefacts fit to your development process.
+
+ The technique you will use depends a lot on the problem you have to solve, on
+ the methodology and the tool chain you have in use, which of transformations
+ between those artefacts fit to your development process.
<ol>
<li>
- <b>Forward engineering from XMI:</b> An UML model in XMI format with class diagrams of your
+ <b>Forward engineering from XMI:</b> A UML model in XMI format with class diagrams of your
persistent classes exists and is used as the master source (model
driven approach).
- Java code, repository.xml and DDL for the database tables have to
- be generated from this model.
+ Java code, repository.xml and DDL for the database tables have to
+ be generated from this model.
</li>
<li>
- <b>Forward engineering from Torque:</b> A model of the persistent entity classes exists
+ <b>Forward engineering from Torque:</b> A model of the persistent entity classes exists
in form of a Torque.XML file.
- Java code, repository.xml and DDL for the database tables have to
- be generated from this model.
+ Java code, repository.xml and DDL for the database tables have to
+ be generated from this model.
</li>
<li>
- <b>Forward engineering from repository.xml:</b>
+ <b>Forward engineering from the repository.xml:</b>
The OJB repository.xml file is used a model format.
- Java code and DDL for the database tables have to
- be generated from this model.
+ Java code and DDL for the database tables have to
+ be generated from this model.
</li>
<li>
<b>Xdoclet transformation from Java code:</b>
Java code for the persistent classes exists and contains special
comment tags in the Xdoclet ojb-module format.
- Repository.xml and DDL for the database tables have to
- be generated from the java files via Xdoclet transformation.
+ Repository.xml and DDL for the database tables have to
+ be generated from the java files via Xdoclet transformation.
</li>
<li>
<b>Reverse engineering from database:</b>
There is a database with existing tables or a DDL script.
- Java code and repository.xml have to
- be generated from the database.
+ Java code and repository.xml have to
+ be generated from the database.
</li>
</ol>
-
+
These transformations are depicted in the following graphics. The numbers close
to the arrows correspond to the numbers in the above enumeration.
All related transformations have the same colour.
@@ -111,95 +113,102 @@
and have to deal with a large number of persistent classes.
This approach works best when there are no restrictions regarding the database,
like integration of legacy tables.
- Forward engineering from XMI fits perfectly into a model driven architecture (MDA)
+ </p>
+ <p>
+ Forward engineering from XMI fits perfectly into a model driven architecture (MDA)
software development process.
</p>
<p><b>Tool support</b><br/>
<ul>
<li>
<a href="http://axgen.sf.net"><b>AXGen</b></a><br/>
- AXgen is a code generator using XMI as input and Velocity templates for transformation.
- <br/>
- The power of AXgen is in its simplicity.
- You don't have to understand complicated structure of your XMI file to write an
- XSLT stylsheet for transformation. AXgen uses nsuml to deal with the xmi file,
- which gives access to the Metamodel in an objectoriented way.
- <br/>
- Further AXgen makes use of Jakartas Velocity.
- Velocity is a very sophisticated Java-based template engine.
- This means that inside your templates you can call Java methods.
- Feel free to write templates that generate anything you want.
+ AXgen is a code generator using XMI as input and Velocity templates for transformation.
+ <br/>
+ The power of AXgen is in its simplicity.
+ You don't have to understand complicated structure of your XMI file to write an
+ XSLT stylsheet for transformation. AXgen uses nsuml to deal with the xmi file,
+ which gives access to the Metamodel in an objectoriented way.
<br/>
- Our motive for AXgen is to generate Java Classes for use in a O/R Mapping
- tool that allows transparent persistence for Java Objects against relational databases.
- Therefore AXgen comes with a bundle of ready to use templates for generating
- ObJectRelationalBridge (OJB) specific stuff like: <br/>
- * Entity Classes<br/>
- * XML Repository<br/>
- * SQL script to build the DB scheme
+ Further AXgen makes use of Jakartas Velocity.
+ Velocity is a very sophisticated Java-based template engine.
+ This means that inside your templates you can call Java methods.
+ Feel free to write templates that generate anything you want.
+ <br/>
+ Our motive for AXgen is to generate Java Classes for use in a O/R Mapping
+ tool that allows transparent persistence for Java Objects against relational databases.
+ Therefore AXgen comes with a bundle of ready to use templates for generating
+ ObJectRelationalBridge (OJB) specific stuff like:
+ <ul>
+ <li>Entity Classes</li>
+ <li>XML Repository</li>
+ <li>SQL script to build the DB scheme</li>
+ </ul>
</li>
<li>
<a href="http://andromda.sf.net"><b>AndroMDA</b></a><br/>
- AndroMDA is a code generator framework - it takes a Unified Modeling Language
- (UML) model from a CASE-tool in XMI format and generates custom components.
- It comes with a set of sample templates that generate classes attributed with
- XDoclet tags. One build step later, the XDoclet tool generates full-blown components
- that can readily be deployed in the JBoss application server (and the other servers
+ AndroMDA is a code generator framework - it takes a Unified Modeling Language
+ (UML) model from a CASE-tool in XMI format and generates custom components.
+ It comes with a set of sample templates that generate classes attributed with
+ XDoclet tags. One build step later, the XDoclet tool generates full-blown components
+ that can readily be deployed in the JBoss application server (and the other servers
that XDoclet can feed).<br/>
<img src="images/andromda.jpg"/>
<br/>
Currently AndroMDA provides no special support for OJB. But by tagging
- classes with tags of the <a href="#Xdoclet transformation from Java code">XDoclet OJB module</a>
- it is possible to use
- it as a full forward engineering engine.
+ classes with tags of the <a href="#Xdoclet transformation from Java code">XDoclet
+ OJB module</a> it is possible to use it as a full forward engineering engine.
</li>
<li>
- Searching the Sourceforge project list for "XMI"
+ Searching the Sourceforge project list for "XMI"
returns a long list of projects dealing with code generation.
It may be a good idea to check if you find a tool that matches your requirements.
</li>
-
+
</ul>
</p>
</section>
<section name="Forward engineering from Torque">
<p>
- <a href="http://db.apache.org/torque/"><b>Torque</b></a><br/>
- Torque is a persistence layer. Torque includes a generator to generate all
- the database resources required by your application and includes a runtime
- environment to run the generated classes.<br/>
-
- Torque was developed as part of the Turbine Framework.
- It is now decoupled and can be used by itself.
- Starting with version 2.2 Turbine uses the decoupled Torque.<br/>
-
- Torque uses a single XML database schema to generate the SQL for your target database
- and Torque's Peer-based object relation model representing your XML database schema.<br/>
-
- You can use <a href="http://www.devaki.org/">devaki-nextobjects</a> to
- create the model for your application.<br/>
-
- OJB uses Torques generator engine to setup the testbed database and feed it with
- initial data.<br/>
-
+ <a href="http://db.apache.org/torque/"><b>Torque</b></a><br/>
+ Torque is a persistence layer. Torque includes a generator to generate all
+ the database resources required by your application and includes a runtime
+ environment to run the generated classes.
+ </p>
+ <p>
+ Torque was developed as part of the Turbine Framework.
+ It is now decoupled and can be used by itself.
+ Starting with version 2.2 Turbine uses the decoupled Torque.
+ </p>
+ <p>
+ Torque uses a single XML database schema to generate the SQL for your target database
+ and Torque's Peer-based object relation model representing your XML database schema.
+ </p>
+ <p>
+ You can use <a href="http://www.devaki.org/">devaki-nextobjects</a> to
+ create the model for your application.
+ </p>
+ <p>
+ OJB uses Torque's generator engine to setup the testbed database and feed it with
+ initial data.
+ </p>
+ <p>
Besides the SQL generation facilities Torque also provides special support for OJB
- related transformations. It provides the following two ant targets:
+ related transformations. It provides the following two ant targets:
<ul>
<li>
- <strong>ojb-model</strong>
- <br/>
+ <strong>ojb-model</strong>
+ <br/>
generates a simple object model for ojb
- </li>
+ </li>
<li>
-
- <strong>ojb-repository</strong>
- <br/>
- generates the repository for ojb
- </li>
+ <strong>ojb-repository</strong>
+ <br/>
+ generates the repository for ojb
+ </li>
</ul>
- A complete list of all availableTorque targets can be found
- <a href="http://db.apache.org/torque/generator/">here</a>
+ A complete list of all availableTorque targets can be found at the
+ <a href="http://db.apache.org/torque/generator/">Torque Generator site</a>.
</p>
</section>
@@ -208,37 +217,40 @@
<p>
There is currently no tool available that directly supports this model.
It is not difficult to implement an XSLT stylesheet that transforms
- the OJB repository.xml directly into DDL Statements.<br/>
+ the OJB repository.xml directly into DDL Statements.
+ </p>
+ <p>
An even simpler approach could be to transform the repository.xml file into
a Torque xml file. DDL can then be generated by the Torque engine.<br/>
- If you write such an XSLT file please tell us about it!
+ If you write such an XSLT file please tell us about it!
</p>
</section>
<section name="Xdoclet transformation from Java code">
<p>
<a href="http://xdoclet.sf.net"><b>XDoclet</b></a><br/>
- XDoclet is a code generation engine. It enables Attribute-Oriented Programming for java.
- In short, this means that you can add more significance to your code by adding meta data
- (attributes) to your java sources. This is done in special JavaDoc tags.<br/>
-
- XDoclet will parse your source files and generate many artifacts such as XML descriptors
- and/or source code from it. These files are generated from templates that use the information
- provided in the source code and its JavaDoc tags. <br/>
-
- XDoclet lets you apply Continuous Integration in component-oriented development.
- Developers should concentrate their editing work on only one Java source file per component.<br/>
-
- XDoclet originated as a tool for creating EJBs, it has evolved
- into a general-purpose code generation engine. XDoclet consists of a core
- and a constantly growing number of modules.
+ XDoclet is a code generation engine. It enables Attribute-Oriented Programming for java.
+ In short, this means that you can add more significance to your code by adding meta data
+ (attributes) to your java sources. This is done in special JavaDoc tags.
+ </p>
+ <p>
+ XDoclet will parse your source files and generate many artifacts such as XML descriptors
+ and/or source code from it. These files are generated from templates that use the information
+ provided in the source code and its JavaDoc tags.
+ </p>
+ <p>
+ XDoclet lets you apply Continuous Integration in component-oriented development.
+ Developers should concentrate their editing work on only one Java source file per component.
+ </p>
+ <p>
+ XDoclet originated as a tool for creating EJBs, it has evolved
+ into a general-purpose code generation engine. XDoclet consists of a core
+ and a constantly growing number of modules.
There is an existing OJB module which is currently part of the OJB contribution package.
This module will be integrated into the regular XDoclet distribution.
A complete documentation is shipped with the module.
-
</p>
-
</section>
<section name="Reverse engineering from database">
@@ -259,7 +271,7 @@
and provides the same functionality (and also some additional goodies).
It ships as a plugin to the Eclipse IDE.
It provides a very convenient GUI that integrates smoothly into the Eclipse platform.
- </li>
+ </li>
<li>
<a href="http://sourceforge.net/projects/rdbs2j"><b>RDBS2J</b></a><br/>
RDBS2J is a GUI based mapping tool from relational database scheme to
@@ -267,14 +279,12 @@
The mapping can be modified by the GUI.<br/>
The current version is designed to create code for OJB.<br/>
The ODMG and the JDO interface are supported. RDBS2J creates the
- *.jdo and the repository_user.xml, which is needed by OJB.
+ *.jdo files and the repository_user.xml, which are needed by OJB.
</li>
</ul>
</p>
</section>
-
-
</body>
</document>
---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-dev-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-dev-help@db.apache.org