You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cayenne.apache.org by nt...@apache.org on 2017/02/01 13:23:49 UTC

[01/10] cayenne git commit: CAY-2215 split cayenne-tools into cayenne-cgen and cayenne-ant

Repository: cayenne
Updated Branches:
  refs/heads/master 660dd4b28 -> c63b6be2f


http://git-wip-us.apache.org/repos/asf/cayenne/blob/c63b6be2/cayenne-tools/src/test/resources/testmap.map.xml
----------------------------------------------------------------------
diff --git a/cayenne-tools/src/test/resources/testmap.map.xml b/cayenne-tools/src/test/resources/testmap.map.xml
deleted file mode 100644
index 60b94a6..0000000
--- a/cayenne-tools/src/test/resources/testmap.map.xml
+++ /dev/null
@@ -1,744 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<data-map xmlns="http://cayenne.apache.org/schema/3.0/modelMap"
-	 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
-	 xsi:schemaLocation="http://cayenne.apache.org/schema/3.0/modelMap http://cayenne.apache.org/schema/3.0/modelMap.xsd"
-	 project-version="6">
-	<property name="defaultPackage" value="org.apache.cayenne.testdo.testmap"/>
-	<property name="defaultSuperclass" value="org.apache.cayenne.CayenneDataObject"/>
-	<property name="clientSupported" value="true"/>
-	<property name="defaultClientPackage" value="test.client"/>
-	<property name="defaultClientSuperclass" value="org.apache.cayenne.PersistentObject"/>
-	<procedure name="cayenne_tst_out_proc">
-		<procedure-parameter name="in_param" type="INTEGER" direction="in"/>
-		<procedure-parameter name="out_param" type="INTEGER" direction="out"/>
-	</procedure>
-	<procedure name="cayenne_tst_select_proc">
-		<procedure-parameter name="aName" type="VARCHAR" length="254" direction="in"/>
-		<procedure-parameter name="paintingPrice" type="INTEGER" direction="in"/>
-	</procedure>
-	<procedure name="cayenne_tst_upd_proc">
-		<procedure-parameter name="paintingPrice" type="INTEGER" direction="in"/>
-	</procedure>
-	<procedure name="cayenne_tst_upd_proc2">
-	</procedure>
-	<db-entity name="ARRAYS_ENTITY">
-		<db-attribute name="BYTE_ARRAY" type="VARBINARY" length="200"/>
-		<db-attribute name="BYTE_WRAPPER_ARRAY" type="VARBINARY" length="200"/>
-		<db-attribute name="CHAR_ARRAY" type="VARCHAR" length="200"/>
-		<db-attribute name="CHAR_WRAPPER_ARRAY" type="VARCHAR" length="200"/>
-		<db-attribute name="ID" type="INTEGER" isPrimaryKey="true" isMandatory="true"/>
-	</db-entity>
-	<db-entity name="ARTGROUP">
-		<db-attribute name="GROUP_ID" type="INTEGER" isPrimaryKey="true" isMandatory="true"/>
-		<db-attribute name="NAME" type="VARCHAR" isMandatory="true" length="100"/>
-		<db-attribute name="PARENT_GROUP_ID" type="INTEGER"/>
-	</db-entity>
-	<db-entity name="ARTIST">
-		<db-attribute name="ARTIST_ID" type="BIGINT" isPrimaryKey="true" isMandatory="true"/>
-		<db-attribute name="ARTIST_NAME" type="CHAR" isMandatory="true" length="254"/>
-		<db-attribute name="DATE_OF_BIRTH" type="DATE"/>
-	</db-entity>
-	<db-entity name="ARTIST_CT">
-		<db-attribute name="ARTIST_ID" type="INTEGER" isPrimaryKey="true" isMandatory="true"/>
-		<db-attribute name="ARTIST_NAME" type="CHAR" isMandatory="true" length="254"/>
-		<db-attribute name="DATE_OF_BIRTH" type="DATE"/>
-	</db-entity>
-	<db-entity name="ARTIST_EXHIBIT">
-		<db-attribute name="ARTIST_ID" type="BIGINT" isPrimaryKey="true" isMandatory="true"/>
-		<db-attribute name="EXHIBIT_ID" type="INTEGER" isPrimaryKey="true" isMandatory="true"/>
-	</db-entity>
-	<db-entity name="ARTIST_GROUP">
-		<db-attribute name="ARTIST_ID" type="BIGINT" isPrimaryKey="true" isMandatory="true"/>
-		<db-attribute name="GROUP_ID" type="INTEGER" isPrimaryKey="true" isMandatory="true"/>
-	</db-entity>
-	<db-entity name="BIGDECIMAL_ENTITY">
-		<db-attribute name="BIGDECIMAL_FIELD" type="NUMERIC" length="12" scale="2"/>
-		<db-attribute name="ID" type="INTEGER" isPrimaryKey="true" isMandatory="true"/>
-	</db-entity>
-	<db-entity name="BIGINTEGER_ENTITY">
-		<db-attribute name="BIG_INTEGER_FIELD" type="BIGINT"/>
-		<db-attribute name="ID" type="INTEGER" isPrimaryKey="true" isMandatory="true"/>
-	</db-entity>
-	<db-entity name="BINARY_PK_TEST1">
-		<db-attribute name="BIN_ID" type="VARBINARY" isPrimaryKey="true" isMandatory="true" length="32"/>
-		<db-attribute name="NAME" type="VARCHAR" length="10"/>
-	</db-entity>
-	<db-entity name="BINARY_PK_TEST2">
-		<db-attribute name="DETAIL_NAME" type="VARCHAR" length="10"/>
-		<db-attribute name="FK_ID" type="VARBINARY" length="32"/>
-		<db-attribute name="ID" type="INTEGER" isPrimaryKey="true" isMandatory="true"/>
-	</db-entity>
-	<db-entity name="BIT_TEST">
-		<db-attribute name="BIT_COLUMN" type="BIT" isMandatory="true"/>
-		<db-attribute name="ID" type="INTEGER" isPrimaryKey="true" isMandatory="true"/>
-	</db-entity>
-	<db-entity name="BLOB_TEST">
-		<db-attribute name="BLOB_COL" type="BLOB"/>
-		<db-attribute name="BLOB_TEST_ID" type="INTEGER" isPrimaryKey="true" isMandatory="true"/>
-	</db-entity>
-	<db-entity name="BOOLEAN_TEST">
-		<db-attribute name="BOOLEAN_COLUMN" type="BOOLEAN" isMandatory="true"/>
-		<db-attribute name="ID" type="INTEGER" isPrimaryKey="true" isMandatory="true"/>
-	</db-entity>
-	<db-entity name="CALENDAR_TEST">
-		<db-attribute name="CALENDAR_FIELD" type="TIMESTAMP"/>
-		<db-attribute name="ID" type="INTEGER" isPrimaryKey="true" isMandatory="true"/>
-	</db-entity>
-	<db-entity name="CHARACTER_ENTITY">
-		<db-attribute name="CHARACTER_FIELD" type="CHAR" length="1"/>
-		<db-attribute name="ID" type="INTEGER" isPrimaryKey="true" isMandatory="true"/>
-	</db-entity>
-	<db-entity name="CHAR_FK_TEST">
-		<db-attribute name="FK_COL" type="CHAR" length="10"/>
-		<db-attribute name="NAME" type="VARCHAR" length="100"/>
-		<db-attribute name="PK" type="INTEGER" isPrimaryKey="true" isMandatory="true"/>
-	</db-entity>
-	<db-entity name="CHAR_PK_TEST">
-		<db-attribute name="OTHER_COL" type="CHAR" length="10"/>
-		<db-attribute name="PK_COL" type="CHAR" isPrimaryKey="true" isMandatory="true" length="10"/>
-	</db-entity>
-	<db-entity name="CLOB_TEST">
-		<db-attribute name="CLOB_COL" type="CLOB"/>
-		<db-attribute name="CLOB_TEST_ID" type="INTEGER" isPrimaryKey="true" isMandatory="true"/>
-	</db-entity>
-	<db-entity name="CLOB_TEST_RELATION">
-		<db-attribute name="ID" type="INTEGER" isPrimaryKey="true" isMandatory="true"/>
-		<db-attribute name="ID_CLOB" type="INTEGER" isMandatory="true"/>
-		<db-attribute name="VALUE" type="INTEGER"/>
-	</db-entity>
-	<db-entity name="COMPOUND_FK_TEST">
-		<db-attribute name="F_KEY1" type="VARCHAR" length="20"/>
-		<db-attribute name="F_KEY2" type="VARCHAR" length="20"/>
-		<db-attribute name="NAME" type="VARCHAR" length="255"/>
-		<db-attribute name="PKEY" type="INTEGER" isPrimaryKey="true" isMandatory="true"/>
-	</db-entity>
-	<db-entity name="COMPOUND_PK_TEST">
-		<db-attribute name="KEY1" type="VARCHAR" isPrimaryKey="true" isMandatory="true" length="20"/>
-		<db-attribute name="KEY2" type="VARCHAR" isPrimaryKey="true" isMandatory="true" length="20"/>
-		<db-attribute name="NAME" type="VARCHAR" length="255"/>
-	</db-entity>
-	<db-entity name="DATE_TEST">
-		<db-attribute name="DATE_COLUMN" type="DATE"/>
-		<db-attribute name="DATE_TEST_ID" type="INTEGER" isPrimaryKey="true" isMandatory="true"/>
-		<db-attribute name="TIMESTAMP_COLUMN" type="TIMESTAMP"/>
-		<db-attribute name="TIME_COLUMN" type="TIME"/>
-	</db-entity>
-	<db-entity name="DECIMAL_PK_TST">
-		<db-attribute name="DECIMAL_PK" type="DECIMAL" isPrimaryKey="true" isMandatory="true"/>
-		<db-attribute name="NAME" type="VARCHAR" length="100"/>
-	</db-entity>
-	<db-entity name="ENUM_ENTITY">
-		<db-attribute name="ENUM_ATTRIBUTE" type="VARCHAR" length="250"/>
-		<db-attribute name="ID" type="INTEGER" isPrimaryKey="true" isMandatory="true"/>
-	</db-entity>
-	<db-entity name="EXHIBIT">
-		<db-attribute name="CLOSING_DATE" type="TIMESTAMP" isMandatory="true"/>
-		<db-attribute name="EXHIBIT_ID" type="INTEGER" isPrimaryKey="true" isMandatory="true"/>
-		<db-attribute name="GALLERY_ID" type="INTEGER" isMandatory="true"/>
-		<db-attribute name="OPENING_DATE" type="TIMESTAMP" isMandatory="true"/>
-	</db-entity>
-	<db-entity name="EXTENDED_TYPE_TEST">
-		<db-attribute name="ID" type="INTEGER" isPrimaryKey="true" isMandatory="true"/>
-		<db-attribute name="NAME" type="VARCHAR" length="200"/>
-	</db-entity>
-	<db-entity name="FLOAT_TEST">
-		<db-attribute name="FLOAT_COL" type="FLOAT"/>
-		<db-attribute name="ID" type="INTEGER" isPrimaryKey="true" isMandatory="true"/>
-	</db-entity>
-	<db-entity name="GALLERY">
-		<db-attribute name="GALLERY_ID" type="INTEGER" isPrimaryKey="true" isMandatory="true"/>
-		<db-attribute name="GALLERY_NAME" type="VARCHAR" isMandatory="true" length="100"/>
-	</db-entity>
-	<db-entity name="GENERATED_COLUMN_COMP_KEY">
-		<db-attribute name="AUTO_PK" type="INTEGER" isPrimaryKey="true" isMandatory="true"/>
-		<db-attribute name="GENERATED_COLUMN" type="INTEGER" isPrimaryKey="true" isGenerated="true" isMandatory="true"/>
-		<db-attribute name="NAME" type="VARCHAR" length="100"/>
-		<db-attribute name="PROPAGATED_PK" type="INTEGER" isPrimaryKey="true" isMandatory="true"/>
-	</db-entity>
-	<db-entity name="GENERATED_COLUMN_COMP_M">
-		<db-attribute name="ID" type="INTEGER" isPrimaryKey="true" isMandatory="true"/>
-		<db-attribute name="NAME" type="VARCHAR" length="100"/>
-	</db-entity>
-	<db-entity name="GENERATED_COLUMN_DEP">
-		<db-attribute name="GENERATED_COLUMN_FK" type="INTEGER" isPrimaryKey="true" isMandatory="true"/>
-		<db-attribute name="NAME" type="VARCHAR" length="100"/>
-	</db-entity>
-	<db-entity name="GENERATED_COLUMN_TEST">
-		<db-attribute name="GENERATED_COLUMN" type="INTEGER" isPrimaryKey="true" isGenerated="true" isMandatory="true"/>
-		<db-attribute name="NAME" type="VARCHAR" length="250"/>
-	</db-entity>
-	<db-entity name="GENERATED_COLUMN_TEST2">
-		<db-attribute name="GENERATED_COLUMN" type="INTEGER" isPrimaryKey="true" isGenerated="true" isMandatory="true"/>
-		<db-attribute name="NAME" type="VARCHAR" length="100"/>
-	</db-entity>
-	<db-entity name="GENERATED_F1">
-		<db-attribute name="ID" type="INTEGER" isPrimaryKey="true" isMandatory="true"/>
-	</db-entity>
-	<db-entity name="GENERATED_F2">
-		<db-attribute name="ID" type="INTEGER" isPrimaryKey="true" isMandatory="true"/>
-	</db-entity>
-	<db-entity name="GENERATED_JOIN">
-		<db-attribute name="ID" type="INTEGER" isPrimaryKey="true" isGenerated="true" isMandatory="true"/>
-		<db-attribute name="ID1" type="INTEGER"/>
-		<db-attribute name="ID2" type="INTEGER"/>
-	</db-entity>
-	<db-entity name="LONG_ENTITY">
-		<db-attribute name="ID" type="INTEGER" isPrimaryKey="true" isMandatory="true"/>
-		<db-attribute name="LONG_FIELD" type="BIGINT"/>
-	</db-entity>
-	<db-entity name="MEANINGFUL_PK_DEP">
-		<db-attribute name="DESCR" type="VARCHAR" length="50"/>
-		<db-attribute name="MASTER_PK" type="INTEGER"/>
-		<db-attribute name="PK_ATTRIBUTE" type="INTEGER" isPrimaryKey="true" isMandatory="true"/>
-	</db-entity>
-	<db-entity name="MEANINGFUL_PK_TEST1">
-		<db-attribute name="DESCR" type="VARCHAR" length="50"/>
-		<db-attribute name="PK_ATTRIBUTE" type="INTEGER" isPrimaryKey="true" isMandatory="true"/>
-	</db-entity>
-	<db-entity name="MIXED_PERSISTENCE_STRATEGY">
-		<db-attribute name="DESCRIPTION" type="VARCHAR" length="200"/>
-		<db-attribute name="ID" type="INTEGER" isPrimaryKey="true" isMandatory="true"/>
-		<db-attribute name="NAME" type="VARCHAR" length="200"/>
-	</db-entity>
-	<db-entity name="MIXED_PERSISTENCE_STRATEGY2">
-		<db-attribute name="ID" type="INTEGER" isPrimaryKey="true" isMandatory="true"/>
-		<db-attribute name="MASTER_ID" type="INTEGER"/>
-		<db-attribute name="NAME" type="VARCHAR" length="200"/>
-	</db-entity>
-	<db-entity name="NO_PK_TEST">
-		<db-attribute name="ATTRIBUTE1" type="INTEGER"/>
-	</db-entity>
-	<db-entity name="PAINTING">
-		<db-attribute name="ARTIST_ID" type="BIGINT"/>
-		<db-attribute name="ESTIMATED_PRICE" type="DECIMAL" length="10" scale="2"/>
-		<db-attribute name="GALLERY_ID" type="INTEGER"/>
-		<db-attribute name="PAINTING_DESCRIPTION" type="VARCHAR" length="255"/>
-		<db-attribute name="PAINTING_ID" type="INTEGER" isPrimaryKey="true" isMandatory="true"/>
-		<db-attribute name="PAINTING_TITLE" type="VARCHAR" isMandatory="true" length="255"/>
-	</db-entity>
-	<db-entity name="PAINTING1">
-		<db-attribute name="ARTIST_ID" type="BIGINT"/>
-		<db-attribute name="ESTIMATED_PRICE" type="DECIMAL" length="10" scale="2"/>
-		<db-attribute name="GALLERY_ID" type="INTEGER"/>
-		<db-attribute name="PAINTING_ID" type="INTEGER" isPrimaryKey="true" isMandatory="true"/>
-		<db-attribute name="PAINTING_TITLE" type="VARCHAR" isMandatory="true" length="255"/>
-	</db-entity>
-	<db-entity name="PAINTING_INFO">
-		<db-attribute name="IMAGE_BLOB" type="LONGVARBINARY"/>
-		<db-attribute name="PAINTING_ID" type="INTEGER" isPrimaryKey="true" isMandatory="true"/>
-		<db-attribute name="TEXT_REVIEW" type="LONGVARCHAR"/>
-	</db-entity>
-	<db-entity name="PRIMITIVES_TEST">
-		<db-attribute name="BOOLEAN_COLUMN" type="BOOLEAN"/>
-		<db-attribute name="ID" type="INTEGER" isPrimaryKey="true" isMandatory="true"/>
-		<db-attribute name="INT_COLUMN" type="INTEGER"/>
-	</db-entity>
-	<db-entity name="SERIALIZABLE_ENTITY">
-		<db-attribute name="ID" type="INTEGER" isPrimaryKey="true" isMandatory="true"/>
-		<db-attribute name="SERIALIZABLE_FIELD" type="BLOB"/>
-	</db-entity>
-	<db-entity name="SMALLINT_TEST">
-		<db-attribute name="ID" type="INTEGER" isPrimaryKey="true" isMandatory="true"/>
-		<db-attribute name="SMALLINT_COL" type="SMALLINT"/>
-	</db-entity>
-	<db-entity name="TINYINT_TEST">
-		<db-attribute name="ID" type="INTEGER" isPrimaryKey="true" isMandatory="true"/>
-		<db-attribute name="TINYINT_COL" type="TINYINT"/>
-	</db-entity>
-	<db-entity name="TYPES_MAPPING_TEST1">
-		<db-attribute name="AAAID" type="INTEGER" isPrimaryKey="true" isMandatory="true"/>
-		<db-attribute name="BIGINT_COLUMN" type="BIGINT"/>
-		<db-attribute name="BIT_COLUMN" type="BIT"/>
-		<db-attribute name="BOOLEAN_COLUMN" type="BOOLEAN"/>
-		<db-attribute name="CHAR_COLUMN" type="CHAR" length="254"/>
-		<db-attribute name="CLOB_COLUMN" type="CLOB"/>
-		<db-attribute name="DATE_COLUMN" type="DATE"/>
-		<db-attribute name="DECIMAL_COLUMN" type="DECIMAL" length="12" scale="5"/>
-		<db-attribute name="DOUBLE_COLUMN" type="DOUBLE" scale="7"/>
-		<db-attribute name="FLOAT_COLUMN" type="FLOAT" scale="3"/>
-		<db-attribute name="INTEGER_COLUMN" type="INTEGER"/>
-		<db-attribute name="LONGVARCHAR_COLUMN" type="LONGVARCHAR"/>
-		<db-attribute name="NUMERIC_COLUMN" type="NUMERIC" length="12" scale="5"/>
-		<db-attribute name="REAL_COLUMN" type="REAL" scale="5"/>
-		<db-attribute name="SMALLINT_COLUMN" type="SMALLINT"/>
-		<db-attribute name="TIMESTAMP_COLUMN" type="TIMESTAMP"/>
-		<db-attribute name="TIME_COLUMN" type="TIME"/>
-		<db-attribute name="TINYINT_COLUMN" type="TINYINT"/>
-		<db-attribute name="VARCHAR_COLUMN" type="VARCHAR" length="255"/>
-	</db-entity>
-	<db-entity name="TYPES_MAPPING_TEST2">
-		<db-attribute name="AAAID" type="INTEGER" isPrimaryKey="true" isMandatory="true"/>
-		<db-attribute name="BINARY_COLUMN" type="BINARY" length="14"/>
-		<db-attribute name="BLOB_COLUMN" type="BLOB"/>
-		<db-attribute name="LONGVARBINARY_COLUMN" type="LONGVARBINARY"/>
-		<db-attribute name="VARBINARY_COLUMN" type="VARBINARY" length="1000"/>
-	</db-entity>
-	<db-entity name="UUID_TEST">
-		<db-attribute name="ID" type="INTEGER" isPrimaryKey="true" isMandatory="true"/>
-		<db-attribute name="UUID" type="VARCHAR" length="100"/>
-	</db-entity>
-	<obj-entity name="ArraysEntity" className="org.apache.cayenne.testdo.misc_types.ArraysEntity" dbEntityName="ARRAYS_ENTITY">
-		<obj-attribute name="byteArray" type="byte[]" db-attribute-path="BYTE_ARRAY"/>
-		<obj-attribute name="byteWrapperArray" type="java.lang.Byte[]" db-attribute-path="BYTE_WRAPPER_ARRAY"/>
-		<obj-attribute name="charArray" type="char[]" db-attribute-path="CHAR_ARRAY"/>
-		<obj-attribute name="charWrapperArray" type="java.lang.Character[]" db-attribute-path="CHAR_WRAPPER_ARRAY"/>
-	</obj-entity>
-	<obj-entity name="ArtGroup" className="org.apache.cayenne.testdo.testmap.ArtGroup" dbEntityName="ARTGROUP">
-		<obj-attribute name="name" type="java.lang.String" db-attribute-path="NAME"/>
-	</obj-entity>
-	<obj-entity name="Artist" className="org.apache.cayenne.testdo.testmap.Artist" dbEntityName="ARTIST">
-		<obj-attribute name="artistName" type="java.lang.String" db-attribute-path="ARTIST_NAME"/>
-		<obj-attribute name="dateOfBirth" type="java.util.Date" db-attribute-path="DATE_OF_BIRTH"/>
-	</obj-entity>
-	<obj-entity name="ArtistCallbackTest" className="org.apache.cayenne.testdo.testmap.ArtistCallbackTest" dbEntityName="ARTIST_CT" exclude-superclass-listeners="true" exclude-default-listeners="true">
-		<obj-attribute name="artistName" type="java.lang.String"/>
-		<obj-attribute name="dateOfBirth" type="java.util.Date"/>
-		<entity-listener class="org.apache.cayenne.testdo.testmap.EntityListenerObjEntity">
-			<post-add method-name="prePersistEntityListener"/>
-			<post-persist method-name="postPersistEntityListener"/>
-			<pre-update method-name="preUpdateEntityListener"/>
-			<post-update method-name="postUpdateEntityListener"/>
-			<pre-remove method-name="preRemoveEntityListener"/>
-			<post-remove method-name="postRemoveEntityListener"/>
-			<post-load method-name="postLoadEntityListener"/>
-		</entity-listener>
-		<post-add method-name="prePersistEntityObjEntity"/>
-		<post-persist method-name="postPersistEntityObjEntity"/>
-		<pre-update method-name="preUpdateEntityObjEntity"/>
-		<post-update method-name="postUpdateEntityObjEntity"/>
-		<pre-remove method-name="preRemoveEntityObjEntity"/>
-		<post-remove method-name="postRemoveEntityObjEntity"/>
-		<post-load method-name="postLoadEntityObjEntity"/>
-	</obj-entity>
-	<obj-entity name="ArtistExhibit" className="org.apache.cayenne.testdo.testmap.ArtistExhibit" dbEntityName="ARTIST_EXHIBIT">
-	</obj-entity>
-	<obj-entity name="BigDecimalEntity" className="org.apache.cayenne.testdo.numeric_types.BigDecimalEntity" dbEntityName="BIGDECIMAL_ENTITY">
-		<obj-attribute name="bigDecimalField" type="java.math.BigDecimal" db-attribute-path="BIGDECIMAL_FIELD"/>
-	</obj-entity>
-	<obj-entity name="BigIntegerEntity" className="org.apache.cayenne.testdo.numeric_types.BigIntegerEntity" dbEntityName="BIGINTEGER_ENTITY">
-		<obj-attribute name="bigIntegerField" type="java.math.BigInteger" db-attribute-path="BIG_INTEGER_FIELD"/>
-	</obj-entity>
-	<obj-entity name="BinaryPKTest1" className="org.apache.cayenne.testdo.binary_pk.BinaryPKTest1" dbEntityName="BINARY_PK_TEST1">
-		<obj-attribute name="name" type="java.lang.String" db-attribute-path="NAME"/>
-	</obj-entity>
-	<obj-entity name="BinaryPKTest2" className="org.apache.cayenne.testdo.binary_pk.BinaryPKTest2" dbEntityName="BINARY_PK_TEST2">
-		<obj-attribute name="detailName" type="java.lang.String" db-attribute-path="DETAIL_NAME"/>
-	</obj-entity>
-	<obj-entity name="BitNumberTestEntity" className="org.apache.cayenne.testdo.numeric_types.BitNumberTestEntity" dbEntityName="BIT_TEST">
-		<obj-attribute name="bitColumn" type="java.lang.Integer" db-attribute-path="BIT_COLUMN"/>
-	</obj-entity>
-	<obj-entity name="BitTestEntity" className="org.apache.cayenne.testdo.numeric_types.BitTestEntity" dbEntityName="BIT_TEST">
-		<obj-attribute name="bitColumn" type="java.lang.Boolean" db-attribute-path="BIT_COLUMN"/>
-	</obj-entity>
-	<obj-entity name="BlobTestEntity" className="org.apache.cayenne.testdo.lob.BlobTestEntity" dbEntityName="BLOB_TEST">
-		<obj-attribute name="blobCol" type="byte[]" db-attribute-path="BLOB_COL"/>
-	</obj-entity>
-	<obj-entity name="BooleanTestEntity" className="org.apache.cayenne.testdo.numeric_types.BooleanTestEntity" dbEntityName="BOOLEAN_TEST">
-		<obj-attribute name="booleanColumn" type="java.lang.Boolean" db-attribute-path="BOOLEAN_COLUMN"/>
-	</obj-entity>
-	<obj-entity name="CalendarEntity" className="org.apache.cayenne.testdo.date_time.CalendarEntity" dbEntityName="CALENDAR_TEST">
-		<obj-attribute name="calendarField" type="java.util.Calendar" db-attribute-path="CALENDAR_FIELD"/>
-	</obj-entity>
-	<obj-entity name="CharFkTestEntity" className="org.apache.cayenne.testdo.compound.CharFkTestEntity" dbEntityName="CHAR_FK_TEST">
-		<obj-attribute name="name" type="java.lang.String" db-attribute-path="NAME"/>
-	</obj-entity>
-	<obj-entity name="CharPkTestEntity" className="org.apache.cayenne.testdo.compound.CharPkTestEntity" dbEntityName="CHAR_PK_TEST">
-		<obj-attribute name="otherCol" type="java.lang.String" db-attribute-path="OTHER_COL"/>
-		<obj-attribute name="pkCol" type="java.lang.String" db-attribute-path="PK_COL"/>
-	</obj-entity>
-	<obj-entity name="CharacterEntity" className="org.apache.cayenne.testdo.misc_types.CharacterEntity" dbEntityName="CHARACTER_ENTITY">
-		<obj-attribute name="characterField" type="java.lang.Character" db-attribute-path="CHARACTER_FIELD"/>
-	</obj-entity>
-	<obj-entity name="ClobTestEntity" className="org.apache.cayenne.testdo.lob.ClobTestEntity" dbEntityName="CLOB_TEST">
-		<obj-attribute name="clobCol" type="java.lang.String" db-attribute-path="CLOB_COL"/>
-	</obj-entity>
-	<obj-entity name="ClobTestRelation" className="org.apache.cayenne.testdo.lob.ClobTestRelation" dbEntityName="CLOB_TEST_RELATION">
-		<obj-attribute name="id" type="java.lang.Integer" db-attribute-path="ID"/>
-		<obj-attribute name="value" type="java.lang.Integer" db-attribute-path="VALUE"/>
-	</obj-entity>
-	<obj-entity name="CompoundFkTestEntity" className="org.apache.cayenne.testdo.compound.CompoundFkTestEntity" dbEntityName="COMPOUND_FK_TEST">
-		<obj-attribute name="name" type="java.lang.String" db-attribute-path="NAME"/>
-	</obj-entity>
-	<obj-entity name="CompoundPainting" className="org.apache.cayenne.testdo.testmap.CompoundPainting" dbEntityName="PAINTING">
-		<obj-attribute name="artistName" type="java.lang.String" db-attribute-path="toArtist.ARTIST_NAME"/>
-		<obj-attribute name="estimatedPrice" type="java.math.BigDecimal" db-attribute-path="ESTIMATED_PRICE"/>
-		<obj-attribute name="galleryName" type="java.lang.String" db-attribute-path="toGallery.GALLERY_NAME"/>
-		<obj-attribute name="paintingTitle" type="java.lang.String" db-attribute-path="PAINTING_TITLE"/>
-		<obj-attribute name="textReview" type="java.lang.String" db-attribute-path="toPaintingInfo.TEXT_REVIEW"/>
-	</obj-entity>
-	<obj-entity name="CompoundPkTestEntity" className="org.apache.cayenne.testdo.compound.CompoundPkTestEntity" dbEntityName="COMPOUND_PK_TEST">
-		<obj-attribute name="key1" type="java.lang.String" db-attribute-path="KEY1"/>
-		<obj-attribute name="key2" type="java.lang.String" db-attribute-path="KEY2"/>
-		<obj-attribute name="name" type="java.lang.String" db-attribute-path="NAME"/>
-	</obj-entity>
-	<obj-entity name="DateTestEntity" className="org.apache.cayenne.testdo.date_time.DateTestEntity" dbEntityName="DATE_TEST">
-		<obj-attribute name="dateColumn" type="java.util.Date" db-attribute-path="DATE_COLUMN"/>
-		<obj-attribute name="timeColumn" type="java.util.Date" db-attribute-path="TIME_COLUMN"/>
-		<obj-attribute name="timestampColumn" type="java.util.Date" db-attribute-path="TIMESTAMP_COLUMN"/>
-	</obj-entity>
-	<obj-entity name="DecimalPKTest1" className="org.apache.cayenne.testdo.numeric_types.DecimalPKTest1" dbEntityName="DECIMAL_PK_TST">
-		<obj-attribute name="decimalPK" type="java.lang.Double" db-attribute-path="DECIMAL_PK"/>
-		<obj-attribute name="name" type="java.lang.String" db-attribute-path="NAME"/>
-	</obj-entity>
-	<obj-entity name="DecimalPKTestEntity" className="org.apache.cayenne.testdo.numeric_types.DecimalPKTestEntity" dbEntityName="DECIMAL_PK_TST">
-		<obj-attribute name="decimalPK" type="java.math.BigDecimal" db-attribute-path="DECIMAL_PK"/>
-		<obj-attribute name="name" type="java.lang.String" db-attribute-path="NAME"/>
-	</obj-entity>
-	<obj-entity name="EnumEntity" className="org.apache.cayenne.testdo.enum_test.EnumEntity" dbEntityName="ENUM_ENTITY">
-		<obj-attribute name="enumAttribute" type="org.apache.cayenne.testdo.enum_test.Enum1" db-attribute-path="ENUM_ATTRIBUTE"/>
-	</obj-entity>
-	<obj-entity name="Exhibit" className="org.apache.cayenne.testdo.testmap.Exhibit" dbEntityName="EXHIBIT">
-		<obj-attribute name="closingDate" type="java.util.Date" db-attribute-path="CLOSING_DATE"/>
-		<obj-attribute name="openingDate" type="java.util.Date" db-attribute-path="OPENING_DATE"/>
-	</obj-entity>
-	<obj-entity name="ExtendedTypeEntity" className="org.apache.cayenne.testdo.extended_type.ExtendedTypeEntity" dbEntityName="EXTENDED_TYPE_TEST">
-		<obj-attribute name="name" type="org.apache.cayenne.testdo.extended_type.StringET1" db-attribute-path="NAME"/>
-	</obj-entity>
-	<obj-entity name="Gallery" className="org.apache.cayenne.testdo.testmap.Gallery" dbEntityName="GALLERY">
-		<obj-attribute name="galleryName" type="java.lang.String" db-attribute-path="GALLERY_NAME"/>
-	</obj-entity>
-	<obj-entity name="GeneratedColumnCompKey" className="org.apache.cayenne.testdo.generated.GeneratedColumnCompKey" dbEntityName="GENERATED_COLUMN_COMP_KEY">
-		<obj-attribute name="name" type="java.lang.String" db-attribute-path="NAME"/>
-	</obj-entity>
-	<obj-entity name="GeneratedColumnCompMaster" className="org.apache.cayenne.testdo.generated.GeneratedColumnCompMaster" dbEntityName="GENERATED_COLUMN_COMP_M">
-		<obj-attribute name="name" type="java.lang.String" db-attribute-path="NAME"/>
-	</obj-entity>
-	<obj-entity name="GeneratedColumnDep" className="org.apache.cayenne.testdo.generated.GeneratedColumnDep" dbEntityName="GENERATED_COLUMN_DEP">
-		<obj-attribute name="name" type="java.lang.String" db-attribute-path="NAME"/>
-	</obj-entity>
-	<obj-entity name="GeneratedColumnTest2" className="org.apache.cayenne.testdo.generated.GeneratedColumnTest2" dbEntityName="GENERATED_COLUMN_TEST2">
-		<obj-attribute name="name" type="java.lang.String" db-attribute-path="NAME"/>
-	</obj-entity>
-	<obj-entity name="GeneratedColumnTestEntity" className="org.apache.cayenne.testdo.generated.GeneratedColumnTestEntity" dbEntityName="GENERATED_COLUMN_TEST">
-		<obj-attribute name="name" type="java.lang.String" db-attribute-path="NAME"/>
-	</obj-entity>
-	<obj-entity name="GeneratedF1" className="org.apache.cayenne.testdo.generated.GeneratedF1" clientClassName="test.client.GeneratedF1" dbEntityName="GENERATED_F1" superClassName="org.apache.cayenne.CayenneDataObject" clientSuperClassName="org.apache.cayenne.PersistentObject">
-	</obj-entity>
-	<obj-entity name="GeneratedF2" className="org.apache.cayenne.testdo.generated.GeneratedF2" clientClassName="test.client.GeneratedF2" dbEntityName="GENERATED_F2" superClassName="org.apache.cayenne.CayenneDataObject" clientSuperClassName="org.apache.cayenne.PersistentObject">
-	</obj-entity>
-	<obj-entity name="LongEntity" className="org.apache.cayenne.testdo.numeric_types.LongEntity" dbEntityName="LONG_ENTITY">
-		<obj-attribute name="longField" type="java.lang.Long" db-attribute-path="LONG_FIELD"/>
-	</obj-entity>
-	<obj-entity name="MeaningfulGeneratedColumnTestEntity" className="org.apache.cayenne.testdo.testmap.MeaningfulGeneratedColumnTestEntity" dbEntityName="GENERATED_COLUMN_TEST">
-		<obj-attribute name="generatedColumn" type="java.lang.Integer" db-attribute-path="GENERATED_COLUMN"/>
-		<obj-attribute name="name" type="java.lang.String" db-attribute-path="NAME"/>
-	</obj-entity>
-	<obj-entity name="MeaningfulPKDep" className="org.apache.cayenne.testdo.meaningful_pk.MeaningfulPKDep" dbEntityName="MEANINGFUL_PK_DEP">
-		<obj-attribute name="descr" type="java.lang.String" db-attribute-path="DESCR"/>
-	</obj-entity>
-	<obj-entity name="MeaningfulPKTest1" className="org.apache.cayenne.testdo.meaningful_pk.MeaningfulPKTest1" dbEntityName="MEANINGFUL_PK_TEST1">
-		<obj-attribute name="descr" type="java.lang.String" db-attribute-path="DESCR"/>
-		<obj-attribute name="pkAttribute" type="java.lang.Integer" db-attribute-path="PK_ATTRIBUTE"/>
-	</obj-entity>
-	<obj-entity name="MixedPersistenceStrategy" className="org.apache.cayenne.testdo.mixed_persistence_strategy.MixedPersistenceStrategy" dbEntityName="MIXED_PERSISTENCE_STRATEGY">
-		<obj-attribute name="description" type="java.lang.String" db-attribute-path="DESCRIPTION"/>
-		<obj-attribute name="name" type="java.lang.String" db-attribute-path="NAME"/>
-	</obj-entity>
-	<obj-entity name="MixedPersistenceStrategy2" className="org.apache.cayenne.testdo.mixed_persistence_strategy.MixedPersistenceStrategy2" dbEntityName="MIXED_PERSISTENCE_STRATEGY2">
-		<obj-attribute name="name" type="java.lang.String" db-attribute-path="NAME"/>
-	</obj-entity>
-	<obj-entity name="NoPkTestEntity" className="org.apache.cayenne.testdo.no_pk.NoPkTestEntity" dbEntityName="NO_PK_TEST">
-		<obj-attribute name="attribute1" type="java.lang.Integer" db-attribute-path="ATTRIBUTE1"/>
-	</obj-entity>
-	<obj-entity name="Painting" className="org.apache.cayenne.testdo.testmap.Painting" dbEntityName="PAINTING" superClassName="org.apache.cayenne.testdo.testmap.ArtDataObject">
-		<obj-attribute name="estimatedPrice" type="java.math.BigDecimal" db-attribute-path="ESTIMATED_PRICE"/>
-		<obj-attribute name="paintingDescription" type="java.lang.String" db-attribute-path="PAINTING_DESCRIPTION"/>
-		<obj-attribute name="paintingTitle" type="java.lang.String" db-attribute-path="PAINTING_TITLE"/>
-	</obj-entity>
-	<obj-entity name="Painting1" className="org.apache.cayenne.testdo.testmap.Painting1" dbEntityName="PAINTING1">
-		<obj-attribute name="estimatedPrice" type="java.math.BigDecimal" db-attribute-path="ESTIMATED_PRICE"/>
-		<obj-attribute name="paintingTitle" type="java.lang.String" db-attribute-path="PAINTING_TITLE"/>
-	</obj-entity>
-	<obj-entity name="PaintingInfo" className="org.apache.cayenne.testdo.testmap.PaintingInfo" dbEntityName="PAINTING_INFO">
-		<obj-attribute name="imageBlob" type="byte[]" db-attribute-path="IMAGE_BLOB"/>
-		<obj-attribute name="textReview" type="java.lang.String" db-attribute-path="TEXT_REVIEW"/>
-	</obj-entity>
-	<obj-entity name="PrimitivesTestEntity" className="org.apache.cayenne.testdo.primitive.PrimitivesTestEntity" dbEntityName="PRIMITIVES_TEST">
-		<obj-attribute name="booleanColumn" type="boolean" db-attribute-path="BOOLEAN_COLUMN"/>
-		<obj-attribute name="intColumn" type="int" db-attribute-path="INT_COLUMN"/>
-	</obj-entity>
-	<obj-entity name="ROArtist" className="org.apache.cayenne.testdo.testmap.ROArtist" readOnly="true" dbEntityName="ARTIST">
-		<obj-attribute name="artistName" type="java.lang.String" db-attribute-path="ARTIST_NAME"/>
-		<obj-attribute name="dateOfBirth" type="java.sql.Date" db-attribute-path="DATE_OF_BIRTH"/>
-	</obj-entity>
-	<obj-entity name="ROPainting" className="org.apache.cayenne.testdo.testmap.ROPainting" readOnly="true" dbEntityName="PAINTING">
-		<obj-attribute name="estimatedPrice" type="java.math.BigDecimal" db-attribute-path="ESTIMATED_PRICE"/>
-		<obj-attribute name="paintingTitle" type="java.lang.String" db-attribute-path="PAINTING_TITLE"/>
-	</obj-entity>
-	<obj-entity name="RWCompoundPainting" className="org.apache.cayenne.testdo.testmap.RWCompoundPainting" dbEntityName="PAINTING">
-		<obj-attribute name="estimatedPrice" type="java.math.BigDecimal" db-attribute-path="ESTIMATED_PRICE"/>
-		<obj-attribute name="paintingTitle" type="java.lang.String" db-attribute-path="PAINTING_TITLE"/>
-		<obj-attribute name="textReview" type="java.lang.String" db-attribute-path="toPaintingInfo.TEXT_REVIEW"/>
-	</obj-entity>
-	<obj-entity name="ReturnTypesMap1" className="org.apache.cayenne.testdo.return_types.ReturnTypesMap1" clientClassName="test.client.ReturnTypesMap1" dbEntityName="TYPES_MAPPING_TEST1" superClassName="org.apache.cayenne.CayenneDataObject" clientSuperClassName="org.apache.cayenne.PersistentObject">
-		<obj-attribute name="bigintColumn" type="java.lang.Long" db-attribute-path="BIGINT_COLUMN"/>
-		<obj-attribute name="bitColumn" type="java.lang.Boolean" db-attribute-path="BIT_COLUMN"/>
-		<obj-attribute name="booleanColumn" type="java.lang.Boolean" db-attribute-path="BOOLEAN_COLUMN"/>
-		<obj-attribute name="charColumn" type="java.lang.String" db-attribute-path="CHAR_COLUMN"/>
-		<obj-attribute name="clobColumn" type="java.lang.String" db-attribute-path="CLOB_COLUMN"/>
-		<obj-attribute name="dateColumn" type="java.util.Date" db-attribute-path="DATE_COLUMN"/>
-		<obj-attribute name="decimalColumn" type="java.math.BigDecimal" db-attribute-path="DECIMAL_COLUMN"/>
-		<obj-attribute name="doubleColumn" type="java.lang.Double" db-attribute-path="DOUBLE_COLUMN"/>
-		<obj-attribute name="floatColumn" type="java.lang.Float" db-attribute-path="FLOAT_COLUMN"/>
-		<obj-attribute name="integerColumn" type="java.lang.Integer" db-attribute-path="INTEGER_COLUMN"/>
-		<obj-attribute name="longvarcharColumn" type="java.lang.String" db-attribute-path="LONGVARCHAR_COLUMN"/>
-		<obj-attribute name="numericColumn" type="java.math.BigDecimal" db-attribute-path="NUMERIC_COLUMN"/>
-		<obj-attribute name="realColumn" type="java.lang.Float" db-attribute-path="REAL_COLUMN"/>
-		<obj-attribute name="smallintColumn" type="java.lang.Short" db-attribute-path="SMALLINT_COLUMN"/>
-		<obj-attribute name="timeColumn" type="java.util.Date" db-attribute-path="TIME_COLUMN"/>
-		<obj-attribute name="timestampColumn" type="java.util.Date" db-attribute-path="TIMESTAMP_COLUMN"/>
-		<obj-attribute name="tinyintColumn" type="java.lang.Byte" db-attribute-path="TINYINT_COLUMN"/>
-		<obj-attribute name="varcharColumn" type="java.lang.String" db-attribute-path="VARCHAR_COLUMN"/>
-	</obj-entity>
-	<obj-entity name="ReturnTypesMap2" className="org.apache.cayenne.testdo.return_types.ReturnTypesMap2" clientClassName="test.client.ReturnTypesMap2" dbEntityName="TYPES_MAPPING_TEST2" superClassName="org.apache.cayenne.CayenneDataObject" clientSuperClassName="org.apache.cayenne.PersistentObject">
-		<obj-attribute name="binaryColumn" type="byte[]" db-attribute-path="BINARY_COLUMN"/>
-		<obj-attribute name="blobColumn" type="byte[]" db-attribute-path="BLOB_COLUMN"/>
-		<obj-attribute name="longvarbinaryColumn" type="byte[]" db-attribute-path="LONGVARBINARY_COLUMN"/>
-		<obj-attribute name="varbinaryColumn" type="byte[]" db-attribute-path="VARBINARY_COLUMN"/>
-	</obj-entity>
-	<obj-entity name="SerializableEntity" className="org.apache.cayenne.testdo.misc_types.SerializableEntity" dbEntityName="SERIALIZABLE_ENTITY">
-		<obj-attribute name="serializableField" type="org.apache.cayenne.MockSerializable" db-attribute-path="SERIALIZABLE_FIELD"/>
-	</obj-entity>
-	<obj-entity name="SmallintTestEntity" className="org.apache.cayenne.testdo.numeric_types.SmallintTestEntity" dbEntityName="SMALLINT_TEST">
-		<obj-attribute name="smallintCol" type="java.lang.Short" db-attribute-path="SMALLINT_COL"/>
-	</obj-entity>
-	<obj-entity name="SubPainting" className="org.apache.cayenne.testdo.testmap.SubPainting" dbEntityName="PAINTING">
-		<obj-attribute name="paintingTitle" type="java.lang.String" db-attribute-path="PAINTING_TITLE"/>
-	</obj-entity>
-	<obj-entity name="TinyintTestEntity" className="org.apache.cayenne.testdo.numeric_types.TinyintTestEntity" dbEntityName="TINYINT_TEST">
-		<obj-attribute name="tinyintCol" type="java.lang.Byte" db-attribute-path="TINYINT_COL"/>
-	</obj-entity>
-	<obj-entity name="UuidTestEntity" className="org.apache.cayenne.testdo.uuid.UuidTestEntity" dbEntityName="UUID_TEST">
-		<obj-attribute name="uuid" type="java.util.UUID" db-attribute-path="UUID"/>
-	</obj-entity>
-	<db-relationship name="artistGroupArray" source="ARTGROUP" target="ARTIST_GROUP" toMany="true">
-		<db-attribute-pair source="GROUP_ID" target="GROUP_ID"/>
-	</db-relationship>
-	<db-relationship name="toChildGroups" source="ARTGROUP" target="ARTGROUP" toMany="true">
-		<db-attribute-pair source="GROUP_ID" target="PARENT_GROUP_ID"/>
-	</db-relationship>
-	<db-relationship name="toParentGroup" source="ARTGROUP" target="ARTGROUP" toMany="false">
-		<db-attribute-pair source="PARENT_GROUP_ID" target="GROUP_ID"/>
-	</db-relationship>
-	<db-relationship name="artistExhibitArray" source="ARTIST" target="ARTIST_EXHIBIT" toDependentPK="true" toMany="true">
-		<db-attribute-pair source="ARTIST_ID" target="ARTIST_ID"/>
-	</db-relationship>
-	<db-relationship name="artistGroupArray" source="ARTIST" target="ARTIST_GROUP" toMany="true">
-		<db-attribute-pair source="ARTIST_ID" target="ARTIST_ID"/>
-	</db-relationship>
-	<db-relationship name="paintingArray" source="ARTIST" target="PAINTING" toMany="true">
-		<db-attribute-pair source="ARTIST_ID" target="ARTIST_ID"/>
-	</db-relationship>
-	<db-relationship name="toArtist" source="ARTIST_EXHIBIT" target="ARTIST" toMany="false">
-		<db-attribute-pair source="ARTIST_ID" target="ARTIST_ID"/>
-	</db-relationship>
-	<db-relationship name="toExhibit" source="ARTIST_EXHIBIT" target="EXHIBIT" toMany="false">
-		<db-attribute-pair source="EXHIBIT_ID" target="EXHIBIT_ID"/>
-	</db-relationship>
-	<db-relationship name="toArtist" source="ARTIST_GROUP" target="ARTIST" toMany="false">
-		<db-attribute-pair source="ARTIST_ID" target="ARTIST_ID"/>
-	</db-relationship>
-	<db-relationship name="toGroup" source="ARTIST_GROUP" target="ARTGROUP" toMany="false">
-		<db-attribute-pair source="GROUP_ID" target="GROUP_ID"/>
-	</db-relationship>
-	<db-relationship name="binaryPKDetails" source="BINARY_PK_TEST1" target="BINARY_PK_TEST2" toMany="true">
-		<db-attribute-pair source="BIN_ID" target="FK_ID"/>
-	</db-relationship>
-	<db-relationship name="toBinaryPKMaster" source="BINARY_PK_TEST2" target="BINARY_PK_TEST1" toMany="false">
-		<db-attribute-pair source="FK_ID" target="BIN_ID"/>
-	</db-relationship>
-	<db-relationship name="toCharPK" source="CHAR_FK_TEST" target="CHAR_PK_TEST" toMany="false">
-		<db-attribute-pair source="FK_COL" target="PK_COL"/>
-	</db-relationship>
-	<db-relationship name="charFKs" source="CHAR_PK_TEST" target="CHAR_FK_TEST" toMany="true">
-		<db-attribute-pair source="PK_COL" target="FK_COL"/>
-	</db-relationship>
-	<db-relationship name="clob" source="CLOB_TEST" target="CLOB_TEST_RELATION" toMany="true">
-		<db-attribute-pair source="CLOB_TEST_ID" target="ID_CLOB"/>
-	</db-relationship>
-	<db-relationship name="CLOB_REL" source="CLOB_TEST_RELATION" target="CLOB_TEST" toMany="false">
-		<db-attribute-pair source="ID_CLOB" target="CLOB_TEST_ID"/>
-	</db-relationship>
-	<db-relationship name="toCompoundPk" source="COMPOUND_FK_TEST" target="COMPOUND_PK_TEST" toMany="false">
-		<db-attribute-pair source="F_KEY1" target="KEY1"/>
-		<db-attribute-pair source="F_KEY2" target="KEY2"/>
-	</db-relationship>
-	<db-relationship name="compoundFkArray" source="COMPOUND_PK_TEST" target="COMPOUND_FK_TEST" toMany="true">
-		<db-attribute-pair source="KEY1" target="F_KEY1"/>
-		<db-attribute-pair source="KEY2" target="F_KEY2"/>
-	</db-relationship>
-	<db-relationship name="artistExhibitArray" source="EXHIBIT" target="ARTIST_EXHIBIT" toDependentPK="true" toMany="true">
-		<db-attribute-pair source="EXHIBIT_ID" target="EXHIBIT_ID"/>
-	</db-relationship>
-	<db-relationship name="toGallery" source="EXHIBIT" target="GALLERY" toMany="false">
-		<db-attribute-pair source="GALLERY_ID" target="GALLERY_ID"/>
-	</db-relationship>
-	<db-relationship name="exhibitArray" source="GALLERY" target="EXHIBIT" toMany="true">
-		<db-attribute-pair source="GALLERY_ID" target="GALLERY_ID"/>
-	</db-relationship>
-	<db-relationship name="paintingArray" source="GALLERY" target="PAINTING" toMany="true">
-		<db-attribute-pair source="GALLERY_ID" target="GALLERY_ID"/>
-	</db-relationship>
-	<db-relationship name="toMaster" source="GENERATED_COLUMN_COMP_KEY" target="GENERATED_COLUMN_COMP_M" toMany="false">
-		<db-attribute-pair source="PROPAGATED_PK" target="ID"/>
-	</db-relationship>
-	<db-relationship name="toDetail" source="GENERATED_COLUMN_COMP_M" target="GENERATED_COLUMN_COMP_KEY" toDependentPK="true" toMany="true">
-		<db-attribute-pair source="ID" target="PROPAGATED_PK"/>
-	</db-relationship>
-	<db-relationship name="toMaster" source="GENERATED_COLUMN_DEP" target="GENERATED_COLUMN_TEST" toMany="false">
-		<db-attribute-pair source="GENERATED_COLUMN_FK" target="GENERATED_COLUMN"/>
-	</db-relationship>
-	<db-relationship name="toDep" source="GENERATED_COLUMN_TEST" target="GENERATED_COLUMN_DEP" toDependentPK="true" toMany="false">
-		<db-attribute-pair source="GENERATED_COLUMN" target="GENERATED_COLUMN_FK"/>
-	</db-relationship>
-	<db-relationship name="join" source="GENERATED_F1" target="GENERATED_JOIN" toMany="true">
-		<db-attribute-pair source="ID" target="ID1"/>
-	</db-relationship>
-	<db-relationship name="join" source="GENERATED_F2" target="GENERATED_JOIN" toMany="true">
-		<db-attribute-pair source="ID" target="ID2"/>
-	</db-relationship>
-	<db-relationship name="f1" source="GENERATED_JOIN" target="GENERATED_F1" toMany="false">
-		<db-attribute-pair source="ID1" target="ID"/>
-	</db-relationship>
-	<db-relationship name="f2" source="GENERATED_JOIN" target="GENERATED_F2" toMany="false">
-		<db-attribute-pair source="ID2" target="ID"/>
-	</db-relationship>
-	<db-relationship name="toMeaningfulPK" source="MEANINGFUL_PK_DEP" target="MEANINGFUL_PK_TEST1" toMany="false">
-		<db-attribute-pair source="MASTER_PK" target="PK_ATTRIBUTE"/>
-	</db-relationship>
-	<db-relationship name="meaningfulPKDepArray" source="MEANINGFUL_PK_TEST1" target="MEANINGFUL_PK_DEP" toMany="true">
-		<db-attribute-pair source="PK_ATTRIBUTE" target="MASTER_PK"/>
-	</db-relationship>
-	<db-relationship name="details" source="MIXED_PERSISTENCE_STRATEGY" target="MIXED_PERSISTENCE_STRATEGY2" toMany="true">
-		<db-attribute-pair source="ID" target="MASTER_ID"/>
-	</db-relationship>
-	<db-relationship name="master" source="MIXED_PERSISTENCE_STRATEGY2" target="MIXED_PERSISTENCE_STRATEGY" toMany="false">
-		<db-attribute-pair source="MASTER_ID" target="ID"/>
-	</db-relationship>
-	<db-relationship name="toArtist" source="PAINTING" target="ARTIST" toMany="false">
-		<db-attribute-pair source="ARTIST_ID" target="ARTIST_ID"/>
-	</db-relationship>
-	<db-relationship name="toGallery" source="PAINTING" target="GALLERY" toMany="false">
-		<db-attribute-pair source="GALLERY_ID" target="GALLERY_ID"/>
-	</db-relationship>
-	<db-relationship name="toPaintingInfo" source="PAINTING" target="PAINTING_INFO" toDependentPK="true" toMany="false">
-		<db-attribute-pair source="PAINTING_ID" target="PAINTING_ID"/>
-	</db-relationship>
-	<db-relationship name="toArtist" source="PAINTING1" target="ARTIST" toMany="false">
-		<db-attribute-pair source="ARTIST_ID" target="ARTIST_ID"/>
-	</db-relationship>
-	<db-relationship name="painting" source="PAINTING_INFO" target="PAINTING" toMany="false">
-		<db-attribute-pair source="PAINTING_ID" target="PAINTING_ID"/>
-	</db-relationship>
-	<obj-relationship name="artistArray" source="ArtGroup" target="Artist" deleteRule="Nullify" db-relationship-path="artistGroupArray.toArtist"/>
-	<obj-relationship name="childGroupsArray" source="ArtGroup" target="ArtGroup" deleteRule="Nullify" db-relationship-path="toChildGroups"/>
-	<obj-relationship name="toParentGroup" source="ArtGroup" target="ArtGroup" deleteRule="Nullify" db-relationship-path="toParentGroup"/>
-	<obj-relationship name="artistExhibitArray" source="Artist" target="ArtistExhibit" deleteRule="Cascade" db-relationship-path="artistExhibitArray"/>
-	<obj-relationship name="groupArray" source="Artist" target="ArtGroup" deleteRule="Cascade" db-relationship-path="artistGroupArray.toGroup"/>
-	<obj-relationship name="paintingArray" source="Artist" target="Painting" deleteRule="Cascade" db-relationship-path="paintingArray"/>
-	<obj-relationship name="toArtist" source="ArtistExhibit" target="Artist" deleteRule="Nullify" db-relationship-path="toArtist"/>
-	<obj-relationship name="toExhibit" source="ArtistExhibit" target="Exhibit" deleteRule="Nullify" db-relationship-path="toExhibit"/>
-	<obj-relationship name="binaryPKDetails" source="BinaryPKTest1" target="BinaryPKTest2" db-relationship-path="binaryPKDetails"/>
-	<obj-relationship name="toBinaryPKMaster" source="BinaryPKTest2" target="BinaryPKTest1" db-relationship-path="toBinaryPKMaster"/>
-	<obj-relationship name="toCharPK" source="CharFkTestEntity" target="CharPkTestEntity" db-relationship-path="toCharPK"/>
-	<obj-relationship name="charFKs" source="CharPkTestEntity" target="CharFkTestEntity" db-relationship-path="charFKs"/>
-	<obj-relationship name="clobValue" source="ClobTestEntity" target="ClobTestRelation" db-relationship-path="clob"/>
-	<obj-relationship name="clobId" source="ClobTestRelation" target="ClobTestEntity" db-relationship-path="CLOB_REL"/>
-	<obj-relationship name="toCompoundPk" source="CompoundFkTestEntity" target="CompoundPkTestEntity" db-relationship-path="toCompoundPk"/>
-	<obj-relationship name="toArtist" source="CompoundPainting" target="Artist" deleteRule="Nullify" db-relationship-path="toArtist"/>
-	<obj-relationship name="toGallery" source="CompoundPainting" target="Gallery" deleteRule="Nullify" db-relationship-path="toGallery"/>
-	<obj-relationship name="toPaintingInfo" source="CompoundPainting" target="PaintingInfo" deleteRule="Cascade" db-relationship-path="toPaintingInfo"/>
-	<obj-relationship name="compoundFkArray" source="CompoundPkTestEntity" target="CompoundFkTestEntity" db-relationship-path="compoundFkArray"/>
-	<obj-relationship name="artistExhibitArray" source="Exhibit" target="ArtistExhibit" deleteRule="Cascade" db-relationship-path="artistExhibitArray"/>
-	<obj-relationship name="toGallery" source="Exhibit" target="Gallery" deleteRule="Nullify" db-relationship-path="toGallery"/>
-	<obj-relationship name="exhibitArray" source="Gallery" target="Exhibit" deleteRule="Cascade" db-relationship-path="exhibitArray"/>
-	<obj-relationship name="paintingArray" source="Gallery" target="Painting" deleteRule="Deny" db-relationship-path="paintingArray"/>
-	<obj-relationship name="toMaster" source="GeneratedColumnCompKey" target="GeneratedColumnCompMaster" db-relationship-path="toMaster"/>
-	<obj-relationship name="toDetail" source="GeneratedColumnCompMaster" target="GeneratedColumnCompKey" db-relationship-path="toDetail"/>
-	<obj-relationship name="toMaster" source="GeneratedColumnDep" target="GeneratedColumnTestEntity" db-relationship-path="toMaster"/>
-	<obj-relationship name="toDep" source="GeneratedColumnTestEntity" target="GeneratedColumnDep" db-relationship-path="toDep"/>
-	<obj-relationship name="f2" source="GeneratedF1" target="GeneratedF2" deleteRule="Nullify" db-relationship-path="join.f2"/>
-	<obj-relationship name="f1" source="GeneratedF2" target="GeneratedF1" deleteRule="Nullify" db-relationship-path="join.f1"/>
-	<obj-relationship name="toMeaningfulPK" source="MeaningfulPKDep" target="MeaningfulPKTest1" db-relationship-path="toMeaningfulPK"/>
-	<obj-relationship name="meaningfulPKDepArray" source="MeaningfulPKTest1" target="MeaningfulPKDep" db-relationship-path="meaningfulPKDepArray"/>
-	<obj-relationship name="details" source="MixedPersistenceStrategy" target="MixedPersistenceStrategy2" db-relationship-path="details"/>
-	<obj-relationship name="master" source="MixedPersistenceStrategy2" target="MixedPersistenceStrategy" db-relationship-path="master"/>
-	<obj-relationship name="toArtist" source="Painting" target="Artist" deleteRule="Nullify" db-relationship-path="toArtist"/>
-	<obj-relationship name="toGallery" source="Painting" target="Gallery" deleteRule="Nullify" db-relationship-path="toGallery"/>
-	<obj-relationship name="toPaintingInfo" source="Painting" target="PaintingInfo" deleteRule="Cascade" db-relationship-path="toPaintingInfo"/>
-	<obj-relationship name="toArtist" source="Painting1" target="Artist" deleteRule="Nullify" db-relationship-path="toArtist"/>
-	<obj-relationship name="painting" source="PaintingInfo" target="Painting" deleteRule="Nullify" db-relationship-path="painting"/>
-	<obj-relationship name="paintingArray" source="ROArtist" target="Painting" deleteRule="Deny" db-relationship-path="paintingArray"/>
-	<obj-relationship name="toArtist" source="ROPainting" target="Artist" deleteRule="Nullify" db-relationship-path="toArtist"/>
-	<query name="EjbqlQueryTest" type="EJBQLQuery">
-		<property name="cayenne.GenericSelectQuery.fetchingDataRows" value="true"/>
-		<property name="cayenne.GenericSelectQuery.cacheStrategy" value="SHARED_CACHE"/>
-		<ejbql><![CDATA[select a from Artist a]]></ejbql>
-	</query>
-	<query name="NonSelectingQuery" type="SQLTemplate" root="data-map" root-name="testmap">
-		<property name="cayenne.SQLTemplate.columnNameCapitalization" value="UPPER"/>
-		<sql><![CDATA[INSERT INTO PAINTING (PAINTING_ID, PAINTING_TITLE, ESTIMATED_PRICE)
-VALUES (512, 'No Painting Like This', 12.5)]]></sql>
-		<sql adapter-class="org.apache.cayenne.dba.db2.DB2Adapter"><![CDATA[INSERT INTO PAINTING (PAINTING_ID, PAINTING_TITLE, ESTIMATED_PRICE) VALUES (512, 'No Painting Like This', 12.5)]]></sql>
-	</query>
-	<query name="ObjectQuery" type="SelectQuery" root="obj-entity" root-name="Painting">
-		<qualifier><![CDATA[toArtist = $artist]]></qualifier>
-		<ordering><![CDATA[paintingTitle]]></ordering>
-	</query>
-	<query name="ParameterizedNonSelectingQuery" type="SQLTemplate" root="data-map" root-name="testmap">
-		<sql><![CDATA[INSERT INTO PAINTING (PAINTING_ID, PAINTING_TITLE, ESTIMATED_PRICE)
-VALUES (#bind($id), #bind($title), #bind($price))]]></sql>
-		<sql adapter-class="org.apache.cayenne.dba.db2.DB2Adapter"><![CDATA[INSERT INTO PAINTING (PAINTING_ID, PAINTING_TITLE, ESTIMATED_PRICE) values (#bind($id), #bind($title), #bind($price))]]></sql>
-	</query>
-	<query name="ParameterizedQueryWithLocalCache" type="SelectQuery" root="obj-entity" root-name="Artist">
-		<property name="cayenne.GenericSelectQuery.cacheStrategy" value="LOCAL_CACHE"/>
-		<qualifier><![CDATA[artistName like $name]]></qualifier>
-	</query>
-	<query name="ParameterizedQueryWithSharedCache" type="SelectQuery" root="obj-entity" root-name="Artist">
-		<property name="cayenne.GenericSelectQuery.cacheStrategy" value="SHARED_CACHE"/>
-		<qualifier><![CDATA[artistName like $name]]></qualifier>
-	</query>
-	<query name="ProcedureQuery" type="ProcedureQuery" root="procedure" root-name="cayenne_tst_select_proc" result-entity="Artist">
-	</query>
-	<query name="QueryWithLocalCache" type="SelectQuery" root="obj-entity" root-name="Artist">
-		<property name="cayenne.GenericSelectQuery.cacheStrategy" value="LOCAL_CACHE"/>
-	</query>
-	<query name="QueryWithOrdering" type="SelectQuery" root="obj-entity" root-name="Artist">
-		<ordering descending="true" ignore-case="true"><![CDATA[artistName]]></ordering>
-		<ordering><![CDATA[dateOfBirth]]></ordering>
-	</query>
-	<query name="QueryWithPrefetch" type="SelectQuery" root="obj-entity" root-name="Gallery">
-		<prefetch>paintingArray</prefetch>
-	</query>
-	<query name="QueryWithQualifier" type="SelectQuery" root="obj-entity" root-name="Artist">
-		<qualifier><![CDATA[artistName = $param1]]></qualifier>
-	</query>
-	<query name="QueryWithSharedCache" type="SelectQuery" root="obj-entity" root-name="Artist">
-		<property name="cayenne.GenericSelectQuery.cacheStrategy" value="SHARED_CACHE"/>
-	</query>
-	<query name="SelectDateTest" type="SQLTemplate" root="data-map" root-name="testmap">
-		<property name="cayenne.GenericSelectQuery.fetchingDataRows" value="true"/>
-		<property name="cayenne.SQLTemplate.columnNameCapitalization" value="UPPER"/>
-		<sql><![CDATA[SELECT * FROM DATE_TEST]]></sql>
-	</query>
-	<query name="SelectReturnTypesMap1" type="SQLTemplate" root="data-map" root-name="testmap">
-		<property name="cayenne.GenericSelectQuery.fetchingDataRows" value="true"/>
-		<property name="cayenne.SQLTemplate.columnNameCapitalization" value="UPPER"/>
-		<sql><![CDATA[SELECT * FROM TYPES_MAPPING_TEST1]]></sql>
-	</query>
-	<query name="SelectReturnTypesMap2" type="SQLTemplate" root="data-map" root-name="testmap">
-		<property name="cayenne.GenericSelectQuery.fetchingDataRows" value="true"/>
-		<property name="cayenne.SQLTemplate.columnNameCapitalization" value="UPPER"/>
-		<sql><![CDATA[SELECT * FROM TYPES_MAPPING_TEST2]]></sql>
-	</query>
-	<query name="SelectTestLower" type="SQLTemplate" root="data-map" root-name="testmap">
-		<property name="cayenne.GenericSelectQuery.fetchingDataRows" value="true"/>
-		<property name="cayenne.SQLTemplate.columnNameCapitalization" value="LOWER"/>
-		<sql><![CDATA[select * from ARTIST]]></sql>
-	</query>
-	<query name="SelectTestUpper" type="SQLTemplate" root="data-map" root-name="testmap">
-		<property name="cayenne.GenericSelectQuery.fetchingDataRows" value="true"/>
-		<property name="cayenne.SQLTemplate.columnNameCapitalization" value="UPPER"/>
-		<sql><![CDATA[select * from ARTIST]]></sql>
-	</query>
-</data-map>

http://git-wip-us.apache.org/repos/asf/cayenne/blob/c63b6be2/itests/cayenne-tools-itest/pom.xml
----------------------------------------------------------------------
diff --git a/itests/cayenne-tools-itest/pom.xml b/itests/cayenne-tools-itest/pom.xml
index b37523e..6f2a75f 100644
--- a/itests/cayenne-tools-itest/pom.xml
+++ b/itests/cayenne-tools-itest/pom.xml
@@ -60,11 +60,6 @@
 			<version>${project.version}</version>
 		</dependency>
 
-		<dependency>
-			<groupId>org.apache.cayenne</groupId>
-			<artifactId>cayenne-tools</artifactId>
-			<version>${project.version}</version>
-		</dependency>
 	</dependencies>
 
 	<build>

http://git-wip-us.apache.org/repos/asf/cayenne/blob/c63b6be2/modeler/cayenne-modeler/pom.xml
----------------------------------------------------------------------
diff --git a/modeler/cayenne-modeler/pom.xml b/modeler/cayenne-modeler/pom.xml
index 1274d7f..a282aae 100644
--- a/modeler/cayenne-modeler/pom.xml
+++ b/modeler/cayenne-modeler/pom.xml
@@ -71,7 +71,13 @@
 
 		<dependency>
 			<groupId>org.apache.cayenne</groupId>
-			<artifactId>cayenne-tools</artifactId>
+			<artifactId>cayenne-cgen</artifactId>
+			<version>${project.version}</version>
+		</dependency>
+
+		<dependency>
+			<groupId>org.apache.cayenne</groupId>
+			<artifactId>cayenne-dbsync</artifactId>
 			<version>${project.version}</version>
 		</dependency>
 

http://git-wip-us.apache.org/repos/asf/cayenne/blob/c63b6be2/plugins/cayenne-maven-plugin/pom.xml
----------------------------------------------------------------------
diff --git a/plugins/cayenne-maven-plugin/pom.xml b/plugins/cayenne-maven-plugin/pom.xml
index eb5c4db..9871994 100644
--- a/plugins/cayenne-maven-plugin/pom.xml
+++ b/plugins/cayenne-maven-plugin/pom.xml
@@ -77,26 +77,14 @@
 
 		<dependency>
 			<groupId>org.apache.cayenne</groupId>
-			<artifactId>cayenne-project</artifactId>
+			<artifactId>cayenne-cgen</artifactId>
 			<version>${project.version}</version>
 		</dependency>
 
 		<dependency>
 			<groupId>org.apache.cayenne</groupId>
-			<artifactId>cayenne-server</artifactId>
-			<version>${project.version}</version>
-		</dependency>
-
-		<dependency>
-			<groupId>org.apache.cayenne</groupId>
-			<artifactId>cayenne-tools</artifactId>
+			<artifactId>cayenne-dbsync</artifactId>
 			<version>${project.version}</version>
-			<exclusions>
-				<exclusion>
-					<groupId>foundrylogic.vpp</groupId>
-					<artifactId>vpp</artifactId>
-				</exclusion>
-			</exclusions>
 		</dependency>
 
 		<!-- Test deps -->
@@ -138,14 +126,6 @@
 
 		<dependency>
 			<groupId>org.apache.cayenne</groupId>
-			<artifactId>cayenne-server</artifactId>
-			<version>${project.version}</version>
-			<scope>test</scope>
-			<type>test-jar</type>
-		</dependency>
-
-		<dependency>
-			<groupId>org.apache.cayenne</groupId>
 			<artifactId>cayenne-dbsync</artifactId>
 			<version>${project.version}</version>
 			<scope>test</scope>

http://git-wip-us.apache.org/repos/asf/cayenne/blob/c63b6be2/plugins/maven-cayenne-plugin/pom.xml
----------------------------------------------------------------------
diff --git a/plugins/maven-cayenne-plugin/pom.xml b/plugins/maven-cayenne-plugin/pom.xml
index d762d0d..cfd365c 100644
--- a/plugins/maven-cayenne-plugin/pom.xml
+++ b/plugins/maven-cayenne-plugin/pom.xml
@@ -109,12 +109,6 @@
         </dependency>
 
         <dependency>
-            <groupId>org.apache.maven</groupId>
-            <artifactId>maven-core</artifactId>
-            <scope>test</scope>
-        </dependency>
-
-        <dependency>
             <groupId>org.apache.cayenne</groupId>
             <artifactId>cayenne-server</artifactId>
             <version>${project.version}</version>

http://git-wip-us.apache.org/repos/asf/cayenne/blob/c63b6be2/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index 5345246..0575df7 100644
--- a/pom.xml
+++ b/pom.xml
@@ -22,7 +22,7 @@
 	<modelVersion>4.0.0</modelVersion>
 	<artifactId>cayenne-parent</artifactId>
 	<groupId>org.apache.cayenne</groupId>
-	<name>cayenne-parent: Top-level parent of Cayenne mdoules</name>
+	<name>cayenne-parent: Top-level parent of Cayenne modules</name>
 
 	<version>4.0.M5-SNAPSHOT</version>
 	<packaging>pom</packaging>
@@ -53,8 +53,9 @@
 		<module>cayenne-di</module>
 		<module>cayenne-server</module>
 		<module>cayenne-client</module>
+		<module>cayenne-cgen</module>
 		<module>cayenne-dbsync</module>
-		<module>cayenne-tools</module>
+		<module>cayenne-ant</module>
 		<module>cayenne-project</module>
 		<module>cayenne-lifecycle</module>
 		<module>cayenne-crypto</module>
@@ -65,7 +66,7 @@
 		<module>plugins</module>
 		<module>tutorials</module>
 		<module>docs</module>
-	</modules>
+    </modules>
 	<issueManagement>
 		<system>jira</system>
 		<url>https://issues.apache.org/jira/browse/CAY</url>


[02/10] cayenne git commit: CAY-2215 split cayenne-tools into cayenne-cgen and cayenne-ant

Posted by nt...@apache.org.
http://git-wip-us.apache.org/repos/asf/cayenne/blob/c63b6be2/cayenne-tools/src/test/java/org/apache/cayenne/gen/StringUtilsTest.java
----------------------------------------------------------------------
diff --git a/cayenne-tools/src/test/java/org/apache/cayenne/gen/StringUtilsTest.java b/cayenne-tools/src/test/java/org/apache/cayenne/gen/StringUtilsTest.java
deleted file mode 100644
index a11ba2f..0000000
--- a/cayenne-tools/src/test/java/org/apache/cayenne/gen/StringUtilsTest.java
+++ /dev/null
@@ -1,110 +0,0 @@
-/*****************************************************************
- *   Licensed to the Apache Software Foundation (ASF) under one
- *  or more contributor license agreements.  See the NOTICE file
- *  distributed with this work for additional information
- *  regarding copyright ownership.  The ASF licenses this file
- *  to you under the Apache License, Version 2.0 (the
- *  "License"); you may not use this file except in compliance
- *  with the License.  You may obtain a copy of the License at
- *
- *    http://www.apache.org/licenses/LICENSE-2.0
- *
- *  Unless required by applicable law or agreed to in writing,
- *  software distributed under the License is distributed on an
- *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- *  KIND, either express or implied.  See the License for the
- *  specific language governing permissions and limitations
- *  under the License.
- ****************************************************************/
-
-package org.apache.cayenne.gen;
-
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-
-import static org.junit.Assert.assertEquals;
-
-public class StringUtilsTest {
-
-    protected StringUtils stringUtils;
-
-    @Before
-    public void setUp() throws Exception {
-        stringUtils = new StringUtils();
-    }
-
-    @After
-    public void tearDown() throws Exception {
-        stringUtils = null;
-    }
-
-    @Test
-    public void testPluralize() throws Exception {
-        assertEquals("Words", stringUtils.pluralize("Word"));
-        assertEquals("Statuses", stringUtils.pluralize("Status"));
-        assertEquals("Indexes", stringUtils.pluralize("Index"));
-        assertEquals("Factories", stringUtils.pluralize("Factory"));
-        assertEquals("", stringUtils.pluralize(""));
-        assertEquals(null, stringUtils.pluralize(null));
-    }
-
-
-    @Test
-    public void testCapitalizedAsConstant1() throws Exception {
-        String expected = "LAST_NAME";
-        assertEquals(expected, stringUtils.capitalizedAsConstant("LastName"));
-    }
-
-    @Test
-    public void testCapitalizedAsConstant2() throws Exception {
-        String expected = "A_CLASS";
-        assertEquals(expected, stringUtils.capitalizedAsConstant("aClass"));
-    }
-
-    @Test
-    public void testCapitalizedAsConstant3() throws Exception {
-        String expected = "VAR_A";
-        assertEquals(expected, stringUtils.capitalizedAsConstant("varA"));
-    }
-
-    @Test
-    public void testCapitalizedAsConstant4() throws Exception {
-        String expected = "LAST_NAME";
-        assertEquals(expected, stringUtils.capitalizedAsConstant("LAST_NAME"));
-    }
-
-    @Test
-    public void testCapitalizedAsConstant5() throws Exception {
-        String expected = "ABC_A";
-        assertEquals(expected, stringUtils.capitalizedAsConstant("abc_A"));
-    }
-
-    @Test
-    public void testCapitalizedAsConstant6() throws Exception {
-        String expected = "A123";
-        assertEquals(expected, stringUtils.capitalizedAsConstant("a123"));
-    }
-
-    @Test
-    public void testCapitalizedAsConstant7() throws Exception {
-        String expected = "AB_CDEF";
-        assertEquals(expected, stringUtils.capitalizedAsConstant("abCDEF"));
-    }
-
-    @Test
-    public void testCapitalizedAsConstant8() throws Exception {
-        String expected = "AB_CE";
-        assertEquals(expected, stringUtils.capitalizedAsConstant("abCe"));
-    }
-
-    @Test
-    public void testStripGeneric() throws Exception {
-        assertEquals("List", stringUtils.stripGeneric("List"));
-        assertEquals("List", stringUtils.stripGeneric("List<Integer>"));
-        assertEquals("List", stringUtils.stripGeneric("List<List<Map<Integer,List<String>>>>"));
-        assertEquals("List123", stringUtils.stripGeneric("List<List<Map<Integer,List<String>>>>123"));
-        assertEquals("List<Integer", stringUtils.stripGeneric("List<Integer"));
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/cayenne/blob/c63b6be2/cayenne-tools/src/test/java/org/apache/cayenne/gen/SuperClassGenerationTest.java
----------------------------------------------------------------------
diff --git a/cayenne-tools/src/test/java/org/apache/cayenne/gen/SuperClassGenerationTest.java b/cayenne-tools/src/test/java/org/apache/cayenne/gen/SuperClassGenerationTest.java
deleted file mode 100644
index 0a47d63..0000000
--- a/cayenne-tools/src/test/java/org/apache/cayenne/gen/SuperClassGenerationTest.java
+++ /dev/null
@@ -1,86 +0,0 @@
-/*****************************************************************
- *   Licensed to the Apache Software Foundation (ASF) under one
- *  or more contributor license agreements.  See the NOTICE file
- *  distributed with this work for additional information
- *  regarding copyright ownership.  The ASF licenses this file
- *  to you under the Apache License, Version 2.0 (the
- *  "License"); you may not use this file except in compliance
- *  with the License.  You may obtain a copy of the License at
- *
- *    http://www.apache.org/licenses/LICENSE-2.0
- *
- *  Unless required by applicable law or agreed to in writing,
- *  software distributed under the License is distributed on an
- *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- *  KIND, either express or implied.  See the License for the
- *  specific language governing permissions and limitations
- *  under the License.
- ****************************************************************/
-
-package org.apache.cayenne.gen;
-
-import org.apache.cayenne.map.ObjAttribute;
-import org.apache.cayenne.map.ObjEntity;
-import org.apache.cayenne.map.ObjRelationship;
-import org.apache.velocity.VelocityContext;
-import org.junit.Test;
-
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
-
-public class SuperClassGenerationTest extends ClassGenerationCase {
-
-    @Test
-    public void testNotContainsPropertyImport() throws Exception {
-        ObjEntity objEntity = new ObjEntity("TEST1");
-
-        VelocityContext context = new VelocityContext();
-        context.put(Artifact.OBJECT_KEY, objEntity);
-
-        String res = renderTemplate(ClassGenerationAction.SUPERCLASS_TEMPLATE, context);
-        assertFalse(res.contains("org.apache.cayenne.exp.Property"));
-    }
-
-    @Test
-    public void testContainsPropertyImportForAttributes() throws Exception {
-        ObjEntity objEntity = new ObjEntity("TEST1");
-        ObjAttribute attr = new ObjAttribute("attr");
-        objEntity.addAttribute(attr);
-
-        VelocityContext context = new VelocityContext();
-        context.put(Artifact.OBJECT_KEY, objEntity);
-
-        String res = renderTemplate(ClassGenerationAction.SUPERCLASS_TEMPLATE, context);
-        assertTrue(res.contains("org.apache.cayenne.exp.Property"));
-    }
-
-    @Test
-    public void testContainsPropertyImportForRelationships() throws Exception {
-        ObjEntity objEntity = new ObjEntity("TEST1");
-        ObjRelationship rel = new ObjRelationship("rel");
-        objEntity.addRelationship(rel);
-
-        VelocityContext context = new VelocityContext();
-        context.put(Artifact.OBJECT_KEY, objEntity);
-
-        String res = renderTemplate(ClassGenerationAction.SUPERCLASS_TEMPLATE, context);
-        assertTrue(res.contains("org.apache.cayenne.exp.Property"));
-    }
-
-    @Test
-    public void testContainsPropertyImport() throws Exception {
-        ObjEntity objEntity = new ObjEntity("TEST1");
-        ObjAttribute attr = new ObjAttribute("attr");
-        ObjRelationship rel = new ObjRelationship("rel");
-
-        objEntity.addAttribute(attr);
-        objEntity.addRelationship(rel);
-
-        VelocityContext context = new VelocityContext();
-        context.put(Artifact.OBJECT_KEY, objEntity);
-
-        String res = renderTemplate(ClassGenerationAction.SUPERCLASS_TEMPLATE, context);
-        assertTrue(res.contains("org.apache.cayenne.exp.Property"));
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/cayenne/blob/c63b6be2/cayenne-tools/src/test/java/org/apache/cayenne/tools/AntDataPortDelegateTest.java
----------------------------------------------------------------------
diff --git a/cayenne-tools/src/test/java/org/apache/cayenne/tools/AntDataPortDelegateTest.java b/cayenne-tools/src/test/java/org/apache/cayenne/tools/AntDataPortDelegateTest.java
deleted file mode 100644
index 584d4c8..0000000
--- a/cayenne-tools/src/test/java/org/apache/cayenne/tools/AntDataPortDelegateTest.java
+++ /dev/null
@@ -1,53 +0,0 @@
-/*****************************************************************
- *   Licensed to the Apache Software Foundation (ASF) under one
- *  or more contributor license agreements.  See the NOTICE file
- *  distributed with this work for additional information
- *  regarding copyright ownership.  The ASF licenses this file
- *  to you under the Apache License, Version 2.0 (the
- *  "License"); you may not use this file except in compliance
- *  with the License.  You may obtain a copy of the License at
- *
- *    http://www.apache.org/licenses/LICENSE-2.0
- *
- *  Unless required by applicable law or agreed to in writing,
- *  software distributed under the License is distributed on an
- *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- *  KIND, either express or implied.  See the License for the
- *  specific language governing permissions and limitations
- *  under the License.
- ****************************************************************/
-
-package org.apache.cayenne.tools;
-
-import org.apache.cayenne.map.DataMap;
-import org.junit.Test;
-
-import java.util.regex.Pattern;
-
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
-
-@Deprecated
-public class AntDataPortDelegateTest {
-
-    @Test
-    public void testPassedDataMapFilter() {
-        AntDataPortDelegate delegate = new AntDataPortDelegate();
-
-        // filtering should be done based on map name
-
-        DataMap map = new DataMap();
-        assertTrue(delegate.passedDataMapFilter(map));
-
-        map.setName("A");
-        assertTrue(delegate.passedDataMapFilter(map));
-
-        delegate.mapFilters = new Pattern[] {
-            Pattern.compile("B")
-        };
-        assertFalse(delegate.passedDataMapFilter(map));
-
-        map.setName("BBBB");
-        assertTrue(delegate.passedDataMapFilter(map));
-    }
-}

http://git-wip-us.apache.org/repos/asf/cayenne/blob/c63b6be2/cayenne-tools/src/test/java/org/apache/cayenne/tools/CayenneGeneratorTaskCrossMapRelationshipsTest.java
----------------------------------------------------------------------
diff --git a/cayenne-tools/src/test/java/org/apache/cayenne/tools/CayenneGeneratorTaskCrossMapRelationshipsTest.java b/cayenne-tools/src/test/java/org/apache/cayenne/tools/CayenneGeneratorTaskCrossMapRelationshipsTest.java
deleted file mode 100644
index 40877b8..0000000
--- a/cayenne-tools/src/test/java/org/apache/cayenne/tools/CayenneGeneratorTaskCrossMapRelationshipsTest.java
+++ /dev/null
@@ -1,157 +0,0 @@
-/*****************************************************************
- *   Licensed to the Apache Software Foundation (ASF) under one
- *  or more contributor license agreements.  See the NOTICE file
- *  distributed with this work for additional information
- *  regarding copyright ownership.  The ASF licenses this file
- *  to you under the Apache License, Version 2.0 (the
- *  "License"); you may not use this file except in compliance
- *  with the License.  You may obtain a copy of the License at
- *
- *    http://www.apache.org/licenses/LICENSE-2.0
- *
- *  Unless required by applicable law or agreed to in writing,
- *  software distributed under the License is distributed on an
- *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- *  KIND, either express or implied.  See the License for the
- *  specific language governing permissions and limitations
- *  under the License.
- ****************************************************************/
-
-package org.apache.cayenne.tools;
-
-import org.apache.cayenne.test.file.FileUtil;
-import org.apache.cayenne.test.resource.ResourceUtil;
-import org.apache.tools.ant.Location;
-import org.apache.tools.ant.Project;
-import org.apache.tools.ant.types.FileList;
-import org.apache.tools.ant.types.Path;
-import org.junit.Test;
-
-import java.io.BufferedReader;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.InputStreamReader;
-import java.util.regex.Pattern;
-
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
-
-public class CayenneGeneratorTaskCrossMapRelationshipsTest {
-
-	/**
-	 * Tests pairs generation with a cross-DataMap relationship.
-	 */
-	@Test
-	public void testCrossDataMapRelationships() throws Exception {
-
-		CayenneGeneratorTask task = new CayenneGeneratorTask();
-		task.setProject(new Project());
-		task.setTaskName("Test");
-		task.setLocation(Location.UNKNOWN_LOCATION);
-
-		// prepare destination directory
-
-		File destDir = new File(FileUtil.baseTestDirectory(), "cgen12");
-		// prepare destination directory
-		if (!destDir.exists()) {
-			assertTrue(destDir.mkdirs());
-		}
-
-		File map = new File(destDir, "cgen-dependent.map.xml");
-		ResourceUtil.copyResourceToFile("org/apache/cayenne/tools/cgen-dependent.map.xml", map);
-
-		File additionalMaps[] = new File[1];
-		additionalMaps[0] = new File(destDir, "cgen.map.xml");
-		ResourceUtil.copyResourceToFile("org/apache/cayenne/tools/cgen.map.xml", additionalMaps[0]);
-
-		FileList additionalMapsFilelist = new FileList();
-		additionalMapsFilelist.setDir(additionalMaps[0].getParentFile());
-		additionalMapsFilelist.setFiles(additionalMaps[0].getName());
-
-		Path additionalMapsPath = new Path(task.getProject());
-		additionalMapsPath.addFilelist(additionalMapsFilelist);
-
-		// setup task
-		task.setMap(map);
-		task.setAdditionalMaps(additionalMapsPath);
-		task.setMakepairs(true);
-		task.setOverwrite(false);
-		task.setMode("entity");
-		task.setIncludeEntities("MyArtGroup");
-		task.setDestDir(destDir);
-		task.setSuperpkg("org.apache.cayenne.testdo.cgen2.auto");
-		task.setUsepkgpath(true);
-
-		// run task
-		task.execute();
-
-		// check results
-		File a = new File(destDir, convertPath("org/apache/cayenne/testdo/cgen2/MyArtGroup.java"));
-		assertTrue(a.isFile());
-		assertContents(a, "MyArtGroup", "org.apache.cayenne.testdo.cgen2", "_MyArtGroup");
-
-		File _a = new File(destDir, convertPath("org/apache/cayenne/testdo/cgen2/auto/_MyArtGroup.java"));
-		assertTrue(_a.exists());
-		assertContents(_a, "_MyArtGroup", "org.apache.cayenne.testdo.cgen2.auto", "CayenneDataObject");
-		assertContents(_a, "import org.apache.cayenne.testdo.testmap.ArtGroup;");
-		assertContents(_a, " ArtGroup getToParentGroup()");
-		assertContents(_a, "setToParentGroup(ArtGroup toParentGroup)");
-	}
-
-	private String convertPath(String unixPath) {
-		return unixPath.replace('/', File.separatorChar);
-	}
-
-	private void assertContents(File f, String content) throws Exception {
-
-		try (BufferedReader in = new BufferedReader(new InputStreamReader(new FileInputStream(f)));) {
-			String s = null;
-			while ((s = in.readLine()) != null) {
-				if (s.contains(content))
-					return;
-			}
-
-			fail("<" + content + "> not found in " + f.getAbsolutePath() + ".");
-		}
-
-	}
-
-	private void assertContents(File f, String className, String packageName, String extendsName) throws Exception {
-
-		try (BufferedReader in = new BufferedReader(new InputStreamReader(new FileInputStream(f)));) {
-			assertPackage(in, packageName);
-			assertClass(in, className, extendsName);
-		}
-	}
-
-	private void assertPackage(BufferedReader in, String packageName) throws Exception {
-
-		String s = null;
-		while ((s = in.readLine()) != null) {
-
-			if (Pattern.matches("^package\\s+([^\\s;]+);", s)) {
-				assertTrue(s.contains(packageName));
-				return;
-			}
-		}
-
-		fail("No package declaration found.");
-	}
-
-	private void assertClass(BufferedReader in, String className, String extendsName) throws Exception {
-
-		Pattern classPattern = Pattern.compile("^public\\s+");
-
-		String s = null;
-		while ((s = in.readLine()) != null) {
-			if (classPattern.matcher(s).find()) {
-				assertTrue(s.contains(className));
-				assertTrue(s.contains(extendsName));
-				assertTrue(s.indexOf(className) < s.indexOf(extendsName));
-				return;
-			}
-		}
-
-		fail("No class declaration found.");
-	}
-}

http://git-wip-us.apache.org/repos/asf/cayenne/blob/c63b6be2/cayenne-tools/src/test/java/org/apache/cayenne/tools/CayenneGeneratorTaskTest.java
----------------------------------------------------------------------
diff --git a/cayenne-tools/src/test/java/org/apache/cayenne/tools/CayenneGeneratorTaskTest.java b/cayenne-tools/src/test/java/org/apache/cayenne/tools/CayenneGeneratorTaskTest.java
deleted file mode 100644
index f6f616b..0000000
--- a/cayenne-tools/src/test/java/org/apache/cayenne/tools/CayenneGeneratorTaskTest.java
+++ /dev/null
@@ -1,317 +0,0 @@
-/*****************************************************************
- *   Licensed to the Apache Software Foundation (ASF) under one
- *  or more contributor license agreements.  See the NOTICE file
- *  distributed with this work for additional information
- *  regarding copyright ownership.  The ASF licenses this file
- *  to you under the Apache License, Version 2.0 (the
- *  "License"); you may not use this file except in compliance
- *  with the License.  You may obtain a copy of the License at
- *
- *    http://www.apache.org/licenses/LICENSE-2.0
- *
- *  Unless required by applicable law or agreed to in writing,
- *  software distributed under the License is distributed on an
- *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- *  KIND, either express or implied.  See the License for the
- *  specific language governing permissions and limitations
- *  under the License.
- ****************************************************************/
-
-package org.apache.cayenne.tools;
-
-import org.apache.cayenne.test.file.FileUtil;
-import org.apache.cayenne.test.resource.ResourceUtil;
-import org.apache.tools.ant.Location;
-import org.apache.tools.ant.Project;
-import org.junit.Before;
-import org.junit.Test;
-
-import java.io.BufferedReader;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.InputStreamReader;
-import java.util.regex.Pattern;
-
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
-
-public class CayenneGeneratorTaskTest {
-
-	private static final File baseDir;
-	private static final File map;
-	private static final File mapEmbeddables;
-	private static final File template;
-
-	static {
-
-		baseDir = FileUtil.baseTestDirectory();
-		map = new File(baseDir, "antmap.xml");
-		mapEmbeddables = new File(baseDir, "antmap-embeddables.xml");
-		template = new File(baseDir, "velotemplate.vm");
-
-		ResourceUtil.copyResourceToFile("testmap.map.xml", map);
-		ResourceUtil.copyResourceToFile("embeddable.map.xml", mapEmbeddables);
-		ResourceUtil.copyResourceToFile("org/apache/cayenne/tools/velotemplate.vm", template);
-	}
-
-	protected CayenneGeneratorTask task;
-
-	@Before
-	public void setUp() {
-
-		Project project = new Project();
-		project.setBaseDir(baseDir);
-
-		task = new CayenneGeneratorTask();
-		task.setProject(project);
-		task.setTaskName("Test");
-		task.setLocation(Location.UNKNOWN_LOCATION);
-	}
-
-	/**
-	 * Test single classes with a non-standard template.
-	 */
-	@Test
-	public void testSingleClassesCustTemplate() throws Exception {
-		// prepare destination directory
-		File mapDir = new File(baseDir, "single-classes-custtempl");
-		assertTrue(mapDir.mkdirs());
-
-		// setup task
-		task.setDestDir(mapDir);
-		task.setMap(map);
-		task.setMakepairs(false);
-		task.setUsepkgpath(true);
-		task.setTemplate(template.getPath());
-
-		// run task
-		task.execute();
-
-		// check results
-		File a = new File(mapDir, convertPath("org/apache/cayenne/testdo/testmap/Artist.java"));
-		assertTrue(a.isFile());
-		assertContents(a, "Artist", "org.apache.cayenne.testdo.testmap", "CayenneDataObject");
-
-		File _a = new File(mapDir, convertPath("org/apache/cayenne/testdo/testmap/_Artist.java"));
-		assertFalse(_a.exists());
-	}
-
-	/** Test single classes generation including full package path. */
-	@Test
-	public void testSingleClasses1() throws Exception {
-		// prepare destination directory
-		File mapDir = new File(baseDir, "single-classes-tree");
-		assertTrue(mapDir.mkdirs());
-
-		// setup task
-		task.setDestDir(mapDir);
-		task.setMap(map);
-		task.setMakepairs(false);
-		task.setUsepkgpath(true);
-
-		// run task
-		task.execute();
-
-		// check results
-		File a = new File(mapDir, convertPath("org/apache/cayenne/testdo/testmap/Artist.java"));
-		assertTrue(a.isFile());
-		assertContents(a, "Artist", "org.apache.cayenne.testdo.testmap", "CayenneDataObject");
-
-		File _a = new File(mapDir, convertPath("org/apache/cayenne/testdo/testmap/_Artist.java"));
-		assertFalse(_a.exists());
-	}
-
-	/** Test single classes generation ignoring package path. */
-	@Test
-	public void testSingleClasses2() throws Exception {
-		// prepare destination directory
-		File mapDir = new File(baseDir, "single-classes-flat");
-		assertTrue(mapDir.mkdirs());
-
-		// setup task
-		task.setDestDir(mapDir);
-		task.setMap(map);
-		task.setMakepairs(false);
-		task.setUsepkgpath(false);
-
-		// run task
-		task.execute();
-
-		// check results
-		File a = new File(mapDir, convertPath("Artist.java"));
-		assertTrue(a.exists());
-		assertContents(a, "Artist", "org.apache.cayenne.testdo.testmap", "CayenneDataObject");
-
-		File _a = new File(mapDir, convertPath("_Artist.java"));
-		assertFalse(_a.exists());
-
-		File pkga = new File(mapDir, convertPath("org/apache/cayenne/testdo/testmap/Artist.java"));
-		assertFalse(pkga.exists());
-	}
-
-	/**
-	 * Test pairs generation including full package path, default superclass
-	 * package.
-	 */
-	@Test
-	public void testPairs1() throws Exception {
-		// prepare destination directory
-		File mapDir = new File(baseDir, "pairs-tree");
-		assertTrue(mapDir.mkdirs());
-
-		// setup task
-		task.setDestDir(mapDir);
-		task.setMap(map);
-		task.setMakepairs(true);
-		task.setUsepkgpath(true);
-
-		// run task
-		task.execute();
-
-		// check results
-		File a = new File(mapDir, convertPath("org/apache/cayenne/testdo/testmap/Artist.java"));
-		assertTrue(a.isFile());
-		assertContents(a, "Artist", "org.apache.cayenne.testdo.testmap", "_Artist");
-
-		File _a = new File(mapDir, convertPath("org/apache/cayenne/testdo/testmap/auto/_Artist.java"));
-		assertTrue(_a.exists());
-		assertContents(_a, "_Artist", "org.apache.cayenne.testdo.testmap", "CayenneDataObject");
-	}
-
-	/** Test pairs generation in the same directory. */
-	@Test
-	public void testPairs2() throws Exception {
-		// prepare destination directory
-		File mapDir = new File(baseDir, "pairs-flat");
-		assertTrue(mapDir.mkdirs());
-
-		// setup task
-		task.setDestDir(mapDir);
-		task.setMap(map);
-		task.setMakepairs(true);
-		task.setUsepkgpath(false);
-
-		// run task
-		task.execute();
-
-		// check results
-		File a = new File(mapDir, convertPath("Artist.java"));
-		assertTrue(a.isFile());
-		assertContents(a, "Artist", "org.apache.cayenne.testdo.testmap", "_Artist");
-
-		File _a = new File(mapDir, convertPath("_Artist.java"));
-		assertTrue(_a.exists());
-		assertContents(_a, "_Artist", "org.apache.cayenne.testdo.testmap", "CayenneDataObject");
-
-		File pkga = new File(mapDir, convertPath("org/apache/cayenne/testdo/testmap/Artist.java"));
-		assertFalse(pkga.exists());
-	}
-
-	/**
-	 * Test pairs generation including full package path with superclass and
-	 * subclass in different packages.
-	 */
-	@Test
-	public void testPairs3() throws Exception {
-		// prepare destination directory
-		File mapDir = new File(baseDir, "pairs-tree-split");
-		assertTrue(mapDir.mkdirs());
-
-		// setup task
-		task.setDestDir(mapDir);
-		task.setMap(map);
-		task.setMakepairs(true);
-		task.setUsepkgpath(true);
-		task.setSuperpkg("org.apache.cayenne.testdo.testmap.superart");
-
-		// run task
-		task.execute();
-
-		// check results
-		File a = new File(mapDir, convertPath("org/apache/cayenne/testdo/testmap/Artist.java"));
-		assertTrue(a.isFile());
-		assertContents(a, "Artist", "org.apache.cayenne.testdo.testmap", "_Artist");
-
-		File _a = new File(mapDir, convertPath("org/apache/cayenne/testdo/testmap/superart/_Artist.java"));
-		assertTrue(_a.exists());
-		assertContents(_a, "_Artist", "org.apache.cayenne.testdo.testmap.superart", "CayenneDataObject");
-	}
-
-	@Test
-	public void testPairsEmbeddable3() throws Exception {
-		// prepare destination directory
-		File mapDir = new File(baseDir, "pairs-embeddables3-split");
-		assertTrue(mapDir.mkdirs());
-
-		// setup task
-		task.setDestDir(mapDir);
-		task.setMap(mapEmbeddables);
-		task.setMakepairs(true);
-		task.setUsepkgpath(true);
-		task.setSuperpkg("org.apache.cayenne.testdo.embeddable.auto");
-
-		// run task
-		task.execute();
-
-		// check entity results
-		File a = new File(mapDir, convertPath("org/apache/cayenne/testdo/embeddable/EmbedEntity1.java"));
-		assertTrue(a.isFile());
-		assertContents(a, "EmbedEntity1", "org.apache.cayenne.testdo.embeddable", "_EmbedEntity1");
-
-		File _a = new File(mapDir, convertPath("org/apache/cayenne/testdo/embeddable/auto/_EmbedEntity1.java"));
-		assertTrue(_a.exists());
-		assertContents(_a, "_EmbedEntity1", "org.apache.cayenne.testdo.embeddable.auto", "CayenneDataObject");
-
-		// check embeddable results
-		File e = new File(mapDir, convertPath("org/apache/cayenne/testdo/embeddable/Embeddable1.java"));
-		assertTrue(e.isFile());
-		assertContents(e, "Embeddable1", "org.apache.cayenne.testdo.embeddable", "_Embeddable1");
-
-		File _e = new File(mapDir, convertPath("org/apache/cayenne/testdo/embeddable/auto/_Embeddable1.java"));
-		assertTrue(_e.exists());
-		assertContents(_e, "_Embeddable1", "org.apache.cayenne.testdo.embeddable.auto", "Object");
-	}
-
-	private String convertPath(String unixPath) {
-		return unixPath.replace('/', File.separatorChar);
-	}
-
-	private void assertContents(File f, String className, String packageName, String extendsName) throws Exception {
-
-		try (BufferedReader in = new BufferedReader(new InputStreamReader(new FileInputStream(f)));) {
-			assertPackage(in, packageName);
-			assertClass(in, className, extendsName);
-		}
-	}
-
-	private void assertPackage(BufferedReader in, String packageName) throws Exception {
-
-		String s = null;
-		while ((s = in.readLine()) != null) {
-			if (Pattern.matches("^package\\s+([^\\s;]+);", s)) {
-				assertTrue(s.indexOf(packageName) > 0);
-				return;
-			}
-		}
-
-		fail("No package declaration found.");
-	}
-
-	private void assertClass(BufferedReader in, String className, String extendsName) throws Exception {
-
-		Pattern classPattern = Pattern.compile("^public\\s+");
-
-		String s = null;
-		while ((s = in.readLine()) != null) {
-			if (classPattern.matcher(s).find()) {
-				assertTrue(s.indexOf(className) > 0);
-				assertTrue(s.indexOf(extendsName) > 0);
-				assertTrue(s.indexOf(className) < s.indexOf(extendsName));
-				return;
-			}
-		}
-
-		fail("No class declaration found.");
-	}
-}

http://git-wip-us.apache.org/repos/asf/cayenne/blob/c63b6be2/cayenne-tools/src/test/java/org/apache/cayenne/tools/DbGeneratorTaskTest.java
----------------------------------------------------------------------
diff --git a/cayenne-tools/src/test/java/org/apache/cayenne/tools/DbGeneratorTaskTest.java b/cayenne-tools/src/test/java/org/apache/cayenne/tools/DbGeneratorTaskTest.java
deleted file mode 100644
index bd02e12..0000000
--- a/cayenne-tools/src/test/java/org/apache/cayenne/tools/DbGeneratorTaskTest.java
+++ /dev/null
@@ -1,75 +0,0 @@
-/*****************************************************************
- *   Licensed to the Apache Software Foundation (ASF) under one
- *  or more contributor license agreements.  See the NOTICE file
- *  distributed with this work for additional information
- *  regarding copyright ownership.  The ASF licenses this file
- *  to you under the Apache License, Version 2.0 (the
- *  "License"); you may not use this file except in compliance
- *  with the License.  You may obtain a copy of the License at
- *
- *    http://www.apache.org/licenses/LICENSE-2.0
- *
- *  Unless required by applicable law or agreed to in writing,
- *  software distributed under the License is distributed on an
- *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- *  KIND, either express or implied.  See the License for the
- *  specific language governing permissions and limitations
- *  under the License.
- ****************************************************************/
-
-package org.apache.cayenne.tools;
-
-import org.apache.cayenne.dba.AutoAdapter;
-import org.apache.cayenne.dba.DbAdapter;
-import org.apache.cayenne.dba.sqlserver.SQLServerAdapter;
-import org.apache.cayenne.dbsync.reverse.configuration.ToolsModule;
-import org.apache.cayenne.di.DIBootstrap;
-import org.apache.cayenne.di.Injector;
-import org.apache.commons.logging.Log;
-import org.junit.Test;
-
-import javax.sql.DataSource;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
-import static org.mockito.Mockito.mock;
-
-public class DbGeneratorTaskTest {
-
-    @Test
-    public void testSetUserName() throws Exception {
-        DbGeneratorTask task = new DbGeneratorTask();
-        task.setUserName("abc");
-        assertEquals("abc", task.userName);
-    }
-
-    @Test
-    public void testSetPassword() throws Exception {
-        DbGeneratorTask task = new DbGeneratorTask();
-        task.setPassword("xyz");
-        assertEquals("xyz", task.password);
-    }
-
-    @Test
-    public void testSetAdapter() throws Exception {
-        DataSource ds = mock(DataSource.class);
-        Injector injector = DIBootstrap.createInjector(new ToolsModule(mock(Log.class)));
-
-        DbGeneratorTask task = new DbGeneratorTask();
-
-        DbAdapter autoAdapter = task.getAdapter(injector, ds);
-        assertTrue(autoAdapter instanceof AutoAdapter);
-
-        task.setAdapter(SQLServerAdapter.class.getName());
-
-        DbAdapter sqlServerAdapter = task.getAdapter(injector, ds);
-        assertTrue(sqlServerAdapter instanceof SQLServerAdapter);
-    }
-
-    @Test
-    public void testSetUrl() throws Exception {
-        DbGeneratorTask task = new DbGeneratorTask();
-        task.setUrl("jdbc:///");
-        assertEquals("jdbc:///", task.url);
-    }
-}

http://git-wip-us.apache.org/repos/asf/cayenne/blob/c63b6be2/cayenne-tools/src/test/java/org/apache/cayenne/tools/DbImporterTaskTest.java
----------------------------------------------------------------------
diff --git a/cayenne-tools/src/test/java/org/apache/cayenne/tools/DbImporterTaskTest.java b/cayenne-tools/src/test/java/org/apache/cayenne/tools/DbImporterTaskTest.java
deleted file mode 100644
index df746c2..0000000
--- a/cayenne-tools/src/test/java/org/apache/cayenne/tools/DbImporterTaskTest.java
+++ /dev/null
@@ -1,229 +0,0 @@
-/*****************************************************************
- *   Licensed to the Apache Software Foundation (ASF) under one
- *  or more contributor license agreements.  See the NOTICE file
- *  distributed with this work for additional information
- *  regarding copyright ownership.  The ASF licenses this file
- *  to you under the Apache License, Version 2.0 (the
- *  "License"); you may not use this file except in compliance
- *  with the License.  You may obtain a copy of the License at
- *
- *    http://www.apache.org/licenses/LICENSE-2.0
- *
- *  Unless required by applicable law or agreed to in writing,
- *  software distributed under the License is distributed on an
- *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- *  KIND, either express or implied.  See the License for the
- *  specific language governing permissions and limitations
- *  under the License.
- ****************************************************************/
-package org.apache.cayenne.tools;
-
-import org.apache.cayenne.dbsync.reverse.dbimport.DbImportConfiguration;
-import org.apache.cayenne.test.file.FileUtil;
-import org.apache.cayenne.test.jdbc.SQLReader;
-import org.apache.cayenne.test.resource.ResourceUtil;
-import org.apache.tools.ant.Project;
-import org.apache.tools.ant.ProjectHelper;
-import org.apache.tools.ant.UnknownElement;
-import org.apache.tools.ant.util.FileUtils;
-import org.custommonkey.xmlunit.DetailedDiff;
-import org.custommonkey.xmlunit.Diff;
-import org.custommonkey.xmlunit.Difference;
-import org.custommonkey.xmlunit.XMLUnit;
-import org.junit.Test;
-import org.xml.sax.SAXException;
-
-import java.io.File;
-import java.io.FileReader;
-import java.io.IOException;
-import java.net.URL;
-import java.sql.Connection;
-import java.sql.DriverManager;
-import java.sql.ResultSet;
-import java.sql.SQLException;
-import java.sql.Statement;
-import java.util.List;
-
-import static org.apache.cayenne.dbsync.reverse.dbimport.ReverseEngineeringUtils.*;
-import static org.apache.commons.lang.StringUtils.isBlank;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
-
-// TODO: we are only testing on Derby. We may need to dynamically switch between DBs 
-// based on "cayenneTestConnection", like we do in cayenne-server, etc.
-public class DbImporterTaskTest {
-
-    static {
-        XMLUnit.setIgnoreWhitespace(true);
-    }
-
-    private static File distDir(String name) {
-        File distDir = new File(FileUtil.baseTestDirectory(), "cdbImport");
-        File file = new File(distDir, name);
-        distDir = file.getParentFile();
-        // prepare destination directory
-        if (!distDir.exists()) {
-            assertTrue(distDir.mkdirs());
-        }
-        return file;
-    }
-
-    @Test
-    public void testLoadCatalog() throws Exception {
-        assertCatalog(getCdbImport("build-catalog.xml").getReverseEngineering());
-    }
-
-    @Test
-    public void testLoadSchema() throws Exception {
-        assertSchema(getCdbImport("build-schema.xml").getReverseEngineering());
-    }
-
-    @Test
-    public void testLoadCatalogAndSchema() throws Exception {
-        assertCatalogAndSchema(getCdbImport("build-catalog-and-schema.xml").getReverseEngineering());
-    }
-
-    @Test
-    public void testLoadFlat() throws Exception {
-        assertFlat(getCdbImport("build-flat.xml").getReverseEngineering());
-    }
-
-    @Test
-    public void testSkipRelationshipsLoading() throws Exception {
-        assertSkipRelationshipsLoading(getCdbImport("build-skip-relationships-loading.xml").getReverseEngineering());
-    }
-
-    @Test
-    public void testTableTypes() throws Exception {
-        assertTableTypes(getCdbImport("build-table-types.xml").getReverseEngineering());
-    }
-
-    @Test
-    public void testIncludeTable() throws Exception {
-        test("build-include-table.xml");
-    }
-
-    private DbImporterTask getCdbImport(String buildFile) {
-        Project project = new Project();
-
-        File map = distDir(buildFile);
-        ResourceUtil.copyResourceToFile(getPackagePath() + "/" + buildFile, map);
-        ProjectHelper.configureProject(project, map);
-
-        UnknownElement task = (UnknownElement) project.getTargets().get("dist").getTasks()[0];
-        task.maybeConfigure();
-
-        return (DbImporterTask) task.getRealThing();
-    }
-
-    private String getPackagePath() {
-        return getClass().getPackage().getName().replace('.', '/');
-    }
-
-    private void test(String name) throws Exception {
-        DbImporterTask cdbImport = getCdbImport(name);
-        File mapFile = cdbImport.getMap();
-
-        URL mapUrlRes = this.getClass().getResource(mapFile.getName() + "-result");
-        assertTrue(mapUrlRes != null && new File(mapUrlRes.toURI()).exists());
-        assertTrue(ResourceUtil
-                .copyResourceToFile(mapUrlRes, new File(mapFile.getParentFile(), mapFile.getName() + "-result")));
-
-
-        File mapFileCopy = distDir("copy-" + mapFile.getName());
-        if (mapFile.exists()) {
-            FileUtils.getFileUtils().copyFile(mapFile, mapFileCopy);
-            cdbImport.setMap(mapFileCopy);
-        } else {
-            mapFileCopy = mapFile;
-        }
-
-        prepareDatabase(name, cdbImport.toParameters());
-
-        try {
-            cdbImport.execute();
-            verifyResult(mapFile, mapFileCopy);
-        } finally {
-            cleanDb(cdbImport.toParameters());
-        }
-    }
-
-    private void cleanDb(DbImportConfiguration dbImportConfiguration) throws ClassNotFoundException,
-            IllegalAccessException, InstantiationException, SQLException {
-        Class.forName(dbImportConfiguration.getDriver()).newInstance();
-        // Get a connection
-        Connection connection = DriverManager.getConnection(dbImportConfiguration.getUrl());
-        Statement stmt = connection.createStatement();
-
-        ResultSet tables = connection.getMetaData().getTables(null, null, null, new String[]{"TABLE"});
-        while (tables.next()) {
-            String schema = tables.getString("TABLE_SCHEM");
-            System.out.println("DROP TABLE " + (isBlank(schema) ? "" : schema + ".") + tables.getString("TABLE_NAME"));
-            stmt.execute("DROP TABLE " + (isBlank(schema) ? "" : schema + ".") + tables.getString("TABLE_NAME"));
-        }
-
-        ResultSet schemas = connection.getMetaData().getSchemas();
-        while (schemas.next()) {
-            String schem = schemas.getString("TABLE_SCHEM");
-            if (schem.startsWith("SCHEMA")) {
-                System.out.println("DROP SCHEMA " + schem);
-                stmt.execute("DROP SCHEMA " + schem + " RESTRICT");
-            }
-        }
-    }
-
-    @SuppressWarnings("unchecked")
-    private void verifyResult(File map, File mapFileCopy) {
-        try {
-            FileReader control = new FileReader(map.getAbsolutePath() + "-result");
-            FileReader test = new FileReader(mapFileCopy);
-
-            DetailedDiff diff = new DetailedDiff(new Diff(control, test));
-            if (!diff.similar()) {
-                for (Difference d : ((List<Difference>) diff.getAllDifferences())) {
-
-                    System.out.println("-------------------------------------------");
-                    System.out.println(d.getTestNodeDetail().getNode());
-                    System.out.println(d.getControlNodeDetail().getValue());
-                }
-                fail(diff.toString());
-            }
-
-        } catch (SAXException e) {
-            e.printStackTrace();
-            fail();
-        } catch (IOException e) {
-            e.printStackTrace();
-            fail();
-        }
-    }
-
-    private void prepareDatabase(String sqlFile, DbImportConfiguration dbImportConfiguration) throws Exception {
-
-        URL sqlUrl = ResourceUtil.getResource(getClass(), sqlFile + ".sql");
-        assertNotNull(sqlUrl);
-
-        Class.forName(dbImportConfiguration.getDriver()).newInstance();
-
-        try (Connection c = DriverManager.getConnection(dbImportConfiguration.getUrl());) {
-
-            // TODO: move parsing SQL files to a common utility (DBHelper?) .
-            // ALso see UnitDbApater.executeDDL - this should use the same
-            // utility
-
-            try (Statement stmt = c.createStatement();) {
-                for (String sql : SQLReader.statements(sqlUrl, ";")) {
-
-                    // skip comments
-                    if (sql.startsWith("-- ")) {
-                        continue;
-                    }
-
-                    stmt.execute(sql);
-                }
-            }
-        }
-    }
-
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/cayenne/blob/c63b6be2/cayenne-tools/src/test/resources/embeddable.map.xml
----------------------------------------------------------------------
diff --git a/cayenne-tools/src/test/resources/embeddable.map.xml b/cayenne-tools/src/test/resources/embeddable.map.xml
deleted file mode 100644
index 0b5c0b8..0000000
--- a/cayenne-tools/src/test/resources/embeddable.map.xml
+++ /dev/null
@@ -1,27 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<data-map xmlns="http://cayenne.apache.org/schema/3.0/modelMap"
-	 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
-	 xsi:schemaLocation="http://cayenne.apache.org/schema/3.0/modelMap http://cayenne.apache.org/schema/3.0/modelMap.xsd"
-	 project-version="6">
-	<property name="defaultPackage" value="org.apache.cayenne.testdo.embeddable"/>
-	<embeddable className="org.apache.cayenne.testdo.embeddable.Embeddable1">
-		<embeddable-attribute name="embedded10" type="java.lang.String" db-attribute-name="EMBEDDED10"/>
-		<embeddable-attribute name="embedded20" type="java.lang.String" db-attribute-name="EMBEDDED20"/>
-	</embeddable>
-	<db-entity name="EMBED_ENTITY1">
-		<db-attribute name="EMBEDDED10" type="VARCHAR" length="100"/>
-		<db-attribute name="EMBEDDED20" type="VARCHAR" length="100"/>
-		<db-attribute name="EMBEDDED30" type="VARCHAR" length="100"/>
-		<db-attribute name="EMBEDDED40" type="VARCHAR" length="100"/>
-		<db-attribute name="ID" type="INTEGER" isPrimaryKey="true" isMandatory="true"/>
-		<db-attribute name="NAME" type="VARCHAR" length="100"/>
-	</db-entity>
-	<obj-entity name="EmbedEntity1" className="org.apache.cayenne.testdo.embeddable.EmbedEntity1" dbEntityName="EMBED_ENTITY1">
-		<embedded-attribute name="embedded1" type="org.apache.cayenne.testdo.embeddable.Embeddable1"/>
-		<embedded-attribute name="embedded2" type="org.apache.cayenne.testdo.embeddable.Embeddable1">
-			<embeddable-attribute-override name="embedded10" db-attribute-path="EMBEDDED30"/>
-			<embeddable-attribute-override name="embedded20" db-attribute-path="EMBEDDED40"/>
-		</embedded-attribute>
-		<obj-attribute name="name" type="java.lang.String" db-attribute-path="NAME"/>
-	</obj-entity>
-</data-map>

http://git-wip-us.apache.org/repos/asf/cayenne/blob/c63b6be2/cayenne-tools/src/test/resources/org/apache/cayenne/tools/build-catalog-and-schema.xml
----------------------------------------------------------------------
diff --git a/cayenne-tools/src/test/resources/org/apache/cayenne/tools/build-catalog-and-schema.xml b/cayenne-tools/src/test/resources/org/apache/cayenne/tools/build-catalog-and-schema.xml
deleted file mode 100644
index ee44b9c..0000000
--- a/cayenne-tools/src/test/resources/org/apache/cayenne/tools/build-catalog-and-schema.xml
+++ /dev/null
@@ -1,78 +0,0 @@
-<!--
-  ~ Licensed to the Apache Software Foundation (ASF) under one
-  ~    or more contributor license agreements.  See the NOTICE file
-  ~    distributed with this work for additional information
-  ~    regarding copyright ownership.  The ASF licenses this file
-  ~    to you under the Apache License, Version 2.0 (the
-  ~    "License"); you may not use this file except in compliance
-  ~    with the License.  You may obtain a copy of the License at
-  ~
-  ~      http://www.apache.org/licenses/LICENSE-2.0
-  ~
-  ~    Unless required by applicable law or agreed to in writing,
-  ~    software distributed under the License is distributed on an
-  ~    "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-  ~    KIND, either express or implied.  See the License for the
-  ~    specific language governing permissions and limitations
-  ~    under the License.
-  -->
-
-<project name="MyProject" default="dist" basedir=".">
-
-    <taskdef name="cdbimport" classname="org.apache.cayenne.tools.DbImporterTask" taskname="cdbimport"
-             classpath="${basedir}"/>
-
-    <target name="dist">
-        <cdbimport map="${context.dir}/WEB-INF/DefaultMap.map.xml"
-                   adapter="org.apache.cayenne.dba.hsqldb.HSQLDBAdapter"
-                   driver="org.hsqldb.jdbcDriver"
-                   url="jdbc:hsqldb:hsql://localhost/bookmarker"
-                   username="sa">
-
-            <catalog name="catalog-name">
-                <schema name="schema-name">
-                    <includeTable>includeTable-01</includeTable>
-
-                    <includeTable>
-                        <pattern>includeTable-02</pattern>
-                    </includeTable>
-
-                    <includeTable pattern="includeTable-03">
-                        <includeColumn pattern="includeColumn-01"/>
-                        <excludeColumn pattern="excludeColumn-01"/>
-                    </includeTable>
-
-                    <excludeTable>excludeTable-01</excludeTable>
-                    <excludeTable>
-                        <pattern>excludeTable-02</pattern>
-                    </excludeTable>
-                    <excludeTable pattern="excludeTable-03"/>
-
-                    <includeColumn>includeColumn-01</includeColumn>
-                    <includeColumn>
-                        <pattern>includeColumn-02</pattern>
-                    </includeColumn>
-                    <includeColumn pattern="includeColumn-03"/>
-                    <excludeColumn>excludeColumn-01</excludeColumn>
-                    <excludeColumn>
-                        <pattern>excludeColumn-02</pattern>
-                    </excludeColumn>
-                    <excludeColumn pattern="excludeColumn-03"/>
-
-                    <includeProcedure>includeProcedure-01</includeProcedure>
-                    <includeProcedure>
-                        <pattern>includeProcedure-02</pattern>
-                    </includeProcedure>
-                    <includeProcedure pattern="includeProcedure-03"/>
-                    <excludeProcedure>excludeProcedure-01</excludeProcedure>
-                    <excludeProcedure>
-                        <pattern>excludeProcedure-02</pattern>
-                    </excludeProcedure>
-                    <excludeProcedure pattern="excludeProcedure-03"/>
-                </schema>
-            </catalog>
-        </cdbimport>
-    </target>
-
-
-</project>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/cayenne/blob/c63b6be2/cayenne-tools/src/test/resources/org/apache/cayenne/tools/build-catalog.xml
----------------------------------------------------------------------
diff --git a/cayenne-tools/src/test/resources/org/apache/cayenne/tools/build-catalog.xml b/cayenne-tools/src/test/resources/org/apache/cayenne/tools/build-catalog.xml
deleted file mode 100644
index fa1781b..0000000
--- a/cayenne-tools/src/test/resources/org/apache/cayenne/tools/build-catalog.xml
+++ /dev/null
@@ -1,82 +0,0 @@
-<!--
-  ~ Licensed to the Apache Software Foundation (ASF) under one
-  ~    or more contributor license agreements.  See the NOTICE file
-  ~    distributed with this work for additional information
-  ~    regarding copyright ownership.  The ASF licenses this file
-  ~    to you under the Apache License, Version 2.0 (the
-  ~    "License"); you may not use this file except in compliance
-  ~    with the License.  You may obtain a copy of the License at
-  ~
-  ~      http://www.apache.org/licenses/LICENSE-2.0
-  ~
-  ~    Unless required by applicable law or agreed to in writing,
-  ~    software distributed under the License is distributed on an
-  ~    "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-  ~    KIND, either express or implied.  See the License for the
-  ~    specific language governing permissions and limitations
-  ~    under the License.
-  -->
-
-<project name="MyProject" default="dist" basedir=".">
-
-    <taskdef name="cdbimport" classname="org.apache.cayenne.tools.DbImporterTask" taskname="cdbimport"
-             classpath="${basedir}"/>
-
-    <target name="dist">
-        <cdbimport map="${context.dir}/WEB-INF/DefaultMap.map.xml"
-                   adapter="org.apache.cayenne.dba.hsqldb.HSQLDBAdapter"
-                   driver="org.hsqldb.jdbcDriver"
-                   url="jdbc:hsqldb:hsql://localhost/bookmarker"
-                   username="sa">
-
-            <catalog>catalog-name-01</catalog>
-
-            <catalog>
-                <name>catalog-name-02</name>
-            </catalog>
-
-            <catalog name="catalog-name-03">
-                <includeTable>includeTable-01</includeTable>
-
-                <includeTable>
-                    <pattern>includeTable-02</pattern>
-                </includeTable>
-
-                <includeTable pattern="includeTable-03">
-                    <includeColumn pattern="includeColumn-01"/>
-                    <excludeColumn pattern="excludeColumn-01"/>
-                </includeTable>
-
-                <excludeTable>excludeTable-01</excludeTable>
-                <excludeTable>
-                    <pattern>excludeTable-02</pattern>
-                </excludeTable>
-                <excludeTable pattern="excludeTable-03"/>
-
-                <includeColumn>includeColumn-01</includeColumn>
-                <includeColumn>
-                    <pattern>includeColumn-02</pattern>
-                </includeColumn>
-                <includeColumn pattern="includeColumn-03"/>
-                <excludeColumn>excludeColumn-01</excludeColumn>
-                <excludeColumn>
-                    <pattern>excludeColumn-02</pattern>
-                </excludeColumn>
-                <excludeColumn pattern="excludeColumn-03"/>
-
-                <includeProcedure>includeProcedure-01</includeProcedure>
-                <includeProcedure>
-                    <pattern>includeProcedure-02</pattern>
-                </includeProcedure>
-                <includeProcedure pattern="includeProcedure-03"/>
-                <excludeProcedure>excludeProcedure-01</excludeProcedure>
-                <excludeProcedure>
-                    <pattern>excludeProcedure-02</pattern>
-                </excludeProcedure>
-                <excludeProcedure pattern="excludeProcedure-03"/>
-            </catalog>
-        </cdbimport>
-    </target>
-
-
-</project>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/cayenne/blob/c63b6be2/cayenne-tools/src/test/resources/org/apache/cayenne/tools/build-flat.xml
----------------------------------------------------------------------
diff --git a/cayenne-tools/src/test/resources/org/apache/cayenne/tools/build-flat.xml b/cayenne-tools/src/test/resources/org/apache/cayenne/tools/build-flat.xml
deleted file mode 100644
index 286bcf3..0000000
--- a/cayenne-tools/src/test/resources/org/apache/cayenne/tools/build-flat.xml
+++ /dev/null
@@ -1,73 +0,0 @@
-<!--
-  ~ Licensed to the Apache Software Foundation (ASF) under one
-  ~    or more contributor license agreements.  See the NOTICE file
-  ~    distributed with this work for additional information
-  ~    regarding copyright ownership.  The ASF licenses this file
-  ~    to you under the Apache License, Version 2.0 (the
-  ~    "License"); you may not use this file except in compliance
-  ~    with the License.  You may obtain a copy of the License at
-  ~
-  ~      http://www.apache.org/licenses/LICENSE-2.0
-  ~
-  ~    Unless required by applicable law or agreed to in writing,
-  ~    software distributed under the License is distributed on an
-  ~    "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-  ~    KIND, either express or implied.  See the License for the
-  ~    specific language governing permissions and limitations
-  ~    under the License.
-  -->
-
-<project name="MyProject" default="dist" basedir=".">
-
-    <taskdef name="cdbimport" classname="org.apache.cayenne.tools.DbImporterTask" taskname="cdbimport"
-             classpath="${basedir}"/>
-
-    <target name="dist">
-        <cdbimport map="${context.dir}/WEB-INF/DefaultMap.map.xml"
-                   adapter="org.apache.cayenne.dba.hsqldb.HSQLDBAdapter"
-                   driver="org.hsqldb.jdbcDriver"
-                   url="jdbc:hsqldb:hsql://localhost/bookmarker"
-                   username="sa">
-            <includeTable>includeTable-01</includeTable>
-
-            <includeTable>
-                <pattern>includeTable-02</pattern>
-            </includeTable>
-
-            <includeTable pattern="includeTable-03">
-                <includeColumn pattern="includeColumn-01"/>
-                <excludeColumn pattern="excludeColumn-01"/>
-            </includeTable>
-
-            <excludeTable>excludeTable-01</excludeTable>
-            <excludeTable>
-                <pattern>excludeTable-02</pattern>
-            </excludeTable>
-            <excludeTable pattern="excludeTable-03"/>
-
-            <includeColumn>includeColumn-01</includeColumn>
-            <includeColumn>
-                <pattern>includeColumn-02</pattern>
-            </includeColumn>
-            <includeColumn pattern="includeColumn-03"/>
-            <excludeColumn>excludeColumn-01</excludeColumn>
-            <excludeColumn>
-                <pattern>excludeColumn-02</pattern>
-            </excludeColumn>
-            <excludeColumn pattern="excludeColumn-03"/>
-
-            <includeProcedure>includeProcedure-01</includeProcedure>
-            <includeProcedure>
-                <pattern>includeProcedure-02</pattern>
-            </includeProcedure>
-            <includeProcedure pattern="includeProcedure-03"/>
-            <excludeProcedure>excludeProcedure-01</excludeProcedure>
-            <excludeProcedure>
-                <pattern>excludeProcedure-02</pattern>
-            </excludeProcedure>
-            <excludeProcedure pattern="excludeProcedure-03"/>
-        </cdbimport>
-    </target>
-
-
-</project>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/cayenne/blob/c63b6be2/cayenne-tools/src/test/resources/org/apache/cayenne/tools/build-include-table.map.xml-result
----------------------------------------------------------------------
diff --git a/cayenne-tools/src/test/resources/org/apache/cayenne/tools/build-include-table.map.xml-result b/cayenne-tools/src/test/resources/org/apache/cayenne/tools/build-include-table.map.xml-result
deleted file mode 100644
index 5c0d2b6..0000000
--- a/cayenne-tools/src/test/resources/org/apache/cayenne/tools/build-include-table.map.xml-result
+++ /dev/null
@@ -1,37 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!--
-	Licensed to the Apache Software Foundation (ASF) under one
-	or more contributor license agreements.  See the NOTICE file
-	distributed with this work for additional information
-	regarding copyright ownership.  The ASF licenses this file
-	to you under the Apache License, Version 2.0 (the
-	"License"); you may not use this file except in compliance
-	with the License.  You may obtain a copy of the License at
-
-	http://www.apache.org/licenses/LICENSE-2.0
-
-	Unless required by applicable law or agreed to in writing,
-	software distributed under the License is distributed on an
-	"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-	KIND, either express or implied.  See the License for the
-	specific language governing permissions and limitations
-	under the License.
--->
-<data-map xmlns="http://cayenne.apache.org/schema/9/modelMap"
-          xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
-          xsi:schemaLocation="http://cayenne.apache.org/schema/9/modelMap http://cayenne.apache.org/schema/9/modelMap.xsd"
-          project-version="9">
-    <db-entity name="PARENT" schema="APP">
-        <db-attribute name="COL2" type="CHAR" length="25"/>
-        <db-attribute name="COL3" type="DECIMAL" length="10" scale="2"/>
-        <db-attribute name="COL4" type="VARCHAR" length="25"/>
-        <db-attribute name="COL5" type="DATE" length="10"/>
-        <db-attribute name="ID" type="INTEGER" isPrimaryKey="true" isMandatory="true" length="10"/>
-    </db-entity>
-    <obj-entity name="Parent" className="Parent" dbEntityName="PARENT">
-        <obj-attribute name="col2" type="java.lang.String" db-attribute-path="COL2"/>
-        <obj-attribute name="col3" type="java.math.BigDecimal" db-attribute-path="COL3"/>
-        <obj-attribute name="col4" type="java.lang.String" db-attribute-path="COL4"/>
-        <obj-attribute name="col5" type="java.util.Date" db-attribute-path="COL5"/>
-    </obj-entity>
-</data-map>

http://git-wip-us.apache.org/repos/asf/cayenne/blob/c63b6be2/cayenne-tools/src/test/resources/org/apache/cayenne/tools/build-include-table.xml
----------------------------------------------------------------------
diff --git a/cayenne-tools/src/test/resources/org/apache/cayenne/tools/build-include-table.xml b/cayenne-tools/src/test/resources/org/apache/cayenne/tools/build-include-table.xml
deleted file mode 100644
index befa01b..0000000
--- a/cayenne-tools/src/test/resources/org/apache/cayenne/tools/build-include-table.xml
+++ /dev/null
@@ -1,34 +0,0 @@
-<!--
-  ~ Licensed to the Apache Software Foundation (ASF) under one
-  ~    or more contributor license agreements.  See the NOTICE file
-  ~    distributed with this work for additional information
-  ~    regarding copyright ownership.  The ASF licenses this file
-  ~    to you under the Apache License, Version 2.0 (the
-  ~    "License"); you may not use this file except in compliance
-  ~    with the License.  You may obtain a copy of the License at
-  ~
-  ~      http://www.apache.org/licenses/LICENSE-2.0
-  ~
-  ~    Unless required by applicable law or agreed to in writing,
-  ~    software distributed under the License is distributed on an
-  ~    "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-  ~    KIND, either express or implied.  See the License for the
-  ~    specific language governing permissions and limitations
-  ~    under the License.
-  -->
-
-<project name="MyProject" default="dist" basedir="../">
-
-    <taskdef name="cdbimport" classname="org.apache.cayenne.tools.DbImporterTask" taskname="cdbimport"
-             classpath="${basedir}"/>
-
-    <target name="dist">
-        <cdbimport map="build-include-table.map.xml"
-                   driver="org.apache.derby.jdbc.EmbeddedDriver"
-                   url="jdbc:derby:memory:DbImporterMojoTest;create=true">
-            <includeTable>Parent</includeTable>
-        </cdbimport>
-    </target>
-
-
-</project>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/cayenne/blob/c63b6be2/cayenne-tools/src/test/resources/org/apache/cayenne/tools/build-include-table.xml.sql
----------------------------------------------------------------------
diff --git a/cayenne-tools/src/test/resources/org/apache/cayenne/tools/build-include-table.xml.sql b/cayenne-tools/src/test/resources/org/apache/cayenne/tools/build-include-table.xml.sql
deleted file mode 100644
index e392d08..0000000
--- a/cayenne-tools/src/test/resources/org/apache/cayenne/tools/build-include-table.xml.sql
+++ /dev/null
@@ -1,38 +0,0 @@
---  Licensed to the Apache Software Foundation (ASF) under one
---  or more contributor license agreements.  See the NOTICE file
---  distributed with this work for additional information
--- regarding copyright ownership.  The ASF licenses this file
---  to you under the Apache License, Version 2.0 (the
---  "License"); you may not use this file except in compliance
---  with the License.  You may obtain a copy of the License at
---
---    http://www.apache.org/licenses/LICENSE-2.0
---
---  Unless required by applicable law or agreed to in writing,
---  software distributed under the License is distributed on an
---  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
---  KIND, either express or implied.  See the License for the
---  specific language governing permissions and limitations
---  under the License.
- 
-
-CREATE TABLE Parent (
-  id INTEGER NOT NULL,
-  COL2 CHAR(25),
-  COL3 DECIMAL(10,2),
-  COL4 VARCHAR(25),
-  COL5 DATE,
-
-  PRIMARY KEY (id),
-  UNIQUE (COL3)
-);
-
-CREATE TABLE Child (
-  id INTEGER NOT NULL,
-  Parent_id CHAR(25),
-  COL3 DECIMAL(10,2),
-  COL4 VARCHAR(25),
-  COL5 DATE,
-
-  PRIMARY KEY (id)
-);
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/cayenne/blob/c63b6be2/cayenne-tools/src/test/resources/org/apache/cayenne/tools/build-mapping.xml
----------------------------------------------------------------------
diff --git a/cayenne-tools/src/test/resources/org/apache/cayenne/tools/build-mapping.xml b/cayenne-tools/src/test/resources/org/apache/cayenne/tools/build-mapping.xml
deleted file mode 100644
index b6ab93e..0000000
--- a/cayenne-tools/src/test/resources/org/apache/cayenne/tools/build-mapping.xml
+++ /dev/null
@@ -1,44 +0,0 @@
-<!--
-  Licensed to the Apache Software Foundation (ASF) under one
-  or more contributor license agreements.  See the NOTICE file
-  distributed with this work for additional information
-  regarding copyright ownership.  The ASF licenses this file
-  to you under the Apache License, Version 2.0 (the
-  "License"); you may not use this file except in compliance
-  with the License.  You may obtain a copy of the License at
-
-  http://www.apache.org/licenses/LICENSE-2.0
-
-  Unless required by applicable law or agreed to in writing,
-  software distributed under the License is distributed on an
-  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-  KIND, either express or implied.  See the License for the
-  specific language governing permissions and limitations
-  under the License.
-  -->
-
-<project name="MyProject" default="dist" basedir=".">
-
-    <taskdef name="cdbimport" classname="org.apache.cayenne.tools.DbImporterTask" taskname="cdbimport"
-             classpath="${basedir}"/>
-
-    <target name="dist">
-        <cdbimport map="${context.dir}/WEB-INF/DefaultMap.map.xml"
-                   adapter="org.apache.cayenne.dba.hsqldb.HSQLDBAdapter"
-                   driver="org.hsqldb.jdbcDriver"
-                   url="jdbc:hsqldb:hsql://localhost/bookmarker"
-                   username="sa">
-
-            <typeMapper mapperClassName="class" usePrimitives="false">
-                <type java="my.personal.type" jdbc="varchar"/>
-                <type java="java-01" jdbc="jdbc-01"/>
-                <type java="java-02" jdbc="jdbc-02" length="21" notNull="true"/>
-                <type java="java-03" jdbc="jdbc-03" precision="5" scale="2"/>
-                <type java="java-03" jdbc="jdbc-03" precision="7" notNull="true"/>
-            </typeMapper>
-
-        </cdbimport>
-    </target>
-
-
-</project>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/cayenne/blob/c63b6be2/cayenne-tools/src/test/resources/org/apache/cayenne/tools/build-reverse-engineering-in-external-file.xml
----------------------------------------------------------------------
diff --git a/cayenne-tools/src/test/resources/org/apache/cayenne/tools/build-reverse-engineering-in-external-file.xml b/cayenne-tools/src/test/resources/org/apache/cayenne/tools/build-reverse-engineering-in-external-file.xml
deleted file mode 100644
index 8cd89e8..0000000
--- a/cayenne-tools/src/test/resources/org/apache/cayenne/tools/build-reverse-engineering-in-external-file.xml
+++ /dev/null
@@ -1,33 +0,0 @@
-<!--
-  Licensed to the Apache Software Foundation (ASF) under one
-  or more contributor license agreements.  See the NOTICE file
-  distributed with this work for additional information
-  regarding copyright ownership.  The ASF licenses this file
-  to you under the Apache License, Version 2.0 (the
-  "License"); you may not use this file except in compliance
-  with the License.  You may obtain a copy of the License at
-
-  http://www.apache.org/licenses/LICENSE-2.0
-
-  Unless required by applicable law or agreed to in writing,
-  software distributed under the License is distributed on an
-  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-  KIND, either express or implied.  See the License for the
-  specific language governing permissions and limitations
-  under the License.
-  -->
-
-<project name="MyProject" default="dist" basedir=".">
-
-    <taskdef name="cdbimport" classname="org.apache.cayenne.tools.DbImporterTask" taskname="cdbimport"
-             classpath="${basedir}"  />
-
-    <target name="dist">
-        <cdbimport map="dbimport/build-include-table.map.xml"
-                   driver="org.apache.derby.jdbc.EmbeddedDriver"
-                   url="jdbc:derby:memory:DbImporterMojoTest;create=true"
-                   reverseEngineeringFile="dbimport/config/reverseEngineering-catalog-and-schema.xml" />
-    </target>
-
-
-</project>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/cayenne/blob/c63b6be2/cayenne-tools/src/test/resources/org/apache/cayenne/tools/build-schema.xml
----------------------------------------------------------------------
diff --git a/cayenne-tools/src/test/resources/org/apache/cayenne/tools/build-schema.xml b/cayenne-tools/src/test/resources/org/apache/cayenne/tools/build-schema.xml
deleted file mode 100644
index 911af23..0000000
--- a/cayenne-tools/src/test/resources/org/apache/cayenne/tools/build-schema.xml
+++ /dev/null
@@ -1,83 +0,0 @@
-<!--
-  ~ Licensed to the Apache Software Foundation (ASF) under one
-  ~    or more contributor license agreements.  See the NOTICE file
-  ~    distributed with this work for additional information
-  ~    regarding copyright ownership.  The ASF licenses this file
-  ~    to you under the Apache License, Version 2.0 (the
-  ~    "License"); you may not use this file except in compliance
-  ~    with the License.  You may obtain a copy of the License at
-  ~
-  ~      http://www.apache.org/licenses/LICENSE-2.0
-  ~
-  ~    Unless required by applicable law or agreed to in writing,
-  ~    software distributed under the License is distributed on an
-  ~    "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-  ~    KIND, either express or implied.  See the License for the
-  ~    specific language governing permissions and limitations
-  ~    under the License.
-  -->
-
-<project name="MyProject" default="dist" basedir=".">
-
-    <taskdef name="cdbimport" classname="org.apache.cayenne.tools.DbImporterTask" taskname="cdbimport"
-             classpath="${basedir}"/>
-
-    <target name="dist">
-        <cdbimport map="${context.dir}/WEB-INF/DefaultMap.map.xml"
-                   adapter="org.apache.cayenne.dba.hsqldb.HSQLDBAdapter"
-                   driver="org.hsqldb.jdbcDriver"
-                   url="jdbc:hsqldb:hsql://localhost/bookmarker"
-                   username="sa">
-
-                <schema>schema-name-01</schema>
-
-                <schema>
-                    <name>schema-name-02</name>
-                </schema>
-
-                <schema name="schema-name-03">
-                    <includeTable>includeTable-01</includeTable>
-
-                    <includeTable>
-                        <pattern>includeTable-02</pattern>
-                    </includeTable>
-
-                    <includeTable pattern="includeTable-03">
-                        <includeColumn pattern="includeColumn-01"/>
-                        <excludeColumn pattern="excludeColumn-01"/>
-                    </includeTable>
-
-                    <excludeTable>excludeTable-01</excludeTable>
-                    <excludeTable>
-                        <pattern>excludeTable-02</pattern>
-                    </excludeTable>
-                    <excludeTable pattern="excludeTable-03"/>
-
-                    <includeColumn>includeColumn-01</includeColumn>
-                    <includeColumn>
-                        <pattern>includeColumn-02</pattern>
-                    </includeColumn>
-                    <includeColumn pattern="includeColumn-03"/>
-                    <excludeColumn>excludeColumn-01</excludeColumn>
-                    <excludeColumn>
-                        <pattern>excludeColumn-02</pattern>
-                    </excludeColumn>
-                    <excludeColumn pattern="excludeColumn-03"/>
-
-                    <includeProcedure>includeProcedure-01</includeProcedure>
-                    <includeProcedure>
-                        <pattern>includeProcedure-02</pattern>
-                    </includeProcedure>
-                    <includeProcedure pattern="includeProcedure-03"/>
-                    <excludeProcedure>excludeProcedure-01</excludeProcedure>
-                    <excludeProcedure>
-                        <pattern>excludeProcedure-02</pattern>
-                    </excludeProcedure>
-                    <excludeProcedure pattern="excludeProcedure-03"/>
-                </schema>
-
-        </cdbimport>
-    </target>
-
-
-</project>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/cayenne/blob/c63b6be2/cayenne-tools/src/test/resources/org/apache/cayenne/tools/build-skip-primary-key-loading.xml
----------------------------------------------------------------------
diff --git a/cayenne-tools/src/test/resources/org/apache/cayenne/tools/build-skip-primary-key-loading.xml b/cayenne-tools/src/test/resources/org/apache/cayenne/tools/build-skip-primary-key-loading.xml
deleted file mode 100644
index 396b603..0000000
--- a/cayenne-tools/src/test/resources/org/apache/cayenne/tools/build-skip-primary-key-loading.xml
+++ /dev/null
@@ -1,35 +0,0 @@
-<!--
-  Licensed to the Apache Software Foundation (ASF) under one
-  or more contributor license agreements.  See the NOTICE file
-  distributed with this work for additional information
-  regarding copyright ownership.  The ASF licenses this file
-  to you under the Apache License, Version 2.0 (the
-  "License"); you may not use this file except in compliance
-  with the License.  You may obtain a copy of the License at
-
-  http://www.apache.org/licenses/LICENSE-2.0
-
-  Unless required by applicable law or agreed to in writing,
-  software distributed under the License is distributed on an
-  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-  KIND, either express or implied.  See the License for the
-  specific language governing permissions and limitations
-  under the License.
-  -->
-
-<project name="MyProject" default="dist" basedir=".">
-
-    <taskdef name="cdbimport" classname="org.apache.cayenne.tools.DbImporterTask" taskname="cdbimport"
-             classpath="${basedir}"/>
-
-    <target name="dist">
-        <cdbimport map="${context.dir}/WEB-INF/DefaultMap.map.xml"
-                   adapter="org.apache.cayenne.dba.hsqldb.HSQLDBAdapter"
-                   driver="org.hsqldb.jdbcDriver"
-                   url="jdbc:hsqldb:hsql://localhost/bookmarker"
-                   username="sa" skipPrimaryKeyLoading="true">
-        </cdbimport>
-    </target>
-
-
-</project>

http://git-wip-us.apache.org/repos/asf/cayenne/blob/c63b6be2/cayenne-tools/src/test/resources/org/apache/cayenne/tools/build-skip-relationships-loading.xml
----------------------------------------------------------------------
diff --git a/cayenne-tools/src/test/resources/org/apache/cayenne/tools/build-skip-relationships-loading.xml b/cayenne-tools/src/test/resources/org/apache/cayenne/tools/build-skip-relationships-loading.xml
deleted file mode 100644
index b2c801b..0000000
--- a/cayenne-tools/src/test/resources/org/apache/cayenne/tools/build-skip-relationships-loading.xml
+++ /dev/null
@@ -1,35 +0,0 @@
-<!--
-  Licensed to the Apache Software Foundation (ASF) under one
-  or more contributor license agreements.  See the NOTICE file
-  distributed with this work for additional information
-  regarding copyright ownership.  The ASF licenses this file
-  to you under the Apache License, Version 2.0 (the
-  "License"); you may not use this file except in compliance
-  with the License.  You may obtain a copy of the License at
-
-  http://www.apache.org/licenses/LICENSE-2.0
-
-  Unless required by applicable law or agreed to in writing,
-  software distributed under the License is distributed on an
-  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-  KIND, either express or implied.  See the License for the
-  specific language governing permissions and limitations
-  under the License.
-  -->
-
-<project name="MyProject" default="dist" basedir=".">
-
-    <taskdef name="cdbimport" classname="org.apache.cayenne.tools.DbImporterTask" taskname="cdbimport"
-             classpath="${basedir}"/>
-
-    <target name="dist">
-        <cdbimport map="${context.dir}/WEB-INF/DefaultMap.map.xml"
-                   adapter="org.apache.cayenne.dba.hsqldb.HSQLDBAdapter"
-                   driver="org.hsqldb.jdbcDriver"
-                   url="jdbc:hsqldb:hsql://localhost/bookmarker"
-                   username="sa"
-                   skipRelationshipsLoading="true"/>
-    </target>
-
-
-</project>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/cayenne/blob/c63b6be2/cayenne-tools/src/test/resources/org/apache/cayenne/tools/build-table-types.xml
----------------------------------------------------------------------
diff --git a/cayenne-tools/src/test/resources/org/apache/cayenne/tools/build-table-types.xml b/cayenne-tools/src/test/resources/org/apache/cayenne/tools/build-table-types.xml
deleted file mode 100644
index 25bf032..0000000
--- a/cayenne-tools/src/test/resources/org/apache/cayenne/tools/build-table-types.xml
+++ /dev/null
@@ -1,40 +0,0 @@
-<!--
-  Licensed to the Apache Software Foundation (ASF) under one
-  or more contributor license agreements.  See the NOTICE file
-  distributed with this work for additional information
-  regarding copyright ownership.  The ASF licenses this file
-  to you under the Apache License, Version 2.0 (the
-  "License"); you may not use this file except in compliance
-  with the License.  You may obtain a copy of the License at
-
-  http://www.apache.org/licenses/LICENSE-2.0
-
-  Unless required by applicable law or agreed to in writing,
-  software distributed under the License is distributed on an
-  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-  KIND, either express or implied.  See the License for the
-  specific language governing permissions and limitations
-  under the License.
-  -->
-
-<project name="MyProject" default="dist" basedir=".">
-
-    <taskdef name="cdbimport" classname="org.apache.cayenne.tools.DbImporterTask" taskname="cdbimport"
-             classpath="${basedir}"/>
-
-    <target name="dist">
-        <cdbimport map="${context.dir}/WEB-INF/DefaultMap.map.xml"
-                   adapter="org.apache.cayenne.dba.hsqldb.HSQLDBAdapter"
-                   driver="org.hsqldb.jdbcDriver"
-                   url="jdbc:hsqldb:hsql://localhost/bookmarker"
-                   username="sa">
-
-            <tableType>type1</tableType>
-
-            <tableType name="type2"/>
-            <tableType name="type3"/>
-        </cdbimport>
-    </target>
-
-
-</project>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/cayenne/blob/c63b6be2/cayenne-tools/src/test/resources/org/apache/cayenne/tools/cgen-dependent.map.xml
----------------------------------------------------------------------
diff --git a/cayenne-tools/src/test/resources/org/apache/cayenne/tools/cgen-dependent.map.xml b/cayenne-tools/src/test/resources/org/apache/cayenne/tools/cgen-dependent.map.xml
deleted file mode 100644
index d06be70..0000000
--- a/cayenne-tools/src/test/resources/org/apache/cayenne/tools/cgen-dependent.map.xml
+++ /dev/null
@@ -1,19 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<data-map xmlns="http://cayenne.apache.org/schema/3.0/modelMap"
-	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
-	xsi:schemaLocation="http://cayenne.apache.org/schema/3.0/modelMap ../../main/resources/org/apache/cayenne/schema/3.0/modelMap.xsd"
-	project-version="1.1">
-	<property name="defaultPackage" value="org.apache.cayenne.testdo.cgen2"/>
-	<db-entity name="MYARTGROUP">
-		<db-attribute name="MY_GROUP_ID" type="INTEGER" isPrimaryKey="true" isMandatory="true"/>
-		<db-attribute name="CUSTOM" type="VARCHAR" isMandatory="true" length="100"/>
-		<db-attribute name="MY_PARENT_GROUP_ID" type="INTEGER"/>
-	</db-entity>
-	<obj-entity name="MyArtGroup" className="org.apache.cayenne.testdo.cgen2.MyArtGroup" dbEntityName="MYARTGROUP">
-		<obj-attribute name="custom" type="java.lang.String" db-attribute-path="CUSTOM"/>
-	</obj-entity>
-	<db-relationship name="toParentArtGroup" source="MYARTGROUP" target="ARTGROUP" toMany="false">
-		<db-attribute-pair source="MY_PARENT_GROUP_ID" target="GROUP_ID"/>
-	</db-relationship>
-	<obj-relationship name="toParentGroup" source="MyArtGroup" target="ArtGroup" deleteRule="Nullify" db-relationship-path="toParentArtGroup"/>
-</data-map>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/cayenne/blob/c63b6be2/cayenne-tools/src/test/resources/org/apache/cayenne/tools/cgen.map.xml
----------------------------------------------------------------------
diff --git a/cayenne-tools/src/test/resources/org/apache/cayenne/tools/cgen.map.xml b/cayenne-tools/src/test/resources/org/apache/cayenne/tools/cgen.map.xml
deleted file mode 100644
index 1c378cf..0000000
--- a/cayenne-tools/src/test/resources/org/apache/cayenne/tools/cgen.map.xml
+++ /dev/null
@@ -1,15 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<data-map xmlns="http://cayenne.apache.org/schema/3.0/modelMap"
-	 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
-	 xsi:schemaLocation="http://cayenne.apache.org/schema/3.0/modelMap http://cayenne.apache.org/schema/3.0/modelMap.xsd"
-	 project-version="6">
-
-	<db-entity name="ARTGROUP">
-		<db-attribute name="GROUP_ID" type="INTEGER" isPrimaryKey="true" isMandatory="true"/>
-		<db-attribute name="NAME" type="VARCHAR" isMandatory="true" length="100"/>
-		<db-attribute name="PARENT_GROUP_ID" type="INTEGER"/>
-	</db-entity>
-	<obj-entity name="ArtGroup" className="org.apache.cayenne.testdo.testmap.ArtGroup" dbEntityName="ARTGROUP">
-		<obj-attribute name="name" type="java.lang.String" db-attribute-path="NAME"/>
-	</obj-entity>
-</data-map>

http://git-wip-us.apache.org/repos/asf/cayenne/blob/c63b6be2/cayenne-tools/src/test/resources/org/apache/cayenne/tools/velotemplate.vm
----------------------------------------------------------------------
diff --git a/cayenne-tools/src/test/resources/org/apache/cayenne/tools/velotemplate.vm b/cayenne-tools/src/test/resources/org/apache/cayenne/tools/velotemplate.vm
deleted file mode 100644
index 1ca078c..0000000
--- a/cayenne-tools/src/test/resources/org/apache/cayenne/tools/velotemplate.vm
+++ /dev/null
@@ -1,13 +0,0 @@
-## Test Velocity template
-${importUtils.setPackage($subPackageName)}##
-${importUtils.generate()}
-
-import java.util.List;
-import org.apache.cayenne.*;
-
-/** Class ${classGen.superPrefix}${classGen.className} was generated by Cayenne.
-  * It is probably a good idea to avoid changing this class manually, 
-  * since it may be overwritten next time code is regenerated. 
-  * If you need to make any customizations, please use subclass. 
-  */
-public class ${subClassName} extends CayenneDataObject {


[07/10] cayenne git commit: CAY-2215 split cayenne-tools into cayenne-cgen and cayenne-ant

Posted by nt...@apache.org.
http://git-wip-us.apache.org/repos/asf/cayenne/blob/c63b6be2/cayenne-cgen/src/main/java/org/apache/cayenne/gen/ClientDataMapArtifact.java
----------------------------------------------------------------------
diff --git a/cayenne-cgen/src/main/java/org/apache/cayenne/gen/ClientDataMapArtifact.java b/cayenne-cgen/src/main/java/org/apache/cayenne/gen/ClientDataMapArtifact.java
new file mode 100644
index 0000000..a9d1dfe
--- /dev/null
+++ b/cayenne-cgen/src/main/java/org/apache/cayenne/gen/ClientDataMapArtifact.java
@@ -0,0 +1,50 @@
+/*****************************************************************
+ *   Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ ****************************************************************/
+
+package org.apache.cayenne.gen;
+
+import org.apache.cayenne.map.DataMap;
+import org.apache.cayenne.map.QueryDescriptor;
+import org.apache.cayenne.util.Util;
+
+import java.util.Collection;
+
+public class ClientDataMapArtifact extends DataMapArtifact {
+
+    public ClientDataMapArtifact(DataMap dataMap, Collection<QueryDescriptor> queries) {
+        super(dataMap, queries);
+
+    }
+
+    @Override
+    public String getQualifiedBaseClassName() {
+
+        return dataMap.getDefaultClientSuperclass();
+    }
+
+    @Override
+    public String getQualifiedClassName() {
+        String clientPrefix = "";
+        if (Util.nullSafeEquals(dataMap.getDefaultClientPackage(), dataMap.getDefaultPackage())) {
+            clientPrefix = "Client_";
+        }
+
+        return dataMap.getNameWithDefaultClientPackage(Util.underscoredToJava(clientPrefix + dataMap.getName(), true));
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/cayenne/blob/c63b6be2/cayenne-cgen/src/main/java/org/apache/cayenne/gen/ClientEntityArtifact.java
----------------------------------------------------------------------
diff --git a/cayenne-cgen/src/main/java/org/apache/cayenne/gen/ClientEntityArtifact.java b/cayenne-cgen/src/main/java/org/apache/cayenne/gen/ClientEntityArtifact.java
new file mode 100644
index 0000000..d20a2d4
--- /dev/null
+++ b/cayenne-cgen/src/main/java/org/apache/cayenne/gen/ClientEntityArtifact.java
@@ -0,0 +1,45 @@
+/*****************************************************************
+ *   Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ ****************************************************************/
+package org.apache.cayenne.gen;
+
+import org.apache.cayenne.PersistentObject;
+import org.apache.cayenne.map.ObjEntity;
+
+/**
+ * Client code generation artifact based on ObjEntity.
+ * 
+ * @since 3.0
+ */
+public class ClientEntityArtifact extends EntityArtifact {
+
+    public ClientEntityArtifact(ObjEntity entity) {
+        super(entity);
+    }
+
+    @Override
+    public String getQualifiedBaseClassName() {
+        return (entity.getClientSuperClassName() != null) ? entity
+                .getClientSuperClassName() : PersistentObject.class.getName();
+    }
+
+    @Override
+    public String getQualifiedClassName() {
+        return entity.getClientClassName();
+    }
+}

http://git-wip-us.apache.org/repos/asf/cayenne/blob/c63b6be2/cayenne-cgen/src/main/java/org/apache/cayenne/gen/DataMapArtifact.java
----------------------------------------------------------------------
diff --git a/cayenne-cgen/src/main/java/org/apache/cayenne/gen/DataMapArtifact.java b/cayenne-cgen/src/main/java/org/apache/cayenne/gen/DataMapArtifact.java
new file mode 100644
index 0000000..8e60495
--- /dev/null
+++ b/cayenne-cgen/src/main/java/org/apache/cayenne/gen/DataMapArtifact.java
@@ -0,0 +1,137 @@
+/*****************************************************************
+ *   Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ ****************************************************************/
+
+package org.apache.cayenne.gen;
+
+import org.apache.cayenne.map.DataMap;
+import org.apache.cayenne.map.QueryDescriptor;
+import org.apache.cayenne.util.Util;
+import org.apache.velocity.VelocityContext;
+
+import java.util.Collection;
+import java.util.LinkedList;
+
+/**
+ * {@link Artifact} facade for a DataMap.
+ * 
+ * @since 3.0
+ */
+public class DataMapArtifact implements Artifact {
+
+    public static final String DATAMAP_UTILS_KEY = "dataMapUtils";
+
+    protected DataMap dataMap;
+    protected Collection<QueryDescriptor> selectQueries;
+    protected Collection<QueryDescriptor> sqlTemplateQueries;
+    protected Collection<QueryDescriptor> procedureQueries;
+    protected Collection<QueryDescriptor> ejbqlQueries;
+    protected Collection<String> queryNames;
+
+    public DataMapArtifact(DataMap dataMap, Collection<QueryDescriptor> queries) {
+        this.dataMap = dataMap;
+        selectQueries = new LinkedList<>();
+        sqlTemplateQueries = new LinkedList<>();
+        procedureQueries = new LinkedList<>();
+        ejbqlQueries = new LinkedList<>();
+        queryNames = new LinkedList<>();
+        addQueries(queries);
+    }
+
+    public String getQualifiedBaseClassName() {
+        return Object.class.getName();
+    }
+
+    public String getQualifiedClassName() {
+        return dataMap.getNameWithDefaultPackage(Util.underscoredToJava(dataMap.getName(), true));
+    }
+
+    public Object getObject() {
+        return this;
+    }
+
+    public void postInitContext(VelocityContext context) {
+        DataMapUtils dataMapUtils = new DataMapUtils();
+        context.put(DATAMAP_UTILS_KEY, dataMapUtils);
+    }
+
+    public TemplateType[] getTemplateTypes(ArtifactGenerationMode mode) {
+        switch (mode) {
+            case SINGLE_CLASS:
+                return new TemplateType[] {
+                    TemplateType.DATAMAP_SINGLE_CLASS
+                };
+            case GENERATION_GAP:
+                return new TemplateType[] {
+                        TemplateType.DATAMAP_SUPERCLASS, TemplateType.DATAMAP_SUBCLASS
+                };
+            default:
+                return new TemplateType[0];
+        }
+    }
+
+    private void addQueries(Collection<QueryDescriptor> queries) {
+        if (queries != null) {
+            for (QueryDescriptor query : queries) {
+                addQuery(query);
+            }
+        }
+    }
+
+    private void addQuery(QueryDescriptor query) {
+
+        switch (query.getType()) {
+            case QueryDescriptor.SELECT_QUERY:
+                selectQueries.add(query);
+                break;
+            case QueryDescriptor.PROCEDURE_QUERY:
+                procedureQueries.add(query);
+                break;
+            case QueryDescriptor.SQL_TEMPLATE:
+                sqlTemplateQueries.add(query);
+                break;
+            case QueryDescriptor.EJBQL_QUERY:
+                ejbqlQueries.add(query);
+                break;
+        }
+
+        if (query.getName() != null && !"".equals(query.getName())) {
+            queryNames.add(query.getName());
+        }
+    }
+
+    public Collection<QueryDescriptor> getSelectQueries() {
+        return selectQueries;
+    }
+
+    public boolean hasSelectQueries() {
+        return selectQueries.size() > 0;
+    }
+
+    public boolean hasQueryNames() {
+        return !queryNames.isEmpty();
+    }
+
+    public Collection<String> getQueryNames() {
+        return queryNames;
+    }
+
+    public DataMap getDataMap() {
+    	return dataMap;
+    }
+}

http://git-wip-us.apache.org/repos/asf/cayenne/blob/c63b6be2/cayenne-cgen/src/main/java/org/apache/cayenne/gen/DataMapUtils.java
----------------------------------------------------------------------
diff --git a/cayenne-cgen/src/main/java/org/apache/cayenne/gen/DataMapUtils.java b/cayenne-cgen/src/main/java/org/apache/cayenne/gen/DataMapUtils.java
new file mode 100644
index 0000000..a0013cc
--- /dev/null
+++ b/cayenne-cgen/src/main/java/org/apache/cayenne/gen/DataMapUtils.java
@@ -0,0 +1,219 @@
+/*****************************************************************
+ *   Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ ****************************************************************/
+
+package org.apache.cayenne.gen;
+
+import org.apache.cayenne.exp.Expression;
+import org.apache.cayenne.exp.ExpressionException;
+import org.apache.cayenne.exp.ExpressionParameter;
+import org.apache.cayenne.exp.parser.ASTList;
+import org.apache.cayenne.exp.parser.ASTObjPath;
+import org.apache.cayenne.map.Entity;
+import org.apache.cayenne.map.ObjAttribute;
+import org.apache.cayenne.map.ObjEntity;
+import org.apache.cayenne.map.ObjRelationship;
+import org.apache.cayenne.map.PathComponent;
+import org.apache.cayenne.map.QueryDescriptor;
+import org.apache.cayenne.map.SelectQueryDescriptor;
+import org.apache.cayenne.query.Ordering;
+import org.apache.cayenne.util.CayenneMapEntry;
+import org.apache.cayenne.util.Util;
+import org.apache.commons.collections.set.ListOrderedSet;
+
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+/**
+ * Attributes and Methods for working with Queries.
+ *
+ * @since 3.0
+ */
+public class DataMapUtils {
+
+	Map<String, Map<String, String>> queriesMap = new HashMap<>();
+
+	/**
+	 * Return valid method name based on query name (replace all illegal
+	 * characters with underscore '_').
+	 * 
+	 * @param query
+	 * @return Method name that perform query.
+	 */
+	public String getQueryMethodName(QueryDescriptor query) {
+		return Util.underscoredToJava(query.getName(), true);
+	}
+
+	/**
+	 * Get all parameter names that used in query qualifier.
+	 *
+	 * @param query
+	 * @return Parameter names.
+	 */
+	public Collection getParameterNames(SelectQueryDescriptor query) {
+
+		if (query.getQualifier() == null) {
+			return Collections.EMPTY_SET;
+		}
+
+		Map<String, String> queryParameters = queriesMap.get(query.getName());
+
+		if (queryParameters == null) {
+			queryParameters = getParameterNames(query.getQualifier(), query.getRoot());
+			queriesMap.put(query.getName(), queryParameters);
+		}
+
+		return parseQualifier(query.getQualifier().toString());
+	}
+
+	public Boolean isValidParameterNames(SelectQueryDescriptor query) {
+
+		if (query.getQualifier() == null) {
+			return true;
+		}
+
+		Map<String, String> queryParameters = queriesMap.get(query.getName());
+
+		if (queryParameters == null) {
+			try {
+				queryParameters = getParameterNames(query.getQualifier(), query.getRoot());
+			} catch (Exception e) {
+				// if we have wrong path in queryParameters return false.
+				return false;
+			}
+		}
+
+		for (Ordering ordering : query.getOrderings()) {
+			// validate paths in ordering
+			String path = ordering.getSortSpecString();
+			Iterator<CayenneMapEntry> it = ((ObjEntity) query.getRoot()).resolvePathComponents(path);
+			while (it.hasNext()) {
+				try {
+					it.next();
+				} catch (ExpressionException e) {
+					// if we have wrong path in orderings return false.
+					return false;
+				}
+			}
+		}
+
+		return true;
+	}
+
+	/**
+	 * Get list of parameter names in the same order as in qualifier.
+	 * 
+	 * @param qualifierString
+	 *            to be parsed
+	 * @return List of parameter names.
+	 */
+	private Set parseQualifier(String qualifierString) {
+		Set result = new ListOrderedSet();
+		Pattern pattern = Pattern.compile("\\$[\\w]+");
+		Matcher matcher = pattern.matcher(qualifierString);
+		while (matcher.find()) {
+			String name = matcher.group();
+			result.add(Util.underscoredToJava(name.substring(1), false));
+		}
+
+		return result;
+	}
+
+	public boolean hasParameters(SelectQueryDescriptor query) {
+		Map queryParameters = queriesMap.get(query.getName());
+
+		if (queryParameters == null) {
+			return false;
+		}
+
+		return queryParameters.keySet().size() > 0;
+
+	}
+
+	/**
+	 * Get type of parameter for given name.
+	 *
+	 * @param query
+	 * @param name
+	 * @return Parameter type.
+	 */
+	public String getParameterType(SelectQueryDescriptor query, String name) {
+		return queriesMap.get(query.getName()).get(name);
+	}
+
+	private Map<String, String> getParameterNames(Expression expression, Object root) {
+		if (expression != null) {
+			Map<String, String> types = new HashMap<>();
+			String typeName = "";
+			List<String> names = new LinkedList<String>();
+
+			for (int i = 0; i < expression.getOperandCount(); i++) {
+				Object operand = expression.getOperand(i);
+
+				if (operand instanceof Expression) {
+					types.putAll(getParameterNames((Expression) operand, root));
+				}
+
+				if (operand instanceof ASTObjPath) {
+					PathComponent<ObjAttribute, ObjRelationship> component = ((Entity) root).lastPathComponent(
+							(ASTObjPath) operand, null);
+					ObjAttribute attribute = component.getAttribute();
+					if (attribute != null) {
+						typeName = attribute.getType();
+					} else {
+						ObjRelationship relationship = component.getRelationship();
+						if (relationship != null) {
+							typeName = ((ObjEntity) relationship.getTargetEntity()).getClassName();
+						} else {
+							typeName = "Object";
+						}
+					}
+				}
+
+				if (operand instanceof ASTList) {
+					Object[] values = (Object[]) ((ASTList) operand).getOperand(0);
+					for (Object value : values) {
+						if (value instanceof ExpressionParameter) {
+							names.add(((ExpressionParameter) value).getName());
+						}
+					}
+				}
+
+				if (operand instanceof ExpressionParameter) {
+					names.add(((ExpressionParameter) operand).getName());
+				}
+
+			}
+
+			for (String name : names) {
+				types.put(Util.underscoredToJava(name, false), typeName);
+			}
+
+			return types;
+		}
+		return Collections.EMPTY_MAP;
+	}
+}

http://git-wip-us.apache.org/repos/asf/cayenne/blob/c63b6be2/cayenne-cgen/src/main/java/org/apache/cayenne/gen/EmbeddableArtifact.java
----------------------------------------------------------------------
diff --git a/cayenne-cgen/src/main/java/org/apache/cayenne/gen/EmbeddableArtifact.java b/cayenne-cgen/src/main/java/org/apache/cayenne/gen/EmbeddableArtifact.java
new file mode 100644
index 0000000..8e6ea43
--- /dev/null
+++ b/cayenne-cgen/src/main/java/org/apache/cayenne/gen/EmbeddableArtifact.java
@@ -0,0 +1,68 @@
+/*****************************************************************
+ *   Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ ****************************************************************/
+package org.apache.cayenne.gen;
+
+import org.apache.cayenne.map.Embeddable;
+import org.apache.velocity.VelocityContext;
+
+/**
+ * {@link Artifact} facade for an {@link Embeddable}.
+ * 
+ * @since 3.0
+ */
+public class EmbeddableArtifact implements Artifact {
+
+    protected Embeddable embeddable;
+
+    public EmbeddableArtifact(Embeddable embeddable) {
+        this.embeddable = embeddable;
+    }
+
+    public Object getObject() {
+        return embeddable;
+    }
+
+    public String getQualifiedBaseClassName() {
+        return Object.class.getName();
+    }
+
+    public String getQualifiedClassName() {
+        return embeddable.getClassName();
+    }
+
+    public TemplateType[] getTemplateTypes(ArtifactGenerationMode mode) {
+        switch (mode) {
+            case SINGLE_CLASS:
+                return new TemplateType[] {
+                    TemplateType.EMBEDDABLE_SINGLE_CLASS
+                };
+            case GENERATION_GAP:
+                return new TemplateType[] {
+                        TemplateType.EMBEDDABLE_SUPERCLASS,
+                        TemplateType.EMBEDDABLE_SUBCLASS
+                };
+            default:
+                return new TemplateType[0];
+        }
+    }
+
+    public void postInitContext(VelocityContext context) {
+        // noop - no special keys...
+    }
+}

http://git-wip-us.apache.org/repos/asf/cayenne/blob/c63b6be2/cayenne-cgen/src/main/java/org/apache/cayenne/gen/EntityArtifact.java
----------------------------------------------------------------------
diff --git a/cayenne-cgen/src/main/java/org/apache/cayenne/gen/EntityArtifact.java b/cayenne-cgen/src/main/java/org/apache/cayenne/gen/EntityArtifact.java
new file mode 100644
index 0000000..394304f
--- /dev/null
+++ b/cayenne-cgen/src/main/java/org/apache/cayenne/gen/EntityArtifact.java
@@ -0,0 +1,98 @@
+/*****************************************************************
+ *   Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ ****************************************************************/
+package org.apache.cayenne.gen;
+
+import org.apache.cayenne.CayenneDataObject;
+import org.apache.cayenne.map.ObjEntity;
+import org.apache.velocity.VelocityContext;
+
+/**
+ * {@link Artifact} facade for an ObjEntity.
+ * 
+ * @since 3.0
+ */
+public class EntityArtifact implements Artifact {
+
+    public static String ENTITY_UTILS_KEY = "entityUtils";
+
+    protected ObjEntity entity;
+
+    public EntityArtifact(ObjEntity entity) {
+        this.entity = entity;
+    }
+
+    /**
+     * Returns ObjEntity.
+     */
+    public Object getObject() {
+        return entity;
+    }
+
+    public String getQualifiedBaseClassName() {
+        return (entity.getSuperClassName() != null)
+                ? entity.getSuperClassName()
+                : CayenneDataObject.class.getName();
+    }
+
+    public String getQualifiedClassName() {
+        return entity.getClassName();
+    }
+
+    public TemplateType getSingleClassType() {
+        return TemplateType.ENTITY_SINGLE_CLASS;
+    }
+
+    public TemplateType getSubclassType() {
+        return TemplateType.ENTITY_SUBCLASS;
+    }
+
+    public TemplateType getSuperClassType() {
+        return TemplateType.ENTITY_SUPERCLASS;
+    }
+
+    public TemplateType[] getTemplateTypes(ArtifactGenerationMode mode) {
+        switch (mode) {
+            case SINGLE_CLASS:
+                return new TemplateType[] {
+                    TemplateType.ENTITY_SINGLE_CLASS
+                };
+            case GENERATION_GAP:
+                return new TemplateType[] {
+                        TemplateType.ENTITY_SUPERCLASS, TemplateType.ENTITY_SUBCLASS
+                };
+            default:
+                return new TemplateType[0];
+        }
+    }
+
+    public void postInitContext(VelocityContext context) {
+        EntityUtils metadata = new EntityUtils(
+                entity.getDataMap(),
+                entity,
+                (String) context.get(BASE_CLASS_KEY),
+                (String) context.get(BASE_PACKAGE_KEY),
+                (String) context.get(SUPER_CLASS_KEY),
+                (String) context.get(SUPER_PACKAGE_KEY),
+                (String) context.get(SUB_CLASS_KEY),
+                (String) context.get(SUB_PACKAGE_KEY));
+
+        context.put(ENTITY_UTILS_KEY, metadata);
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/cayenne/blob/c63b6be2/cayenne-cgen/src/main/java/org/apache/cayenne/gen/EntityUtils.java
----------------------------------------------------------------------
diff --git a/cayenne-cgen/src/main/java/org/apache/cayenne/gen/EntityUtils.java b/cayenne-cgen/src/main/java/org/apache/cayenne/gen/EntityUtils.java
new file mode 100644
index 0000000..ecf2a3f
--- /dev/null
+++ b/cayenne-cgen/src/main/java/org/apache/cayenne/gen/EntityUtils.java
@@ -0,0 +1,274 @@
+/*****************************************************************
+ *   Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ ****************************************************************/
+
+package org.apache.cayenne.gen;
+
+import java.util.Collection;
+
+import org.apache.cayenne.CayenneRuntimeException;
+import org.apache.cayenne.ObjectId;
+import org.apache.cayenne.map.DataMap;
+import org.apache.cayenne.map.DbEntity;
+import org.apache.cayenne.map.MappingNamespace;
+import org.apache.cayenne.map.ObjAttribute;
+import org.apache.cayenne.map.ObjEntity;
+import org.apache.cayenne.map.ObjRelationship;
+import org.apache.cayenne.map.Relationship;
+
+/**
+ * Attributes and Methods for working with ObjEntities.
+ * 
+ * @since 1.2
+ */
+public class EntityUtils {
+
+    // template substitution values
+    protected String subClassName;
+    protected String superClassName;
+    protected String baseClassName;
+    protected String subPackageName;
+    protected String superPackageName;
+    protected String basePackageName;
+
+    protected DataMap primaryDataMap;
+    protected ObjEntity objEntity;
+
+    protected Collection<String> callbackNames;
+
+    public EntityUtils(DataMap dataMap, ObjEntity objEntity, String fqnBaseClass, String fqnSuperClass,
+            String fqnSubClass) {
+
+        StringUtils stringUtils = StringUtils.getInstance();
+
+        this.baseClassName = stringUtils.stripPackageName(fqnBaseClass);
+        this.basePackageName = stringUtils.stripClass(fqnBaseClass);
+        this.superClassName = stringUtils.stripPackageName(fqnSuperClass);
+        this.superPackageName = stringUtils.stripClass(fqnSuperClass);
+        this.subClassName = stringUtils.stripPackageName(fqnSubClass);
+        this.subPackageName = stringUtils.stripClass(fqnSubClass);
+
+        this.primaryDataMap = dataMap;
+
+        this.objEntity = objEntity;
+        this.callbackNames = objEntity.getCallbackMethods();
+    }
+
+    EntityUtils(DataMap dataMap, ObjEntity objEntity, String baseClassName, String basePackageName,
+            String superClassName, String superPackageName, String subClassName, String subPackageName) {
+
+        this.baseClassName = baseClassName;
+        this.basePackageName = basePackageName;
+        this.superClassName = superClassName;
+        this.superPackageName = superPackageName;
+        this.subClassName = subClassName;
+        this.subPackageName = subPackageName;
+
+        this.primaryDataMap = dataMap;
+
+        this.objEntity = objEntity;
+        this.callbackNames = objEntity.getCallbackMethods();
+    }
+
+    /**
+     * @return Returns the primary DataMap.
+     * @since 1.2
+     */
+    public DataMap getPrimaryDataMap() {
+        return primaryDataMap;
+    }
+
+    /**
+     * Returns the EntityResolver for this set of DataMaps.
+     * 
+     * @since 1.2
+     */
+    public MappingNamespace getEntityResolver() {
+        return primaryDataMap.getNamespace();
+    }
+
+    /**
+     * Returns true if current ObjEntity is defined as abstract.
+     */
+    public boolean isAbstract() {
+        return isAbstract(objEntity);
+    }
+
+    /**
+     * Returns true if current ObjEntity is defined as abstract.
+     */
+    public boolean isAbstract(ObjEntity anObjEntity) {
+        return anObjEntity != null && anObjEntity.isAbstract();
+    }
+
+    /**
+     * Returns true if current ObjEntity contains at least one toMany
+     * relationship.
+     */
+    public boolean hasToManyRelationships() {
+        return hasToManyRelationships(objEntity);
+    }
+
+    /**
+     * Returns true if an ObjEntity contains at least one toMany relationship.
+     */
+    public boolean hasToManyRelationships(ObjEntity anObjEntity) {
+        if (anObjEntity == null) {
+            return false;
+        }
+
+        for (Relationship r : anObjEntity.getRelationships()) {
+            if (r.isToMany()) {
+                return true;
+            }
+        }
+
+        return false;
+    }
+
+    /**
+     * Returns true if current ObjEntity contains at least one toMany
+     * relationship, ignoring those declared in superentities.
+     * 
+     * @since 1.2
+     */
+    public boolean hasToManyDeclaredRelationships() {
+        return hasToManyDeclaredRelationships(objEntity);
+    }
+
+    /**
+     * Returns true if an ObjEntity contains at least one toMany relationship,
+     * ignoring those declared in superentities.
+     * 
+     * @since 1.2
+     */
+    public boolean hasToManyDeclaredRelationships(ObjEntity anObjEntity) {
+        if (anObjEntity == null) {
+            return false;
+        }
+
+        for (Relationship r : anObjEntity.getDeclaredRelationships()) {
+            if (r.isToMany()) {
+                return true;
+            }
+        }
+
+        return false;
+    }
+
+    /**
+     * Returns true if current ObjEntity contains at least one toOne
+     * relationship.
+     */
+    public boolean hasToOneRelationships() {
+        return hasToOneRelationships(objEntity);
+    }
+
+    /**
+     * Returns true if an ObjEntity contains at least one toOne relationship.
+     */
+    public boolean hasToOneRelationships(ObjEntity anObjEntity) {
+        if (anObjEntity == null) {
+            return false;
+        }
+
+        for (Relationship r : anObjEntity.getRelationships()) {
+            if (!r.isToMany()) {
+                return true;
+            }
+        }
+
+        return false;
+    }
+
+    /**
+     * Returns true if current ObjEntity contains at least one toOne
+     * relationship, ignoring those declared in superentities.
+     */
+    public boolean hasToOneDeclaredRelationships() {
+        return hasToOneDeclaredRelationships(objEntity);
+    }
+
+    /**
+     * Returns true if an ObjEntity contains at least one toOne relationship,
+     * ignoring those declared in superentities.
+     */
+    public boolean hasToOneDeclaredRelationships(ObjEntity anObjEntity) {
+        if (anObjEntity == null) {
+            return false;
+        }
+
+        for (Relationship r : anObjEntity.getDeclaredRelationships()) {
+            if (!r.isToMany()) {
+                return true;
+            }
+        }
+
+        return false;
+    }
+
+    /**
+     * Returns the map key type for a collection relationship of type
+     * java.util.Map.
+     * 
+     * @param relationship
+     *            The relationship to look up type information for.
+     * @return The type of the attribute keyed on.
+     */
+    public String getMapKeyType(final ObjRelationship relationship) {
+
+        ObjEntity targetEntity = (ObjEntity) relationship.getTargetEntity();
+
+        // If the map key is null, then we're doing look-ups by actual object
+        // key.
+        if (relationship.getMapKey() == null) {
+
+            // If it's a multi-column key, then the return type is always
+            // ObjectId.
+            DbEntity dbEntity = targetEntity.getDbEntity();
+            if ((dbEntity != null) && (dbEntity.getPrimaryKeys().size() > 1)) {
+                return ObjectId.class.getName();
+            }
+
+            // If it's a single column key or no key exists at all, then we
+            // really don't
+            // know what the key type is,
+            // so default to Object.
+            return Object.class.getName();
+        }
+
+        // If the map key is a non-default attribute, then fetch the attribute
+        // and return
+        // its type.
+        ObjAttribute attribute = targetEntity.getAttribute(relationship.getMapKey());
+        if (attribute == null) {
+            throw new CayenneRuntimeException("Invalid map key '" + relationship.getMapKey()
+                    + "', no matching attribute found");
+        }
+
+        return attribute.getType();
+    }
+
+    /**
+     * @return the list of all callback names registered for the entity.
+     * @since 3.0
+     */
+    public Collection<String> getCallbackNames() {
+        return callbackNames;
+    }
+}

http://git-wip-us.apache.org/repos/asf/cayenne/blob/c63b6be2/cayenne-cgen/src/main/java/org/apache/cayenne/gen/ImportUtils.java
----------------------------------------------------------------------
diff --git a/cayenne-cgen/src/main/java/org/apache/cayenne/gen/ImportUtils.java b/cayenne-cgen/src/main/java/org/apache/cayenne/gen/ImportUtils.java
new file mode 100644
index 0000000..af40499
--- /dev/null
+++ b/cayenne-cgen/src/main/java/org/apache/cayenne/gen/ImportUtils.java
@@ -0,0 +1,266 @@
+/*****************************************************************
+ *   Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ ****************************************************************/
+
+package org.apache.cayenne.gen;
+
+import org.apache.cayenne.util.Util;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * Methods for mangling strings.
+ * 
+ */
+public class ImportUtils {
+
+	public static final String importOrdering[] = new String[] { "java.", "javax.", "org.", "com." };
+
+	static final String primitives[] = new String[] { "long", "double", "byte", "boolean", "float", "short", "int",
+			"char" };
+
+	static final String primitiveClasses[] = new String[] { Long.class.getName(), Double.class.getName(),
+			Byte.class.getName(), Boolean.class.getName(), Float.class.getName(), Short.class.getName(),
+			Integer.class.getName(), Character.class.getName() };
+
+	static Map<String, String> classesForPrimitives = Util.toMap(primitives, primitiveClasses);
+	static Map<String, String> primitivesForClasses = Util.toMap(primitiveClasses, primitives);
+
+	protected Map<String, String> importTypesMap = new HashMap<>();
+
+	// Types forced to be FQN
+	protected Map<String, String> reservedImportTypesMap = new HashMap<>();
+
+	protected String packageName;
+
+	public ImportUtils() {
+		super();
+	}
+
+	protected boolean canRegisterType(String typeName) {
+		// Not sure why this would ever happen, but it did
+		if (null == typeName)
+			return false;
+
+		StringUtils stringUtils = StringUtils.getInstance();
+		String typeClassName = stringUtils.stripPackageName(typeName);
+		String typePackageName = stringUtils.stripClass(typeName);
+
+		if (typePackageName.length() == 0)
+			return false; // disallow non-packaged types (primitives, probably)
+		if ("java.lang".equals(typePackageName))
+			return false;
+
+		// Can only have one type -- rest must use fqn
+		if (reservedImportTypesMap.containsKey(typeClassName))
+			return false;
+		if (importTypesMap.containsKey(typeClassName))
+			return false;
+
+		return true;
+	}
+
+	/**
+	 * Reserve a fully-qualified data type class name so it cannot be used by
+	 * another class. No import statements will be generated for reserved types.
+	 * Typically, this is the fully-qualified class name of the class being
+	 * generated.
+	 * 
+	 * @param typeName
+	 *            FQ data type class name.
+	 */
+	public void addReservedType(String typeName) {
+		if (!canRegisterType(typeName))
+			return;
+
+		StringUtils stringUtils = StringUtils.getInstance();
+		String typeClassName = stringUtils.stripPackageName(typeName);
+
+		reservedImportTypesMap.put(typeClassName, typeName);
+	}
+
+	/**
+	 * Register a fully-qualified data type class name. For example,
+	 * org.apache.cayenne.CayenneDataObject.
+	 * 
+	 * @param typeName
+	 *            FQ data type class name.
+	 */
+	public void addType(String typeName) {
+		if (!canRegisterType(typeName))
+			return;
+
+		StringUtils stringUtils = StringUtils.getInstance();
+		String typePackageName = stringUtils.stripClass(typeName);
+		String typeClassName = stringUtils.stripPackageName(typeName);
+
+		if (typePackageName.equals(packageName))
+			return;
+
+		importTypesMap.put(typeClassName, typeName);
+	}
+
+	/**
+	 * Add the package name to use for this importUtil invocation.
+	 * 
+	 * @param packageName
+	 */
+	public void setPackage(String packageName) {
+		this.packageName = packageName;
+	}
+
+	/**
+	 * Performs processing similar to <code>formatJavaType(String)</code>, with
+	 * special handling of primitive types and their Java class counterparts.
+	 * This method allows users to make a decision whether to use primitives or
+	 * not, regardless of how type is mapped.
+	 */
+	public String formatJavaType(String typeName, boolean usePrimitives) {
+		if (usePrimitives) {
+			String primitive = primitivesForClasses.get(typeName);
+			return (primitive != null) ? primitive : formatJavaType(typeName);
+		} else {
+			String primitiveClass = classesForPrimitives.get(typeName);
+			return (primitiveClass != null) ? formatJavaType(primitiveClass) : formatJavaType(typeName);
+		}
+	}
+
+	/**
+	 * Removes registered package and non-reserved registered type name prefixes
+	 * from java types
+	 */
+	public String formatJavaType(String typeName) {
+		if (typeName != null) {
+			StringUtils stringUtils = StringUtils.getInstance();
+			String typeClassName = stringUtils.stripPackageName(typeName);
+
+			if (!reservedImportTypesMap.containsKey(typeClassName)) {
+				if (importTypesMap.containsKey(typeClassName)) {
+					if (typeName.equals(importTypesMap.get(typeClassName)))
+						return typeClassName;
+				}
+			}
+
+			String typePackageName = stringUtils.stripClass(typeName);
+			if ("java.lang".equals(typePackageName))
+				return typeClassName;
+			if ((null != packageName) && (packageName.equals(typePackageName)))
+				return typeClassName;
+		}
+
+		return typeName;
+	}
+
+	/**
+	 * @since 3.0
+	 */
+	public String formatJavaTypeAsNonBooleanPrimitive(String type) {
+		String value = ImportUtils.classesForPrimitives.get(type);
+		return formatJavaType(value != null ? value : type);
+	}
+
+	/**
+	 * @since 3.0
+	 */
+	public boolean isNonBooleanPrimitive(String type) {
+		return ImportUtils.classesForPrimitives.containsKey(type) && !isBoolean(type);
+	}
+
+	/**
+	 * @since 3.0
+	 */
+	public boolean isBoolean(String type) {
+		return "boolean".equals(type);
+	}
+
+	/**
+	 * Generate package and list of import statements based on the registered
+	 * types.
+	 */
+	public String generate() {
+		StringBuilder outputBuffer = new StringBuilder();
+
+		if (null != packageName) {
+			outputBuffer.append("package ");
+			outputBuffer.append(packageName);
+
+			// Using UNIX line endings intentionally - generated Java files
+			// should look
+			// the same regardless of platform to prevent developer teams
+			// working on
+			// multiple OS's to override each other's work
+			outputBuffer.append(";\n\n");
+		}
+
+		List<String> typesList = new ArrayList<>(importTypesMap.values());
+		Collections.sort(typesList, new Comparator<String>() {
+
+			public int compare(String s1, String s2) {
+
+				for (String ordering : importOrdering) {
+					if ((s1.startsWith(ordering)) && (!s2.startsWith(ordering))) {
+						return -1;
+					}
+					if ((!s1.startsWith(ordering)) && (s2.startsWith(ordering))) {
+						return 1;
+					}
+				}
+
+				return s1.compareTo(s2);
+			}
+		});
+
+		String lastStringPrefix = null;
+		boolean firstIteration = true;
+		for (String typeName : typesList) {
+
+			if (firstIteration) {
+				firstIteration = false;
+			} else {
+				outputBuffer.append('\n');
+			}
+			// Output another newline if we're in a different root package.
+			// Find root package
+			String thisStringPrefix = typeName;
+			int dotIndex = typeName.indexOf('.');
+			if (-1 != dotIndex) {
+				thisStringPrefix = typeName.substring(0, dotIndex);
+			}
+			// if this isn't the first import,
+			if (null != lastStringPrefix) {
+				// and it's different from the last import
+				if (false == thisStringPrefix.equals(lastStringPrefix)) {
+					// output a newline; force UNIX style per comment above
+					outputBuffer.append("\n");
+				}
+			}
+			lastStringPrefix = thisStringPrefix;
+
+			outputBuffer.append("import ");
+			outputBuffer.append(typeName);
+			outputBuffer.append(';');
+		}
+
+		return outputBuffer.toString();
+	}
+}

http://git-wip-us.apache.org/repos/asf/cayenne/blob/c63b6be2/cayenne-cgen/src/main/java/org/apache/cayenne/gen/StringUtils.java
----------------------------------------------------------------------
diff --git a/cayenne-cgen/src/main/java/org/apache/cayenne/gen/StringUtils.java b/cayenne-cgen/src/main/java/org/apache/cayenne/gen/StringUtils.java
new file mode 100644
index 0000000..778a09b
--- /dev/null
+++ b/cayenne-cgen/src/main/java/org/apache/cayenne/gen/StringUtils.java
@@ -0,0 +1,213 @@
+/*****************************************************************
+ *   Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ ****************************************************************/
+
+package org.apache.cayenne.gen;
+
+import org.apache.cayenne.project.validation.NameValidationHelper;
+import org.apache.cayenne.util.Util;
+
+/**
+ * Methods for mangling strings.
+ */
+public class StringUtils {
+
+    private static StringUtils sharedInstance;
+
+    public static StringUtils getInstance() {
+        if (null == sharedInstance) {
+            sharedInstance = new StringUtils();
+        }
+
+        return sharedInstance;
+    }
+
+    /**
+     * Prepends underscore to variable name if necessary to remove conflict with reserved
+     * keywords.
+     */
+    public String formatVariableName(String variableName) {
+        if (NameValidationHelper.getInstance().isReservedJavaKeyword(variableName)) {
+            return "_" + variableName;
+        }
+        else {
+            return variableName;
+        }
+    }
+
+    /**
+     * Removes package name, leaving base name.
+     * 
+     * @since 1.2
+     */
+    public String stripPackageName(String fullyQualifiedClassName) {
+        return Util.stripPackageName(fullyQualifiedClassName);
+    }
+
+    /**
+     * Removes base name, leaving package name.
+     * 
+     * @since 1.2
+     */
+    public String stripClass(String aString) {
+        if (aString == null || aString.length() == 0)
+            return aString;
+
+        int lastDot = aString.lastIndexOf('.');
+
+        if (-1 == lastDot)
+            return "";
+
+        return aString.substring(0, lastDot);
+    }
+
+    /**
+     * Capitalizes the first letter of the property name.
+     * 
+     * @since 1.1
+     */
+    public String capitalized(String name) {
+        if (name == null || name.length() == 0)
+            return name;
+
+        char c = Character.toUpperCase(name.charAt(0));
+        return (name.length() == 1) ? Character.toString(c) : c + name.substring(1);
+    }
+
+    /**
+     * Returns string with lowercased first letter
+     * 
+     * @since 1.2
+     */
+    public static String uncapitalized(String aString) {
+        if (aString == null || aString.length() == 0)
+            return aString;
+
+        char c = Character.toLowerCase(aString.charAt(0));
+        return (aString.length() == 1) ? Character.toString(c) : c + aString.substring(1);
+    }
+
+    /**
+     * Converts property name to Java constants naming convention.
+     * 
+     * @since 1.1
+     */
+    public String capitalizedAsConstant(String name) {
+        if (name == null || name.length() == 0)
+            return name;
+
+        // clear of non-java chars. While the method name implies that a passed identifier
+        // is pure Java, it is used to build pk columns names and such, so extra safety
+        // check is a good idea
+        name = Util.specialCharsToJava(name);
+
+        char charArray[] = name.toCharArray();
+        StringBuilder buffer = new StringBuilder();
+
+        for (int i = 0; i < charArray.length; i++) {
+            if ((Character.isUpperCase(charArray[i])) && (i != 0)) {
+
+                char prevChar = charArray[i - 1];
+                if ((Character.isLowerCase(prevChar))) {
+                    buffer.append("_");
+                }
+            }
+
+            buffer.append(Character.toUpperCase(charArray[i]));
+        }
+
+        return buffer.toString();
+    }
+
+    /**
+     * Converts entity or property name to a plural form. For example:
+     * <ul>
+     * <li>pluralize("Word") == "Words"</li>
+     * <li>pluralize("Status") == "Statuses"</li>
+     * <li>pluralize("Index") == "Indexes"</li>
+     * <li>pluralize("Factory") == "Factories"</li>
+     * </ul>
+     * <p>
+     * As of 3.1 this method is not used in bundled templates, and is present here for
+     * user templates convenience.
+     * 
+     * @since 3.1
+     */
+    public String pluralize(String str) {
+        if (str == null || str.length() == 0) {
+            return str;
+        }
+        else if (str.endsWith("s") || str.endsWith("x")) {
+            return str + "es";
+        }
+        else if (str.endsWith("y")) {
+            return str.substring(0, str.length() - 1) + "ies";
+        }
+        else {
+            return str + "s";
+        }
+    }
+
+    /**
+     * <p>
+     * Strip generic definition from string
+     * </p>
+     * <p>For example: List&gt;Integer&lt; == List</p>
+     * @since 4.0
+     */
+    public String stripGeneric(String str) {
+        if(str == null) {
+            return null;
+        }
+        int start = str.indexOf('<');
+        if(start == -1) {
+            return str;
+        }
+        int end = str.lastIndexOf('>');
+        if(end == -1) {
+            return str;
+        } else if(end == str.length() - 1) {
+            return str.substring(0, start);
+        }
+        return str.substring(0, start) + str.substring(end+1);
+    }
+
+    public String replaceWildcardInStringWithString(String wildcard, String pattern, String replacement) {
+        if (pattern == null || wildcard == null) {
+            return pattern;
+        }
+
+        StringBuilder buffer = new StringBuilder();
+        int lastPos = 0;
+        int wildCardPos = pattern.indexOf(wildcard);
+        while (wildCardPos != -1) {
+            if (lastPos != wildCardPos) {
+                buffer.append(pattern.substring(lastPos, wildCardPos));
+            }
+            buffer.append(replacement);
+            lastPos += wildCardPos + wildcard.length();
+            wildCardPos = pattern.indexOf(wildcard, lastPos);
+        }
+
+        if (lastPos < pattern.length()) {
+            buffer.append(pattern.substring(lastPos));
+        }
+
+        return buffer.toString();
+    }
+}

http://git-wip-us.apache.org/repos/asf/cayenne/blob/c63b6be2/cayenne-cgen/src/main/java/org/apache/cayenne/gen/TemplateType.java
----------------------------------------------------------------------
diff --git a/cayenne-cgen/src/main/java/org/apache/cayenne/gen/TemplateType.java b/cayenne-cgen/src/main/java/org/apache/cayenne/gen/TemplateType.java
new file mode 100644
index 0000000..109627e
--- /dev/null
+++ b/cayenne-cgen/src/main/java/org/apache/cayenne/gen/TemplateType.java
@@ -0,0 +1,55 @@
+/*****************************************************************
+ *   Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ ****************************************************************/
+package org.apache.cayenne.gen;
+
+/**
+ * Defines class generation template types.
+ * 
+ * @since 3.0
+ */
+public enum TemplateType {
+
+    ENTITY_SINGLE_CLASS(false),
+
+    ENTITY_SUPERCLASS(true),
+
+    ENTITY_SUBCLASS(false),
+
+    EMBEDDABLE_SINGLE_CLASS(false),
+
+    EMBEDDABLE_SUPERCLASS(true),
+
+    EMBEDDABLE_SUBCLASS(false),
+
+    DATAMAP_SINGLE_CLASS(false),
+
+    DATAMAP_SUPERCLASS(true),
+
+    DATAMAP_SUBCLASS(false);
+
+    private boolean superclass;
+
+    private TemplateType(boolean superclass) {
+        this.superclass = superclass;
+    }
+
+    public boolean isSuperclass() {
+        return superclass;
+    }
+}

http://git-wip-us.apache.org/repos/asf/cayenne/blob/c63b6be2/cayenne-cgen/src/main/java/org/apache/cayenne/gen/package.html
----------------------------------------------------------------------
diff --git a/cayenne-cgen/src/main/java/org/apache/cayenne/gen/package.html b/cayenne-cgen/src/main/java/org/apache/cayenne/gen/package.html
new file mode 100644
index 0000000..69b8b7d
--- /dev/null
+++ b/cayenne-cgen/src/main/java/org/apache/cayenne/gen/package.html
@@ -0,0 +1,28 @@
+<!--
+   Licensed to the Apache Software Foundation (ASF) under one
+   or more contributor license agreements.  See the NOTICE file
+   distributed with this work for additional information
+   regarding copyright ownership.  The ASF licenses this file
+   to you under the Apache License, Version 2.0 (the
+   "License"); you may not use this file except in compliance
+   with the License.  You may obtain a copy of the License at
+
+     http://www.apache.org/licenses/LICENSE-2.0
+
+   Unless required by applicable law or agreed to in writing,
+   software distributed under the License is distributed on an
+   "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+   KIND, either express or implied.  See the License for the
+   specific language governing permissions and limitations
+   under the License.
+-->
+<html>
+<body>
+Contains classes that provide Java source generation facility. 
+Source creation is based on a set of templates parsed 
+during generation process, using Jakarta Velocity template engine.
+
+<p><i>For more information see <a href="../../../../../../index.html"
+target="_top">Cayenne User Guide.</a></i></p>
+</body>
+</html>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/cayenne/blob/c63b6be2/cayenne-cgen/src/main/java/org/apache/cayenne/tools/CayenneGeneratorEntityFilterAction.java
----------------------------------------------------------------------
diff --git a/cayenne-cgen/src/main/java/org/apache/cayenne/tools/CayenneGeneratorEntityFilterAction.java b/cayenne-cgen/src/main/java/org/apache/cayenne/tools/CayenneGeneratorEntityFilterAction.java
new file mode 100644
index 0000000..4d068d8
--- /dev/null
+++ b/cayenne-cgen/src/main/java/org/apache/cayenne/tools/CayenneGeneratorEntityFilterAction.java
@@ -0,0 +1,85 @@
+/*****************************************************************
+ *   Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ ****************************************************************/
+package org.apache.cayenne.tools;
+
+import org.apache.cayenne.dbsync.filter.NameFilter;
+import org.apache.cayenne.map.DataMap;
+import org.apache.cayenne.map.Embeddable;
+import org.apache.cayenne.map.ObjEntity;
+
+import java.net.MalformedURLException;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Iterator;
+
+/**
+ * Performs entity filtering to build a collection of entities that should be used in
+ * class generation.
+ * 
+ * @since 3.0
+ */
+class CayenneGeneratorEntityFilterAction {
+
+    private NameFilter nameFilter;
+    private boolean client;
+
+    Collection<Embeddable> getFilteredEmbeddables(DataMap mainDataMap) {
+        Collection<Embeddable> embeddables = new ArrayList<>(mainDataMap.getEmbeddables());
+
+        // filter out excluded entities...
+        Iterator<Embeddable> it = embeddables.iterator();
+
+        while (it.hasNext()) {
+            Embeddable e = it.next();
+
+            // note that unlike entity, embeddable is matched by class name as it doesn't
+            // have a symbolic name...
+            if (!nameFilter.isIncluded(e.getClassName())) {
+                it.remove();
+            }
+        }
+
+        return embeddables;
+    }
+
+    Collection<ObjEntity> getFilteredEntities(DataMap mainDataMap)
+            throws MalformedURLException {
+
+        Collection<ObjEntity> entities = new ArrayList<>(mainDataMap.getObjEntities());
+
+        // filter out excluded entities...
+        Iterator<ObjEntity> it = entities.iterator();
+        while (it.hasNext()) {
+            ObjEntity e = it.next();
+            if (e.isGeneric() || client && !e.isClientAllowed() || !nameFilter.isIncluded(e.getName())) {
+                it.remove();
+            }
+        }
+
+        return entities;
+    }
+
+    void setClient(boolean client) {
+        this.client = client;
+    }
+
+    public void setNameFilter(NameFilter nameFilter) {
+        this.nameFilter = nameFilter;
+    }
+}

http://git-wip-us.apache.org/repos/asf/cayenne/blob/c63b6be2/cayenne-cgen/src/main/java/org/apache/cayenne/tools/CayenneGeneratorMapLoaderAction.java
----------------------------------------------------------------------
diff --git a/cayenne-cgen/src/main/java/org/apache/cayenne/tools/CayenneGeneratorMapLoaderAction.java b/cayenne-cgen/src/main/java/org/apache/cayenne/tools/CayenneGeneratorMapLoaderAction.java
new file mode 100644
index 0000000..1a0a098
--- /dev/null
+++ b/cayenne-cgen/src/main/java/org/apache/cayenne/tools/CayenneGeneratorMapLoaderAction.java
@@ -0,0 +1,78 @@
+/*****************************************************************
+ *   Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ ****************************************************************/
+package org.apache.cayenne.tools;
+
+import java.io.File;
+import java.net.MalformedURLException;
+
+import org.apache.cayenne.map.DataMap;
+import org.apache.cayenne.map.EntityResolver;
+import org.apache.cayenne.map.MapLoader;
+import org.xml.sax.InputSource;
+
+/**
+ * Loads a DataMap and a shared entity namespace.
+ * 
+ * @since 3.0
+ */
+class CayenneGeneratorMapLoaderAction {
+
+    private File mainDataMapFile;
+    private File[] additionalDataMapFiles;
+    private DataMap mainDataMap;
+
+    DataMap getMainDataMap() throws MalformedURLException {
+        if (mainDataMap == null) {
+            MapLoader mapLoader = new MapLoader();
+
+            DataMap mainDataMap = loadDataMap(mapLoader, mainDataMapFile);
+
+            if (additionalDataMapFiles != null) {
+
+                EntityResolver entityResolver = new EntityResolver();
+                entityResolver.addDataMap(mainDataMap);
+                mainDataMap.setNamespace(entityResolver);
+
+                for (File additionalDataMapFile : additionalDataMapFiles) {
+
+                    DataMap dataMap = loadDataMap(mapLoader, additionalDataMapFile);
+                    entityResolver.addDataMap(dataMap);
+                    dataMap.setNamespace(entityResolver);
+                }
+            }
+
+            this.mainDataMap = mainDataMap;
+        }
+
+        return mainDataMap;
+    }
+
+    protected DataMap loadDataMap(MapLoader mapLoader, File dataMapFile) throws MalformedURLException {
+        InputSource in = new InputSource(dataMapFile.toURI().toURL().toString());
+        return mapLoader.loadDataMap(in);
+    }
+
+    void setMainDataMapFile(File mainDataMapFile) {
+        this.mainDataMapFile = mainDataMapFile;
+    }
+
+    void setAdditionalDataMapFiles(File[] additionalDataMapFiles) {
+        this.additionalDataMapFiles = additionalDataMapFiles;
+    }
+}

http://git-wip-us.apache.org/repos/asf/cayenne/blob/c63b6be2/cayenne-cgen/src/main/resources/templates/v1_2/client-datamap-singleclass.vm
----------------------------------------------------------------------
diff --git a/cayenne-cgen/src/main/resources/templates/v1_2/client-datamap-singleclass.vm b/cayenne-cgen/src/main/resources/templates/v1_2/client-datamap-singleclass.vm
new file mode 100644
index 0000000..d0c7f6c
--- /dev/null
+++ b/cayenne-cgen/src/main/resources/templates/v1_2/client-datamap-singleclass.vm
@@ -0,0 +1,96 @@
+##   Licensed to the Apache Software Foundation (ASF) under one
+##  or more contributor license agreements.  See the NOTICE file
+##  distributed with this work for additional information
+##  regarding copyright ownership.  The ASF licenses this file
+##  to you under the Apache License, Version 2.0 (the
+##  "License"); you may not use this file except in compliance
+##  with the License.  You may obtain a copy of the License at
+##
+##    http://www.apache.org/licenses/LICENSE-2.0
+##
+##  Unless required by applicable law or agreed to in writing,
+##  software distributed under the License is distributed on an
+##  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+##  KIND, either express or implied.  See the License for the
+##  specific language governing permissions and limitations
+##  under the License.
+##
+##Terminology:
+##	Base class - super superclass of entity, ie, org.apache.cayenne.CayenneDataObject or MyBaseClass
+##  Super class - superclass of entity, ie,  org.apache.cayenne.art.auto._Artist
+##	Sub class - class of entity, ie, org.apache.cayenne.art.Artist
+##
+##  Classes available in template
+##    object (duplicated as 'objEntity') - the ObjEntity class: See org.apache.cayenne.map.ObjectEntity
+##    stringUtils - class for string "helper" functions: See org.apache.cayenne.gen.StringUtils
+##    dataMapUtils - class for query "helper" functions: See org.apache.cayenne.gen.DataMapUtils
+##    importUtils - class for import statement management: See org.apache.cayenne.gen.ImportUtils
+##    superClassName
+##    superPackageName
+##    subClassName
+##    subPackageName
+##    baseClassName
+##    basePackageName 
+##
+##
+${importUtils.setPackage($subPackageName)}##
+${importUtils.addReservedType("${subPackageName}.${subClassName}")}##
+${importUtils.addType("${basePackageName}.${baseClassName}")}##
+${importUtils.addType('java.util.List')}
+${importUtils.addType('java.util.Map')}
+${importUtils.addType('java.util.HashMap')}
+${importUtils.addType('org.apache.cayenne.ObjectContext')}
+#foreach( $selectQuery in ${object.SelectQueries})
+${importUtils.addType(${selectQuery.Root.ClassName})}
+#foreach( $parameter in ${dataMapUtils.getParameterNames(${selectQuery})})
+${importUtils.addType(${dataMapUtils.getParameterType(${selectQuery}, ${parameter})})}
+#end
+#end
+${importUtils.generate()}
+
+/**
+ * This class was generated by Cayenne.
+ * It is probably a good idea to avoid changing this class manually,
+ * since it may be overwritten next time code is regenerated.
+ * If you need to make any customizations, please use subclass.
+ */
+public class ${subClassName} {
+#if( ${object.hasQueryNames()})
+#foreach( $qname in ${object.QueryNames})
+
+    public static final String ${stringUtils.capitalizedAsConstant($qname)}_QUERYNAME = "$qname";
+#end
+#end
+
+private static ${subClassName} instance;
+
+    private ${subClassName}() {}
+
+    public ${subClassName} getInstance() {
+      if( instance == null) {
+        instance = new ${subClassName}();
+      }
+      return instance;
+    }
+
+#foreach( $selectQuery in ${object.SelectQueries})
+    public List<${stringUtils.stripPackageName($selectQuery.Root.ClassName)}> perform${dataMapUtils.getQueryMethodName(${selectQuery})}(ObjectContext context #foreach( $parameter in ${dataMapUtils.getParameterNames(${selectQuery})}), ${stringUtils.stripPackageName(${dataMapUtils.getParameterType(${selectQuery}, ${parameter})})} ${parameter} #end) {
+    #if(${dataMapUtils.hasParameters($selectQuery)})
+      String[] parameters = new String[] {
+      #foreach( $parameter in ${dataMapUtils.getParameterNames(${selectQuery})})
+      "${parameter}",
+      #end
+      };
+
+      Object[] values = new Object[] {
+      #foreach( $parameter in ${dataMapUtils.getParameterNames(${selectQuery})})
+      ${parameter},
+      #end
+      };
+    #end
+
+      NamedQuery query = new NamedQuery("${selectQuery.Name}"#if(${dataMapUtils.hasParameters($selectQuery)}), parameters, values#end);
+      return context.performQuery(query);
+    }
+#end
+}

http://git-wip-us.apache.org/repos/asf/cayenne/blob/c63b6be2/cayenne-cgen/src/main/resources/templates/v1_2/client-datamap-subclass.vm
----------------------------------------------------------------------
diff --git a/cayenne-cgen/src/main/resources/templates/v1_2/client-datamap-subclass.vm b/cayenne-cgen/src/main/resources/templates/v1_2/client-datamap-subclass.vm
new file mode 100644
index 0000000..f5e0474
--- /dev/null
+++ b/cayenne-cgen/src/main/resources/templates/v1_2/client-datamap-subclass.vm
@@ -0,0 +1,47 @@
+##   Licensed to the Apache Software Foundation (ASF) under one
+##  or more contributor license agreements.  See the NOTICE file
+##  distributed with this work for additional information
+##  regarding copyright ownership.  The ASF licenses this file
+##  to you under the Apache License, Version 2.0 (the
+##  "License"); you may not use this file except in compliance
+##  with the License.  You may obtain a copy of the License at
+##
+##    http://www.apache.org/licenses/LICENSE-2.0
+##
+##  Unless required by applicable law or agreed to in writing,
+##  software distributed under the License is distributed on an
+##  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+##  KIND, either express or implied.  See the License for the
+##  specific language governing permissions and limitations
+##  under the License.
+##
+##Terminology:
+##	Base class - super superclass of entity, ie, org.apache.cayenne.CayenneDataObject or MyBaseClass
+##  Super class - superclass of entity, ie,  org.apache.cayenne.art.auto._Artist
+##	Sub class - class of entity, ie, org.apache.cayenne.art.Artist
+##
+##  Classes available in template
+##    stringUtils - class for string "helper" functions: See org.apache.cayenne.gen.StringUtils
+##    dataMapUtils - class for query "helper" functions: See org.apache.cayenne.gen.dataMapUtils
+##    importUtils - class for import statement management: See org.apache.cayenne.gen.ImportUtils
+##
+##
+${importUtils.setPackage($subPackageName)}##
+${importUtils.addReservedType("${subPackageName}.${subClassName}")}##
+${importUtils.addType("${superPackageName}.${superClassName}")}##
+${importUtils.generate()}
+
+public class ${subClassName} extends ${superClassName} {
+
+    private static ${subClassName} instance;
+
+    private ${subClassName}() {}
+
+    public static ${subClassName} getInstance() {
+        if(instance == null) {
+            instance = new ${subClassName}();
+        }
+
+        return instance;
+    }
+}

http://git-wip-us.apache.org/repos/asf/cayenne/blob/c63b6be2/cayenne-cgen/src/main/resources/templates/v1_2/client-datamap-superclass.vm
----------------------------------------------------------------------
diff --git a/cayenne-cgen/src/main/resources/templates/v1_2/client-datamap-superclass.vm b/cayenne-cgen/src/main/resources/templates/v1_2/client-datamap-superclass.vm
new file mode 100644
index 0000000..c196301
--- /dev/null
+++ b/cayenne-cgen/src/main/resources/templates/v1_2/client-datamap-superclass.vm
@@ -0,0 +1,83 @@
+##   Licensed to the Apache Software Foundation (ASF) under one
+##  or more contributor license agreements.  See the NOTICE file
+##  distributed with this work for additional information
+##  regarding copyright ownership.  The ASF licenses this file
+##  to you under the Apache License, Version 2.0 (the
+##  "License"); you may not use this file except in compliance
+##  with the License.  You may obtain a copy of the License at
+##
+##    http://www.apache.org/licenses/LICENSE-2.0
+##
+##  Unless required by applicable law or agreed to in writing,
+##  software distributed under the License is distributed on an
+##  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+##  KIND, either express or implied.  See the License for the
+##  specific language governing permissions and limitations
+##  under the License.
+##
+##Terminology:
+##	Base class - super superclass of entity, ie, org.apache.cayenne.CayenneDataObject or MyBaseClass
+##  Super class - superclass of entity, ie,  org.apache.cayenne.art.auto._Artist
+##	Sub class - class of entity, ie, org.apache.cayenne.art.Artist
+##
+##  Classes available in template
+##    stringUtils - class for string "helper" functions: See org.apache.cayenne.gen.StringUtils
+##    dataMapUtils - class for query "helper" functions: See org.apache.cayenne.gen.DataMapUtils
+##    importUtils - class for import statement management: See org.apache.cayenne.gen.ImportUtils
+##    superClassName
+##    superPackageName
+##    subClassName
+##    subPackageName
+##    baseClassName
+##    basePackageName
+##
+${importUtils.setPackage($superPackageName)}##
+#if(${superPackageName})${importUtils.addReservedType("${superPackageName}.${superClassName}")}#end##
+#if(${basePackageName})${importUtils.addType("${basePackageName}.${baseClassName}")}#end##
+#if( ${object.hasSelectQueries()} ) 
+${importUtils.addType('java.util.List')}##
+${importUtils.addType('org.apache.cayenne.ObjectContext')}##
+${importUtils.addType('org.apache.cayenne.query.NamedQuery')}##
+#foreach( $selectQuery in ${object.SelectQueries})
+${importUtils.addType(${selectQuery.Root.ClientClassName})}##
+#foreach( $parameter in ${dataMapUtils.getParameterNames(${selectQuery})})
+${importUtils.addType(${dataMapUtils.getParameterType(${selectQuery}, ${parameter})})}##
+#end    
+#end
+#end
+${importUtils.generate()}
+
+/**
+ * This class was generated by Cayenne.
+ * It is probably a good idea to avoid changing this class manually,
+ * since it may be overwritten next time code is regenerated.
+ * If you need to make any customizations, please use subclass.
+ */
+public class ${superClassName} {
+#if( ${object.hasQueryNames()})
+#foreach( $qname in ${object.QueryNames})
+
+    public static final String ${stringUtils.capitalizedAsConstant($qname)}_QUERYNAME = "$qname";
+#end
+#end
+#foreach( $selectQuery in ${object.SelectQueries})
+
+    public List<${stringUtils.stripPackageName($selectQuery.Root.ClientClassName)}> perform${dataMapUtils.getQueryMethodName(${selectQuery})}(ObjectContext context #foreach( $parameter in ${dataMapUtils.getParameterNames(${selectQuery})}), ${stringUtils.stripPackageName(${dataMapUtils.getParameterType(${selectQuery}, ${parameter})})} ${parameter}#end) {
+#if(${dataMapUtils.hasParameters($selectQuery)})
+        String[] parameters = {
+#foreach( $parameter in ${dataMapUtils.getParameterNames(${selectQuery})})
+            "${parameter}",
+#end
+        };
+
+        Object[] values = {
+#foreach( $parameter in ${dataMapUtils.getParameterNames(${selectQuery})})
+            ${parameter},
+#end
+        };
+
+#end
+        return context.performQuery(new NamedQuery("${selectQuery.Name}"#if(${dataMapUtils.hasParameters($selectQuery)}), parameters, values#end));
+    }
+#end
+}

http://git-wip-us.apache.org/repos/asf/cayenne/blob/c63b6be2/cayenne-cgen/src/main/resources/templates/v1_2/client-subclass.vm
----------------------------------------------------------------------
diff --git a/cayenne-cgen/src/main/resources/templates/v1_2/client-subclass.vm b/cayenne-cgen/src/main/resources/templates/v1_2/client-subclass.vm
new file mode 100644
index 0000000..d28de85
--- /dev/null
+++ b/cayenne-cgen/src/main/resources/templates/v1_2/client-subclass.vm
@@ -0,0 +1,57 @@
+##   Licensed to the Apache Software Foundation (ASF) under one
+##  or more contributor license agreements.  See the NOTICE file
+##  distributed with this work for additional information
+##  regarding copyright ownership.  The ASF licenses this file
+##  to you under the Apache License, Version 2.0 (the
+##  "License"); you may not use this file except in compliance
+##  with the License.  You may obtain a copy of the License at
+##
+##    http://www.apache.org/licenses/LICENSE-2.0
+##
+##  Unless required by applicable law or agreed to in writing,
+##  software distributed under the License is distributed on an
+##  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+##  KIND, either express or implied.  See the License for the
+##  specific language governing permissions and limitations
+##  under the License.
+##
+##  A default Cayenne template for a client-side subclass in a generated subclass/superclass pair.
+## 
+##  Terminology:
+##  Base class - super superclass of entity, ie, org.apache.cayenne.CayenneDataObject or MyBaseClass
+##  Super class - superclass of entity, ie,  org.apache.cayenne.art.auto._Artist
+##  Sub class - class of entity, ie, org.apache.cayenne.art.Artist
+##
+##  Classes available in template
+##    object (duplicated as 'objEntity') - the ObjEntity class: See org.apache.cayenne.map.ObjectEntity
+##    stringUtils - class for string "helper" functions: See org.apache.cayenne.gen.StringUtils
+##    entityUtils - class for entity "helper" functions: See org.apache.cayenne.gen.EntityUtils
+##    importUtils - class for import statement management: See org.apache.cayenne.gen.ImportUtils
+##    superClassName
+##    superPackageName
+##    subClassName
+##    subPackageName
+##    baseClassName
+##    basePackageName 
+##
+${importUtils.setPackage($subPackageName)}##
+${importUtils.addReservedType("${$subPackageName}.${subClassName}")}##
+${importUtils.addType("${superPackageName}.${superClassName}")}##
+${importUtils.generate()}
+
+/**
+ * A persistent class mapped as "${object.name}" Cayenne entity.
+ */
+public#if("true" == "${object.getIsAbstract()}") abstract#end class ${subClassName} extends ${superClassName} {
+
+     private static final long serialVersionUID = 1L; 
+     
+##callback methods
+#foreach( $cbname in ${entityUtils.callbackNames})
+    @Override
+    protected void ${cbname}() {
+        //TODO: Implement ${cbname}
+    }
+
+#end
+}

http://git-wip-us.apache.org/repos/asf/cayenne/blob/c63b6be2/cayenne-cgen/src/main/resources/templates/v1_2/client-superclass.vm
----------------------------------------------------------------------
diff --git a/cayenne-cgen/src/main/resources/templates/v1_2/client-superclass.vm b/cayenne-cgen/src/main/resources/templates/v1_2/client-superclass.vm
new file mode 100644
index 0000000..f8c9cbe
--- /dev/null
+++ b/cayenne-cgen/src/main/resources/templates/v1_2/client-superclass.vm
@@ -0,0 +1,248 @@
+##   Licensed to the Apache Software Foundation (ASF) under one
+##  or more contributor license agreements.  See the NOTICE file
+##  distributed with this work for additional information
+##  regarding copyright ownership.  The ASF licenses this file
+##  to you under the Apache License, Version 2.0 (the
+##  "License"); you may not use this file except in compliance
+##  with the License.  You may obtain a copy of the License at
+##
+##    http://www.apache.org/licenses/LICENSE-2.0
+##
+##  Unless required by applicable law or agreed to in writing,
+##  software distributed under the License is distributed on an
+##  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+##  KIND, either express or implied.  See the License for the
+##  specific language governing permissions and limitations
+##  under the License.
+##
+##Terminology:
+##	Base class - super superclass of entity, ie, org.apache.cayenne.PersistentObject or MyBaseClass
+##  Super class - superclass of entity, ie,  org.apache.cayenne.art.auto._Artist
+##	Sub class - class of entity, ie, org.apache.cayenne.art.Artist
+##
+##  Classes available in template
+##    object (duplicated as 'objEntity') - the ObjEntity class: See org.apache.cayenne.map.ObjectEntity
+##    stringUtils - class for string "helper" functions: See org.apache.cayenne.gen.StringUtils
+##    entityUtils - class for entity "helper" functions: See org.apache.cayenne.gen.EntityUtils
+##    importUtils - class for import statement management: See org.apache.cayenne.gen.ImportUtils
+##    superClassName
+##    superPackageName
+##    subClassName
+##    subPackageName
+##    baseClassName
+##    basePackageName
+##
+##
+${importUtils.setPackage($superPackageName)}##
+${importUtils.addReservedType("${$superPackageName}.${superClassName}")}##
+${importUtils.addType("${basePackageName}.${baseClassName}")}##
+#if((${object.DeclaredAttributes} && !${object.DeclaredAttributes.isEmpty()}) || (${object.DeclaredRelationships} && !${object.DeclaredRelationships.isEmpty()}))
+${importUtils.addType('org.apache.cayenne.exp.Property')}##
+#end
+#foreach( $attr in ${object.DeclaredAttributes} )
+$importUtils.addType(${attr.Type})##
+#end
+#foreach( $rel in ${object.DeclaredRelationships} )
+$importUtils.addType(${rel.TargetEntity.ClientClassName})##
+#if(${rel.CollectionType}) 
+$importUtils.addType(${rel.CollectionType})##
+#end
+#end
+#if( ${entityUtils.hasToOneDeclaredRelationships()} )
+${importUtils.addType('org.apache.cayenne.ValueHolder')}##
+${importUtils.addType('org.apache.cayenne.util.PersistentObjectHolder')}##
+#end
+#if( ${entityUtils.hasToManyDeclaredRelationships()} )
+${importUtils.addType('org.apache.cayenne.util.PersistentObjectList')}##
+#end
+${importUtils.generate()}
+
+/**
+ * A generated persistent class mapped as "${object.name}" Cayenne entity. It is a good idea to
+ * avoid changing this class manually, since it will be overwritten next time code is
+ * regenerated. If you need to make any customizations, put them in a subclass.
+ */
+public abstract class ${superClassName} extends ${baseClassName} {
+
+## Create ivars names
+#if( $createPropertyNames )
+#foreach( $attr in ${object.DeclaredAttributes} )
+    public static final String ${stringUtils.capitalizedAsConstant($attr.Name)}_PROPERTY = "${attr.Name}";
+#end
+#foreach( $rel in ${object.DeclaredRelationships} )
+    public static final String ${stringUtils.capitalizedAsConstant($rel.Name)}_PROPERTY = "${rel.Name}";
+#end
+
+#end
+## Create Properties
+#foreach( $attr in ${object.DeclaredAttributes} )
+    #set ( $type = "$importUtils.formatJavaType(${attr.Type}, false)" )
+    public static final Property<$type> ${stringUtils.capitalizedAsConstant($attr.Name)} = Property.create("${attr.Name}", ${stringUtils.stripGeneric($type)}.class);
+#end
+#foreach( $rel in ${object.DeclaredRelationships} )
+#if( $rel.ToMany )
+#if ( ${rel.CollectionType} == "java.util.Map")
+    #set( $type = "$importUtils.formatJavaType($rel.CollectionType)<$importUtils.formatJavaType($entityUtils.getMapKeyType($rel)), $importUtils.formatJavaType($rel.TargetEntity.ClientClassName)>" )
+    public static final Property<$type> ${stringUtils.capitalizedAsConstant($rel.Name)} = Property.create("${rel.Name}", ${stringUtils.stripGeneric($type)}.class);
+#else
+    #set( $type = "$importUtils.formatJavaType($rel.CollectionType)<$importUtils.formatJavaType($rel.TargetEntity.ClientClassName)>" )
+    public static final Property<$type> ${stringUtils.capitalizedAsConstant($rel.Name)} = Property.create("${rel.Name}", ${stringUtils.stripGeneric($type)}.class);
+#end
+#else
+    #set( $type = "$importUtils.formatJavaType(${rel.TargetEntity.ClassName})" )
+    public static final Property<$type> ${stringUtils.capitalizedAsConstant($rel.Name)} = Property.create("${rel.Name}", ${stringUtils.stripGeneric($type)}.class);
+#end
+#end
+
+## Create ivars
+#foreach( $attr in ${object.DeclaredAttributes} )
+    protected $importUtils.formatJavaType(${attr.Type}) ${attr.Name};
+#end
+#foreach( $rel in ${object.DeclaredRelationships} )
+#if( $rel.ToMany )
+#if ( ${rel.CollectionType} == "java.util.Map")
+    protected $importUtils.formatJavaType($rel.CollectionType)<$importUtils.formatJavaType($entityUtils.getMapKeyType($rel)), $importUtils.formatJavaType($rel.TargetEntity.ClientClassName)> ${rel.Name};
+#else
+    protected $importUtils.formatJavaType($rel.CollectionType)<$importUtils.formatJavaType($rel.TargetEntity.ClientClassName)> ${rel.Name};
+#end
+#else
+    protected ValueHolder ${rel.Name};
+#end
+#end
+
+## Create attribute set/get methods
+#foreach( $attr in ${object.DeclaredAttributes} )
+#if ( $importUtils.isBoolean(${attr.Type}) )
+    public boolean is${stringUtils.capitalized($attr.Name)}() {
+        if(objectContext != null) {
+            objectContext.prepareForAccess(this, "${attr.Name}", false);
+        }
+
+        return ${attr.Name};
+    }
+#else 
+    public $importUtils.formatJavaType(${attr.Type}) get${stringUtils.capitalized($attr.Name)}() {
+        if(objectContext != null) {
+            objectContext.prepareForAccess(this, "${attr.Name}", false);
+        }
+
+        return ${attr.Name};
+    }
+#end
+#if ("true" != "${object.isReadOnly()}")
+    public void set${stringUtils.capitalized($attr.Name)}($importUtils.formatJavaType(${attr.Type}) $stringUtils.formatVariableName(${attr.Name})) {
+        if(objectContext != null) {
+            objectContext.prepareForAccess(this, "${attr.Name}", false);
+        }
+
+        Object oldValue = this.${stringUtils.formatVariableName($attr.Name)};
+        // notify objectContext about simple property change
+        if(objectContext != null) {
+            objectContext.propertyChanged(this, "${attr.Name}", oldValue, $stringUtils.formatVariableName(${attr.Name}));
+        }
+        
+        this.${stringUtils.formatVariableName($attr.Name)} = ${stringUtils.formatVariableName($attr.Name)};
+    }
+#end
+
+#end
+##
+##
+## Create list add/remove/get methods
+#foreach( $rel in ${object.DeclaredRelationships} )
+#if( $rel.ToMany )
+#if ( ${rel.CollectionType} == "java.util.Map")
+    public $importUtils.formatJavaType($rel.CollectionType)<$importUtils.formatJavaType($entityUtils.getMapKeyType($rel)), $importUtils.formatJavaType($rel.TargetEntity.ClientClassName)> get${stringUtils.capitalized($rel.Name)}() {
+#else
+    public $importUtils.formatJavaType($rel.CollectionType)<$importUtils.formatJavaType($rel.TargetEntity.ClientClassName)> get${stringUtils.capitalized($rel.Name)}() {
+#end
+        if(objectContext != null) {
+            objectContext.prepareForAccess(this, "${rel.Name}", true);
+        } else if (this.$rel.Name == null) {
+#if ( ${rel.CollectionType} == "java.util.Map")
+        	throw new RuntimeException("Map relationships cannot be accessed for transient objects");
+#else
+        	this.$rel.Name = new PersistentObjectList(this, "${rel.Name}");
+#end
+		}
+
+        return ${rel.Name};
+    }
+#if ( ! $rel.ReadOnly )
+#if ( ${rel.CollectionType} == "java.util.Map")
+	public void addTo${stringUtils.capitalized($rel.Name)}($importUtils.formatJavaType(${rel.TargetEntity.ClientClassName}) object) {
+        if(objectContext != null) {
+            objectContext.prepareForAccess(this, "${rel.Name}", true);
+        } else if (this.$rel.Name == null) {
+        	throw new RuntimeException("Map relationships cannot be accessed for transient objects");        
+        }
+
+        this.${rel.Name}.put(getMapKey("${rel.Name}", object), object);
+    }
+    public void removeFrom${stringUtils.capitalized($rel.Name)}($importUtils.formatJavaType(${rel.TargetEntity.ClientClassName}) object) {
+        if(objectContext != null) {
+            objectContext.prepareForAccess(this, "${rel.Name}", true);
+        } else if (this.$rel.Name == null) {
+        	throw new RuntimeException("Map relationships cannot be accessed for transient objects");        
+        }
+
+        this.${rel.Name}.remove(getMapKey("${rel.Name}", object));
+    }
+#else
+    public void addTo${stringUtils.capitalized($rel.Name)}($importUtils.formatJavaType(${rel.TargetEntity.ClientClassName}) object) {
+        if(objectContext != null) {
+            objectContext.prepareForAccess(this, "${rel.Name}", true);
+        } else if (this.$rel.Name == null) {
+        	this.$rel.Name = new PersistentObjectList(this, "${rel.Name}");
+		}
+
+        this.${rel.Name}.add(object);
+    }
+    public void removeFrom${stringUtils.capitalized($rel.Name)}($importUtils.formatJavaType(${rel.TargetEntity.ClientClassName}) object) {
+        if(objectContext != null) {
+            objectContext.prepareForAccess(this, "${rel.Name}", true);
+        } else if (this.$rel.Name == null) {
+        	this.$rel.Name = new PersistentObjectList(this, "${rel.Name}");
+		}
+
+        this.${rel.Name}.remove(object);
+    }
+#end
+#end
+#else
+    public $importUtils.formatJavaType(${rel.TargetEntity.ClientClassName}) get${stringUtils.capitalized($rel.Name)}() {
+        if(objectContext != null) {
+            objectContext.prepareForAccess(this, "${rel.Name}", true);
+        } else if (this.$rel.Name == null) {
+        	this.$rel.Name = new PersistentObjectHolder(this, "$rel.Name");
+		}
+
+        return ($importUtils.formatJavaType(${rel.TargetEntity.ClientClassName})) ${rel.Name}.getValue();
+    }
+#if ( !${object.isReadOnly()} && !$rel.ReadOnly )
+    public void set${stringUtils.capitalized($rel.Name)}(${importUtils.formatJavaType($rel.TargetEntity.ClientClassName)} $stringUtils.formatVariableName(${rel.Name})) {
+        if(objectContext != null) {
+            objectContext.prepareForAccess(this, "${rel.Name}", true);
+        } else if (this.$rel.Name == null) {
+        	this.$rel.Name = new PersistentObjectHolder(this, "$rel.Name");
+		}
+
+        // note how we notify ObjectContext of change BEFORE the object is actually
+        // changed... this is needed to take a valid current snapshot
+        Object oldValue = this.${rel.Name}.getValueDirectly();
+        if (objectContext != null) {
+        	objectContext.propertyChanged(this, "$rel.Name", oldValue, $stringUtils.formatVariableName(${rel.Name}));
+        }
+        
+        this.${stringUtils.formatVariableName($rel.Name)}.setValue(${stringUtils.formatVariableName($rel.Name)});
+    }
+#end
+#end
+
+#end
+##callback methods
+#foreach( $cbname in ${entityUtils.callbackNames})
+    protected abstract void ${cbname}();
+
+#end
+}


[08/10] cayenne git commit: CAY-2215 split cayenne-tools into cayenne-cgen and cayenne-ant

Posted by nt...@apache.org.
http://git-wip-us.apache.org/repos/asf/cayenne/blob/c63b6be2/cayenne-ant/src/test/resources/testmap.map.xml
----------------------------------------------------------------------
diff --git a/cayenne-ant/src/test/resources/testmap.map.xml b/cayenne-ant/src/test/resources/testmap.map.xml
new file mode 100644
index 0000000..60b94a6
--- /dev/null
+++ b/cayenne-ant/src/test/resources/testmap.map.xml
@@ -0,0 +1,744 @@
+<?xml version="1.0" encoding="utf-8"?>
+<data-map xmlns="http://cayenne.apache.org/schema/3.0/modelMap"
+	 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+	 xsi:schemaLocation="http://cayenne.apache.org/schema/3.0/modelMap http://cayenne.apache.org/schema/3.0/modelMap.xsd"
+	 project-version="6">
+	<property name="defaultPackage" value="org.apache.cayenne.testdo.testmap"/>
+	<property name="defaultSuperclass" value="org.apache.cayenne.CayenneDataObject"/>
+	<property name="clientSupported" value="true"/>
+	<property name="defaultClientPackage" value="test.client"/>
+	<property name="defaultClientSuperclass" value="org.apache.cayenne.PersistentObject"/>
+	<procedure name="cayenne_tst_out_proc">
+		<procedure-parameter name="in_param" type="INTEGER" direction="in"/>
+		<procedure-parameter name="out_param" type="INTEGER" direction="out"/>
+	</procedure>
+	<procedure name="cayenne_tst_select_proc">
+		<procedure-parameter name="aName" type="VARCHAR" length="254" direction="in"/>
+		<procedure-parameter name="paintingPrice" type="INTEGER" direction="in"/>
+	</procedure>
+	<procedure name="cayenne_tst_upd_proc">
+		<procedure-parameter name="paintingPrice" type="INTEGER" direction="in"/>
+	</procedure>
+	<procedure name="cayenne_tst_upd_proc2">
+	</procedure>
+	<db-entity name="ARRAYS_ENTITY">
+		<db-attribute name="BYTE_ARRAY" type="VARBINARY" length="200"/>
+		<db-attribute name="BYTE_WRAPPER_ARRAY" type="VARBINARY" length="200"/>
+		<db-attribute name="CHAR_ARRAY" type="VARCHAR" length="200"/>
+		<db-attribute name="CHAR_WRAPPER_ARRAY" type="VARCHAR" length="200"/>
+		<db-attribute name="ID" type="INTEGER" isPrimaryKey="true" isMandatory="true"/>
+	</db-entity>
+	<db-entity name="ARTGROUP">
+		<db-attribute name="GROUP_ID" type="INTEGER" isPrimaryKey="true" isMandatory="true"/>
+		<db-attribute name="NAME" type="VARCHAR" isMandatory="true" length="100"/>
+		<db-attribute name="PARENT_GROUP_ID" type="INTEGER"/>
+	</db-entity>
+	<db-entity name="ARTIST">
+		<db-attribute name="ARTIST_ID" type="BIGINT" isPrimaryKey="true" isMandatory="true"/>
+		<db-attribute name="ARTIST_NAME" type="CHAR" isMandatory="true" length="254"/>
+		<db-attribute name="DATE_OF_BIRTH" type="DATE"/>
+	</db-entity>
+	<db-entity name="ARTIST_CT">
+		<db-attribute name="ARTIST_ID" type="INTEGER" isPrimaryKey="true" isMandatory="true"/>
+		<db-attribute name="ARTIST_NAME" type="CHAR" isMandatory="true" length="254"/>
+		<db-attribute name="DATE_OF_BIRTH" type="DATE"/>
+	</db-entity>
+	<db-entity name="ARTIST_EXHIBIT">
+		<db-attribute name="ARTIST_ID" type="BIGINT" isPrimaryKey="true" isMandatory="true"/>
+		<db-attribute name="EXHIBIT_ID" type="INTEGER" isPrimaryKey="true" isMandatory="true"/>
+	</db-entity>
+	<db-entity name="ARTIST_GROUP">
+		<db-attribute name="ARTIST_ID" type="BIGINT" isPrimaryKey="true" isMandatory="true"/>
+		<db-attribute name="GROUP_ID" type="INTEGER" isPrimaryKey="true" isMandatory="true"/>
+	</db-entity>
+	<db-entity name="BIGDECIMAL_ENTITY">
+		<db-attribute name="BIGDECIMAL_FIELD" type="NUMERIC" length="12" scale="2"/>
+		<db-attribute name="ID" type="INTEGER" isPrimaryKey="true" isMandatory="true"/>
+	</db-entity>
+	<db-entity name="BIGINTEGER_ENTITY">
+		<db-attribute name="BIG_INTEGER_FIELD" type="BIGINT"/>
+		<db-attribute name="ID" type="INTEGER" isPrimaryKey="true" isMandatory="true"/>
+	</db-entity>
+	<db-entity name="BINARY_PK_TEST1">
+		<db-attribute name="BIN_ID" type="VARBINARY" isPrimaryKey="true" isMandatory="true" length="32"/>
+		<db-attribute name="NAME" type="VARCHAR" length="10"/>
+	</db-entity>
+	<db-entity name="BINARY_PK_TEST2">
+		<db-attribute name="DETAIL_NAME" type="VARCHAR" length="10"/>
+		<db-attribute name="FK_ID" type="VARBINARY" length="32"/>
+		<db-attribute name="ID" type="INTEGER" isPrimaryKey="true" isMandatory="true"/>
+	</db-entity>
+	<db-entity name="BIT_TEST">
+		<db-attribute name="BIT_COLUMN" type="BIT" isMandatory="true"/>
+		<db-attribute name="ID" type="INTEGER" isPrimaryKey="true" isMandatory="true"/>
+	</db-entity>
+	<db-entity name="BLOB_TEST">
+		<db-attribute name="BLOB_COL" type="BLOB"/>
+		<db-attribute name="BLOB_TEST_ID" type="INTEGER" isPrimaryKey="true" isMandatory="true"/>
+	</db-entity>
+	<db-entity name="BOOLEAN_TEST">
+		<db-attribute name="BOOLEAN_COLUMN" type="BOOLEAN" isMandatory="true"/>
+		<db-attribute name="ID" type="INTEGER" isPrimaryKey="true" isMandatory="true"/>
+	</db-entity>
+	<db-entity name="CALENDAR_TEST">
+		<db-attribute name="CALENDAR_FIELD" type="TIMESTAMP"/>
+		<db-attribute name="ID" type="INTEGER" isPrimaryKey="true" isMandatory="true"/>
+	</db-entity>
+	<db-entity name="CHARACTER_ENTITY">
+		<db-attribute name="CHARACTER_FIELD" type="CHAR" length="1"/>
+		<db-attribute name="ID" type="INTEGER" isPrimaryKey="true" isMandatory="true"/>
+	</db-entity>
+	<db-entity name="CHAR_FK_TEST">
+		<db-attribute name="FK_COL" type="CHAR" length="10"/>
+		<db-attribute name="NAME" type="VARCHAR" length="100"/>
+		<db-attribute name="PK" type="INTEGER" isPrimaryKey="true" isMandatory="true"/>
+	</db-entity>
+	<db-entity name="CHAR_PK_TEST">
+		<db-attribute name="OTHER_COL" type="CHAR" length="10"/>
+		<db-attribute name="PK_COL" type="CHAR" isPrimaryKey="true" isMandatory="true" length="10"/>
+	</db-entity>
+	<db-entity name="CLOB_TEST">
+		<db-attribute name="CLOB_COL" type="CLOB"/>
+		<db-attribute name="CLOB_TEST_ID" type="INTEGER" isPrimaryKey="true" isMandatory="true"/>
+	</db-entity>
+	<db-entity name="CLOB_TEST_RELATION">
+		<db-attribute name="ID" type="INTEGER" isPrimaryKey="true" isMandatory="true"/>
+		<db-attribute name="ID_CLOB" type="INTEGER" isMandatory="true"/>
+		<db-attribute name="VALUE" type="INTEGER"/>
+	</db-entity>
+	<db-entity name="COMPOUND_FK_TEST">
+		<db-attribute name="F_KEY1" type="VARCHAR" length="20"/>
+		<db-attribute name="F_KEY2" type="VARCHAR" length="20"/>
+		<db-attribute name="NAME" type="VARCHAR" length="255"/>
+		<db-attribute name="PKEY" type="INTEGER" isPrimaryKey="true" isMandatory="true"/>
+	</db-entity>
+	<db-entity name="COMPOUND_PK_TEST">
+		<db-attribute name="KEY1" type="VARCHAR" isPrimaryKey="true" isMandatory="true" length="20"/>
+		<db-attribute name="KEY2" type="VARCHAR" isPrimaryKey="true" isMandatory="true" length="20"/>
+		<db-attribute name="NAME" type="VARCHAR" length="255"/>
+	</db-entity>
+	<db-entity name="DATE_TEST">
+		<db-attribute name="DATE_COLUMN" type="DATE"/>
+		<db-attribute name="DATE_TEST_ID" type="INTEGER" isPrimaryKey="true" isMandatory="true"/>
+		<db-attribute name="TIMESTAMP_COLUMN" type="TIMESTAMP"/>
+		<db-attribute name="TIME_COLUMN" type="TIME"/>
+	</db-entity>
+	<db-entity name="DECIMAL_PK_TST">
+		<db-attribute name="DECIMAL_PK" type="DECIMAL" isPrimaryKey="true" isMandatory="true"/>
+		<db-attribute name="NAME" type="VARCHAR" length="100"/>
+	</db-entity>
+	<db-entity name="ENUM_ENTITY">
+		<db-attribute name="ENUM_ATTRIBUTE" type="VARCHAR" length="250"/>
+		<db-attribute name="ID" type="INTEGER" isPrimaryKey="true" isMandatory="true"/>
+	</db-entity>
+	<db-entity name="EXHIBIT">
+		<db-attribute name="CLOSING_DATE" type="TIMESTAMP" isMandatory="true"/>
+		<db-attribute name="EXHIBIT_ID" type="INTEGER" isPrimaryKey="true" isMandatory="true"/>
+		<db-attribute name="GALLERY_ID" type="INTEGER" isMandatory="true"/>
+		<db-attribute name="OPENING_DATE" type="TIMESTAMP" isMandatory="true"/>
+	</db-entity>
+	<db-entity name="EXTENDED_TYPE_TEST">
+		<db-attribute name="ID" type="INTEGER" isPrimaryKey="true" isMandatory="true"/>
+		<db-attribute name="NAME" type="VARCHAR" length="200"/>
+	</db-entity>
+	<db-entity name="FLOAT_TEST">
+		<db-attribute name="FLOAT_COL" type="FLOAT"/>
+		<db-attribute name="ID" type="INTEGER" isPrimaryKey="true" isMandatory="true"/>
+	</db-entity>
+	<db-entity name="GALLERY">
+		<db-attribute name="GALLERY_ID" type="INTEGER" isPrimaryKey="true" isMandatory="true"/>
+		<db-attribute name="GALLERY_NAME" type="VARCHAR" isMandatory="true" length="100"/>
+	</db-entity>
+	<db-entity name="GENERATED_COLUMN_COMP_KEY">
+		<db-attribute name="AUTO_PK" type="INTEGER" isPrimaryKey="true" isMandatory="true"/>
+		<db-attribute name="GENERATED_COLUMN" type="INTEGER" isPrimaryKey="true" isGenerated="true" isMandatory="true"/>
+		<db-attribute name="NAME" type="VARCHAR" length="100"/>
+		<db-attribute name="PROPAGATED_PK" type="INTEGER" isPrimaryKey="true" isMandatory="true"/>
+	</db-entity>
+	<db-entity name="GENERATED_COLUMN_COMP_M">
+		<db-attribute name="ID" type="INTEGER" isPrimaryKey="true" isMandatory="true"/>
+		<db-attribute name="NAME" type="VARCHAR" length="100"/>
+	</db-entity>
+	<db-entity name="GENERATED_COLUMN_DEP">
+		<db-attribute name="GENERATED_COLUMN_FK" type="INTEGER" isPrimaryKey="true" isMandatory="true"/>
+		<db-attribute name="NAME" type="VARCHAR" length="100"/>
+	</db-entity>
+	<db-entity name="GENERATED_COLUMN_TEST">
+		<db-attribute name="GENERATED_COLUMN" type="INTEGER" isPrimaryKey="true" isGenerated="true" isMandatory="true"/>
+		<db-attribute name="NAME" type="VARCHAR" length="250"/>
+	</db-entity>
+	<db-entity name="GENERATED_COLUMN_TEST2">
+		<db-attribute name="GENERATED_COLUMN" type="INTEGER" isPrimaryKey="true" isGenerated="true" isMandatory="true"/>
+		<db-attribute name="NAME" type="VARCHAR" length="100"/>
+	</db-entity>
+	<db-entity name="GENERATED_F1">
+		<db-attribute name="ID" type="INTEGER" isPrimaryKey="true" isMandatory="true"/>
+	</db-entity>
+	<db-entity name="GENERATED_F2">
+		<db-attribute name="ID" type="INTEGER" isPrimaryKey="true" isMandatory="true"/>
+	</db-entity>
+	<db-entity name="GENERATED_JOIN">
+		<db-attribute name="ID" type="INTEGER" isPrimaryKey="true" isGenerated="true" isMandatory="true"/>
+		<db-attribute name="ID1" type="INTEGER"/>
+		<db-attribute name="ID2" type="INTEGER"/>
+	</db-entity>
+	<db-entity name="LONG_ENTITY">
+		<db-attribute name="ID" type="INTEGER" isPrimaryKey="true" isMandatory="true"/>
+		<db-attribute name="LONG_FIELD" type="BIGINT"/>
+	</db-entity>
+	<db-entity name="MEANINGFUL_PK_DEP">
+		<db-attribute name="DESCR" type="VARCHAR" length="50"/>
+		<db-attribute name="MASTER_PK" type="INTEGER"/>
+		<db-attribute name="PK_ATTRIBUTE" type="INTEGER" isPrimaryKey="true" isMandatory="true"/>
+	</db-entity>
+	<db-entity name="MEANINGFUL_PK_TEST1">
+		<db-attribute name="DESCR" type="VARCHAR" length="50"/>
+		<db-attribute name="PK_ATTRIBUTE" type="INTEGER" isPrimaryKey="true" isMandatory="true"/>
+	</db-entity>
+	<db-entity name="MIXED_PERSISTENCE_STRATEGY">
+		<db-attribute name="DESCRIPTION" type="VARCHAR" length="200"/>
+		<db-attribute name="ID" type="INTEGER" isPrimaryKey="true" isMandatory="true"/>
+		<db-attribute name="NAME" type="VARCHAR" length="200"/>
+	</db-entity>
+	<db-entity name="MIXED_PERSISTENCE_STRATEGY2">
+		<db-attribute name="ID" type="INTEGER" isPrimaryKey="true" isMandatory="true"/>
+		<db-attribute name="MASTER_ID" type="INTEGER"/>
+		<db-attribute name="NAME" type="VARCHAR" length="200"/>
+	</db-entity>
+	<db-entity name="NO_PK_TEST">
+		<db-attribute name="ATTRIBUTE1" type="INTEGER"/>
+	</db-entity>
+	<db-entity name="PAINTING">
+		<db-attribute name="ARTIST_ID" type="BIGINT"/>
+		<db-attribute name="ESTIMATED_PRICE" type="DECIMAL" length="10" scale="2"/>
+		<db-attribute name="GALLERY_ID" type="INTEGER"/>
+		<db-attribute name="PAINTING_DESCRIPTION" type="VARCHAR" length="255"/>
+		<db-attribute name="PAINTING_ID" type="INTEGER" isPrimaryKey="true" isMandatory="true"/>
+		<db-attribute name="PAINTING_TITLE" type="VARCHAR" isMandatory="true" length="255"/>
+	</db-entity>
+	<db-entity name="PAINTING1">
+		<db-attribute name="ARTIST_ID" type="BIGINT"/>
+		<db-attribute name="ESTIMATED_PRICE" type="DECIMAL" length="10" scale="2"/>
+		<db-attribute name="GALLERY_ID" type="INTEGER"/>
+		<db-attribute name="PAINTING_ID" type="INTEGER" isPrimaryKey="true" isMandatory="true"/>
+		<db-attribute name="PAINTING_TITLE" type="VARCHAR" isMandatory="true" length="255"/>
+	</db-entity>
+	<db-entity name="PAINTING_INFO">
+		<db-attribute name="IMAGE_BLOB" type="LONGVARBINARY"/>
+		<db-attribute name="PAINTING_ID" type="INTEGER" isPrimaryKey="true" isMandatory="true"/>
+		<db-attribute name="TEXT_REVIEW" type="LONGVARCHAR"/>
+	</db-entity>
+	<db-entity name="PRIMITIVES_TEST">
+		<db-attribute name="BOOLEAN_COLUMN" type="BOOLEAN"/>
+		<db-attribute name="ID" type="INTEGER" isPrimaryKey="true" isMandatory="true"/>
+		<db-attribute name="INT_COLUMN" type="INTEGER"/>
+	</db-entity>
+	<db-entity name="SERIALIZABLE_ENTITY">
+		<db-attribute name="ID" type="INTEGER" isPrimaryKey="true" isMandatory="true"/>
+		<db-attribute name="SERIALIZABLE_FIELD" type="BLOB"/>
+	</db-entity>
+	<db-entity name="SMALLINT_TEST">
+		<db-attribute name="ID" type="INTEGER" isPrimaryKey="true" isMandatory="true"/>
+		<db-attribute name="SMALLINT_COL" type="SMALLINT"/>
+	</db-entity>
+	<db-entity name="TINYINT_TEST">
+		<db-attribute name="ID" type="INTEGER" isPrimaryKey="true" isMandatory="true"/>
+		<db-attribute name="TINYINT_COL" type="TINYINT"/>
+	</db-entity>
+	<db-entity name="TYPES_MAPPING_TEST1">
+		<db-attribute name="AAAID" type="INTEGER" isPrimaryKey="true" isMandatory="true"/>
+		<db-attribute name="BIGINT_COLUMN" type="BIGINT"/>
+		<db-attribute name="BIT_COLUMN" type="BIT"/>
+		<db-attribute name="BOOLEAN_COLUMN" type="BOOLEAN"/>
+		<db-attribute name="CHAR_COLUMN" type="CHAR" length="254"/>
+		<db-attribute name="CLOB_COLUMN" type="CLOB"/>
+		<db-attribute name="DATE_COLUMN" type="DATE"/>
+		<db-attribute name="DECIMAL_COLUMN" type="DECIMAL" length="12" scale="5"/>
+		<db-attribute name="DOUBLE_COLUMN" type="DOUBLE" scale="7"/>
+		<db-attribute name="FLOAT_COLUMN" type="FLOAT" scale="3"/>
+		<db-attribute name="INTEGER_COLUMN" type="INTEGER"/>
+		<db-attribute name="LONGVARCHAR_COLUMN" type="LONGVARCHAR"/>
+		<db-attribute name="NUMERIC_COLUMN" type="NUMERIC" length="12" scale="5"/>
+		<db-attribute name="REAL_COLUMN" type="REAL" scale="5"/>
+		<db-attribute name="SMALLINT_COLUMN" type="SMALLINT"/>
+		<db-attribute name="TIMESTAMP_COLUMN" type="TIMESTAMP"/>
+		<db-attribute name="TIME_COLUMN" type="TIME"/>
+		<db-attribute name="TINYINT_COLUMN" type="TINYINT"/>
+		<db-attribute name="VARCHAR_COLUMN" type="VARCHAR" length="255"/>
+	</db-entity>
+	<db-entity name="TYPES_MAPPING_TEST2">
+		<db-attribute name="AAAID" type="INTEGER" isPrimaryKey="true" isMandatory="true"/>
+		<db-attribute name="BINARY_COLUMN" type="BINARY" length="14"/>
+		<db-attribute name="BLOB_COLUMN" type="BLOB"/>
+		<db-attribute name="LONGVARBINARY_COLUMN" type="LONGVARBINARY"/>
+		<db-attribute name="VARBINARY_COLUMN" type="VARBINARY" length="1000"/>
+	</db-entity>
+	<db-entity name="UUID_TEST">
+		<db-attribute name="ID" type="INTEGER" isPrimaryKey="true" isMandatory="true"/>
+		<db-attribute name="UUID" type="VARCHAR" length="100"/>
+	</db-entity>
+	<obj-entity name="ArraysEntity" className="org.apache.cayenne.testdo.misc_types.ArraysEntity" dbEntityName="ARRAYS_ENTITY">
+		<obj-attribute name="byteArray" type="byte[]" db-attribute-path="BYTE_ARRAY"/>
+		<obj-attribute name="byteWrapperArray" type="java.lang.Byte[]" db-attribute-path="BYTE_WRAPPER_ARRAY"/>
+		<obj-attribute name="charArray" type="char[]" db-attribute-path="CHAR_ARRAY"/>
+		<obj-attribute name="charWrapperArray" type="java.lang.Character[]" db-attribute-path="CHAR_WRAPPER_ARRAY"/>
+	</obj-entity>
+	<obj-entity name="ArtGroup" className="org.apache.cayenne.testdo.testmap.ArtGroup" dbEntityName="ARTGROUP">
+		<obj-attribute name="name" type="java.lang.String" db-attribute-path="NAME"/>
+	</obj-entity>
+	<obj-entity name="Artist" className="org.apache.cayenne.testdo.testmap.Artist" dbEntityName="ARTIST">
+		<obj-attribute name="artistName" type="java.lang.String" db-attribute-path="ARTIST_NAME"/>
+		<obj-attribute name="dateOfBirth" type="java.util.Date" db-attribute-path="DATE_OF_BIRTH"/>
+	</obj-entity>
+	<obj-entity name="ArtistCallbackTest" className="org.apache.cayenne.testdo.testmap.ArtistCallbackTest" dbEntityName="ARTIST_CT" exclude-superclass-listeners="true" exclude-default-listeners="true">
+		<obj-attribute name="artistName" type="java.lang.String"/>
+		<obj-attribute name="dateOfBirth" type="java.util.Date"/>
+		<entity-listener class="org.apache.cayenne.testdo.testmap.EntityListenerObjEntity">
+			<post-add method-name="prePersistEntityListener"/>
+			<post-persist method-name="postPersistEntityListener"/>
+			<pre-update method-name="preUpdateEntityListener"/>
+			<post-update method-name="postUpdateEntityListener"/>
+			<pre-remove method-name="preRemoveEntityListener"/>
+			<post-remove method-name="postRemoveEntityListener"/>
+			<post-load method-name="postLoadEntityListener"/>
+		</entity-listener>
+		<post-add method-name="prePersistEntityObjEntity"/>
+		<post-persist method-name="postPersistEntityObjEntity"/>
+		<pre-update method-name="preUpdateEntityObjEntity"/>
+		<post-update method-name="postUpdateEntityObjEntity"/>
+		<pre-remove method-name="preRemoveEntityObjEntity"/>
+		<post-remove method-name="postRemoveEntityObjEntity"/>
+		<post-load method-name="postLoadEntityObjEntity"/>
+	</obj-entity>
+	<obj-entity name="ArtistExhibit" className="org.apache.cayenne.testdo.testmap.ArtistExhibit" dbEntityName="ARTIST_EXHIBIT">
+	</obj-entity>
+	<obj-entity name="BigDecimalEntity" className="org.apache.cayenne.testdo.numeric_types.BigDecimalEntity" dbEntityName="BIGDECIMAL_ENTITY">
+		<obj-attribute name="bigDecimalField" type="java.math.BigDecimal" db-attribute-path="BIGDECIMAL_FIELD"/>
+	</obj-entity>
+	<obj-entity name="BigIntegerEntity" className="org.apache.cayenne.testdo.numeric_types.BigIntegerEntity" dbEntityName="BIGINTEGER_ENTITY">
+		<obj-attribute name="bigIntegerField" type="java.math.BigInteger" db-attribute-path="BIG_INTEGER_FIELD"/>
+	</obj-entity>
+	<obj-entity name="BinaryPKTest1" className="org.apache.cayenne.testdo.binary_pk.BinaryPKTest1" dbEntityName="BINARY_PK_TEST1">
+		<obj-attribute name="name" type="java.lang.String" db-attribute-path="NAME"/>
+	</obj-entity>
+	<obj-entity name="BinaryPKTest2" className="org.apache.cayenne.testdo.binary_pk.BinaryPKTest2" dbEntityName="BINARY_PK_TEST2">
+		<obj-attribute name="detailName" type="java.lang.String" db-attribute-path="DETAIL_NAME"/>
+	</obj-entity>
+	<obj-entity name="BitNumberTestEntity" className="org.apache.cayenne.testdo.numeric_types.BitNumberTestEntity" dbEntityName="BIT_TEST">
+		<obj-attribute name="bitColumn" type="java.lang.Integer" db-attribute-path="BIT_COLUMN"/>
+	</obj-entity>
+	<obj-entity name="BitTestEntity" className="org.apache.cayenne.testdo.numeric_types.BitTestEntity" dbEntityName="BIT_TEST">
+		<obj-attribute name="bitColumn" type="java.lang.Boolean" db-attribute-path="BIT_COLUMN"/>
+	</obj-entity>
+	<obj-entity name="BlobTestEntity" className="org.apache.cayenne.testdo.lob.BlobTestEntity" dbEntityName="BLOB_TEST">
+		<obj-attribute name="blobCol" type="byte[]" db-attribute-path="BLOB_COL"/>
+	</obj-entity>
+	<obj-entity name="BooleanTestEntity" className="org.apache.cayenne.testdo.numeric_types.BooleanTestEntity" dbEntityName="BOOLEAN_TEST">
+		<obj-attribute name="booleanColumn" type="java.lang.Boolean" db-attribute-path="BOOLEAN_COLUMN"/>
+	</obj-entity>
+	<obj-entity name="CalendarEntity" className="org.apache.cayenne.testdo.date_time.CalendarEntity" dbEntityName="CALENDAR_TEST">
+		<obj-attribute name="calendarField" type="java.util.Calendar" db-attribute-path="CALENDAR_FIELD"/>
+	</obj-entity>
+	<obj-entity name="CharFkTestEntity" className="org.apache.cayenne.testdo.compound.CharFkTestEntity" dbEntityName="CHAR_FK_TEST">
+		<obj-attribute name="name" type="java.lang.String" db-attribute-path="NAME"/>
+	</obj-entity>
+	<obj-entity name="CharPkTestEntity" className="org.apache.cayenne.testdo.compound.CharPkTestEntity" dbEntityName="CHAR_PK_TEST">
+		<obj-attribute name="otherCol" type="java.lang.String" db-attribute-path="OTHER_COL"/>
+		<obj-attribute name="pkCol" type="java.lang.String" db-attribute-path="PK_COL"/>
+	</obj-entity>
+	<obj-entity name="CharacterEntity" className="org.apache.cayenne.testdo.misc_types.CharacterEntity" dbEntityName="CHARACTER_ENTITY">
+		<obj-attribute name="characterField" type="java.lang.Character" db-attribute-path="CHARACTER_FIELD"/>
+	</obj-entity>
+	<obj-entity name="ClobTestEntity" className="org.apache.cayenne.testdo.lob.ClobTestEntity" dbEntityName="CLOB_TEST">
+		<obj-attribute name="clobCol" type="java.lang.String" db-attribute-path="CLOB_COL"/>
+	</obj-entity>
+	<obj-entity name="ClobTestRelation" className="org.apache.cayenne.testdo.lob.ClobTestRelation" dbEntityName="CLOB_TEST_RELATION">
+		<obj-attribute name="id" type="java.lang.Integer" db-attribute-path="ID"/>
+		<obj-attribute name="value" type="java.lang.Integer" db-attribute-path="VALUE"/>
+	</obj-entity>
+	<obj-entity name="CompoundFkTestEntity" className="org.apache.cayenne.testdo.compound.CompoundFkTestEntity" dbEntityName="COMPOUND_FK_TEST">
+		<obj-attribute name="name" type="java.lang.String" db-attribute-path="NAME"/>
+	</obj-entity>
+	<obj-entity name="CompoundPainting" className="org.apache.cayenne.testdo.testmap.CompoundPainting" dbEntityName="PAINTING">
+		<obj-attribute name="artistName" type="java.lang.String" db-attribute-path="toArtist.ARTIST_NAME"/>
+		<obj-attribute name="estimatedPrice" type="java.math.BigDecimal" db-attribute-path="ESTIMATED_PRICE"/>
+		<obj-attribute name="galleryName" type="java.lang.String" db-attribute-path="toGallery.GALLERY_NAME"/>
+		<obj-attribute name="paintingTitle" type="java.lang.String" db-attribute-path="PAINTING_TITLE"/>
+		<obj-attribute name="textReview" type="java.lang.String" db-attribute-path="toPaintingInfo.TEXT_REVIEW"/>
+	</obj-entity>
+	<obj-entity name="CompoundPkTestEntity" className="org.apache.cayenne.testdo.compound.CompoundPkTestEntity" dbEntityName="COMPOUND_PK_TEST">
+		<obj-attribute name="key1" type="java.lang.String" db-attribute-path="KEY1"/>
+		<obj-attribute name="key2" type="java.lang.String" db-attribute-path="KEY2"/>
+		<obj-attribute name="name" type="java.lang.String" db-attribute-path="NAME"/>
+	</obj-entity>
+	<obj-entity name="DateTestEntity" className="org.apache.cayenne.testdo.date_time.DateTestEntity" dbEntityName="DATE_TEST">
+		<obj-attribute name="dateColumn" type="java.util.Date" db-attribute-path="DATE_COLUMN"/>
+		<obj-attribute name="timeColumn" type="java.util.Date" db-attribute-path="TIME_COLUMN"/>
+		<obj-attribute name="timestampColumn" type="java.util.Date" db-attribute-path="TIMESTAMP_COLUMN"/>
+	</obj-entity>
+	<obj-entity name="DecimalPKTest1" className="org.apache.cayenne.testdo.numeric_types.DecimalPKTest1" dbEntityName="DECIMAL_PK_TST">
+		<obj-attribute name="decimalPK" type="java.lang.Double" db-attribute-path="DECIMAL_PK"/>
+		<obj-attribute name="name" type="java.lang.String" db-attribute-path="NAME"/>
+	</obj-entity>
+	<obj-entity name="DecimalPKTestEntity" className="org.apache.cayenne.testdo.numeric_types.DecimalPKTestEntity" dbEntityName="DECIMAL_PK_TST">
+		<obj-attribute name="decimalPK" type="java.math.BigDecimal" db-attribute-path="DECIMAL_PK"/>
+		<obj-attribute name="name" type="java.lang.String" db-attribute-path="NAME"/>
+	</obj-entity>
+	<obj-entity name="EnumEntity" className="org.apache.cayenne.testdo.enum_test.EnumEntity" dbEntityName="ENUM_ENTITY">
+		<obj-attribute name="enumAttribute" type="org.apache.cayenne.testdo.enum_test.Enum1" db-attribute-path="ENUM_ATTRIBUTE"/>
+	</obj-entity>
+	<obj-entity name="Exhibit" className="org.apache.cayenne.testdo.testmap.Exhibit" dbEntityName="EXHIBIT">
+		<obj-attribute name="closingDate" type="java.util.Date" db-attribute-path="CLOSING_DATE"/>
+		<obj-attribute name="openingDate" type="java.util.Date" db-attribute-path="OPENING_DATE"/>
+	</obj-entity>
+	<obj-entity name="ExtendedTypeEntity" className="org.apache.cayenne.testdo.extended_type.ExtendedTypeEntity" dbEntityName="EXTENDED_TYPE_TEST">
+		<obj-attribute name="name" type="org.apache.cayenne.testdo.extended_type.StringET1" db-attribute-path="NAME"/>
+	</obj-entity>
+	<obj-entity name="Gallery" className="org.apache.cayenne.testdo.testmap.Gallery" dbEntityName="GALLERY">
+		<obj-attribute name="galleryName" type="java.lang.String" db-attribute-path="GALLERY_NAME"/>
+	</obj-entity>
+	<obj-entity name="GeneratedColumnCompKey" className="org.apache.cayenne.testdo.generated.GeneratedColumnCompKey" dbEntityName="GENERATED_COLUMN_COMP_KEY">
+		<obj-attribute name="name" type="java.lang.String" db-attribute-path="NAME"/>
+	</obj-entity>
+	<obj-entity name="GeneratedColumnCompMaster" className="org.apache.cayenne.testdo.generated.GeneratedColumnCompMaster" dbEntityName="GENERATED_COLUMN_COMP_M">
+		<obj-attribute name="name" type="java.lang.String" db-attribute-path="NAME"/>
+	</obj-entity>
+	<obj-entity name="GeneratedColumnDep" className="org.apache.cayenne.testdo.generated.GeneratedColumnDep" dbEntityName="GENERATED_COLUMN_DEP">
+		<obj-attribute name="name" type="java.lang.String" db-attribute-path="NAME"/>
+	</obj-entity>
+	<obj-entity name="GeneratedColumnTest2" className="org.apache.cayenne.testdo.generated.GeneratedColumnTest2" dbEntityName="GENERATED_COLUMN_TEST2">
+		<obj-attribute name="name" type="java.lang.String" db-attribute-path="NAME"/>
+	</obj-entity>
+	<obj-entity name="GeneratedColumnTestEntity" className="org.apache.cayenne.testdo.generated.GeneratedColumnTestEntity" dbEntityName="GENERATED_COLUMN_TEST">
+		<obj-attribute name="name" type="java.lang.String" db-attribute-path="NAME"/>
+	</obj-entity>
+	<obj-entity name="GeneratedF1" className="org.apache.cayenne.testdo.generated.GeneratedF1" clientClassName="test.client.GeneratedF1" dbEntityName="GENERATED_F1" superClassName="org.apache.cayenne.CayenneDataObject" clientSuperClassName="org.apache.cayenne.PersistentObject">
+	</obj-entity>
+	<obj-entity name="GeneratedF2" className="org.apache.cayenne.testdo.generated.GeneratedF2" clientClassName="test.client.GeneratedF2" dbEntityName="GENERATED_F2" superClassName="org.apache.cayenne.CayenneDataObject" clientSuperClassName="org.apache.cayenne.PersistentObject">
+	</obj-entity>
+	<obj-entity name="LongEntity" className="org.apache.cayenne.testdo.numeric_types.LongEntity" dbEntityName="LONG_ENTITY">
+		<obj-attribute name="longField" type="java.lang.Long" db-attribute-path="LONG_FIELD"/>
+	</obj-entity>
+	<obj-entity name="MeaningfulGeneratedColumnTestEntity" className="org.apache.cayenne.testdo.testmap.MeaningfulGeneratedColumnTestEntity" dbEntityName="GENERATED_COLUMN_TEST">
+		<obj-attribute name="generatedColumn" type="java.lang.Integer" db-attribute-path="GENERATED_COLUMN"/>
+		<obj-attribute name="name" type="java.lang.String" db-attribute-path="NAME"/>
+	</obj-entity>
+	<obj-entity name="MeaningfulPKDep" className="org.apache.cayenne.testdo.meaningful_pk.MeaningfulPKDep" dbEntityName="MEANINGFUL_PK_DEP">
+		<obj-attribute name="descr" type="java.lang.String" db-attribute-path="DESCR"/>
+	</obj-entity>
+	<obj-entity name="MeaningfulPKTest1" className="org.apache.cayenne.testdo.meaningful_pk.MeaningfulPKTest1" dbEntityName="MEANINGFUL_PK_TEST1">
+		<obj-attribute name="descr" type="java.lang.String" db-attribute-path="DESCR"/>
+		<obj-attribute name="pkAttribute" type="java.lang.Integer" db-attribute-path="PK_ATTRIBUTE"/>
+	</obj-entity>
+	<obj-entity name="MixedPersistenceStrategy" className="org.apache.cayenne.testdo.mixed_persistence_strategy.MixedPersistenceStrategy" dbEntityName="MIXED_PERSISTENCE_STRATEGY">
+		<obj-attribute name="description" type="java.lang.String" db-attribute-path="DESCRIPTION"/>
+		<obj-attribute name="name" type="java.lang.String" db-attribute-path="NAME"/>
+	</obj-entity>
+	<obj-entity name="MixedPersistenceStrategy2" className="org.apache.cayenne.testdo.mixed_persistence_strategy.MixedPersistenceStrategy2" dbEntityName="MIXED_PERSISTENCE_STRATEGY2">
+		<obj-attribute name="name" type="java.lang.String" db-attribute-path="NAME"/>
+	</obj-entity>
+	<obj-entity name="NoPkTestEntity" className="org.apache.cayenne.testdo.no_pk.NoPkTestEntity" dbEntityName="NO_PK_TEST">
+		<obj-attribute name="attribute1" type="java.lang.Integer" db-attribute-path="ATTRIBUTE1"/>
+	</obj-entity>
+	<obj-entity name="Painting" className="org.apache.cayenne.testdo.testmap.Painting" dbEntityName="PAINTING" superClassName="org.apache.cayenne.testdo.testmap.ArtDataObject">
+		<obj-attribute name="estimatedPrice" type="java.math.BigDecimal" db-attribute-path="ESTIMATED_PRICE"/>
+		<obj-attribute name="paintingDescription" type="java.lang.String" db-attribute-path="PAINTING_DESCRIPTION"/>
+		<obj-attribute name="paintingTitle" type="java.lang.String" db-attribute-path="PAINTING_TITLE"/>
+	</obj-entity>
+	<obj-entity name="Painting1" className="org.apache.cayenne.testdo.testmap.Painting1" dbEntityName="PAINTING1">
+		<obj-attribute name="estimatedPrice" type="java.math.BigDecimal" db-attribute-path="ESTIMATED_PRICE"/>
+		<obj-attribute name="paintingTitle" type="java.lang.String" db-attribute-path="PAINTING_TITLE"/>
+	</obj-entity>
+	<obj-entity name="PaintingInfo" className="org.apache.cayenne.testdo.testmap.PaintingInfo" dbEntityName="PAINTING_INFO">
+		<obj-attribute name="imageBlob" type="byte[]" db-attribute-path="IMAGE_BLOB"/>
+		<obj-attribute name="textReview" type="java.lang.String" db-attribute-path="TEXT_REVIEW"/>
+	</obj-entity>
+	<obj-entity name="PrimitivesTestEntity" className="org.apache.cayenne.testdo.primitive.PrimitivesTestEntity" dbEntityName="PRIMITIVES_TEST">
+		<obj-attribute name="booleanColumn" type="boolean" db-attribute-path="BOOLEAN_COLUMN"/>
+		<obj-attribute name="intColumn" type="int" db-attribute-path="INT_COLUMN"/>
+	</obj-entity>
+	<obj-entity name="ROArtist" className="org.apache.cayenne.testdo.testmap.ROArtist" readOnly="true" dbEntityName="ARTIST">
+		<obj-attribute name="artistName" type="java.lang.String" db-attribute-path="ARTIST_NAME"/>
+		<obj-attribute name="dateOfBirth" type="java.sql.Date" db-attribute-path="DATE_OF_BIRTH"/>
+	</obj-entity>
+	<obj-entity name="ROPainting" className="org.apache.cayenne.testdo.testmap.ROPainting" readOnly="true" dbEntityName="PAINTING">
+		<obj-attribute name="estimatedPrice" type="java.math.BigDecimal" db-attribute-path="ESTIMATED_PRICE"/>
+		<obj-attribute name="paintingTitle" type="java.lang.String" db-attribute-path="PAINTING_TITLE"/>
+	</obj-entity>
+	<obj-entity name="RWCompoundPainting" className="org.apache.cayenne.testdo.testmap.RWCompoundPainting" dbEntityName="PAINTING">
+		<obj-attribute name="estimatedPrice" type="java.math.BigDecimal" db-attribute-path="ESTIMATED_PRICE"/>
+		<obj-attribute name="paintingTitle" type="java.lang.String" db-attribute-path="PAINTING_TITLE"/>
+		<obj-attribute name="textReview" type="java.lang.String" db-attribute-path="toPaintingInfo.TEXT_REVIEW"/>
+	</obj-entity>
+	<obj-entity name="ReturnTypesMap1" className="org.apache.cayenne.testdo.return_types.ReturnTypesMap1" clientClassName="test.client.ReturnTypesMap1" dbEntityName="TYPES_MAPPING_TEST1" superClassName="org.apache.cayenne.CayenneDataObject" clientSuperClassName="org.apache.cayenne.PersistentObject">
+		<obj-attribute name="bigintColumn" type="java.lang.Long" db-attribute-path="BIGINT_COLUMN"/>
+		<obj-attribute name="bitColumn" type="java.lang.Boolean" db-attribute-path="BIT_COLUMN"/>
+		<obj-attribute name="booleanColumn" type="java.lang.Boolean" db-attribute-path="BOOLEAN_COLUMN"/>
+		<obj-attribute name="charColumn" type="java.lang.String" db-attribute-path="CHAR_COLUMN"/>
+		<obj-attribute name="clobColumn" type="java.lang.String" db-attribute-path="CLOB_COLUMN"/>
+		<obj-attribute name="dateColumn" type="java.util.Date" db-attribute-path="DATE_COLUMN"/>
+		<obj-attribute name="decimalColumn" type="java.math.BigDecimal" db-attribute-path="DECIMAL_COLUMN"/>
+		<obj-attribute name="doubleColumn" type="java.lang.Double" db-attribute-path="DOUBLE_COLUMN"/>
+		<obj-attribute name="floatColumn" type="java.lang.Float" db-attribute-path="FLOAT_COLUMN"/>
+		<obj-attribute name="integerColumn" type="java.lang.Integer" db-attribute-path="INTEGER_COLUMN"/>
+		<obj-attribute name="longvarcharColumn" type="java.lang.String" db-attribute-path="LONGVARCHAR_COLUMN"/>
+		<obj-attribute name="numericColumn" type="java.math.BigDecimal" db-attribute-path="NUMERIC_COLUMN"/>
+		<obj-attribute name="realColumn" type="java.lang.Float" db-attribute-path="REAL_COLUMN"/>
+		<obj-attribute name="smallintColumn" type="java.lang.Short" db-attribute-path="SMALLINT_COLUMN"/>
+		<obj-attribute name="timeColumn" type="java.util.Date" db-attribute-path="TIME_COLUMN"/>
+		<obj-attribute name="timestampColumn" type="java.util.Date" db-attribute-path="TIMESTAMP_COLUMN"/>
+		<obj-attribute name="tinyintColumn" type="java.lang.Byte" db-attribute-path="TINYINT_COLUMN"/>
+		<obj-attribute name="varcharColumn" type="java.lang.String" db-attribute-path="VARCHAR_COLUMN"/>
+	</obj-entity>
+	<obj-entity name="ReturnTypesMap2" className="org.apache.cayenne.testdo.return_types.ReturnTypesMap2" clientClassName="test.client.ReturnTypesMap2" dbEntityName="TYPES_MAPPING_TEST2" superClassName="org.apache.cayenne.CayenneDataObject" clientSuperClassName="org.apache.cayenne.PersistentObject">
+		<obj-attribute name="binaryColumn" type="byte[]" db-attribute-path="BINARY_COLUMN"/>
+		<obj-attribute name="blobColumn" type="byte[]" db-attribute-path="BLOB_COLUMN"/>
+		<obj-attribute name="longvarbinaryColumn" type="byte[]" db-attribute-path="LONGVARBINARY_COLUMN"/>
+		<obj-attribute name="varbinaryColumn" type="byte[]" db-attribute-path="VARBINARY_COLUMN"/>
+	</obj-entity>
+	<obj-entity name="SerializableEntity" className="org.apache.cayenne.testdo.misc_types.SerializableEntity" dbEntityName="SERIALIZABLE_ENTITY">
+		<obj-attribute name="serializableField" type="org.apache.cayenne.MockSerializable" db-attribute-path="SERIALIZABLE_FIELD"/>
+	</obj-entity>
+	<obj-entity name="SmallintTestEntity" className="org.apache.cayenne.testdo.numeric_types.SmallintTestEntity" dbEntityName="SMALLINT_TEST">
+		<obj-attribute name="smallintCol" type="java.lang.Short" db-attribute-path="SMALLINT_COL"/>
+	</obj-entity>
+	<obj-entity name="SubPainting" className="org.apache.cayenne.testdo.testmap.SubPainting" dbEntityName="PAINTING">
+		<obj-attribute name="paintingTitle" type="java.lang.String" db-attribute-path="PAINTING_TITLE"/>
+	</obj-entity>
+	<obj-entity name="TinyintTestEntity" className="org.apache.cayenne.testdo.numeric_types.TinyintTestEntity" dbEntityName="TINYINT_TEST">
+		<obj-attribute name="tinyintCol" type="java.lang.Byte" db-attribute-path="TINYINT_COL"/>
+	</obj-entity>
+	<obj-entity name="UuidTestEntity" className="org.apache.cayenne.testdo.uuid.UuidTestEntity" dbEntityName="UUID_TEST">
+		<obj-attribute name="uuid" type="java.util.UUID" db-attribute-path="UUID"/>
+	</obj-entity>
+	<db-relationship name="artistGroupArray" source="ARTGROUP" target="ARTIST_GROUP" toMany="true">
+		<db-attribute-pair source="GROUP_ID" target="GROUP_ID"/>
+	</db-relationship>
+	<db-relationship name="toChildGroups" source="ARTGROUP" target="ARTGROUP" toMany="true">
+		<db-attribute-pair source="GROUP_ID" target="PARENT_GROUP_ID"/>
+	</db-relationship>
+	<db-relationship name="toParentGroup" source="ARTGROUP" target="ARTGROUP" toMany="false">
+		<db-attribute-pair source="PARENT_GROUP_ID" target="GROUP_ID"/>
+	</db-relationship>
+	<db-relationship name="artistExhibitArray" source="ARTIST" target="ARTIST_EXHIBIT" toDependentPK="true" toMany="true">
+		<db-attribute-pair source="ARTIST_ID" target="ARTIST_ID"/>
+	</db-relationship>
+	<db-relationship name="artistGroupArray" source="ARTIST" target="ARTIST_GROUP" toMany="true">
+		<db-attribute-pair source="ARTIST_ID" target="ARTIST_ID"/>
+	</db-relationship>
+	<db-relationship name="paintingArray" source="ARTIST" target="PAINTING" toMany="true">
+		<db-attribute-pair source="ARTIST_ID" target="ARTIST_ID"/>
+	</db-relationship>
+	<db-relationship name="toArtist" source="ARTIST_EXHIBIT" target="ARTIST" toMany="false">
+		<db-attribute-pair source="ARTIST_ID" target="ARTIST_ID"/>
+	</db-relationship>
+	<db-relationship name="toExhibit" source="ARTIST_EXHIBIT" target="EXHIBIT" toMany="false">
+		<db-attribute-pair source="EXHIBIT_ID" target="EXHIBIT_ID"/>
+	</db-relationship>
+	<db-relationship name="toArtist" source="ARTIST_GROUP" target="ARTIST" toMany="false">
+		<db-attribute-pair source="ARTIST_ID" target="ARTIST_ID"/>
+	</db-relationship>
+	<db-relationship name="toGroup" source="ARTIST_GROUP" target="ARTGROUP" toMany="false">
+		<db-attribute-pair source="GROUP_ID" target="GROUP_ID"/>
+	</db-relationship>
+	<db-relationship name="binaryPKDetails" source="BINARY_PK_TEST1" target="BINARY_PK_TEST2" toMany="true">
+		<db-attribute-pair source="BIN_ID" target="FK_ID"/>
+	</db-relationship>
+	<db-relationship name="toBinaryPKMaster" source="BINARY_PK_TEST2" target="BINARY_PK_TEST1" toMany="false">
+		<db-attribute-pair source="FK_ID" target="BIN_ID"/>
+	</db-relationship>
+	<db-relationship name="toCharPK" source="CHAR_FK_TEST" target="CHAR_PK_TEST" toMany="false">
+		<db-attribute-pair source="FK_COL" target="PK_COL"/>
+	</db-relationship>
+	<db-relationship name="charFKs" source="CHAR_PK_TEST" target="CHAR_FK_TEST" toMany="true">
+		<db-attribute-pair source="PK_COL" target="FK_COL"/>
+	</db-relationship>
+	<db-relationship name="clob" source="CLOB_TEST" target="CLOB_TEST_RELATION" toMany="true">
+		<db-attribute-pair source="CLOB_TEST_ID" target="ID_CLOB"/>
+	</db-relationship>
+	<db-relationship name="CLOB_REL" source="CLOB_TEST_RELATION" target="CLOB_TEST" toMany="false">
+		<db-attribute-pair source="ID_CLOB" target="CLOB_TEST_ID"/>
+	</db-relationship>
+	<db-relationship name="toCompoundPk" source="COMPOUND_FK_TEST" target="COMPOUND_PK_TEST" toMany="false">
+		<db-attribute-pair source="F_KEY1" target="KEY1"/>
+		<db-attribute-pair source="F_KEY2" target="KEY2"/>
+	</db-relationship>
+	<db-relationship name="compoundFkArray" source="COMPOUND_PK_TEST" target="COMPOUND_FK_TEST" toMany="true">
+		<db-attribute-pair source="KEY1" target="F_KEY1"/>
+		<db-attribute-pair source="KEY2" target="F_KEY2"/>
+	</db-relationship>
+	<db-relationship name="artistExhibitArray" source="EXHIBIT" target="ARTIST_EXHIBIT" toDependentPK="true" toMany="true">
+		<db-attribute-pair source="EXHIBIT_ID" target="EXHIBIT_ID"/>
+	</db-relationship>
+	<db-relationship name="toGallery" source="EXHIBIT" target="GALLERY" toMany="false">
+		<db-attribute-pair source="GALLERY_ID" target="GALLERY_ID"/>
+	</db-relationship>
+	<db-relationship name="exhibitArray" source="GALLERY" target="EXHIBIT" toMany="true">
+		<db-attribute-pair source="GALLERY_ID" target="GALLERY_ID"/>
+	</db-relationship>
+	<db-relationship name="paintingArray" source="GALLERY" target="PAINTING" toMany="true">
+		<db-attribute-pair source="GALLERY_ID" target="GALLERY_ID"/>
+	</db-relationship>
+	<db-relationship name="toMaster" source="GENERATED_COLUMN_COMP_KEY" target="GENERATED_COLUMN_COMP_M" toMany="false">
+		<db-attribute-pair source="PROPAGATED_PK" target="ID"/>
+	</db-relationship>
+	<db-relationship name="toDetail" source="GENERATED_COLUMN_COMP_M" target="GENERATED_COLUMN_COMP_KEY" toDependentPK="true" toMany="true">
+		<db-attribute-pair source="ID" target="PROPAGATED_PK"/>
+	</db-relationship>
+	<db-relationship name="toMaster" source="GENERATED_COLUMN_DEP" target="GENERATED_COLUMN_TEST" toMany="false">
+		<db-attribute-pair source="GENERATED_COLUMN_FK" target="GENERATED_COLUMN"/>
+	</db-relationship>
+	<db-relationship name="toDep" source="GENERATED_COLUMN_TEST" target="GENERATED_COLUMN_DEP" toDependentPK="true" toMany="false">
+		<db-attribute-pair source="GENERATED_COLUMN" target="GENERATED_COLUMN_FK"/>
+	</db-relationship>
+	<db-relationship name="join" source="GENERATED_F1" target="GENERATED_JOIN" toMany="true">
+		<db-attribute-pair source="ID" target="ID1"/>
+	</db-relationship>
+	<db-relationship name="join" source="GENERATED_F2" target="GENERATED_JOIN" toMany="true">
+		<db-attribute-pair source="ID" target="ID2"/>
+	</db-relationship>
+	<db-relationship name="f1" source="GENERATED_JOIN" target="GENERATED_F1" toMany="false">
+		<db-attribute-pair source="ID1" target="ID"/>
+	</db-relationship>
+	<db-relationship name="f2" source="GENERATED_JOIN" target="GENERATED_F2" toMany="false">
+		<db-attribute-pair source="ID2" target="ID"/>
+	</db-relationship>
+	<db-relationship name="toMeaningfulPK" source="MEANINGFUL_PK_DEP" target="MEANINGFUL_PK_TEST1" toMany="false">
+		<db-attribute-pair source="MASTER_PK" target="PK_ATTRIBUTE"/>
+	</db-relationship>
+	<db-relationship name="meaningfulPKDepArray" source="MEANINGFUL_PK_TEST1" target="MEANINGFUL_PK_DEP" toMany="true">
+		<db-attribute-pair source="PK_ATTRIBUTE" target="MASTER_PK"/>
+	</db-relationship>
+	<db-relationship name="details" source="MIXED_PERSISTENCE_STRATEGY" target="MIXED_PERSISTENCE_STRATEGY2" toMany="true">
+		<db-attribute-pair source="ID" target="MASTER_ID"/>
+	</db-relationship>
+	<db-relationship name="master" source="MIXED_PERSISTENCE_STRATEGY2" target="MIXED_PERSISTENCE_STRATEGY" toMany="false">
+		<db-attribute-pair source="MASTER_ID" target="ID"/>
+	</db-relationship>
+	<db-relationship name="toArtist" source="PAINTING" target="ARTIST" toMany="false">
+		<db-attribute-pair source="ARTIST_ID" target="ARTIST_ID"/>
+	</db-relationship>
+	<db-relationship name="toGallery" source="PAINTING" target="GALLERY" toMany="false">
+		<db-attribute-pair source="GALLERY_ID" target="GALLERY_ID"/>
+	</db-relationship>
+	<db-relationship name="toPaintingInfo" source="PAINTING" target="PAINTING_INFO" toDependentPK="true" toMany="false">
+		<db-attribute-pair source="PAINTING_ID" target="PAINTING_ID"/>
+	</db-relationship>
+	<db-relationship name="toArtist" source="PAINTING1" target="ARTIST" toMany="false">
+		<db-attribute-pair source="ARTIST_ID" target="ARTIST_ID"/>
+	</db-relationship>
+	<db-relationship name="painting" source="PAINTING_INFO" target="PAINTING" toMany="false">
+		<db-attribute-pair source="PAINTING_ID" target="PAINTING_ID"/>
+	</db-relationship>
+	<obj-relationship name="artistArray" source="ArtGroup" target="Artist" deleteRule="Nullify" db-relationship-path="artistGroupArray.toArtist"/>
+	<obj-relationship name="childGroupsArray" source="ArtGroup" target="ArtGroup" deleteRule="Nullify" db-relationship-path="toChildGroups"/>
+	<obj-relationship name="toParentGroup" source="ArtGroup" target="ArtGroup" deleteRule="Nullify" db-relationship-path="toParentGroup"/>
+	<obj-relationship name="artistExhibitArray" source="Artist" target="ArtistExhibit" deleteRule="Cascade" db-relationship-path="artistExhibitArray"/>
+	<obj-relationship name="groupArray" source="Artist" target="ArtGroup" deleteRule="Cascade" db-relationship-path="artistGroupArray.toGroup"/>
+	<obj-relationship name="paintingArray" source="Artist" target="Painting" deleteRule="Cascade" db-relationship-path="paintingArray"/>
+	<obj-relationship name="toArtist" source="ArtistExhibit" target="Artist" deleteRule="Nullify" db-relationship-path="toArtist"/>
+	<obj-relationship name="toExhibit" source="ArtistExhibit" target="Exhibit" deleteRule="Nullify" db-relationship-path="toExhibit"/>
+	<obj-relationship name="binaryPKDetails" source="BinaryPKTest1" target="BinaryPKTest2" db-relationship-path="binaryPKDetails"/>
+	<obj-relationship name="toBinaryPKMaster" source="BinaryPKTest2" target="BinaryPKTest1" db-relationship-path="toBinaryPKMaster"/>
+	<obj-relationship name="toCharPK" source="CharFkTestEntity" target="CharPkTestEntity" db-relationship-path="toCharPK"/>
+	<obj-relationship name="charFKs" source="CharPkTestEntity" target="CharFkTestEntity" db-relationship-path="charFKs"/>
+	<obj-relationship name="clobValue" source="ClobTestEntity" target="ClobTestRelation" db-relationship-path="clob"/>
+	<obj-relationship name="clobId" source="ClobTestRelation" target="ClobTestEntity" db-relationship-path="CLOB_REL"/>
+	<obj-relationship name="toCompoundPk" source="CompoundFkTestEntity" target="CompoundPkTestEntity" db-relationship-path="toCompoundPk"/>
+	<obj-relationship name="toArtist" source="CompoundPainting" target="Artist" deleteRule="Nullify" db-relationship-path="toArtist"/>
+	<obj-relationship name="toGallery" source="CompoundPainting" target="Gallery" deleteRule="Nullify" db-relationship-path="toGallery"/>
+	<obj-relationship name="toPaintingInfo" source="CompoundPainting" target="PaintingInfo" deleteRule="Cascade" db-relationship-path="toPaintingInfo"/>
+	<obj-relationship name="compoundFkArray" source="CompoundPkTestEntity" target="CompoundFkTestEntity" db-relationship-path="compoundFkArray"/>
+	<obj-relationship name="artistExhibitArray" source="Exhibit" target="ArtistExhibit" deleteRule="Cascade" db-relationship-path="artistExhibitArray"/>
+	<obj-relationship name="toGallery" source="Exhibit" target="Gallery" deleteRule="Nullify" db-relationship-path="toGallery"/>
+	<obj-relationship name="exhibitArray" source="Gallery" target="Exhibit" deleteRule="Cascade" db-relationship-path="exhibitArray"/>
+	<obj-relationship name="paintingArray" source="Gallery" target="Painting" deleteRule="Deny" db-relationship-path="paintingArray"/>
+	<obj-relationship name="toMaster" source="GeneratedColumnCompKey" target="GeneratedColumnCompMaster" db-relationship-path="toMaster"/>
+	<obj-relationship name="toDetail" source="GeneratedColumnCompMaster" target="GeneratedColumnCompKey" db-relationship-path="toDetail"/>
+	<obj-relationship name="toMaster" source="GeneratedColumnDep" target="GeneratedColumnTestEntity" db-relationship-path="toMaster"/>
+	<obj-relationship name="toDep" source="GeneratedColumnTestEntity" target="GeneratedColumnDep" db-relationship-path="toDep"/>
+	<obj-relationship name="f2" source="GeneratedF1" target="GeneratedF2" deleteRule="Nullify" db-relationship-path="join.f2"/>
+	<obj-relationship name="f1" source="GeneratedF2" target="GeneratedF1" deleteRule="Nullify" db-relationship-path="join.f1"/>
+	<obj-relationship name="toMeaningfulPK" source="MeaningfulPKDep" target="MeaningfulPKTest1" db-relationship-path="toMeaningfulPK"/>
+	<obj-relationship name="meaningfulPKDepArray" source="MeaningfulPKTest1" target="MeaningfulPKDep" db-relationship-path="meaningfulPKDepArray"/>
+	<obj-relationship name="details" source="MixedPersistenceStrategy" target="MixedPersistenceStrategy2" db-relationship-path="details"/>
+	<obj-relationship name="master" source="MixedPersistenceStrategy2" target="MixedPersistenceStrategy" db-relationship-path="master"/>
+	<obj-relationship name="toArtist" source="Painting" target="Artist" deleteRule="Nullify" db-relationship-path="toArtist"/>
+	<obj-relationship name="toGallery" source="Painting" target="Gallery" deleteRule="Nullify" db-relationship-path="toGallery"/>
+	<obj-relationship name="toPaintingInfo" source="Painting" target="PaintingInfo" deleteRule="Cascade" db-relationship-path="toPaintingInfo"/>
+	<obj-relationship name="toArtist" source="Painting1" target="Artist" deleteRule="Nullify" db-relationship-path="toArtist"/>
+	<obj-relationship name="painting" source="PaintingInfo" target="Painting" deleteRule="Nullify" db-relationship-path="painting"/>
+	<obj-relationship name="paintingArray" source="ROArtist" target="Painting" deleteRule="Deny" db-relationship-path="paintingArray"/>
+	<obj-relationship name="toArtist" source="ROPainting" target="Artist" deleteRule="Nullify" db-relationship-path="toArtist"/>
+	<query name="EjbqlQueryTest" type="EJBQLQuery">
+		<property name="cayenne.GenericSelectQuery.fetchingDataRows" value="true"/>
+		<property name="cayenne.GenericSelectQuery.cacheStrategy" value="SHARED_CACHE"/>
+		<ejbql><![CDATA[select a from Artist a]]></ejbql>
+	</query>
+	<query name="NonSelectingQuery" type="SQLTemplate" root="data-map" root-name="testmap">
+		<property name="cayenne.SQLTemplate.columnNameCapitalization" value="UPPER"/>
+		<sql><![CDATA[INSERT INTO PAINTING (PAINTING_ID, PAINTING_TITLE, ESTIMATED_PRICE)
+VALUES (512, 'No Painting Like This', 12.5)]]></sql>
+		<sql adapter-class="org.apache.cayenne.dba.db2.DB2Adapter"><![CDATA[INSERT INTO PAINTING (PAINTING_ID, PAINTING_TITLE, ESTIMATED_PRICE) VALUES (512, 'No Painting Like This', 12.5)]]></sql>
+	</query>
+	<query name="ObjectQuery" type="SelectQuery" root="obj-entity" root-name="Painting">
+		<qualifier><![CDATA[toArtist = $artist]]></qualifier>
+		<ordering><![CDATA[paintingTitle]]></ordering>
+	</query>
+	<query name="ParameterizedNonSelectingQuery" type="SQLTemplate" root="data-map" root-name="testmap">
+		<sql><![CDATA[INSERT INTO PAINTING (PAINTING_ID, PAINTING_TITLE, ESTIMATED_PRICE)
+VALUES (#bind($id), #bind($title), #bind($price))]]></sql>
+		<sql adapter-class="org.apache.cayenne.dba.db2.DB2Adapter"><![CDATA[INSERT INTO PAINTING (PAINTING_ID, PAINTING_TITLE, ESTIMATED_PRICE) values (#bind($id), #bind($title), #bind($price))]]></sql>
+	</query>
+	<query name="ParameterizedQueryWithLocalCache" type="SelectQuery" root="obj-entity" root-name="Artist">
+		<property name="cayenne.GenericSelectQuery.cacheStrategy" value="LOCAL_CACHE"/>
+		<qualifier><![CDATA[artistName like $name]]></qualifier>
+	</query>
+	<query name="ParameterizedQueryWithSharedCache" type="SelectQuery" root="obj-entity" root-name="Artist">
+		<property name="cayenne.GenericSelectQuery.cacheStrategy" value="SHARED_CACHE"/>
+		<qualifier><![CDATA[artistName like $name]]></qualifier>
+	</query>
+	<query name="ProcedureQuery" type="ProcedureQuery" root="procedure" root-name="cayenne_tst_select_proc" result-entity="Artist">
+	</query>
+	<query name="QueryWithLocalCache" type="SelectQuery" root="obj-entity" root-name="Artist">
+		<property name="cayenne.GenericSelectQuery.cacheStrategy" value="LOCAL_CACHE"/>
+	</query>
+	<query name="QueryWithOrdering" type="SelectQuery" root="obj-entity" root-name="Artist">
+		<ordering descending="true" ignore-case="true"><![CDATA[artistName]]></ordering>
+		<ordering><![CDATA[dateOfBirth]]></ordering>
+	</query>
+	<query name="QueryWithPrefetch" type="SelectQuery" root="obj-entity" root-name="Gallery">
+		<prefetch>paintingArray</prefetch>
+	</query>
+	<query name="QueryWithQualifier" type="SelectQuery" root="obj-entity" root-name="Artist">
+		<qualifier><![CDATA[artistName = $param1]]></qualifier>
+	</query>
+	<query name="QueryWithSharedCache" type="SelectQuery" root="obj-entity" root-name="Artist">
+		<property name="cayenne.GenericSelectQuery.cacheStrategy" value="SHARED_CACHE"/>
+	</query>
+	<query name="SelectDateTest" type="SQLTemplate" root="data-map" root-name="testmap">
+		<property name="cayenne.GenericSelectQuery.fetchingDataRows" value="true"/>
+		<property name="cayenne.SQLTemplate.columnNameCapitalization" value="UPPER"/>
+		<sql><![CDATA[SELECT * FROM DATE_TEST]]></sql>
+	</query>
+	<query name="SelectReturnTypesMap1" type="SQLTemplate" root="data-map" root-name="testmap">
+		<property name="cayenne.GenericSelectQuery.fetchingDataRows" value="true"/>
+		<property name="cayenne.SQLTemplate.columnNameCapitalization" value="UPPER"/>
+		<sql><![CDATA[SELECT * FROM TYPES_MAPPING_TEST1]]></sql>
+	</query>
+	<query name="SelectReturnTypesMap2" type="SQLTemplate" root="data-map" root-name="testmap">
+		<property name="cayenne.GenericSelectQuery.fetchingDataRows" value="true"/>
+		<property name="cayenne.SQLTemplate.columnNameCapitalization" value="UPPER"/>
+		<sql><![CDATA[SELECT * FROM TYPES_MAPPING_TEST2]]></sql>
+	</query>
+	<query name="SelectTestLower" type="SQLTemplate" root="data-map" root-name="testmap">
+		<property name="cayenne.GenericSelectQuery.fetchingDataRows" value="true"/>
+		<property name="cayenne.SQLTemplate.columnNameCapitalization" value="LOWER"/>
+		<sql><![CDATA[select * from ARTIST]]></sql>
+	</query>
+	<query name="SelectTestUpper" type="SQLTemplate" root="data-map" root-name="testmap">
+		<property name="cayenne.GenericSelectQuery.fetchingDataRows" value="true"/>
+		<property name="cayenne.SQLTemplate.columnNameCapitalization" value="UPPER"/>
+		<sql><![CDATA[select * from ARTIST]]></sql>
+	</query>
+</data-map>

http://git-wip-us.apache.org/repos/asf/cayenne/blob/c63b6be2/cayenne-cgen/pom.xml
----------------------------------------------------------------------
diff --git a/cayenne-cgen/pom.xml b/cayenne-cgen/pom.xml
new file mode 100644
index 0000000..7aa0d84
--- /dev/null
+++ b/cayenne-cgen/pom.xml
@@ -0,0 +1,81 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+  ~   Licensed to the Apache Software Foundation (ASF) under one
+  ~  or more contributor license agreements.  See the NOTICE file
+  ~  distributed with this work for additional information
+  ~  regarding copyright ownership.  The ASF licenses this file
+  ~  to you under the Apache License, Version 2.0 (the
+  ~  "License"); you may not use this file except in compliance
+  ~  with the License.  You may obtain a copy of the License at
+  ~
+  ~    http://www.apache.org/licenses/LICENSE-2.0
+  ~
+  ~  Unless required by applicable law or agreed to in writing,
+  ~  software distributed under the License is distributed on an
+  ~  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+  ~  KIND, either express or implied.  See the License for the
+  ~  specific language governing permissions and limitations
+  ~  under the License.
+  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~-->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+    <parent>
+        <artifactId>cayenne-parent</artifactId>
+        <groupId>org.apache.cayenne</groupId>
+        <version>4.0.M5-SNAPSHOT</version>
+    </parent>
+    <modelVersion>4.0.0</modelVersion>
+
+    <artifactId>cayenne-cgen</artifactId>
+    <packaging>jar</packaging>
+    <name>cayenne-cgen: Cayenne Class Generation Tools</name>
+
+    <dependencies>
+        <!--
+        using org.apache.cayenne.project.validation.NameValidationHelper from cayenne-project
+        and org.apache.cayenne.dbsync.filter.NameFilter from cayenne-dbsync
+        -->
+        <dependency>
+            <groupId>org.apache.cayenne</groupId>
+            <artifactId>cayenne-dbsync</artifactId>
+            <version>${project.version}</version>
+            <scope>compile</scope>
+        </dependency>
+
+        <dependency>
+            <groupId>commons-logging</groupId>
+            <artifactId>commons-logging</artifactId>
+            <scope>compile</scope>
+        </dependency>
+
+        <dependency>
+            <groupId>org.apache.velocity</groupId>
+            <artifactId>velocity</artifactId>
+            <scope>compile</scope>
+        </dependency>
+
+        <dependency>
+            <groupId>junit</groupId>
+            <artifactId>junit</artifactId>
+            <scope>test</scope>
+        </dependency>
+    </dependencies>
+
+    <build>
+        <plugins>
+            <!-- This ensures LICENSE and NOTICE inclusion in all jars -->
+            <plugin>
+                <artifactId>maven-remote-resources-plugin</artifactId>
+                <executions>
+                    <execution>
+                        <goals>
+                            <goal>process</goal>
+                        </goals>
+                    </execution>
+                </executions>
+            </plugin>
+        </plugins>
+    </build>
+</project>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/cayenne/blob/c63b6be2/cayenne-cgen/src/main/java/org/apache/cayenne/gen/Artifact.java
----------------------------------------------------------------------
diff --git a/cayenne-cgen/src/main/java/org/apache/cayenne/gen/Artifact.java b/cayenne-cgen/src/main/java/org/apache/cayenne/gen/Artifact.java
new file mode 100644
index 0000000..fcd9118
--- /dev/null
+++ b/cayenne-cgen/src/main/java/org/apache/cayenne/gen/Artifact.java
@@ -0,0 +1,65 @@
+/*****************************************************************
+ *   Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ ****************************************************************/
+package org.apache.cayenne.gen;
+
+import org.apache.velocity.VelocityContext;
+
+/**
+ * Represents a class generation "artifact" which is a facade to a metadata object used
+ * for a given single generation template run.
+ * 
+ * @since 3.0
+ */
+public interface Artifact {
+
+    public static String STRING_UTILS_KEY = "stringUtils";
+    public static String IMPORT_UTILS_KEY = "importUtils";
+
+    /**
+     * Root object, such as ObjEntity or Embeddable, etc.
+     */
+    public static String OBJECT_KEY = "object";
+    public static String SUPER_CLASS_KEY = "superClassName";
+    public static String SUPER_PACKAGE_KEY = "superPackageName";
+    public static String SUB_CLASS_KEY = "subClassName";
+    public static String SUB_PACKAGE_KEY = "subPackageName";
+    public static String BASE_CLASS_KEY = "baseClassName";
+    public static String BASE_PACKAGE_KEY = "basePackageName";
+    public static String CREATE_PROPERTY_NAMES = "createPropertyNames";
+
+    TemplateType[] getTemplateTypes(ArtifactGenerationMode mode);
+
+    String getQualifiedBaseClassName();
+
+    String getQualifiedClassName();
+
+    /**
+     * Returns a mapping metadata object for this artifact.
+     */
+    Object getObject();
+
+    /**
+     * A callback method that allows each artifact to add its own special keys to the
+     * context. Invoked from
+     * {@link ClassGenerationAction#resetContextForArtifactTemplate(Artifact, TemplateType)},
+     * after the context is initialized by code generator, so this method can use
+     * predefined keys from the context.
+     */
+    void postInitContext(VelocityContext context);
+}

http://git-wip-us.apache.org/repos/asf/cayenne/blob/c63b6be2/cayenne-cgen/src/main/java/org/apache/cayenne/gen/ArtifactGenerationMode.java
----------------------------------------------------------------------
diff --git a/cayenne-cgen/src/main/java/org/apache/cayenne/gen/ArtifactGenerationMode.java b/cayenne-cgen/src/main/java/org/apache/cayenne/gen/ArtifactGenerationMode.java
new file mode 100644
index 0000000..b0c20cc
--- /dev/null
+++ b/cayenne-cgen/src/main/java/org/apache/cayenne/gen/ArtifactGenerationMode.java
@@ -0,0 +1,28 @@
+/*****************************************************************
+ *   Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ ****************************************************************/
+package org.apache.cayenne.gen;
+
+/**
+ * Code generator execution mode for a single artifact.
+ * 
+ * @since 3.0
+ */
+public enum ArtifactGenerationMode {
+    SINGLE_CLASS, GENERATION_GAP
+}

http://git-wip-us.apache.org/repos/asf/cayenne/blob/c63b6be2/cayenne-cgen/src/main/java/org/apache/cayenne/gen/ArtifactsGenerationMode.java
----------------------------------------------------------------------
diff --git a/cayenne-cgen/src/main/java/org/apache/cayenne/gen/ArtifactsGenerationMode.java b/cayenne-cgen/src/main/java/org/apache/cayenne/gen/ArtifactsGenerationMode.java
new file mode 100644
index 0000000..e76c172
--- /dev/null
+++ b/cayenne-cgen/src/main/java/org/apache/cayenne/gen/ArtifactsGenerationMode.java
@@ -0,0 +1,40 @@
+/*****************************************************************
+ *   Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ ****************************************************************/
+package org.apache.cayenne.gen;
+
+/**
+ * Code generator execution mode for a collection of artifacts.
+ * 
+ * @since 3.0
+ */
+public enum ArtifactsGenerationMode {
+
+    // TODO: andrus 12/9/2007 - label names are old... need to call it something else...
+    DATAMAP("datamap"), ENTITY("entity"), ALL("all");
+
+    private String label;
+
+    private ArtifactsGenerationMode(String label) {
+        this.label = label;
+    }
+
+    public String getLabel() {
+        return label;
+    }
+}

http://git-wip-us.apache.org/repos/asf/cayenne/blob/c63b6be2/cayenne-cgen/src/main/java/org/apache/cayenne/gen/ClassGenerationAction.java
----------------------------------------------------------------------
diff --git a/cayenne-cgen/src/main/java/org/apache/cayenne/gen/ClassGenerationAction.java b/cayenne-cgen/src/main/java/org/apache/cayenne/gen/ClassGenerationAction.java
new file mode 100644
index 0000000..6c46977
--- /dev/null
+++ b/cayenne-cgen/src/main/java/org/apache/cayenne/gen/ClassGenerationAction.java
@@ -0,0 +1,584 @@
+/*****************************************************************
+ *   Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ ****************************************************************/
+
+package org.apache.cayenne.gen;
+
+import org.apache.cayenne.CayenneRuntimeException;
+import org.apache.cayenne.map.DataMap;
+import org.apache.cayenne.map.Embeddable;
+import org.apache.cayenne.map.ObjEntity;
+import org.apache.cayenne.map.QueryDescriptor;
+import org.apache.commons.logging.Log;
+import org.apache.velocity.Template;
+import org.apache.velocity.VelocityContext;
+import org.apache.velocity.app.VelocityEngine;
+import org.apache.velocity.runtime.RuntimeConstants;
+import org.apache.velocity.runtime.log.NullLogSystem;
+
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.OutputStreamWriter;
+import java.io.Writer;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Properties;
+
+public class ClassGenerationAction {
+	static final String TEMPLATES_DIR_NAME = "templates/v1_2/";
+
+	public static final String SINGLE_CLASS_TEMPLATE = TEMPLATES_DIR_NAME + "singleclass.vm";
+	public static final String SUBCLASS_TEMPLATE = TEMPLATES_DIR_NAME + "subclass.vm";
+	public static final String SUPERCLASS_TEMPLATE = TEMPLATES_DIR_NAME + "superclass.vm";
+
+	public static final String EMBEDDABLE_SINGLE_CLASS_TEMPLATE = TEMPLATES_DIR_NAME + "embeddable-singleclass.vm";
+	public static final String EMBEDDABLE_SUBCLASS_TEMPLATE = TEMPLATES_DIR_NAME + "embeddable-subclass.vm";
+	public static final String EMBEDDABLE_SUPERCLASS_TEMPLATE = TEMPLATES_DIR_NAME + "embeddable-superclass.vm";
+
+	public static final String DATAMAP_SINGLE_CLASS_TEMPLATE = TEMPLATES_DIR_NAME + "datamap-singleclass.vm";
+	public static final String DATAMAP_SUBCLASS_TEMPLATE = TEMPLATES_DIR_NAME + "datamap-subclass.vm";
+	public static final String DATAMAP_SUPERCLASS_TEMPLATE = TEMPLATES_DIR_NAME + "datamap-superclass.vm";
+
+	public static final String SUPERCLASS_PREFIX = "_";
+	private static final String WILDCARD = "*";
+
+	protected Collection<Artifact> artifacts;
+
+	protected String superPkg;
+	protected DataMap dataMap;
+
+	protected ArtifactsGenerationMode artifactsGenerationMode;
+	protected boolean makePairs;
+
+	protected Log logger;
+	protected File destDir;
+	protected boolean overwrite;
+	protected boolean usePkgPath;
+
+	protected String template;
+	protected String superTemplate;
+	protected String embeddableTemplate;
+	protected String embeddableSuperTemplate;
+	protected String queryTemplate;
+	protected String querySuperTemplate;
+	protected long timestamp;
+	protected String outputPattern;
+	protected String encoding;
+	protected boolean createPropertyNames;
+
+	// runtime ivars
+	protected VelocityContext context;
+	protected Map<String, Template> templateCache;
+
+	public ClassGenerationAction() {
+		this.outputPattern = "*.java";
+		this.timestamp = System.currentTimeMillis();
+		this.usePkgPath = true;
+		this.makePairs = true;
+		this.context = new VelocityContext();
+		this.templateCache = new HashMap<>(5);
+
+		this.artifacts = new ArrayList<>();
+	}
+
+	protected String defaultTemplateName(TemplateType type) {
+		switch (type) {
+		case ENTITY_SINGLE_CLASS:
+			return ClassGenerationAction.SINGLE_CLASS_TEMPLATE;
+		case ENTITY_SUBCLASS:
+			return ClassGenerationAction.SUBCLASS_TEMPLATE;
+		case ENTITY_SUPERCLASS:
+			return ClassGenerationAction.SUPERCLASS_TEMPLATE;
+		case EMBEDDABLE_SUBCLASS:
+			return ClassGenerationAction.EMBEDDABLE_SUBCLASS_TEMPLATE;
+		case EMBEDDABLE_SUPERCLASS:
+			return ClassGenerationAction.EMBEDDABLE_SUPERCLASS_TEMPLATE;
+		case EMBEDDABLE_SINGLE_CLASS:
+			return ClassGenerationAction.EMBEDDABLE_SINGLE_CLASS_TEMPLATE;
+		case DATAMAP_SINGLE_CLASS:
+			return ClassGenerationAction.DATAMAP_SINGLE_CLASS_TEMPLATE;
+		case DATAMAP_SUPERCLASS:
+			return ClassGenerationAction.DATAMAP_SUPERCLASS_TEMPLATE;
+		case DATAMAP_SUBCLASS:
+			return ClassGenerationAction.DATAMAP_SUBCLASS_TEMPLATE;
+		default:
+			throw new IllegalArgumentException("Invalid template type: " + type);
+		}
+	}
+
+	protected String customTemplateName(TemplateType type) {
+		switch (type) {
+		case ENTITY_SINGLE_CLASS:
+			return template;
+		case ENTITY_SUBCLASS:
+			return template;
+		case ENTITY_SUPERCLASS:
+			return superTemplate;
+		case EMBEDDABLE_SUBCLASS:
+			return embeddableTemplate;
+		case EMBEDDABLE_SUPERCLASS:
+			return embeddableSuperTemplate;
+		case DATAMAP_SINGLE_CLASS:
+			return queryTemplate;
+		case DATAMAP_SUPERCLASS:
+			return querySuperTemplate;
+		case DATAMAP_SUBCLASS:
+			return queryTemplate;
+		default:
+			throw new IllegalArgumentException("Invalid template type: " + type);
+		}
+	}
+
+	/**
+	 * Returns a String used to prefix class name to create a generated
+	 * superclass. Default value is "_".
+	 */
+	protected String getSuperclassPrefix() {
+		return ClassGenerationAction.SUPERCLASS_PREFIX;
+	}
+
+	/**
+	 * VelocityContext initialization method called once per artifact.
+	 */
+	protected void resetContextForArtifact(Artifact artifact) {
+		StringUtils stringUtils = StringUtils.getInstance();
+
+		String qualifiedClassName = artifact.getQualifiedClassName();
+		String packageName = stringUtils.stripClass(qualifiedClassName);
+		String className = stringUtils.stripPackageName(qualifiedClassName);
+
+		String qualifiedBaseClassName = artifact.getQualifiedBaseClassName();
+		String basePackageName = stringUtils.stripClass(qualifiedBaseClassName);
+		String baseClassName = stringUtils.stripPackageName(qualifiedBaseClassName);
+
+		String superClassName = getSuperclassPrefix() + stringUtils.stripPackageName(qualifiedClassName);
+
+		String superPackageName = this.superPkg;
+		if (superPackageName == null) {
+			superPackageName = packageName + ".auto";
+		}
+
+		context.put(Artifact.BASE_CLASS_KEY, baseClassName);
+		context.put(Artifact.BASE_PACKAGE_KEY, basePackageName);
+
+		context.put(Artifact.SUB_CLASS_KEY, className);
+		context.put(Artifact.SUB_PACKAGE_KEY, packageName);
+
+		context.put(Artifact.SUPER_CLASS_KEY, superClassName);
+		context.put(Artifact.SUPER_PACKAGE_KEY, superPackageName);
+
+		context.put(Artifact.OBJECT_KEY, artifact.getObject());
+		context.put(Artifact.STRING_UTILS_KEY, stringUtils);
+
+		context.put(Artifact.CREATE_PROPERTY_NAMES, createPropertyNames);
+	}
+
+	/**
+	 * VelocityContext initialization method called once per each artifact and
+	 * template type combination.
+	 */
+	protected void resetContextForArtifactTemplate(Artifact artifact, TemplateType templateType) {
+		context.put(Artifact.IMPORT_UTILS_KEY, new ImportUtils());
+		artifact.postInitContext(context);
+	}
+
+	/**
+	 * Executes class generation once per each artifact.
+	 */
+	public void execute() throws Exception {
+
+		validateAttributes();
+
+		try {
+			for (Artifact artifact : artifacts) {
+				execute(artifact);
+			}
+		} finally {
+			// must reset engine at the end of class generator run to avoid
+			// memory
+			// leaks and stale templates
+			this.templateCache.clear();
+		}
+	}
+
+	/**
+	 * Executes class generation for a single artifact.
+	 */
+	protected void execute(Artifact artifact) throws Exception {
+
+		resetContextForArtifact(artifact);
+
+		ArtifactGenerationMode artifactMode = makePairs ? ArtifactGenerationMode.GENERATION_GAP
+				: ArtifactGenerationMode.SINGLE_CLASS;
+
+		TemplateType[] templateTypes = artifact.getTemplateTypes(artifactMode);
+		for (TemplateType type : templateTypes) {
+
+			try (Writer out = openWriter(type);) {
+				if (out != null) {
+
+					resetContextForArtifactTemplate(artifact, type);
+					getTemplate(type).merge(context, out);
+				}
+			}
+		}
+	}
+
+	protected Template getTemplate(TemplateType type) throws Exception {
+
+		String templateName = customTemplateName(type);
+		if (templateName == null) {
+			templateName = defaultTemplateName(type);
+		}
+
+		// Velocity < 1.5 has some memory problems, so we will create a
+		// VelocityEngine
+		// every time, and store templates in an internal cache, to avoid
+		// uncontrolled
+		// memory leaks... Presumably 1.5 fixes it.
+
+		Template template = templateCache.get(templateName);
+
+		if (template == null) {
+
+			Properties props = new Properties();
+
+			// null logger that will prevent velocity.log from being generated
+			props.put(RuntimeConstants.RUNTIME_LOG_LOGSYSTEM_CLASS, NullLogSystem.class.getName());
+			props.put("resource.loader", "cayenne");
+			props.put("cayenne.resource.loader.class", ClassGeneratorResourceLoader.class.getName());
+			props.put("cayenne.resource.loader.cache", "false");
+
+			VelocityEngine velocityEngine = new VelocityEngine();
+			velocityEngine.init(props);
+
+			template = velocityEngine.getTemplate(templateName);
+			templateCache.put(templateName, template);
+		}
+
+		return template;
+	}
+
+	/**
+	 * Validates the state of this class generator. Throws
+	 * CayenneRuntimeException if it is in an inconsistent state. Called
+	 * internally from "execute".
+	 */
+	protected void validateAttributes() {
+		if (destDir == null) {
+			throw new CayenneRuntimeException("'destDir' attribute is missing.");
+		}
+
+		if (!destDir.isDirectory()) {
+			throw new CayenneRuntimeException("'destDir' is not a directory.");
+		}
+
+		if (!destDir.canWrite()) {
+			throw new CayenneRuntimeException("Do not have write permissions for " + destDir);
+		}
+	}
+
+	/**
+	 * Sets the destDir.
+	 */
+	public void setDestDir(File destDir) {
+		this.destDir = destDir;
+	}
+
+	/**
+	 * Sets <code>overwrite</code> property.
+	 */
+	public void setOverwrite(boolean overwrite) {
+		this.overwrite = overwrite;
+	}
+
+	/**
+	 * Sets <code>makepairs</code> property.
+	 */
+	public void setMakePairs(boolean makePairs) {
+		this.makePairs = makePairs;
+	}
+
+	/**
+	 * Sets <code>template</code> property.
+	 */
+	public void setTemplate(String template) {
+		this.template = template;
+	}
+
+	/**
+	 * Sets <code>superTemplate</code> property.
+	 */
+	public void setSuperTemplate(String superTemplate) {
+		this.superTemplate = superTemplate;
+	}
+
+	public void setQueryTemplate(String queryTemplate) {
+		this.queryTemplate = queryTemplate;
+	}
+
+	public void setQuerySuperTemplate(String querySuperTemplate) {
+		this.querySuperTemplate = querySuperTemplate;
+	}
+
+	/**
+	 * Sets <code>usepkgpath</code> property.
+	 */
+	public void setUsePkgPath(boolean usePkgPath) {
+		this.usePkgPath = usePkgPath;
+	}
+
+	/**
+	 * Sets <code>outputPattern</code> property.
+	 */
+	public void setOutputPattern(String outputPattern) {
+		this.outputPattern = outputPattern;
+	}
+
+	/**
+	 * Sets <code>createPropertyNames</code> property.
+	 */
+	public void setCreatePropertyNames(boolean createPropertyNames) {
+		this.createPropertyNames = createPropertyNames;
+	}
+
+	/**
+	 * Opens a Writer to write generated output. Returned Writer is mapped to a
+	 * filesystem file (although subclasses may override that). File location is
+	 * determined from the current state of VelocityContext and the TemplateType
+	 * passed as a parameter. Writer encoding is determined from the value of
+	 * the "encoding" property.
+	 */
+	protected Writer openWriter(TemplateType templateType) throws Exception {
+
+		File outFile = (templateType.isSuperclass()) ? fileForSuperclass() : fileForClass();
+		if (outFile == null) {
+			return null;
+		}
+
+		if (logger != null) {
+			String label = templateType.isSuperclass() ? "superclass" : "class";
+			logger.info("Generating " + label + " file: " + outFile.getCanonicalPath());
+		}
+
+		// return writer with specified encoding
+		FileOutputStream out = new FileOutputStream(outFile);
+
+		return (encoding != null) ? new OutputStreamWriter(out, encoding) : new OutputStreamWriter(out);
+	}
+
+	/**
+	 * Returns a target file where a generated superclass must be saved. If null
+	 * is returned, class shouldn't be generated.
+	 */
+	protected File fileForSuperclass() throws Exception {
+
+		String packageName = (String) context.get(Artifact.SUPER_PACKAGE_KEY);
+		String className = (String) context.get(Artifact.SUPER_CLASS_KEY);
+
+		String filename = StringUtils.getInstance().replaceWildcardInStringWithString(WILDCARD, outputPattern, className);
+		File dest = new File(mkpath(destDir, packageName), filename);
+
+		// Ignore if the destination is newer than the map
+		// (internal timestamp), i.e. has been generated after the map was
+		// last saved AND the template is older than the destination file
+		if (dest.exists() && !isOld(dest)) {
+
+			if (superTemplate == null) {
+				return null;
+			}
+
+			File superTemplateFile = new File(superTemplate);
+			if (superTemplateFile.lastModified() < dest.lastModified()) {
+				return null;
+			}
+		}
+
+		return dest;
+	}
+
+	/**
+	 * Returns a target file where a generated class must be saved. If null is
+	 * returned, class shouldn't be generated.
+	 */
+	protected File fileForClass() throws Exception {
+
+		String packageName = (String) context.get(Artifact.SUB_PACKAGE_KEY);
+		String className = (String) context.get(Artifact.SUB_CLASS_KEY);
+
+		String filename = StringUtils.getInstance().replaceWildcardInStringWithString(WILDCARD, outputPattern, className);
+		File dest = new File(mkpath(destDir, packageName), filename);
+
+		if (dest.exists()) {
+			// no overwrite of subclasses
+			if (makePairs) {
+				return null;
+			}
+
+			// skip if said so
+			if (!overwrite) {
+				return null;
+			}
+
+			// Ignore if the destination is newer than the map
+			// (internal timestamp), i.e. has been generated after the map was
+			// last saved AND the template is older than the destination file
+			if (!isOld(dest)) {
+
+				if (template == null) {
+					return null;
+				}
+
+				File templateFile = new File(template);
+				if (templateFile.lastModified() < dest.lastModified()) {
+					return null;
+				}
+			}
+		}
+
+		return dest;
+	}
+
+	/**
+	 * Returns true if <code>file</code> parameter is older than internal
+	 * timestamp of this class generator.
+	 */
+	protected boolean isOld(File file) {
+		return file.lastModified() <= timestamp;
+	}
+
+	/**
+	 * Returns a File object corresponding to a directory where files that
+	 * belong to <code>pkgName</code> package should reside. Creates any missing
+	 * diectories below <code>dest</code>.
+	 */
+	protected File mkpath(File dest, String pkgName) throws Exception {
+
+		if (!usePkgPath || pkgName == null) {
+			return dest;
+		}
+
+		String path = pkgName.replace('.', File.separatorChar);
+		File fullPath = new File(dest, path);
+		if (!fullPath.isDirectory() && !fullPath.mkdirs()) {
+			throw new Exception("Error making path: " + fullPath);
+		}
+
+		return fullPath;
+	}
+
+	public void setTimestamp(long timestamp) {
+		this.timestamp = timestamp;
+	}
+
+	/**
+	 * Sets file encoding. If set to null, default system encoding will be used.
+	 */
+	public void setEncoding(String encoding) {
+		this.encoding = encoding;
+	}
+
+	/**
+	 * Sets "superPkg" property value.
+	 */
+	public void setSuperPkg(String superPkg) {
+		this.superPkg = superPkg;
+	}
+
+	/**
+	 * @param dataMap
+	 *            The dataMap to set.
+	 */
+	public void setDataMap(DataMap dataMap) {
+		this.dataMap = dataMap;
+	}
+
+	/**
+	 * Adds entities to the internal entity list.
+	 */
+	public void addEntities(Collection<ObjEntity> entities) {
+		if (artifactsGenerationMode == ArtifactsGenerationMode.ENTITY
+				|| artifactsGenerationMode == ArtifactsGenerationMode.ALL) {
+			if (entities != null) {
+				for (ObjEntity entity : entities) {
+					artifacts.add(new EntityArtifact(entity));
+				}
+			}
+		}
+	}
+
+	public void addEmbeddables(Collection<Embeddable> embeddables) {
+		if (artifactsGenerationMode == ArtifactsGenerationMode.ENTITY
+				|| artifactsGenerationMode == ArtifactsGenerationMode.ALL) {
+			if (embeddables != null) {
+				for (Embeddable embeddable : embeddables) {
+					artifacts.add(new EmbeddableArtifact(embeddable));
+				}
+			}
+		}
+	}
+
+	public void addQueries(Collection<QueryDescriptor> queries) {
+		if (artifactsGenerationMode == ArtifactsGenerationMode.DATAMAP
+				|| artifactsGenerationMode == ArtifactsGenerationMode.ALL) {
+
+			// TODO: andrus 10.12.2010 - why not also check for empty query
+			// list?? Or
+			// create a better API for enabling DataMapArtifact
+			if (queries != null) {
+				artifacts.add(new DataMapArtifact(dataMap, queries));
+			}
+		}
+	}
+
+	/**
+	 * Sets an optional shared VelocityContext. Useful with tools like VPP that
+	 * can set custom values in the context, not known to Cayenne.
+	 */
+	public void setContext(VelocityContext context) {
+		this.context = context;
+	}
+
+	/**
+	 * Injects an optional logger that will be used to trace generated files at
+	 * the info level.
+	 */
+	public void setLogger(Log logger) {
+		this.logger = logger;
+	}
+
+	public void setEmbeddableTemplate(String embeddableTemplate) {
+		this.embeddableTemplate = embeddableTemplate;
+	}
+
+	public void setEmbeddableSuperTemplate(String embeddableSuperTemplate) {
+		this.embeddableSuperTemplate = embeddableSuperTemplate;
+	}
+
+	public void setArtifactsGenerationMode(String mode) {
+		if (ArtifactsGenerationMode.ENTITY.getLabel().equalsIgnoreCase(mode)) {
+			this.artifactsGenerationMode = ArtifactsGenerationMode.ENTITY;
+		} else if (ArtifactsGenerationMode.DATAMAP.getLabel().equalsIgnoreCase(mode)) {
+			this.artifactsGenerationMode = ArtifactsGenerationMode.DATAMAP;
+		} else {
+			this.artifactsGenerationMode = ArtifactsGenerationMode.ALL;
+		}
+	}
+}

http://git-wip-us.apache.org/repos/asf/cayenne/blob/c63b6be2/cayenne-cgen/src/main/java/org/apache/cayenne/gen/ClassGeneratorResourceLoader.java
----------------------------------------------------------------------
diff --git a/cayenne-cgen/src/main/java/org/apache/cayenne/gen/ClassGeneratorResourceLoader.java b/cayenne-cgen/src/main/java/org/apache/cayenne/gen/ClassGeneratorResourceLoader.java
new file mode 100644
index 0000000..8e8a1ee
--- /dev/null
+++ b/cayenne-cgen/src/main/java/org/apache/cayenne/gen/ClassGeneratorResourceLoader.java
@@ -0,0 +1,102 @@
+/*****************************************************************
+ *   Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ ****************************************************************/
+
+package org.apache.cayenne.gen;
+
+import java.io.BufferedInputStream;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.InputStream;
+
+import org.apache.velocity.exception.ResourceNotFoundException;
+import org.apache.velocity.runtime.resource.loader.FileResourceLoader;
+
+/**
+ * Velocity template resource loader customized for Cayenne use. Supports loading
+ * templates from the thread ClassLoader and from relative and absolute paths.
+ * 
+ * @since 1.2
+ */
+// must be public top-level class as it is
+// instantiated via reflection by Velocity
+public class ClassGeneratorResourceLoader extends FileResourceLoader {
+
+    /**
+     * Returns resource as InputStream. First calls super implementation. If resource
+     * wasn't found, it attempts to load it from current directory or as an absolute path.
+     */
+    @Override
+    public synchronized InputStream getResourceStream(String name)
+            throws ResourceNotFoundException {
+
+        InputStream stream = loadFromRelativePath(name);
+        if (stream != null) {
+            return stream;
+        }
+
+        stream = loadFromAbsPath(name);
+        if (stream != null) {
+            return stream;
+        }
+
+        stream = loadFromThreadClassLoader(name);
+        if (stream != null) {
+            return stream;
+        }
+
+        stream = loadFromThisClassLoader(name);
+        if (stream != null) {
+            return stream;
+        }
+
+        throw new ResourceNotFoundException("Couldn't find resource '"
+                + name
+                + "'. Searched filesystem path and classpath");
+    }
+
+    protected InputStream loadFromRelativePath(String name) {
+        try {
+            return super.getResourceStream(name);
+        }
+        catch (ResourceNotFoundException rnfex) {
+            return null;
+        }
+    }
+
+    protected InputStream loadFromAbsPath(String name) {
+        try {
+            File file = new File(name);
+            return (file.canRead()) ? new BufferedInputStream(new FileInputStream(file
+                    .getAbsolutePath())) : null;
+
+        }
+        catch (FileNotFoundException fnfe) {
+            return null;
+        }
+    }
+
+    protected InputStream loadFromThreadClassLoader(String name) {
+        return Thread.currentThread().getContextClassLoader().getResourceAsStream(name);
+    }
+
+    protected InputStream loadFromThisClassLoader(String name) {
+        return getClass().getClassLoader().getResourceAsStream(name);
+    }
+}

http://git-wip-us.apache.org/repos/asf/cayenne/blob/c63b6be2/cayenne-cgen/src/main/java/org/apache/cayenne/gen/ClientClassGenerationAction.java
----------------------------------------------------------------------
diff --git a/cayenne-cgen/src/main/java/org/apache/cayenne/gen/ClientClassGenerationAction.java b/cayenne-cgen/src/main/java/org/apache/cayenne/gen/ClientClassGenerationAction.java
new file mode 100644
index 0000000..c89b1eb
--- /dev/null
+++ b/cayenne-cgen/src/main/java/org/apache/cayenne/gen/ClientClassGenerationAction.java
@@ -0,0 +1,80 @@
+/*****************************************************************
+ *   Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ ****************************************************************/
+
+package org.apache.cayenne.gen;
+
+import java.util.Collection;
+
+import org.apache.cayenne.map.ObjEntity;
+import org.apache.cayenne.map.QueryDescriptor;
+
+/**
+ * @since 3.0
+ */
+public class ClientClassGenerationAction extends ClassGenerationAction {
+
+    public static final String SUBCLASS_TEMPLATE = TEMPLATES_DIR_NAME + "client-subclass.vm";
+    public static final String SUPERCLASS_TEMPLATE = TEMPLATES_DIR_NAME + "client-superclass.vm";
+    
+    public static final String DMAP_SINGLE_CLASS_TEMPLATE = TEMPLATES_DIR_NAME + "client-datamap-singleclass.vm";
+    public static final String DMAP_SUBCLASS_TEMPLATE = TEMPLATES_DIR_NAME + "client-datamap-subclass.vm";
+    public static final String DMAP_SUPERCLASS_TEMPLATE = TEMPLATES_DIR_NAME + "client-datamap-superclass.vm";
+    
+    public static final String CLIENT_SUPERCLASS_PREFIX = "_Client";
+
+    @Override
+    protected String defaultTemplateName(TemplateType type) {
+        switch (type) {
+            case ENTITY_SUBCLASS:
+                return ClientClassGenerationAction.SUBCLASS_TEMPLATE;
+            case ENTITY_SUPERCLASS:
+                return ClientClassGenerationAction.SUPERCLASS_TEMPLATE;
+            case EMBEDDABLE_SUBCLASS:
+                return EMBEDDABLE_SUBCLASS_TEMPLATE;
+            case EMBEDDABLE_SUPERCLASS:
+                return EMBEDDABLE_SUPERCLASS_TEMPLATE;
+            
+            case DATAMAP_SUPERCLASS:
+                return ClientClassGenerationAction.DMAP_SUPERCLASS_TEMPLATE;
+            case DATAMAP_SUBCLASS:
+                return ClientClassGenerationAction.DMAP_SUBCLASS_TEMPLATE;
+            default:
+                throw new IllegalArgumentException("Unsupported template type: " + type);
+        }
+    }
+
+    @Override
+    public void addEntities(Collection<ObjEntity> entities) {
+        if (entities != null) {
+            for (ObjEntity entity : entities) {
+                artifacts.add(new ClientEntityArtifact(entity));
+            }
+        }
+    }
+
+    @Override
+    public void addQueries(Collection<QueryDescriptor> queries) {
+        if (artifactsGenerationMode == ArtifactsGenerationMode.DATAMAP
+                || artifactsGenerationMode == ArtifactsGenerationMode.ALL) {
+            if (queries != null) {
+                artifacts.add(new ClientDataMapArtifact(dataMap, queries));
+            }
+        }
+    }
+}


[05/10] cayenne git commit: CAY-2215 split cayenne-tools into cayenne-cgen and cayenne-ant

Posted by nt...@apache.org.
http://git-wip-us.apache.org/repos/asf/cayenne/blob/c63b6be2/cayenne-dbsync/src/test/java/org/apache/cayenne/dbsync/filter/NamePatternMatcherTest.java
----------------------------------------------------------------------
diff --git a/cayenne-dbsync/src/test/java/org/apache/cayenne/dbsync/filter/NamePatternMatcherTest.java b/cayenne-dbsync/src/test/java/org/apache/cayenne/dbsync/filter/NamePatternMatcherTest.java
index d99ba09..0b4674b 100644
--- a/cayenne-dbsync/src/test/java/org/apache/cayenne/dbsync/filter/NamePatternMatcherTest.java
+++ b/cayenne-dbsync/src/test/java/org/apache/cayenne/dbsync/filter/NamePatternMatcherTest.java
@@ -21,27 +21,11 @@ package org.apache.cayenne.dbsync.filter;
 
 import org.junit.Test;
 
-import static org.apache.cayenne.dbsync.filter.NamePatternMatcher.replaceWildcardInStringWithString;
 import static org.junit.Assert.assertEquals;
 
 public class NamePatternMatcherTest {
 
     /**
-     * Test pattern expansion.
-     */
-    @Test
-    public void testReplaceWildcardInStringWithString() throws Exception {
-        assertEquals(null, replaceWildcardInStringWithString("*", null, "Entity"));
-        assertEquals("*.java", replaceWildcardInStringWithString(null, "*.java", "Entity"));
-        assertEquals("Entity.java", replaceWildcardInStringWithString("*", "*.java", "Entity"));
-        assertEquals("java.Entity", replaceWildcardInStringWithString("*", "java.*", "Entity"));
-        assertEquals("Entity.Entity", replaceWildcardInStringWithString("*", "*.*", "Entity"));
-        assertEquals("EntityEntity", replaceWildcardInStringWithString("*", "**", "Entity"));
-        assertEquals("EditEntityReport.vm", replaceWildcardInStringWithString("*", "Edit*Report.vm", "Entity"));
-        assertEquals("Entity", replaceWildcardInStringWithString("*", "*", "Entity"));
-    }
-
-    /**
      * Test tokenizing
      */
     @Test

http://git-wip-us.apache.org/repos/asf/cayenne/blob/c63b6be2/cayenne-di/pom.xml
----------------------------------------------------------------------
diff --git a/cayenne-di/pom.xml b/cayenne-di/pom.xml
index 12fd6fd..1984dd3 100644
--- a/cayenne-di/pom.xml
+++ b/cayenne-di/pom.xml
@@ -29,7 +29,7 @@
 	</dependencies>
 	<build>
 		<plugins>
-			<!-- This ensures LICESNE and NOTICE inclusion in all jars -->
+			<!-- This ensures LICENSE and NOTICE inclusion in all jars -->
             <plugin>
                 <artifactId>maven-remote-resources-plugin</artifactId>
                 <executions>

http://git-wip-us.apache.org/repos/asf/cayenne/blob/c63b6be2/cayenne-joda/pom.xml
----------------------------------------------------------------------
diff --git a/cayenne-joda/pom.xml b/cayenne-joda/pom.xml
index 7e969cf..18354ff 100644
--- a/cayenne-joda/pom.xml
+++ b/cayenne-joda/pom.xml
@@ -100,7 +100,7 @@
 	</dependencies>
 	<build>
 		<plugins>
-			<!-- This ensures LICESNE and NOTICE inclusion in all jars -->
+			<!-- This ensures LICENSE and NOTICE inclusion in all jars -->
             <plugin>
                 <artifactId>maven-remote-resources-plugin</artifactId>
                 <executions>

http://git-wip-us.apache.org/repos/asf/cayenne/blob/c63b6be2/cayenne-lifecycle/pom.xml
----------------------------------------------------------------------
diff --git a/cayenne-lifecycle/pom.xml b/cayenne-lifecycle/pom.xml
index 04d62a1..b1172c7 100644
--- a/cayenne-lifecycle/pom.xml
+++ b/cayenne-lifecycle/pom.xml
@@ -68,7 +68,7 @@
 	</dependencies>
 	<build>
 		<plugins>
-			<!-- This ensures LICESNE and NOTICE inclusion in all jars -->
+			<!-- This ensures LICENSE and NOTICE inclusion in all jars -->
             <plugin>
                 <artifactId>maven-remote-resources-plugin</artifactId>
                 <executions>

http://git-wip-us.apache.org/repos/asf/cayenne/blob/c63b6be2/cayenne-project/pom.xml
----------------------------------------------------------------------
diff --git a/cayenne-project/pom.xml b/cayenne-project/pom.xml
index 4c2174c..c426335 100644
--- a/cayenne-project/pom.xml
+++ b/cayenne-project/pom.xml
@@ -82,7 +82,7 @@
 
     <build>
         <plugins>
-            <!-- This ensures LICESNE and NOTICE inclusion in all jars -->
+            <!-- This ensures LICENSE and NOTICE inclusion in all jars -->
             <plugin>
                 <artifactId>maven-remote-resources-plugin</artifactId>
                 <executions>

http://git-wip-us.apache.org/repos/asf/cayenne/blob/c63b6be2/cayenne-protostuff/pom.xml
----------------------------------------------------------------------
diff --git a/cayenne-protostuff/pom.xml b/cayenne-protostuff/pom.xml
index 0328db7..185f446 100644
--- a/cayenne-protostuff/pom.xml
+++ b/cayenne-protostuff/pom.xml
@@ -90,7 +90,7 @@
 
     <build>
         <plugins>
-            <!-- This ensures LICESNE and NOTICE inclusion in all jars -->
+            <!-- This ensures LICENSE and NOTICE inclusion in all jars -->
             <plugin>
                 <artifactId>maven-remote-resources-plugin</artifactId>
                 <executions>

http://git-wip-us.apache.org/repos/asf/cayenne/blob/c63b6be2/cayenne-server/pom.xml
----------------------------------------------------------------------
diff --git a/cayenne-server/pom.xml b/cayenne-server/pom.xml
index 1e27e2f..88d9e7b 100644
--- a/cayenne-server/pom.xml
+++ b/cayenne-server/pom.xml
@@ -166,7 +166,7 @@
 			</resource>
 		</resources>
 		<plugins>
-			<!-- This ensures LICESNE and NOTICE inclusion in all jars -->
+			<!-- This ensures LICENSE and NOTICE inclusion in all jars -->
             <plugin>
                 <artifactId>maven-remote-resources-plugin</artifactId>
                 <executions>

http://git-wip-us.apache.org/repos/asf/cayenne/blob/c63b6be2/cayenne-tools/pom.xml
----------------------------------------------------------------------
diff --git a/cayenne-tools/pom.xml b/cayenne-tools/pom.xml
deleted file mode 100644
index fb48cb3..0000000
--- a/cayenne-tools/pom.xml
+++ /dev/null
@@ -1,193 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
-	Licensed to the Apache Software Foundation (ASF) under one
-	or more contributor license agreements.  See the NOTICE file
-	distributed with this work for additional information
-	regarding copyright ownership.  The ASF licenses this file
-	to you under the Apache License, Version 2.0 (the
-	"License"); you may not use this file except in compliance
-	with the License.  You may obtain a copy of the License at
-	
-	http://www.apache.org/licenses/LICENSE-2.0
-	
-	Unless required by applicable law or agreed to in writing,
-	software distributed under the License is distributed on an
-	"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-	KIND, either express or implied.  See the License for the
-	specific language governing permissions and limitations
-	under the License.   
--->
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
-
-	<parent>
-		<artifactId>cayenne-parent</artifactId>
-		<groupId>org.apache.cayenne</groupId>
-		<version>4.0.M5-SNAPSHOT</version>
-	</parent>
-
-	<modelVersion>4.0.0</modelVersion>
-
-	<artifactId>cayenne-tools</artifactId>
-	<packaging>jar</packaging>
-	<name>cayenne-tools: Cayenne Tools</name>
-	<dependencies>
-        <!-- Compile Dependencies -->
-        <dependency>
-            <groupId>org.apache.ant</groupId>
-            <artifactId>ant</artifactId>
-            <scope>compile</scope>
-        </dependency>
-		<dependency>
-			<groupId>commons-collections</groupId>
-			<artifactId>commons-collections</artifactId>
-            <scope>compile</scope>
-		</dependency>
-		<dependency>
-			<groupId>commons-logging</groupId>
-			<artifactId>commons-logging</artifactId>
-            <scope>compile</scope>
-		</dependency>
-		<dependency>
-			<groupId>org.apache.velocity</groupId>
-			<artifactId>velocity</artifactId>
-            <scope>compile</scope>
-		</dependency>
-		<dependency>
-			<groupId>org.apache.cayenne</groupId>
-			<artifactId>cayenne-server</artifactId>
-			<version>${project.version}</version>
-            <scope>compile</scope>
-		</dependency>
-		<dependency>
-			<groupId>org.apache.cayenne</groupId>
-			<artifactId>cayenne-project</artifactId>
-			<version>${project.version}</version>
-            <scope>compile</scope>
-		</dependency>
-        <dependency>
-            <groupId>org.apache.cayenne</groupId>
-            <artifactId>cayenne-dbsync</artifactId>
-            <version>${project.version}</version>
-            <scope>compile</scope>
-        </dependency>
-		<dependency>
-			<groupId>foundrylogic.vpp</groupId>
-			<artifactId>vpp</artifactId>
-            <scope>compile</scope>
-		</dependency>
-
-        <!-- Test Dependencies -->
-        <dependency>
-            <groupId>junit</groupId>
-            <artifactId>junit</artifactId>
-            <scope>test</scope>
-        </dependency>
-        <dependency>
-            <groupId>org.apache.cayenne</groupId>
-            <artifactId>cayenne-server</artifactId>
-            <version>${project.version}</version>
-            <scope>test</scope>
-            <type>test-jar</type>
-        </dependency>
-        <dependency>
-            <groupId>org.apache.cayenne</groupId>
-            <artifactId>cayenne-dbsync</artifactId>
-            <version>${project.version}</version>
-            <scope>test</scope>
-            <type>test-jar</type>
-        </dependency>
-        <dependency>
-            <groupId>org.apache.cayenne.build-tools</groupId>
-            <artifactId>cayenne-test-utilities</artifactId>
-            <version>${project.version}</version>
-            <scope>test</scope>
-        </dependency>
-        <dependency>
-            <groupId>org.mockito</groupId>
-            <artifactId>mockito-all</artifactId>
-            <scope>test</scope>
-        </dependency>
-        <dependency>
-            <groupId>org.slf4j</groupId>
-            <artifactId>jcl-over-slf4j</artifactId>
-            <scope>test</scope>
-        </dependency>
-        <dependency>
-            <groupId>org.slf4j</groupId>
-            <artifactId>slf4j-api</artifactId>
-            <scope>test</scope>
-        </dependency>
-        <dependency>
-            <groupId>org.slf4j</groupId>
-            <artifactId>slf4j-simple</artifactId>
-            <scope>test</scope>
-        </dependency>
-        <dependency>
-            <groupId>org.apache.ant</groupId>
-            <artifactId>ant-testutil</artifactId>
-            <version>1.9.4</version>
-            <scope>test</scope>
-        </dependency>
-        <dependency>
-            <groupId>org.apache.derby</groupId>
-            <artifactId>derby</artifactId>
-            <scope>test</scope>
-        </dependency>
-        <dependency>
-            <groupId>xmlunit</groupId>
-            <artifactId>xmlunit</artifactId>
-            <scope>test</scope>
-        </dependency>
-
-	</dependencies>
-	
-	<build>
-		<plugins>
-			<!-- This ensures LICENSE and NOTICE inclusion in all jars -->
-            <plugin>
-                <artifactId>maven-remote-resources-plugin</artifactId>
-                <executions>
-                    <execution>
-                        <goals>
-                            <goal>process</goal>
-                        </goals>
-                    </execution>
-                </executions>
-            </plugin>
-            <plugin>
-                <artifactId>maven-jar-plugin</artifactId>
-                <executions>
-                    <execution>
-                        <goals>
-                            <goal>test-jar</goal>
-                        </goals>
-                    </execution>
-                </executions>
-            </plugin>
-        </plugins>
-	</build>
-    <profiles>
-        <profile>
-            <id>code-quality</id>
-
-            <activation>
-                <property>
-                    <name>!fast-and-dirty</name>
-                </property>
-            </activation>
-            <build>
-                <plugins>
-                    <plugin>
-                        <artifactId>maven-checkstyle-plugin</artifactId>
-                        <!--<configuration>
-                            <suppressionsLocation>${project.basedir}/cayenne-checkstyle-suppression.xml</suppressionsLocation>
-                        </configuration>-->
-                    </plugin>
-                    <plugin>
-                        <artifactId>maven-pmd-plugin</artifactId>
-                    </plugin>
-                </plugins>
-            </build>
-        </profile>
-    </profiles>
-</project>

http://git-wip-us.apache.org/repos/asf/cayenne/blob/c63b6be2/cayenne-tools/src/main/java/org/apache/cayenne/gen/Artifact.java
----------------------------------------------------------------------
diff --git a/cayenne-tools/src/main/java/org/apache/cayenne/gen/Artifact.java b/cayenne-tools/src/main/java/org/apache/cayenne/gen/Artifact.java
deleted file mode 100644
index fcd9118..0000000
--- a/cayenne-tools/src/main/java/org/apache/cayenne/gen/Artifact.java
+++ /dev/null
@@ -1,65 +0,0 @@
-/*****************************************************************
- *   Licensed to the Apache Software Foundation (ASF) under one
- *  or more contributor license agreements.  See the NOTICE file
- *  distributed with this work for additional information
- *  regarding copyright ownership.  The ASF licenses this file
- *  to you under the Apache License, Version 2.0 (the
- *  "License"); you may not use this file except in compliance
- *  with the License.  You may obtain a copy of the License at
- *
- *    http://www.apache.org/licenses/LICENSE-2.0
- *
- *  Unless required by applicable law or agreed to in writing,
- *  software distributed under the License is distributed on an
- *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- *  KIND, either express or implied.  See the License for the
- *  specific language governing permissions and limitations
- *  under the License.
- ****************************************************************/
-package org.apache.cayenne.gen;
-
-import org.apache.velocity.VelocityContext;
-
-/**
- * Represents a class generation "artifact" which is a facade to a metadata object used
- * for a given single generation template run.
- * 
- * @since 3.0
- */
-public interface Artifact {
-
-    public static String STRING_UTILS_KEY = "stringUtils";
-    public static String IMPORT_UTILS_KEY = "importUtils";
-
-    /**
-     * Root object, such as ObjEntity or Embeddable, etc.
-     */
-    public static String OBJECT_KEY = "object";
-    public static String SUPER_CLASS_KEY = "superClassName";
-    public static String SUPER_PACKAGE_KEY = "superPackageName";
-    public static String SUB_CLASS_KEY = "subClassName";
-    public static String SUB_PACKAGE_KEY = "subPackageName";
-    public static String BASE_CLASS_KEY = "baseClassName";
-    public static String BASE_PACKAGE_KEY = "basePackageName";
-    public static String CREATE_PROPERTY_NAMES = "createPropertyNames";
-
-    TemplateType[] getTemplateTypes(ArtifactGenerationMode mode);
-
-    String getQualifiedBaseClassName();
-
-    String getQualifiedClassName();
-
-    /**
-     * Returns a mapping metadata object for this artifact.
-     */
-    Object getObject();
-
-    /**
-     * A callback method that allows each artifact to add its own special keys to the
-     * context. Invoked from
-     * {@link ClassGenerationAction#resetContextForArtifactTemplate(Artifact, TemplateType)},
-     * after the context is initialized by code generator, so this method can use
-     * predefined keys from the context.
-     */
-    void postInitContext(VelocityContext context);
-}

http://git-wip-us.apache.org/repos/asf/cayenne/blob/c63b6be2/cayenne-tools/src/main/java/org/apache/cayenne/gen/ArtifactGenerationMode.java
----------------------------------------------------------------------
diff --git a/cayenne-tools/src/main/java/org/apache/cayenne/gen/ArtifactGenerationMode.java b/cayenne-tools/src/main/java/org/apache/cayenne/gen/ArtifactGenerationMode.java
deleted file mode 100644
index b0c20cc..0000000
--- a/cayenne-tools/src/main/java/org/apache/cayenne/gen/ArtifactGenerationMode.java
+++ /dev/null
@@ -1,28 +0,0 @@
-/*****************************************************************
- *   Licensed to the Apache Software Foundation (ASF) under one
- *  or more contributor license agreements.  See the NOTICE file
- *  distributed with this work for additional information
- *  regarding copyright ownership.  The ASF licenses this file
- *  to you under the Apache License, Version 2.0 (the
- *  "License"); you may not use this file except in compliance
- *  with the License.  You may obtain a copy of the License at
- *
- *    http://www.apache.org/licenses/LICENSE-2.0
- *
- *  Unless required by applicable law or agreed to in writing,
- *  software distributed under the License is distributed on an
- *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- *  KIND, either express or implied.  See the License for the
- *  specific language governing permissions and limitations
- *  under the License.
- ****************************************************************/
-package org.apache.cayenne.gen;
-
-/**
- * Code generator execution mode for a single artifact.
- * 
- * @since 3.0
- */
-public enum ArtifactGenerationMode {
-    SINGLE_CLASS, GENERATION_GAP
-}

http://git-wip-us.apache.org/repos/asf/cayenne/blob/c63b6be2/cayenne-tools/src/main/java/org/apache/cayenne/gen/ArtifactsGenerationMode.java
----------------------------------------------------------------------
diff --git a/cayenne-tools/src/main/java/org/apache/cayenne/gen/ArtifactsGenerationMode.java b/cayenne-tools/src/main/java/org/apache/cayenne/gen/ArtifactsGenerationMode.java
deleted file mode 100644
index e76c172..0000000
--- a/cayenne-tools/src/main/java/org/apache/cayenne/gen/ArtifactsGenerationMode.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*****************************************************************
- *   Licensed to the Apache Software Foundation (ASF) under one
- *  or more contributor license agreements.  See the NOTICE file
- *  distributed with this work for additional information
- *  regarding copyright ownership.  The ASF licenses this file
- *  to you under the Apache License, Version 2.0 (the
- *  "License"); you may not use this file except in compliance
- *  with the License.  You may obtain a copy of the License at
- *
- *    http://www.apache.org/licenses/LICENSE-2.0
- *
- *  Unless required by applicable law or agreed to in writing,
- *  software distributed under the License is distributed on an
- *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- *  KIND, either express or implied.  See the License for the
- *  specific language governing permissions and limitations
- *  under the License.
- ****************************************************************/
-package org.apache.cayenne.gen;
-
-/**
- * Code generator execution mode for a collection of artifacts.
- * 
- * @since 3.0
- */
-public enum ArtifactsGenerationMode {
-
-    // TODO: andrus 12/9/2007 - label names are old... need to call it something else...
-    DATAMAP("datamap"), ENTITY("entity"), ALL("all");
-
-    private String label;
-
-    private ArtifactsGenerationMode(String label) {
-        this.label = label;
-    }
-
-    public String getLabel() {
-        return label;
-    }
-}

http://git-wip-us.apache.org/repos/asf/cayenne/blob/c63b6be2/cayenne-tools/src/main/java/org/apache/cayenne/gen/ClassGenerationAction.java
----------------------------------------------------------------------
diff --git a/cayenne-tools/src/main/java/org/apache/cayenne/gen/ClassGenerationAction.java b/cayenne-tools/src/main/java/org/apache/cayenne/gen/ClassGenerationAction.java
deleted file mode 100644
index 9c5c932..0000000
--- a/cayenne-tools/src/main/java/org/apache/cayenne/gen/ClassGenerationAction.java
+++ /dev/null
@@ -1,584 +0,0 @@
-/*****************************************************************
- *   Licensed to the Apache Software Foundation (ASF) under one
- *  or more contributor license agreements.  See the NOTICE file
- *  distributed with this work for additional information
- *  regarding copyright ownership.  The ASF licenses this file
- *  to you under the Apache License, Version 2.0 (the
- *  "License"); you may not use this file except in compliance
- *  with the License.  You may obtain a copy of the License at
- *
- *    http://www.apache.org/licenses/LICENSE-2.0
- *
- *  Unless required by applicable law or agreed to in writing,
- *  software distributed under the License is distributed on an
- *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- *  KIND, either express or implied.  See the License for the
- *  specific language governing permissions and limitations
- *  under the License.
- ****************************************************************/
-package org.apache.cayenne.gen;
-
-import org.apache.cayenne.CayenneRuntimeException;
-import org.apache.cayenne.dbsync.filter.NamePatternMatcher;
-import org.apache.cayenne.map.DataMap;
-import org.apache.cayenne.map.Embeddable;
-import org.apache.cayenne.map.ObjEntity;
-import org.apache.cayenne.map.QueryDescriptor;
-import org.apache.commons.logging.Log;
-import org.apache.velocity.Template;
-import org.apache.velocity.VelocityContext;
-import org.apache.velocity.app.VelocityEngine;
-import org.apache.velocity.runtime.RuntimeConstants;
-import org.apache.velocity.runtime.log.NullLogSystem;
-
-import java.io.File;
-import java.io.FileOutputStream;
-import java.io.OutputStreamWriter;
-import java.io.Writer;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.Properties;
-
-public class ClassGenerationAction {
-	static final String TEMPLATES_DIR_NAME = "templates/v1_2/";
-
-	public static final String SINGLE_CLASS_TEMPLATE = TEMPLATES_DIR_NAME + "singleclass.vm";
-	public static final String SUBCLASS_TEMPLATE = TEMPLATES_DIR_NAME + "subclass.vm";
-	public static final String SUPERCLASS_TEMPLATE = TEMPLATES_DIR_NAME + "superclass.vm";
-
-	public static final String EMBEDDABLE_SINGLE_CLASS_TEMPLATE = TEMPLATES_DIR_NAME + "embeddable-singleclass.vm";
-	public static final String EMBEDDABLE_SUBCLASS_TEMPLATE = TEMPLATES_DIR_NAME + "embeddable-subclass.vm";
-	public static final String EMBEDDABLE_SUPERCLASS_TEMPLATE = TEMPLATES_DIR_NAME + "embeddable-superclass.vm";
-
-	public static final String DATAMAP_SINGLE_CLASS_TEMPLATE = TEMPLATES_DIR_NAME + "datamap-singleclass.vm";
-	public static final String DATAMAP_SUBCLASS_TEMPLATE = TEMPLATES_DIR_NAME + "datamap-subclass.vm";
-	public static final String DATAMAP_SUPERCLASS_TEMPLATE = TEMPLATES_DIR_NAME + "datamap-superclass.vm";
-
-	public static final String SUPERCLASS_PREFIX = "_";
-	private static final String WILDCARD = "*";
-
-	protected Collection<Artifact> artifacts;
-
-	protected String superPkg;
-	protected DataMap dataMap;
-
-	protected ArtifactsGenerationMode artifactsGenerationMode;
-	protected boolean makePairs;
-
-	protected Log logger;
-	protected File destDir;
-	protected boolean overwrite;
-	protected boolean usePkgPath;
-
-	protected String template;
-	protected String superTemplate;
-	protected String embeddableTemplate;
-	protected String embeddableSuperTemplate;
-	protected String queryTemplate;
-	protected String querySuperTemplate;
-	protected long timestamp;
-	protected String outputPattern;
-	protected String encoding;
-	protected boolean createPropertyNames;
-
-	// runtime ivars
-	protected VelocityContext context;
-	protected Map<String, Template> templateCache;
-
-	public ClassGenerationAction() {
-		this.outputPattern = "*.java";
-		this.timestamp = System.currentTimeMillis();
-		this.usePkgPath = true;
-		this.makePairs = true;
-		this.context = new VelocityContext();
-		this.templateCache = new HashMap<>(5);
-
-		this.artifacts = new ArrayList<>();
-	}
-
-	protected String defaultTemplateName(TemplateType type) {
-		switch (type) {
-		case ENTITY_SINGLE_CLASS:
-			return ClassGenerationAction.SINGLE_CLASS_TEMPLATE;
-		case ENTITY_SUBCLASS:
-			return ClassGenerationAction.SUBCLASS_TEMPLATE;
-		case ENTITY_SUPERCLASS:
-			return ClassGenerationAction.SUPERCLASS_TEMPLATE;
-		case EMBEDDABLE_SUBCLASS:
-			return ClassGenerationAction.EMBEDDABLE_SUBCLASS_TEMPLATE;
-		case EMBEDDABLE_SUPERCLASS:
-			return ClassGenerationAction.EMBEDDABLE_SUPERCLASS_TEMPLATE;
-		case EMBEDDABLE_SINGLE_CLASS:
-			return ClassGenerationAction.EMBEDDABLE_SINGLE_CLASS_TEMPLATE;
-		case DATAMAP_SINGLE_CLASS:
-			return ClassGenerationAction.DATAMAP_SINGLE_CLASS_TEMPLATE;
-		case DATAMAP_SUPERCLASS:
-			return ClassGenerationAction.DATAMAP_SUPERCLASS_TEMPLATE;
-		case DATAMAP_SUBCLASS:
-			return ClassGenerationAction.DATAMAP_SUBCLASS_TEMPLATE;
-		default:
-			throw new IllegalArgumentException("Invalid template type: " + type);
-		}
-	}
-
-	protected String customTemplateName(TemplateType type) {
-		switch (type) {
-		case ENTITY_SINGLE_CLASS:
-			return template;
-		case ENTITY_SUBCLASS:
-			return template;
-		case ENTITY_SUPERCLASS:
-			return superTemplate;
-		case EMBEDDABLE_SUBCLASS:
-			return embeddableTemplate;
-		case EMBEDDABLE_SUPERCLASS:
-			return embeddableSuperTemplate;
-		case DATAMAP_SINGLE_CLASS:
-			return queryTemplate;
-		case DATAMAP_SUPERCLASS:
-			return querySuperTemplate;
-		case DATAMAP_SUBCLASS:
-			return queryTemplate;
-		default:
-			throw new IllegalArgumentException("Invalid template type: " + type);
-		}
-	}
-
-	/**
-	 * Returns a String used to prefix class name to create a generated
-	 * superclass. Default value is "_".
-	 */
-	protected String getSuperclassPrefix() {
-		return ClassGenerationAction.SUPERCLASS_PREFIX;
-	}
-
-	/**
-	 * VelocityContext initialization method called once per artifact.
-	 */
-	protected void resetContextForArtifact(Artifact artifact) {
-		StringUtils stringUtils = StringUtils.getInstance();
-
-		String qualifiedClassName = artifact.getQualifiedClassName();
-		String packageName = stringUtils.stripClass(qualifiedClassName);
-		String className = stringUtils.stripPackageName(qualifiedClassName);
-
-		String qualifiedBaseClassName = artifact.getQualifiedBaseClassName();
-		String basePackageName = stringUtils.stripClass(qualifiedBaseClassName);
-		String baseClassName = stringUtils.stripPackageName(qualifiedBaseClassName);
-
-		String superClassName = getSuperclassPrefix() + stringUtils.stripPackageName(qualifiedClassName);
-
-		String superPackageName = this.superPkg;
-		if (superPackageName == null) {
-			superPackageName = packageName + ".auto";
-		}
-
-		context.put(Artifact.BASE_CLASS_KEY, baseClassName);
-		context.put(Artifact.BASE_PACKAGE_KEY, basePackageName);
-
-		context.put(Artifact.SUB_CLASS_KEY, className);
-		context.put(Artifact.SUB_PACKAGE_KEY, packageName);
-
-		context.put(Artifact.SUPER_CLASS_KEY, superClassName);
-		context.put(Artifact.SUPER_PACKAGE_KEY, superPackageName);
-
-		context.put(Artifact.OBJECT_KEY, artifact.getObject());
-		context.put(Artifact.STRING_UTILS_KEY, stringUtils);
-
-		context.put(Artifact.CREATE_PROPERTY_NAMES, createPropertyNames);
-	}
-
-	/**
-	 * VelocityContext initialization method called once per each artifact and
-	 * template type combination.
-	 */
-	protected void resetContextForArtifactTemplate(Artifact artifact, TemplateType templateType) {
-		context.put(Artifact.IMPORT_UTILS_KEY, new ImportUtils());
-		artifact.postInitContext(context);
-	}
-
-	/**
-	 * Executes class generation once per each artifact.
-	 */
-	public void execute() throws Exception {
-
-		validateAttributes();
-
-		try {
-			for (Artifact artifact : artifacts) {
-				execute(artifact);
-			}
-		} finally {
-			// must reset engine at the end of class generator run to avoid
-			// memory
-			// leaks and stale templates
-			this.templateCache.clear();
-		}
-	}
-
-	/**
-	 * Executes class generation for a single artifact.
-	 */
-	protected void execute(Artifact artifact) throws Exception {
-
-		resetContextForArtifact(artifact);
-
-		ArtifactGenerationMode artifactMode = makePairs ? ArtifactGenerationMode.GENERATION_GAP
-				: ArtifactGenerationMode.SINGLE_CLASS;
-
-		TemplateType[] templateTypes = artifact.getTemplateTypes(artifactMode);
-		for (TemplateType type : templateTypes) {
-
-			try (Writer out = openWriter(type);) {
-				if (out != null) {
-
-					resetContextForArtifactTemplate(artifact, type);
-					getTemplate(type).merge(context, out);
-				}
-			}
-		}
-	}
-
-	protected Template getTemplate(TemplateType type) throws Exception {
-
-		String templateName = customTemplateName(type);
-		if (templateName == null) {
-			templateName = defaultTemplateName(type);
-		}
-
-		// Velocity < 1.5 has some memory problems, so we will create a
-		// VelocityEngine
-		// every time, and store templates in an internal cache, to avoid
-		// uncontrolled
-		// memory leaks... Presumably 1.5 fixes it.
-
-		Template template = templateCache.get(templateName);
-
-		if (template == null) {
-
-			Properties props = new Properties();
-
-			// null logger that will prevent velocity.log from being generated
-			props.put(RuntimeConstants.RUNTIME_LOG_LOGSYSTEM_CLASS, NullLogSystem.class.getName());
-			props.put("resource.loader", "cayenne");
-			props.put("cayenne.resource.loader.class", ClassGeneratorResourceLoader.class.getName());
-			props.put("cayenne.resource.loader.cache", "false");
-
-			VelocityEngine velocityEngine = new VelocityEngine();
-			velocityEngine.init(props);
-
-			template = velocityEngine.getTemplate(templateName);
-			templateCache.put(templateName, template);
-		}
-
-		return template;
-	}
-
-	/**
-	 * Validates the state of this class generator. Throws
-	 * CayenneRuntimeException if it is in an inconsistent state. Called
-	 * internally from "execute".
-	 */
-	protected void validateAttributes() {
-		if (destDir == null) {
-			throw new CayenneRuntimeException("'destDir' attribute is missing.");
-		}
-
-		if (!destDir.isDirectory()) {
-			throw new CayenneRuntimeException("'destDir' is not a directory.");
-		}
-
-		if (!destDir.canWrite()) {
-			throw new CayenneRuntimeException("Do not have write permissions for " + destDir);
-		}
-	}
-
-	/**
-	 * Sets the destDir.
-	 */
-	public void setDestDir(File destDir) {
-		this.destDir = destDir;
-	}
-
-	/**
-	 * Sets <code>overwrite</code> property.
-	 */
-	public void setOverwrite(boolean overwrite) {
-		this.overwrite = overwrite;
-	}
-
-	/**
-	 * Sets <code>makepairs</code> property.
-	 */
-	public void setMakePairs(boolean makePairs) {
-		this.makePairs = makePairs;
-	}
-
-	/**
-	 * Sets <code>template</code> property.
-	 */
-	public void setTemplate(String template) {
-		this.template = template;
-	}
-
-	/**
-	 * Sets <code>superTemplate</code> property.
-	 */
-	public void setSuperTemplate(String superTemplate) {
-		this.superTemplate = superTemplate;
-	}
-
-	public void setQueryTemplate(String queryTemplate) {
-		this.queryTemplate = queryTemplate;
-	}
-
-	public void setQuerySuperTemplate(String querySuperTemplate) {
-		this.querySuperTemplate = querySuperTemplate;
-	}
-
-	/**
-	 * Sets <code>usepkgpath</code> property.
-	 */
-	public void setUsePkgPath(boolean usePkgPath) {
-		this.usePkgPath = usePkgPath;
-	}
-
-	/**
-	 * Sets <code>outputPattern</code> property.
-	 */
-	public void setOutputPattern(String outputPattern) {
-		this.outputPattern = outputPattern;
-	}
-
-	/**
-	 * Sets <code>createPropertyNames</code> property.
-	 */
-	public void setCreatePropertyNames(boolean createPropertyNames) {
-		this.createPropertyNames = createPropertyNames;
-	}
-
-	/**
-	 * Opens a Writer to write generated output. Returned Writer is mapped to a
-	 * filesystem file (although subclasses may override that). File location is
-	 * determined from the current state of VelocityContext and the TemplateType
-	 * passed as a parameter. Writer encoding is determined from the value of
-	 * the "encoding" property.
-	 */
-	protected Writer openWriter(TemplateType templateType) throws Exception {
-
-		File outFile = (templateType.isSuperclass()) ? fileForSuperclass() : fileForClass();
-		if (outFile == null) {
-			return null;
-		}
-
-		if (logger != null) {
-			String label = templateType.isSuperclass() ? "superclass" : "class";
-			logger.info("Generating " + label + " file: " + outFile.getCanonicalPath());
-		}
-
-		// return writer with specified encoding
-		FileOutputStream out = new FileOutputStream(outFile);
-
-		return (encoding != null) ? new OutputStreamWriter(out, encoding) : new OutputStreamWriter(out);
-	}
-
-	/**
-	 * Returns a target file where a generated superclass must be saved. If null
-	 * is returned, class shouldn't be generated.
-	 */
-	protected File fileForSuperclass() throws Exception {
-
-		String packageName = (String) context.get(Artifact.SUPER_PACKAGE_KEY);
-		String className = (String) context.get(Artifact.SUPER_CLASS_KEY);
-
-		String filename = NamePatternMatcher.replaceWildcardInStringWithString(WILDCARD, outputPattern, className);
-		File dest = new File(mkpath(destDir, packageName), filename);
-
-		// Ignore if the destination is newer than the map
-		// (internal timestamp), i.e. has been generated after the map was
-		// last saved AND the template is older than the destination file
-		if (dest.exists() && !isOld(dest)) {
-
-			if (superTemplate == null) {
-				return null;
-			}
-
-			File superTemplateFile = new File(superTemplate);
-			if (superTemplateFile.lastModified() < dest.lastModified()) {
-				return null;
-			}
-		}
-
-		return dest;
-	}
-
-	/**
-	 * Returns a target file where a generated class must be saved. If null is
-	 * returned, class shouldn't be generated.
-	 */
-	protected File fileForClass() throws Exception {
-
-		String packageName = (String) context.get(Artifact.SUB_PACKAGE_KEY);
-		String className = (String) context.get(Artifact.SUB_CLASS_KEY);
-
-		String filename = NamePatternMatcher.replaceWildcardInStringWithString(WILDCARD, outputPattern, className);
-		File dest = new File(mkpath(destDir, packageName), filename);
-
-		if (dest.exists()) {
-			// no overwrite of subclasses
-			if (makePairs) {
-				return null;
-			}
-
-			// skip if said so
-			if (!overwrite) {
-				return null;
-			}
-
-			// Ignore if the destination is newer than the map
-			// (internal timestamp), i.e. has been generated after the map was
-			// last saved AND the template is older than the destination file
-			if (!isOld(dest)) {
-
-				if (template == null) {
-					return null;
-				}
-
-				File templateFile = new File(template);
-				if (templateFile.lastModified() < dest.lastModified()) {
-					return null;
-				}
-			}
-		}
-
-		return dest;
-	}
-
-	/**
-	 * Returns true if <code>file</code> parameter is older than internal
-	 * timestamp of this class generator.
-	 */
-	protected boolean isOld(File file) {
-		return file.lastModified() <= timestamp;
-	}
-
-	/**
-	 * Returns a File object corresponding to a directory where files that
-	 * belong to <code>pkgName</code> package should reside. Creates any missing
-	 * diectories below <code>dest</code>.
-	 */
-	protected File mkpath(File dest, String pkgName) throws Exception {
-
-		if (!usePkgPath || pkgName == null) {
-			return dest;
-		}
-
-		String path = pkgName.replace('.', File.separatorChar);
-		File fullPath = new File(dest, path);
-		if (!fullPath.isDirectory() && !fullPath.mkdirs()) {
-			throw new Exception("Error making path: " + fullPath);
-		}
-
-		return fullPath;
-	}
-
-	public void setTimestamp(long timestamp) {
-		this.timestamp = timestamp;
-	}
-
-	/**
-	 * Sets file encoding. If set to null, default system encoding will be used.
-	 */
-	public void setEncoding(String encoding) {
-		this.encoding = encoding;
-	}
-
-	/**
-	 * Sets "superPkg" property value.
-	 */
-	public void setSuperPkg(String superPkg) {
-		this.superPkg = superPkg;
-	}
-
-	/**
-	 * @param dataMap
-	 *            The dataMap to set.
-	 */
-	public void setDataMap(DataMap dataMap) {
-		this.dataMap = dataMap;
-	}
-
-	/**
-	 * Adds entities to the internal entity list.
-	 */
-	public void addEntities(Collection<ObjEntity> entities) {
-		if (artifactsGenerationMode == ArtifactsGenerationMode.ENTITY
-				|| artifactsGenerationMode == ArtifactsGenerationMode.ALL) {
-			if (entities != null) {
-				for (ObjEntity entity : entities) {
-					artifacts.add(new EntityArtifact(entity));
-				}
-			}
-		}
-	}
-
-	public void addEmbeddables(Collection<Embeddable> embeddables) {
-		if (artifactsGenerationMode == ArtifactsGenerationMode.ENTITY
-				|| artifactsGenerationMode == ArtifactsGenerationMode.ALL) {
-			if (embeddables != null) {
-				for (Embeddable embeddable : embeddables) {
-					artifacts.add(new EmbeddableArtifact(embeddable));
-				}
-			}
-		}
-	}
-
-	public void addQueries(Collection<QueryDescriptor> queries) {
-		if (artifactsGenerationMode == ArtifactsGenerationMode.DATAMAP
-				|| artifactsGenerationMode == ArtifactsGenerationMode.ALL) {
-
-			// TODO: andrus 10.12.2010 - why not also check for empty query
-			// list?? Or
-			// create a better API for enabling DataMapArtifact
-			if (queries != null) {
-				artifacts.add(new DataMapArtifact(dataMap, queries));
-			}
-		}
-	}
-
-	/**
-	 * Sets an optional shared VelocityContext. Useful with tools like VPP that
-	 * can set custom values in the context, not known to Cayenne.
-	 */
-	public void setContext(VelocityContext context) {
-		this.context = context;
-	}
-
-	/**
-	 * Injects an optional logger that will be used to trace generated files at
-	 * the info level.
-	 */
-	public void setLogger(Log logger) {
-		this.logger = logger;
-	}
-
-	public void setEmbeddableTemplate(String embeddableTemplate) {
-		this.embeddableTemplate = embeddableTemplate;
-	}
-
-	public void setEmbeddableSuperTemplate(String embeddableSuperTemplate) {
-		this.embeddableSuperTemplate = embeddableSuperTemplate;
-	}
-
-	public void setArtifactsGenerationMode(String mode) {
-		if (ArtifactsGenerationMode.ENTITY.getLabel().equalsIgnoreCase(mode)) {
-			this.artifactsGenerationMode = ArtifactsGenerationMode.ENTITY;
-		} else if (ArtifactsGenerationMode.DATAMAP.getLabel().equalsIgnoreCase(mode)) {
-			this.artifactsGenerationMode = ArtifactsGenerationMode.DATAMAP;
-		} else {
-			this.artifactsGenerationMode = ArtifactsGenerationMode.ALL;
-		}
-	}
-}

http://git-wip-us.apache.org/repos/asf/cayenne/blob/c63b6be2/cayenne-tools/src/main/java/org/apache/cayenne/gen/ClassGeneratorResourceLoader.java
----------------------------------------------------------------------
diff --git a/cayenne-tools/src/main/java/org/apache/cayenne/gen/ClassGeneratorResourceLoader.java b/cayenne-tools/src/main/java/org/apache/cayenne/gen/ClassGeneratorResourceLoader.java
deleted file mode 100644
index 8e8a1ee..0000000
--- a/cayenne-tools/src/main/java/org/apache/cayenne/gen/ClassGeneratorResourceLoader.java
+++ /dev/null
@@ -1,102 +0,0 @@
-/*****************************************************************
- *   Licensed to the Apache Software Foundation (ASF) under one
- *  or more contributor license agreements.  See the NOTICE file
- *  distributed with this work for additional information
- *  regarding copyright ownership.  The ASF licenses this file
- *  to you under the Apache License, Version 2.0 (the
- *  "License"); you may not use this file except in compliance
- *  with the License.  You may obtain a copy of the License at
- *
- *    http://www.apache.org/licenses/LICENSE-2.0
- *
- *  Unless required by applicable law or agreed to in writing,
- *  software distributed under the License is distributed on an
- *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- *  KIND, either express or implied.  See the License for the
- *  specific language governing permissions and limitations
- *  under the License.
- ****************************************************************/
-
-package org.apache.cayenne.gen;
-
-import java.io.BufferedInputStream;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileNotFoundException;
-import java.io.InputStream;
-
-import org.apache.velocity.exception.ResourceNotFoundException;
-import org.apache.velocity.runtime.resource.loader.FileResourceLoader;
-
-/**
- * Velocity template resource loader customized for Cayenne use. Supports loading
- * templates from the thread ClassLoader and from relative and absolute paths.
- * 
- * @since 1.2
- */
-// must be public top-level class as it is
-// instantiated via reflection by Velocity
-public class ClassGeneratorResourceLoader extends FileResourceLoader {
-
-    /**
-     * Returns resource as InputStream. First calls super implementation. If resource
-     * wasn't found, it attempts to load it from current directory or as an absolute path.
-     */
-    @Override
-    public synchronized InputStream getResourceStream(String name)
-            throws ResourceNotFoundException {
-
-        InputStream stream = loadFromRelativePath(name);
-        if (stream != null) {
-            return stream;
-        }
-
-        stream = loadFromAbsPath(name);
-        if (stream != null) {
-            return stream;
-        }
-
-        stream = loadFromThreadClassLoader(name);
-        if (stream != null) {
-            return stream;
-        }
-
-        stream = loadFromThisClassLoader(name);
-        if (stream != null) {
-            return stream;
-        }
-
-        throw new ResourceNotFoundException("Couldn't find resource '"
-                + name
-                + "'. Searched filesystem path and classpath");
-    }
-
-    protected InputStream loadFromRelativePath(String name) {
-        try {
-            return super.getResourceStream(name);
-        }
-        catch (ResourceNotFoundException rnfex) {
-            return null;
-        }
-    }
-
-    protected InputStream loadFromAbsPath(String name) {
-        try {
-            File file = new File(name);
-            return (file.canRead()) ? new BufferedInputStream(new FileInputStream(file
-                    .getAbsolutePath())) : null;
-
-        }
-        catch (FileNotFoundException fnfe) {
-            return null;
-        }
-    }
-
-    protected InputStream loadFromThreadClassLoader(String name) {
-        return Thread.currentThread().getContextClassLoader().getResourceAsStream(name);
-    }
-
-    protected InputStream loadFromThisClassLoader(String name) {
-        return getClass().getClassLoader().getResourceAsStream(name);
-    }
-}

http://git-wip-us.apache.org/repos/asf/cayenne/blob/c63b6be2/cayenne-tools/src/main/java/org/apache/cayenne/gen/ClientClassGenerationAction.java
----------------------------------------------------------------------
diff --git a/cayenne-tools/src/main/java/org/apache/cayenne/gen/ClientClassGenerationAction.java b/cayenne-tools/src/main/java/org/apache/cayenne/gen/ClientClassGenerationAction.java
deleted file mode 100644
index f36fd68..0000000
--- a/cayenne-tools/src/main/java/org/apache/cayenne/gen/ClientClassGenerationAction.java
+++ /dev/null
@@ -1,79 +0,0 @@
-/*****************************************************************
- *   Licensed to the Apache Software Foundation (ASF) under one
- *  or more contributor license agreements.  See the NOTICE file
- *  distributed with this work for additional information
- *  regarding copyright ownership.  The ASF licenses this file
- *  to you under the Apache License, Version 2.0 (the
- *  "License"); you may not use this file except in compliance
- *  with the License.  You may obtain a copy of the License at
- *
- *    http://www.apache.org/licenses/LICENSE-2.0
- *
- *  Unless required by applicable law or agreed to in writing,
- *  software distributed under the License is distributed on an
- *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- *  KIND, either express or implied.  See the License for the
- *  specific language governing permissions and limitations
- *  under the License.
- ****************************************************************/
-package org.apache.cayenne.gen;
-
-import java.util.Collection;
-
-import org.apache.cayenne.map.ObjEntity;
-import org.apache.cayenne.map.QueryDescriptor;
-
-/**
- * @since 3.0
- */
-public class ClientClassGenerationAction extends ClassGenerationAction {
-
-    public static final String SUBCLASS_TEMPLATE = TEMPLATES_DIR_NAME + "client-subclass.vm";
-    public static final String SUPERCLASS_TEMPLATE = TEMPLATES_DIR_NAME + "client-superclass.vm";
-    
-    public static final String DMAP_SINGLE_CLASS_TEMPLATE = TEMPLATES_DIR_NAME + "client-datamap-singleclass.vm";
-    public static final String DMAP_SUBCLASS_TEMPLATE = TEMPLATES_DIR_NAME + "client-datamap-subclass.vm";
-    public static final String DMAP_SUPERCLASS_TEMPLATE = TEMPLATES_DIR_NAME + "client-datamap-superclass.vm";
-    
-    public static final String CLIENT_SUPERCLASS_PREFIX = "_Client";
-
-    @Override
-    protected String defaultTemplateName(TemplateType type) {
-        switch (type) {
-            case ENTITY_SUBCLASS:
-                return ClientClassGenerationAction.SUBCLASS_TEMPLATE;
-            case ENTITY_SUPERCLASS:
-                return ClientClassGenerationAction.SUPERCLASS_TEMPLATE;
-            case EMBEDDABLE_SUBCLASS:
-                return ClassGenerationAction.EMBEDDABLE_SUBCLASS_TEMPLATE;
-            case EMBEDDABLE_SUPERCLASS:
-                return ClassGenerationAction.EMBEDDABLE_SUPERCLASS_TEMPLATE;
-            
-            case DATAMAP_SUPERCLASS:
-                return ClientClassGenerationAction.DMAP_SUPERCLASS_TEMPLATE;
-            case DATAMAP_SUBCLASS:
-                return ClientClassGenerationAction.DMAP_SUBCLASS_TEMPLATE;
-            default:
-                throw new IllegalArgumentException("Unsupported template type: " + type);
-        }
-    }
-
-    @Override
-    public void addEntities(Collection<ObjEntity> entities) {
-        if (entities != null) {
-            for (ObjEntity entity : entities) {
-                artifacts.add(new ClientEntityArtifact(entity));
-            }
-        }
-    }
-
-    @Override
-    public void addQueries(Collection<QueryDescriptor> queries) {
-        if (artifactsGenerationMode == ArtifactsGenerationMode.DATAMAP
-                || artifactsGenerationMode == ArtifactsGenerationMode.ALL) {
-            if (queries != null) {
-                artifacts.add(new ClientDataMapArtifact(dataMap, queries));
-            }
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/cayenne/blob/c63b6be2/cayenne-tools/src/main/java/org/apache/cayenne/gen/ClientDataMapArtifact.java
----------------------------------------------------------------------
diff --git a/cayenne-tools/src/main/java/org/apache/cayenne/gen/ClientDataMapArtifact.java b/cayenne-tools/src/main/java/org/apache/cayenne/gen/ClientDataMapArtifact.java
deleted file mode 100644
index a9d1dfe..0000000
--- a/cayenne-tools/src/main/java/org/apache/cayenne/gen/ClientDataMapArtifact.java
+++ /dev/null
@@ -1,50 +0,0 @@
-/*****************************************************************
- *   Licensed to the Apache Software Foundation (ASF) under one
- *  or more contributor license agreements.  See the NOTICE file
- *  distributed with this work for additional information
- *  regarding copyright ownership.  The ASF licenses this file
- *  to you under the Apache License, Version 2.0 (the
- *  "License"); you may not use this file except in compliance
- *  with the License.  You may obtain a copy of the License at
- *
- *    http://www.apache.org/licenses/LICENSE-2.0
- *
- *  Unless required by applicable law or agreed to in writing,
- *  software distributed under the License is distributed on an
- *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- *  KIND, either express or implied.  See the License for the
- *  specific language governing permissions and limitations
- *  under the License.
- ****************************************************************/
-
-package org.apache.cayenne.gen;
-
-import org.apache.cayenne.map.DataMap;
-import org.apache.cayenne.map.QueryDescriptor;
-import org.apache.cayenne.util.Util;
-
-import java.util.Collection;
-
-public class ClientDataMapArtifact extends DataMapArtifact {
-
-    public ClientDataMapArtifact(DataMap dataMap, Collection<QueryDescriptor> queries) {
-        super(dataMap, queries);
-
-    }
-
-    @Override
-    public String getQualifiedBaseClassName() {
-
-        return dataMap.getDefaultClientSuperclass();
-    }
-
-    @Override
-    public String getQualifiedClassName() {
-        String clientPrefix = "";
-        if (Util.nullSafeEquals(dataMap.getDefaultClientPackage(), dataMap.getDefaultPackage())) {
-            clientPrefix = "Client_";
-        }
-
-        return dataMap.getNameWithDefaultClientPackage(Util.underscoredToJava(clientPrefix + dataMap.getName(), true));
-    }
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/cayenne/blob/c63b6be2/cayenne-tools/src/main/java/org/apache/cayenne/gen/ClientEntityArtifact.java
----------------------------------------------------------------------
diff --git a/cayenne-tools/src/main/java/org/apache/cayenne/gen/ClientEntityArtifact.java b/cayenne-tools/src/main/java/org/apache/cayenne/gen/ClientEntityArtifact.java
deleted file mode 100644
index d20a2d4..0000000
--- a/cayenne-tools/src/main/java/org/apache/cayenne/gen/ClientEntityArtifact.java
+++ /dev/null
@@ -1,45 +0,0 @@
-/*****************************************************************
- *   Licensed to the Apache Software Foundation (ASF) under one
- *  or more contributor license agreements.  See the NOTICE file
- *  distributed with this work for additional information
- *  regarding copyright ownership.  The ASF licenses this file
- *  to you under the Apache License, Version 2.0 (the
- *  "License"); you may not use this file except in compliance
- *  with the License.  You may obtain a copy of the License at
- *
- *    http://www.apache.org/licenses/LICENSE-2.0
- *
- *  Unless required by applicable law or agreed to in writing,
- *  software distributed under the License is distributed on an
- *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- *  KIND, either express or implied.  See the License for the
- *  specific language governing permissions and limitations
- *  under the License.
- ****************************************************************/
-package org.apache.cayenne.gen;
-
-import org.apache.cayenne.PersistentObject;
-import org.apache.cayenne.map.ObjEntity;
-
-/**
- * Client code generation artifact based on ObjEntity.
- * 
- * @since 3.0
- */
-public class ClientEntityArtifact extends EntityArtifact {
-
-    public ClientEntityArtifact(ObjEntity entity) {
-        super(entity);
-    }
-
-    @Override
-    public String getQualifiedBaseClassName() {
-        return (entity.getClientSuperClassName() != null) ? entity
-                .getClientSuperClassName() : PersistentObject.class.getName();
-    }
-
-    @Override
-    public String getQualifiedClassName() {
-        return entity.getClientClassName();
-    }
-}

http://git-wip-us.apache.org/repos/asf/cayenne/blob/c63b6be2/cayenne-tools/src/main/java/org/apache/cayenne/gen/DataMapArtifact.java
----------------------------------------------------------------------
diff --git a/cayenne-tools/src/main/java/org/apache/cayenne/gen/DataMapArtifact.java b/cayenne-tools/src/main/java/org/apache/cayenne/gen/DataMapArtifact.java
deleted file mode 100644
index 8e60495..0000000
--- a/cayenne-tools/src/main/java/org/apache/cayenne/gen/DataMapArtifact.java
+++ /dev/null
@@ -1,137 +0,0 @@
-/*****************************************************************
- *   Licensed to the Apache Software Foundation (ASF) under one
- *  or more contributor license agreements.  See the NOTICE file
- *  distributed with this work for additional information
- *  regarding copyright ownership.  The ASF licenses this file
- *  to you under the Apache License, Version 2.0 (the
- *  "License"); you may not use this file except in compliance
- *  with the License.  You may obtain a copy of the License at
- *
- *    http://www.apache.org/licenses/LICENSE-2.0
- *
- *  Unless required by applicable law or agreed to in writing,
- *  software distributed under the License is distributed on an
- *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- *  KIND, either express or implied.  See the License for the
- *  specific language governing permissions and limitations
- *  under the License.
- ****************************************************************/
-
-package org.apache.cayenne.gen;
-
-import org.apache.cayenne.map.DataMap;
-import org.apache.cayenne.map.QueryDescriptor;
-import org.apache.cayenne.util.Util;
-import org.apache.velocity.VelocityContext;
-
-import java.util.Collection;
-import java.util.LinkedList;
-
-/**
- * {@link Artifact} facade for a DataMap.
- * 
- * @since 3.0
- */
-public class DataMapArtifact implements Artifact {
-
-    public static final String DATAMAP_UTILS_KEY = "dataMapUtils";
-
-    protected DataMap dataMap;
-    protected Collection<QueryDescriptor> selectQueries;
-    protected Collection<QueryDescriptor> sqlTemplateQueries;
-    protected Collection<QueryDescriptor> procedureQueries;
-    protected Collection<QueryDescriptor> ejbqlQueries;
-    protected Collection<String> queryNames;
-
-    public DataMapArtifact(DataMap dataMap, Collection<QueryDescriptor> queries) {
-        this.dataMap = dataMap;
-        selectQueries = new LinkedList<>();
-        sqlTemplateQueries = new LinkedList<>();
-        procedureQueries = new LinkedList<>();
-        ejbqlQueries = new LinkedList<>();
-        queryNames = new LinkedList<>();
-        addQueries(queries);
-    }
-
-    public String getQualifiedBaseClassName() {
-        return Object.class.getName();
-    }
-
-    public String getQualifiedClassName() {
-        return dataMap.getNameWithDefaultPackage(Util.underscoredToJava(dataMap.getName(), true));
-    }
-
-    public Object getObject() {
-        return this;
-    }
-
-    public void postInitContext(VelocityContext context) {
-        DataMapUtils dataMapUtils = new DataMapUtils();
-        context.put(DATAMAP_UTILS_KEY, dataMapUtils);
-    }
-
-    public TemplateType[] getTemplateTypes(ArtifactGenerationMode mode) {
-        switch (mode) {
-            case SINGLE_CLASS:
-                return new TemplateType[] {
-                    TemplateType.DATAMAP_SINGLE_CLASS
-                };
-            case GENERATION_GAP:
-                return new TemplateType[] {
-                        TemplateType.DATAMAP_SUPERCLASS, TemplateType.DATAMAP_SUBCLASS
-                };
-            default:
-                return new TemplateType[0];
-        }
-    }
-
-    private void addQueries(Collection<QueryDescriptor> queries) {
-        if (queries != null) {
-            for (QueryDescriptor query : queries) {
-                addQuery(query);
-            }
-        }
-    }
-
-    private void addQuery(QueryDescriptor query) {
-
-        switch (query.getType()) {
-            case QueryDescriptor.SELECT_QUERY:
-                selectQueries.add(query);
-                break;
-            case QueryDescriptor.PROCEDURE_QUERY:
-                procedureQueries.add(query);
-                break;
-            case QueryDescriptor.SQL_TEMPLATE:
-                sqlTemplateQueries.add(query);
-                break;
-            case QueryDescriptor.EJBQL_QUERY:
-                ejbqlQueries.add(query);
-                break;
-        }
-
-        if (query.getName() != null && !"".equals(query.getName())) {
-            queryNames.add(query.getName());
-        }
-    }
-
-    public Collection<QueryDescriptor> getSelectQueries() {
-        return selectQueries;
-    }
-
-    public boolean hasSelectQueries() {
-        return selectQueries.size() > 0;
-    }
-
-    public boolean hasQueryNames() {
-        return !queryNames.isEmpty();
-    }
-
-    public Collection<String> getQueryNames() {
-        return queryNames;
-    }
-
-    public DataMap getDataMap() {
-    	return dataMap;
-    }
-}

http://git-wip-us.apache.org/repos/asf/cayenne/blob/c63b6be2/cayenne-tools/src/main/java/org/apache/cayenne/gen/DataMapUtils.java
----------------------------------------------------------------------
diff --git a/cayenne-tools/src/main/java/org/apache/cayenne/gen/DataMapUtils.java b/cayenne-tools/src/main/java/org/apache/cayenne/gen/DataMapUtils.java
deleted file mode 100644
index a0013cc..0000000
--- a/cayenne-tools/src/main/java/org/apache/cayenne/gen/DataMapUtils.java
+++ /dev/null
@@ -1,219 +0,0 @@
-/*****************************************************************
- *   Licensed to the Apache Software Foundation (ASF) under one
- *  or more contributor license agreements.  See the NOTICE file
- *  distributed with this work for additional information
- *  regarding copyright ownership.  The ASF licenses this file
- *  to you under the Apache License, Version 2.0 (the
- *  "License"); you may not use this file except in compliance
- *  with the License.  You may obtain a copy of the License at
- *
- *    http://www.apache.org/licenses/LICENSE-2.0
- *
- *  Unless required by applicable law or agreed to in writing,
- *  software distributed under the License is distributed on an
- *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- *  KIND, either express or implied.  See the License for the
- *  specific language governing permissions and limitations
- *  under the License.
- ****************************************************************/
-
-package org.apache.cayenne.gen;
-
-import org.apache.cayenne.exp.Expression;
-import org.apache.cayenne.exp.ExpressionException;
-import org.apache.cayenne.exp.ExpressionParameter;
-import org.apache.cayenne.exp.parser.ASTList;
-import org.apache.cayenne.exp.parser.ASTObjPath;
-import org.apache.cayenne.map.Entity;
-import org.apache.cayenne.map.ObjAttribute;
-import org.apache.cayenne.map.ObjEntity;
-import org.apache.cayenne.map.ObjRelationship;
-import org.apache.cayenne.map.PathComponent;
-import org.apache.cayenne.map.QueryDescriptor;
-import org.apache.cayenne.map.SelectQueryDescriptor;
-import org.apache.cayenne.query.Ordering;
-import org.apache.cayenne.util.CayenneMapEntry;
-import org.apache.cayenne.util.Util;
-import org.apache.commons.collections.set.ListOrderedSet;
-
-import java.util.Collection;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-
-/**
- * Attributes and Methods for working with Queries.
- *
- * @since 3.0
- */
-public class DataMapUtils {
-
-	Map<String, Map<String, String>> queriesMap = new HashMap<>();
-
-	/**
-	 * Return valid method name based on query name (replace all illegal
-	 * characters with underscore '_').
-	 * 
-	 * @param query
-	 * @return Method name that perform query.
-	 */
-	public String getQueryMethodName(QueryDescriptor query) {
-		return Util.underscoredToJava(query.getName(), true);
-	}
-
-	/**
-	 * Get all parameter names that used in query qualifier.
-	 *
-	 * @param query
-	 * @return Parameter names.
-	 */
-	public Collection getParameterNames(SelectQueryDescriptor query) {
-
-		if (query.getQualifier() == null) {
-			return Collections.EMPTY_SET;
-		}
-
-		Map<String, String> queryParameters = queriesMap.get(query.getName());
-
-		if (queryParameters == null) {
-			queryParameters = getParameterNames(query.getQualifier(), query.getRoot());
-			queriesMap.put(query.getName(), queryParameters);
-		}
-
-		return parseQualifier(query.getQualifier().toString());
-	}
-
-	public Boolean isValidParameterNames(SelectQueryDescriptor query) {
-
-		if (query.getQualifier() == null) {
-			return true;
-		}
-
-		Map<String, String> queryParameters = queriesMap.get(query.getName());
-
-		if (queryParameters == null) {
-			try {
-				queryParameters = getParameterNames(query.getQualifier(), query.getRoot());
-			} catch (Exception e) {
-				// if we have wrong path in queryParameters return false.
-				return false;
-			}
-		}
-
-		for (Ordering ordering : query.getOrderings()) {
-			// validate paths in ordering
-			String path = ordering.getSortSpecString();
-			Iterator<CayenneMapEntry> it = ((ObjEntity) query.getRoot()).resolvePathComponents(path);
-			while (it.hasNext()) {
-				try {
-					it.next();
-				} catch (ExpressionException e) {
-					// if we have wrong path in orderings return false.
-					return false;
-				}
-			}
-		}
-
-		return true;
-	}
-
-	/**
-	 * Get list of parameter names in the same order as in qualifier.
-	 * 
-	 * @param qualifierString
-	 *            to be parsed
-	 * @return List of parameter names.
-	 */
-	private Set parseQualifier(String qualifierString) {
-		Set result = new ListOrderedSet();
-		Pattern pattern = Pattern.compile("\\$[\\w]+");
-		Matcher matcher = pattern.matcher(qualifierString);
-		while (matcher.find()) {
-			String name = matcher.group();
-			result.add(Util.underscoredToJava(name.substring(1), false));
-		}
-
-		return result;
-	}
-
-	public boolean hasParameters(SelectQueryDescriptor query) {
-		Map queryParameters = queriesMap.get(query.getName());
-
-		if (queryParameters == null) {
-			return false;
-		}
-
-		return queryParameters.keySet().size() > 0;
-
-	}
-
-	/**
-	 * Get type of parameter for given name.
-	 *
-	 * @param query
-	 * @param name
-	 * @return Parameter type.
-	 */
-	public String getParameterType(SelectQueryDescriptor query, String name) {
-		return queriesMap.get(query.getName()).get(name);
-	}
-
-	private Map<String, String> getParameterNames(Expression expression, Object root) {
-		if (expression != null) {
-			Map<String, String> types = new HashMap<>();
-			String typeName = "";
-			List<String> names = new LinkedList<String>();
-
-			for (int i = 0; i < expression.getOperandCount(); i++) {
-				Object operand = expression.getOperand(i);
-
-				if (operand instanceof Expression) {
-					types.putAll(getParameterNames((Expression) operand, root));
-				}
-
-				if (operand instanceof ASTObjPath) {
-					PathComponent<ObjAttribute, ObjRelationship> component = ((Entity) root).lastPathComponent(
-							(ASTObjPath) operand, null);
-					ObjAttribute attribute = component.getAttribute();
-					if (attribute != null) {
-						typeName = attribute.getType();
-					} else {
-						ObjRelationship relationship = component.getRelationship();
-						if (relationship != null) {
-							typeName = ((ObjEntity) relationship.getTargetEntity()).getClassName();
-						} else {
-							typeName = "Object";
-						}
-					}
-				}
-
-				if (operand instanceof ASTList) {
-					Object[] values = (Object[]) ((ASTList) operand).getOperand(0);
-					for (Object value : values) {
-						if (value instanceof ExpressionParameter) {
-							names.add(((ExpressionParameter) value).getName());
-						}
-					}
-				}
-
-				if (operand instanceof ExpressionParameter) {
-					names.add(((ExpressionParameter) operand).getName());
-				}
-
-			}
-
-			for (String name : names) {
-				types.put(Util.underscoredToJava(name, false), typeName);
-			}
-
-			return types;
-		}
-		return Collections.EMPTY_MAP;
-	}
-}

http://git-wip-us.apache.org/repos/asf/cayenne/blob/c63b6be2/cayenne-tools/src/main/java/org/apache/cayenne/gen/EmbeddableArtifact.java
----------------------------------------------------------------------
diff --git a/cayenne-tools/src/main/java/org/apache/cayenne/gen/EmbeddableArtifact.java b/cayenne-tools/src/main/java/org/apache/cayenne/gen/EmbeddableArtifact.java
deleted file mode 100644
index 8e6ea43..0000000
--- a/cayenne-tools/src/main/java/org/apache/cayenne/gen/EmbeddableArtifact.java
+++ /dev/null
@@ -1,68 +0,0 @@
-/*****************************************************************
- *   Licensed to the Apache Software Foundation (ASF) under one
- *  or more contributor license agreements.  See the NOTICE file
- *  distributed with this work for additional information
- *  regarding copyright ownership.  The ASF licenses this file
- *  to you under the Apache License, Version 2.0 (the
- *  "License"); you may not use this file except in compliance
- *  with the License.  You may obtain a copy of the License at
- *
- *    http://www.apache.org/licenses/LICENSE-2.0
- *
- *  Unless required by applicable law or agreed to in writing,
- *  software distributed under the License is distributed on an
- *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- *  KIND, either express or implied.  See the License for the
- *  specific language governing permissions and limitations
- *  under the License.
- ****************************************************************/
-package org.apache.cayenne.gen;
-
-import org.apache.cayenne.map.Embeddable;
-import org.apache.velocity.VelocityContext;
-
-/**
- * {@link Artifact} facade for an {@link Embeddable}.
- * 
- * @since 3.0
- */
-public class EmbeddableArtifact implements Artifact {
-
-    protected Embeddable embeddable;
-
-    public EmbeddableArtifact(Embeddable embeddable) {
-        this.embeddable = embeddable;
-    }
-
-    public Object getObject() {
-        return embeddable;
-    }
-
-    public String getQualifiedBaseClassName() {
-        return Object.class.getName();
-    }
-
-    public String getQualifiedClassName() {
-        return embeddable.getClassName();
-    }
-
-    public TemplateType[] getTemplateTypes(ArtifactGenerationMode mode) {
-        switch (mode) {
-            case SINGLE_CLASS:
-                return new TemplateType[] {
-                    TemplateType.EMBEDDABLE_SINGLE_CLASS
-                };
-            case GENERATION_GAP:
-                return new TemplateType[] {
-                        TemplateType.EMBEDDABLE_SUPERCLASS,
-                        TemplateType.EMBEDDABLE_SUBCLASS
-                };
-            default:
-                return new TemplateType[0];
-        }
-    }
-
-    public void postInitContext(VelocityContext context) {
-        // noop - no special keys...
-    }
-}

http://git-wip-us.apache.org/repos/asf/cayenne/blob/c63b6be2/cayenne-tools/src/main/java/org/apache/cayenne/gen/EntityArtifact.java
----------------------------------------------------------------------
diff --git a/cayenne-tools/src/main/java/org/apache/cayenne/gen/EntityArtifact.java b/cayenne-tools/src/main/java/org/apache/cayenne/gen/EntityArtifact.java
deleted file mode 100644
index 394304f..0000000
--- a/cayenne-tools/src/main/java/org/apache/cayenne/gen/EntityArtifact.java
+++ /dev/null
@@ -1,98 +0,0 @@
-/*****************************************************************
- *   Licensed to the Apache Software Foundation (ASF) under one
- *  or more contributor license agreements.  See the NOTICE file
- *  distributed with this work for additional information
- *  regarding copyright ownership.  The ASF licenses this file
- *  to you under the Apache License, Version 2.0 (the
- *  "License"); you may not use this file except in compliance
- *  with the License.  You may obtain a copy of the License at
- *
- *    http://www.apache.org/licenses/LICENSE-2.0
- *
- *  Unless required by applicable law or agreed to in writing,
- *  software distributed under the License is distributed on an
- *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- *  KIND, either express or implied.  See the License for the
- *  specific language governing permissions and limitations
- *  under the License.
- ****************************************************************/
-package org.apache.cayenne.gen;
-
-import org.apache.cayenne.CayenneDataObject;
-import org.apache.cayenne.map.ObjEntity;
-import org.apache.velocity.VelocityContext;
-
-/**
- * {@link Artifact} facade for an ObjEntity.
- * 
- * @since 3.0
- */
-public class EntityArtifact implements Artifact {
-
-    public static String ENTITY_UTILS_KEY = "entityUtils";
-
-    protected ObjEntity entity;
-
-    public EntityArtifact(ObjEntity entity) {
-        this.entity = entity;
-    }
-
-    /**
-     * Returns ObjEntity.
-     */
-    public Object getObject() {
-        return entity;
-    }
-
-    public String getQualifiedBaseClassName() {
-        return (entity.getSuperClassName() != null)
-                ? entity.getSuperClassName()
-                : CayenneDataObject.class.getName();
-    }
-
-    public String getQualifiedClassName() {
-        return entity.getClassName();
-    }
-
-    public TemplateType getSingleClassType() {
-        return TemplateType.ENTITY_SINGLE_CLASS;
-    }
-
-    public TemplateType getSubclassType() {
-        return TemplateType.ENTITY_SUBCLASS;
-    }
-
-    public TemplateType getSuperClassType() {
-        return TemplateType.ENTITY_SUPERCLASS;
-    }
-
-    public TemplateType[] getTemplateTypes(ArtifactGenerationMode mode) {
-        switch (mode) {
-            case SINGLE_CLASS:
-                return new TemplateType[] {
-                    TemplateType.ENTITY_SINGLE_CLASS
-                };
-            case GENERATION_GAP:
-                return new TemplateType[] {
-                        TemplateType.ENTITY_SUPERCLASS, TemplateType.ENTITY_SUBCLASS
-                };
-            default:
-                return new TemplateType[0];
-        }
-    }
-
-    public void postInitContext(VelocityContext context) {
-        EntityUtils metadata = new EntityUtils(
-                entity.getDataMap(),
-                entity,
-                (String) context.get(BASE_CLASS_KEY),
-                (String) context.get(BASE_PACKAGE_KEY),
-                (String) context.get(SUPER_CLASS_KEY),
-                (String) context.get(SUPER_PACKAGE_KEY),
-                (String) context.get(SUB_CLASS_KEY),
-                (String) context.get(SUB_PACKAGE_KEY));
-
-        context.put(ENTITY_UTILS_KEY, metadata);
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/cayenne/blob/c63b6be2/cayenne-tools/src/main/java/org/apache/cayenne/gen/EntityUtils.java
----------------------------------------------------------------------
diff --git a/cayenne-tools/src/main/java/org/apache/cayenne/gen/EntityUtils.java b/cayenne-tools/src/main/java/org/apache/cayenne/gen/EntityUtils.java
deleted file mode 100644
index ecf2a3f..0000000
--- a/cayenne-tools/src/main/java/org/apache/cayenne/gen/EntityUtils.java
+++ /dev/null
@@ -1,274 +0,0 @@
-/*****************************************************************
- *   Licensed to the Apache Software Foundation (ASF) under one
- *  or more contributor license agreements.  See the NOTICE file
- *  distributed with this work for additional information
- *  regarding copyright ownership.  The ASF licenses this file
- *  to you under the Apache License, Version 2.0 (the
- *  "License"); you may not use this file except in compliance
- *  with the License.  You may obtain a copy of the License at
- *
- *    http://www.apache.org/licenses/LICENSE-2.0
- *
- *  Unless required by applicable law or agreed to in writing,
- *  software distributed under the License is distributed on an
- *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- *  KIND, either express or implied.  See the License for the
- *  specific language governing permissions and limitations
- *  under the License.
- ****************************************************************/
-
-package org.apache.cayenne.gen;
-
-import java.util.Collection;
-
-import org.apache.cayenne.CayenneRuntimeException;
-import org.apache.cayenne.ObjectId;
-import org.apache.cayenne.map.DataMap;
-import org.apache.cayenne.map.DbEntity;
-import org.apache.cayenne.map.MappingNamespace;
-import org.apache.cayenne.map.ObjAttribute;
-import org.apache.cayenne.map.ObjEntity;
-import org.apache.cayenne.map.ObjRelationship;
-import org.apache.cayenne.map.Relationship;
-
-/**
- * Attributes and Methods for working with ObjEntities.
- * 
- * @since 1.2
- */
-public class EntityUtils {
-
-    // template substitution values
-    protected String subClassName;
-    protected String superClassName;
-    protected String baseClassName;
-    protected String subPackageName;
-    protected String superPackageName;
-    protected String basePackageName;
-
-    protected DataMap primaryDataMap;
-    protected ObjEntity objEntity;
-
-    protected Collection<String> callbackNames;
-
-    public EntityUtils(DataMap dataMap, ObjEntity objEntity, String fqnBaseClass, String fqnSuperClass,
-            String fqnSubClass) {
-
-        StringUtils stringUtils = StringUtils.getInstance();
-
-        this.baseClassName = stringUtils.stripPackageName(fqnBaseClass);
-        this.basePackageName = stringUtils.stripClass(fqnBaseClass);
-        this.superClassName = stringUtils.stripPackageName(fqnSuperClass);
-        this.superPackageName = stringUtils.stripClass(fqnSuperClass);
-        this.subClassName = stringUtils.stripPackageName(fqnSubClass);
-        this.subPackageName = stringUtils.stripClass(fqnSubClass);
-
-        this.primaryDataMap = dataMap;
-
-        this.objEntity = objEntity;
-        this.callbackNames = objEntity.getCallbackMethods();
-    }
-
-    EntityUtils(DataMap dataMap, ObjEntity objEntity, String baseClassName, String basePackageName,
-            String superClassName, String superPackageName, String subClassName, String subPackageName) {
-
-        this.baseClassName = baseClassName;
-        this.basePackageName = basePackageName;
-        this.superClassName = superClassName;
-        this.superPackageName = superPackageName;
-        this.subClassName = subClassName;
-        this.subPackageName = subPackageName;
-
-        this.primaryDataMap = dataMap;
-
-        this.objEntity = objEntity;
-        this.callbackNames = objEntity.getCallbackMethods();
-    }
-
-    /**
-     * @return Returns the primary DataMap.
-     * @since 1.2
-     */
-    public DataMap getPrimaryDataMap() {
-        return primaryDataMap;
-    }
-
-    /**
-     * Returns the EntityResolver for this set of DataMaps.
-     * 
-     * @since 1.2
-     */
-    public MappingNamespace getEntityResolver() {
-        return primaryDataMap.getNamespace();
-    }
-
-    /**
-     * Returns true if current ObjEntity is defined as abstract.
-     */
-    public boolean isAbstract() {
-        return isAbstract(objEntity);
-    }
-
-    /**
-     * Returns true if current ObjEntity is defined as abstract.
-     */
-    public boolean isAbstract(ObjEntity anObjEntity) {
-        return anObjEntity != null && anObjEntity.isAbstract();
-    }
-
-    /**
-     * Returns true if current ObjEntity contains at least one toMany
-     * relationship.
-     */
-    public boolean hasToManyRelationships() {
-        return hasToManyRelationships(objEntity);
-    }
-
-    /**
-     * Returns true if an ObjEntity contains at least one toMany relationship.
-     */
-    public boolean hasToManyRelationships(ObjEntity anObjEntity) {
-        if (anObjEntity == null) {
-            return false;
-        }
-
-        for (Relationship r : anObjEntity.getRelationships()) {
-            if (r.isToMany()) {
-                return true;
-            }
-        }
-
-        return false;
-    }
-
-    /**
-     * Returns true if current ObjEntity contains at least one toMany
-     * relationship, ignoring those declared in superentities.
-     * 
-     * @since 1.2
-     */
-    public boolean hasToManyDeclaredRelationships() {
-        return hasToManyDeclaredRelationships(objEntity);
-    }
-
-    /**
-     * Returns true if an ObjEntity contains at least one toMany relationship,
-     * ignoring those declared in superentities.
-     * 
-     * @since 1.2
-     */
-    public boolean hasToManyDeclaredRelationships(ObjEntity anObjEntity) {
-        if (anObjEntity == null) {
-            return false;
-        }
-
-        for (Relationship r : anObjEntity.getDeclaredRelationships()) {
-            if (r.isToMany()) {
-                return true;
-            }
-        }
-
-        return false;
-    }
-
-    /**
-     * Returns true if current ObjEntity contains at least one toOne
-     * relationship.
-     */
-    public boolean hasToOneRelationships() {
-        return hasToOneRelationships(objEntity);
-    }
-
-    /**
-     * Returns true if an ObjEntity contains at least one toOne relationship.
-     */
-    public boolean hasToOneRelationships(ObjEntity anObjEntity) {
-        if (anObjEntity == null) {
-            return false;
-        }
-
-        for (Relationship r : anObjEntity.getRelationships()) {
-            if (!r.isToMany()) {
-                return true;
-            }
-        }
-
-        return false;
-    }
-
-    /**
-     * Returns true if current ObjEntity contains at least one toOne
-     * relationship, ignoring those declared in superentities.
-     */
-    public boolean hasToOneDeclaredRelationships() {
-        return hasToOneDeclaredRelationships(objEntity);
-    }
-
-    /**
-     * Returns true if an ObjEntity contains at least one toOne relationship,
-     * ignoring those declared in superentities.
-     */
-    public boolean hasToOneDeclaredRelationships(ObjEntity anObjEntity) {
-        if (anObjEntity == null) {
-            return false;
-        }
-
-        for (Relationship r : anObjEntity.getDeclaredRelationships()) {
-            if (!r.isToMany()) {
-                return true;
-            }
-        }
-
-        return false;
-    }
-
-    /**
-     * Returns the map key type for a collection relationship of type
-     * java.util.Map.
-     * 
-     * @param relationship
-     *            The relationship to look up type information for.
-     * @return The type of the attribute keyed on.
-     */
-    public String getMapKeyType(final ObjRelationship relationship) {
-
-        ObjEntity targetEntity = (ObjEntity) relationship.getTargetEntity();
-
-        // If the map key is null, then we're doing look-ups by actual object
-        // key.
-        if (relationship.getMapKey() == null) {
-
-            // If it's a multi-column key, then the return type is always
-            // ObjectId.
-            DbEntity dbEntity = targetEntity.getDbEntity();
-            if ((dbEntity != null) && (dbEntity.getPrimaryKeys().size() > 1)) {
-                return ObjectId.class.getName();
-            }
-
-            // If it's a single column key or no key exists at all, then we
-            // really don't
-            // know what the key type is,
-            // so default to Object.
-            return Object.class.getName();
-        }
-
-        // If the map key is a non-default attribute, then fetch the attribute
-        // and return
-        // its type.
-        ObjAttribute attribute = targetEntity.getAttribute(relationship.getMapKey());
-        if (attribute == null) {
-            throw new CayenneRuntimeException("Invalid map key '" + relationship.getMapKey()
-                    + "', no matching attribute found");
-        }
-
-        return attribute.getType();
-    }
-
-    /**
-     * @return the list of all callback names registered for the entity.
-     * @since 3.0
-     */
-    public Collection<String> getCallbackNames() {
-        return callbackNames;
-    }
-}

http://git-wip-us.apache.org/repos/asf/cayenne/blob/c63b6be2/cayenne-tools/src/main/java/org/apache/cayenne/gen/ImportUtils.java
----------------------------------------------------------------------
diff --git a/cayenne-tools/src/main/java/org/apache/cayenne/gen/ImportUtils.java b/cayenne-tools/src/main/java/org/apache/cayenne/gen/ImportUtils.java
deleted file mode 100644
index af40499..0000000
--- a/cayenne-tools/src/main/java/org/apache/cayenne/gen/ImportUtils.java
+++ /dev/null
@@ -1,266 +0,0 @@
-/*****************************************************************
- *   Licensed to the Apache Software Foundation (ASF) under one
- *  or more contributor license agreements.  See the NOTICE file
- *  distributed with this work for additional information
- *  regarding copyright ownership.  The ASF licenses this file
- *  to you under the Apache License, Version 2.0 (the
- *  "License"); you may not use this file except in compliance
- *  with the License.  You may obtain a copy of the License at
- *
- *    http://www.apache.org/licenses/LICENSE-2.0
- *
- *  Unless required by applicable law or agreed to in writing,
- *  software distributed under the License is distributed on an
- *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- *  KIND, either express or implied.  See the License for the
- *  specific language governing permissions and limitations
- *  under the License.
- ****************************************************************/
-
-package org.apache.cayenne.gen;
-
-import org.apache.cayenne.util.Util;
-
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.Comparator;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-/**
- * Methods for mangling strings.
- * 
- */
-public class ImportUtils {
-
-	public static final String importOrdering[] = new String[] { "java.", "javax.", "org.", "com." };
-
-	static final String primitives[] = new String[] { "long", "double", "byte", "boolean", "float", "short", "int",
-			"char" };
-
-	static final String primitiveClasses[] = new String[] { Long.class.getName(), Double.class.getName(),
-			Byte.class.getName(), Boolean.class.getName(), Float.class.getName(), Short.class.getName(),
-			Integer.class.getName(), Character.class.getName() };
-
-	static Map<String, String> classesForPrimitives = Util.toMap(primitives, primitiveClasses);
-	static Map<String, String> primitivesForClasses = Util.toMap(primitiveClasses, primitives);
-
-	protected Map<String, String> importTypesMap = new HashMap<>();
-
-	// Types forced to be FQN
-	protected Map<String, String> reservedImportTypesMap = new HashMap<>();
-
-	protected String packageName;
-
-	public ImportUtils() {
-		super();
-	}
-
-	protected boolean canRegisterType(String typeName) {
-		// Not sure why this would ever happen, but it did
-		if (null == typeName)
-			return false;
-
-		StringUtils stringUtils = StringUtils.getInstance();
-		String typeClassName = stringUtils.stripPackageName(typeName);
-		String typePackageName = stringUtils.stripClass(typeName);
-
-		if (typePackageName.length() == 0)
-			return false; // disallow non-packaged types (primitives, probably)
-		if ("java.lang".equals(typePackageName))
-			return false;
-
-		// Can only have one type -- rest must use fqn
-		if (reservedImportTypesMap.containsKey(typeClassName))
-			return false;
-		if (importTypesMap.containsKey(typeClassName))
-			return false;
-
-		return true;
-	}
-
-	/**
-	 * Reserve a fully-qualified data type class name so it cannot be used by
-	 * another class. No import statements will be generated for reserved types.
-	 * Typically, this is the fully-qualified class name of the class being
-	 * generated.
-	 * 
-	 * @param typeName
-	 *            FQ data type class name.
-	 */
-	public void addReservedType(String typeName) {
-		if (!canRegisterType(typeName))
-			return;
-
-		StringUtils stringUtils = StringUtils.getInstance();
-		String typeClassName = stringUtils.stripPackageName(typeName);
-
-		reservedImportTypesMap.put(typeClassName, typeName);
-	}
-
-	/**
-	 * Register a fully-qualified data type class name. For example,
-	 * org.apache.cayenne.CayenneDataObject.
-	 * 
-	 * @param typeName
-	 *            FQ data type class name.
-	 */
-	public void addType(String typeName) {
-		if (!canRegisterType(typeName))
-			return;
-
-		StringUtils stringUtils = StringUtils.getInstance();
-		String typePackageName = stringUtils.stripClass(typeName);
-		String typeClassName = stringUtils.stripPackageName(typeName);
-
-		if (typePackageName.equals(packageName))
-			return;
-
-		importTypesMap.put(typeClassName, typeName);
-	}
-
-	/**
-	 * Add the package name to use for this importUtil invocation.
-	 * 
-	 * @param packageName
-	 */
-	public void setPackage(String packageName) {
-		this.packageName = packageName;
-	}
-
-	/**
-	 * Performs processing similar to <code>formatJavaType(String)</code>, with
-	 * special handling of primitive types and their Java class counterparts.
-	 * This method allows users to make a decision whether to use primitives or
-	 * not, regardless of how type is mapped.
-	 */
-	public String formatJavaType(String typeName, boolean usePrimitives) {
-		if (usePrimitives) {
-			String primitive = primitivesForClasses.get(typeName);
-			return (primitive != null) ? primitive : formatJavaType(typeName);
-		} else {
-			String primitiveClass = classesForPrimitives.get(typeName);
-			return (primitiveClass != null) ? formatJavaType(primitiveClass) : formatJavaType(typeName);
-		}
-	}
-
-	/**
-	 * Removes registered package and non-reserved registered type name prefixes
-	 * from java types
-	 */
-	public String formatJavaType(String typeName) {
-		if (typeName != null) {
-			StringUtils stringUtils = StringUtils.getInstance();
-			String typeClassName = stringUtils.stripPackageName(typeName);
-
-			if (!reservedImportTypesMap.containsKey(typeClassName)) {
-				if (importTypesMap.containsKey(typeClassName)) {
-					if (typeName.equals(importTypesMap.get(typeClassName)))
-						return typeClassName;
-				}
-			}
-
-			String typePackageName = stringUtils.stripClass(typeName);
-			if ("java.lang".equals(typePackageName))
-				return typeClassName;
-			if ((null != packageName) && (packageName.equals(typePackageName)))
-				return typeClassName;
-		}
-
-		return typeName;
-	}
-
-	/**
-	 * @since 3.0
-	 */
-	public String formatJavaTypeAsNonBooleanPrimitive(String type) {
-		String value = ImportUtils.classesForPrimitives.get(type);
-		return formatJavaType(value != null ? value : type);
-	}
-
-	/**
-	 * @since 3.0
-	 */
-	public boolean isNonBooleanPrimitive(String type) {
-		return ImportUtils.classesForPrimitives.containsKey(type) && !isBoolean(type);
-	}
-
-	/**
-	 * @since 3.0
-	 */
-	public boolean isBoolean(String type) {
-		return "boolean".equals(type);
-	}
-
-	/**
-	 * Generate package and list of import statements based on the registered
-	 * types.
-	 */
-	public String generate() {
-		StringBuilder outputBuffer = new StringBuilder();
-
-		if (null != packageName) {
-			outputBuffer.append("package ");
-			outputBuffer.append(packageName);
-
-			// Using UNIX line endings intentionally - generated Java files
-			// should look
-			// the same regardless of platform to prevent developer teams
-			// working on
-			// multiple OS's to override each other's work
-			outputBuffer.append(";\n\n");
-		}
-
-		List<String> typesList = new ArrayList<>(importTypesMap.values());
-		Collections.sort(typesList, new Comparator<String>() {
-
-			public int compare(String s1, String s2) {
-
-				for (String ordering : importOrdering) {
-					if ((s1.startsWith(ordering)) && (!s2.startsWith(ordering))) {
-						return -1;
-					}
-					if ((!s1.startsWith(ordering)) && (s2.startsWith(ordering))) {
-						return 1;
-					}
-				}
-
-				return s1.compareTo(s2);
-			}
-		});
-
-		String lastStringPrefix = null;
-		boolean firstIteration = true;
-		for (String typeName : typesList) {
-
-			if (firstIteration) {
-				firstIteration = false;
-			} else {
-				outputBuffer.append('\n');
-			}
-			// Output another newline if we're in a different root package.
-			// Find root package
-			String thisStringPrefix = typeName;
-			int dotIndex = typeName.indexOf('.');
-			if (-1 != dotIndex) {
-				thisStringPrefix = typeName.substring(0, dotIndex);
-			}
-			// if this isn't the first import,
-			if (null != lastStringPrefix) {
-				// and it's different from the last import
-				if (false == thisStringPrefix.equals(lastStringPrefix)) {
-					// output a newline; force UNIX style per comment above
-					outputBuffer.append("\n");
-				}
-			}
-			lastStringPrefix = thisStringPrefix;
-
-			outputBuffer.append("import ");
-			outputBuffer.append(typeName);
-			outputBuffer.append(';');
-		}
-
-		return outputBuffer.toString();
-	}
-}


[04/10] cayenne git commit: CAY-2215 split cayenne-tools into cayenne-cgen and cayenne-ant

Posted by nt...@apache.org.
http://git-wip-us.apache.org/repos/asf/cayenne/blob/c63b6be2/cayenne-tools/src/main/java/org/apache/cayenne/gen/StringUtils.java
----------------------------------------------------------------------
diff --git a/cayenne-tools/src/main/java/org/apache/cayenne/gen/StringUtils.java b/cayenne-tools/src/main/java/org/apache/cayenne/gen/StringUtils.java
deleted file mode 100644
index cc27627..0000000
--- a/cayenne-tools/src/main/java/org/apache/cayenne/gen/StringUtils.java
+++ /dev/null
@@ -1,189 +0,0 @@
-/*****************************************************************
- *   Licensed to the Apache Software Foundation (ASF) under one
- *  or more contributor license agreements.  See the NOTICE file
- *  distributed with this work for additional information
- *  regarding copyright ownership.  The ASF licenses this file
- *  to you under the Apache License, Version 2.0 (the
- *  "License"); you may not use this file except in compliance
- *  with the License.  You may obtain a copy of the License at
- *
- *    http://www.apache.org/licenses/LICENSE-2.0
- *
- *  Unless required by applicable law or agreed to in writing,
- *  software distributed under the License is distributed on an
- *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- *  KIND, either express or implied.  See the License for the
- *  specific language governing permissions and limitations
- *  under the License.
- ****************************************************************/
-
-package org.apache.cayenne.gen;
-
-import org.apache.cayenne.project.validation.NameValidationHelper;
-import org.apache.cayenne.util.Util;
-
-/**
- * Methods for mangling strings.
- */
-public class StringUtils {
-
-    private static StringUtils sharedInstance;
-
-    public static StringUtils getInstance() {
-        if (null == sharedInstance) {
-            sharedInstance = new StringUtils();
-        }
-
-        return sharedInstance;
-    }
-
-    /**
-     * Prepends underscore to variable name if necessary to remove conflict with reserved
-     * keywords.
-     */
-    public String formatVariableName(String variableName) {
-        if (NameValidationHelper.getInstance().isReservedJavaKeyword(variableName)) {
-            return "_" + variableName;
-        }
-        else {
-            return variableName;
-        }
-    }
-
-    /**
-     * Removes package name, leaving base name.
-     * 
-     * @since 1.2
-     */
-    public String stripPackageName(String fullyQualifiedClassName) {
-        return Util.stripPackageName(fullyQualifiedClassName);
-    }
-
-    /**
-     * Removes base name, leaving package name.
-     * 
-     * @since 1.2
-     */
-    public String stripClass(String aString) {
-        if (aString == null || aString.length() == 0)
-            return aString;
-
-        int lastDot = aString.lastIndexOf('.');
-
-        if (-1 == lastDot)
-            return "";
-
-        return aString.substring(0, lastDot);
-    }
-
-    /**
-     * Capitalizes the first letter of the property name.
-     * 
-     * @since 1.1
-     */
-    public String capitalized(String name) {
-        if (name == null || name.length() == 0)
-            return name;
-
-        char c = Character.toUpperCase(name.charAt(0));
-        return (name.length() == 1) ? Character.toString(c) : c + name.substring(1);
-    }
-
-    /**
-     * Returns string with lowercased first letter
-     * 
-     * @since 1.2
-     */
-    public static String uncapitalized(String aString) {
-        if (aString == null || aString.length() == 0)
-            return aString;
-
-        char c = Character.toLowerCase(aString.charAt(0));
-        return (aString.length() == 1) ? Character.toString(c) : c + aString.substring(1);
-    }
-
-    /**
-     * Converts property name to Java constants naming convention.
-     * 
-     * @since 1.1
-     */
-    public String capitalizedAsConstant(String name) {
-        if (name == null || name.length() == 0)
-            return name;
-
-        // clear of non-java chars. While the method name implies that a passed identifier
-        // is pure Java, it is used to build pk columns names and such, so extra safety
-        // check is a good idea
-        name = Util.specialCharsToJava(name);
-
-        char charArray[] = name.toCharArray();
-        StringBuilder buffer = new StringBuilder();
-
-        for (int i = 0; i < charArray.length; i++) {
-            if ((Character.isUpperCase(charArray[i])) && (i != 0)) {
-
-                char prevChar = charArray[i - 1];
-                if ((Character.isLowerCase(prevChar))) {
-                    buffer.append("_");
-                }
-            }
-
-            buffer.append(Character.toUpperCase(charArray[i]));
-        }
-
-        return buffer.toString();
-    }
-
-    /**
-     * Converts entity or property name to a plural form. For example:
-     * <ul>
-     * <li>pluralize("Word") == "Words"</li>
-     * <li>pluralize("Status") == "Statuses"</li>
-     * <li>pluralize("Index") == "Indexes"</li>
-     * <li>pluralize("Factory") == "Factories"</li>
-     * </ul>
-     * <p>
-     * As of 3.1 this method is not used in bundled templates, and is present here for
-     * user templates convenience.
-     * 
-     * @since 3.1
-     */
-    public String pluralize(String str) {
-        if (str == null || str.length() == 0) {
-            return str;
-        }
-        else if (str.endsWith("s") || str.endsWith("x")) {
-            return str + "es";
-        }
-        else if (str.endsWith("y")) {
-            return str.substring(0, str.length() - 1) + "ies";
-        }
-        else {
-            return str + "s";
-        }
-    }
-
-    /**
-     * <p>
-     * Strip generic definition from string
-     * </p>
-     * <p>For example: List&gt;Integer&lt; == List</p>
-     * @since 4.0
-     */
-    public String stripGeneric(String str) {
-        if(str == null) {
-            return null;
-        }
-        int start = str.indexOf('<');
-        if(start == -1) {
-            return str;
-        }
-        int end = str.lastIndexOf('>');
-        if(end == -1) {
-            return str;
-        } else if(end == str.length() - 1) {
-            return str.substring(0, start);
-        }
-        return str.substring(0, start) + str.substring(end+1);
-    }
-}

http://git-wip-us.apache.org/repos/asf/cayenne/blob/c63b6be2/cayenne-tools/src/main/java/org/apache/cayenne/gen/TemplateType.java
----------------------------------------------------------------------
diff --git a/cayenne-tools/src/main/java/org/apache/cayenne/gen/TemplateType.java b/cayenne-tools/src/main/java/org/apache/cayenne/gen/TemplateType.java
deleted file mode 100644
index 109627e..0000000
--- a/cayenne-tools/src/main/java/org/apache/cayenne/gen/TemplateType.java
+++ /dev/null
@@ -1,55 +0,0 @@
-/*****************************************************************
- *   Licensed to the Apache Software Foundation (ASF) under one
- *  or more contributor license agreements.  See the NOTICE file
- *  distributed with this work for additional information
- *  regarding copyright ownership.  The ASF licenses this file
- *  to you under the Apache License, Version 2.0 (the
- *  "License"); you may not use this file except in compliance
- *  with the License.  You may obtain a copy of the License at
- *
- *    http://www.apache.org/licenses/LICENSE-2.0
- *
- *  Unless required by applicable law or agreed to in writing,
- *  software distributed under the License is distributed on an
- *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- *  KIND, either express or implied.  See the License for the
- *  specific language governing permissions and limitations
- *  under the License.
- ****************************************************************/
-package org.apache.cayenne.gen;
-
-/**
- * Defines class generation template types.
- * 
- * @since 3.0
- */
-public enum TemplateType {
-
-    ENTITY_SINGLE_CLASS(false),
-
-    ENTITY_SUPERCLASS(true),
-
-    ENTITY_SUBCLASS(false),
-
-    EMBEDDABLE_SINGLE_CLASS(false),
-
-    EMBEDDABLE_SUPERCLASS(true),
-
-    EMBEDDABLE_SUBCLASS(false),
-
-    DATAMAP_SINGLE_CLASS(false),
-
-    DATAMAP_SUPERCLASS(true),
-
-    DATAMAP_SUBCLASS(false);
-
-    private boolean superclass;
-
-    private TemplateType(boolean superclass) {
-        this.superclass = superclass;
-    }
-
-    public boolean isSuperclass() {
-        return superclass;
-    }
-}

http://git-wip-us.apache.org/repos/asf/cayenne/blob/c63b6be2/cayenne-tools/src/main/java/org/apache/cayenne/gen/package.html
----------------------------------------------------------------------
diff --git a/cayenne-tools/src/main/java/org/apache/cayenne/gen/package.html b/cayenne-tools/src/main/java/org/apache/cayenne/gen/package.html
deleted file mode 100644
index 69b8b7d..0000000
--- a/cayenne-tools/src/main/java/org/apache/cayenne/gen/package.html
+++ /dev/null
@@ -1,28 +0,0 @@
-<!--
-   Licensed to the Apache Software Foundation (ASF) under one
-   or more contributor license agreements.  See the NOTICE file
-   distributed with this work for additional information
-   regarding copyright ownership.  The ASF licenses this file
-   to you under the Apache License, Version 2.0 (the
-   "License"); you may not use this file except in compliance
-   with the License.  You may obtain a copy of the License at
-
-     http://www.apache.org/licenses/LICENSE-2.0
-
-   Unless required by applicable law or agreed to in writing,
-   software distributed under the License is distributed on an
-   "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-   KIND, either express or implied.  See the License for the
-   specific language governing permissions and limitations
-   under the License.
--->
-<html>
-<body>
-Contains classes that provide Java source generation facility. 
-Source creation is based on a set of templates parsed 
-during generation process, using Jakarta Velocity template engine.
-
-<p><i>For more information see <a href="../../../../../../index.html"
-target="_top">Cayenne User Guide.</a></i></p>
-</body>
-</html>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/cayenne/blob/c63b6be2/cayenne-tools/src/main/java/org/apache/cayenne/tools/AntDataPortDelegate.java
----------------------------------------------------------------------
diff --git a/cayenne-tools/src/main/java/org/apache/cayenne/tools/AntDataPortDelegate.java b/cayenne-tools/src/main/java/org/apache/cayenne/tools/AntDataPortDelegate.java
deleted file mode 100644
index de001bd..0000000
--- a/cayenne-tools/src/main/java/org/apache/cayenne/tools/AntDataPortDelegate.java
+++ /dev/null
@@ -1,170 +0,0 @@
-/*****************************************************************
- *   Licensed to the Apache Software Foundation (ASF) under one
- *  or more contributor license agreements.  See the NOTICE file
- *  distributed with this work for additional information
- *  regarding copyright ownership.  The ASF licenses this file
- *  to you under the Apache License, Version 2.0 (the
- *  "License"); you may not use this file except in compliance
- *  with the License.  You may obtain a copy of the License at
- *
- *    http://www.apache.org/licenses/LICENSE-2.0
- *
- *  Unless required by applicable law or agreed to in writing,
- *  software distributed under the License is distributed on an
- *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- *  KIND, either express or implied.  See the License for the
- *  specific language governing permissions and limitations
- *  under the License.
- ****************************************************************/
-
-package org.apache.cayenne.tools;
-
-import org.apache.cayenne.access.DataPort;
-import org.apache.cayenne.access.DataPortDelegate;
-import org.apache.cayenne.dbsync.filter.NamePatternMatcher;
-import org.apache.cayenne.map.DataMap;
-import org.apache.cayenne.map.DbEntity;
-import org.apache.cayenne.query.Query;
-import org.apache.tools.ant.Project;
-import org.apache.tools.ant.Task;
-
-import java.util.Iterator;
-import java.util.List;
-import java.util.regex.Pattern;
-
-/**
- * DataPortDelegate implementation that works in the context of Ant DataPortTask
- * task execution, performing entity filtering and logging functions.
- * 
- * @since 1.2: Prior to 1.2 DataPort classes were a part of cayenne-examples
- *        package.
- * @deprecated since 4.0
- */
-@Deprecated
-class AntDataPortDelegate implements DataPortDelegate {
-
-    protected Task parentTask;
-
-    protected Pattern[] mapFilters;
-
-    protected long timestamp;
-    protected DbEntity lastEntity;
-
-    protected NamePatternMatcher namePatternMatcher;
-
-    // exists for testing and such
-    AntDataPortDelegate() {
-        mapFilters = new Pattern[] {};
-    }
-
-    AntDataPortDelegate(Task parentTask, String mapsPattern,
-            String includeEntitiesPattern, String excludeEntitiesPattern) {
-        this.parentTask = parentTask;
-
-        AntLogger logger = new AntLogger(parentTask);
-
-        this.namePatternMatcher = NamePatternMatcher.build(logger, includeEntitiesPattern, excludeEntitiesPattern);
-        this.mapFilters = NamePatternMatcher.createPatterns(logger, mapsPattern);
-    }
-
-    /**
-     * Applies preconfigured list of filters to the list, removing entities that
-     * do not pass the filter.
-     */
-    protected List filterEntities(List entities) {
-        if (entities == null || entities.isEmpty()) {
-            return entities;
-        }
-
-        Iterator it = entities.iterator();
-        while (it.hasNext()) {
-            DbEntity entity = (DbEntity) it.next();
-
-            if (!passedDataMapFilter(entity.getDataMap())) {
-                it.remove();
-            }
-        }
-
-        namePatternMatcher.filter(entities);
-
-        return entities;
-    }
-
-    /**
-     * Returns true if the DataMap passes a set of DataMap filters or if there
-     * is no DataMap filters.
-     */
-    protected boolean passedDataMapFilter(DataMap map) {
-        if (mapFilters.length == 0) {
-            return true;
-        }
-
-        if (map == null) {
-            return true;
-        }
-
-        String mapName = map.getName();
-        for (Pattern mapFilter : mapFilters) {
-            if (mapFilter.matcher(mapName).find()) {
-                return true;
-            }
-        }
-
-        return false;
-    }
-
-    /**
-     * Implements the delegate method to filter the list of entities applying
-     * filtering rules encapsulated by this object.
-     */
-    public List willPortEntities(DataPort portTool, List entities) {
-        return filterEntities(entities);
-    }
-
-    /**
-     * Logs entity porting event using Ant logger.
-     */
-    public Query willPortEntity(DataPort portTool, DbEntity entity, Query query) {
-        parentTask.log("Porting '" + entity.getName() + "'");
-        lastEntity = entity;
-        timestamp = System.currentTimeMillis();
-        return query;
-    }
-
-    public void didPortEntity(DataPort portTool, DbEntity entity, int rowCount) {
-        String timestampLabel = "";
-        if (lastEntity == entity) {
-            timestampLabel = " in " + (System.currentTimeMillis() - timestamp)
-                    + " ms.";
-        }
-
-        String label = (rowCount == 1) ? "1 row transferred" : rowCount
-                + " rows transferred";
-        parentTask.log("Done porting " + entity.getName() + ", " + label
-                + timestampLabel, Project.MSG_VERBOSE);
-    }
-
-    public List willCleanData(DataPort portTool, List entities) {
-        return filterEntities(entities);
-    }
-
-    public Query willCleanData(DataPort portTool, DbEntity entity, Query query) {
-        parentTask.log("Deleting " + entity.getName(), Project.MSG_VERBOSE);
-        lastEntity = entity;
-        timestamp = System.currentTimeMillis();
-        return query;
-    }
-
-    public void didCleanData(DataPort portTool, DbEntity entity, int rowCount) {
-        String timestampLabel = "";
-        if (lastEntity == entity) {
-            timestampLabel = " in " + (System.currentTimeMillis() - timestamp)
-                    + " ms.";
-        }
-
-        String label = (rowCount == 1) ? "1 row deleted" : rowCount
-                + " rows deleted";
-        parentTask.log("Done deleting " + entity.getName() + ", " + label
-                + timestampLabel, Project.MSG_VERBOSE);
-    }
-}

http://git-wip-us.apache.org/repos/asf/cayenne/blob/c63b6be2/cayenne-tools/src/main/java/org/apache/cayenne/tools/AntLogger.java
----------------------------------------------------------------------
diff --git a/cayenne-tools/src/main/java/org/apache/cayenne/tools/AntLogger.java b/cayenne-tools/src/main/java/org/apache/cayenne/tools/AntLogger.java
deleted file mode 100644
index 5ef9166..0000000
--- a/cayenne-tools/src/main/java/org/apache/cayenne/tools/AntLogger.java
+++ /dev/null
@@ -1,108 +0,0 @@
-/*****************************************************************
- *   Licensed to the Apache Software Foundation (ASF) under one
- *  or more contributor license agreements.  See the NOTICE file
- *  distributed with this work for additional information
- *  regarding copyright ownership.  The ASF licenses this file
- *  to you under the Apache License, Version 2.0 (the
- *  "License"); you may not use this file except in compliance
- *  with the License.  You may obtain a copy of the License at
- *
- *    http://www.apache.org/licenses/LICENSE-2.0
- *
- *  Unless required by applicable law or agreed to in writing,
- *  software distributed under the License is distributed on an
- *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- *  KIND, either express or implied.  See the License for the
- *  specific language governing permissions and limitations
- *  under the License.
- ****************************************************************/
-
-package org.apache.cayenne.tools;
-
-import org.apache.commons.logging.Log;
-import org.apache.tools.ant.Project;
-import org.apache.tools.ant.Task;
-
-/**
- * @since 3.0
- */
-class AntLogger implements Log {
-
-    private Task parentTask;
-
-    public AntLogger(Task parentTask) {
-        this.parentTask = parentTask;
-    }
-
-    public void debug(Object message, Throwable th) {
-        parentTask.log(String.valueOf(message), Project.MSG_DEBUG);
-    }
-
-    public void debug(Object message) {
-        parentTask.log(String.valueOf(message), Project.MSG_DEBUG);
-    }
-
-    public void error(Object message, Throwable th) {
-        parentTask.log(String.valueOf(message), Project.MSG_ERR);
-    }
-
-    public void error(Object message) {
-        parentTask.log(String.valueOf(message), Project.MSG_ERR);
-    }
-
-    public void fatal(Object message, Throwable th) {
-        parentTask.log(String.valueOf(message), Project.MSG_ERR);
-    }
-
-    public void fatal(Object message) {
-        parentTask.log(String.valueOf(message), Project.MSG_ERR);
-    }
-
-    public void info(Object message, Throwable th) {
-        parentTask.log(String.valueOf(message), Project.MSG_INFO);
-    }
-
-    public void info(Object message) {
-        parentTask.log(String.valueOf(message), Project.MSG_INFO);
-    }
-
-    public void trace(Object message, Throwable th) {
-        parentTask.log(String.valueOf(message), Project.MSG_VERBOSE);
-    }
-
-    public void trace(Object message) {
-        parentTask.log(String.valueOf(message), Project.MSG_VERBOSE);
-    }
-
-    public void warn(Object message, Throwable th) {
-        parentTask.log(String.valueOf(message), Project.MSG_WARN);
-    }
-
-    public void warn(Object message) {
-        parentTask.log(String.valueOf(message), Project.MSG_WARN);
-    }
-
-    public boolean isWarnEnabled() {
-        return true;
-    }
-
-    public boolean isDebugEnabled() {
-        return true;
-    }
-
-    public boolean isErrorEnabled() {
-        return true;
-    }
-
-    public boolean isFatalEnabled() {
-        return true;
-    }
-
-    public boolean isInfoEnabled() {
-        return true;
-    }
-
-    public boolean isTraceEnabled() {
-        return true;
-    }
-}

http://git-wip-us.apache.org/repos/asf/cayenne/blob/c63b6be2/cayenne-tools/src/main/java/org/apache/cayenne/tools/AntTableType.java
----------------------------------------------------------------------
diff --git a/cayenne-tools/src/main/java/org/apache/cayenne/tools/AntTableType.java b/cayenne-tools/src/main/java/org/apache/cayenne/tools/AntTableType.java
deleted file mode 100644
index d195f9a..0000000
--- a/cayenne-tools/src/main/java/org/apache/cayenne/tools/AntTableType.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- *    Licensed to the Apache Software Foundation (ASF) under one
- *    or more contributor license agreements.  See the NOTICE file
- *    distributed with this work for additional information
- *    regarding copyright ownership.  The ASF licenses this file
- *    to you under the Apache License, Version 2.0 (the
- *    "License"); you may not use this file except in compliance
- *    with the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- *    Unless required by applicable law or agreed to in writing,
- *    software distributed under the License is distributed on an
- *    "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- *    KIND, either express or implied.  See the License for the
- *    specific language governing permissions and limitations
- *    under the License.
- */
-package org.apache.cayenne.tools;
-
-public class AntTableType {
-    private String name;
-
-    public void addText(String string) {
-        setName(string);
-    }
-
-    public String getName() {
-        return name;
-    }
-
-    public void setName(String name) {
-        this.name = name;
-    }
-}

http://git-wip-us.apache.org/repos/asf/cayenne/blob/c63b6be2/cayenne-tools/src/main/java/org/apache/cayenne/tools/CayenneGeneratorEntityFilterAction.java
----------------------------------------------------------------------
diff --git a/cayenne-tools/src/main/java/org/apache/cayenne/tools/CayenneGeneratorEntityFilterAction.java b/cayenne-tools/src/main/java/org/apache/cayenne/tools/CayenneGeneratorEntityFilterAction.java
deleted file mode 100644
index 4d068d8..0000000
--- a/cayenne-tools/src/main/java/org/apache/cayenne/tools/CayenneGeneratorEntityFilterAction.java
+++ /dev/null
@@ -1,85 +0,0 @@
-/*****************************************************************
- *   Licensed to the Apache Software Foundation (ASF) under one
- *  or more contributor license agreements.  See the NOTICE file
- *  distributed with this work for additional information
- *  regarding copyright ownership.  The ASF licenses this file
- *  to you under the Apache License, Version 2.0 (the
- *  "License"); you may not use this file except in compliance
- *  with the License.  You may obtain a copy of the License at
- *
- *    http://www.apache.org/licenses/LICENSE-2.0
- *
- *  Unless required by applicable law or agreed to in writing,
- *  software distributed under the License is distributed on an
- *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- *  KIND, either express or implied.  See the License for the
- *  specific language governing permissions and limitations
- *  under the License.
- ****************************************************************/
-package org.apache.cayenne.tools;
-
-import org.apache.cayenne.dbsync.filter.NameFilter;
-import org.apache.cayenne.map.DataMap;
-import org.apache.cayenne.map.Embeddable;
-import org.apache.cayenne.map.ObjEntity;
-
-import java.net.MalformedURLException;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Iterator;
-
-/**
- * Performs entity filtering to build a collection of entities that should be used in
- * class generation.
- * 
- * @since 3.0
- */
-class CayenneGeneratorEntityFilterAction {
-
-    private NameFilter nameFilter;
-    private boolean client;
-
-    Collection<Embeddable> getFilteredEmbeddables(DataMap mainDataMap) {
-        Collection<Embeddable> embeddables = new ArrayList<>(mainDataMap.getEmbeddables());
-
-        // filter out excluded entities...
-        Iterator<Embeddable> it = embeddables.iterator();
-
-        while (it.hasNext()) {
-            Embeddable e = it.next();
-
-            // note that unlike entity, embeddable is matched by class name as it doesn't
-            // have a symbolic name...
-            if (!nameFilter.isIncluded(e.getClassName())) {
-                it.remove();
-            }
-        }
-
-        return embeddables;
-    }
-
-    Collection<ObjEntity> getFilteredEntities(DataMap mainDataMap)
-            throws MalformedURLException {
-
-        Collection<ObjEntity> entities = new ArrayList<>(mainDataMap.getObjEntities());
-
-        // filter out excluded entities...
-        Iterator<ObjEntity> it = entities.iterator();
-        while (it.hasNext()) {
-            ObjEntity e = it.next();
-            if (e.isGeneric() || client && !e.isClientAllowed() || !nameFilter.isIncluded(e.getName())) {
-                it.remove();
-            }
-        }
-
-        return entities;
-    }
-
-    void setClient(boolean client) {
-        this.client = client;
-    }
-
-    public void setNameFilter(NameFilter nameFilter) {
-        this.nameFilter = nameFilter;
-    }
-}

http://git-wip-us.apache.org/repos/asf/cayenne/blob/c63b6be2/cayenne-tools/src/main/java/org/apache/cayenne/tools/CayenneGeneratorMapLoaderAction.java
----------------------------------------------------------------------
diff --git a/cayenne-tools/src/main/java/org/apache/cayenne/tools/CayenneGeneratorMapLoaderAction.java b/cayenne-tools/src/main/java/org/apache/cayenne/tools/CayenneGeneratorMapLoaderAction.java
deleted file mode 100644
index 819a0e2..0000000
--- a/cayenne-tools/src/main/java/org/apache/cayenne/tools/CayenneGeneratorMapLoaderAction.java
+++ /dev/null
@@ -1,79 +0,0 @@
-/*****************************************************************
- *   Licensed to the Apache Software Foundation (ASF) under one
- *  or more contributor license agreements.  See the NOTICE file
- *  distributed with this work for additional information
- *  regarding copyright ownership.  The ASF licenses this file
- *  to you under the Apache License, Version 2.0 (the
- *  "License"); you may not use this file except in compliance
- *  with the License.  You may obtain a copy of the License at
- *
- *    http://www.apache.org/licenses/LICENSE-2.0
- *
- *  Unless required by applicable law or agreed to in writing,
- *  software distributed under the License is distributed on an
- *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- *  KIND, either express or implied.  See the License for the
- *  specific language governing permissions and limitations
- *  under the License.
- ****************************************************************/
-package org.apache.cayenne.tools;
-
-import java.io.File;
-import java.net.MalformedURLException;
-
-import org.apache.cayenne.map.DataMap;
-import org.apache.cayenne.map.EntityResolver;
-import org.apache.cayenne.map.MapLoader;
-import org.xml.sax.InputSource;
-
-/**
- * Loads a DataMap and a shared entity namespace.
- * 
- * @since 3.0
- */
-class CayenneGeneratorMapLoaderAction {
-
-    private File mainDataMapFile;
-    private File[] additionalDataMapFiles;
-    private DataMap mainDataMap;
-
-    DataMap getMainDataMap() throws MalformedURLException {
-        if (mainDataMap == null) {
-            MapLoader mapLoader = new MapLoader();
-
-            DataMap mainDataMap = loadDataMap(mapLoader, mainDataMapFile);
-
-            if (additionalDataMapFiles != null) {
-
-                EntityResolver entityResolver = new EntityResolver();
-                entityResolver.addDataMap(mainDataMap);
-                mainDataMap.setNamespace(entityResolver);
-
-                for (File additionalDataMapFile : additionalDataMapFiles) {
-
-                    DataMap dataMap = loadDataMap(mapLoader, additionalDataMapFile);
-                    entityResolver.addDataMap(dataMap);
-                    dataMap.setNamespace(entityResolver);
-                }
-            }
-
-            this.mainDataMap = mainDataMap;
-        }
-
-        return mainDataMap;
-    }
-
-    protected DataMap loadDataMap(MapLoader mapLoader, File dataMapFile)
-            throws MalformedURLException {
-        InputSource in = new InputSource(dataMapFile.toURI().toURL().toString());
-        return mapLoader.loadDataMap(in);
-    }
-
-    void setMainDataMapFile(File mainDataMapFile) {
-        this.mainDataMapFile = mainDataMapFile;
-    }
-
-    void setAdditionalDataMapFiles(File[] additionalDataMapFiles) {
-        this.additionalDataMapFiles = additionalDataMapFiles;
-    }
-}

http://git-wip-us.apache.org/repos/asf/cayenne/blob/c63b6be2/cayenne-tools/src/main/java/org/apache/cayenne/tools/CayenneGeneratorTask.java
----------------------------------------------------------------------
diff --git a/cayenne-tools/src/main/java/org/apache/cayenne/tools/CayenneGeneratorTask.java b/cayenne-tools/src/main/java/org/apache/cayenne/tools/CayenneGeneratorTask.java
deleted file mode 100644
index d57b350..0000000
--- a/cayenne-tools/src/main/java/org/apache/cayenne/tools/CayenneGeneratorTask.java
+++ /dev/null
@@ -1,304 +0,0 @@
-/*****************************************************************
- *   Licensed to the Apache Software Foundation (ASF) under one
- *  or more contributor license agreements.  See the NOTICE file
- *  distributed with this work for additional information
- *  regarding copyright ownership.  The ASF licenses this file
- *  to you under the Apache License, Version 2.0 (the
- *  "License"); you may not use this file except in compliance
- *  with the License.  You may obtain a copy of the License at
- *
- *    http://www.apache.org/licenses/LICENSE-2.0
- *
- *  Unless required by applicable law or agreed to in writing,
- *  software distributed under the License is distributed on an
- *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- *  KIND, either express or implied.  See the License for the
- *  specific language governing permissions and limitations
- *  under the License.
- ****************************************************************/
-package org.apache.cayenne.tools;
-
-import foundrylogic.vpp.VPPConfig;
-import org.apache.cayenne.dbsync.filter.NamePatternMatcher;
-import org.apache.cayenne.gen.ArtifactsGenerationMode;
-import org.apache.cayenne.gen.ClassGenerationAction;
-import org.apache.cayenne.gen.ClientClassGenerationAction;
-import org.apache.cayenne.map.DataMap;
-import org.apache.tools.ant.BuildException;
-import org.apache.tools.ant.types.Path;
-import org.apache.velocity.VelocityContext;
-
-import java.io.File;
-
-/**
- * An Ant task to perform class generation based on CayenneDataMap.
- * 
- * @since 3.0
- */
-public class CayenneGeneratorTask extends CayenneTask {
-
-    protected String includeEntitiesPattern;
-    protected String excludeEntitiesPattern;
-    protected VPPConfig vppConfig;
-
-    protected File map;
-    protected File additionalMaps[];
-    protected boolean client;
-    protected File destDir;
-    protected String encoding;
-    protected boolean makepairs;
-    protected String mode;
-    protected String outputPattern;
-    protected boolean overwrite;
-    protected String superpkg;
-    protected String supertemplate;
-    protected String template;
-    protected String embeddabletemplate;
-    protected String embeddablesupertemplate;
-    protected String querytemplate;
-    protected String querysupertemplate;
-    protected boolean usepkgpath;
-    protected boolean createpropertynames;
-
-    public CayenneGeneratorTask() {
-        this.makepairs = true;
-        this.mode = ArtifactsGenerationMode.ENTITY.getLabel();
-        this.outputPattern = "*.java";
-        this.usepkgpath = true;
-    }
-
-    protected VelocityContext getVppContext() {
-        initializeVppConfig();
-        return vppConfig.getVelocityContext();
-    }
-
-    protected ClassGenerationAction createGeneratorAction() {
-        ClassGenerationAction action = client ? new ClientClassGenerationAction() : new ClassGenerationAction();
-
-        action.setContext(getVppContext());
-        action.setDestDir(destDir);
-        action.setEncoding(encoding);
-        action.setMakePairs(makepairs);
-        action.setArtifactsGenerationMode(mode);
-        action.setOutputPattern(outputPattern);
-        action.setOverwrite(overwrite);
-        action.setSuperPkg(superpkg);
-        action.setSuperTemplate(supertemplate);
-        action.setTemplate(template);
-        action.setEmbeddableSuperTemplate(embeddablesupertemplate);
-        action.setEmbeddableTemplate(embeddabletemplate);
-        action.setQueryTemplate(querytemplate);
-        action.setQuerySuperTemplate(querysupertemplate);
-        action.setUsePkgPath(usepkgpath);
-        action.setCreatePropertyNames(createpropertynames);
-
-        return action;
-    }
-
-    /**
-     * Executes the task. It will be called by ant framework.
-     */
-    @Override
-    public void execute() throws BuildException {
-        validateAttributes();
-
-        AntLogger logger = new AntLogger(this);
-        CayenneGeneratorMapLoaderAction loadAction = new CayenneGeneratorMapLoaderAction();
-
-        loadAction.setMainDataMapFile(map);
-        loadAction.setAdditionalDataMapFiles(additionalMaps);
-
-        CayenneGeneratorEntityFilterAction filterAction = new CayenneGeneratorEntityFilterAction();
-        filterAction.setClient(client);
-        filterAction.setNameFilter(NamePatternMatcher.build(logger, includeEntitiesPattern, excludeEntitiesPattern));
-
-        try {
-
-            DataMap dataMap = loadAction.getMainDataMap();
-
-            ClassGenerationAction generatorAction = createGeneratorAction();
-            generatorAction.setLogger(logger);
-            generatorAction.setTimestamp(map.lastModified());
-            generatorAction.setDataMap(dataMap);
-            generatorAction.addEntities(filterAction.getFilteredEntities(dataMap));
-            generatorAction.addEmbeddables(filterAction.getFilteredEmbeddables(dataMap));
-            generatorAction.addQueries(dataMap.getQueryDescriptors());
-            generatorAction.execute();
-        }
-        catch (Exception e) {
-            throw new BuildException(e);
-        }
-    }
-
-    /**
-     * Validates attributes that are not related to internal DefaultClassGenerator. Throws
-     * BuildException if attributes are invalid.
-     */
-    protected void validateAttributes() throws BuildException {
-        if (map == null && this.getProject() == null) {
-            throw new BuildException("either 'map' or 'project' is required.");
-        }
-    }
-
-    /**
-     * Sets the map.
-     * 
-     * @param map The map to set
-     */
-    public void setMap(File map) {
-        this.map = map;
-    }
-
-    /**
-     * Sets the additional DataMaps.
-     * 
-     * @param additionalMapsPath The additional DataMaps to set
-     */
-    public void setAdditionalMaps(Path additionalMapsPath) {
-        String additionalMapFilenames[] = additionalMapsPath.list();
-        this.additionalMaps = new File[additionalMapFilenames.length];
-
-        for (int i = 0; i < additionalMapFilenames.length; i++) {
-            additionalMaps[i] = new File(additionalMapFilenames[i]);
-        }
-    }
-
-    /**
-     * Sets the destDir.
-     */
-    public void setDestDir(File destDir) {
-        this.destDir = destDir;
-    }
-
-    /**
-     * Sets <code>overwrite</code> property.
-     */
-    public void setOverwrite(boolean overwrite) {
-        this.overwrite = overwrite;
-    }
-
-    /**
-     * Sets <code>makepairs</code> property.
-     */
-    public void setMakepairs(boolean makepairs) {
-        this.makepairs = makepairs;
-    }
-
-    /**
-     * Sets <code>template</code> property.
-     */
-    public void setTemplate(String template) {
-        this.template = template;
-    }
-
-    /**
-     * Sets <code>supertemplate</code> property.
-     */
-    public void setSupertemplate(String supertemplate) {
-        this.supertemplate = supertemplate;
-    }
-
-    /**
-     * Sets <code>querytemplate</code> property.
-     */
-    public void setQueryTemplate(String querytemplate) {
-        this.querytemplate = querytemplate;
-    }
-
-    /**
-     * Sets <code>querysupertemplate</code> property.
-     */
-    public void setQuerySupertemplate(String querysupertemplate) {
-        this.querysupertemplate = querysupertemplate;
-    }
-
-    /**
-     * Sets <code>usepkgpath</code> property.
-     */
-    public void setUsepkgpath(boolean usepkgpath) {
-        this.usepkgpath = usepkgpath;
-    }
-
-    /**
-     * Sets <code>superpkg</code> property.
-     */
-    public void setSuperpkg(String superpkg) {
-        this.superpkg = superpkg;
-    }
-
-    /**
-     * Sets <code>client</code> property.
-     */
-    public void setClient(boolean client) {
-        this.client = client;
-    }
-
-    /**
-     * Sets <code>encoding</code> property that allows to generate files using non-default
-     * encoding.
-     */
-    public void setEncoding(String encoding) {
-        this.encoding = encoding;
-    }
-
-    /**
-     * Sets <code>excludeEntitiesPattern</code> property.
-     */
-    public void setExcludeEntities(String excludeEntitiesPattern) {
-        this.excludeEntitiesPattern = excludeEntitiesPattern;
-    }
-
-    /**
-     * Sets <code>includeEntitiesPattern</code> property.
-     */
-    public void setIncludeEntities(String includeEntitiesPattern) {
-        this.includeEntitiesPattern = includeEntitiesPattern;
-    }
-
-    /**
-     * Sets <code>outputPattern</code> property.
-     */
-    public void setOutputPattern(String outputPattern) {
-        this.outputPattern = outputPattern;
-    }
-
-    /**
-     * Sets <code>mode</code> property.
-     */
-    public void setMode(String mode) {
-        this.mode = mode;
-    }
-
-    /**
-     * Sets <code>createpropertynames</code> property.
-     */
-    public void setCreatepropertynames(boolean createpropertynames) {
-        this.createpropertynames = createpropertynames;
-    }
-
-    public void setEmbeddabletemplate(String embeddabletemplate) {
-        this.embeddabletemplate = embeddabletemplate;
-    }
-
-    public void setEmbeddablesupertemplate(String embeddablesupertemplate) {
-        this.embeddablesupertemplate = embeddablesupertemplate;
-    }
-
-    /**
-     * Provides a <code>VPPConfig</code> object to configure. (Written with createConfig()
-     * instead of addConfig() to avoid run-time dependency on VPP).
-     */
-    public Object createConfig() {
-        this.vppConfig = new VPPConfig();
-        return this.vppConfig;
-    }
-
-    /**
-     * If no VppConfig element specified, use the default one.
-     */
-    private void initializeVppConfig() {
-        if (vppConfig == null) {
-            vppConfig = VPPConfig.getDefaultConfig(getProject());
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/cayenne/blob/c63b6be2/cayenne-tools/src/main/java/org/apache/cayenne/tools/CayenneTask.java
----------------------------------------------------------------------
diff --git a/cayenne-tools/src/main/java/org/apache/cayenne/tools/CayenneTask.java b/cayenne-tools/src/main/java/org/apache/cayenne/tools/CayenneTask.java
deleted file mode 100644
index 2bff0e3..0000000
--- a/cayenne-tools/src/main/java/org/apache/cayenne/tools/CayenneTask.java
+++ /dev/null
@@ -1,161 +0,0 @@
-/*****************************************************************
- *   Licensed to the Apache Software Foundation (ASF) under one
- *  or more contributor license agreements.  See the NOTICE file
- *  distributed with this work for additional information
- *  regarding copyright ownership.  The ASF licenses this file
- *  to you under the Apache License, Version 2.0 (the
- *  "License"); you may not use this file except in compliance
- *  with the License.  You may obtain a copy of the License at
- *
- *    http://www.apache.org/licenses/LICENSE-2.0
- *
- *  Unless required by applicable law or agreed to in writing,
- *  software distributed under the License is distributed on an
- *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- *  KIND, either express or implied.  See the License for the
- *  specific language governing permissions and limitations
- *  under the License.
- ****************************************************************/
-
-package org.apache.cayenne.tools;
-
-import java.io.File;
-
-import javax.sql.DataSource;
-
-import org.apache.cayenne.configuration.DataNodeDescriptor;
-import org.apache.cayenne.configuration.server.DbAdapterFactory;
-import org.apache.cayenne.dba.DbAdapter;
-import org.apache.cayenne.di.Injector;
-import org.apache.cayenne.map.DataMap;
-import org.apache.cayenne.map.MapLoader;
-import org.apache.tools.ant.Task;
-import org.apache.tools.ant.types.Path;
-import org.apache.tools.ant.types.Reference;
-import org.xml.sax.InputSource;
-
-/**
- * Base task for all Cayenne ant tasks, providing support for common
- * configuration items.
- * 
- * @since 1.2
- */
-public abstract class CayenneTask extends Task {
-    protected Path classpath;
-
-    protected String adapter;
-    protected File map;
-    protected String driver;
-    protected String url;
-    protected String userName;
-    protected String password;
-
-    /**
-     * Sets the classpath used by the task.
-     * 
-     * @param path
-     *            The classpath to set.
-     */
-    public void setClasspath(Path path) {
-        createClasspath().append(path);
-    }
-
-    /**
-     * Sets the classpath reference used by the task.
-     * 
-     * @param reference
-     *            The classpath reference to set.
-     */
-    public void setClasspathRef(Reference reference) {
-        createClasspath().setRefid(reference);
-    }
-
-    /**
-     * Convenience method for creating a classpath instance to be used for the
-     * task.
-     * 
-     * @return The new classpath.
-     */
-    private Path createClasspath() {
-        if (null == classpath) {
-            classpath = new Path(getProject());
-        }
-
-        return classpath.createPath();
-    }
-
-    /**
-     * Sets the map.
-     * 
-     * @param map
-     *            The map to set
-     */
-    public void setMap(File map) {
-        this.map = map;
-    }
-
-    /**
-     * Sets the db adapter.
-     * 
-     * @param adapter
-     *            The db adapter to set.
-     */
-    public void setAdapter(String adapter) {
-        this.adapter = adapter;
-    }
-
-    /**
-     * Sets the JDBC driver used to connect to the database server.
-     * 
-     * @param driver
-     *            The driver to set.
-     */
-    public void setDriver(String driver) {
-        this.driver = driver;
-    }
-
-    /**
-     * Sets the JDBC URL used to connect to the database server.
-     * 
-     * @param url
-     *            The url to set.
-     */
-    public void setUrl(String url) {
-        this.url = url;
-    }
-
-    /**
-     * Sets the username used to connect to the database server.
-     */
-    public void setUserName(String username) {
-        this.userName = username;
-    }
-
-    /**
-     * Sets the password used to connect to the database server.
-     * 
-     * @param password
-     *            The password to set.
-     */
-    public void setPassword(String password) {
-        this.password = password;
-    }
-
-    /** Loads and returns DataMap based on <code>map</code> attribute. */
-    protected DataMap loadDataMap() throws Exception {
-        InputSource in = new InputSource(map.getCanonicalPath());
-        return new MapLoader().loadDataMap(in);
-    }
-
-    protected DbAdapter getAdapter(Injector injector, DataSource dataSource)
-            throws Exception {
-
-        DbAdapterFactory adapterFactory = injector
-                .getInstance(DbAdapterFactory.class);
-
-        DataNodeDescriptor nodeDescriptor = new DataNodeDescriptor();
-        nodeDescriptor.setAdapterType(adapter);
-
-        return adapterFactory.createAdapter(nodeDescriptor, dataSource);
-    }
-}

http://git-wip-us.apache.org/repos/asf/cayenne/blob/c63b6be2/cayenne-tools/src/main/java/org/apache/cayenne/tools/DataPortTask.java
----------------------------------------------------------------------
diff --git a/cayenne-tools/src/main/java/org/apache/cayenne/tools/DataPortTask.java b/cayenne-tools/src/main/java/org/apache/cayenne/tools/DataPortTask.java
deleted file mode 100644
index 4b24035..0000000
--- a/cayenne-tools/src/main/java/org/apache/cayenne/tools/DataPortTask.java
+++ /dev/null
@@ -1,213 +0,0 @@
-/*****************************************************************
- *   Licensed to the Apache Software Foundation (ASF) under one
- *  or more contributor license agreements.  See the NOTICE file
- *  distributed with this work for additional information
- *  regarding copyright ownership.  The ASF licenses this file
- *  to you under the Apache License, Version 2.0 (the
- *  "License"); you may not use this file except in compliance
- *  with the License.  You may obtain a copy of the License at
- *
- *    http://www.apache.org/licenses/LICENSE-2.0
- *
- *  Unless required by applicable law or agreed to in writing,
- *  software distributed under the License is distributed on an
- *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- *  KIND, either express or implied.  See the License for the
- *  specific language governing permissions and limitations
- *  under the License.
- ****************************************************************/
-
-package org.apache.cayenne.tools;
-
-import org.apache.cayenne.access.DataDomain;
-import org.apache.cayenne.access.DataNode;
-import org.apache.cayenne.access.DataPort;
-import org.apache.cayenne.configuration.Constants;
-import org.apache.cayenne.configuration.server.ServerRuntime;
-import org.apache.cayenne.di.Binder;
-import org.apache.cayenne.di.Key;
-import org.apache.cayenne.di.Module;
-import org.apache.cayenne.map.DataMap;
-import org.apache.cayenne.map.DbEntity;
-import org.apache.cayenne.resource.FilesystemResourceLocator;
-import org.apache.cayenne.resource.ResourceLocator;
-import org.apache.cayenne.util.Util;
-import org.apache.tools.ant.BuildException;
-import org.apache.tools.ant.Project;
-
-import java.io.File;
-import java.util.Collection;
-import java.util.HashSet;
-
-/**
- * A "cdataport" Ant task implementing a frontend to DataPort allowing porting
- * database data using Ant build scripts.
- * 
- * @since 1.2: Prior to 1.2 DataPort classes were a part of cayenne-examples
- *        package.
- * @deprecated since 4.0
- */
-@Deprecated
-public class DataPortTask extends CayenneTask {
-
-    protected File projectFile;
-    protected String maps;
-    protected String srcNode;
-    protected String destNode;
-    protected String includeTables;
-    protected String excludeTables;
-    protected boolean cleanDest = true;
-
-    public DataPortTask() {
-        // set defaults
-        this.cleanDest = true;
-    }
-
-    @Override
-    public void execute() throws BuildException {
-
-        log("*** 'cdataport' task is deprecated and will be removed after 4.0",
-                Project.MSG_WARN);
-
-        validateParameters();
-
-        String projectFileLocation = projectFile.getName();
-        Module dataPortModule = new Module() {
-
-            public void configure(Binder binder) {
-                FilesystemResourceLocator filesystemResourceLocator = new FilesystemResourceLocator(projectFile);
-                binder.bind(ResourceLocator.class).toInstance(filesystemResourceLocator);
-                binder.bind(Key.get(ResourceLocator.class, Constants.SERVER_RESOURCE_LOCATOR))
-                        .toInstance(filesystemResourceLocator);
-            }
-        };
-
-        ServerRuntime runtime = new ServerRuntime(projectFileLocation,
-                dataPortModule);
-        DataDomain domain;
-
-        ClassLoader threadContextClassLoader = Thread.currentThread()
-                .getContextClassLoader();
-        try {
-            // need to set context class loader so that cayenne can find jdbc
-            // driver and
-            // PasswordEncoder
-            // TODO: andrus 04/11/2010 is this still relevant in 3.1?
-            Thread.currentThread().setContextClassLoader(
-                    getClass().getClassLoader());
-
-            domain = runtime.getDataDomain();
-        } catch (Exception ex) {
-            throw new BuildException(
-                    "Error loading Cayenne configuration from " + projectFile,
-                    ex);
-        } finally {
-            // set back to original ClassLoader
-            Thread.currentThread().setContextClassLoader(
-                    threadContextClassLoader);
-        }
-
-        // perform project validation
-        DataNode source = domain.getDataNode(srcNode);
-        if (source == null) {
-            throw new BuildException("srcNode not found in the project: "
-                    + srcNode);
-        }
-
-        DataNode destination = domain.getDataNode(destNode);
-        if (destination == null) {
-            throw new BuildException("destNode not found in the project: "
-                    + destNode);
-        }
-
-        log("Porting from '" + srcNode + "' to '" + destNode + "'.");
-
-        AntDataPortDelegate portDelegate = new AntDataPortDelegate(this, maps,
-                includeTables, excludeTables);
-        DataPort dataPort = new DataPort(portDelegate);
-        dataPort.setEntities(getAllEntities(source, destination));
-        dataPort.setCleaningDestination(cleanDest);
-        dataPort.setSourceNode(source);
-        dataPort.setDestinationNode(destination);
-
-        try {
-            dataPort.execute();
-        } catch (Exception e) {
-            Throwable topOfStack = Util.unwindException(e);
-            throw new BuildException("Error porting data: "
-                    + topOfStack.getMessage(), topOfStack);
-        }
-    }
-
-    protected Collection<DbEntity> getAllEntities(DataNode source,
-            DataNode target) {
-        // use a set to exclude duplicates, though a valid project will probably
-        // have
-        // none...
-        Collection<DbEntity> allEntities = new HashSet<DbEntity>();
-
-        for (DataMap map : source.getDataMaps()) {
-            allEntities.addAll(map.getDbEntities());
-        }
-
-        for (DataMap map : target.getDataMaps()) {
-            allEntities.addAll(map.getDbEntities());
-        }
-
-        log("Number of entities: " + allEntities.size(), Project.MSG_VERBOSE);
-
-        if (allEntities.size() == 0) {
-            log("No entities found for either source or target.");
-        }
-        return allEntities;
-    }
-
-    protected void validateParameters() throws BuildException {
-        if (projectFile == null) {
-            throw new BuildException(
-                    "Required 'projectFile' parameter is missing.");
-        }
-
-        if (!projectFile.exists()) {
-            throw new BuildException("'projectFile' does not exist: "
-                    + projectFile);
-        }
-
-        if (srcNode == null) {
-            throw new BuildException("Required 'srcNode' parameter is missing.");
-        }
-
-        if (destNode == null) {
-            throw new BuildException(
-                    "Required 'destNode' parameter is missing.");
-        }
-    }
-
-    public void setDestNode(String destNode) {
-        this.destNode = destNode;
-    }
-
-    public void setExcludeTables(String excludeTables) {
-        this.excludeTables = excludeTables;
-    }
-
-    public void setIncludeTables(String includeTables) {
-        this.includeTables = includeTables;
-    }
-
-    public void setMaps(String maps) {
-        this.maps = maps;
-    }
-
-    public void setProjectFile(File projectFile) {
-        this.projectFile = projectFile;
-    }
-
-    public void setSrcNode(String srcNode) {
-        this.srcNode = srcNode;
-    }
-
-    public void setCleanDest(boolean flag) {
-        this.cleanDest = flag;
-    }
-}

http://git-wip-us.apache.org/repos/asf/cayenne/blob/c63b6be2/cayenne-tools/src/main/java/org/apache/cayenne/tools/DbGeneratorTask.java
----------------------------------------------------------------------
diff --git a/cayenne-tools/src/main/java/org/apache/cayenne/tools/DbGeneratorTask.java b/cayenne-tools/src/main/java/org/apache/cayenne/tools/DbGeneratorTask.java
deleted file mode 100644
index ce2e574..0000000
--- a/cayenne-tools/src/main/java/org/apache/cayenne/tools/DbGeneratorTask.java
+++ /dev/null
@@ -1,155 +0,0 @@
-/*****************************************************************
- *   Licensed to the Apache Software Foundation (ASF) under one
- *  or more contributor license agreements.  See the NOTICE file
- *  distributed with this work for additional information
- *  regarding copyright ownership.  The ASF licenses this file
- *  to you under the Apache License, Version 2.0 (the
- *  "License"); you may not use this file except in compliance
- *  with the License.  You may obtain a copy of the License at
- *
- *    http://www.apache.org/licenses/LICENSE-2.0
- *
- *  Unless required by applicable law or agreed to in writing,
- *  software distributed under the License is distributed on an
- *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- *  KIND, either express or implied.  See the License for the
- *  specific language governing permissions and limitations
- *  under the License.
- ****************************************************************/
-
-package org.apache.cayenne.tools;
-
-import org.apache.cayenne.access.DbGenerator;
-import org.apache.cayenne.datasource.DriverDataSource;
-import org.apache.cayenne.dba.DbAdapter;
-import org.apache.cayenne.dbsync.DbSyncModule;
-import org.apache.cayenne.di.DIBootstrap;
-import org.apache.cayenne.di.Injector;
-import org.apache.cayenne.log.NoopJdbcEventLogger;
-import org.apache.cayenne.map.DataMap;
-import org.apache.cayenne.map.DbEntity;
-import org.apache.cayenne.dbsync.reverse.configuration.ToolsModule;
-import org.apache.cayenne.util.Util;
-import org.apache.commons.logging.Log;
-import org.apache.tools.ant.BuildException;
-import org.apache.tools.ant.Project;
-
-import java.sql.Driver;
-import java.util.Collections;
-
-/**
- * An Ant Task that is a frontend to Cayenne DbGenerator allowing schema
- * generation from DataMap using Ant.
- * 
- * @since 1.2
- */
-// TODO: support classpath attribute for loading the driver
-public class DbGeneratorTask extends CayenneTask {
-
-	// DbGenerator options... setup defaults similar to DbGenerator itself:
-	// all DROP set to false, all CREATE - to true
-	protected boolean dropTables;
-	protected boolean dropPK;
-	protected boolean createTables = true;
-	protected boolean createPK = true;
-	protected boolean createFK = true;
-
-	@Override
-	public void execute() {
-
-		Log logger = new AntLogger(this);
-
-		log(String.format("connection settings - [driver: %s, url: %s, username: %s]", driver, url, userName),
-				Project.MSG_VERBOSE);
-
-		log(String.format(
-				"generator options - [dropTables: %s, dropPK: %s, createTables: %s, createPK: %s, createFK: %s]",
-				dropTables, dropPK, createTables, createPK, createFK), Project.MSG_VERBOSE);
-
-		validateAttributes();
-
-		ClassLoader loader = null;
-		Injector injector = DIBootstrap.createInjector(new DbSyncModule(), new ToolsModule(logger));
-		try {
-			loader = Thread.currentThread().getContextClassLoader();
-			Thread.currentThread().setContextClassLoader(DbGeneratorTask.class.getClassLoader());
-
-			// Load the data map and run the db generator.
-			DataMap dataMap = loadDataMap();
-
-			// load driver taking custom CLASSPATH into account...
-			DriverDataSource dataSource = new DriverDataSource((Driver) Class.forName(driver).newInstance(), url,
-					userName, password);
-
-			DbAdapter adapter = getAdapter(injector, dataSource);
-
-			DbGenerator generator = new DbGenerator(adapter, dataMap, Collections.<DbEntity> emptyList(), null,
-					NoopJdbcEventLogger.getInstance());
-			generator.setShouldCreateFKConstraints(createFK);
-			generator.setShouldCreatePKSupport(createPK);
-			generator.setShouldCreateTables(createTables);
-			generator.setShouldDropPKSupport(dropPK);
-			generator.setShouldDropTables(dropTables);
-
-			generator.runGenerator(dataSource);
-		} catch (Exception ex) {
-			Throwable th = Util.unwindException(ex);
-
-			String message = "Error generating database";
-
-			if (th.getLocalizedMessage() != null) {
-				message += ": " + th.getLocalizedMessage();
-			}
-
-			log(message, Project.MSG_ERR);
-			throw new BuildException(message, th);
-		} finally {
-			Thread.currentThread().setContextClassLoader(loader);
-			injector.shutdown();
-		}
-	}
-
-	/**
-	 * Validates attributes that are not related to internal
-	 * DefaultClassGenerator. Throws BuildException if attributes are invalid.
-	 */
-	protected void validateAttributes() throws BuildException {
-		StringBuilder error = new StringBuilder("");
-
-		if (map == null) {
-			error.append("The 'map' attribute must be set.\n");
-		}
-
-		if (driver == null) {
-			error.append("The 'driver' attribute must be set.\n");
-		}
-
-		if (url == null) {
-			error.append("The 'adapter' attribute must be set.\n");
-		}
-
-		if (error.length() > 0) {
-			throw new BuildException(error.toString());
-		}
-	}
-
-	public void setCreateFK(boolean createFK) {
-		this.createFK = createFK;
-	}
-
-	public void setCreatePK(boolean createPK) {
-		this.createPK = createPK;
-	}
-
-	public void setCreateTables(boolean createTables) {
-		this.createTables = createTables;
-	}
-
-	public void setDropPK(boolean dropPK) {
-		this.dropPK = dropPK;
-	}
-
-	public void setDropTables(boolean dropTables) {
-		this.dropTables = dropTables;
-	}
-}

http://git-wip-us.apache.org/repos/asf/cayenne/blob/c63b6be2/cayenne-tools/src/main/java/org/apache/cayenne/tools/DbImporterTask.java
----------------------------------------------------------------------
diff --git a/cayenne-tools/src/main/java/org/apache/cayenne/tools/DbImporterTask.java b/cayenne-tools/src/main/java/org/apache/cayenne/tools/DbImporterTask.java
deleted file mode 100644
index 6c939c1..0000000
--- a/cayenne-tools/src/main/java/org/apache/cayenne/tools/DbImporterTask.java
+++ /dev/null
@@ -1,241 +0,0 @@
-/*****************************************************************
- *   Licensed to the Apache Software Foundation (ASF) under one
- *  or more contributor license agreements.  See the NOTICE file
- *  distributed with this work for additional information
- *  regarding copyright ownership.  The ASF licenses this file
- *  to you under the Apache License, Version 2.0 (the
- *  "License"); you may not use this file except in compliance
- *  with the License.  You may obtain a copy of the License at
- *
- *    http://www.apache.org/licenses/LICENSE-2.0
- *
- *  Unless required by applicable law or agreed to in writing,
- *  software distributed under the License is distributed on an
- *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- *  KIND, either express or implied.  See the License for the
- *  specific language governing permissions and limitations
- *  under the License.
- ****************************************************************/
-package org.apache.cayenne.tools;
-
-import org.apache.cayenne.conn.DataSourceInfo;
-import org.apache.cayenne.dbsync.DbSyncModule;
-import org.apache.cayenne.dbsync.naming.DefaultObjectNameGenerator;
-import org.apache.cayenne.dbsync.reverse.configuration.ToolsModule;
-import org.apache.cayenne.dbsync.reverse.dbimport.Catalog;
-import org.apache.cayenne.dbsync.reverse.dbimport.DbImportAction;
-import org.apache.cayenne.dbsync.reverse.dbimport.DbImportConfigurationValidator;
-import org.apache.cayenne.dbsync.reverse.dbimport.DbImportConfiguration;
-import org.apache.cayenne.dbsync.reverse.dbimport.DbImportModule;
-import org.apache.cayenne.dbsync.reverse.dbimport.ExcludeColumn;
-import org.apache.cayenne.dbsync.reverse.dbimport.ExcludeProcedure;
-import org.apache.cayenne.dbsync.reverse.dbimport.ExcludeTable;
-import org.apache.cayenne.dbsync.reverse.dbimport.IncludeColumn;
-import org.apache.cayenne.dbsync.reverse.dbimport.IncludeProcedure;
-import org.apache.cayenne.dbsync.reverse.dbimport.IncludeTable;
-import org.apache.cayenne.dbsync.reverse.dbimport.ReverseEngineering;
-import org.apache.cayenne.dbsync.reverse.dbimport.Schema;
-import org.apache.cayenne.dbsync.reverse.filters.FiltersConfigBuilder;
-import org.apache.cayenne.di.DIBootstrap;
-import org.apache.cayenne.di.Injector;
-import org.apache.cayenne.util.Util;
-import org.apache.commons.logging.Log;
-import org.apache.tools.ant.BuildException;
-import org.apache.tools.ant.Project;
-import org.apache.tools.ant.Task;
-
-import java.io.File;
-
-public class DbImporterTask extends Task {
-
-    private final DbImportConfiguration config;
-    private ReverseEngineering reverseEngineering;
-
-    public DbImporterTask() {
-        this.config = new DbImportConfiguration();
-        this.config.setUsePrimitives(true);
-        this.config.setNamingStrategy(DefaultObjectNameGenerator.class.getName());
-
-        // reverse engineering config is flattened into task...
-        this.reverseEngineering = new ReverseEngineering();
-    }
-
-    public void addIncludeColumn(IncludeColumn includeColumn) {
-        reverseEngineering.addIncludeColumn(includeColumn);
-    }
-
-    public void addExcludeColumn(ExcludeColumn excludeColumn) {
-        reverseEngineering.addExcludeColumn(excludeColumn);
-    }
-
-    public void addIncludeTable(IncludeTable includeTable) {
-        reverseEngineering.addIncludeTable(includeTable);
-    }
-
-    public void addExcludeTable(ExcludeTable excludeTable) {
-        reverseEngineering.addExcludeTable(excludeTable);
-    }
-
-    public void addIncludeProcedure(IncludeProcedure includeProcedure) {
-        reverseEngineering.addIncludeProcedure(includeProcedure);
-    }
-
-    public void addExcludeProcedure(ExcludeProcedure excludeProcedure) {
-        reverseEngineering.addExcludeProcedure(excludeProcedure);
-    }
-
-    public void setSkipRelationshipsLoading(boolean skipRelationshipsLoading) {
-        reverseEngineering.setSkipRelationshipsLoading(skipRelationshipsLoading);
-    }
-
-    public void setSkipPrimaryKeyLoading(boolean skipPrimaryKeyLoading) {
-        reverseEngineering.setSkipPrimaryKeyLoading(skipPrimaryKeyLoading);
-    }
-
-    public void addConfiguredTableType(AntTableType type) {
-        reverseEngineering.addTableType(type.getName());
-    }
-
-    public void addConfiguredSchema(Schema schema) {
-        reverseEngineering.addSchema(schema);
-    }
-
-    public void addCatalog(Catalog catalog) {
-        reverseEngineering.addCatalog(catalog);
-    }
-
-    @Override
-    public void execute() {
-        config.setFiltersConfig(new FiltersConfigBuilder(reverseEngineering).build());
-        validateAttributes();
-
-        Log logger = new AntLogger(this);
-        config.setLogger(logger);
-        config.setSkipRelationshipsLoading(reverseEngineering.getSkipRelationshipsLoading());
-        config.setSkipPrimaryKeyLoading(reverseEngineering.getSkipPrimaryKeyLoading());
-        config.setTableTypes(reverseEngineering.getTableTypes());
-
-        Injector injector = DIBootstrap.createInjector(new DbSyncModule(), new ToolsModule(logger), new DbImportModule());
-        DbImportConfigurationValidator validator = new DbImportConfigurationValidator(reverseEngineering, config, injector);
-        try {
-            validator.validate();
-        } catch (Exception ex) {
-            throw new BuildException(ex.getMessage(), ex);
-        }
-
-        try {
-            injector.getInstance(DbImportAction.class).execute(config);
-        } catch (Exception ex) {
-            Throwable th = Util.unwindException(ex);
-
-            String message = "Error importing database schema";
-
-            if (th.getLocalizedMessage() != null) {
-                message += ": " + th.getLocalizedMessage();
-            }
-
-            log(message, Project.MSG_ERR);
-            throw new BuildException(message, th);
-        } finally {
-            injector.shutdown();
-        }
-    }
-
-    /**
-     * Validates attributes that are not related to internal
-     * DefaultClassGenerator. Throws BuildException if attributes are invalid.
-     */
-    protected void validateAttributes() throws BuildException {
-        StringBuilder error = new StringBuilder("");
-
-        if (config.getTargetDataMap() == null) {
-            error.append("The 'map' attribute must be set.\n");
-        }
-
-        DataSourceInfo dataSourceInfo = config.getDataSourceInfo();
-        if (dataSourceInfo.getJdbcDriver() == null) {
-            error.append("The 'driver' attribute must be set.\n");
-        }
-
-        if (dataSourceInfo.getDataSourceUrl() == null) {
-            error.append("The 'url' attribute must be set.\n");
-        }
-
-        if (error.length() > 0) {
-            throw new BuildException(error.toString());
-        }
-    }
-
-    /**
-     * @since 4.0
-     */
-    public void setDefaultPackage(String defaultPackage) {
-        config.setDefaultPackage(defaultPackage);
-    }
-
-    /**
-     * @since 4.0
-     */
-    public void setMeaningfulPkTables(String meaningfulPkTables) {
-        config.setMeaningfulPkTables(meaningfulPkTables);
-    }
-
-    public void setNamingStrategy(String namingStrategy) {
-        config.setNamingStrategy(namingStrategy);
-    }
-
-    /**
-     * @since 4.0
-     */
-    public void setStripFromTableNames(String pattern) {
-        config.setStripFromTableNames(pattern);
-    }
-
-    public void setAdapter(String adapter) {
-        config.setAdapter(adapter);
-    }
-
-    public void setDriver(String driver) {
-        config.setDriver(driver);
-    }
-
-    public void setPassword(String password) {
-        config.setPassword(password);
-    }
-
-    public void setUrl(String url) {
-        config.setUrl(url);
-    }
-
-    public void setUserName(String username) {
-        config.setUsername(username);
-    }
-
-    public void setUsePrimitives(boolean flag) {
-        config.setUsePrimitives(flag);
-    }
-
-    public void setForceDataMapCatalog(boolean flag) {
-        config.setForceDataMapCatalog(flag);
-    }
-
-    public void setForceDataMapSchema(boolean flag) {
-        config.setForceDataMapSchema(flag);
-    }
-
-    public ReverseEngineering getReverseEngineering() {
-        return reverseEngineering;
-    }
-
-    public File getMap() {
-        return config.getTargetDataMap();
-    }
-
-    public void setMap(File map) {
-        config.setTargetDataMap(map);
-    }
-
-    public DbImportConfiguration toParameters() {
-        return config;
-    }
-}

http://git-wip-us.apache.org/repos/asf/cayenne/blob/c63b6be2/cayenne-tools/src/main/java/org/apache/cayenne/tools/package.html
----------------------------------------------------------------------
diff --git a/cayenne-tools/src/main/java/org/apache/cayenne/tools/package.html b/cayenne-tools/src/main/java/org/apache/cayenne/tools/package.html
deleted file mode 100644
index f25bcbe..0000000
--- a/cayenne-tools/src/main/java/org/apache/cayenne/tools/package.html
+++ /dev/null
@@ -1,23 +0,0 @@
-<!--
-   Licensed to the Apache Software Foundation (ASF) under one
-   or more contributor license agreements.  See the NOTICE file
-   distributed with this work for additional information
-   regarding copyright ownership.  The ASF licenses this file
-   to you under the Apache License, Version 2.0 (the
-   "License"); you may not use this file except in compliance
-   with the License.  You may obtain a copy of the License at
-
-     http://www.apache.org/licenses/LICENSE-2.0
-
-   Unless required by applicable law or agreed to in writing,
-   software distributed under the License is distributed on an
-   "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-   KIND, either express or implied.  See the License for the
-   specific language governing permissions and limitations
-   under the License.
--->
-<html>
-<body>
-Command line tools and Ant tasks. 
-</body>
-</html>

http://git-wip-us.apache.org/repos/asf/cayenne/blob/c63b6be2/cayenne-tools/src/main/resources/org/apache/cayenne/tools/antlib.xml
----------------------------------------------------------------------
diff --git a/cayenne-tools/src/main/resources/org/apache/cayenne/tools/antlib.xml b/cayenne-tools/src/main/resources/org/apache/cayenne/tools/antlib.xml
deleted file mode 100644
index bfebaf6..0000000
--- a/cayenne-tools/src/main/resources/org/apache/cayenne/tools/antlib.xml
+++ /dev/null
@@ -1,25 +0,0 @@
-<!--
-   Licensed to the Apache Software Foundation (ASF) under one
-   or more contributor license agreements.  See the NOTICE file
-   distributed with this work for additional information
-   regarding copyright ownership.  The ASF licenses this file
-   to you under the Apache License, Version 2.0 (the
-   "License"); you may not use this file except in compliance
-   with the License.  You may obtain a copy of the License at
- 
-     http://www.apache.org/licenses/LICENSE-2.0
- 
-   Unless required by applicable law or agreed to in writing,
-   software distributed under the License is distributed on an
-   "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-   KIND, either express or implied.  See the License for the
-   specific language governing permissions and limitations
-   under the License.
--->
-
-<antlib>
-  <taskdef name="cgen" classname="org.apache.cayenne.tools.CayenneGeneratorTask"/>
-  <taskdef name="cdbgen" classname="org.apache.cayenne.tools.DbGeneratorTask"/>
-  <taskdef name="cdataport" classname="org.apache.cayenne.tools.DataPortTask"/>
-  <taskdef name="cdbimport" classname="org.apache.cayenne.tools.DbImporterTask"/>
-</antlib>

http://git-wip-us.apache.org/repos/asf/cayenne/blob/c63b6be2/cayenne-tools/src/main/resources/templates/v1_2/client-datamap-singleclass.vm
----------------------------------------------------------------------
diff --git a/cayenne-tools/src/main/resources/templates/v1_2/client-datamap-singleclass.vm b/cayenne-tools/src/main/resources/templates/v1_2/client-datamap-singleclass.vm
deleted file mode 100644
index d0c7f6c..0000000
--- a/cayenne-tools/src/main/resources/templates/v1_2/client-datamap-singleclass.vm
+++ /dev/null
@@ -1,96 +0,0 @@
-##   Licensed to the Apache Software Foundation (ASF) under one
-##  or more contributor license agreements.  See the NOTICE file
-##  distributed with this work for additional information
-##  regarding copyright ownership.  The ASF licenses this file
-##  to you under the Apache License, Version 2.0 (the
-##  "License"); you may not use this file except in compliance
-##  with the License.  You may obtain a copy of the License at
-##
-##    http://www.apache.org/licenses/LICENSE-2.0
-##
-##  Unless required by applicable law or agreed to in writing,
-##  software distributed under the License is distributed on an
-##  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-##  KIND, either express or implied.  See the License for the
-##  specific language governing permissions and limitations
-##  under the License.
-##
-##Terminology:
-##	Base class - super superclass of entity, ie, org.apache.cayenne.CayenneDataObject or MyBaseClass
-##  Super class - superclass of entity, ie,  org.apache.cayenne.art.auto._Artist
-##	Sub class - class of entity, ie, org.apache.cayenne.art.Artist
-##
-##  Classes available in template
-##    object (duplicated as 'objEntity') - the ObjEntity class: See org.apache.cayenne.map.ObjectEntity
-##    stringUtils - class for string "helper" functions: See org.apache.cayenne.gen.StringUtils
-##    dataMapUtils - class for query "helper" functions: See org.apache.cayenne.gen.DataMapUtils
-##    importUtils - class for import statement management: See org.apache.cayenne.gen.ImportUtils
-##    superClassName
-##    superPackageName
-##    subClassName
-##    subPackageName
-##    baseClassName
-##    basePackageName 
-##
-##
-${importUtils.setPackage($subPackageName)}##
-${importUtils.addReservedType("${subPackageName}.${subClassName}")}##
-${importUtils.addType("${basePackageName}.${baseClassName}")}##
-${importUtils.addType('java.util.List')}
-${importUtils.addType('java.util.Map')}
-${importUtils.addType('java.util.HashMap')}
-${importUtils.addType('org.apache.cayenne.ObjectContext')}
-#foreach( $selectQuery in ${object.SelectQueries})
-${importUtils.addType(${selectQuery.Root.ClassName})}
-#foreach( $parameter in ${dataMapUtils.getParameterNames(${selectQuery})})
-${importUtils.addType(${dataMapUtils.getParameterType(${selectQuery}, ${parameter})})}
-#end
-#end
-${importUtils.generate()}
-
-/**
- * This class was generated by Cayenne.
- * It is probably a good idea to avoid changing this class manually,
- * since it may be overwritten next time code is regenerated.
- * If you need to make any customizations, please use subclass.
- */
-public class ${subClassName} {
-#if( ${object.hasQueryNames()})
-#foreach( $qname in ${object.QueryNames})
-
-    public static final String ${stringUtils.capitalizedAsConstant($qname)}_QUERYNAME = "$qname";
-#end
-#end
-
-private static ${subClassName} instance;
-
-    private ${subClassName}() {}
-
-    public ${subClassName} getInstance() {
-      if( instance == null) {
-        instance = new ${subClassName}();
-      }
-      return instance;
-    }
-
-#foreach( $selectQuery in ${object.SelectQueries})
-    public List<${stringUtils.stripPackageName($selectQuery.Root.ClassName)}> perform${dataMapUtils.getQueryMethodName(${selectQuery})}(ObjectContext context #foreach( $parameter in ${dataMapUtils.getParameterNames(${selectQuery})}), ${stringUtils.stripPackageName(${dataMapUtils.getParameterType(${selectQuery}, ${parameter})})} ${parameter} #end) {
-    #if(${dataMapUtils.hasParameters($selectQuery)})
-      String[] parameters = new String[] {
-      #foreach( $parameter in ${dataMapUtils.getParameterNames(${selectQuery})})
-      "${parameter}",
-      #end
-      };
-
-      Object[] values = new Object[] {
-      #foreach( $parameter in ${dataMapUtils.getParameterNames(${selectQuery})})
-      ${parameter},
-      #end
-      };
-    #end
-
-      NamedQuery query = new NamedQuery("${selectQuery.Name}"#if(${dataMapUtils.hasParameters($selectQuery)}), parameters, values#end);
-      return context.performQuery(query);
-    }
-#end
-}

http://git-wip-us.apache.org/repos/asf/cayenne/blob/c63b6be2/cayenne-tools/src/main/resources/templates/v1_2/client-datamap-subclass.vm
----------------------------------------------------------------------
diff --git a/cayenne-tools/src/main/resources/templates/v1_2/client-datamap-subclass.vm b/cayenne-tools/src/main/resources/templates/v1_2/client-datamap-subclass.vm
deleted file mode 100644
index f5e0474..0000000
--- a/cayenne-tools/src/main/resources/templates/v1_2/client-datamap-subclass.vm
+++ /dev/null
@@ -1,47 +0,0 @@
-##   Licensed to the Apache Software Foundation (ASF) under one
-##  or more contributor license agreements.  See the NOTICE file
-##  distributed with this work for additional information
-##  regarding copyright ownership.  The ASF licenses this file
-##  to you under the Apache License, Version 2.0 (the
-##  "License"); you may not use this file except in compliance
-##  with the License.  You may obtain a copy of the License at
-##
-##    http://www.apache.org/licenses/LICENSE-2.0
-##
-##  Unless required by applicable law or agreed to in writing,
-##  software distributed under the License is distributed on an
-##  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-##  KIND, either express or implied.  See the License for the
-##  specific language governing permissions and limitations
-##  under the License.
-##
-##Terminology:
-##	Base class - super superclass of entity, ie, org.apache.cayenne.CayenneDataObject or MyBaseClass
-##  Super class - superclass of entity, ie,  org.apache.cayenne.art.auto._Artist
-##	Sub class - class of entity, ie, org.apache.cayenne.art.Artist
-##
-##  Classes available in template
-##    stringUtils - class for string "helper" functions: See org.apache.cayenne.gen.StringUtils
-##    dataMapUtils - class for query "helper" functions: See org.apache.cayenne.gen.dataMapUtils
-##    importUtils - class for import statement management: See org.apache.cayenne.gen.ImportUtils
-##
-##
-${importUtils.setPackage($subPackageName)}##
-${importUtils.addReservedType("${subPackageName}.${subClassName}")}##
-${importUtils.addType("${superPackageName}.${superClassName}")}##
-${importUtils.generate()}
-
-public class ${subClassName} extends ${superClassName} {
-
-    private static ${subClassName} instance;
-
-    private ${subClassName}() {}
-
-    public static ${subClassName} getInstance() {
-        if(instance == null) {
-            instance = new ${subClassName}();
-        }
-
-        return instance;
-    }
-}

http://git-wip-us.apache.org/repos/asf/cayenne/blob/c63b6be2/cayenne-tools/src/main/resources/templates/v1_2/client-datamap-superclass.vm
----------------------------------------------------------------------
diff --git a/cayenne-tools/src/main/resources/templates/v1_2/client-datamap-superclass.vm b/cayenne-tools/src/main/resources/templates/v1_2/client-datamap-superclass.vm
deleted file mode 100644
index c196301..0000000
--- a/cayenne-tools/src/main/resources/templates/v1_2/client-datamap-superclass.vm
+++ /dev/null
@@ -1,83 +0,0 @@
-##   Licensed to the Apache Software Foundation (ASF) under one
-##  or more contributor license agreements.  See the NOTICE file
-##  distributed with this work for additional information
-##  regarding copyright ownership.  The ASF licenses this file
-##  to you under the Apache License, Version 2.0 (the
-##  "License"); you may not use this file except in compliance
-##  with the License.  You may obtain a copy of the License at
-##
-##    http://www.apache.org/licenses/LICENSE-2.0
-##
-##  Unless required by applicable law or agreed to in writing,
-##  software distributed under the License is distributed on an
-##  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-##  KIND, either express or implied.  See the License for the
-##  specific language governing permissions and limitations
-##  under the License.
-##
-##Terminology:
-##	Base class - super superclass of entity, ie, org.apache.cayenne.CayenneDataObject or MyBaseClass
-##  Super class - superclass of entity, ie,  org.apache.cayenne.art.auto._Artist
-##	Sub class - class of entity, ie, org.apache.cayenne.art.Artist
-##
-##  Classes available in template
-##    stringUtils - class for string "helper" functions: See org.apache.cayenne.gen.StringUtils
-##    dataMapUtils - class for query "helper" functions: See org.apache.cayenne.gen.DataMapUtils
-##    importUtils - class for import statement management: See org.apache.cayenne.gen.ImportUtils
-##    superClassName
-##    superPackageName
-##    subClassName
-##    subPackageName
-##    baseClassName
-##    basePackageName
-##
-${importUtils.setPackage($superPackageName)}##
-#if(${superPackageName})${importUtils.addReservedType("${superPackageName}.${superClassName}")}#end##
-#if(${basePackageName})${importUtils.addType("${basePackageName}.${baseClassName}")}#end##
-#if( ${object.hasSelectQueries()} ) 
-${importUtils.addType('java.util.List')}##
-${importUtils.addType('org.apache.cayenne.ObjectContext')}##
-${importUtils.addType('org.apache.cayenne.query.NamedQuery')}##
-#foreach( $selectQuery in ${object.SelectQueries})
-${importUtils.addType(${selectQuery.Root.ClientClassName})}##
-#foreach( $parameter in ${dataMapUtils.getParameterNames(${selectQuery})})
-${importUtils.addType(${dataMapUtils.getParameterType(${selectQuery}, ${parameter})})}##
-#end    
-#end
-#end
-${importUtils.generate()}
-
-/**
- * This class was generated by Cayenne.
- * It is probably a good idea to avoid changing this class manually,
- * since it may be overwritten next time code is regenerated.
- * If you need to make any customizations, please use subclass.
- */
-public class ${superClassName} {
-#if( ${object.hasQueryNames()})
-#foreach( $qname in ${object.QueryNames})
-
-    public static final String ${stringUtils.capitalizedAsConstant($qname)}_QUERYNAME = "$qname";
-#end
-#end
-#foreach( $selectQuery in ${object.SelectQueries})
-
-    public List<${stringUtils.stripPackageName($selectQuery.Root.ClientClassName)}> perform${dataMapUtils.getQueryMethodName(${selectQuery})}(ObjectContext context #foreach( $parameter in ${dataMapUtils.getParameterNames(${selectQuery})}), ${stringUtils.stripPackageName(${dataMapUtils.getParameterType(${selectQuery}, ${parameter})})} ${parameter}#end) {
-#if(${dataMapUtils.hasParameters($selectQuery)})
-        String[] parameters = {
-#foreach( $parameter in ${dataMapUtils.getParameterNames(${selectQuery})})
-            "${parameter}",
-#end
-        };
-
-        Object[] values = {
-#foreach( $parameter in ${dataMapUtils.getParameterNames(${selectQuery})})
-            ${parameter},
-#end
-        };
-
-#end
-        return context.performQuery(new NamedQuery("${selectQuery.Name}"#if(${dataMapUtils.hasParameters($selectQuery)}), parameters, values#end));
-    }
-#end
-}

http://git-wip-us.apache.org/repos/asf/cayenne/blob/c63b6be2/cayenne-tools/src/main/resources/templates/v1_2/client-subclass.vm
----------------------------------------------------------------------
diff --git a/cayenne-tools/src/main/resources/templates/v1_2/client-subclass.vm b/cayenne-tools/src/main/resources/templates/v1_2/client-subclass.vm
deleted file mode 100644
index d28de85..0000000
--- a/cayenne-tools/src/main/resources/templates/v1_2/client-subclass.vm
+++ /dev/null
@@ -1,57 +0,0 @@
-##   Licensed to the Apache Software Foundation (ASF) under one
-##  or more contributor license agreements.  See the NOTICE file
-##  distributed with this work for additional information
-##  regarding copyright ownership.  The ASF licenses this file
-##  to you under the Apache License, Version 2.0 (the
-##  "License"); you may not use this file except in compliance
-##  with the License.  You may obtain a copy of the License at
-##
-##    http://www.apache.org/licenses/LICENSE-2.0
-##
-##  Unless required by applicable law or agreed to in writing,
-##  software distributed under the License is distributed on an
-##  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-##  KIND, either express or implied.  See the License for the
-##  specific language governing permissions and limitations
-##  under the License.
-##
-##  A default Cayenne template for a client-side subclass in a generated subclass/superclass pair.
-## 
-##  Terminology:
-##  Base class - super superclass of entity, ie, org.apache.cayenne.CayenneDataObject or MyBaseClass
-##  Super class - superclass of entity, ie,  org.apache.cayenne.art.auto._Artist
-##  Sub class - class of entity, ie, org.apache.cayenne.art.Artist
-##
-##  Classes available in template
-##    object (duplicated as 'objEntity') - the ObjEntity class: See org.apache.cayenne.map.ObjectEntity
-##    stringUtils - class for string "helper" functions: See org.apache.cayenne.gen.StringUtils
-##    entityUtils - class for entity "helper" functions: See org.apache.cayenne.gen.EntityUtils
-##    importUtils - class for import statement management: See org.apache.cayenne.gen.ImportUtils
-##    superClassName
-##    superPackageName
-##    subClassName
-##    subPackageName
-##    baseClassName
-##    basePackageName 
-##
-${importUtils.setPackage($subPackageName)}##
-${importUtils.addReservedType("${$subPackageName}.${subClassName}")}##
-${importUtils.addType("${superPackageName}.${superClassName}")}##
-${importUtils.generate()}
-
-/**
- * A persistent class mapped as "${object.name}" Cayenne entity.
- */
-public#if("true" == "${object.getIsAbstract()}") abstract#end class ${subClassName} extends ${superClassName} {
-
-     private static final long serialVersionUID = 1L; 
-     
-##callback methods
-#foreach( $cbname in ${entityUtils.callbackNames})
-    @Override
-    protected void ${cbname}() {
-        //TODO: Implement ${cbname}
-    }
-
-#end
-}


[03/10] cayenne git commit: CAY-2215 split cayenne-tools into cayenne-cgen and cayenne-ant

Posted by nt...@apache.org.
http://git-wip-us.apache.org/repos/asf/cayenne/blob/c63b6be2/cayenne-tools/src/main/resources/templates/v1_2/client-superclass.vm
----------------------------------------------------------------------
diff --git a/cayenne-tools/src/main/resources/templates/v1_2/client-superclass.vm b/cayenne-tools/src/main/resources/templates/v1_2/client-superclass.vm
deleted file mode 100644
index f8c9cbe..0000000
--- a/cayenne-tools/src/main/resources/templates/v1_2/client-superclass.vm
+++ /dev/null
@@ -1,248 +0,0 @@
-##   Licensed to the Apache Software Foundation (ASF) under one
-##  or more contributor license agreements.  See the NOTICE file
-##  distributed with this work for additional information
-##  regarding copyright ownership.  The ASF licenses this file
-##  to you under the Apache License, Version 2.0 (the
-##  "License"); you may not use this file except in compliance
-##  with the License.  You may obtain a copy of the License at
-##
-##    http://www.apache.org/licenses/LICENSE-2.0
-##
-##  Unless required by applicable law or agreed to in writing,
-##  software distributed under the License is distributed on an
-##  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-##  KIND, either express or implied.  See the License for the
-##  specific language governing permissions and limitations
-##  under the License.
-##
-##Terminology:
-##	Base class - super superclass of entity, ie, org.apache.cayenne.PersistentObject or MyBaseClass
-##  Super class - superclass of entity, ie,  org.apache.cayenne.art.auto._Artist
-##	Sub class - class of entity, ie, org.apache.cayenne.art.Artist
-##
-##  Classes available in template
-##    object (duplicated as 'objEntity') - the ObjEntity class: See org.apache.cayenne.map.ObjectEntity
-##    stringUtils - class for string "helper" functions: See org.apache.cayenne.gen.StringUtils
-##    entityUtils - class for entity "helper" functions: See org.apache.cayenne.gen.EntityUtils
-##    importUtils - class for import statement management: See org.apache.cayenne.gen.ImportUtils
-##    superClassName
-##    superPackageName
-##    subClassName
-##    subPackageName
-##    baseClassName
-##    basePackageName
-##
-##
-${importUtils.setPackage($superPackageName)}##
-${importUtils.addReservedType("${$superPackageName}.${superClassName}")}##
-${importUtils.addType("${basePackageName}.${baseClassName}")}##
-#if((${object.DeclaredAttributes} && !${object.DeclaredAttributes.isEmpty()}) || (${object.DeclaredRelationships} && !${object.DeclaredRelationships.isEmpty()}))
-${importUtils.addType('org.apache.cayenne.exp.Property')}##
-#end
-#foreach( $attr in ${object.DeclaredAttributes} )
-$importUtils.addType(${attr.Type})##
-#end
-#foreach( $rel in ${object.DeclaredRelationships} )
-$importUtils.addType(${rel.TargetEntity.ClientClassName})##
-#if(${rel.CollectionType}) 
-$importUtils.addType(${rel.CollectionType})##
-#end
-#end
-#if( ${entityUtils.hasToOneDeclaredRelationships()} )
-${importUtils.addType('org.apache.cayenne.ValueHolder')}##
-${importUtils.addType('org.apache.cayenne.util.PersistentObjectHolder')}##
-#end
-#if( ${entityUtils.hasToManyDeclaredRelationships()} )
-${importUtils.addType('org.apache.cayenne.util.PersistentObjectList')}##
-#end
-${importUtils.generate()}
-
-/**
- * A generated persistent class mapped as "${object.name}" Cayenne entity. It is a good idea to
- * avoid changing this class manually, since it will be overwritten next time code is
- * regenerated. If you need to make any customizations, put them in a subclass.
- */
-public abstract class ${superClassName} extends ${baseClassName} {
-
-## Create ivars names
-#if( $createPropertyNames )
-#foreach( $attr in ${object.DeclaredAttributes} )
-    public static final String ${stringUtils.capitalizedAsConstant($attr.Name)}_PROPERTY = "${attr.Name}";
-#end
-#foreach( $rel in ${object.DeclaredRelationships} )
-    public static final String ${stringUtils.capitalizedAsConstant($rel.Name)}_PROPERTY = "${rel.Name}";
-#end
-
-#end
-## Create Properties
-#foreach( $attr in ${object.DeclaredAttributes} )
-    #set ( $type = "$importUtils.formatJavaType(${attr.Type}, false)" )
-    public static final Property<$type> ${stringUtils.capitalizedAsConstant($attr.Name)} = Property.create("${attr.Name}", ${stringUtils.stripGeneric($type)}.class);
-#end
-#foreach( $rel in ${object.DeclaredRelationships} )
-#if( $rel.ToMany )
-#if ( ${rel.CollectionType} == "java.util.Map")
-    #set( $type = "$importUtils.formatJavaType($rel.CollectionType)<$importUtils.formatJavaType($entityUtils.getMapKeyType($rel)), $importUtils.formatJavaType($rel.TargetEntity.ClientClassName)>" )
-    public static final Property<$type> ${stringUtils.capitalizedAsConstant($rel.Name)} = Property.create("${rel.Name}", ${stringUtils.stripGeneric($type)}.class);
-#else
-    #set( $type = "$importUtils.formatJavaType($rel.CollectionType)<$importUtils.formatJavaType($rel.TargetEntity.ClientClassName)>" )
-    public static final Property<$type> ${stringUtils.capitalizedAsConstant($rel.Name)} = Property.create("${rel.Name}", ${stringUtils.stripGeneric($type)}.class);
-#end
-#else
-    #set( $type = "$importUtils.formatJavaType(${rel.TargetEntity.ClassName})" )
-    public static final Property<$type> ${stringUtils.capitalizedAsConstant($rel.Name)} = Property.create("${rel.Name}", ${stringUtils.stripGeneric($type)}.class);
-#end
-#end
-
-## Create ivars
-#foreach( $attr in ${object.DeclaredAttributes} )
-    protected $importUtils.formatJavaType(${attr.Type}) ${attr.Name};
-#end
-#foreach( $rel in ${object.DeclaredRelationships} )
-#if( $rel.ToMany )
-#if ( ${rel.CollectionType} == "java.util.Map")
-    protected $importUtils.formatJavaType($rel.CollectionType)<$importUtils.formatJavaType($entityUtils.getMapKeyType($rel)), $importUtils.formatJavaType($rel.TargetEntity.ClientClassName)> ${rel.Name};
-#else
-    protected $importUtils.formatJavaType($rel.CollectionType)<$importUtils.formatJavaType($rel.TargetEntity.ClientClassName)> ${rel.Name};
-#end
-#else
-    protected ValueHolder ${rel.Name};
-#end
-#end
-
-## Create attribute set/get methods
-#foreach( $attr in ${object.DeclaredAttributes} )
-#if ( $importUtils.isBoolean(${attr.Type}) )
-    public boolean is${stringUtils.capitalized($attr.Name)}() {
-        if(objectContext != null) {
-            objectContext.prepareForAccess(this, "${attr.Name}", false);
-        }
-
-        return ${attr.Name};
-    }
-#else 
-    public $importUtils.formatJavaType(${attr.Type}) get${stringUtils.capitalized($attr.Name)}() {
-        if(objectContext != null) {
-            objectContext.prepareForAccess(this, "${attr.Name}", false);
-        }
-
-        return ${attr.Name};
-    }
-#end
-#if ("true" != "${object.isReadOnly()}")
-    public void set${stringUtils.capitalized($attr.Name)}($importUtils.formatJavaType(${attr.Type}) $stringUtils.formatVariableName(${attr.Name})) {
-        if(objectContext != null) {
-            objectContext.prepareForAccess(this, "${attr.Name}", false);
-        }
-
-        Object oldValue = this.${stringUtils.formatVariableName($attr.Name)};
-        // notify objectContext about simple property change
-        if(objectContext != null) {
-            objectContext.propertyChanged(this, "${attr.Name}", oldValue, $stringUtils.formatVariableName(${attr.Name}));
-        }
-        
-        this.${stringUtils.formatVariableName($attr.Name)} = ${stringUtils.formatVariableName($attr.Name)};
-    }
-#end
-
-#end
-##
-##
-## Create list add/remove/get methods
-#foreach( $rel in ${object.DeclaredRelationships} )
-#if( $rel.ToMany )
-#if ( ${rel.CollectionType} == "java.util.Map")
-    public $importUtils.formatJavaType($rel.CollectionType)<$importUtils.formatJavaType($entityUtils.getMapKeyType($rel)), $importUtils.formatJavaType($rel.TargetEntity.ClientClassName)> get${stringUtils.capitalized($rel.Name)}() {
-#else
-    public $importUtils.formatJavaType($rel.CollectionType)<$importUtils.formatJavaType($rel.TargetEntity.ClientClassName)> get${stringUtils.capitalized($rel.Name)}() {
-#end
-        if(objectContext != null) {
-            objectContext.prepareForAccess(this, "${rel.Name}", true);
-        } else if (this.$rel.Name == null) {
-#if ( ${rel.CollectionType} == "java.util.Map")
-        	throw new RuntimeException("Map relationships cannot be accessed for transient objects");
-#else
-        	this.$rel.Name = new PersistentObjectList(this, "${rel.Name}");
-#end
-		}
-
-        return ${rel.Name};
-    }
-#if ( ! $rel.ReadOnly )
-#if ( ${rel.CollectionType} == "java.util.Map")
-	public void addTo${stringUtils.capitalized($rel.Name)}($importUtils.formatJavaType(${rel.TargetEntity.ClientClassName}) object) {
-        if(objectContext != null) {
-            objectContext.prepareForAccess(this, "${rel.Name}", true);
-        } else if (this.$rel.Name == null) {
-        	throw new RuntimeException("Map relationships cannot be accessed for transient objects");        
-        }
-
-        this.${rel.Name}.put(getMapKey("${rel.Name}", object), object);
-    }
-    public void removeFrom${stringUtils.capitalized($rel.Name)}($importUtils.formatJavaType(${rel.TargetEntity.ClientClassName}) object) {
-        if(objectContext != null) {
-            objectContext.prepareForAccess(this, "${rel.Name}", true);
-        } else if (this.$rel.Name == null) {
-        	throw new RuntimeException("Map relationships cannot be accessed for transient objects");        
-        }
-
-        this.${rel.Name}.remove(getMapKey("${rel.Name}", object));
-    }
-#else
-    public void addTo${stringUtils.capitalized($rel.Name)}($importUtils.formatJavaType(${rel.TargetEntity.ClientClassName}) object) {
-        if(objectContext != null) {
-            objectContext.prepareForAccess(this, "${rel.Name}", true);
-        } else if (this.$rel.Name == null) {
-        	this.$rel.Name = new PersistentObjectList(this, "${rel.Name}");
-		}
-
-        this.${rel.Name}.add(object);
-    }
-    public void removeFrom${stringUtils.capitalized($rel.Name)}($importUtils.formatJavaType(${rel.TargetEntity.ClientClassName}) object) {
-        if(objectContext != null) {
-            objectContext.prepareForAccess(this, "${rel.Name}", true);
-        } else if (this.$rel.Name == null) {
-        	this.$rel.Name = new PersistentObjectList(this, "${rel.Name}");
-		}
-
-        this.${rel.Name}.remove(object);
-    }
-#end
-#end
-#else
-    public $importUtils.formatJavaType(${rel.TargetEntity.ClientClassName}) get${stringUtils.capitalized($rel.Name)}() {
-        if(objectContext != null) {
-            objectContext.prepareForAccess(this, "${rel.Name}", true);
-        } else if (this.$rel.Name == null) {
-        	this.$rel.Name = new PersistentObjectHolder(this, "$rel.Name");
-		}
-
-        return ($importUtils.formatJavaType(${rel.TargetEntity.ClientClassName})) ${rel.Name}.getValue();
-    }
-#if ( !${object.isReadOnly()} && !$rel.ReadOnly )
-    public void set${stringUtils.capitalized($rel.Name)}(${importUtils.formatJavaType($rel.TargetEntity.ClientClassName)} $stringUtils.formatVariableName(${rel.Name})) {
-        if(objectContext != null) {
-            objectContext.prepareForAccess(this, "${rel.Name}", true);
-        } else if (this.$rel.Name == null) {
-        	this.$rel.Name = new PersistentObjectHolder(this, "$rel.Name");
-		}
-
-        // note how we notify ObjectContext of change BEFORE the object is actually
-        // changed... this is needed to take a valid current snapshot
-        Object oldValue = this.${rel.Name}.getValueDirectly();
-        if (objectContext != null) {
-        	objectContext.propertyChanged(this, "$rel.Name", oldValue, $stringUtils.formatVariableName(${rel.Name}));
-        }
-        
-        this.${stringUtils.formatVariableName($rel.Name)}.setValue(${stringUtils.formatVariableName($rel.Name)});
-    }
-#end
-#end
-
-#end
-##callback methods
-#foreach( $cbname in ${entityUtils.callbackNames})
-    protected abstract void ${cbname}();
-
-#end
-}

http://git-wip-us.apache.org/repos/asf/cayenne/blob/c63b6be2/cayenne-tools/src/main/resources/templates/v1_2/datamap-singleclass.vm
----------------------------------------------------------------------
diff --git a/cayenne-tools/src/main/resources/templates/v1_2/datamap-singleclass.vm b/cayenne-tools/src/main/resources/templates/v1_2/datamap-singleclass.vm
deleted file mode 100644
index 9ad544c..0000000
--- a/cayenne-tools/src/main/resources/templates/v1_2/datamap-singleclass.vm
+++ /dev/null
@@ -1,96 +0,0 @@
-##   Licensed to the Apache Software Foundation (ASF) under one
-##  or more contributor license agreements.  See the NOTICE file
-##  distributed with this work for additional information
-##  regarding copyright ownership.  The ASF licenses this file
-##  to you under the Apache License, Version 2.0 (the
-##  "License"); you may not use this file except in compliance
-##  with the License.  You may obtain a copy of the License at
-##
-##    http://www.apache.org/licenses/LICENSE-2.0
-##
-##  Unless required by applicable law or agreed to in writing,
-##  software distributed under the License is distributed on an
-##  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-##  KIND, either express or implied.  See the License for the
-##  specific language governing permissions and limitations
-##  under the License.
-##
-##Terminology:
-##	Base class - super superclass of entity, ie, org.apache.cayenne.CayenneDataObject or MyBaseClass
-##  Super class - superclass of entity, ie,  org.apache.cayenne.art.auto._Artist
-##	Sub class - class of entity, ie, org.apache.cayenne.art.Artist
-##
-##  Classes available in template
-##    object (duplicated as 'objEntity') - the ObjEntity class: See org.apache.cayenne.map.ObjectEntity
-##    stringUtils - class for string "helper" functions: See org.apache.cayenne.gen.StringUtils
-##    dataMapUtils - class for query "helper" functions: See org.apache.cayenne.gen.DataMapUtils
-##    importUtils - class for import statement management: See org.apache.cayenne.gen.ImportUtils
-##    superClassName
-##    superPackageName
-##    subClassName
-##    subPackageName
-##    baseClassName
-##    basePackageName 
-##
-##
-${importUtils.setPackage($subPackageName)}##
-${importUtils.addReservedType("${subPackageName}.${subClassName}")}##
-${importUtils.addType("${basePackageName}.${baseClassName}")}##
-${importUtils.addType('java.util.List')}
-${importUtils.addType('java.util.Map')}
-${importUtils.addType('java.util.HashMap')}
-${importUtils.addType('org.apache.cayenne.ObjectContext')}
-#foreach( $selectQuery in ${object.SelectQueries})
-${importUtils.addType(${selectQuery.Root.ClassName})}
-#foreach( $parameter in ${dataMapUtils.getParameterNames(${selectQuery})})
-${importUtils.addType(${dataMapUtils.getParameterType(${selectQuery}, ${parameter})})}
-#end
-#end
-${importUtils.generate()}
-
-/**
- * This class was generated by Cayenne.
- * It is probably a good idea to avoid changing this class manually,
- * since it may be overwritten next time code is regenerated.
- * If you need to make any customizations, please use subclass.
- */
-public class ${subClassName} {
-#if( ${object.hasQueryNames()})
-#foreach( $qname in ${object.QueryNames})
-
-public static final String ${stringUtils.capitalizedAsConstant($qname)}_QUERYNAME = "$qname";
-#end
-#end
-
-    private static ${subClassName} instance;
-
-    private ${subClassName}() {}
-
-    public ${subClassName} getInstance() {
-      if( instance == null) {
-        instance = new ${subClassName}();
-      }
-      return instance;
-    }
-
-#foreach( $selectQuery in ${object.SelectQueries})
-    public List<${stringUtils.stripPackageName($selectQuery.Root.ClassName)}> perform${dataMapUtils.getQueryMethodName(${selectQuery})}(ObjectContext context #foreach( $parameter in ${dataMapUtils.getParameterNames(${selectQuery})}), ${stringUtils.stripPackageName(${dataMapUtils.getParameterType(${selectQuery}, ${parameter})})} ${parameter} #end) {
-    #if(${dataMapUtils.hasParameters($selectQuery)})
-      String[] parameters = new String[] {
-      #foreach( $parameter in ${dataMapUtils.getParameterNames(${selectQuery})})
-      "${parameter}",
-      #end
-      };
-
-      Object[] values = new Object[] {
-      #foreach( $parameter in ${dataMapUtils.getParameterNames(${selectQuery})})
-      ${parameter},
-      #end
-      };
-    #end
-
-      NamedQuery query = new NamedQuery("${selectQuery.Name}"#if(${dataMapUtils.hasParameters($selectQuery)}), parameters, values#end);
-      return context.performQuery(query);
-    }
-#end
-}

http://git-wip-us.apache.org/repos/asf/cayenne/blob/c63b6be2/cayenne-tools/src/main/resources/templates/v1_2/datamap-subclass.vm
----------------------------------------------------------------------
diff --git a/cayenne-tools/src/main/resources/templates/v1_2/datamap-subclass.vm b/cayenne-tools/src/main/resources/templates/v1_2/datamap-subclass.vm
deleted file mode 100644
index f5e0474..0000000
--- a/cayenne-tools/src/main/resources/templates/v1_2/datamap-subclass.vm
+++ /dev/null
@@ -1,47 +0,0 @@
-##   Licensed to the Apache Software Foundation (ASF) under one
-##  or more contributor license agreements.  See the NOTICE file
-##  distributed with this work for additional information
-##  regarding copyright ownership.  The ASF licenses this file
-##  to you under the Apache License, Version 2.0 (the
-##  "License"); you may not use this file except in compliance
-##  with the License.  You may obtain a copy of the License at
-##
-##    http://www.apache.org/licenses/LICENSE-2.0
-##
-##  Unless required by applicable law or agreed to in writing,
-##  software distributed under the License is distributed on an
-##  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-##  KIND, either express or implied.  See the License for the
-##  specific language governing permissions and limitations
-##  under the License.
-##
-##Terminology:
-##	Base class - super superclass of entity, ie, org.apache.cayenne.CayenneDataObject or MyBaseClass
-##  Super class - superclass of entity, ie,  org.apache.cayenne.art.auto._Artist
-##	Sub class - class of entity, ie, org.apache.cayenne.art.Artist
-##
-##  Classes available in template
-##    stringUtils - class for string "helper" functions: See org.apache.cayenne.gen.StringUtils
-##    dataMapUtils - class for query "helper" functions: See org.apache.cayenne.gen.dataMapUtils
-##    importUtils - class for import statement management: See org.apache.cayenne.gen.ImportUtils
-##
-##
-${importUtils.setPackage($subPackageName)}##
-${importUtils.addReservedType("${subPackageName}.${subClassName}")}##
-${importUtils.addType("${superPackageName}.${superClassName}")}##
-${importUtils.generate()}
-
-public class ${subClassName} extends ${superClassName} {
-
-    private static ${subClassName} instance;
-
-    private ${subClassName}() {}
-
-    public static ${subClassName} getInstance() {
-        if(instance == null) {
-            instance = new ${subClassName}();
-        }
-
-        return instance;
-    }
-}

http://git-wip-us.apache.org/repos/asf/cayenne/blob/c63b6be2/cayenne-tools/src/main/resources/templates/v1_2/datamap-superclass.vm
----------------------------------------------------------------------
diff --git a/cayenne-tools/src/main/resources/templates/v1_2/datamap-superclass.vm b/cayenne-tools/src/main/resources/templates/v1_2/datamap-superclass.vm
deleted file mode 100644
index 51c00f3..0000000
--- a/cayenne-tools/src/main/resources/templates/v1_2/datamap-superclass.vm
+++ /dev/null
@@ -1,87 +0,0 @@
-##   Licensed to the Apache Software Foundation (ASF) under one
-##  or more contributor license agreements.  See the NOTICE file
-##  distributed with this work for additional information
-##  regarding copyright ownership.  The ASF licenses this file
-##  to you under the Apache License, Version 2.0 (the
-##  "License"); you may not use this file except in compliance
-##  with the License.  You may obtain a copy of the License at
-##
-##    http://www.apache.org/licenses/LICENSE-2.0
-##
-##  Unless required by applicable law or agreed to in writing,
-##  software distributed under the License is distributed on an
-##  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-##  KIND, either express or implied.  See the License for the
-##  specific language governing permissions and limitations
-##  under the License.
-##
-##Terminology:
-##	Base class - super superclass of entity, ie, org.apache.cayenne.CayenneDataObject or MyBaseClass
-##  Super class - superclass of entity, ie,  org.apache.cayenne.art.auto._Artist
-##	Sub class - class of entity, ie, org.apache.cayenne.art.Artist
-##
-##  Classes available in template
-##    stringUtils - class for string "helper" functions: See org.apache.cayenne.gen.StringUtils
-##    dataMapUtils - class for query "helper" functions: See org.apache.cayenne.gen.DataMapUtils
-##    importUtils - class for import statement management: See org.apache.cayenne.gen.ImportUtils
-##    superClassName
-##    superPackageName
-##    subClassName
-##    subPackageName
-##    baseClassName
-##    basePackageName
-##
-${importUtils.setPackage($superPackageName)}##
-#if(${superPackageName})${importUtils.addReservedType("${superPackageName}.${superClassName}")}#end##
-#if(${basePackageName})${importUtils.addType("${basePackageName}.${baseClassName}")}#end##
-#if( ${object.hasSelectQueries()} )
-${importUtils.addType('java.util.List')}##
-${importUtils.addType('org.apache.cayenne.ObjectContext')}##
-${importUtils.addType('org.apache.cayenne.query.NamedQuery')}##
-#foreach( $selectQuery in ${object.SelectQueries})
-${importUtils.addType(${selectQuery.Root.ClassName})}##
-#if(${dataMapUtils.isValidParameterNames($selectQuery)})
-#foreach( $parameter in ${dataMapUtils.getParameterNames(${selectQuery})})
-${importUtils.addType(${dataMapUtils.getParameterType(${selectQuery}, ${parameter})})}##
-#end
-#end    
-#end
-#end
-${importUtils.generate()}
-
-/**
- * This class was generated by Cayenne.
- * It is probably a good idea to avoid changing this class manually,
- * since it may be overwritten next time code is regenerated.
- * If you need to make any customizations, please use subclass.
- */
-public class ${superClassName} {
-#if( ${object.hasQueryNames()})
-#foreach( $qname in ${object.queryNames})
-
-    public static final String ${stringUtils.capitalizedAsConstant($qname)}_QUERYNAME = "$qname";
-#end
-#end
-#foreach( $selectQuery in ${object.SelectQueries})
-
-#if(${dataMapUtils.isValidParameterNames($selectQuery)})
-    public List<${stringUtils.stripPackageName($selectQuery.Root.ClassName)}> perform${dataMapUtils.getQueryMethodName(${selectQuery})}(ObjectContext context #foreach( $parameter in ${dataMapUtils.getParameterNames(${selectQuery})}), ${stringUtils.stripPackageName(${dataMapUtils.getParameterType(${selectQuery}, ${parameter})})} ${parameter}#end) {
-#if(${dataMapUtils.hasParameters($selectQuery)})
-        String[] parameters = {
-#foreach( $parameter in ${dataMapUtils.getParameterNames(${selectQuery})})
-            "${parameter}",
-#end
-        };
-
-        Object[] values = {
-#foreach( $parameter in ${dataMapUtils.getParameterNames(${selectQuery})})
-            ${parameter},
-#end
-        };
-
-#end
-        return context.performQuery(new NamedQuery("${selectQuery.Name}"#if(${dataMapUtils.hasParameters($selectQuery)}), parameters, values#end));
-    }
-#end
-#end
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/cayenne/blob/c63b6be2/cayenne-tools/src/main/resources/templates/v1_2/embeddable-singleclass.vm
----------------------------------------------------------------------
diff --git a/cayenne-tools/src/main/resources/templates/v1_2/embeddable-singleclass.vm b/cayenne-tools/src/main/resources/templates/v1_2/embeddable-singleclass.vm
deleted file mode 100644
index a30dcec..0000000
--- a/cayenne-tools/src/main/resources/templates/v1_2/embeddable-singleclass.vm
+++ /dev/null
@@ -1,106 +0,0 @@
-##  Licensed to the Apache Software Foundation (ASF) under one
-##  or more contributor license agreements.  See the NOTICE file
-##  distributed with this work for additional information
-##  regarding copyright ownership.  The ASF licenses this file
-##  to you under the Apache License, Version 2.0 (the
-##  "License"); you may not use this file except in compliance
-##  with the License.  You may obtain a copy of the License at
-##
-##    http://www.apache.org/licenses/LICENSE-2.0
-##
-##  Unless required by applicable law or agreed to in writing,
-##  software distributed under the License is distributed on an
-##  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-##  KIND, either express or implied.  See the License for the
-##  specific language governing permissions and limitations
-##  under the License.
-##
-##  Terminology:
-## 
-##	Base class - super superclass of embeddable, usually java.lang.Object
-##  Super class - superclass of embeddable, ie,  org.apache.cayenne.art.auto._Embeddable
-##	Sub class - class of entity, ie, org.apache.cayenne.art.Embeddable
-##
-##  Keys of objects available in template are defined in 'org.apache.cayenne.gen.Artifact', namely:
-## 
-##    object - the Embeddable class: See org.apache.cayenne.map.Embeddable
-##    stringUtils - class for string "helper" functions: See org.apache.cayenne.gen.StringUtils
-##    importUtils - class for import statement management: See org.apache.cayenne.gen.ImportUtils
-##    superClassName
-##    superPackageName
-##    subClassName
-##    subPackageName
-##    baseClassName
-##    basePackageName 
-##
-##
-${importUtils.setPackage($subPackageName)}##
-${importUtils.addReservedType("${subPackageName}.${subClassName}")}##
-${importUtils.addType("${basePackageName}.${baseClassName}")}##
-${importUtils.addType("org.apache.cayenne.Persistent")}##
-#if(${object.Attributes} && !${object.Attributes.isEmpty()})
-${importUtils.addType('org.apache.cayenne.exp.Property')}##
-#end
-#foreach( $attr in ${object.Attributes} )
-$importUtils.addType(${attr.Type})##
-#end
-${importUtils.generate()}
-
-public abstract class ${subClassName} extends ${baseClassName} {
-
-## Create property names
-#if( $createPropertyNames )
-#foreach( $attr in ${object.Attributes} )
-    public static final String ${stringUtils.capitalizedAsConstant($attr.Name)}_PROPERTY = "${attr.Name}";
-#end
-
-#end
-## Create Properties
-#foreach( $attr in ${object.Attributes} )
-    #set ( $type = "$importUtils.formatJavaType(${attr.Type}, false)" )
-    public static final Property<$type> ${stringUtils.capitalizedAsConstant($attr.Name)} = Property.create("${attr.Name}", ${stringUtils.stripGeneric($type)}.class);
-#end
-
-    // special properties injected by Cayenne
-    private Persistent owner;
-    private String embeddedProperty;
-    
-    // declared properties
-#foreach( $attr in ${object.Attributes} )
-    protected $importUtils.formatJavaType(${attr.Type}) $stringUtils.formatVariableName(${attr.Name});
-#end
-
-    // lifecycle methods
-    protected void propertyWillChange(String property, Object oldValue, Object newValue) {
-        if (owner != null && owner.getObjectContext() != null) {
-            owner.getObjectContext().propertyChanged(
-                    owner,
-                    embeddedProperty + "." + property,
-                    oldValue,
-                    newValue);
-        }
-    }
-
-    // declared getters and setters
-## Create attribute set/get methods
-#foreach( $attr in ${object.Attributes} )
-    public void set${stringUtils.capitalized($attr.Name)}($importUtils.formatJavaType(${attr.Type}) $stringUtils.formatVariableName(${attr.Name})) {
-        propertyWillChange("${attr.Name}", this.$stringUtils.formatVariableName(${attr.Name}), $stringUtils.formatVariableName(${attr.Name}));
-        this.$stringUtils.formatVariableName(${attr.Name}) = $stringUtils.formatVariableName(${attr.Name});
-    }
-#if ( $importUtils.isBoolean(${attr.Type}) )
-	public boolean is${stringUtils.capitalized($attr.Name)}() {
-        return $stringUtils.formatVariableName(${attr.Name});
-    }
-#elseif ( $importUtils.isNonBooleanPrimitive(${attr.Type}) )
-    public $classGen.formatJavaType(${attr.Type}) get${stringUtils.capitalized($attr.Name)}() {
-        return $stringUtils.formatVariableName(${attr.Name});
-    }
-#else
-    public $importUtils.formatJavaType(${attr.Type}) get${stringUtils.capitalized($attr.Name)}() {
-        return $stringUtils.formatVariableName(${attr.Name});
-    }
-#end
-
-#end
-}

http://git-wip-us.apache.org/repos/asf/cayenne/blob/c63b6be2/cayenne-tools/src/main/resources/templates/v1_2/embeddable-subclass.vm
----------------------------------------------------------------------
diff --git a/cayenne-tools/src/main/resources/templates/v1_2/embeddable-subclass.vm b/cayenne-tools/src/main/resources/templates/v1_2/embeddable-subclass.vm
deleted file mode 100644
index b5b701b..0000000
--- a/cayenne-tools/src/main/resources/templates/v1_2/embeddable-subclass.vm
+++ /dev/null
@@ -1,45 +0,0 @@
-##  Licensed to the Apache Software Foundation (ASF) under one
-##  or more contributor license agreements.  See the NOTICE file
-##  distributed with this work for additional information
-##  regarding copyright ownership.  The ASF licenses this file
-##  to you under the Apache License, Version 2.0 (the
-##  "License"); you may not use this file except in compliance
-##  with the License.  You may obtain a copy of the License at
-##
-##    http://www.apache.org/licenses/LICENSE-2.0
-##
-##  Unless required by applicable law or agreed to in writing,
-##  software distributed under the License is distributed on an
-##  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-##  KIND, either express or implied.  See the License for the
-##  specific language governing permissions and limitations
-##  under the License.
-##
-##  Terminology:
-## 
-##	Base class - super superclass of embeddable, usually java.lang.Object
-##  Super class - superclass of embeddable, ie,  org.apache.cayenne.art.auto._Embeddable
-##	Sub class - class of entity, ie, org.apache.cayenne.art.Embeddable
-##
-##  Keys of objects available in template are defined in 'org.apache.cayenne.gen.Artifact', namely:
-## 
-##    object - the Embeddable class: See org.apache.cayenne.map.Embeddable
-##    stringUtils - class for string "helper" functions: See org.apache.cayenne.gen.StringUtils
-##    importUtils - class for import statement management: See org.apache.cayenne.gen.ImportUtils
-##    superClassName
-##    superPackageName
-##    subClassName
-##    subPackageName
-##    baseClassName
-##    basePackageName 
-##
-##
-${importUtils.setPackage($subPackageName)}##
-${importUtils.addReservedType("${subPackageName}.${subClassName}")}##
-${importUtils.addType("${superPackageName}.${superClassName}")}##
-${importUtils.generate()}
-
-
-public#if("true" == "${object.getIsAbstract()}") abstract#end class ${subClassName} extends ${superClassName} {
-
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/cayenne/blob/c63b6be2/cayenne-tools/src/main/resources/templates/v1_2/embeddable-superclass.vm
----------------------------------------------------------------------
diff --git a/cayenne-tools/src/main/resources/templates/v1_2/embeddable-superclass.vm b/cayenne-tools/src/main/resources/templates/v1_2/embeddable-superclass.vm
deleted file mode 100644
index 95e39dc..0000000
--- a/cayenne-tools/src/main/resources/templates/v1_2/embeddable-superclass.vm
+++ /dev/null
@@ -1,112 +0,0 @@
-##  Licensed to the Apache Software Foundation (ASF) under one
-##  or more contributor license agreements.  See the NOTICE file
-##  distributed with this work for additional information
-##  regarding copyright ownership.  The ASF licenses this file
-##  to you under the Apache License, Version 2.0 (the
-##  "License"); you may not use this file except in compliance
-##  with the License.  You may obtain a copy of the License at
-##
-##    http://www.apache.org/licenses/LICENSE-2.0
-##
-##  Unless required by applicable law or agreed to in writing,
-##  software distributed under the License is distributed on an
-##  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-##  KIND, either express or implied.  See the License for the
-##  specific language governing permissions and limitations
-##  under the License.
-##
-##  Terminology:
-## 
-##	Base class - super superclass of embeddable, usually java.lang.Object
-##  Super class - superclass of embeddable, ie,  org.apache.cayenne.art.auto._Embeddable
-##	Sub class - class of entity, ie, org.apache.cayenne.art.Embeddable
-##
-##  Keys of objects available in template are defined in 'org.apache.cayenne.gen.Artifact', namely:
-## 
-##    object - the Embeddable class: See org.apache.cayenne.map.Embeddable
-##    stringUtils - class for string "helper" functions: See org.apache.cayenne.gen.StringUtils
-##    importUtils - class for import statement management: See org.apache.cayenne.gen.ImportUtils
-##    superClassName
-##    superPackageName
-##    subClassName
-##    subPackageName
-##    baseClassName
-##    basePackageName 
-##
-##
-${importUtils.setPackage($superPackageName)}##
-${importUtils.addReservedType("${superPackageName}.${superClassName}")}##
-${importUtils.addType("${basePackageName}.${baseClassName}")}##
-${importUtils.addType("org.apache.cayenne.Persistent")}##
-#if(${object.Attributes} && !${object.Attributes.isEmpty()})
-${importUtils.addType('org.apache.cayenne.exp.Property')}##
-#end
-#foreach( $attr in ${object.Attributes} )
-$importUtils.addType(${attr.Type})##
-#end
-${importUtils.generate()}
-
-/** 
- * Embeddable class ${superClassName} was generated by Cayenne.
- * It is probably a good idea to avoid changing this class manually, 
- * since it may be overwritten next time code is regenerated. 
- * If you need to make any customizations, please use subclass. 
- */
-public abstract class ${superClassName} extends ${baseClassName} {
-
-## Create property names
-#if( $createPropertyNames )
-#foreach( $attr in ${object.Attributes} )
-    public static final String ${stringUtils.capitalizedAsConstant($attr.Name)}_PROPERTY = "${attr.Name}";
-#end
-
-#end
-## Create Properties
-#foreach( $attr in ${object.Attributes} )
-    #set ( $type = "$importUtils.formatJavaType(${attr.Type}, false)" )
-    public static final Property<$type> ${stringUtils.capitalizedAsConstant($attr.Name)} = Property.create("${attr.Name}", ${stringUtils.stripGeneric($type)}.class);
-#end
-
-    // special properties injected by Cayenne
-    private Persistent owner;
-    private String embeddedProperty;
-    
-    // declared properties
-#foreach( $attr in ${object.Attributes} )
-    protected $importUtils.formatJavaType(${attr.Type}) $stringUtils.formatVariableName(${attr.Name});
-#end
-
-    // lifecycle methods
-    protected void propertyWillChange(String property, Object oldValue, Object newValue) {
-        if (owner != null && owner.getObjectContext() != null) {
-            owner.getObjectContext().propertyChanged(
-                    owner,
-                    embeddedProperty + "." + property,
-                    oldValue,
-                    newValue);
-        }
-    }
-
-    // declared getters and setters
-## Create attribute set/get methods
-#foreach( $attr in ${object.Attributes} )
-    public void set${stringUtils.capitalized($attr.Name)}($importUtils.formatJavaType(${attr.Type}) $stringUtils.formatVariableName(${attr.Name})) {
-        propertyWillChange("${attr.Name}", this.$stringUtils.formatVariableName(${attr.Name}), $stringUtils.formatVariableName(${attr.Name}));
-        this.$stringUtils.formatVariableName(${attr.Name}) = $stringUtils.formatVariableName(${attr.Name});
-    }
-#if ( $importUtils.isBoolean(${attr.Type}) )
-	public boolean is${stringUtils.capitalized($attr.Name)}() {
-        return $stringUtils.formatVariableName(${attr.Name});
-    }
-#elseif ( $importUtils.isNonBooleanPrimitive(${attr.Type}) )
-    public $importUtils.formatJavaType(${attr.Type}) get${stringUtils.capitalized($attr.Name)}() {
-        return $stringUtils.formatVariableName(${attr.Name});
-    }
-#else
-    public $importUtils.formatJavaType(${attr.Type}) get${stringUtils.capitalized($attr.Name)}() {
-        return $stringUtils.formatVariableName(${attr.Name});
-    }
-#end
-
-#end
-}

http://git-wip-us.apache.org/repos/asf/cayenne/blob/c63b6be2/cayenne-tools/src/main/resources/templates/v1_2/singleclass.vm
----------------------------------------------------------------------
diff --git a/cayenne-tools/src/main/resources/templates/v1_2/singleclass.vm b/cayenne-tools/src/main/resources/templates/v1_2/singleclass.vm
deleted file mode 100644
index 53c6aa7..0000000
--- a/cayenne-tools/src/main/resources/templates/v1_2/singleclass.vm
+++ /dev/null
@@ -1,147 +0,0 @@
-##   Licensed to the Apache Software Foundation (ASF) under one
-##  or more contributor license agreements.  See the NOTICE file
-##  distributed with this work for additional information
-##  regarding copyright ownership.  The ASF licenses this file
-##  to you under the Apache License, Version 2.0 (the
-##  "License"); you may not use this file except in compliance
-##  with the License.  You may obtain a copy of the License at
-##
-##    http://www.apache.org/licenses/LICENSE-2.0
-##
-##  Unless required by applicable law or agreed to in writing,
-##  software distributed under the License is distributed on an
-##  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-##  KIND, either express or implied.  See the License for the
-##  specific language governing permissions and limitations
-##  under the License.
-##
-##Terminology:
-##	Base class - super superclass of entity, ie, org.apache.cayenne.CayenneDataObject or MyBaseClass
-##  Super class - superclass of entity, ie,  org.apache.cayenne.art.auto._Artist
-##	Sub class - class of entity, ie, org.apache.cayenne.art.Artist
-##
-##  Classes available in template
-##    object (duplicated as 'objEntity') - the ObjEntity class: See org.apache.cayenne.map.ObjectEntity
-##    stringUtils - class for string "helper" functions: See org.apache.cayenne.gen.StringUtils
-##    entityUtils - class for entity "helper" functions: See org.apache.cayenne.gen.EntityUtils
-##    importUtils - class for import statement management: See org.apache.cayenne.gen.ImportUtils
-##    superClassName
-##    superPackageName
-##    subClassName
-##    subPackageName
-##    baseClassName
-##    basePackageName 
-##
-##
-${importUtils.setPackage($subPackageName)}##
-${importUtils.addReservedType("${subPackageName}.${subClassName}")}##
-${importUtils.addType("${basePackageName}.${baseClassName}")}##
-#if((${object.DeclaredAttributes} && !${object.DeclaredAttributes.isEmpty()}) || (${object.DeclaredRelationships} && !${object.DeclaredRelationships.isEmpty()}))
-${importUtils.addType('org.apache.cayenne.exp.Property')}##
-#end
-#foreach( $attr in ${object.DeclaredAttributes} )
-$importUtils.addType(${attr.Type})##
-#end
-#foreach( $rel in ${object.DeclaredRelationships} )
-$importUtils.addType(${rel.TargetEntity.ClassName})##
-#if(${rel.CollectionType})
-$importUtils.addType(${rel.CollectionType})##
-#end
-#end
-${importUtils.generate()}
-
-public#if("true" == "${object.isAbstract()}") abstract#end class ${subClassName} extends ${baseClassName} {
-
-    private static final long serialVersionUID = 1L;
-
-## Create property names
-#if( $createPropertyNames )
-#foreach( $attr in ${object.DeclaredAttributes} )
-    public static final String ${stringUtils.capitalizedAsConstant($attr.Name)}_PROPERTY = "${attr.Name}";
-#end
-#foreach( $rel in ${object.DeclaredRelationships} )
-    public static final String ${stringUtils.capitalizedAsConstant($rel.Name)}_PROPERTY = "${rel.Name}";
-#end
-
-#end
-#if( $object.DbEntity )
-#foreach( $idAttr in ${object.DbEntity.PrimaryKeys} )
-    public static final String ${stringUtils.capitalizedAsConstant($idAttr.Name)}_PK_COLUMN = "${idAttr.Name}";
-#end
-#end
-
-## Create Properties
-#foreach( $attr in ${object.DeclaredAttributes} )
-    #set ( $type = "$importUtils.formatJavaType(${attr.Type}, false)" )
-    public static final Property<$type> ${stringUtils.capitalizedAsConstant($attr.Name)} = Property.create("${attr.Name}", ${stringUtils.stripGeneric($type)}.class);
-#end
-#foreach( $rel in ${object.DeclaredRelationships} )
-#if( $rel.ToMany )
-#if ( ${rel.CollectionType} == "java.util.Map")
-    #set( $type = "$importUtils.formatJavaType($rel.CollectionType)<$importUtils.formatJavaType($entityUtils.getMapKeyType($rel)), $importUtils.formatJavaType($rel.TargetEntity.ClassName)>" )
-    public static final Property<$type> ${stringUtils.capitalizedAsConstant($rel.Name)} = Property.create("${rel.Name}", ${stringUtils.stripGeneric($type)}.class);
-#else
-    #set( $type = "$importUtils.formatJavaType($rel.CollectionType)<$importUtils.formatJavaType($rel.TargetEntity.ClassName)>" )
-    public static final Property<$type> ${stringUtils.capitalizedAsConstant($rel.Name)} = Property.create("${rel.Name}", ${stringUtils.stripGeneric($type)}.class);
-#end
-#else
-    #set( $type = "$importUtils.formatJavaType(${rel.TargetEntity.ClassName})" )
-    public static final Property<$type> ${stringUtils.capitalizedAsConstant($rel.Name)} = Property.create("${rel.Name}", ${stringUtils.stripGeneric($type)}.class);
-#end
-#end
-
-## Create attribute set/get methods
-#foreach( $attr in ${object.DeclaredAttributes} )
-#if ("true" != "${object.isReadOnly()}")
-    public void set${stringUtils.capitalized($attr.Name)}($importUtils.formatJavaType(${attr.Type}) $stringUtils.formatVariableName(${attr.Name})) {
-        writeProperty("${attr.Name}", $stringUtils.formatVariableName(${attr.Name}));
-    }
-#end
-#if ( $importUtils.isBoolean(${attr.Type}) )
-	public boolean is${stringUtils.capitalized($attr.Name)}() {
-        Boolean value = (Boolean)readProperty("${attr.Name}");
-        return (value != null) ? value.booleanValue() : false;
-    }
-#elseif ( $importUtils.isNonBooleanPrimitive(${attr.Type}) )
-    public ${importUtils.formatJavaType($attr.Type)} get${stringUtils.capitalized($attr.Name)}() {
-        Object value = readProperty("${attr.Name}");
-        return (value != null) ? ($importUtils.formatJavaTypeAsNonBooleanPrimitive(${attr.Type})) value : 0;
-    }
-#else
-    public $importUtils.formatJavaType(${attr.Type}) get${stringUtils.capitalized($attr.Name)}() {
-        return ($importUtils.formatJavaType(${attr.Type}))readProperty("${attr.Name}");
-    }
-#end
-
-#end
-##
-## Create list add/remove/get methods
-#foreach( $rel in ${object.DeclaredRelationships} )
-#if( $rel.ToMany )
-#if ( ! $rel.ReadOnly )    public void addTo${stringUtils.capitalized($rel.Name)}($importUtils.formatJavaType(${rel.TargetEntity.ClassName}) obj) {
-        addToManyTarget("${rel.name}", obj, true);
-    }
-    public void removeFrom${stringUtils.capitalized($rel.Name)}($importUtils.formatJavaType(${rel.TargetEntity.ClassName}) obj) {
-        removeToManyTarget("${rel.name}", obj, true);
-    }
-#end
-    public $importUtils.formatJavaType($rel.CollectionType) get${stringUtils.capitalized($rel.Name)}() {
-        return ($importUtils.formatJavaType($rel.CollectionType))readProperty("${rel.name}");
-    }
-#else
-#if ( ! ${object.isReadOnly()} && ! $rel.ReadOnly )
-    public void set${stringUtils.capitalized($rel.Name)}($importUtils.formatJavaType(${rel.TargetEntity.ClassName}) $stringUtils.formatVariableName(${rel.name})) {
-        setToOneTarget("${rel.name}", $stringUtils.formatVariableName(${rel.name}), true);
-    }
-#end
-    public $importUtils.formatJavaType(${rel.TargetEntity.ClassName}) get${stringUtils.capitalized($rel.Name)}() {
-        return ($importUtils.formatJavaType(${rel.TargetEntity.ClassName}))readProperty("${rel.name}");
-    }
-#end
-
-
-#end
-}
-
-
-

http://git-wip-us.apache.org/repos/asf/cayenne/blob/c63b6be2/cayenne-tools/src/main/resources/templates/v1_2/subclass.vm
----------------------------------------------------------------------
diff --git a/cayenne-tools/src/main/resources/templates/v1_2/subclass.vm b/cayenne-tools/src/main/resources/templates/v1_2/subclass.vm
deleted file mode 100644
index e31e658..0000000
--- a/cayenne-tools/src/main/resources/templates/v1_2/subclass.vm
+++ /dev/null
@@ -1,47 +0,0 @@
-##   Licensed to the Apache Software Foundation (ASF) under one
-##  or more contributor license agreements.  See the NOTICE file
-##  distributed with this work for additional information
-##  regarding copyright ownership.  The ASF licenses this file
-##  to you under the Apache License, Version 2.0 (the
-##  "License"); you may not use this file except in compliance
-##  with the License.  You may obtain a copy of the License at
-##
-##    http://www.apache.org/licenses/LICENSE-2.0
-##
-##  Unless required by applicable law or agreed to in writing,
-##  software distributed under the License is distributed on an
-##  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-##  KIND, either express or implied.  See the License for the
-##  specific language governing permissions and limitations
-##  under the License.
-##
-##Terminology:
-##	Base class - super superclass of entity, ie, org.apache.cayenne.CayenneDataObject or MyBaseClass
-##  Super class - superclass of entity, ie,  org.apache.cayenne.art.auto._Artist
-##	Sub class - class of entity, ie, org.apache.cayenne.art.Artist
-##
-##  Classes available in template
-##    objEntity - the ObjEntity class: See org.apache.cayenne.map.ObjectEntity
-##    stringUtils - class for string "helper" functions: See org.apache.cayenne.gen.StringUtils
-##    entityUtils - class for entity "helper" functions: See org.apache.cayenne.gen.EntityUtils
-##    importUtils - class for import statement management: See org.apache.cayenne.gen.ImportUtils
-##
-##
-${importUtils.setPackage($subPackageName)}##
-${importUtils.addReservedType("${subPackageName}.${subClassName}")}##
-${importUtils.addType("${superPackageName}.${superClassName}")}##
-${importUtils.generate()}
-
-public#if("true" == "${object.isAbstract()}") abstract#end class ${subClassName} extends ${superClassName} {
-
-    private static final long serialVersionUID = 1L; 
-
-##callbacks
-#foreach($cbname in ${entityUtils.callbackNames})
-    @Override
-    protected void ${cbname}() {
-        //TODO: implement ${cbname}
-    }
-
-#end 
-}

http://git-wip-us.apache.org/repos/asf/cayenne/blob/c63b6be2/cayenne-tools/src/main/resources/templates/v1_2/superclass.vm
----------------------------------------------------------------------
diff --git a/cayenne-tools/src/main/resources/templates/v1_2/superclass.vm b/cayenne-tools/src/main/resources/templates/v1_2/superclass.vm
deleted file mode 100644
index 7857189..0000000
--- a/cayenne-tools/src/main/resources/templates/v1_2/superclass.vm
+++ /dev/null
@@ -1,164 +0,0 @@
-##   Licensed to the Apache Software Foundation (ASF) under one
-##  or more contributor license agreements.  See the NOTICE file
-##  distributed with this work for additional information
-##  regarding copyright ownership.  The ASF licenses this file
-##  to you under the Apache License, Version 2.0 (the
-##  "License"); you may not use this file except in compliance
-##  with the License.  You may obtain a copy of the License at
-##
-##    http://www.apache.org/licenses/LICENSE-2.0
-##
-##  Unless required by applicable law or agreed to in writing,
-##  software distributed under the License is distributed on an
-##  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-##  KIND, either express or implied.  See the License for the
-##  specific language governing permissions and limitations
-##  under the License.
-##
-##Terminology:
-##	Base class - super superclass of entity, ie, org.apache.cayenne.CayenneDataObject or MyBaseClass
-##  Super class - superclass of entity, ie,  org.apache.cayenne.art.auto._Artist
-##	Sub class - class of entity, ie, org.apache.cayenne.art.Artist
-##
-##  Classes available in template
-##    object (duplicated as 'objEntity') - the ObjEntity class: See org.apache.cayenne.map.ObjectEntity
-##    stringUtils - class for string "helper" functions: See org.apache.cayenne.gen.StringUtils
-##    entityUtils - class for entity "helper" functions: See org.apache.cayenne.gen.EntityUtils
-##    importUtils - class for import statement management: See org.apache.cayenne.gen.ImportUtils
-##    superClassName
-##    superPackageName
-##    subClassName
-##    subPackageName
-##    baseClassName
-##    basePackageName
-##
-${importUtils.setPackage($superPackageName)}##
-${importUtils.addReservedType("${superPackageName}.${superClassName}")}##
-${importUtils.addType("${basePackageName}.${baseClassName}")}##
-#if((${object.DeclaredAttributes} && !${object.DeclaredAttributes.isEmpty()}) || (${object.DeclaredRelationships} && !${object.DeclaredRelationships.isEmpty()}))
-${importUtils.addType('org.apache.cayenne.exp.Property')}##
-#end
-#foreach( $attr in ${object.DeclaredAttributes} )
-$importUtils.addType(${attr.Type})##
-#end
-#foreach( $rel in ${object.DeclaredRelationships} )
-$importUtils.addType(${rel.TargetEntity.ClassName})##
-#if(${rel.CollectionType}) 
-$importUtils.addType(${rel.CollectionType})##
-#end
-#end
-${importUtils.generate()}
-
-/**
- * Class ${superClassName} was generated by Cayenne.
- * It is probably a good idea to avoid changing this class manually,
- * since it may be overwritten next time code is regenerated.
- * If you need to make any customizations, please use subclass.
- */
-public abstract class ${superClassName} extends ${baseClassName} {
-
-    private static final long serialVersionUID = 1L; 
-
-## Create property names
-#if( $createPropertyNames )
-#foreach( $attr in ${object.DeclaredAttributes} )
-    public static final String ${stringUtils.capitalizedAsConstant($attr.Name)}_PROPERTY = "${attr.Name}";
-#end
-#foreach( $rel in ${object.DeclaredRelationships} )
-    public static final String ${stringUtils.capitalizedAsConstant($rel.Name)}_PROPERTY = "${rel.Name}";
-#end
-
-#end
-#if( $object.DbEntity )
-#foreach( $idAttr in ${object.DbEntity.PrimaryKeys} )
-    public static final String ${stringUtils.capitalizedAsConstant($idAttr.Name)}_PK_COLUMN = "${idAttr.Name}";
-#end
-#end
-
-## Create Properties
-#foreach( $attr in ${object.DeclaredAttributes} )
-    #set ( $type = "$importUtils.formatJavaType(${attr.Type}, false)")
-    public static final Property<$type> ${stringUtils.capitalizedAsConstant($attr.Name)} = Property.create("${attr.Name}", ${stringUtils.stripGeneric($type)}.class);
-#end
-#foreach( $rel in ${object.DeclaredRelationships} )
-#if( $rel.ToMany )
-#if ( ${rel.CollectionType} == "java.util.Map")
-    #set( $type = "$importUtils.formatJavaType($rel.CollectionType)<$importUtils.formatJavaType($entityUtils.getMapKeyType($rel)), $importUtils.formatJavaType($rel.TargetEntity.ClassName)>" )
-    public static final Property<$type> ${stringUtils.capitalizedAsConstant($rel.Name)} = Property.create("${rel.Name}", ${stringUtils.stripGeneric($type)}.class);
-#else
-    #set( $type = "$importUtils.formatJavaType($rel.CollectionType)<$importUtils.formatJavaType($rel.TargetEntity.ClassName)>" )
-    public static final Property<$type> ${stringUtils.capitalizedAsConstant($rel.Name)} = Property.create("${rel.Name}", ${stringUtils.stripGeneric($type)}.class);
-#end
-#else
-    #set( $type = "$importUtils.formatJavaType(${rel.TargetEntity.ClassName})" )
-    public static final Property<$type> ${stringUtils.capitalizedAsConstant($rel.Name)} = Property.create("${rel.Name}", ${stringUtils.stripGeneric($type)}.class);
-#end
-#end
-
-## Create attribute set/get methods
-#foreach( $attr in ${object.DeclaredAttributes} )
-#if ("true" != "${object.isReadOnly()}")
-    public void set${stringUtils.capitalized($attr.Name)}($importUtils.formatJavaType(${attr.Type}) $stringUtils.formatVariableName(${attr.Name})) {
-        writeProperty("${attr.Name}", $stringUtils.formatVariableName(${attr.Name}));
-    }
-#end
-#if ( $importUtils.isBoolean(${attr.Type}) )
-	public boolean is${stringUtils.capitalized($attr.Name)}() {
-        Boolean value = (Boolean)readProperty("${attr.Name}");
-        return (value != null) ? value.booleanValue() : false;
-    }
-#elseif ( $importUtils.isNonBooleanPrimitive(${attr.Type}) )
-    public ${importUtils.formatJavaType($attr.Type)} get${stringUtils.capitalized($attr.Name)}() {
-        Object value = readProperty("${attr.Name}");
-        return (value != null) ? ($importUtils.formatJavaTypeAsNonBooleanPrimitive(${attr.Type})) value : 0;
-    }
-#else
-    public $importUtils.formatJavaType(${attr.Type}) get${stringUtils.capitalized($attr.Name)}() {
-        return ($importUtils.formatJavaType(${attr.Type}))readProperty("${attr.Name}");
-    }
-#end
-
-#end
-##
-## Create list add/remove/get methods
-#foreach( $rel in ${object.DeclaredRelationships} )
-#if( $rel.ToMany )
-#if ( ! $rel.ReadOnly )
-    public void addTo${stringUtils.capitalized($rel.Name)}($importUtils.formatJavaType(${rel.TargetEntity.ClassName}) obj) {
-        addToManyTarget("${rel.Name}", obj, true);
-    }
-    public void removeFrom${stringUtils.capitalized($rel.Name)}($importUtils.formatJavaType(${rel.TargetEntity.ClassName}) obj) {
-        removeToManyTarget("${rel.Name}", obj, true);
-    }
-#end
-    @SuppressWarnings("unchecked")
-#if ( ${rel.CollectionType} == "java.util.Map")
-    public $importUtils.formatJavaType($rel.CollectionType)<$importUtils.formatJavaType($entityUtils.getMapKeyType($rel)), $importUtils.formatJavaType($rel.TargetEntity.ClassName)> get${stringUtils.capitalized($rel.Name)}() {
-        return ($importUtils.formatJavaType($rel.CollectionType)<$importUtils.formatJavaType($entityUtils.getMapKeyType($rel)), $importUtils.formatJavaType($rel.TargetEntity.ClassName)>)readProperty("${rel.Name}");
-    }
-#else
-    public $importUtils.formatJavaType($rel.CollectionType)<$importUtils.formatJavaType($rel.TargetEntity.ClassName)> get${stringUtils.capitalized($rel.Name)}() {
-        return ($importUtils.formatJavaType($rel.CollectionType)<$importUtils.formatJavaType($rel.TargetEntity.ClassName)>)readProperty("${rel.Name}");
-    }
-#end
-#else
-#if ( !${object.isReadOnly()} && !$rel.ReadOnly )
-    public void set${stringUtils.capitalized($rel.Name)}($importUtils.formatJavaType(${rel.TargetEntity.ClassName}) $stringUtils.formatVariableName(${rel.name})) {
-        setToOneTarget("${rel.Name}", $stringUtils.formatVariableName(${rel.name}), true);
-    }
-#end
-
-    public $importUtils.formatJavaType(${rel.TargetEntity.ClassName}) get${stringUtils.capitalized($rel.Name)}() {
-        return ($importUtils.formatJavaType(${rel.TargetEntity.ClassName}))readProperty("${rel.Name}");
-    }
-#end
-
-
-#end
-##
-##callback methods
-#foreach($cbname in ${entityUtils.callbackNames})
-    protected abstract void ${cbname}();
-
-#end
-}

http://git-wip-us.apache.org/repos/asf/cayenne/blob/c63b6be2/cayenne-tools/src/test/java/org/apache/cayenne/gen/ClassGenerationActionTest.java
----------------------------------------------------------------------
diff --git a/cayenne-tools/src/test/java/org/apache/cayenne/gen/ClassGenerationActionTest.java b/cayenne-tools/src/test/java/org/apache/cayenne/gen/ClassGenerationActionTest.java
deleted file mode 100644
index 9379e21..0000000
--- a/cayenne-tools/src/test/java/org/apache/cayenne/gen/ClassGenerationActionTest.java
+++ /dev/null
@@ -1,255 +0,0 @@
-/*****************************************************************
- *   Licensed to the Apache Software Foundation (ASF) under one
- *  or more contributor license agreements.  See the NOTICE file
- *  distributed with this work for additional information
- *  regarding copyright ownership.  The ASF licenses this file
- *  to you under the Apache License, Version 2.0 (the
- *  "License"); you may not use this file except in compliance
- *  with the License.  You may obtain a copy of the License at
- *
- *    http://www.apache.org/licenses/LICENSE-2.0
- *
- *  Unless required by applicable law or agreed to in writing,
- *  software distributed under the License is distributed on an
- *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- *  KIND, either express or implied.  See the License for the
- *  specific language governing permissions and limitations
- *  under the License.
- ****************************************************************/
-package org.apache.cayenne.gen;
-
-import org.apache.cayenne.map.CallbackDescriptor;
-import org.apache.cayenne.map.DataMap;
-import org.apache.cayenne.map.ObjAttribute;
-import org.apache.cayenne.map.ObjEntity;
-import org.apache.cayenne.map.ObjRelationship;
-import org.apache.cayenne.map.QueryDescriptor;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-
-import java.io.StringWriter;
-import java.io.Writer;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.List;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
-
-public class ClassGenerationActionTest {
-
-	protected ClassGenerationAction action;
-	protected Collection<StringWriter> writers;
-
-	@Before
-	public void setUp() throws Exception {
-		this.writers = new ArrayList<StringWriter>(3);
-		this.action = new ClassGenerationAction() {
-
-			@Override
-			protected Writer openWriter(TemplateType templateType) throws Exception {
-				StringWriter writer = new StringWriter();
-				writers.add(writer);
-				return writer;
-			}
-		};
-	}
-
-	@After
-	public void tearDown() throws Exception {
-		action = null;
-		writers = null;
-	}
-
-	@Test
-	public void testExecuteArtifactPairsImports() throws Exception {
-
-		ObjEntity testEntity1 = new ObjEntity("TE1");
-		testEntity1.setClassName("org.example.TestClass1");
-
-		action.setMakePairs(true);
-		action.setSuperPkg("org.example.auto");
-
-		List<String> generated = execute(new EntityArtifact(testEntity1));
-		assertNotNull(generated);
-		assertEquals(2, generated.size());
-
-		String superclass = generated.get(0);
-		assertTrue(superclass, superclass.contains("package org.example.auto;"));
-		assertTrue(superclass, superclass.contains("import org.apache.cayenne.CayenneDataObject;"));
-
-		String subclass = generated.get(1);
-		assertTrue(subclass, subclass.contains("package org.example;"));
-		assertTrue(subclass, subclass.contains("import org.example.auto._TestClass1;"));
-	}
-
-	@Test
-	public void testExecuteArtifactPairsMapRelationships() throws Exception {
-
-		ObjEntity testEntity1 = new ObjEntity("TE1");
-		testEntity1.setClassName("org.example.TestClass1");
-
-		final ObjEntity testEntity2 = new ObjEntity("TE1");
-		testEntity2.setClassName("org.example.TestClass2");
-
-		ObjRelationship relationship = new ObjRelationship("xMap") {
-
-			private static final long serialVersionUID = 8042147877503405974L;
-
-			@Override
-			public boolean isToMany() {
-				return true;
-			}
-
-			@Override
-			public ObjEntity getTargetEntity() {
-				return testEntity2;
-			}
-		};
-		relationship.setCollectionType("java.util.Map");
-		testEntity1.addRelationship(relationship);
-
-		action.setMakePairs(true);
-
-		List<String> generated = execute(new EntityArtifact(testEntity1));
-		assertNotNull(generated);
-		assertEquals(2, generated.size());
-
-		String superclass = generated.get(0);
-		assertTrue(superclass, superclass.contains("import java.util.Map;"));
-	}
-
-	@Test
-	public void testExecuteArtifactPairsAttribute() throws Exception {
-
-		ObjEntity testEntity1 = new ObjEntity("TE1");
-		testEntity1.setClassName("org.example.TestClass1");
-
-		ObjAttribute attr = new ObjAttribute();
-		attr.setName("ID");
-		attr.setType("int");
-
-		ObjAttribute attr1 = new ObjAttribute();
-		attr1.setName("name");
-		attr1.setType("char");
-
-		testEntity1.addAttribute(attr);
-		testEntity1.addAttribute(attr1);
-
-		action.setMakePairs(true);
-
-		List<String> generated = execute(new EntityArtifact(testEntity1));
-		assertNotNull(generated);
-		assertEquals(2, generated.size());
-		String superclass = generated.get(0);
-
-		assertTrue(superclass, superclass.contains("public void setID(int ID)"));
-		assertTrue(superclass, superclass.contains("writeProperty(\"ID\", ID);"));
-
-		assertTrue(superclass, superclass.contains("public int getID()"));
-		assertTrue(superclass, superclass.contains("Object value = readProperty(\"ID\");"));
-		assertTrue(superclass, superclass.contains("return (value != null) ? (Integer) value : 0;"));
-
-		assertTrue(superclass, superclass.contains("public void setName(char name)"));
-		assertTrue(superclass, superclass.contains("writeProperty(\"name\", name);"));
-
-		assertTrue(superclass, superclass.contains("public char getName()"));
-		assertTrue(superclass, superclass.contains("Object value = readProperty(\"name\");"));
-		assertTrue(superclass, superclass.contains("return (value != null) ? (Character) value : 0;"));
-
-	}
-
-	@Test
-	public void testExecuteDataMapQueryNames() throws Exception {
-		runDataMapTest(false);
-	}
-
-	@Test
-	public void testExecuteClientDataMapQueryNames() throws Exception {
-		runDataMapTest(true);
-	}
-
-	private void runDataMapTest(boolean client) throws Exception {
-		QueryDescriptor descriptor = QueryDescriptor.selectQueryDescriptor();
-        descriptor.setName("TestQuery");
-
-		DataMap map = new DataMap();
-		map.addQueryDescriptor(descriptor);
-		map.setName("testmap");
-		List<String> generated;
-		if (client) {
-			map.setDefaultClientPackage("testpackage");
-			generated = execute(new ClientDataMapArtifact(map, map.getQueryDescriptors()));
-		} else {
-			map.setDefaultPackage("testpackage");
-			generated = execute(new DataMapArtifact(map, map.getQueryDescriptors()));
-		}
-		assertEquals(2, generated.size());
-		assertTrue(generated.get(0).contains("public static final String TEST_QUERY_QUERYNAME = \"TestQuery\""));
-	}
-
-	@Test
-	public void testCallbackMethodGeneration() throws Exception {
-		assertCallbacks(false);
-	}
-
-	@Test
-	public void testClientCallbackMethodGeneration() throws Exception {
-		assertCallbacks(true);
-	}
-
-	private void assertCallbacks(boolean isClient) throws Exception {
-		ObjEntity testEntity1 = new ObjEntity("TE1");
-		testEntity1.setClassName("org.example.TestClass1");
-		int i = 0;
-		for (CallbackDescriptor cb : testEntity1.getCallbackMap().getCallbacks()) {
-			cb.addCallbackMethod("cb" + i++);
-		}
-
-		if (isClient) {
-
-			action = new ClientClassGenerationAction() {
-				@Override
-				protected Writer openWriter(TemplateType templateType) throws Exception {
-					StringWriter writer = new StringWriter();
-					writers.add(writer);
-					return writer;
-				}
-
-			};
-
-		}
-
-		action.setMakePairs(true);
-
-		List<String> generated = execute(new EntityArtifact(testEntity1));
-		assertNotNull(generated);
-		assertEquals(2, generated.size());
-
-		String superclass = generated.get(0);
-
-		assertTrue(superclass, superclass.contains("public abstract class _TestClass1"));
-
-		for (int j = 0; j < i; j++) {
-			assertTrue(superclass, superclass.contains("protected abstract void cb" + j + "();"));
-		}
-
-		String subclass = generated.get(1);
-		for (int j = 0; j < i; j++) {
-			assertTrue(subclass, subclass.contains("protected void cb" + j + "() {"));
-		}
-	}
-
-	protected List<String> execute(Artifact artifact) throws Exception {
-
-		action.execute(artifact);
-
-		List<String> strings = new ArrayList<String>(writers.size());
-		for (StringWriter writer : writers) {
-			strings.add(writer.toString());
-		}
-		return strings;
-	}
-}

http://git-wip-us.apache.org/repos/asf/cayenne/blob/c63b6be2/cayenne-tools/src/test/java/org/apache/cayenne/gen/ClassGenerationCase.java
----------------------------------------------------------------------
diff --git a/cayenne-tools/src/test/java/org/apache/cayenne/gen/ClassGenerationCase.java b/cayenne-tools/src/test/java/org/apache/cayenne/gen/ClassGenerationCase.java
deleted file mode 100644
index 44b709d..0000000
--- a/cayenne-tools/src/test/java/org/apache/cayenne/gen/ClassGenerationCase.java
+++ /dev/null
@@ -1,59 +0,0 @@
-/*****************************************************************
- *   Licensed to the Apache Software Foundation (ASF) under one
- *  or more contributor license agreements.  See the NOTICE file
- *  distributed with this work for additional information
- *  regarding copyright ownership.  The ASF licenses this file
- *  to you under the Apache License, Version 2.0 (the
- *  "License"); you may not use this file except in compliance
- *  with the License.  You may obtain a copy of the License at
- *
- *    http://www.apache.org/licenses/LICENSE-2.0
- *
- *  Unless required by applicable law or agreed to in writing,
- *  software distributed under the License is distributed on an
- *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- *  KIND, either express or implied.  See the License for the
- *  specific language governing permissions and limitations
- *  under the License.
- ****************************************************************/
-
-package org.apache.cayenne.gen;
-
-import org.apache.velocity.Template;
-import org.apache.velocity.app.VelocityEngine;
-import org.apache.velocity.context.Context;
-import org.apache.velocity.runtime.RuntimeConstants;
-import org.apache.velocity.runtime.log.NullLogSystem;
-import org.junit.Before;
-
-import java.io.StringWriter;
-import java.util.Properties;
-
-public class ClassGenerationCase {
-
-    private VelocityEngine velocityEngine;
-
-    @Before
-    public void setUp() throws Exception {
-        Properties props = new Properties();
-
-        // null logger that will prevent velocity.log from being generated
-        props.put(RuntimeConstants.RUNTIME_LOG_LOGSYSTEM_CLASS, NullLogSystem.class.getName());
-        props.put("resource.loader", "cayenne");
-        props.put("cayenne.resource.loader.class", ClassGeneratorResourceLoader.class.getName());
-        props.put("cayenne.resource.loader.cache", "false");
-
-        this.velocityEngine = new VelocityEngine();
-        this.velocityEngine.init(props);
-    }
-
-    protected String renderTemplate(String templateName, Context context) throws Exception {
-        StringWriter writer = new StringWriter();
-
-        Template template = velocityEngine.getTemplate(templateName);
-        template.merge(context, writer);
-
-        return writer.toString();
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/cayenne/blob/c63b6be2/cayenne-tools/src/test/java/org/apache/cayenne/gen/ClientSuperClassGenerationTest.java
----------------------------------------------------------------------
diff --git a/cayenne-tools/src/test/java/org/apache/cayenne/gen/ClientSuperClassGenerationTest.java b/cayenne-tools/src/test/java/org/apache/cayenne/gen/ClientSuperClassGenerationTest.java
deleted file mode 100644
index b690367..0000000
--- a/cayenne-tools/src/test/java/org/apache/cayenne/gen/ClientSuperClassGenerationTest.java
+++ /dev/null
@@ -1,86 +0,0 @@
-/*****************************************************************
- *   Licensed to the Apache Software Foundation (ASF) under one
- *  or more contributor license agreements.  See the NOTICE file
- *  distributed with this work for additional information
- *  regarding copyright ownership.  The ASF licenses this file
- *  to you under the Apache License, Version 2.0 (the
- *  "License"); you may not use this file except in compliance
- *  with the License.  You may obtain a copy of the License at
- *
- *    http://www.apache.org/licenses/LICENSE-2.0
- *
- *  Unless required by applicable law or agreed to in writing,
- *  software distributed under the License is distributed on an
- *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- *  KIND, either express or implied.  See the License for the
- *  specific language governing permissions and limitations
- *  under the License.
- ****************************************************************/
-
-package org.apache.cayenne.gen;
-
-import org.apache.cayenne.map.ObjAttribute;
-import org.apache.cayenne.map.ObjEntity;
-import org.apache.cayenne.map.ObjRelationship;
-import org.apache.velocity.VelocityContext;
-import org.junit.Test;
-
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
-
-public class ClientSuperClassGenerationTest extends ClassGenerationCase {
-
-    @Test
-    public void testNotContainsPropertyImport() throws Exception {
-        ObjEntity objEntity = new ObjEntity("TEST1");
-
-        VelocityContext context = new VelocityContext();
-        context.put(Artifact.OBJECT_KEY, objEntity);
-
-        String res = renderTemplate(ClientClassGenerationAction.SUPERCLASS_TEMPLATE, context);
-        assertFalse(res.contains("org.apache.cayenne.exp.Property"));
-    }
-
-    @Test
-    public void testContainsPropertyImportForAttributes() throws Exception {
-        ObjEntity objEntity = new ObjEntity("TEST1");
-        ObjAttribute attr = new ObjAttribute("attr");
-        objEntity.addAttribute(attr);
-
-        VelocityContext context = new VelocityContext();
-        context.put(Artifact.OBJECT_KEY, objEntity);
-
-        String res = renderTemplate(ClientClassGenerationAction.SUPERCLASS_TEMPLATE, context);
-        assertTrue(res.contains("org.apache.cayenne.exp.Property"));
-    }
-
-    @Test
-    public void testContainsPropertyImportForRelationships() throws Exception {
-        ObjEntity objEntity = new ObjEntity("TEST1");
-        ObjRelationship rel = new ObjRelationship("rel");
-        objEntity.addRelationship(rel);
-
-        VelocityContext context = new VelocityContext();
-        context.put(Artifact.OBJECT_KEY, objEntity);
-
-        String res = renderTemplate(ClientClassGenerationAction.SUPERCLASS_TEMPLATE, context);
-        assertTrue(res.contains("org.apache.cayenne.exp.Property"));
-    }
-
-    @Test
-    public void testContainsPropertyImport() throws Exception {
-        ObjEntity objEntity = new ObjEntity("TEST1");
-        ObjAttribute attr = new ObjAttribute("attr");
-        ObjRelationship rel = new ObjRelationship("rel");
-
-        objEntity.addAttribute(attr);
-        objEntity.addRelationship(rel);
-
-        VelocityContext context = new VelocityContext();
-        context.put(Artifact.OBJECT_KEY, objEntity);
-
-        String res = renderTemplate(ClientClassGenerationAction.SUPERCLASS_TEMPLATE, context);
-        assertTrue(res.contains("org.apache.cayenne.exp.Property"));
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/cayenne/blob/c63b6be2/cayenne-tools/src/test/java/org/apache/cayenne/gen/EntityUtilsTest.java
----------------------------------------------------------------------
diff --git a/cayenne-tools/src/test/java/org/apache/cayenne/gen/EntityUtilsTest.java b/cayenne-tools/src/test/java/org/apache/cayenne/gen/EntityUtilsTest.java
deleted file mode 100644
index 0e4ce23..0000000
--- a/cayenne-tools/src/test/java/org/apache/cayenne/gen/EntityUtilsTest.java
+++ /dev/null
@@ -1,74 +0,0 @@
-/*****************************************************************
- *   Licensed to the Apache Software Foundation (ASF) under one
- *  or more contributor license agreements.  See the NOTICE file
- *  distributed with this work for additional information
- *  regarding copyright ownership.  The ASF licenses this file
- *  to you under the Apache License, Version 2.0 (the
- *  "License"); you may not use this file except in compliance
- *  with the License.  You may obtain a copy of the License at
- *
- *    http://www.apache.org/licenses/LICENSE-2.0
- *
- *  Unless required by applicable law or agreed to in writing,
- *  software distributed under the License is distributed on an
- *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- *  KIND, either express or implied.  See the License for the
- *  specific language governing permissions and limitations
- *  under the License.
- ****************************************************************/
-package org.apache.cayenne.gen;
-
-import org.apache.cayenne.map.CallbackDescriptor;
-import org.apache.cayenne.map.DataMap;
-import org.apache.cayenne.map.ObjEntity;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-
-import java.util.LinkedHashSet;
-import java.util.Set;
-
-import static org.junit.Assert.assertTrue;
-
-
-public class EntityUtilsTest {
-    
-    protected EntityUtils entityUtils = null;
-    protected DataMap dataMap = null;
-    protected ObjEntity objEntity = null;
-    
-    @Before
-    public void setUp() throws Exception {
-        dataMap = new DataMap();
-        objEntity = new ObjEntity();
-    }
-    
-    @After
-    public void tearDown() throws Exception {
-        dataMap = null;
-        objEntity = null;
-        entityUtils = null;
-    }
-
-    @Test
-    public void testAllCallbackNamesUnique() throws Exception {
-        
-        CallbackDescriptor[] callbacks = objEntity.getCallbackMap().getCallbacks();
-        for (int i = 0; i < callbacks.length; i++) {
-            callbacks[i].addCallbackMethod("callback1");
-            callbacks[i].addCallbackMethod("callback2");
-            callbacks[i].addCallbackMethod("callback3");
-        }
-        entityUtils = new EntityUtils(dataMap, objEntity, "TestBaseClass", "TestSuperClass", "TestSubClass");
-        
-        boolean hasNoDuplicates = true;
-        Set<String> callbackNames = new LinkedHashSet<String>();
-        for (String cbName : entityUtils.getCallbackNames()) {
-            if (!callbackNames.add(cbName)) {
-                hasNoDuplicates = false;
-            }
-        }
-        
-        assertTrue("Contains duplicate callback names.", hasNoDuplicates);
-    }
-}

http://git-wip-us.apache.org/repos/asf/cayenne/blob/c63b6be2/cayenne-tools/src/test/java/org/apache/cayenne/gen/ImportUtilsTest.java
----------------------------------------------------------------------
diff --git a/cayenne-tools/src/test/java/org/apache/cayenne/gen/ImportUtilsTest.java b/cayenne-tools/src/test/java/org/apache/cayenne/gen/ImportUtilsTest.java
deleted file mode 100644
index c6baa31..0000000
--- a/cayenne-tools/src/test/java/org/apache/cayenne/gen/ImportUtilsTest.java
+++ /dev/null
@@ -1,252 +0,0 @@
-/*****************************************************************
- *   Licensed to the Apache Software Foundation (ASF) under one
- *  or more contributor license agreements.  See the NOTICE file
- *  distributed with this work for additional information
- *  regarding copyright ownership.  The ASF licenses this file
- *  to you under the Apache License, Version 2.0 (the
- *  "License"); you may not use this file except in compliance
- *  with the License.  You may obtain a copy of the License at
- *
- *    http://www.apache.org/licenses/LICENSE-2.0
- *
- *  Unless required by applicable law or agreed to in writing,
- *  software distributed under the License is distributed on an
- *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- *  KIND, either express or implied.  See the License for the
- *  specific language governing permissions and limitations
- *  under the License.
- ****************************************************************/
-
-package org.apache.cayenne.gen;
-
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
-
-public class ImportUtilsTest {
-
-    protected ImportUtils importUtils = null;
-
-    @Before
-    public void setUp() throws Exception {
-        importUtils = new ImportUtils();
-    }
-
-    @After
-    public void tearDown() throws Exception {
-        importUtils = null;
-    }
-
-    @Test
-    public void testSetPackageGeneratesPackageStatement() throws Exception {
-        final String packageName = "org.myPackage";
-        final String expectedPackageStatement = "package " + packageName + ";";
-
-        importUtils.setPackage(packageName);
-
-        String generatedStatements = importUtils.generate();
-        assertTrue("<"
-                + generatedStatements
-                + "> does not start with <"
-                + expectedPackageStatement
-                + ">", generatedStatements.startsWith(expectedPackageStatement));
-        assertEquals("package statement appears multiple times.", generatedStatements
-                .lastIndexOf(expectedPackageStatement), generatedStatements
-                .lastIndexOf(expectedPackageStatement));
-    }
-
-    @Test
-    public void testAddTypeGeneratesImportStatement() throws Exception {
-        final String type = "org.myPackage.myType";
-        final String expectedImportStatement = "import " + type + ";";
-
-        importUtils.addType(type);
-
-        String generatedStatements = importUtils.generate();
-        assertFalse("<"
-                + generatedStatements
-                + "> does not contain <"
-                + expectedImportStatement
-                + ">", !generatedStatements.contains(expectedImportStatement));
-        assertEquals("import statement appears multiple times.", generatedStatements
-                .lastIndexOf(expectedImportStatement), generatedStatements
-                .lastIndexOf(expectedImportStatement));
-    }
-
-    @Test
-    public void testAddReservedTypeGeneratesNoImportStatement() throws Exception {
-        final String type = "org.myPackage.myType";
-
-        importUtils.addReservedType(type);
-
-        String generatedStatements = importUtils.generate();
-        assertEquals(
-                "<" + generatedStatements + "> contains <" + type + ">",
-                -1,
-                generatedStatements.indexOf(type));
-    }
-
-    @Test
-    public void testAddTypeAfterReservedTypeGeneratesNoImportStatement() throws Exception {
-        final String baseType = "myType";
-        final String reservedType = "org.myPackage." + baseType;
-        final String nonReservedType = "org.myPackage2." + baseType;
-
-        importUtils.addReservedType(reservedType);
-        importUtils.addType(nonReservedType);
-
-        String generatedStatements = importUtils.generate();
-        assertEquals(
-                "<" + generatedStatements + "> contains <" + reservedType + ">",
-                -1,
-                generatedStatements.indexOf(reservedType));
-        assertEquals(
-                "<" + generatedStatements + "> contains <" + nonReservedType + ">",
-                -1,
-                generatedStatements.indexOf(nonReservedType));
-    }
-
-    @Test
-    public void testAddTypeAfterPackageReservedTypeGeneratesNoImportStatement()
-            throws Exception {
-        final String baseType = "myType";
-        final String packageType = "org.myPackage";
-        final String reservedType = packageType + "." + baseType;
-        final String nonReservedType = "org.myPackage2." + baseType;
-
-        importUtils.setPackage(packageType);
-        importUtils.addReservedType(reservedType);
-        importUtils.addType(nonReservedType);
-
-        String generatedStatements = importUtils.generate();
-
-        assertEquals(
-                "<" + generatedStatements + "> contains <" + reservedType + ">",
-                -1,
-                generatedStatements.indexOf(reservedType));
-        assertEquals(
-                "<" + generatedStatements + "> contains <" + nonReservedType + ">",
-                -1,
-                generatedStatements.indexOf(nonReservedType));
-    }
-
-    @Test
-    public void testAddTypeAfterTypeGeneratesNoImportStatement() throws Exception {
-        final String baseType = "myType";
-        final String firstType = "org.myPackage." + baseType;
-        final String secondType = "org.myPackage2." + baseType;
-
-        final String expectedImportStatement = "import " + firstType + ";";
-
-        importUtils.addType(firstType);
-        importUtils.addType(secondType);
-
-        String generatedStatements = importUtils.generate();
-
-        assertFalse("<"
-                + generatedStatements
-                + "> does not contain <"
-                + expectedImportStatement
-                + ">", !generatedStatements.contains(expectedImportStatement));
-        assertEquals("import statement appears multiple times.", generatedStatements
-                .lastIndexOf(expectedImportStatement), generatedStatements
-                .lastIndexOf(expectedImportStatement));
-
-        assertEquals(
-                "<" + generatedStatements + "> contains <" + secondType + ">",
-                -1,
-                generatedStatements.indexOf(secondType));
-    }
-
-    @Test
-    public void testAddSimilarTypeTwiceBeforeFormatJavaTypeGeneratesCorrectFQNs()
-            throws Exception {
-        final String baseType = "myType";
-        final String firstType = "org.myPackage." + baseType;
-        final String secondType = "org.myPackage2." + baseType;
-
-        importUtils.addType(firstType);
-        importUtils.addType(secondType);
-
-        assertEquals(baseType, importUtils.formatJavaType(firstType));
-        assertEquals(secondType, importUtils.formatJavaType(secondType));
-    }
-
-    @Test
-    public void testAddTypeBeforeFormatJavaTypeGeneratesCorrectFQNs() throws Exception {
-        final String baseType = "myType";
-        final String fullyQualifiedType = "org.myPackage." + baseType;
-
-        importUtils.addType(fullyQualifiedType);
-
-        assertEquals(baseType, importUtils.formatJavaType(fullyQualifiedType));
-    }
-
-    @Test
-    public void testAddReservedTypeBeforeFormatJavaTypeGeneratesCorrectFQNs()
-            throws Exception {
-        final String baseType = "myType";
-        final String fullyQualifiedType = "org.myPackage." + baseType;
-
-        importUtils.addReservedType(fullyQualifiedType);
-
-        assertEquals(fullyQualifiedType, importUtils.formatJavaType(fullyQualifiedType));
-    }
-
-    @Test
-    public void testFormatJavaTypeWithPrimitives() throws Exception {
-        assertEquals("int", importUtils.formatJavaType("int", true));
-        assertEquals("Integer", importUtils.formatJavaType("int", false));
-
-        assertEquals("char", importUtils.formatJavaType("char", true));
-        assertEquals("Character", importUtils
-                .formatJavaType("java.lang.Character", false));
-
-        assertEquals("double", importUtils.formatJavaType("java.lang.Double", true));
-        assertEquals("Double", importUtils.formatJavaType("java.lang.Double", false));
-
-        assertEquals("a.b.C", importUtils.formatJavaType("a.b.C", true));
-        assertEquals("a.b.C", importUtils.formatJavaType("a.b.C", false));
-    }
-
-    @Test
-    public void testFormatJavaTypeWithoutAddTypeGeneratesCorrectFQNs() throws Exception {
-        final String baseType = "myType";
-        final String fullyQualifiedType = "org.myPackage." + baseType;
-
-        assertEquals(fullyQualifiedType, importUtils.formatJavaType(fullyQualifiedType));
-    }
-
-    @Test
-    public void testPackageFormatJavaTypeWithoutAddTypeGeneratesCorrectFQNs()
-            throws Exception {
-        final String baseType = "myType";
-        final String packageType = "org.myPackage";
-        final String fullyQualifiedType = packageType + "." + baseType;
-
-        importUtils.setPackage(packageType);
-
-        assertEquals(baseType, importUtils.formatJavaType(fullyQualifiedType));
-    }
-
-    @Test
-    public void testFormatJavaType() {
-        assertEquals("x.X", importUtils.formatJavaType("x.X"));
-        assertEquals("X", importUtils.formatJavaType("java.lang.X"));
-        assertEquals("java.lang.x.X", importUtils.formatJavaType("java.lang.x.X"));
-    }
-
-    @Test
-    public void testJavaLangTypeFormatJavaTypeWithoutAddTypeGeneratesCorrectFQNs()
-            throws Exception {
-        final String baseType = "myType";
-        final String packageType = "java.lang";
-        final String fullyQualifiedType = packageType + "." + baseType;
-
-        assertEquals(baseType, importUtils.formatJavaType(fullyQualifiedType));
-    }
-}

http://git-wip-us.apache.org/repos/asf/cayenne/blob/c63b6be2/cayenne-tools/src/test/java/org/apache/cayenne/gen/SingleClassGenerationTest.java
----------------------------------------------------------------------
diff --git a/cayenne-tools/src/test/java/org/apache/cayenne/gen/SingleClassGenerationTest.java b/cayenne-tools/src/test/java/org/apache/cayenne/gen/SingleClassGenerationTest.java
deleted file mode 100644
index 0bbe9e9..0000000
--- a/cayenne-tools/src/test/java/org/apache/cayenne/gen/SingleClassGenerationTest.java
+++ /dev/null
@@ -1,86 +0,0 @@
-/*****************************************************************
- *   Licensed to the Apache Software Foundation (ASF) under one
- *  or more contributor license agreements.  See the NOTICE file
- *  distributed with this work for additional information
- *  regarding copyright ownership.  The ASF licenses this file
- *  to you under the Apache License, Version 2.0 (the
- *  "License"); you may not use this file except in compliance
- *  with the License.  You may obtain a copy of the License at
- *
- *    http://www.apache.org/licenses/LICENSE-2.0
- *
- *  Unless required by applicable law or agreed to in writing,
- *  software distributed under the License is distributed on an
- *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- *  KIND, either express or implied.  See the License for the
- *  specific language governing permissions and limitations
- *  under the License.
- ****************************************************************/
-
-package org.apache.cayenne.gen;
-
-import org.apache.cayenne.map.ObjAttribute;
-import org.apache.cayenne.map.ObjEntity;
-import org.apache.cayenne.map.ObjRelationship;
-import org.apache.velocity.VelocityContext;
-import org.junit.Test;
-
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
-
-public class SingleClassGenerationTest extends ClassGenerationCase {
-
-    @Test
-    public void testNotContainsPropertyImport() throws Exception {
-        ObjEntity objEntity = new ObjEntity("TEST1");
-
-        VelocityContext context = new VelocityContext();
-        context.put(Artifact.OBJECT_KEY, objEntity);
-
-        String res = renderTemplate(ClassGenerationAction.SINGLE_CLASS_TEMPLATE, context);
-        assertFalse(res.contains("org.apache.cayenne.exp.Property"));
-    }
-
-    @Test
-    public void testContainsPropertyImportForAttributes() throws Exception {
-        ObjEntity objEntity = new ObjEntity("TEST1");
-        ObjAttribute attr = new ObjAttribute("attr");
-        objEntity.addAttribute(attr);
-
-        VelocityContext context = new VelocityContext();
-        context.put(Artifact.OBJECT_KEY, objEntity);
-
-        String res = renderTemplate(ClassGenerationAction.SINGLE_CLASS_TEMPLATE, context);
-        assertTrue(res.contains("org.apache.cayenne.exp.Property"));
-    }
-
-    @Test
-    public void testContainsPropertyImportForRelationships() throws Exception {
-        ObjEntity objEntity = new ObjEntity("TEST1");
-        ObjRelationship rel = new ObjRelationship("rel");
-        objEntity.addRelationship(rel);
-
-        VelocityContext context = new VelocityContext();
-        context.put(Artifact.OBJECT_KEY, objEntity);
-
-        String res = renderTemplate(ClassGenerationAction.SINGLE_CLASS_TEMPLATE, context);
-        assertTrue(res.contains("org.apache.cayenne.exp.Property"));
-    }
-
-    @Test
-    public void testContainsPropertyImport() throws Exception {
-        ObjEntity objEntity = new ObjEntity("TEST1");
-        ObjAttribute attr = new ObjAttribute("attr");
-        ObjRelationship rel = new ObjRelationship("rel");
-
-        objEntity.addAttribute(attr);
-        objEntity.addRelationship(rel);
-
-        VelocityContext context = new VelocityContext();
-        context.put(Artifact.OBJECT_KEY, objEntity);
-
-        String res = renderTemplate(ClassGenerationAction.SINGLE_CLASS_TEMPLATE, context);
-        assertTrue(res.contains("org.apache.cayenne.exp.Property"));
-    }
-
-}


[09/10] cayenne git commit: CAY-2215 split cayenne-tools into cayenne-cgen and cayenne-ant

Posted by nt...@apache.org.
http://git-wip-us.apache.org/repos/asf/cayenne/blob/c63b6be2/cayenne-ant/src/test/java/org/apache/cayenne/tools/CayenneGeneratorTaskTest.java
----------------------------------------------------------------------
diff --git a/cayenne-ant/src/test/java/org/apache/cayenne/tools/CayenneGeneratorTaskTest.java b/cayenne-ant/src/test/java/org/apache/cayenne/tools/CayenneGeneratorTaskTest.java
new file mode 100644
index 0000000..f6f616b
--- /dev/null
+++ b/cayenne-ant/src/test/java/org/apache/cayenne/tools/CayenneGeneratorTaskTest.java
@@ -0,0 +1,317 @@
+/*****************************************************************
+ *   Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ ****************************************************************/
+
+package org.apache.cayenne.tools;
+
+import org.apache.cayenne.test.file.FileUtil;
+import org.apache.cayenne.test.resource.ResourceUtil;
+import org.apache.tools.ant.Location;
+import org.apache.tools.ant.Project;
+import org.junit.Before;
+import org.junit.Test;
+
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.InputStreamReader;
+import java.util.regex.Pattern;
+
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
+public class CayenneGeneratorTaskTest {
+
+	private static final File baseDir;
+	private static final File map;
+	private static final File mapEmbeddables;
+	private static final File template;
+
+	static {
+
+		baseDir = FileUtil.baseTestDirectory();
+		map = new File(baseDir, "antmap.xml");
+		mapEmbeddables = new File(baseDir, "antmap-embeddables.xml");
+		template = new File(baseDir, "velotemplate.vm");
+
+		ResourceUtil.copyResourceToFile("testmap.map.xml", map);
+		ResourceUtil.copyResourceToFile("embeddable.map.xml", mapEmbeddables);
+		ResourceUtil.copyResourceToFile("org/apache/cayenne/tools/velotemplate.vm", template);
+	}
+
+	protected CayenneGeneratorTask task;
+
+	@Before
+	public void setUp() {
+
+		Project project = new Project();
+		project.setBaseDir(baseDir);
+
+		task = new CayenneGeneratorTask();
+		task.setProject(project);
+		task.setTaskName("Test");
+		task.setLocation(Location.UNKNOWN_LOCATION);
+	}
+
+	/**
+	 * Test single classes with a non-standard template.
+	 */
+	@Test
+	public void testSingleClassesCustTemplate() throws Exception {
+		// prepare destination directory
+		File mapDir = new File(baseDir, "single-classes-custtempl");
+		assertTrue(mapDir.mkdirs());
+
+		// setup task
+		task.setDestDir(mapDir);
+		task.setMap(map);
+		task.setMakepairs(false);
+		task.setUsepkgpath(true);
+		task.setTemplate(template.getPath());
+
+		// run task
+		task.execute();
+
+		// check results
+		File a = new File(mapDir, convertPath("org/apache/cayenne/testdo/testmap/Artist.java"));
+		assertTrue(a.isFile());
+		assertContents(a, "Artist", "org.apache.cayenne.testdo.testmap", "CayenneDataObject");
+
+		File _a = new File(mapDir, convertPath("org/apache/cayenne/testdo/testmap/_Artist.java"));
+		assertFalse(_a.exists());
+	}
+
+	/** Test single classes generation including full package path. */
+	@Test
+	public void testSingleClasses1() throws Exception {
+		// prepare destination directory
+		File mapDir = new File(baseDir, "single-classes-tree");
+		assertTrue(mapDir.mkdirs());
+
+		// setup task
+		task.setDestDir(mapDir);
+		task.setMap(map);
+		task.setMakepairs(false);
+		task.setUsepkgpath(true);
+
+		// run task
+		task.execute();
+
+		// check results
+		File a = new File(mapDir, convertPath("org/apache/cayenne/testdo/testmap/Artist.java"));
+		assertTrue(a.isFile());
+		assertContents(a, "Artist", "org.apache.cayenne.testdo.testmap", "CayenneDataObject");
+
+		File _a = new File(mapDir, convertPath("org/apache/cayenne/testdo/testmap/_Artist.java"));
+		assertFalse(_a.exists());
+	}
+
+	/** Test single classes generation ignoring package path. */
+	@Test
+	public void testSingleClasses2() throws Exception {
+		// prepare destination directory
+		File mapDir = new File(baseDir, "single-classes-flat");
+		assertTrue(mapDir.mkdirs());
+
+		// setup task
+		task.setDestDir(mapDir);
+		task.setMap(map);
+		task.setMakepairs(false);
+		task.setUsepkgpath(false);
+
+		// run task
+		task.execute();
+
+		// check results
+		File a = new File(mapDir, convertPath("Artist.java"));
+		assertTrue(a.exists());
+		assertContents(a, "Artist", "org.apache.cayenne.testdo.testmap", "CayenneDataObject");
+
+		File _a = new File(mapDir, convertPath("_Artist.java"));
+		assertFalse(_a.exists());
+
+		File pkga = new File(mapDir, convertPath("org/apache/cayenne/testdo/testmap/Artist.java"));
+		assertFalse(pkga.exists());
+	}
+
+	/**
+	 * Test pairs generation including full package path, default superclass
+	 * package.
+	 */
+	@Test
+	public void testPairs1() throws Exception {
+		// prepare destination directory
+		File mapDir = new File(baseDir, "pairs-tree");
+		assertTrue(mapDir.mkdirs());
+
+		// setup task
+		task.setDestDir(mapDir);
+		task.setMap(map);
+		task.setMakepairs(true);
+		task.setUsepkgpath(true);
+
+		// run task
+		task.execute();
+
+		// check results
+		File a = new File(mapDir, convertPath("org/apache/cayenne/testdo/testmap/Artist.java"));
+		assertTrue(a.isFile());
+		assertContents(a, "Artist", "org.apache.cayenne.testdo.testmap", "_Artist");
+
+		File _a = new File(mapDir, convertPath("org/apache/cayenne/testdo/testmap/auto/_Artist.java"));
+		assertTrue(_a.exists());
+		assertContents(_a, "_Artist", "org.apache.cayenne.testdo.testmap", "CayenneDataObject");
+	}
+
+	/** Test pairs generation in the same directory. */
+	@Test
+	public void testPairs2() throws Exception {
+		// prepare destination directory
+		File mapDir = new File(baseDir, "pairs-flat");
+		assertTrue(mapDir.mkdirs());
+
+		// setup task
+		task.setDestDir(mapDir);
+		task.setMap(map);
+		task.setMakepairs(true);
+		task.setUsepkgpath(false);
+
+		// run task
+		task.execute();
+
+		// check results
+		File a = new File(mapDir, convertPath("Artist.java"));
+		assertTrue(a.isFile());
+		assertContents(a, "Artist", "org.apache.cayenne.testdo.testmap", "_Artist");
+
+		File _a = new File(mapDir, convertPath("_Artist.java"));
+		assertTrue(_a.exists());
+		assertContents(_a, "_Artist", "org.apache.cayenne.testdo.testmap", "CayenneDataObject");
+
+		File pkga = new File(mapDir, convertPath("org/apache/cayenne/testdo/testmap/Artist.java"));
+		assertFalse(pkga.exists());
+	}
+
+	/**
+	 * Test pairs generation including full package path with superclass and
+	 * subclass in different packages.
+	 */
+	@Test
+	public void testPairs3() throws Exception {
+		// prepare destination directory
+		File mapDir = new File(baseDir, "pairs-tree-split");
+		assertTrue(mapDir.mkdirs());
+
+		// setup task
+		task.setDestDir(mapDir);
+		task.setMap(map);
+		task.setMakepairs(true);
+		task.setUsepkgpath(true);
+		task.setSuperpkg("org.apache.cayenne.testdo.testmap.superart");
+
+		// run task
+		task.execute();
+
+		// check results
+		File a = new File(mapDir, convertPath("org/apache/cayenne/testdo/testmap/Artist.java"));
+		assertTrue(a.isFile());
+		assertContents(a, "Artist", "org.apache.cayenne.testdo.testmap", "_Artist");
+
+		File _a = new File(mapDir, convertPath("org/apache/cayenne/testdo/testmap/superart/_Artist.java"));
+		assertTrue(_a.exists());
+		assertContents(_a, "_Artist", "org.apache.cayenne.testdo.testmap.superart", "CayenneDataObject");
+	}
+
+	@Test
+	public void testPairsEmbeddable3() throws Exception {
+		// prepare destination directory
+		File mapDir = new File(baseDir, "pairs-embeddables3-split");
+		assertTrue(mapDir.mkdirs());
+
+		// setup task
+		task.setDestDir(mapDir);
+		task.setMap(mapEmbeddables);
+		task.setMakepairs(true);
+		task.setUsepkgpath(true);
+		task.setSuperpkg("org.apache.cayenne.testdo.embeddable.auto");
+
+		// run task
+		task.execute();
+
+		// check entity results
+		File a = new File(mapDir, convertPath("org/apache/cayenne/testdo/embeddable/EmbedEntity1.java"));
+		assertTrue(a.isFile());
+		assertContents(a, "EmbedEntity1", "org.apache.cayenne.testdo.embeddable", "_EmbedEntity1");
+
+		File _a = new File(mapDir, convertPath("org/apache/cayenne/testdo/embeddable/auto/_EmbedEntity1.java"));
+		assertTrue(_a.exists());
+		assertContents(_a, "_EmbedEntity1", "org.apache.cayenne.testdo.embeddable.auto", "CayenneDataObject");
+
+		// check embeddable results
+		File e = new File(mapDir, convertPath("org/apache/cayenne/testdo/embeddable/Embeddable1.java"));
+		assertTrue(e.isFile());
+		assertContents(e, "Embeddable1", "org.apache.cayenne.testdo.embeddable", "_Embeddable1");
+
+		File _e = new File(mapDir, convertPath("org/apache/cayenne/testdo/embeddable/auto/_Embeddable1.java"));
+		assertTrue(_e.exists());
+		assertContents(_e, "_Embeddable1", "org.apache.cayenne.testdo.embeddable.auto", "Object");
+	}
+
+	private String convertPath(String unixPath) {
+		return unixPath.replace('/', File.separatorChar);
+	}
+
+	private void assertContents(File f, String className, String packageName, String extendsName) throws Exception {
+
+		try (BufferedReader in = new BufferedReader(new InputStreamReader(new FileInputStream(f)));) {
+			assertPackage(in, packageName);
+			assertClass(in, className, extendsName);
+		}
+	}
+
+	private void assertPackage(BufferedReader in, String packageName) throws Exception {
+
+		String s = null;
+		while ((s = in.readLine()) != null) {
+			if (Pattern.matches("^package\\s+([^\\s;]+);", s)) {
+				assertTrue(s.indexOf(packageName) > 0);
+				return;
+			}
+		}
+
+		fail("No package declaration found.");
+	}
+
+	private void assertClass(BufferedReader in, String className, String extendsName) throws Exception {
+
+		Pattern classPattern = Pattern.compile("^public\\s+");
+
+		String s = null;
+		while ((s = in.readLine()) != null) {
+			if (classPattern.matcher(s).find()) {
+				assertTrue(s.indexOf(className) > 0);
+				assertTrue(s.indexOf(extendsName) > 0);
+				assertTrue(s.indexOf(className) < s.indexOf(extendsName));
+				return;
+			}
+		}
+
+		fail("No class declaration found.");
+	}
+}

http://git-wip-us.apache.org/repos/asf/cayenne/blob/c63b6be2/cayenne-ant/src/test/java/org/apache/cayenne/tools/DbGeneratorTaskTest.java
----------------------------------------------------------------------
diff --git a/cayenne-ant/src/test/java/org/apache/cayenne/tools/DbGeneratorTaskTest.java b/cayenne-ant/src/test/java/org/apache/cayenne/tools/DbGeneratorTaskTest.java
new file mode 100644
index 0000000..bd02e12
--- /dev/null
+++ b/cayenne-ant/src/test/java/org/apache/cayenne/tools/DbGeneratorTaskTest.java
@@ -0,0 +1,75 @@
+/*****************************************************************
+ *   Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ ****************************************************************/
+
+package org.apache.cayenne.tools;
+
+import org.apache.cayenne.dba.AutoAdapter;
+import org.apache.cayenne.dba.DbAdapter;
+import org.apache.cayenne.dba.sqlserver.SQLServerAdapter;
+import org.apache.cayenne.dbsync.reverse.configuration.ToolsModule;
+import org.apache.cayenne.di.DIBootstrap;
+import org.apache.cayenne.di.Injector;
+import org.apache.commons.logging.Log;
+import org.junit.Test;
+
+import javax.sql.DataSource;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+import static org.mockito.Mockito.mock;
+
+public class DbGeneratorTaskTest {
+
+    @Test
+    public void testSetUserName() throws Exception {
+        DbGeneratorTask task = new DbGeneratorTask();
+        task.setUserName("abc");
+        assertEquals("abc", task.userName);
+    }
+
+    @Test
+    public void testSetPassword() throws Exception {
+        DbGeneratorTask task = new DbGeneratorTask();
+        task.setPassword("xyz");
+        assertEquals("xyz", task.password);
+    }
+
+    @Test
+    public void testSetAdapter() throws Exception {
+        DataSource ds = mock(DataSource.class);
+        Injector injector = DIBootstrap.createInjector(new ToolsModule(mock(Log.class)));
+
+        DbGeneratorTask task = new DbGeneratorTask();
+
+        DbAdapter autoAdapter = task.getAdapter(injector, ds);
+        assertTrue(autoAdapter instanceof AutoAdapter);
+
+        task.setAdapter(SQLServerAdapter.class.getName());
+
+        DbAdapter sqlServerAdapter = task.getAdapter(injector, ds);
+        assertTrue(sqlServerAdapter instanceof SQLServerAdapter);
+    }
+
+    @Test
+    public void testSetUrl() throws Exception {
+        DbGeneratorTask task = new DbGeneratorTask();
+        task.setUrl("jdbc:///");
+        assertEquals("jdbc:///", task.url);
+    }
+}

http://git-wip-us.apache.org/repos/asf/cayenne/blob/c63b6be2/cayenne-ant/src/test/java/org/apache/cayenne/tools/DbImporterTaskTest.java
----------------------------------------------------------------------
diff --git a/cayenne-ant/src/test/java/org/apache/cayenne/tools/DbImporterTaskTest.java b/cayenne-ant/src/test/java/org/apache/cayenne/tools/DbImporterTaskTest.java
new file mode 100644
index 0000000..df746c2
--- /dev/null
+++ b/cayenne-ant/src/test/java/org/apache/cayenne/tools/DbImporterTaskTest.java
@@ -0,0 +1,229 @@
+/*****************************************************************
+ *   Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ ****************************************************************/
+package org.apache.cayenne.tools;
+
+import org.apache.cayenne.dbsync.reverse.dbimport.DbImportConfiguration;
+import org.apache.cayenne.test.file.FileUtil;
+import org.apache.cayenne.test.jdbc.SQLReader;
+import org.apache.cayenne.test.resource.ResourceUtil;
+import org.apache.tools.ant.Project;
+import org.apache.tools.ant.ProjectHelper;
+import org.apache.tools.ant.UnknownElement;
+import org.apache.tools.ant.util.FileUtils;
+import org.custommonkey.xmlunit.DetailedDiff;
+import org.custommonkey.xmlunit.Diff;
+import org.custommonkey.xmlunit.Difference;
+import org.custommonkey.xmlunit.XMLUnit;
+import org.junit.Test;
+import org.xml.sax.SAXException;
+
+import java.io.File;
+import java.io.FileReader;
+import java.io.IOException;
+import java.net.URL;
+import java.sql.Connection;
+import java.sql.DriverManager;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.sql.Statement;
+import java.util.List;
+
+import static org.apache.cayenne.dbsync.reverse.dbimport.ReverseEngineeringUtils.*;
+import static org.apache.commons.lang.StringUtils.isBlank;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
+// TODO: we are only testing on Derby. We may need to dynamically switch between DBs 
+// based on "cayenneTestConnection", like we do in cayenne-server, etc.
+public class DbImporterTaskTest {
+
+    static {
+        XMLUnit.setIgnoreWhitespace(true);
+    }
+
+    private static File distDir(String name) {
+        File distDir = new File(FileUtil.baseTestDirectory(), "cdbImport");
+        File file = new File(distDir, name);
+        distDir = file.getParentFile();
+        // prepare destination directory
+        if (!distDir.exists()) {
+            assertTrue(distDir.mkdirs());
+        }
+        return file;
+    }
+
+    @Test
+    public void testLoadCatalog() throws Exception {
+        assertCatalog(getCdbImport("build-catalog.xml").getReverseEngineering());
+    }
+
+    @Test
+    public void testLoadSchema() throws Exception {
+        assertSchema(getCdbImport("build-schema.xml").getReverseEngineering());
+    }
+
+    @Test
+    public void testLoadCatalogAndSchema() throws Exception {
+        assertCatalogAndSchema(getCdbImport("build-catalog-and-schema.xml").getReverseEngineering());
+    }
+
+    @Test
+    public void testLoadFlat() throws Exception {
+        assertFlat(getCdbImport("build-flat.xml").getReverseEngineering());
+    }
+
+    @Test
+    public void testSkipRelationshipsLoading() throws Exception {
+        assertSkipRelationshipsLoading(getCdbImport("build-skip-relationships-loading.xml").getReverseEngineering());
+    }
+
+    @Test
+    public void testTableTypes() throws Exception {
+        assertTableTypes(getCdbImport("build-table-types.xml").getReverseEngineering());
+    }
+
+    @Test
+    public void testIncludeTable() throws Exception {
+        test("build-include-table.xml");
+    }
+
+    private DbImporterTask getCdbImport(String buildFile) {
+        Project project = new Project();
+
+        File map = distDir(buildFile);
+        ResourceUtil.copyResourceToFile(getPackagePath() + "/" + buildFile, map);
+        ProjectHelper.configureProject(project, map);
+
+        UnknownElement task = (UnknownElement) project.getTargets().get("dist").getTasks()[0];
+        task.maybeConfigure();
+
+        return (DbImporterTask) task.getRealThing();
+    }
+
+    private String getPackagePath() {
+        return getClass().getPackage().getName().replace('.', '/');
+    }
+
+    private void test(String name) throws Exception {
+        DbImporterTask cdbImport = getCdbImport(name);
+        File mapFile = cdbImport.getMap();
+
+        URL mapUrlRes = this.getClass().getResource(mapFile.getName() + "-result");
+        assertTrue(mapUrlRes != null && new File(mapUrlRes.toURI()).exists());
+        assertTrue(ResourceUtil
+                .copyResourceToFile(mapUrlRes, new File(mapFile.getParentFile(), mapFile.getName() + "-result")));
+
+
+        File mapFileCopy = distDir("copy-" + mapFile.getName());
+        if (mapFile.exists()) {
+            FileUtils.getFileUtils().copyFile(mapFile, mapFileCopy);
+            cdbImport.setMap(mapFileCopy);
+        } else {
+            mapFileCopy = mapFile;
+        }
+
+        prepareDatabase(name, cdbImport.toParameters());
+
+        try {
+            cdbImport.execute();
+            verifyResult(mapFile, mapFileCopy);
+        } finally {
+            cleanDb(cdbImport.toParameters());
+        }
+    }
+
+    private void cleanDb(DbImportConfiguration dbImportConfiguration) throws ClassNotFoundException,
+            IllegalAccessException, InstantiationException, SQLException {
+        Class.forName(dbImportConfiguration.getDriver()).newInstance();
+        // Get a connection
+        Connection connection = DriverManager.getConnection(dbImportConfiguration.getUrl());
+        Statement stmt = connection.createStatement();
+
+        ResultSet tables = connection.getMetaData().getTables(null, null, null, new String[]{"TABLE"});
+        while (tables.next()) {
+            String schema = tables.getString("TABLE_SCHEM");
+            System.out.println("DROP TABLE " + (isBlank(schema) ? "" : schema + ".") + tables.getString("TABLE_NAME"));
+            stmt.execute("DROP TABLE " + (isBlank(schema) ? "" : schema + ".") + tables.getString("TABLE_NAME"));
+        }
+
+        ResultSet schemas = connection.getMetaData().getSchemas();
+        while (schemas.next()) {
+            String schem = schemas.getString("TABLE_SCHEM");
+            if (schem.startsWith("SCHEMA")) {
+                System.out.println("DROP SCHEMA " + schem);
+                stmt.execute("DROP SCHEMA " + schem + " RESTRICT");
+            }
+        }
+    }
+
+    @SuppressWarnings("unchecked")
+    private void verifyResult(File map, File mapFileCopy) {
+        try {
+            FileReader control = new FileReader(map.getAbsolutePath() + "-result");
+            FileReader test = new FileReader(mapFileCopy);
+
+            DetailedDiff diff = new DetailedDiff(new Diff(control, test));
+            if (!diff.similar()) {
+                for (Difference d : ((List<Difference>) diff.getAllDifferences())) {
+
+                    System.out.println("-------------------------------------------");
+                    System.out.println(d.getTestNodeDetail().getNode());
+                    System.out.println(d.getControlNodeDetail().getValue());
+                }
+                fail(diff.toString());
+            }
+
+        } catch (SAXException e) {
+            e.printStackTrace();
+            fail();
+        } catch (IOException e) {
+            e.printStackTrace();
+            fail();
+        }
+    }
+
+    private void prepareDatabase(String sqlFile, DbImportConfiguration dbImportConfiguration) throws Exception {
+
+        URL sqlUrl = ResourceUtil.getResource(getClass(), sqlFile + ".sql");
+        assertNotNull(sqlUrl);
+
+        Class.forName(dbImportConfiguration.getDriver()).newInstance();
+
+        try (Connection c = DriverManager.getConnection(dbImportConfiguration.getUrl());) {
+
+            // TODO: move parsing SQL files to a common utility (DBHelper?) .
+            // ALso see UnitDbApater.executeDDL - this should use the same
+            // utility
+
+            try (Statement stmt = c.createStatement();) {
+                for (String sql : SQLReader.statements(sqlUrl, ";")) {
+
+                    // skip comments
+                    if (sql.startsWith("-- ")) {
+                        continue;
+                    }
+
+                    stmt.execute(sql);
+                }
+            }
+        }
+    }
+
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/cayenne/blob/c63b6be2/cayenne-ant/src/test/resources/embeddable.map.xml
----------------------------------------------------------------------
diff --git a/cayenne-ant/src/test/resources/embeddable.map.xml b/cayenne-ant/src/test/resources/embeddable.map.xml
new file mode 100644
index 0000000..0b5c0b8
--- /dev/null
+++ b/cayenne-ant/src/test/resources/embeddable.map.xml
@@ -0,0 +1,27 @@
+<?xml version="1.0" encoding="utf-8"?>
+<data-map xmlns="http://cayenne.apache.org/schema/3.0/modelMap"
+	 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+	 xsi:schemaLocation="http://cayenne.apache.org/schema/3.0/modelMap http://cayenne.apache.org/schema/3.0/modelMap.xsd"
+	 project-version="6">
+	<property name="defaultPackage" value="org.apache.cayenne.testdo.embeddable"/>
+	<embeddable className="org.apache.cayenne.testdo.embeddable.Embeddable1">
+		<embeddable-attribute name="embedded10" type="java.lang.String" db-attribute-name="EMBEDDED10"/>
+		<embeddable-attribute name="embedded20" type="java.lang.String" db-attribute-name="EMBEDDED20"/>
+	</embeddable>
+	<db-entity name="EMBED_ENTITY1">
+		<db-attribute name="EMBEDDED10" type="VARCHAR" length="100"/>
+		<db-attribute name="EMBEDDED20" type="VARCHAR" length="100"/>
+		<db-attribute name="EMBEDDED30" type="VARCHAR" length="100"/>
+		<db-attribute name="EMBEDDED40" type="VARCHAR" length="100"/>
+		<db-attribute name="ID" type="INTEGER" isPrimaryKey="true" isMandatory="true"/>
+		<db-attribute name="NAME" type="VARCHAR" length="100"/>
+	</db-entity>
+	<obj-entity name="EmbedEntity1" className="org.apache.cayenne.testdo.embeddable.EmbedEntity1" dbEntityName="EMBED_ENTITY1">
+		<embedded-attribute name="embedded1" type="org.apache.cayenne.testdo.embeddable.Embeddable1"/>
+		<embedded-attribute name="embedded2" type="org.apache.cayenne.testdo.embeddable.Embeddable1">
+			<embeddable-attribute-override name="embedded10" db-attribute-path="EMBEDDED30"/>
+			<embeddable-attribute-override name="embedded20" db-attribute-path="EMBEDDED40"/>
+		</embedded-attribute>
+		<obj-attribute name="name" type="java.lang.String" db-attribute-path="NAME"/>
+	</obj-entity>
+</data-map>

http://git-wip-us.apache.org/repos/asf/cayenne/blob/c63b6be2/cayenne-ant/src/test/resources/org/apache/cayenne/tools/build-catalog-and-schema.xml
----------------------------------------------------------------------
diff --git a/cayenne-ant/src/test/resources/org/apache/cayenne/tools/build-catalog-and-schema.xml b/cayenne-ant/src/test/resources/org/apache/cayenne/tools/build-catalog-and-schema.xml
new file mode 100644
index 0000000..ee44b9c
--- /dev/null
+++ b/cayenne-ant/src/test/resources/org/apache/cayenne/tools/build-catalog-and-schema.xml
@@ -0,0 +1,78 @@
+<!--
+  ~ Licensed to the Apache Software Foundation (ASF) under one
+  ~    or more contributor license agreements.  See the NOTICE file
+  ~    distributed with this work for additional information
+  ~    regarding copyright ownership.  The ASF licenses this file
+  ~    to you under the Apache License, Version 2.0 (the
+  ~    "License"); you may not use this file except in compliance
+  ~    with the License.  You may obtain a copy of the License at
+  ~
+  ~      http://www.apache.org/licenses/LICENSE-2.0
+  ~
+  ~    Unless required by applicable law or agreed to in writing,
+  ~    software distributed under the License is distributed on an
+  ~    "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+  ~    KIND, either express or implied.  See the License for the
+  ~    specific language governing permissions and limitations
+  ~    under the License.
+  -->
+
+<project name="MyProject" default="dist" basedir=".">
+
+    <taskdef name="cdbimport" classname="org.apache.cayenne.tools.DbImporterTask" taskname="cdbimport"
+             classpath="${basedir}"/>
+
+    <target name="dist">
+        <cdbimport map="${context.dir}/WEB-INF/DefaultMap.map.xml"
+                   adapter="org.apache.cayenne.dba.hsqldb.HSQLDBAdapter"
+                   driver="org.hsqldb.jdbcDriver"
+                   url="jdbc:hsqldb:hsql://localhost/bookmarker"
+                   username="sa">
+
+            <catalog name="catalog-name">
+                <schema name="schema-name">
+                    <includeTable>includeTable-01</includeTable>
+
+                    <includeTable>
+                        <pattern>includeTable-02</pattern>
+                    </includeTable>
+
+                    <includeTable pattern="includeTable-03">
+                        <includeColumn pattern="includeColumn-01"/>
+                        <excludeColumn pattern="excludeColumn-01"/>
+                    </includeTable>
+
+                    <excludeTable>excludeTable-01</excludeTable>
+                    <excludeTable>
+                        <pattern>excludeTable-02</pattern>
+                    </excludeTable>
+                    <excludeTable pattern="excludeTable-03"/>
+
+                    <includeColumn>includeColumn-01</includeColumn>
+                    <includeColumn>
+                        <pattern>includeColumn-02</pattern>
+                    </includeColumn>
+                    <includeColumn pattern="includeColumn-03"/>
+                    <excludeColumn>excludeColumn-01</excludeColumn>
+                    <excludeColumn>
+                        <pattern>excludeColumn-02</pattern>
+                    </excludeColumn>
+                    <excludeColumn pattern="excludeColumn-03"/>
+
+                    <includeProcedure>includeProcedure-01</includeProcedure>
+                    <includeProcedure>
+                        <pattern>includeProcedure-02</pattern>
+                    </includeProcedure>
+                    <includeProcedure pattern="includeProcedure-03"/>
+                    <excludeProcedure>excludeProcedure-01</excludeProcedure>
+                    <excludeProcedure>
+                        <pattern>excludeProcedure-02</pattern>
+                    </excludeProcedure>
+                    <excludeProcedure pattern="excludeProcedure-03"/>
+                </schema>
+            </catalog>
+        </cdbimport>
+    </target>
+
+
+</project>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/cayenne/blob/c63b6be2/cayenne-ant/src/test/resources/org/apache/cayenne/tools/build-catalog.xml
----------------------------------------------------------------------
diff --git a/cayenne-ant/src/test/resources/org/apache/cayenne/tools/build-catalog.xml b/cayenne-ant/src/test/resources/org/apache/cayenne/tools/build-catalog.xml
new file mode 100644
index 0000000..fa1781b
--- /dev/null
+++ b/cayenne-ant/src/test/resources/org/apache/cayenne/tools/build-catalog.xml
@@ -0,0 +1,82 @@
+<!--
+  ~ Licensed to the Apache Software Foundation (ASF) under one
+  ~    or more contributor license agreements.  See the NOTICE file
+  ~    distributed with this work for additional information
+  ~    regarding copyright ownership.  The ASF licenses this file
+  ~    to you under the Apache License, Version 2.0 (the
+  ~    "License"); you may not use this file except in compliance
+  ~    with the License.  You may obtain a copy of the License at
+  ~
+  ~      http://www.apache.org/licenses/LICENSE-2.0
+  ~
+  ~    Unless required by applicable law or agreed to in writing,
+  ~    software distributed under the License is distributed on an
+  ~    "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+  ~    KIND, either express or implied.  See the License for the
+  ~    specific language governing permissions and limitations
+  ~    under the License.
+  -->
+
+<project name="MyProject" default="dist" basedir=".">
+
+    <taskdef name="cdbimport" classname="org.apache.cayenne.tools.DbImporterTask" taskname="cdbimport"
+             classpath="${basedir}"/>
+
+    <target name="dist">
+        <cdbimport map="${context.dir}/WEB-INF/DefaultMap.map.xml"
+                   adapter="org.apache.cayenne.dba.hsqldb.HSQLDBAdapter"
+                   driver="org.hsqldb.jdbcDriver"
+                   url="jdbc:hsqldb:hsql://localhost/bookmarker"
+                   username="sa">
+
+            <catalog>catalog-name-01</catalog>
+
+            <catalog>
+                <name>catalog-name-02</name>
+            </catalog>
+
+            <catalog name="catalog-name-03">
+                <includeTable>includeTable-01</includeTable>
+
+                <includeTable>
+                    <pattern>includeTable-02</pattern>
+                </includeTable>
+
+                <includeTable pattern="includeTable-03">
+                    <includeColumn pattern="includeColumn-01"/>
+                    <excludeColumn pattern="excludeColumn-01"/>
+                </includeTable>
+
+                <excludeTable>excludeTable-01</excludeTable>
+                <excludeTable>
+                    <pattern>excludeTable-02</pattern>
+                </excludeTable>
+                <excludeTable pattern="excludeTable-03"/>
+
+                <includeColumn>includeColumn-01</includeColumn>
+                <includeColumn>
+                    <pattern>includeColumn-02</pattern>
+                </includeColumn>
+                <includeColumn pattern="includeColumn-03"/>
+                <excludeColumn>excludeColumn-01</excludeColumn>
+                <excludeColumn>
+                    <pattern>excludeColumn-02</pattern>
+                </excludeColumn>
+                <excludeColumn pattern="excludeColumn-03"/>
+
+                <includeProcedure>includeProcedure-01</includeProcedure>
+                <includeProcedure>
+                    <pattern>includeProcedure-02</pattern>
+                </includeProcedure>
+                <includeProcedure pattern="includeProcedure-03"/>
+                <excludeProcedure>excludeProcedure-01</excludeProcedure>
+                <excludeProcedure>
+                    <pattern>excludeProcedure-02</pattern>
+                </excludeProcedure>
+                <excludeProcedure pattern="excludeProcedure-03"/>
+            </catalog>
+        </cdbimport>
+    </target>
+
+
+</project>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/cayenne/blob/c63b6be2/cayenne-ant/src/test/resources/org/apache/cayenne/tools/build-flat.xml
----------------------------------------------------------------------
diff --git a/cayenne-ant/src/test/resources/org/apache/cayenne/tools/build-flat.xml b/cayenne-ant/src/test/resources/org/apache/cayenne/tools/build-flat.xml
new file mode 100644
index 0000000..286bcf3
--- /dev/null
+++ b/cayenne-ant/src/test/resources/org/apache/cayenne/tools/build-flat.xml
@@ -0,0 +1,73 @@
+<!--
+  ~ Licensed to the Apache Software Foundation (ASF) under one
+  ~    or more contributor license agreements.  See the NOTICE file
+  ~    distributed with this work for additional information
+  ~    regarding copyright ownership.  The ASF licenses this file
+  ~    to you under the Apache License, Version 2.0 (the
+  ~    "License"); you may not use this file except in compliance
+  ~    with the License.  You may obtain a copy of the License at
+  ~
+  ~      http://www.apache.org/licenses/LICENSE-2.0
+  ~
+  ~    Unless required by applicable law or agreed to in writing,
+  ~    software distributed under the License is distributed on an
+  ~    "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+  ~    KIND, either express or implied.  See the License for the
+  ~    specific language governing permissions and limitations
+  ~    under the License.
+  -->
+
+<project name="MyProject" default="dist" basedir=".">
+
+    <taskdef name="cdbimport" classname="org.apache.cayenne.tools.DbImporterTask" taskname="cdbimport"
+             classpath="${basedir}"/>
+
+    <target name="dist">
+        <cdbimport map="${context.dir}/WEB-INF/DefaultMap.map.xml"
+                   adapter="org.apache.cayenne.dba.hsqldb.HSQLDBAdapter"
+                   driver="org.hsqldb.jdbcDriver"
+                   url="jdbc:hsqldb:hsql://localhost/bookmarker"
+                   username="sa">
+            <includeTable>includeTable-01</includeTable>
+
+            <includeTable>
+                <pattern>includeTable-02</pattern>
+            </includeTable>
+
+            <includeTable pattern="includeTable-03">
+                <includeColumn pattern="includeColumn-01"/>
+                <excludeColumn pattern="excludeColumn-01"/>
+            </includeTable>
+
+            <excludeTable>excludeTable-01</excludeTable>
+            <excludeTable>
+                <pattern>excludeTable-02</pattern>
+            </excludeTable>
+            <excludeTable pattern="excludeTable-03"/>
+
+            <includeColumn>includeColumn-01</includeColumn>
+            <includeColumn>
+                <pattern>includeColumn-02</pattern>
+            </includeColumn>
+            <includeColumn pattern="includeColumn-03"/>
+            <excludeColumn>excludeColumn-01</excludeColumn>
+            <excludeColumn>
+                <pattern>excludeColumn-02</pattern>
+            </excludeColumn>
+            <excludeColumn pattern="excludeColumn-03"/>
+
+            <includeProcedure>includeProcedure-01</includeProcedure>
+            <includeProcedure>
+                <pattern>includeProcedure-02</pattern>
+            </includeProcedure>
+            <includeProcedure pattern="includeProcedure-03"/>
+            <excludeProcedure>excludeProcedure-01</excludeProcedure>
+            <excludeProcedure>
+                <pattern>excludeProcedure-02</pattern>
+            </excludeProcedure>
+            <excludeProcedure pattern="excludeProcedure-03"/>
+        </cdbimport>
+    </target>
+
+
+</project>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/cayenne/blob/c63b6be2/cayenne-ant/src/test/resources/org/apache/cayenne/tools/build-include-table.map.xml-result
----------------------------------------------------------------------
diff --git a/cayenne-ant/src/test/resources/org/apache/cayenne/tools/build-include-table.map.xml-result b/cayenne-ant/src/test/resources/org/apache/cayenne/tools/build-include-table.map.xml-result
new file mode 100644
index 0000000..5c0d2b6
--- /dev/null
+++ b/cayenne-ant/src/test/resources/org/apache/cayenne/tools/build-include-table.map.xml-result
@@ -0,0 +1,37 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+	Licensed to the Apache Software Foundation (ASF) under one
+	or more contributor license agreements.  See the NOTICE file
+	distributed with this work for additional information
+	regarding copyright ownership.  The ASF licenses this file
+	to you under the Apache License, Version 2.0 (the
+	"License"); you may not use this file except in compliance
+	with the License.  You may obtain a copy of the License at
+
+	http://www.apache.org/licenses/LICENSE-2.0
+
+	Unless required by applicable law or agreed to in writing,
+	software distributed under the License is distributed on an
+	"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+	KIND, either express or implied.  See the License for the
+	specific language governing permissions and limitations
+	under the License.
+-->
+<data-map xmlns="http://cayenne.apache.org/schema/9/modelMap"
+          xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+          xsi:schemaLocation="http://cayenne.apache.org/schema/9/modelMap http://cayenne.apache.org/schema/9/modelMap.xsd"
+          project-version="9">
+    <db-entity name="PARENT" schema="APP">
+        <db-attribute name="COL2" type="CHAR" length="25"/>
+        <db-attribute name="COL3" type="DECIMAL" length="10" scale="2"/>
+        <db-attribute name="COL4" type="VARCHAR" length="25"/>
+        <db-attribute name="COL5" type="DATE" length="10"/>
+        <db-attribute name="ID" type="INTEGER" isPrimaryKey="true" isMandatory="true" length="10"/>
+    </db-entity>
+    <obj-entity name="Parent" className="Parent" dbEntityName="PARENT">
+        <obj-attribute name="col2" type="java.lang.String" db-attribute-path="COL2"/>
+        <obj-attribute name="col3" type="java.math.BigDecimal" db-attribute-path="COL3"/>
+        <obj-attribute name="col4" type="java.lang.String" db-attribute-path="COL4"/>
+        <obj-attribute name="col5" type="java.util.Date" db-attribute-path="COL5"/>
+    </obj-entity>
+</data-map>

http://git-wip-us.apache.org/repos/asf/cayenne/blob/c63b6be2/cayenne-ant/src/test/resources/org/apache/cayenne/tools/build-include-table.xml
----------------------------------------------------------------------
diff --git a/cayenne-ant/src/test/resources/org/apache/cayenne/tools/build-include-table.xml b/cayenne-ant/src/test/resources/org/apache/cayenne/tools/build-include-table.xml
new file mode 100644
index 0000000..befa01b
--- /dev/null
+++ b/cayenne-ant/src/test/resources/org/apache/cayenne/tools/build-include-table.xml
@@ -0,0 +1,34 @@
+<!--
+  ~ Licensed to the Apache Software Foundation (ASF) under one
+  ~    or more contributor license agreements.  See the NOTICE file
+  ~    distributed with this work for additional information
+  ~    regarding copyright ownership.  The ASF licenses this file
+  ~    to you under the Apache License, Version 2.0 (the
+  ~    "License"); you may not use this file except in compliance
+  ~    with the License.  You may obtain a copy of the License at
+  ~
+  ~      http://www.apache.org/licenses/LICENSE-2.0
+  ~
+  ~    Unless required by applicable law or agreed to in writing,
+  ~    software distributed under the License is distributed on an
+  ~    "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+  ~    KIND, either express or implied.  See the License for the
+  ~    specific language governing permissions and limitations
+  ~    under the License.
+  -->
+
+<project name="MyProject" default="dist" basedir="../">
+
+    <taskdef name="cdbimport" classname="org.apache.cayenne.tools.DbImporterTask" taskname="cdbimport"
+             classpath="${basedir}"/>
+
+    <target name="dist">
+        <cdbimport map="build-include-table.map.xml"
+                   driver="org.apache.derby.jdbc.EmbeddedDriver"
+                   url="jdbc:derby:memory:DbImporterMojoTest;create=true">
+            <includeTable>Parent</includeTable>
+        </cdbimport>
+    </target>
+
+
+</project>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/cayenne/blob/c63b6be2/cayenne-ant/src/test/resources/org/apache/cayenne/tools/build-include-table.xml.sql
----------------------------------------------------------------------
diff --git a/cayenne-ant/src/test/resources/org/apache/cayenne/tools/build-include-table.xml.sql b/cayenne-ant/src/test/resources/org/apache/cayenne/tools/build-include-table.xml.sql
new file mode 100644
index 0000000..e392d08
--- /dev/null
+++ b/cayenne-ant/src/test/resources/org/apache/cayenne/tools/build-include-table.xml.sql
@@ -0,0 +1,38 @@
+--  Licensed to the Apache Software Foundation (ASF) under one
+--  or more contributor license agreements.  See the NOTICE file
+--  distributed with this work for additional information
+-- regarding copyright ownership.  The ASF licenses this file
+--  to you under the Apache License, Version 2.0 (the
+--  "License"); you may not use this file except in compliance
+--  with the License.  You may obtain a copy of the License at
+--
+--    http://www.apache.org/licenses/LICENSE-2.0
+--
+--  Unless required by applicable law or agreed to in writing,
+--  software distributed under the License is distributed on an
+--  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+--  KIND, either express or implied.  See the License for the
+--  specific language governing permissions and limitations
+--  under the License.
+ 
+
+CREATE TABLE Parent (
+  id INTEGER NOT NULL,
+  COL2 CHAR(25),
+  COL3 DECIMAL(10,2),
+  COL4 VARCHAR(25),
+  COL5 DATE,
+
+  PRIMARY KEY (id),
+  UNIQUE (COL3)
+);
+
+CREATE TABLE Child (
+  id INTEGER NOT NULL,
+  Parent_id CHAR(25),
+  COL3 DECIMAL(10,2),
+  COL4 VARCHAR(25),
+  COL5 DATE,
+
+  PRIMARY KEY (id)
+);
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/cayenne/blob/c63b6be2/cayenne-ant/src/test/resources/org/apache/cayenne/tools/build-mapping.xml
----------------------------------------------------------------------
diff --git a/cayenne-ant/src/test/resources/org/apache/cayenne/tools/build-mapping.xml b/cayenne-ant/src/test/resources/org/apache/cayenne/tools/build-mapping.xml
new file mode 100644
index 0000000..b6ab93e
--- /dev/null
+++ b/cayenne-ant/src/test/resources/org/apache/cayenne/tools/build-mapping.xml
@@ -0,0 +1,44 @@
+<!--
+  Licensed to the Apache Software Foundation (ASF) under one
+  or more contributor license agreements.  See the NOTICE file
+  distributed with this work for additional information
+  regarding copyright ownership.  The ASF licenses this file
+  to you under the Apache License, Version 2.0 (the
+  "License"); you may not use this file except in compliance
+  with the License.  You may obtain a copy of the License at
+
+  http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing,
+  software distributed under the License is distributed on an
+  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+  KIND, either express or implied.  See the License for the
+  specific language governing permissions and limitations
+  under the License.
+  -->
+
+<project name="MyProject" default="dist" basedir=".">
+
+    <taskdef name="cdbimport" classname="org.apache.cayenne.tools.DbImporterTask" taskname="cdbimport"
+             classpath="${basedir}"/>
+
+    <target name="dist">
+        <cdbimport map="${context.dir}/WEB-INF/DefaultMap.map.xml"
+                   adapter="org.apache.cayenne.dba.hsqldb.HSQLDBAdapter"
+                   driver="org.hsqldb.jdbcDriver"
+                   url="jdbc:hsqldb:hsql://localhost/bookmarker"
+                   username="sa">
+
+            <typeMapper mapperClassName="class" usePrimitives="false">
+                <type java="my.personal.type" jdbc="varchar"/>
+                <type java="java-01" jdbc="jdbc-01"/>
+                <type java="java-02" jdbc="jdbc-02" length="21" notNull="true"/>
+                <type java="java-03" jdbc="jdbc-03" precision="5" scale="2"/>
+                <type java="java-03" jdbc="jdbc-03" precision="7" notNull="true"/>
+            </typeMapper>
+
+        </cdbimport>
+    </target>
+
+
+</project>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/cayenne/blob/c63b6be2/cayenne-ant/src/test/resources/org/apache/cayenne/tools/build-reverse-engineering-in-external-file.xml
----------------------------------------------------------------------
diff --git a/cayenne-ant/src/test/resources/org/apache/cayenne/tools/build-reverse-engineering-in-external-file.xml b/cayenne-ant/src/test/resources/org/apache/cayenne/tools/build-reverse-engineering-in-external-file.xml
new file mode 100644
index 0000000..8cd89e8
--- /dev/null
+++ b/cayenne-ant/src/test/resources/org/apache/cayenne/tools/build-reverse-engineering-in-external-file.xml
@@ -0,0 +1,33 @@
+<!--
+  Licensed to the Apache Software Foundation (ASF) under one
+  or more contributor license agreements.  See the NOTICE file
+  distributed with this work for additional information
+  regarding copyright ownership.  The ASF licenses this file
+  to you under the Apache License, Version 2.0 (the
+  "License"); you may not use this file except in compliance
+  with the License.  You may obtain a copy of the License at
+
+  http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing,
+  software distributed under the License is distributed on an
+  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+  KIND, either express or implied.  See the License for the
+  specific language governing permissions and limitations
+  under the License.
+  -->
+
+<project name="MyProject" default="dist" basedir=".">
+
+    <taskdef name="cdbimport" classname="org.apache.cayenne.tools.DbImporterTask" taskname="cdbimport"
+             classpath="${basedir}"  />
+
+    <target name="dist">
+        <cdbimport map="dbimport/build-include-table.map.xml"
+                   driver="org.apache.derby.jdbc.EmbeddedDriver"
+                   url="jdbc:derby:memory:DbImporterMojoTest;create=true"
+                   reverseEngineeringFile="dbimport/config/reverseEngineering-catalog-and-schema.xml" />
+    </target>
+
+
+</project>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/cayenne/blob/c63b6be2/cayenne-ant/src/test/resources/org/apache/cayenne/tools/build-schema.xml
----------------------------------------------------------------------
diff --git a/cayenne-ant/src/test/resources/org/apache/cayenne/tools/build-schema.xml b/cayenne-ant/src/test/resources/org/apache/cayenne/tools/build-schema.xml
new file mode 100644
index 0000000..911af23
--- /dev/null
+++ b/cayenne-ant/src/test/resources/org/apache/cayenne/tools/build-schema.xml
@@ -0,0 +1,83 @@
+<!--
+  ~ Licensed to the Apache Software Foundation (ASF) under one
+  ~    or more contributor license agreements.  See the NOTICE file
+  ~    distributed with this work for additional information
+  ~    regarding copyright ownership.  The ASF licenses this file
+  ~    to you under the Apache License, Version 2.0 (the
+  ~    "License"); you may not use this file except in compliance
+  ~    with the License.  You may obtain a copy of the License at
+  ~
+  ~      http://www.apache.org/licenses/LICENSE-2.0
+  ~
+  ~    Unless required by applicable law or agreed to in writing,
+  ~    software distributed under the License is distributed on an
+  ~    "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+  ~    KIND, either express or implied.  See the License for the
+  ~    specific language governing permissions and limitations
+  ~    under the License.
+  -->
+
+<project name="MyProject" default="dist" basedir=".">
+
+    <taskdef name="cdbimport" classname="org.apache.cayenne.tools.DbImporterTask" taskname="cdbimport"
+             classpath="${basedir}"/>
+
+    <target name="dist">
+        <cdbimport map="${context.dir}/WEB-INF/DefaultMap.map.xml"
+                   adapter="org.apache.cayenne.dba.hsqldb.HSQLDBAdapter"
+                   driver="org.hsqldb.jdbcDriver"
+                   url="jdbc:hsqldb:hsql://localhost/bookmarker"
+                   username="sa">
+
+                <schema>schema-name-01</schema>
+
+                <schema>
+                    <name>schema-name-02</name>
+                </schema>
+
+                <schema name="schema-name-03">
+                    <includeTable>includeTable-01</includeTable>
+
+                    <includeTable>
+                        <pattern>includeTable-02</pattern>
+                    </includeTable>
+
+                    <includeTable pattern="includeTable-03">
+                        <includeColumn pattern="includeColumn-01"/>
+                        <excludeColumn pattern="excludeColumn-01"/>
+                    </includeTable>
+
+                    <excludeTable>excludeTable-01</excludeTable>
+                    <excludeTable>
+                        <pattern>excludeTable-02</pattern>
+                    </excludeTable>
+                    <excludeTable pattern="excludeTable-03"/>
+
+                    <includeColumn>includeColumn-01</includeColumn>
+                    <includeColumn>
+                        <pattern>includeColumn-02</pattern>
+                    </includeColumn>
+                    <includeColumn pattern="includeColumn-03"/>
+                    <excludeColumn>excludeColumn-01</excludeColumn>
+                    <excludeColumn>
+                        <pattern>excludeColumn-02</pattern>
+                    </excludeColumn>
+                    <excludeColumn pattern="excludeColumn-03"/>
+
+                    <includeProcedure>includeProcedure-01</includeProcedure>
+                    <includeProcedure>
+                        <pattern>includeProcedure-02</pattern>
+                    </includeProcedure>
+                    <includeProcedure pattern="includeProcedure-03"/>
+                    <excludeProcedure>excludeProcedure-01</excludeProcedure>
+                    <excludeProcedure>
+                        <pattern>excludeProcedure-02</pattern>
+                    </excludeProcedure>
+                    <excludeProcedure pattern="excludeProcedure-03"/>
+                </schema>
+
+        </cdbimport>
+    </target>
+
+
+</project>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/cayenne/blob/c63b6be2/cayenne-ant/src/test/resources/org/apache/cayenne/tools/build-skip-primary-key-loading.xml
----------------------------------------------------------------------
diff --git a/cayenne-ant/src/test/resources/org/apache/cayenne/tools/build-skip-primary-key-loading.xml b/cayenne-ant/src/test/resources/org/apache/cayenne/tools/build-skip-primary-key-loading.xml
new file mode 100644
index 0000000..396b603
--- /dev/null
+++ b/cayenne-ant/src/test/resources/org/apache/cayenne/tools/build-skip-primary-key-loading.xml
@@ -0,0 +1,35 @@
+<!--
+  Licensed to the Apache Software Foundation (ASF) under one
+  or more contributor license agreements.  See the NOTICE file
+  distributed with this work for additional information
+  regarding copyright ownership.  The ASF licenses this file
+  to you under the Apache License, Version 2.0 (the
+  "License"); you may not use this file except in compliance
+  with the License.  You may obtain a copy of the License at
+
+  http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing,
+  software distributed under the License is distributed on an
+  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+  KIND, either express or implied.  See the License for the
+  specific language governing permissions and limitations
+  under the License.
+  -->
+
+<project name="MyProject" default="dist" basedir=".">
+
+    <taskdef name="cdbimport" classname="org.apache.cayenne.tools.DbImporterTask" taskname="cdbimport"
+             classpath="${basedir}"/>
+
+    <target name="dist">
+        <cdbimport map="${context.dir}/WEB-INF/DefaultMap.map.xml"
+                   adapter="org.apache.cayenne.dba.hsqldb.HSQLDBAdapter"
+                   driver="org.hsqldb.jdbcDriver"
+                   url="jdbc:hsqldb:hsql://localhost/bookmarker"
+                   username="sa" skipPrimaryKeyLoading="true">
+        </cdbimport>
+    </target>
+
+
+</project>

http://git-wip-us.apache.org/repos/asf/cayenne/blob/c63b6be2/cayenne-ant/src/test/resources/org/apache/cayenne/tools/build-skip-relationships-loading.xml
----------------------------------------------------------------------
diff --git a/cayenne-ant/src/test/resources/org/apache/cayenne/tools/build-skip-relationships-loading.xml b/cayenne-ant/src/test/resources/org/apache/cayenne/tools/build-skip-relationships-loading.xml
new file mode 100644
index 0000000..b2c801b
--- /dev/null
+++ b/cayenne-ant/src/test/resources/org/apache/cayenne/tools/build-skip-relationships-loading.xml
@@ -0,0 +1,35 @@
+<!--
+  Licensed to the Apache Software Foundation (ASF) under one
+  or more contributor license agreements.  See the NOTICE file
+  distributed with this work for additional information
+  regarding copyright ownership.  The ASF licenses this file
+  to you under the Apache License, Version 2.0 (the
+  "License"); you may not use this file except in compliance
+  with the License.  You may obtain a copy of the License at
+
+  http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing,
+  software distributed under the License is distributed on an
+  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+  KIND, either express or implied.  See the License for the
+  specific language governing permissions and limitations
+  under the License.
+  -->
+
+<project name="MyProject" default="dist" basedir=".">
+
+    <taskdef name="cdbimport" classname="org.apache.cayenne.tools.DbImporterTask" taskname="cdbimport"
+             classpath="${basedir}"/>
+
+    <target name="dist">
+        <cdbimport map="${context.dir}/WEB-INF/DefaultMap.map.xml"
+                   adapter="org.apache.cayenne.dba.hsqldb.HSQLDBAdapter"
+                   driver="org.hsqldb.jdbcDriver"
+                   url="jdbc:hsqldb:hsql://localhost/bookmarker"
+                   username="sa"
+                   skipRelationshipsLoading="true"/>
+    </target>
+
+
+</project>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/cayenne/blob/c63b6be2/cayenne-ant/src/test/resources/org/apache/cayenne/tools/build-table-types.xml
----------------------------------------------------------------------
diff --git a/cayenne-ant/src/test/resources/org/apache/cayenne/tools/build-table-types.xml b/cayenne-ant/src/test/resources/org/apache/cayenne/tools/build-table-types.xml
new file mode 100644
index 0000000..25bf032
--- /dev/null
+++ b/cayenne-ant/src/test/resources/org/apache/cayenne/tools/build-table-types.xml
@@ -0,0 +1,40 @@
+<!--
+  Licensed to the Apache Software Foundation (ASF) under one
+  or more contributor license agreements.  See the NOTICE file
+  distributed with this work for additional information
+  regarding copyright ownership.  The ASF licenses this file
+  to you under the Apache License, Version 2.0 (the
+  "License"); you may not use this file except in compliance
+  with the License.  You may obtain a copy of the License at
+
+  http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing,
+  software distributed under the License is distributed on an
+  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+  KIND, either express or implied.  See the License for the
+  specific language governing permissions and limitations
+  under the License.
+  -->
+
+<project name="MyProject" default="dist" basedir=".">
+
+    <taskdef name="cdbimport" classname="org.apache.cayenne.tools.DbImporterTask" taskname="cdbimport"
+             classpath="${basedir}"/>
+
+    <target name="dist">
+        <cdbimport map="${context.dir}/WEB-INF/DefaultMap.map.xml"
+                   adapter="org.apache.cayenne.dba.hsqldb.HSQLDBAdapter"
+                   driver="org.hsqldb.jdbcDriver"
+                   url="jdbc:hsqldb:hsql://localhost/bookmarker"
+                   username="sa">
+
+            <tableType>type1</tableType>
+
+            <tableType name="type2"/>
+            <tableType name="type3"/>
+        </cdbimport>
+    </target>
+
+
+</project>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/cayenne/blob/c63b6be2/cayenne-ant/src/test/resources/org/apache/cayenne/tools/cgen-dependent.map.xml
----------------------------------------------------------------------
diff --git a/cayenne-ant/src/test/resources/org/apache/cayenne/tools/cgen-dependent.map.xml b/cayenne-ant/src/test/resources/org/apache/cayenne/tools/cgen-dependent.map.xml
new file mode 100644
index 0000000..d06be70
--- /dev/null
+++ b/cayenne-ant/src/test/resources/org/apache/cayenne/tools/cgen-dependent.map.xml
@@ -0,0 +1,19 @@
+<?xml version="1.0" encoding="utf-8"?>
+<data-map xmlns="http://cayenne.apache.org/schema/3.0/modelMap"
+	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+	xsi:schemaLocation="http://cayenne.apache.org/schema/3.0/modelMap ../../main/resources/org/apache/cayenne/schema/3.0/modelMap.xsd"
+	project-version="1.1">
+	<property name="defaultPackage" value="org.apache.cayenne.testdo.cgen2"/>
+	<db-entity name="MYARTGROUP">
+		<db-attribute name="MY_GROUP_ID" type="INTEGER" isPrimaryKey="true" isMandatory="true"/>
+		<db-attribute name="CUSTOM" type="VARCHAR" isMandatory="true" length="100"/>
+		<db-attribute name="MY_PARENT_GROUP_ID" type="INTEGER"/>
+	</db-entity>
+	<obj-entity name="MyArtGroup" className="org.apache.cayenne.testdo.cgen2.MyArtGroup" dbEntityName="MYARTGROUP">
+		<obj-attribute name="custom" type="java.lang.String" db-attribute-path="CUSTOM"/>
+	</obj-entity>
+	<db-relationship name="toParentArtGroup" source="MYARTGROUP" target="ARTGROUP" toMany="false">
+		<db-attribute-pair source="MY_PARENT_GROUP_ID" target="GROUP_ID"/>
+	</db-relationship>
+	<obj-relationship name="toParentGroup" source="MyArtGroup" target="ArtGroup" deleteRule="Nullify" db-relationship-path="toParentArtGroup"/>
+</data-map>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/cayenne/blob/c63b6be2/cayenne-ant/src/test/resources/org/apache/cayenne/tools/cgen.map.xml
----------------------------------------------------------------------
diff --git a/cayenne-ant/src/test/resources/org/apache/cayenne/tools/cgen.map.xml b/cayenne-ant/src/test/resources/org/apache/cayenne/tools/cgen.map.xml
new file mode 100644
index 0000000..1c378cf
--- /dev/null
+++ b/cayenne-ant/src/test/resources/org/apache/cayenne/tools/cgen.map.xml
@@ -0,0 +1,15 @@
+<?xml version="1.0" encoding="utf-8"?>
+<data-map xmlns="http://cayenne.apache.org/schema/3.0/modelMap"
+	 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+	 xsi:schemaLocation="http://cayenne.apache.org/schema/3.0/modelMap http://cayenne.apache.org/schema/3.0/modelMap.xsd"
+	 project-version="6">
+
+	<db-entity name="ARTGROUP">
+		<db-attribute name="GROUP_ID" type="INTEGER" isPrimaryKey="true" isMandatory="true"/>
+		<db-attribute name="NAME" type="VARCHAR" isMandatory="true" length="100"/>
+		<db-attribute name="PARENT_GROUP_ID" type="INTEGER"/>
+	</db-entity>
+	<obj-entity name="ArtGroup" className="org.apache.cayenne.testdo.testmap.ArtGroup" dbEntityName="ARTGROUP">
+		<obj-attribute name="name" type="java.lang.String" db-attribute-path="NAME"/>
+	</obj-entity>
+</data-map>

http://git-wip-us.apache.org/repos/asf/cayenne/blob/c63b6be2/cayenne-ant/src/test/resources/org/apache/cayenne/tools/velotemplate.vm
----------------------------------------------------------------------
diff --git a/cayenne-ant/src/test/resources/org/apache/cayenne/tools/velotemplate.vm b/cayenne-ant/src/test/resources/org/apache/cayenne/tools/velotemplate.vm
new file mode 100644
index 0000000..1ca078c
--- /dev/null
+++ b/cayenne-ant/src/test/resources/org/apache/cayenne/tools/velotemplate.vm
@@ -0,0 +1,13 @@
+## Test Velocity template
+${importUtils.setPackage($subPackageName)}##
+${importUtils.generate()}
+
+import java.util.List;
+import org.apache.cayenne.*;
+
+/** Class ${classGen.superPrefix}${classGen.className} was generated by Cayenne.
+  * It is probably a good idea to avoid changing this class manually, 
+  * since it may be overwritten next time code is regenerated. 
+  * If you need to make any customizations, please use subclass. 
+  */
+public class ${subClassName} extends CayenneDataObject {


[10/10] cayenne git commit: CAY-2215 split cayenne-tools into cayenne-cgen and cayenne-ant

Posted by nt...@apache.org.
CAY-2215 split cayenne-tools into cayenne-cgen and cayenne-ant


Project: http://git-wip-us.apache.org/repos/asf/cayenne/repo
Commit: http://git-wip-us.apache.org/repos/asf/cayenne/commit/c63b6be2
Tree: http://git-wip-us.apache.org/repos/asf/cayenne/tree/c63b6be2
Diff: http://git-wip-us.apache.org/repos/asf/cayenne/diff/c63b6be2

Branch: refs/heads/master
Commit: c63b6be2f27e1bad203d22cab950a87b4f514b38
Parents: 660dd4b
Author: Nikita Timofeev <st...@gmail.com>
Authored: Wed Feb 1 16:05:31 2017 +0300
Committer: Nikita Timofeev <st...@gmail.com>
Committed: Wed Feb 1 16:05:31 2017 +0300

----------------------------------------------------------------------
 assembly/pom.xml                                |   8 +-
 .../resources/assemblies/assembly-generic.xml   |   3 +-
 .../main/resources/assemblies/assembly-mac.xml  |   3 +-
 .../resources/assemblies/assembly-windows.xml   |   3 +-
 build-tools/cayenne-coverage/pom.xml            |   2 +-
 cayenne-ant/pom.xml                             | 180 +++++
 .../cayenne/tools/AntDataPortDelegate.java      | 170 +++++
 .../org/apache/cayenne/tools/AntLogger.java     | 108 +++
 .../org/apache/cayenne/tools/AntTableType.java  |  35 +
 .../cayenne/tools/CayenneGeneratorTask.java     | 304 ++++++++
 .../org/apache/cayenne/tools/CayenneTask.java   | 161 ++++
 .../org/apache/cayenne/tools/DataPortTask.java  | 213 ++++++
 .../apache/cayenne/tools/DbGeneratorTask.java   | 155 ++++
 .../apache/cayenne/tools/DbImporterTask.java    | 241 ++++++
 .../java/org/apache/cayenne/tools/package.html  |  23 +
 .../org/apache/cayenne/tools/antlib.xml         |  25 +
 .../cayenne/tools/AntDataPortDelegateTest.java  |  53 ++
 ...eGeneratorTaskCrossMapRelationshipsTest.java | 157 ++++
 .../cayenne/tools/CayenneGeneratorTaskTest.java | 317 ++++++++
 .../cayenne/tools/DbGeneratorTaskTest.java      |  75 ++
 .../cayenne/tools/DbImporterTaskTest.java       | 229 ++++++
 .../src/test/resources/embeddable.map.xml       |  27 +
 .../cayenne/tools/build-catalog-and-schema.xml  |  78 ++
 .../org/apache/cayenne/tools/build-catalog.xml  |  82 ++
 .../org/apache/cayenne/tools/build-flat.xml     |  73 ++
 .../tools/build-include-table.map.xml-result    |  37 +
 .../cayenne/tools/build-include-table.xml       |  34 +
 .../cayenne/tools/build-include-table.xml.sql   |  38 +
 .../org/apache/cayenne/tools/build-mapping.xml  |  44 ++
 ...ild-reverse-engineering-in-external-file.xml |  33 +
 .../org/apache/cayenne/tools/build-schema.xml   |  83 +++
 .../tools/build-skip-primary-key-loading.xml    |  35 +
 .../tools/build-skip-relationships-loading.xml  |  35 +
 .../apache/cayenne/tools/build-table-types.xml  |  40 +
 .../apache/cayenne/tools/cgen-dependent.map.xml |  19 +
 .../org/apache/cayenne/tools/cgen.map.xml       |  15 +
 .../org/apache/cayenne/tools/velotemplate.vm    |  13 +
 cayenne-ant/src/test/resources/testmap.map.xml  | 744 +++++++++++++++++++
 cayenne-cgen/pom.xml                            |  81 ++
 .../java/org/apache/cayenne/gen/Artifact.java   |  65 ++
 .../cayenne/gen/ArtifactGenerationMode.java     |  28 +
 .../cayenne/gen/ArtifactsGenerationMode.java    |  40 +
 .../cayenne/gen/ClassGenerationAction.java      | 584 +++++++++++++++
 .../gen/ClassGeneratorResourceLoader.java       | 102 +++
 .../gen/ClientClassGenerationAction.java        |  80 ++
 .../cayenne/gen/ClientDataMapArtifact.java      |  50 ++
 .../cayenne/gen/ClientEntityArtifact.java       |  45 ++
 .../org/apache/cayenne/gen/DataMapArtifact.java | 137 ++++
 .../org/apache/cayenne/gen/DataMapUtils.java    | 219 ++++++
 .../apache/cayenne/gen/EmbeddableArtifact.java  |  68 ++
 .../org/apache/cayenne/gen/EntityArtifact.java  |  98 +++
 .../org/apache/cayenne/gen/EntityUtils.java     | 274 +++++++
 .../org/apache/cayenne/gen/ImportUtils.java     | 266 +++++++
 .../org/apache/cayenne/gen/StringUtils.java     | 213 ++++++
 .../org/apache/cayenne/gen/TemplateType.java    |  55 ++
 .../java/org/apache/cayenne/gen/package.html    |  28 +
 .../CayenneGeneratorEntityFilterAction.java     |  85 +++
 .../tools/CayenneGeneratorMapLoaderAction.java  |  78 ++
 .../v1_2/client-datamap-singleclass.vm          |  96 +++
 .../templates/v1_2/client-datamap-subclass.vm   |  47 ++
 .../templates/v1_2/client-datamap-superclass.vm |  83 +++
 .../resources/templates/v1_2/client-subclass.vm |  57 ++
 .../templates/v1_2/client-superclass.vm         | 248 +++++++
 .../templates/v1_2/datamap-singleclass.vm       |  96 +++
 .../templates/v1_2/datamap-subclass.vm          |  47 ++
 .../templates/v1_2/datamap-superclass.vm        |  87 +++
 .../templates/v1_2/embeddable-singleclass.vm    | 106 +++
 .../templates/v1_2/embeddable-subclass.vm       |  45 ++
 .../templates/v1_2/embeddable-superclass.vm     | 112 +++
 .../resources/templates/v1_2/singleclass.vm     | 147 ++++
 .../main/resources/templates/v1_2/subclass.vm   |  47 ++
 .../main/resources/templates/v1_2/superclass.vm | 164 ++++
 .../cayenne/gen/ClassGenerationActionTest.java  | 256 +++++++
 .../apache/cayenne/gen/ClassGenerationCase.java |  59 ++
 .../gen/ClientSuperClassGenerationTest.java     |  86 +++
 .../org/apache/cayenne/gen/EntityUtilsTest.java |  75 ++
 .../org/apache/cayenne/gen/ImportUtilsTest.java | 252 +++++++
 .../cayenne/gen/SingleClassGenerationTest.java  |  86 +++
 .../org/apache/cayenne/gen/StringUtilsTest.java | 124 ++++
 .../cayenne/gen/SuperClassGenerationTest.java   |  86 +++
 cayenne-client-jetty/pom.xml                    |   2 +-
 cayenne-client/pom.xml                          |   2 +-
 cayenne-dbcp2/pom.xml                           |   2 +-
 cayenne-dbsync/pom.xml                          |   2 +-
 .../dbsync/filter/NamePatternMatcher.java       |  27 -
 .../dbsync/filter/NamePatternMatcherTest.java   |  16 -
 cayenne-di/pom.xml                              |   2 +-
 cayenne-joda/pom.xml                            |   2 +-
 cayenne-lifecycle/pom.xml                       |   2 +-
 cayenne-project/pom.xml                         |   2 +-
 cayenne-protostuff/pom.xml                      |   2 +-
 cayenne-server/pom.xml                          |   2 +-
 cayenne-tools/pom.xml                           | 193 -----
 .../java/org/apache/cayenne/gen/Artifact.java   |  65 --
 .../cayenne/gen/ArtifactGenerationMode.java     |  28 -
 .../cayenne/gen/ArtifactsGenerationMode.java    |  40 -
 .../cayenne/gen/ClassGenerationAction.java      | 584 ---------------
 .../gen/ClassGeneratorResourceLoader.java       | 102 ---
 .../gen/ClientClassGenerationAction.java        |  79 --
 .../cayenne/gen/ClientDataMapArtifact.java      |  50 --
 .../cayenne/gen/ClientEntityArtifact.java       |  45 --
 .../org/apache/cayenne/gen/DataMapArtifact.java | 137 ----
 .../org/apache/cayenne/gen/DataMapUtils.java    | 219 ------
 .../apache/cayenne/gen/EmbeddableArtifact.java  |  68 --
 .../org/apache/cayenne/gen/EntityArtifact.java  |  98 ---
 .../org/apache/cayenne/gen/EntityUtils.java     | 274 -------
 .../org/apache/cayenne/gen/ImportUtils.java     | 266 -------
 .../org/apache/cayenne/gen/StringUtils.java     | 189 -----
 .../org/apache/cayenne/gen/TemplateType.java    |  55 --
 .../java/org/apache/cayenne/gen/package.html    |  28 -
 .../cayenne/tools/AntDataPortDelegate.java      | 170 -----
 .../org/apache/cayenne/tools/AntLogger.java     | 108 ---
 .../org/apache/cayenne/tools/AntTableType.java  |  35 -
 .../CayenneGeneratorEntityFilterAction.java     |  85 ---
 .../tools/CayenneGeneratorMapLoaderAction.java  |  79 --
 .../cayenne/tools/CayenneGeneratorTask.java     | 304 --------
 .../org/apache/cayenne/tools/CayenneTask.java   | 161 ----
 .../org/apache/cayenne/tools/DataPortTask.java  | 213 ------
 .../apache/cayenne/tools/DbGeneratorTask.java   | 155 ----
 .../apache/cayenne/tools/DbImporterTask.java    | 241 ------
 .../java/org/apache/cayenne/tools/package.html  |  23 -
 .../org/apache/cayenne/tools/antlib.xml         |  25 -
 .../v1_2/client-datamap-singleclass.vm          |  96 ---
 .../templates/v1_2/client-datamap-subclass.vm   |  47 --
 .../templates/v1_2/client-datamap-superclass.vm |  83 ---
 .../resources/templates/v1_2/client-subclass.vm |  57 --
 .../templates/v1_2/client-superclass.vm         | 248 -------
 .../templates/v1_2/datamap-singleclass.vm       |  96 ---
 .../templates/v1_2/datamap-subclass.vm          |  47 --
 .../templates/v1_2/datamap-superclass.vm        |  87 ---
 .../templates/v1_2/embeddable-singleclass.vm    | 106 ---
 .../templates/v1_2/embeddable-subclass.vm       |  45 --
 .../templates/v1_2/embeddable-superclass.vm     | 112 ---
 .../resources/templates/v1_2/singleclass.vm     | 147 ----
 .../main/resources/templates/v1_2/subclass.vm   |  47 --
 .../main/resources/templates/v1_2/superclass.vm | 164 ----
 .../cayenne/gen/ClassGenerationActionTest.java  | 255 -------
 .../apache/cayenne/gen/ClassGenerationCase.java |  59 --
 .../gen/ClientSuperClassGenerationTest.java     |  86 ---
 .../org/apache/cayenne/gen/EntityUtilsTest.java |  74 --
 .../org/apache/cayenne/gen/ImportUtilsTest.java | 252 -------
 .../cayenne/gen/SingleClassGenerationTest.java  |  86 ---
 .../org/apache/cayenne/gen/StringUtilsTest.java | 110 ---
 .../cayenne/gen/SuperClassGenerationTest.java   |  86 ---
 .../cayenne/tools/AntDataPortDelegateTest.java  |  53 --
 ...eGeneratorTaskCrossMapRelationshipsTest.java | 157 ----
 .../cayenne/tools/CayenneGeneratorTaskTest.java | 317 --------
 .../cayenne/tools/DbGeneratorTaskTest.java      |  75 --
 .../cayenne/tools/DbImporterTaskTest.java       | 229 ------
 .../src/test/resources/embeddable.map.xml       |  27 -
 .../cayenne/tools/build-catalog-and-schema.xml  |  78 --
 .../org/apache/cayenne/tools/build-catalog.xml  |  82 --
 .../org/apache/cayenne/tools/build-flat.xml     |  73 --
 .../tools/build-include-table.map.xml-result    |  37 -
 .../cayenne/tools/build-include-table.xml       |  34 -
 .../cayenne/tools/build-include-table.xml.sql   |  38 -
 .../org/apache/cayenne/tools/build-mapping.xml  |  44 --
 ...ild-reverse-engineering-in-external-file.xml |  33 -
 .../org/apache/cayenne/tools/build-schema.xml   |  83 ---
 .../tools/build-skip-primary-key-loading.xml    |  35 -
 .../tools/build-skip-relationships-loading.xml  |  35 -
 .../apache/cayenne/tools/build-table-types.xml  |  40 -
 .../apache/cayenne/tools/cgen-dependent.map.xml |  19 -
 .../org/apache/cayenne/tools/cgen.map.xml       |  15 -
 .../org/apache/cayenne/tools/velotemplate.vm    |  13 -
 .../src/test/resources/testmap.map.xml          | 744 -------------------
 itests/cayenne-tools-itest/pom.xml              |   5 -
 modeler/cayenne-modeler/pom.xml                 |   8 +-
 plugins/cayenne-maven-plugin/pom.xml            |  24 +-
 plugins/maven-cayenne-plugin/pom.xml            |   6 -
 pom.xml                                         |   7 +-
 171 files changed, 8915 insertions(+), 8865 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cayenne/blob/c63b6be2/assembly/pom.xml
----------------------------------------------------------------------
diff --git a/assembly/pom.xml b/assembly/pom.xml
index 47d73ea..74d643f 100644
--- a/assembly/pom.xml
+++ b/assembly/pom.xml
@@ -56,7 +56,13 @@
 
 		<dependency>
 			<groupId>org.apache.cayenne</groupId>
-			<artifactId>cayenne-tools</artifactId>
+			<artifactId>cayenne-cgen</artifactId>
+			<version>${project.version}</version>
+		</dependency>
+
+		<dependency>
+			<groupId>org.apache.cayenne</groupId>
+			<artifactId>cayenne-ant</artifactId>
 			<version>${project.version}</version>
 		</dependency>
 

http://git-wip-us.apache.org/repos/asf/cayenne/blob/c63b6be2/assembly/src/main/resources/assemblies/assembly-generic.xml
----------------------------------------------------------------------
diff --git a/assembly/src/main/resources/assemblies/assembly-generic.xml b/assembly/src/main/resources/assemblies/assembly-generic.xml
index 5eb4a62..e297a8a 100644
--- a/assembly/src/main/resources/assemblies/assembly-generic.xml
+++ b/assembly/src/main/resources/assemblies/assembly-generic.xml
@@ -81,7 +81,8 @@
 				<include>org.apache.cayenne:cayenne-project</include>
 				<include>org.apache.cayenne:cayenne-server</include>
 				<include>org.apache.cayenne:cayenne-dbsync</include>
-				<include>org.apache.cayenne:cayenne-tools</include>
+				<include>org.apache.cayenne:cayenne-cgen</include>
+				<include>org.apache.cayenne:cayenne-ant</include>
 				<include>org.apache.cayenne:cayenne-dbcp2</include>
 				<include>org.apache.cayenne:cayenne-java8</include>
 			</includes>

http://git-wip-us.apache.org/repos/asf/cayenne/blob/c63b6be2/assembly/src/main/resources/assemblies/assembly-mac.xml
----------------------------------------------------------------------
diff --git a/assembly/src/main/resources/assemblies/assembly-mac.xml b/assembly/src/main/resources/assemblies/assembly-mac.xml
index 11e3546..8d94bb6 100644
--- a/assembly/src/main/resources/assemblies/assembly-mac.xml
+++ b/assembly/src/main/resources/assemblies/assembly-mac.xml
@@ -81,7 +81,8 @@
 				<include>org.apache.cayenne:cayenne-project</include>
 				<include>org.apache.cayenne:cayenne-server</include>
 				<include>org.apache.cayenne:cayenne-dbsync</include>
-				<include>org.apache.cayenne:cayenne-tools</include>
+				<include>org.apache.cayenne:cayenne-cgen</include>
+				<include>org.apache.cayenne:cayenne-ant</include>
 				<include>org.apache.cayenne:cayenne-dbcp2</include>
 				<include>org.apache.cayenne:cayenne-java8</include>
 			</includes>

http://git-wip-us.apache.org/repos/asf/cayenne/blob/c63b6be2/assembly/src/main/resources/assemblies/assembly-windows.xml
----------------------------------------------------------------------
diff --git a/assembly/src/main/resources/assemblies/assembly-windows.xml b/assembly/src/main/resources/assemblies/assembly-windows.xml
index efa451d..2dd3781 100644
--- a/assembly/src/main/resources/assemblies/assembly-windows.xml
+++ b/assembly/src/main/resources/assemblies/assembly-windows.xml
@@ -81,7 +81,8 @@
 				<include>org.apache.cayenne:cayenne-project</include>
 				<include>org.apache.cayenne:cayenne-server</include>
 				<include>org.apache.cayenne:cayenne-dbsync</include>
-				<include>org.apache.cayenne:cayenne-tools</include>
+				<include>org.apache.cayenne:cayenne-cgen</include>
+				<include>org.apache.cayenne:cayenne-ant</include>
 				<include>org.apache.cayenne:cayenne-dbcp2</include>
 				<include>org.apache.cayenne:cayenne-java8</include>
 			</includes>

http://git-wip-us.apache.org/repos/asf/cayenne/blob/c63b6be2/build-tools/cayenne-coverage/pom.xml
----------------------------------------------------------------------
diff --git a/build-tools/cayenne-coverage/pom.xml b/build-tools/cayenne-coverage/pom.xml
index 2a15c13..aa09df8 100644
--- a/build-tools/cayenne-coverage/pom.xml
+++ b/build-tools/cayenne-coverage/pom.xml
@@ -57,7 +57,7 @@
         </dependency>
         <dependency>
             <groupId>org.apache.cayenne</groupId>
-            <artifactId>cayenne-tools</artifactId>
+            <artifactId>cayenne-ant</artifactId>
             <version>${cayenne.version}</version>
         </dependency>
     </dependencies>

http://git-wip-us.apache.org/repos/asf/cayenne/blob/c63b6be2/cayenne-ant/pom.xml
----------------------------------------------------------------------
diff --git a/cayenne-ant/pom.xml b/cayenne-ant/pom.xml
new file mode 100644
index 0000000..3ef7426
--- /dev/null
+++ b/cayenne-ant/pom.xml
@@ -0,0 +1,180 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+	Licensed to the Apache Software Foundation (ASF) under one
+	or more contributor license agreements.  See the NOTICE file
+	distributed with this work for additional information
+	regarding copyright ownership.  The ASF licenses this file
+	to you under the Apache License, Version 2.0 (the
+	"License"); you may not use this file except in compliance
+	with the License.  You may obtain a copy of the License at
+	
+	http://www.apache.org/licenses/LICENSE-2.0
+	
+	Unless required by applicable law or agreed to in writing,
+	software distributed under the License is distributed on an
+	"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+	KIND, either express or implied.  See the License for the
+	specific language governing permissions and limitations
+	under the License.   
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+
+	<parent>
+		<artifactId>cayenne-parent</artifactId>
+		<groupId>org.apache.cayenne</groupId>
+		<version>4.0.M5-SNAPSHOT</version>
+	</parent>
+
+	<modelVersion>4.0.0</modelVersion>
+
+	<artifactId>cayenne-ant</artifactId>
+	<packaging>jar</packaging>
+	<name>cayenne-ant: Cayenne Ant Tasks</name>
+	<dependencies>
+        <!-- Compile Dependencies -->
+        <dependency>
+            <groupId>org.apache.ant</groupId>
+            <artifactId>ant</artifactId>
+            <scope>compile</scope>
+        </dependency>
+		<dependency>
+			<groupId>commons-collections</groupId>
+			<artifactId>commons-collections</artifactId>
+            <scope>compile</scope>
+		</dependency>
+		<dependency>
+			<groupId>commons-logging</groupId>
+			<artifactId>commons-logging</artifactId>
+            <scope>compile</scope>
+		</dependency>
+		<dependency>
+			<groupId>org.apache.velocity</groupId>
+			<artifactId>velocity</artifactId>
+            <scope>compile</scope>
+		</dependency>
+		<dependency>
+			<groupId>org.apache.cayenne</groupId>
+			<artifactId>cayenne-cgen</artifactId>
+			<version>${project.version}</version>
+            <scope>compile</scope>
+		</dependency>
+        <dependency>
+            <groupId>org.apache.cayenne</groupId>
+            <artifactId>cayenne-dbsync</artifactId>
+            <version>${project.version}</version>
+            <scope>compile</scope>
+        </dependency>
+		<dependency>
+			<groupId>foundrylogic.vpp</groupId>
+			<artifactId>vpp</artifactId>
+            <scope>compile</scope>
+		</dependency>
+
+        <!-- Test Dependencies -->
+        <dependency>
+            <groupId>junit</groupId>
+            <artifactId>junit</artifactId>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.cayenne</groupId>
+            <artifactId>cayenne-dbsync</artifactId>
+            <version>${project.version}</version>
+            <scope>test</scope>
+            <type>test-jar</type>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.cayenne.build-tools</groupId>
+            <artifactId>cayenne-test-utilities</artifactId>
+            <version>${project.version}</version>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.mockito</groupId>
+            <artifactId>mockito-all</artifactId>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.slf4j</groupId>
+            <artifactId>jcl-over-slf4j</artifactId>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.slf4j</groupId>
+            <artifactId>slf4j-api</artifactId>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.slf4j</groupId>
+            <artifactId>slf4j-simple</artifactId>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.ant</groupId>
+            <artifactId>ant-testutil</artifactId>
+            <version>1.9.4</version>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.derby</groupId>
+            <artifactId>derby</artifactId>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>xmlunit</groupId>
+            <artifactId>xmlunit</artifactId>
+            <scope>test</scope>
+        </dependency>
+
+	</dependencies>
+	
+	<build>
+		<plugins>
+			<!-- This ensures LICENSE and NOTICE inclusion in all jars -->
+            <plugin>
+                <artifactId>maven-remote-resources-plugin</artifactId>
+                <executions>
+                    <execution>
+                        <goals>
+                            <goal>process</goal>
+                        </goals>
+                    </execution>
+                </executions>
+            </plugin>
+            <plugin>
+                <artifactId>maven-jar-plugin</artifactId>
+                <executions>
+                    <execution>
+                        <goals>
+                            <goal>test-jar</goal>
+                        </goals>
+                    </execution>
+                </executions>
+            </plugin>
+        </plugins>
+	</build>
+    <profiles>
+        <profile>
+            <id>code-quality</id>
+
+            <activation>
+                <property>
+                    <name>!fast-and-dirty</name>
+                </property>
+            </activation>
+            <build>
+                <plugins>
+                    <plugin>
+                        <artifactId>maven-checkstyle-plugin</artifactId>
+                        <!--<configuration>
+                            <suppressionsLocation>${project.basedir}/cayenne-checkstyle-suppression.xml</suppressionsLocation>
+                        </configuration>-->
+                    </plugin>
+                    <plugin>
+                        <artifactId>maven-pmd-plugin</artifactId>
+                    </plugin>
+                </plugins>
+            </build>
+        </profile>
+    </profiles>
+</project>

http://git-wip-us.apache.org/repos/asf/cayenne/blob/c63b6be2/cayenne-ant/src/main/java/org/apache/cayenne/tools/AntDataPortDelegate.java
----------------------------------------------------------------------
diff --git a/cayenne-ant/src/main/java/org/apache/cayenne/tools/AntDataPortDelegate.java b/cayenne-ant/src/main/java/org/apache/cayenne/tools/AntDataPortDelegate.java
new file mode 100644
index 0000000..de001bd
--- /dev/null
+++ b/cayenne-ant/src/main/java/org/apache/cayenne/tools/AntDataPortDelegate.java
@@ -0,0 +1,170 @@
+/*****************************************************************
+ *   Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ ****************************************************************/
+
+package org.apache.cayenne.tools;
+
+import org.apache.cayenne.access.DataPort;
+import org.apache.cayenne.access.DataPortDelegate;
+import org.apache.cayenne.dbsync.filter.NamePatternMatcher;
+import org.apache.cayenne.map.DataMap;
+import org.apache.cayenne.map.DbEntity;
+import org.apache.cayenne.query.Query;
+import org.apache.tools.ant.Project;
+import org.apache.tools.ant.Task;
+
+import java.util.Iterator;
+import java.util.List;
+import java.util.regex.Pattern;
+
+/**
+ * DataPortDelegate implementation that works in the context of Ant DataPortTask
+ * task execution, performing entity filtering and logging functions.
+ * 
+ * @since 1.2: Prior to 1.2 DataPort classes were a part of cayenne-examples
+ *        package.
+ * @deprecated since 4.0
+ */
+@Deprecated
+class AntDataPortDelegate implements DataPortDelegate {
+
+    protected Task parentTask;
+
+    protected Pattern[] mapFilters;
+
+    protected long timestamp;
+    protected DbEntity lastEntity;
+
+    protected NamePatternMatcher namePatternMatcher;
+
+    // exists for testing and such
+    AntDataPortDelegate() {
+        mapFilters = new Pattern[] {};
+    }
+
+    AntDataPortDelegate(Task parentTask, String mapsPattern,
+            String includeEntitiesPattern, String excludeEntitiesPattern) {
+        this.parentTask = parentTask;
+
+        AntLogger logger = new AntLogger(parentTask);
+
+        this.namePatternMatcher = NamePatternMatcher.build(logger, includeEntitiesPattern, excludeEntitiesPattern);
+        this.mapFilters = NamePatternMatcher.createPatterns(logger, mapsPattern);
+    }
+
+    /**
+     * Applies preconfigured list of filters to the list, removing entities that
+     * do not pass the filter.
+     */
+    protected List filterEntities(List entities) {
+        if (entities == null || entities.isEmpty()) {
+            return entities;
+        }
+
+        Iterator it = entities.iterator();
+        while (it.hasNext()) {
+            DbEntity entity = (DbEntity) it.next();
+
+            if (!passedDataMapFilter(entity.getDataMap())) {
+                it.remove();
+            }
+        }
+
+        namePatternMatcher.filter(entities);
+
+        return entities;
+    }
+
+    /**
+     * Returns true if the DataMap passes a set of DataMap filters or if there
+     * is no DataMap filters.
+     */
+    protected boolean passedDataMapFilter(DataMap map) {
+        if (mapFilters.length == 0) {
+            return true;
+        }
+
+        if (map == null) {
+            return true;
+        }
+
+        String mapName = map.getName();
+        for (Pattern mapFilter : mapFilters) {
+            if (mapFilter.matcher(mapName).find()) {
+                return true;
+            }
+        }
+
+        return false;
+    }
+
+    /**
+     * Implements the delegate method to filter the list of entities applying
+     * filtering rules encapsulated by this object.
+     */
+    public List willPortEntities(DataPort portTool, List entities) {
+        return filterEntities(entities);
+    }
+
+    /**
+     * Logs entity porting event using Ant logger.
+     */
+    public Query willPortEntity(DataPort portTool, DbEntity entity, Query query) {
+        parentTask.log("Porting '" + entity.getName() + "'");
+        lastEntity = entity;
+        timestamp = System.currentTimeMillis();
+        return query;
+    }
+
+    public void didPortEntity(DataPort portTool, DbEntity entity, int rowCount) {
+        String timestampLabel = "";
+        if (lastEntity == entity) {
+            timestampLabel = " in " + (System.currentTimeMillis() - timestamp)
+                    + " ms.";
+        }
+
+        String label = (rowCount == 1) ? "1 row transferred" : rowCount
+                + " rows transferred";
+        parentTask.log("Done porting " + entity.getName() + ", " + label
+                + timestampLabel, Project.MSG_VERBOSE);
+    }
+
+    public List willCleanData(DataPort portTool, List entities) {
+        return filterEntities(entities);
+    }
+
+    public Query willCleanData(DataPort portTool, DbEntity entity, Query query) {
+        parentTask.log("Deleting " + entity.getName(), Project.MSG_VERBOSE);
+        lastEntity = entity;
+        timestamp = System.currentTimeMillis();
+        return query;
+    }
+
+    public void didCleanData(DataPort portTool, DbEntity entity, int rowCount) {
+        String timestampLabel = "";
+        if (lastEntity == entity) {
+            timestampLabel = " in " + (System.currentTimeMillis() - timestamp)
+                    + " ms.";
+        }
+
+        String label = (rowCount == 1) ? "1 row deleted" : rowCount
+                + " rows deleted";
+        parentTask.log("Done deleting " + entity.getName() + ", " + label
+                + timestampLabel, Project.MSG_VERBOSE);
+    }
+}

http://git-wip-us.apache.org/repos/asf/cayenne/blob/c63b6be2/cayenne-ant/src/main/java/org/apache/cayenne/tools/AntLogger.java
----------------------------------------------------------------------
diff --git a/cayenne-ant/src/main/java/org/apache/cayenne/tools/AntLogger.java b/cayenne-ant/src/main/java/org/apache/cayenne/tools/AntLogger.java
new file mode 100644
index 0000000..4e8e8b5
--- /dev/null
+++ b/cayenne-ant/src/main/java/org/apache/cayenne/tools/AntLogger.java
@@ -0,0 +1,108 @@
+/*****************************************************************
+ *   Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ ****************************************************************/
+
+package org.apache.cayenne.tools;
+
+import org.apache.commons.logging.Log;
+import org.apache.tools.ant.Project;
+import org.apache.tools.ant.Task;
+
+/**
+ * @since 3.0
+ */
+class AntLogger implements Log {
+
+    private Task parentTask;
+
+    public AntLogger(Task parentTask) {
+        this.parentTask = parentTask;
+    }
+
+    public void debug(Object message, Throwable th) {
+        parentTask.log(String.valueOf(message), Project.MSG_DEBUG);
+    }
+
+    public void debug(Object message) {
+        parentTask.log(String.valueOf(message), Project.MSG_DEBUG);
+    }
+
+    public void error(Object message, Throwable th) {
+        parentTask.log(String.valueOf(message), Project.MSG_ERR);
+    }
+
+    public void error(Object message) {
+        parentTask.log(String.valueOf(message), Project.MSG_ERR);
+    }
+
+    public void fatal(Object message, Throwable th) {
+        parentTask.log(String.valueOf(message), Project.MSG_ERR);
+    }
+
+    public void fatal(Object message) {
+        parentTask.log(String.valueOf(message), Project.MSG_ERR);
+    }
+
+    public void info(Object message, Throwable th) {
+        parentTask.log(String.valueOf(message), Project.MSG_INFO);
+    }
+
+    public void info(Object message) {
+        parentTask.log(String.valueOf(message), Project.MSG_INFO);
+    }
+
+    public void trace(Object message, Throwable th) {
+        parentTask.log(String.valueOf(message), Project.MSG_VERBOSE);
+    }
+
+    public void trace(Object message) {
+        parentTask.log(String.valueOf(message), Project.MSG_VERBOSE);
+    }
+
+    public void warn(Object message, Throwable th) {
+        parentTask.log(String.valueOf(message), Project.MSG_WARN);
+    }
+
+    public void warn(Object message) {
+        parentTask.log(String.valueOf(message), Project.MSG_WARN);
+    }
+
+    public boolean isWarnEnabled() {
+        return true;
+    }
+
+    public boolean isDebugEnabled() {
+        return true;
+    }
+
+    public boolean isErrorEnabled() {
+        return true;
+    }
+
+    public boolean isFatalEnabled() {
+        return true;
+    }
+
+    public boolean isInfoEnabled() {
+        return true;
+    }
+
+    public boolean isTraceEnabled() {
+        return true;
+    }
+}

http://git-wip-us.apache.org/repos/asf/cayenne/blob/c63b6be2/cayenne-ant/src/main/java/org/apache/cayenne/tools/AntTableType.java
----------------------------------------------------------------------
diff --git a/cayenne-ant/src/main/java/org/apache/cayenne/tools/AntTableType.java b/cayenne-ant/src/main/java/org/apache/cayenne/tools/AntTableType.java
new file mode 100644
index 0000000..d195f9a
--- /dev/null
+++ b/cayenne-ant/src/main/java/org/apache/cayenne/tools/AntTableType.java
@@ -0,0 +1,35 @@
+/*
+ *    Licensed to the Apache Software Foundation (ASF) under one
+ *    or more contributor license agreements.  See the NOTICE file
+ *    distributed with this work for additional information
+ *    regarding copyright ownership.  The ASF licenses this file
+ *    to you under the Apache License, Version 2.0 (the
+ *    "License"); you may not use this file except in compliance
+ *    with the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *    Unless required by applicable law or agreed to in writing,
+ *    software distributed under the License is distributed on an
+ *    "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *    KIND, either express or implied.  See the License for the
+ *    specific language governing permissions and limitations
+ *    under the License.
+ */
+package org.apache.cayenne.tools;
+
+public class AntTableType {
+    private String name;
+
+    public void addText(String string) {
+        setName(string);
+    }
+
+    public String getName() {
+        return name;
+    }
+
+    public void setName(String name) {
+        this.name = name;
+    }
+}

http://git-wip-us.apache.org/repos/asf/cayenne/blob/c63b6be2/cayenne-ant/src/main/java/org/apache/cayenne/tools/CayenneGeneratorTask.java
----------------------------------------------------------------------
diff --git a/cayenne-ant/src/main/java/org/apache/cayenne/tools/CayenneGeneratorTask.java b/cayenne-ant/src/main/java/org/apache/cayenne/tools/CayenneGeneratorTask.java
new file mode 100644
index 0000000..d57b350
--- /dev/null
+++ b/cayenne-ant/src/main/java/org/apache/cayenne/tools/CayenneGeneratorTask.java
@@ -0,0 +1,304 @@
+/*****************************************************************
+ *   Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ ****************************************************************/
+package org.apache.cayenne.tools;
+
+import foundrylogic.vpp.VPPConfig;
+import org.apache.cayenne.dbsync.filter.NamePatternMatcher;
+import org.apache.cayenne.gen.ArtifactsGenerationMode;
+import org.apache.cayenne.gen.ClassGenerationAction;
+import org.apache.cayenne.gen.ClientClassGenerationAction;
+import org.apache.cayenne.map.DataMap;
+import org.apache.tools.ant.BuildException;
+import org.apache.tools.ant.types.Path;
+import org.apache.velocity.VelocityContext;
+
+import java.io.File;
+
+/**
+ * An Ant task to perform class generation based on CayenneDataMap.
+ * 
+ * @since 3.0
+ */
+public class CayenneGeneratorTask extends CayenneTask {
+
+    protected String includeEntitiesPattern;
+    protected String excludeEntitiesPattern;
+    protected VPPConfig vppConfig;
+
+    protected File map;
+    protected File additionalMaps[];
+    protected boolean client;
+    protected File destDir;
+    protected String encoding;
+    protected boolean makepairs;
+    protected String mode;
+    protected String outputPattern;
+    protected boolean overwrite;
+    protected String superpkg;
+    protected String supertemplate;
+    protected String template;
+    protected String embeddabletemplate;
+    protected String embeddablesupertemplate;
+    protected String querytemplate;
+    protected String querysupertemplate;
+    protected boolean usepkgpath;
+    protected boolean createpropertynames;
+
+    public CayenneGeneratorTask() {
+        this.makepairs = true;
+        this.mode = ArtifactsGenerationMode.ENTITY.getLabel();
+        this.outputPattern = "*.java";
+        this.usepkgpath = true;
+    }
+
+    protected VelocityContext getVppContext() {
+        initializeVppConfig();
+        return vppConfig.getVelocityContext();
+    }
+
+    protected ClassGenerationAction createGeneratorAction() {
+        ClassGenerationAction action = client ? new ClientClassGenerationAction() : new ClassGenerationAction();
+
+        action.setContext(getVppContext());
+        action.setDestDir(destDir);
+        action.setEncoding(encoding);
+        action.setMakePairs(makepairs);
+        action.setArtifactsGenerationMode(mode);
+        action.setOutputPattern(outputPattern);
+        action.setOverwrite(overwrite);
+        action.setSuperPkg(superpkg);
+        action.setSuperTemplate(supertemplate);
+        action.setTemplate(template);
+        action.setEmbeddableSuperTemplate(embeddablesupertemplate);
+        action.setEmbeddableTemplate(embeddabletemplate);
+        action.setQueryTemplate(querytemplate);
+        action.setQuerySuperTemplate(querysupertemplate);
+        action.setUsePkgPath(usepkgpath);
+        action.setCreatePropertyNames(createpropertynames);
+
+        return action;
+    }
+
+    /**
+     * Executes the task. It will be called by ant framework.
+     */
+    @Override
+    public void execute() throws BuildException {
+        validateAttributes();
+
+        AntLogger logger = new AntLogger(this);
+        CayenneGeneratorMapLoaderAction loadAction = new CayenneGeneratorMapLoaderAction();
+
+        loadAction.setMainDataMapFile(map);
+        loadAction.setAdditionalDataMapFiles(additionalMaps);
+
+        CayenneGeneratorEntityFilterAction filterAction = new CayenneGeneratorEntityFilterAction();
+        filterAction.setClient(client);
+        filterAction.setNameFilter(NamePatternMatcher.build(logger, includeEntitiesPattern, excludeEntitiesPattern));
+
+        try {
+
+            DataMap dataMap = loadAction.getMainDataMap();
+
+            ClassGenerationAction generatorAction = createGeneratorAction();
+            generatorAction.setLogger(logger);
+            generatorAction.setTimestamp(map.lastModified());
+            generatorAction.setDataMap(dataMap);
+            generatorAction.addEntities(filterAction.getFilteredEntities(dataMap));
+            generatorAction.addEmbeddables(filterAction.getFilteredEmbeddables(dataMap));
+            generatorAction.addQueries(dataMap.getQueryDescriptors());
+            generatorAction.execute();
+        }
+        catch (Exception e) {
+            throw new BuildException(e);
+        }
+    }
+
+    /**
+     * Validates attributes that are not related to internal DefaultClassGenerator. Throws
+     * BuildException if attributes are invalid.
+     */
+    protected void validateAttributes() throws BuildException {
+        if (map == null && this.getProject() == null) {
+            throw new BuildException("either 'map' or 'project' is required.");
+        }
+    }
+
+    /**
+     * Sets the map.
+     * 
+     * @param map The map to set
+     */
+    public void setMap(File map) {
+        this.map = map;
+    }
+
+    /**
+     * Sets the additional DataMaps.
+     * 
+     * @param additionalMapsPath The additional DataMaps to set
+     */
+    public void setAdditionalMaps(Path additionalMapsPath) {
+        String additionalMapFilenames[] = additionalMapsPath.list();
+        this.additionalMaps = new File[additionalMapFilenames.length];
+
+        for (int i = 0; i < additionalMapFilenames.length; i++) {
+            additionalMaps[i] = new File(additionalMapFilenames[i]);
+        }
+    }
+
+    /**
+     * Sets the destDir.
+     */
+    public void setDestDir(File destDir) {
+        this.destDir = destDir;
+    }
+
+    /**
+     * Sets <code>overwrite</code> property.
+     */
+    public void setOverwrite(boolean overwrite) {
+        this.overwrite = overwrite;
+    }
+
+    /**
+     * Sets <code>makepairs</code> property.
+     */
+    public void setMakepairs(boolean makepairs) {
+        this.makepairs = makepairs;
+    }
+
+    /**
+     * Sets <code>template</code> property.
+     */
+    public void setTemplate(String template) {
+        this.template = template;
+    }
+
+    /**
+     * Sets <code>supertemplate</code> property.
+     */
+    public void setSupertemplate(String supertemplate) {
+        this.supertemplate = supertemplate;
+    }
+
+    /**
+     * Sets <code>querytemplate</code> property.
+     */
+    public void setQueryTemplate(String querytemplate) {
+        this.querytemplate = querytemplate;
+    }
+
+    /**
+     * Sets <code>querysupertemplate</code> property.
+     */
+    public void setQuerySupertemplate(String querysupertemplate) {
+        this.querysupertemplate = querysupertemplate;
+    }
+
+    /**
+     * Sets <code>usepkgpath</code> property.
+     */
+    public void setUsepkgpath(boolean usepkgpath) {
+        this.usepkgpath = usepkgpath;
+    }
+
+    /**
+     * Sets <code>superpkg</code> property.
+     */
+    public void setSuperpkg(String superpkg) {
+        this.superpkg = superpkg;
+    }
+
+    /**
+     * Sets <code>client</code> property.
+     */
+    public void setClient(boolean client) {
+        this.client = client;
+    }
+
+    /**
+     * Sets <code>encoding</code> property that allows to generate files using non-default
+     * encoding.
+     */
+    public void setEncoding(String encoding) {
+        this.encoding = encoding;
+    }
+
+    /**
+     * Sets <code>excludeEntitiesPattern</code> property.
+     */
+    public void setExcludeEntities(String excludeEntitiesPattern) {
+        this.excludeEntitiesPattern = excludeEntitiesPattern;
+    }
+
+    /**
+     * Sets <code>includeEntitiesPattern</code> property.
+     */
+    public void setIncludeEntities(String includeEntitiesPattern) {
+        this.includeEntitiesPattern = includeEntitiesPattern;
+    }
+
+    /**
+     * Sets <code>outputPattern</code> property.
+     */
+    public void setOutputPattern(String outputPattern) {
+        this.outputPattern = outputPattern;
+    }
+
+    /**
+     * Sets <code>mode</code> property.
+     */
+    public void setMode(String mode) {
+        this.mode = mode;
+    }
+
+    /**
+     * Sets <code>createpropertynames</code> property.
+     */
+    public void setCreatepropertynames(boolean createpropertynames) {
+        this.createpropertynames = createpropertynames;
+    }
+
+    public void setEmbeddabletemplate(String embeddabletemplate) {
+        this.embeddabletemplate = embeddabletemplate;
+    }
+
+    public void setEmbeddablesupertemplate(String embeddablesupertemplate) {
+        this.embeddablesupertemplate = embeddablesupertemplate;
+    }
+
+    /**
+     * Provides a <code>VPPConfig</code> object to configure. (Written with createConfig()
+     * instead of addConfig() to avoid run-time dependency on VPP).
+     */
+    public Object createConfig() {
+        this.vppConfig = new VPPConfig();
+        return this.vppConfig;
+    }
+
+    /**
+     * If no VppConfig element specified, use the default one.
+     */
+    private void initializeVppConfig() {
+        if (vppConfig == null) {
+            vppConfig = VPPConfig.getDefaultConfig(getProject());
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/cayenne/blob/c63b6be2/cayenne-ant/src/main/java/org/apache/cayenne/tools/CayenneTask.java
----------------------------------------------------------------------
diff --git a/cayenne-ant/src/main/java/org/apache/cayenne/tools/CayenneTask.java b/cayenne-ant/src/main/java/org/apache/cayenne/tools/CayenneTask.java
new file mode 100644
index 0000000..2bff0e3
--- /dev/null
+++ b/cayenne-ant/src/main/java/org/apache/cayenne/tools/CayenneTask.java
@@ -0,0 +1,161 @@
+/*****************************************************************
+ *   Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ ****************************************************************/
+
+package org.apache.cayenne.tools;
+
+import java.io.File;
+
+import javax.sql.DataSource;
+
+import org.apache.cayenne.configuration.DataNodeDescriptor;
+import org.apache.cayenne.configuration.server.DbAdapterFactory;
+import org.apache.cayenne.dba.DbAdapter;
+import org.apache.cayenne.di.Injector;
+import org.apache.cayenne.map.DataMap;
+import org.apache.cayenne.map.MapLoader;
+import org.apache.tools.ant.Task;
+import org.apache.tools.ant.types.Path;
+import org.apache.tools.ant.types.Reference;
+import org.xml.sax.InputSource;
+
+/**
+ * Base task for all Cayenne ant tasks, providing support for common
+ * configuration items.
+ * 
+ * @since 1.2
+ */
+public abstract class CayenneTask extends Task {
+    protected Path classpath;
+
+    protected String adapter;
+    protected File map;
+    protected String driver;
+    protected String url;
+    protected String userName;
+    protected String password;
+
+    /**
+     * Sets the classpath used by the task.
+     * 
+     * @param path
+     *            The classpath to set.
+     */
+    public void setClasspath(Path path) {
+        createClasspath().append(path);
+    }
+
+    /**
+     * Sets the classpath reference used by the task.
+     * 
+     * @param reference
+     *            The classpath reference to set.
+     */
+    public void setClasspathRef(Reference reference) {
+        createClasspath().setRefid(reference);
+    }
+
+    /**
+     * Convenience method for creating a classpath instance to be used for the
+     * task.
+     * 
+     * @return The new classpath.
+     */
+    private Path createClasspath() {
+        if (null == classpath) {
+            classpath = new Path(getProject());
+        }
+
+        return classpath.createPath();
+    }
+
+    /**
+     * Sets the map.
+     * 
+     * @param map
+     *            The map to set
+     */
+    public void setMap(File map) {
+        this.map = map;
+    }
+
+    /**
+     * Sets the db adapter.
+     * 
+     * @param adapter
+     *            The db adapter to set.
+     */
+    public void setAdapter(String adapter) {
+        this.adapter = adapter;
+    }
+
+    /**
+     * Sets the JDBC driver used to connect to the database server.
+     * 
+     * @param driver
+     *            The driver to set.
+     */
+    public void setDriver(String driver) {
+        this.driver = driver;
+    }
+
+    /**
+     * Sets the JDBC URL used to connect to the database server.
+     * 
+     * @param url
+     *            The url to set.
+     */
+    public void setUrl(String url) {
+        this.url = url;
+    }
+
+    /**
+     * Sets the username used to connect to the database server.
+     */
+    public void setUserName(String username) {
+        this.userName = username;
+    }
+
+    /**
+     * Sets the password used to connect to the database server.
+     * 
+     * @param password
+     *            The password to set.
+     */
+    public void setPassword(String password) {
+        this.password = password;
+    }
+
+    /** Loads and returns DataMap based on <code>map</code> attribute. */
+    protected DataMap loadDataMap() throws Exception {
+        InputSource in = new InputSource(map.getCanonicalPath());
+        return new MapLoader().loadDataMap(in);
+    }
+
+    protected DbAdapter getAdapter(Injector injector, DataSource dataSource)
+            throws Exception {
+
+        DbAdapterFactory adapterFactory = injector
+                .getInstance(DbAdapterFactory.class);
+
+        DataNodeDescriptor nodeDescriptor = new DataNodeDescriptor();
+        nodeDescriptor.setAdapterType(adapter);
+
+        return adapterFactory.createAdapter(nodeDescriptor, dataSource);
+    }
+}

http://git-wip-us.apache.org/repos/asf/cayenne/blob/c63b6be2/cayenne-ant/src/main/java/org/apache/cayenne/tools/DataPortTask.java
----------------------------------------------------------------------
diff --git a/cayenne-ant/src/main/java/org/apache/cayenne/tools/DataPortTask.java b/cayenne-ant/src/main/java/org/apache/cayenne/tools/DataPortTask.java
new file mode 100644
index 0000000..4b24035
--- /dev/null
+++ b/cayenne-ant/src/main/java/org/apache/cayenne/tools/DataPortTask.java
@@ -0,0 +1,213 @@
+/*****************************************************************
+ *   Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ ****************************************************************/
+
+package org.apache.cayenne.tools;
+
+import org.apache.cayenne.access.DataDomain;
+import org.apache.cayenne.access.DataNode;
+import org.apache.cayenne.access.DataPort;
+import org.apache.cayenne.configuration.Constants;
+import org.apache.cayenne.configuration.server.ServerRuntime;
+import org.apache.cayenne.di.Binder;
+import org.apache.cayenne.di.Key;
+import org.apache.cayenne.di.Module;
+import org.apache.cayenne.map.DataMap;
+import org.apache.cayenne.map.DbEntity;
+import org.apache.cayenne.resource.FilesystemResourceLocator;
+import org.apache.cayenne.resource.ResourceLocator;
+import org.apache.cayenne.util.Util;
+import org.apache.tools.ant.BuildException;
+import org.apache.tools.ant.Project;
+
+import java.io.File;
+import java.util.Collection;
+import java.util.HashSet;
+
+/**
+ * A "cdataport" Ant task implementing a frontend to DataPort allowing porting
+ * database data using Ant build scripts.
+ * 
+ * @since 1.2: Prior to 1.2 DataPort classes were a part of cayenne-examples
+ *        package.
+ * @deprecated since 4.0
+ */
+@Deprecated
+public class DataPortTask extends CayenneTask {
+
+    protected File projectFile;
+    protected String maps;
+    protected String srcNode;
+    protected String destNode;
+    protected String includeTables;
+    protected String excludeTables;
+    protected boolean cleanDest = true;
+
+    public DataPortTask() {
+        // set defaults
+        this.cleanDest = true;
+    }
+
+    @Override
+    public void execute() throws BuildException {
+
+        log("*** 'cdataport' task is deprecated and will be removed after 4.0",
+                Project.MSG_WARN);
+
+        validateParameters();
+
+        String projectFileLocation = projectFile.getName();
+        Module dataPortModule = new Module() {
+
+            public void configure(Binder binder) {
+                FilesystemResourceLocator filesystemResourceLocator = new FilesystemResourceLocator(projectFile);
+                binder.bind(ResourceLocator.class).toInstance(filesystemResourceLocator);
+                binder.bind(Key.get(ResourceLocator.class, Constants.SERVER_RESOURCE_LOCATOR))
+                        .toInstance(filesystemResourceLocator);
+            }
+        };
+
+        ServerRuntime runtime = new ServerRuntime(projectFileLocation,
+                dataPortModule);
+        DataDomain domain;
+
+        ClassLoader threadContextClassLoader = Thread.currentThread()
+                .getContextClassLoader();
+        try {
+            // need to set context class loader so that cayenne can find jdbc
+            // driver and
+            // PasswordEncoder
+            // TODO: andrus 04/11/2010 is this still relevant in 3.1?
+            Thread.currentThread().setContextClassLoader(
+                    getClass().getClassLoader());
+
+            domain = runtime.getDataDomain();
+        } catch (Exception ex) {
+            throw new BuildException(
+                    "Error loading Cayenne configuration from " + projectFile,
+                    ex);
+        } finally {
+            // set back to original ClassLoader
+            Thread.currentThread().setContextClassLoader(
+                    threadContextClassLoader);
+        }
+
+        // perform project validation
+        DataNode source = domain.getDataNode(srcNode);
+        if (source == null) {
+            throw new BuildException("srcNode not found in the project: "
+                    + srcNode);
+        }
+
+        DataNode destination = domain.getDataNode(destNode);
+        if (destination == null) {
+            throw new BuildException("destNode not found in the project: "
+                    + destNode);
+        }
+
+        log("Porting from '" + srcNode + "' to '" + destNode + "'.");
+
+        AntDataPortDelegate portDelegate = new AntDataPortDelegate(this, maps,
+                includeTables, excludeTables);
+        DataPort dataPort = new DataPort(portDelegate);
+        dataPort.setEntities(getAllEntities(source, destination));
+        dataPort.setCleaningDestination(cleanDest);
+        dataPort.setSourceNode(source);
+        dataPort.setDestinationNode(destination);
+
+        try {
+            dataPort.execute();
+        } catch (Exception e) {
+            Throwable topOfStack = Util.unwindException(e);
+            throw new BuildException("Error porting data: "
+                    + topOfStack.getMessage(), topOfStack);
+        }
+    }
+
+    protected Collection<DbEntity> getAllEntities(DataNode source,
+            DataNode target) {
+        // use a set to exclude duplicates, though a valid project will probably
+        // have
+        // none...
+        Collection<DbEntity> allEntities = new HashSet<DbEntity>();
+
+        for (DataMap map : source.getDataMaps()) {
+            allEntities.addAll(map.getDbEntities());
+        }
+
+        for (DataMap map : target.getDataMaps()) {
+            allEntities.addAll(map.getDbEntities());
+        }
+
+        log("Number of entities: " + allEntities.size(), Project.MSG_VERBOSE);
+
+        if (allEntities.size() == 0) {
+            log("No entities found for either source or target.");
+        }
+        return allEntities;
+    }
+
+    protected void validateParameters() throws BuildException {
+        if (projectFile == null) {
+            throw new BuildException(
+                    "Required 'projectFile' parameter is missing.");
+        }
+
+        if (!projectFile.exists()) {
+            throw new BuildException("'projectFile' does not exist: "
+                    + projectFile);
+        }
+
+        if (srcNode == null) {
+            throw new BuildException("Required 'srcNode' parameter is missing.");
+        }
+
+        if (destNode == null) {
+            throw new BuildException(
+                    "Required 'destNode' parameter is missing.");
+        }
+    }
+
+    public void setDestNode(String destNode) {
+        this.destNode = destNode;
+    }
+
+    public void setExcludeTables(String excludeTables) {
+        this.excludeTables = excludeTables;
+    }
+
+    public void setIncludeTables(String includeTables) {
+        this.includeTables = includeTables;
+    }
+
+    public void setMaps(String maps) {
+        this.maps = maps;
+    }
+
+    public void setProjectFile(File projectFile) {
+        this.projectFile = projectFile;
+    }
+
+    public void setSrcNode(String srcNode) {
+        this.srcNode = srcNode;
+    }
+
+    public void setCleanDest(boolean flag) {
+        this.cleanDest = flag;
+    }
+}

http://git-wip-us.apache.org/repos/asf/cayenne/blob/c63b6be2/cayenne-ant/src/main/java/org/apache/cayenne/tools/DbGeneratorTask.java
----------------------------------------------------------------------
diff --git a/cayenne-ant/src/main/java/org/apache/cayenne/tools/DbGeneratorTask.java b/cayenne-ant/src/main/java/org/apache/cayenne/tools/DbGeneratorTask.java
new file mode 100644
index 0000000..ce2e574
--- /dev/null
+++ b/cayenne-ant/src/main/java/org/apache/cayenne/tools/DbGeneratorTask.java
@@ -0,0 +1,155 @@
+/*****************************************************************
+ *   Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ ****************************************************************/
+
+package org.apache.cayenne.tools;
+
+import org.apache.cayenne.access.DbGenerator;
+import org.apache.cayenne.datasource.DriverDataSource;
+import org.apache.cayenne.dba.DbAdapter;
+import org.apache.cayenne.dbsync.DbSyncModule;
+import org.apache.cayenne.di.DIBootstrap;
+import org.apache.cayenne.di.Injector;
+import org.apache.cayenne.log.NoopJdbcEventLogger;
+import org.apache.cayenne.map.DataMap;
+import org.apache.cayenne.map.DbEntity;
+import org.apache.cayenne.dbsync.reverse.configuration.ToolsModule;
+import org.apache.cayenne.util.Util;
+import org.apache.commons.logging.Log;
+import org.apache.tools.ant.BuildException;
+import org.apache.tools.ant.Project;
+
+import java.sql.Driver;
+import java.util.Collections;
+
+/**
+ * An Ant Task that is a frontend to Cayenne DbGenerator allowing schema
+ * generation from DataMap using Ant.
+ * 
+ * @since 1.2
+ */
+// TODO: support classpath attribute for loading the driver
+public class DbGeneratorTask extends CayenneTask {
+
+	// DbGenerator options... setup defaults similar to DbGenerator itself:
+	// all DROP set to false, all CREATE - to true
+	protected boolean dropTables;
+	protected boolean dropPK;
+	protected boolean createTables = true;
+	protected boolean createPK = true;
+	protected boolean createFK = true;
+
+	@Override
+	public void execute() {
+
+		Log logger = new AntLogger(this);
+
+		log(String.format("connection settings - [driver: %s, url: %s, username: %s]", driver, url, userName),
+				Project.MSG_VERBOSE);
+
+		log(String.format(
+				"generator options - [dropTables: %s, dropPK: %s, createTables: %s, createPK: %s, createFK: %s]",
+				dropTables, dropPK, createTables, createPK, createFK), Project.MSG_VERBOSE);
+
+		validateAttributes();
+
+		ClassLoader loader = null;
+		Injector injector = DIBootstrap.createInjector(new DbSyncModule(), new ToolsModule(logger));
+		try {
+			loader = Thread.currentThread().getContextClassLoader();
+			Thread.currentThread().setContextClassLoader(DbGeneratorTask.class.getClassLoader());
+
+			// Load the data map and run the db generator.
+			DataMap dataMap = loadDataMap();
+
+			// load driver taking custom CLASSPATH into account...
+			DriverDataSource dataSource = new DriverDataSource((Driver) Class.forName(driver).newInstance(), url,
+					userName, password);
+
+			DbAdapter adapter = getAdapter(injector, dataSource);
+
+			DbGenerator generator = new DbGenerator(adapter, dataMap, Collections.<DbEntity> emptyList(), null,
+					NoopJdbcEventLogger.getInstance());
+			generator.setShouldCreateFKConstraints(createFK);
+			generator.setShouldCreatePKSupport(createPK);
+			generator.setShouldCreateTables(createTables);
+			generator.setShouldDropPKSupport(dropPK);
+			generator.setShouldDropTables(dropTables);
+
+			generator.runGenerator(dataSource);
+		} catch (Exception ex) {
+			Throwable th = Util.unwindException(ex);
+
+			String message = "Error generating database";
+
+			if (th.getLocalizedMessage() != null) {
+				message += ": " + th.getLocalizedMessage();
+			}
+
+			log(message, Project.MSG_ERR);
+			throw new BuildException(message, th);
+		} finally {
+			Thread.currentThread().setContextClassLoader(loader);
+			injector.shutdown();
+		}
+	}
+
+	/**
+	 * Validates attributes that are not related to internal
+	 * DefaultClassGenerator. Throws BuildException if attributes are invalid.
+	 */
+	protected void validateAttributes() throws BuildException {
+		StringBuilder error = new StringBuilder("");
+
+		if (map == null) {
+			error.append("The 'map' attribute must be set.\n");
+		}
+
+		if (driver == null) {
+			error.append("The 'driver' attribute must be set.\n");
+		}
+
+		if (url == null) {
+			error.append("The 'adapter' attribute must be set.\n");
+		}
+
+		if (error.length() > 0) {
+			throw new BuildException(error.toString());
+		}
+	}
+
+	public void setCreateFK(boolean createFK) {
+		this.createFK = createFK;
+	}
+
+	public void setCreatePK(boolean createPK) {
+		this.createPK = createPK;
+	}
+
+	public void setCreateTables(boolean createTables) {
+		this.createTables = createTables;
+	}
+
+	public void setDropPK(boolean dropPK) {
+		this.dropPK = dropPK;
+	}
+
+	public void setDropTables(boolean dropTables) {
+		this.dropTables = dropTables;
+	}
+}

http://git-wip-us.apache.org/repos/asf/cayenne/blob/c63b6be2/cayenne-ant/src/main/java/org/apache/cayenne/tools/DbImporterTask.java
----------------------------------------------------------------------
diff --git a/cayenne-ant/src/main/java/org/apache/cayenne/tools/DbImporterTask.java b/cayenne-ant/src/main/java/org/apache/cayenne/tools/DbImporterTask.java
new file mode 100644
index 0000000..6c939c1
--- /dev/null
+++ b/cayenne-ant/src/main/java/org/apache/cayenne/tools/DbImporterTask.java
@@ -0,0 +1,241 @@
+/*****************************************************************
+ *   Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ ****************************************************************/
+package org.apache.cayenne.tools;
+
+import org.apache.cayenne.conn.DataSourceInfo;
+import org.apache.cayenne.dbsync.DbSyncModule;
+import org.apache.cayenne.dbsync.naming.DefaultObjectNameGenerator;
+import org.apache.cayenne.dbsync.reverse.configuration.ToolsModule;
+import org.apache.cayenne.dbsync.reverse.dbimport.Catalog;
+import org.apache.cayenne.dbsync.reverse.dbimport.DbImportAction;
+import org.apache.cayenne.dbsync.reverse.dbimport.DbImportConfigurationValidator;
+import org.apache.cayenne.dbsync.reverse.dbimport.DbImportConfiguration;
+import org.apache.cayenne.dbsync.reverse.dbimport.DbImportModule;
+import org.apache.cayenne.dbsync.reverse.dbimport.ExcludeColumn;
+import org.apache.cayenne.dbsync.reverse.dbimport.ExcludeProcedure;
+import org.apache.cayenne.dbsync.reverse.dbimport.ExcludeTable;
+import org.apache.cayenne.dbsync.reverse.dbimport.IncludeColumn;
+import org.apache.cayenne.dbsync.reverse.dbimport.IncludeProcedure;
+import org.apache.cayenne.dbsync.reverse.dbimport.IncludeTable;
+import org.apache.cayenne.dbsync.reverse.dbimport.ReverseEngineering;
+import org.apache.cayenne.dbsync.reverse.dbimport.Schema;
+import org.apache.cayenne.dbsync.reverse.filters.FiltersConfigBuilder;
+import org.apache.cayenne.di.DIBootstrap;
+import org.apache.cayenne.di.Injector;
+import org.apache.cayenne.util.Util;
+import org.apache.commons.logging.Log;
+import org.apache.tools.ant.BuildException;
+import org.apache.tools.ant.Project;
+import org.apache.tools.ant.Task;
+
+import java.io.File;
+
+public class DbImporterTask extends Task {
+
+    private final DbImportConfiguration config;
+    private ReverseEngineering reverseEngineering;
+
+    public DbImporterTask() {
+        this.config = new DbImportConfiguration();
+        this.config.setUsePrimitives(true);
+        this.config.setNamingStrategy(DefaultObjectNameGenerator.class.getName());
+
+        // reverse engineering config is flattened into task...
+        this.reverseEngineering = new ReverseEngineering();
+    }
+
+    public void addIncludeColumn(IncludeColumn includeColumn) {
+        reverseEngineering.addIncludeColumn(includeColumn);
+    }
+
+    public void addExcludeColumn(ExcludeColumn excludeColumn) {
+        reverseEngineering.addExcludeColumn(excludeColumn);
+    }
+
+    public void addIncludeTable(IncludeTable includeTable) {
+        reverseEngineering.addIncludeTable(includeTable);
+    }
+
+    public void addExcludeTable(ExcludeTable excludeTable) {
+        reverseEngineering.addExcludeTable(excludeTable);
+    }
+
+    public void addIncludeProcedure(IncludeProcedure includeProcedure) {
+        reverseEngineering.addIncludeProcedure(includeProcedure);
+    }
+
+    public void addExcludeProcedure(ExcludeProcedure excludeProcedure) {
+        reverseEngineering.addExcludeProcedure(excludeProcedure);
+    }
+
+    public void setSkipRelationshipsLoading(boolean skipRelationshipsLoading) {
+        reverseEngineering.setSkipRelationshipsLoading(skipRelationshipsLoading);
+    }
+
+    public void setSkipPrimaryKeyLoading(boolean skipPrimaryKeyLoading) {
+        reverseEngineering.setSkipPrimaryKeyLoading(skipPrimaryKeyLoading);
+    }
+
+    public void addConfiguredTableType(AntTableType type) {
+        reverseEngineering.addTableType(type.getName());
+    }
+
+    public void addConfiguredSchema(Schema schema) {
+        reverseEngineering.addSchema(schema);
+    }
+
+    public void addCatalog(Catalog catalog) {
+        reverseEngineering.addCatalog(catalog);
+    }
+
+    @Override
+    public void execute() {
+        config.setFiltersConfig(new FiltersConfigBuilder(reverseEngineering).build());
+        validateAttributes();
+
+        Log logger = new AntLogger(this);
+        config.setLogger(logger);
+        config.setSkipRelationshipsLoading(reverseEngineering.getSkipRelationshipsLoading());
+        config.setSkipPrimaryKeyLoading(reverseEngineering.getSkipPrimaryKeyLoading());
+        config.setTableTypes(reverseEngineering.getTableTypes());
+
+        Injector injector = DIBootstrap.createInjector(new DbSyncModule(), new ToolsModule(logger), new DbImportModule());
+        DbImportConfigurationValidator validator = new DbImportConfigurationValidator(reverseEngineering, config, injector);
+        try {
+            validator.validate();
+        } catch (Exception ex) {
+            throw new BuildException(ex.getMessage(), ex);
+        }
+
+        try {
+            injector.getInstance(DbImportAction.class).execute(config);
+        } catch (Exception ex) {
+            Throwable th = Util.unwindException(ex);
+
+            String message = "Error importing database schema";
+
+            if (th.getLocalizedMessage() != null) {
+                message += ": " + th.getLocalizedMessage();
+            }
+
+            log(message, Project.MSG_ERR);
+            throw new BuildException(message, th);
+        } finally {
+            injector.shutdown();
+        }
+    }
+
+    /**
+     * Validates attributes that are not related to internal
+     * DefaultClassGenerator. Throws BuildException if attributes are invalid.
+     */
+    protected void validateAttributes() throws BuildException {
+        StringBuilder error = new StringBuilder("");
+
+        if (config.getTargetDataMap() == null) {
+            error.append("The 'map' attribute must be set.\n");
+        }
+
+        DataSourceInfo dataSourceInfo = config.getDataSourceInfo();
+        if (dataSourceInfo.getJdbcDriver() == null) {
+            error.append("The 'driver' attribute must be set.\n");
+        }
+
+        if (dataSourceInfo.getDataSourceUrl() == null) {
+            error.append("The 'url' attribute must be set.\n");
+        }
+
+        if (error.length() > 0) {
+            throw new BuildException(error.toString());
+        }
+    }
+
+    /**
+     * @since 4.0
+     */
+    public void setDefaultPackage(String defaultPackage) {
+        config.setDefaultPackage(defaultPackage);
+    }
+
+    /**
+     * @since 4.0
+     */
+    public void setMeaningfulPkTables(String meaningfulPkTables) {
+        config.setMeaningfulPkTables(meaningfulPkTables);
+    }
+
+    public void setNamingStrategy(String namingStrategy) {
+        config.setNamingStrategy(namingStrategy);
+    }
+
+    /**
+     * @since 4.0
+     */
+    public void setStripFromTableNames(String pattern) {
+        config.setStripFromTableNames(pattern);
+    }
+
+    public void setAdapter(String adapter) {
+        config.setAdapter(adapter);
+    }
+
+    public void setDriver(String driver) {
+        config.setDriver(driver);
+    }
+
+    public void setPassword(String password) {
+        config.setPassword(password);
+    }
+
+    public void setUrl(String url) {
+        config.setUrl(url);
+    }
+
+    public void setUserName(String username) {
+        config.setUsername(username);
+    }
+
+    public void setUsePrimitives(boolean flag) {
+        config.setUsePrimitives(flag);
+    }
+
+    public void setForceDataMapCatalog(boolean flag) {
+        config.setForceDataMapCatalog(flag);
+    }
+
+    public void setForceDataMapSchema(boolean flag) {
+        config.setForceDataMapSchema(flag);
+    }
+
+    public ReverseEngineering getReverseEngineering() {
+        return reverseEngineering;
+    }
+
+    public File getMap() {
+        return config.getTargetDataMap();
+    }
+
+    public void setMap(File map) {
+        config.setTargetDataMap(map);
+    }
+
+    public DbImportConfiguration toParameters() {
+        return config;
+    }
+}

http://git-wip-us.apache.org/repos/asf/cayenne/blob/c63b6be2/cayenne-ant/src/main/java/org/apache/cayenne/tools/package.html
----------------------------------------------------------------------
diff --git a/cayenne-ant/src/main/java/org/apache/cayenne/tools/package.html b/cayenne-ant/src/main/java/org/apache/cayenne/tools/package.html
new file mode 100644
index 0000000..f25bcbe
--- /dev/null
+++ b/cayenne-ant/src/main/java/org/apache/cayenne/tools/package.html
@@ -0,0 +1,23 @@
+<!--
+   Licensed to the Apache Software Foundation (ASF) under one
+   or more contributor license agreements.  See the NOTICE file
+   distributed with this work for additional information
+   regarding copyright ownership.  The ASF licenses this file
+   to you under the Apache License, Version 2.0 (the
+   "License"); you may not use this file except in compliance
+   with the License.  You may obtain a copy of the License at
+
+     http://www.apache.org/licenses/LICENSE-2.0
+
+   Unless required by applicable law or agreed to in writing,
+   software distributed under the License is distributed on an
+   "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+   KIND, either express or implied.  See the License for the
+   specific language governing permissions and limitations
+   under the License.
+-->
+<html>
+<body>
+Command line tools and Ant tasks. 
+</body>
+</html>

http://git-wip-us.apache.org/repos/asf/cayenne/blob/c63b6be2/cayenne-ant/src/main/resources/org/apache/cayenne/tools/antlib.xml
----------------------------------------------------------------------
diff --git a/cayenne-ant/src/main/resources/org/apache/cayenne/tools/antlib.xml b/cayenne-ant/src/main/resources/org/apache/cayenne/tools/antlib.xml
new file mode 100644
index 0000000..bfebaf6
--- /dev/null
+++ b/cayenne-ant/src/main/resources/org/apache/cayenne/tools/antlib.xml
@@ -0,0 +1,25 @@
+<!--
+   Licensed to the Apache Software Foundation (ASF) under one
+   or more contributor license agreements.  See the NOTICE file
+   distributed with this work for additional information
+   regarding copyright ownership.  The ASF licenses this file
+   to you under the Apache License, Version 2.0 (the
+   "License"); you may not use this file except in compliance
+   with the License.  You may obtain a copy of the License at
+ 
+     http://www.apache.org/licenses/LICENSE-2.0
+ 
+   Unless required by applicable law or agreed to in writing,
+   software distributed under the License is distributed on an
+   "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+   KIND, either express or implied.  See the License for the
+   specific language governing permissions and limitations
+   under the License.
+-->
+
+<antlib>
+  <taskdef name="cgen" classname="org.apache.cayenne.tools.CayenneGeneratorTask"/>
+  <taskdef name="cdbgen" classname="org.apache.cayenne.tools.DbGeneratorTask"/>
+  <taskdef name="cdataport" classname="org.apache.cayenne.tools.DataPortTask"/>
+  <taskdef name="cdbimport" classname="org.apache.cayenne.tools.DbImporterTask"/>
+</antlib>

http://git-wip-us.apache.org/repos/asf/cayenne/blob/c63b6be2/cayenne-ant/src/test/java/org/apache/cayenne/tools/AntDataPortDelegateTest.java
----------------------------------------------------------------------
diff --git a/cayenne-ant/src/test/java/org/apache/cayenne/tools/AntDataPortDelegateTest.java b/cayenne-ant/src/test/java/org/apache/cayenne/tools/AntDataPortDelegateTest.java
new file mode 100644
index 0000000..584d4c8
--- /dev/null
+++ b/cayenne-ant/src/test/java/org/apache/cayenne/tools/AntDataPortDelegateTest.java
@@ -0,0 +1,53 @@
+/*****************************************************************
+ *   Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ ****************************************************************/
+
+package org.apache.cayenne.tools;
+
+import org.apache.cayenne.map.DataMap;
+import org.junit.Test;
+
+import java.util.regex.Pattern;
+
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
+@Deprecated
+public class AntDataPortDelegateTest {
+
+    @Test
+    public void testPassedDataMapFilter() {
+        AntDataPortDelegate delegate = new AntDataPortDelegate();
+
+        // filtering should be done based on map name
+
+        DataMap map = new DataMap();
+        assertTrue(delegate.passedDataMapFilter(map));
+
+        map.setName("A");
+        assertTrue(delegate.passedDataMapFilter(map));
+
+        delegate.mapFilters = new Pattern[] {
+            Pattern.compile("B")
+        };
+        assertFalse(delegate.passedDataMapFilter(map));
+
+        map.setName("BBBB");
+        assertTrue(delegate.passedDataMapFilter(map));
+    }
+}

http://git-wip-us.apache.org/repos/asf/cayenne/blob/c63b6be2/cayenne-ant/src/test/java/org/apache/cayenne/tools/CayenneGeneratorTaskCrossMapRelationshipsTest.java
----------------------------------------------------------------------
diff --git a/cayenne-ant/src/test/java/org/apache/cayenne/tools/CayenneGeneratorTaskCrossMapRelationshipsTest.java b/cayenne-ant/src/test/java/org/apache/cayenne/tools/CayenneGeneratorTaskCrossMapRelationshipsTest.java
new file mode 100644
index 0000000..40877b8
--- /dev/null
+++ b/cayenne-ant/src/test/java/org/apache/cayenne/tools/CayenneGeneratorTaskCrossMapRelationshipsTest.java
@@ -0,0 +1,157 @@
+/*****************************************************************
+ *   Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ ****************************************************************/
+
+package org.apache.cayenne.tools;
+
+import org.apache.cayenne.test.file.FileUtil;
+import org.apache.cayenne.test.resource.ResourceUtil;
+import org.apache.tools.ant.Location;
+import org.apache.tools.ant.Project;
+import org.apache.tools.ant.types.FileList;
+import org.apache.tools.ant.types.Path;
+import org.junit.Test;
+
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.InputStreamReader;
+import java.util.regex.Pattern;
+
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
+public class CayenneGeneratorTaskCrossMapRelationshipsTest {
+
+	/**
+	 * Tests pairs generation with a cross-DataMap relationship.
+	 */
+	@Test
+	public void testCrossDataMapRelationships() throws Exception {
+
+		CayenneGeneratorTask task = new CayenneGeneratorTask();
+		task.setProject(new Project());
+		task.setTaskName("Test");
+		task.setLocation(Location.UNKNOWN_LOCATION);
+
+		// prepare destination directory
+
+		File destDir = new File(FileUtil.baseTestDirectory(), "cgen12");
+		// prepare destination directory
+		if (!destDir.exists()) {
+			assertTrue(destDir.mkdirs());
+		}
+
+		File map = new File(destDir, "cgen-dependent.map.xml");
+		ResourceUtil.copyResourceToFile("org/apache/cayenne/tools/cgen-dependent.map.xml", map);
+
+		File additionalMaps[] = new File[1];
+		additionalMaps[0] = new File(destDir, "cgen.map.xml");
+		ResourceUtil.copyResourceToFile("org/apache/cayenne/tools/cgen.map.xml", additionalMaps[0]);
+
+		FileList additionalMapsFilelist = new FileList();
+		additionalMapsFilelist.setDir(additionalMaps[0].getParentFile());
+		additionalMapsFilelist.setFiles(additionalMaps[0].getName());
+
+		Path additionalMapsPath = new Path(task.getProject());
+		additionalMapsPath.addFilelist(additionalMapsFilelist);
+
+		// setup task
+		task.setMap(map);
+		task.setAdditionalMaps(additionalMapsPath);
+		task.setMakepairs(true);
+		task.setOverwrite(false);
+		task.setMode("entity");
+		task.setIncludeEntities("MyArtGroup");
+		task.setDestDir(destDir);
+		task.setSuperpkg("org.apache.cayenne.testdo.cgen2.auto");
+		task.setUsepkgpath(true);
+
+		// run task
+		task.execute();
+
+		// check results
+		File a = new File(destDir, convertPath("org/apache/cayenne/testdo/cgen2/MyArtGroup.java"));
+		assertTrue(a.isFile());
+		assertContents(a, "MyArtGroup", "org.apache.cayenne.testdo.cgen2", "_MyArtGroup");
+
+		File _a = new File(destDir, convertPath("org/apache/cayenne/testdo/cgen2/auto/_MyArtGroup.java"));
+		assertTrue(_a.exists());
+		assertContents(_a, "_MyArtGroup", "org.apache.cayenne.testdo.cgen2.auto", "CayenneDataObject");
+		assertContents(_a, "import org.apache.cayenne.testdo.testmap.ArtGroup;");
+		assertContents(_a, " ArtGroup getToParentGroup()");
+		assertContents(_a, "setToParentGroup(ArtGroup toParentGroup)");
+	}
+
+	private String convertPath(String unixPath) {
+		return unixPath.replace('/', File.separatorChar);
+	}
+
+	private void assertContents(File f, String content) throws Exception {
+
+		try (BufferedReader in = new BufferedReader(new InputStreamReader(new FileInputStream(f)));) {
+			String s = null;
+			while ((s = in.readLine()) != null) {
+				if (s.contains(content))
+					return;
+			}
+
+			fail("<" + content + "> not found in " + f.getAbsolutePath() + ".");
+		}
+
+	}
+
+	private void assertContents(File f, String className, String packageName, String extendsName) throws Exception {
+
+		try (BufferedReader in = new BufferedReader(new InputStreamReader(new FileInputStream(f)));) {
+			assertPackage(in, packageName);
+			assertClass(in, className, extendsName);
+		}
+	}
+
+	private void assertPackage(BufferedReader in, String packageName) throws Exception {
+
+		String s = null;
+		while ((s = in.readLine()) != null) {
+
+			if (Pattern.matches("^package\\s+([^\\s;]+);", s)) {
+				assertTrue(s.contains(packageName));
+				return;
+			}
+		}
+
+		fail("No package declaration found.");
+	}
+
+	private void assertClass(BufferedReader in, String className, String extendsName) throws Exception {
+
+		Pattern classPattern = Pattern.compile("^public\\s+");
+
+		String s = null;
+		while ((s = in.readLine()) != null) {
+			if (classPattern.matcher(s).find()) {
+				assertTrue(s.contains(className));
+				assertTrue(s.contains(extendsName));
+				assertTrue(s.indexOf(className) < s.indexOf(extendsName));
+				return;
+			}
+		}
+
+		fail("No class declaration found.");
+	}
+}


[06/10] cayenne git commit: CAY-2215 split cayenne-tools into cayenne-cgen and cayenne-ant

Posted by nt...@apache.org.
http://git-wip-us.apache.org/repos/asf/cayenne/blob/c63b6be2/cayenne-cgen/src/main/resources/templates/v1_2/datamap-singleclass.vm
----------------------------------------------------------------------
diff --git a/cayenne-cgen/src/main/resources/templates/v1_2/datamap-singleclass.vm b/cayenne-cgen/src/main/resources/templates/v1_2/datamap-singleclass.vm
new file mode 100644
index 0000000..9ad544c
--- /dev/null
+++ b/cayenne-cgen/src/main/resources/templates/v1_2/datamap-singleclass.vm
@@ -0,0 +1,96 @@
+##   Licensed to the Apache Software Foundation (ASF) under one
+##  or more contributor license agreements.  See the NOTICE file
+##  distributed with this work for additional information
+##  regarding copyright ownership.  The ASF licenses this file
+##  to you under the Apache License, Version 2.0 (the
+##  "License"); you may not use this file except in compliance
+##  with the License.  You may obtain a copy of the License at
+##
+##    http://www.apache.org/licenses/LICENSE-2.0
+##
+##  Unless required by applicable law or agreed to in writing,
+##  software distributed under the License is distributed on an
+##  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+##  KIND, either express or implied.  See the License for the
+##  specific language governing permissions and limitations
+##  under the License.
+##
+##Terminology:
+##	Base class - super superclass of entity, ie, org.apache.cayenne.CayenneDataObject or MyBaseClass
+##  Super class - superclass of entity, ie,  org.apache.cayenne.art.auto._Artist
+##	Sub class - class of entity, ie, org.apache.cayenne.art.Artist
+##
+##  Classes available in template
+##    object (duplicated as 'objEntity') - the ObjEntity class: See org.apache.cayenne.map.ObjectEntity
+##    stringUtils - class for string "helper" functions: See org.apache.cayenne.gen.StringUtils
+##    dataMapUtils - class for query "helper" functions: See org.apache.cayenne.gen.DataMapUtils
+##    importUtils - class for import statement management: See org.apache.cayenne.gen.ImportUtils
+##    superClassName
+##    superPackageName
+##    subClassName
+##    subPackageName
+##    baseClassName
+##    basePackageName 
+##
+##
+${importUtils.setPackage($subPackageName)}##
+${importUtils.addReservedType("${subPackageName}.${subClassName}")}##
+${importUtils.addType("${basePackageName}.${baseClassName}")}##
+${importUtils.addType('java.util.List')}
+${importUtils.addType('java.util.Map')}
+${importUtils.addType('java.util.HashMap')}
+${importUtils.addType('org.apache.cayenne.ObjectContext')}
+#foreach( $selectQuery in ${object.SelectQueries})
+${importUtils.addType(${selectQuery.Root.ClassName})}
+#foreach( $parameter in ${dataMapUtils.getParameterNames(${selectQuery})})
+${importUtils.addType(${dataMapUtils.getParameterType(${selectQuery}, ${parameter})})}
+#end
+#end
+${importUtils.generate()}
+
+/**
+ * This class was generated by Cayenne.
+ * It is probably a good idea to avoid changing this class manually,
+ * since it may be overwritten next time code is regenerated.
+ * If you need to make any customizations, please use subclass.
+ */
+public class ${subClassName} {
+#if( ${object.hasQueryNames()})
+#foreach( $qname in ${object.QueryNames})
+
+public static final String ${stringUtils.capitalizedAsConstant($qname)}_QUERYNAME = "$qname";
+#end
+#end
+
+    private static ${subClassName} instance;
+
+    private ${subClassName}() {}
+
+    public ${subClassName} getInstance() {
+      if( instance == null) {
+        instance = new ${subClassName}();
+      }
+      return instance;
+    }
+
+#foreach( $selectQuery in ${object.SelectQueries})
+    public List<${stringUtils.stripPackageName($selectQuery.Root.ClassName)}> perform${dataMapUtils.getQueryMethodName(${selectQuery})}(ObjectContext context #foreach( $parameter in ${dataMapUtils.getParameterNames(${selectQuery})}), ${stringUtils.stripPackageName(${dataMapUtils.getParameterType(${selectQuery}, ${parameter})})} ${parameter} #end) {
+    #if(${dataMapUtils.hasParameters($selectQuery)})
+      String[] parameters = new String[] {
+      #foreach( $parameter in ${dataMapUtils.getParameterNames(${selectQuery})})
+      "${parameter}",
+      #end
+      };
+
+      Object[] values = new Object[] {
+      #foreach( $parameter in ${dataMapUtils.getParameterNames(${selectQuery})})
+      ${parameter},
+      #end
+      };
+    #end
+
+      NamedQuery query = new NamedQuery("${selectQuery.Name}"#if(${dataMapUtils.hasParameters($selectQuery)}), parameters, values#end);
+      return context.performQuery(query);
+    }
+#end
+}

http://git-wip-us.apache.org/repos/asf/cayenne/blob/c63b6be2/cayenne-cgen/src/main/resources/templates/v1_2/datamap-subclass.vm
----------------------------------------------------------------------
diff --git a/cayenne-cgen/src/main/resources/templates/v1_2/datamap-subclass.vm b/cayenne-cgen/src/main/resources/templates/v1_2/datamap-subclass.vm
new file mode 100644
index 0000000..f5e0474
--- /dev/null
+++ b/cayenne-cgen/src/main/resources/templates/v1_2/datamap-subclass.vm
@@ -0,0 +1,47 @@
+##   Licensed to the Apache Software Foundation (ASF) under one
+##  or more contributor license agreements.  See the NOTICE file
+##  distributed with this work for additional information
+##  regarding copyright ownership.  The ASF licenses this file
+##  to you under the Apache License, Version 2.0 (the
+##  "License"); you may not use this file except in compliance
+##  with the License.  You may obtain a copy of the License at
+##
+##    http://www.apache.org/licenses/LICENSE-2.0
+##
+##  Unless required by applicable law or agreed to in writing,
+##  software distributed under the License is distributed on an
+##  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+##  KIND, either express or implied.  See the License for the
+##  specific language governing permissions and limitations
+##  under the License.
+##
+##Terminology:
+##	Base class - super superclass of entity, ie, org.apache.cayenne.CayenneDataObject or MyBaseClass
+##  Super class - superclass of entity, ie,  org.apache.cayenne.art.auto._Artist
+##	Sub class - class of entity, ie, org.apache.cayenne.art.Artist
+##
+##  Classes available in template
+##    stringUtils - class for string "helper" functions: See org.apache.cayenne.gen.StringUtils
+##    dataMapUtils - class for query "helper" functions: See org.apache.cayenne.gen.dataMapUtils
+##    importUtils - class for import statement management: See org.apache.cayenne.gen.ImportUtils
+##
+##
+${importUtils.setPackage($subPackageName)}##
+${importUtils.addReservedType("${subPackageName}.${subClassName}")}##
+${importUtils.addType("${superPackageName}.${superClassName}")}##
+${importUtils.generate()}
+
+public class ${subClassName} extends ${superClassName} {
+
+    private static ${subClassName} instance;
+
+    private ${subClassName}() {}
+
+    public static ${subClassName} getInstance() {
+        if(instance == null) {
+            instance = new ${subClassName}();
+        }
+
+        return instance;
+    }
+}

http://git-wip-us.apache.org/repos/asf/cayenne/blob/c63b6be2/cayenne-cgen/src/main/resources/templates/v1_2/datamap-superclass.vm
----------------------------------------------------------------------
diff --git a/cayenne-cgen/src/main/resources/templates/v1_2/datamap-superclass.vm b/cayenne-cgen/src/main/resources/templates/v1_2/datamap-superclass.vm
new file mode 100644
index 0000000..51c00f3
--- /dev/null
+++ b/cayenne-cgen/src/main/resources/templates/v1_2/datamap-superclass.vm
@@ -0,0 +1,87 @@
+##   Licensed to the Apache Software Foundation (ASF) under one
+##  or more contributor license agreements.  See the NOTICE file
+##  distributed with this work for additional information
+##  regarding copyright ownership.  The ASF licenses this file
+##  to you under the Apache License, Version 2.0 (the
+##  "License"); you may not use this file except in compliance
+##  with the License.  You may obtain a copy of the License at
+##
+##    http://www.apache.org/licenses/LICENSE-2.0
+##
+##  Unless required by applicable law or agreed to in writing,
+##  software distributed under the License is distributed on an
+##  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+##  KIND, either express or implied.  See the License for the
+##  specific language governing permissions and limitations
+##  under the License.
+##
+##Terminology:
+##	Base class - super superclass of entity, ie, org.apache.cayenne.CayenneDataObject or MyBaseClass
+##  Super class - superclass of entity, ie,  org.apache.cayenne.art.auto._Artist
+##	Sub class - class of entity, ie, org.apache.cayenne.art.Artist
+##
+##  Classes available in template
+##    stringUtils - class for string "helper" functions: See org.apache.cayenne.gen.StringUtils
+##    dataMapUtils - class for query "helper" functions: See org.apache.cayenne.gen.DataMapUtils
+##    importUtils - class for import statement management: See org.apache.cayenne.gen.ImportUtils
+##    superClassName
+##    superPackageName
+##    subClassName
+##    subPackageName
+##    baseClassName
+##    basePackageName
+##
+${importUtils.setPackage($superPackageName)}##
+#if(${superPackageName})${importUtils.addReservedType("${superPackageName}.${superClassName}")}#end##
+#if(${basePackageName})${importUtils.addType("${basePackageName}.${baseClassName}")}#end##
+#if( ${object.hasSelectQueries()} )
+${importUtils.addType('java.util.List')}##
+${importUtils.addType('org.apache.cayenne.ObjectContext')}##
+${importUtils.addType('org.apache.cayenne.query.NamedQuery')}##
+#foreach( $selectQuery in ${object.SelectQueries})
+${importUtils.addType(${selectQuery.Root.ClassName})}##
+#if(${dataMapUtils.isValidParameterNames($selectQuery)})
+#foreach( $parameter in ${dataMapUtils.getParameterNames(${selectQuery})})
+${importUtils.addType(${dataMapUtils.getParameterType(${selectQuery}, ${parameter})})}##
+#end
+#end    
+#end
+#end
+${importUtils.generate()}
+
+/**
+ * This class was generated by Cayenne.
+ * It is probably a good idea to avoid changing this class manually,
+ * since it may be overwritten next time code is regenerated.
+ * If you need to make any customizations, please use subclass.
+ */
+public class ${superClassName} {
+#if( ${object.hasQueryNames()})
+#foreach( $qname in ${object.queryNames})
+
+    public static final String ${stringUtils.capitalizedAsConstant($qname)}_QUERYNAME = "$qname";
+#end
+#end
+#foreach( $selectQuery in ${object.SelectQueries})
+
+#if(${dataMapUtils.isValidParameterNames($selectQuery)})
+    public List<${stringUtils.stripPackageName($selectQuery.Root.ClassName)}> perform${dataMapUtils.getQueryMethodName(${selectQuery})}(ObjectContext context #foreach( $parameter in ${dataMapUtils.getParameterNames(${selectQuery})}), ${stringUtils.stripPackageName(${dataMapUtils.getParameterType(${selectQuery}, ${parameter})})} ${parameter}#end) {
+#if(${dataMapUtils.hasParameters($selectQuery)})
+        String[] parameters = {
+#foreach( $parameter in ${dataMapUtils.getParameterNames(${selectQuery})})
+            "${parameter}",
+#end
+        };
+
+        Object[] values = {
+#foreach( $parameter in ${dataMapUtils.getParameterNames(${selectQuery})})
+            ${parameter},
+#end
+        };
+
+#end
+        return context.performQuery(new NamedQuery("${selectQuery.Name}"#if(${dataMapUtils.hasParameters($selectQuery)}), parameters, values#end));
+    }
+#end
+#end
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/cayenne/blob/c63b6be2/cayenne-cgen/src/main/resources/templates/v1_2/embeddable-singleclass.vm
----------------------------------------------------------------------
diff --git a/cayenne-cgen/src/main/resources/templates/v1_2/embeddable-singleclass.vm b/cayenne-cgen/src/main/resources/templates/v1_2/embeddable-singleclass.vm
new file mode 100644
index 0000000..a30dcec
--- /dev/null
+++ b/cayenne-cgen/src/main/resources/templates/v1_2/embeddable-singleclass.vm
@@ -0,0 +1,106 @@
+##  Licensed to the Apache Software Foundation (ASF) under one
+##  or more contributor license agreements.  See the NOTICE file
+##  distributed with this work for additional information
+##  regarding copyright ownership.  The ASF licenses this file
+##  to you under the Apache License, Version 2.0 (the
+##  "License"); you may not use this file except in compliance
+##  with the License.  You may obtain a copy of the License at
+##
+##    http://www.apache.org/licenses/LICENSE-2.0
+##
+##  Unless required by applicable law or agreed to in writing,
+##  software distributed under the License is distributed on an
+##  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+##  KIND, either express or implied.  See the License for the
+##  specific language governing permissions and limitations
+##  under the License.
+##
+##  Terminology:
+## 
+##	Base class - super superclass of embeddable, usually java.lang.Object
+##  Super class - superclass of embeddable, ie,  org.apache.cayenne.art.auto._Embeddable
+##	Sub class - class of entity, ie, org.apache.cayenne.art.Embeddable
+##
+##  Keys of objects available in template are defined in 'org.apache.cayenne.gen.Artifact', namely:
+## 
+##    object - the Embeddable class: See org.apache.cayenne.map.Embeddable
+##    stringUtils - class for string "helper" functions: See org.apache.cayenne.gen.StringUtils
+##    importUtils - class for import statement management: See org.apache.cayenne.gen.ImportUtils
+##    superClassName
+##    superPackageName
+##    subClassName
+##    subPackageName
+##    baseClassName
+##    basePackageName 
+##
+##
+${importUtils.setPackage($subPackageName)}##
+${importUtils.addReservedType("${subPackageName}.${subClassName}")}##
+${importUtils.addType("${basePackageName}.${baseClassName}")}##
+${importUtils.addType("org.apache.cayenne.Persistent")}##
+#if(${object.Attributes} && !${object.Attributes.isEmpty()})
+${importUtils.addType('org.apache.cayenne.exp.Property')}##
+#end
+#foreach( $attr in ${object.Attributes} )
+$importUtils.addType(${attr.Type})##
+#end
+${importUtils.generate()}
+
+public abstract class ${subClassName} extends ${baseClassName} {
+
+## Create property names
+#if( $createPropertyNames )
+#foreach( $attr in ${object.Attributes} )
+    public static final String ${stringUtils.capitalizedAsConstant($attr.Name)}_PROPERTY = "${attr.Name}";
+#end
+
+#end
+## Create Properties
+#foreach( $attr in ${object.Attributes} )
+    #set ( $type = "$importUtils.formatJavaType(${attr.Type}, false)" )
+    public static final Property<$type> ${stringUtils.capitalizedAsConstant($attr.Name)} = Property.create("${attr.Name}", ${stringUtils.stripGeneric($type)}.class);
+#end
+
+    // special properties injected by Cayenne
+    private Persistent owner;
+    private String embeddedProperty;
+    
+    // declared properties
+#foreach( $attr in ${object.Attributes} )
+    protected $importUtils.formatJavaType(${attr.Type}) $stringUtils.formatVariableName(${attr.Name});
+#end
+
+    // lifecycle methods
+    protected void propertyWillChange(String property, Object oldValue, Object newValue) {
+        if (owner != null && owner.getObjectContext() != null) {
+            owner.getObjectContext().propertyChanged(
+                    owner,
+                    embeddedProperty + "." + property,
+                    oldValue,
+                    newValue);
+        }
+    }
+
+    // declared getters and setters
+## Create attribute set/get methods
+#foreach( $attr in ${object.Attributes} )
+    public void set${stringUtils.capitalized($attr.Name)}($importUtils.formatJavaType(${attr.Type}) $stringUtils.formatVariableName(${attr.Name})) {
+        propertyWillChange("${attr.Name}", this.$stringUtils.formatVariableName(${attr.Name}), $stringUtils.formatVariableName(${attr.Name}));
+        this.$stringUtils.formatVariableName(${attr.Name}) = $stringUtils.formatVariableName(${attr.Name});
+    }
+#if ( $importUtils.isBoolean(${attr.Type}) )
+	public boolean is${stringUtils.capitalized($attr.Name)}() {
+        return $stringUtils.formatVariableName(${attr.Name});
+    }
+#elseif ( $importUtils.isNonBooleanPrimitive(${attr.Type}) )
+    public $classGen.formatJavaType(${attr.Type}) get${stringUtils.capitalized($attr.Name)}() {
+        return $stringUtils.formatVariableName(${attr.Name});
+    }
+#else
+    public $importUtils.formatJavaType(${attr.Type}) get${stringUtils.capitalized($attr.Name)}() {
+        return $stringUtils.formatVariableName(${attr.Name});
+    }
+#end
+
+#end
+}

http://git-wip-us.apache.org/repos/asf/cayenne/blob/c63b6be2/cayenne-cgen/src/main/resources/templates/v1_2/embeddable-subclass.vm
----------------------------------------------------------------------
diff --git a/cayenne-cgen/src/main/resources/templates/v1_2/embeddable-subclass.vm b/cayenne-cgen/src/main/resources/templates/v1_2/embeddable-subclass.vm
new file mode 100644
index 0000000..b5b701b
--- /dev/null
+++ b/cayenne-cgen/src/main/resources/templates/v1_2/embeddable-subclass.vm
@@ -0,0 +1,45 @@
+##  Licensed to the Apache Software Foundation (ASF) under one
+##  or more contributor license agreements.  See the NOTICE file
+##  distributed with this work for additional information
+##  regarding copyright ownership.  The ASF licenses this file
+##  to you under the Apache License, Version 2.0 (the
+##  "License"); you may not use this file except in compliance
+##  with the License.  You may obtain a copy of the License at
+##
+##    http://www.apache.org/licenses/LICENSE-2.0
+##
+##  Unless required by applicable law or agreed to in writing,
+##  software distributed under the License is distributed on an
+##  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+##  KIND, either express or implied.  See the License for the
+##  specific language governing permissions and limitations
+##  under the License.
+##
+##  Terminology:
+## 
+##	Base class - super superclass of embeddable, usually java.lang.Object
+##  Super class - superclass of embeddable, ie,  org.apache.cayenne.art.auto._Embeddable
+##	Sub class - class of entity, ie, org.apache.cayenne.art.Embeddable
+##
+##  Keys of objects available in template are defined in 'org.apache.cayenne.gen.Artifact', namely:
+## 
+##    object - the Embeddable class: See org.apache.cayenne.map.Embeddable
+##    stringUtils - class for string "helper" functions: See org.apache.cayenne.gen.StringUtils
+##    importUtils - class for import statement management: See org.apache.cayenne.gen.ImportUtils
+##    superClassName
+##    superPackageName
+##    subClassName
+##    subPackageName
+##    baseClassName
+##    basePackageName 
+##
+##
+${importUtils.setPackage($subPackageName)}##
+${importUtils.addReservedType("${subPackageName}.${subClassName}")}##
+${importUtils.addType("${superPackageName}.${superClassName}")}##
+${importUtils.generate()}
+
+
+public#if("true" == "${object.getIsAbstract()}") abstract#end class ${subClassName} extends ${superClassName} {
+
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/cayenne/blob/c63b6be2/cayenne-cgen/src/main/resources/templates/v1_2/embeddable-superclass.vm
----------------------------------------------------------------------
diff --git a/cayenne-cgen/src/main/resources/templates/v1_2/embeddable-superclass.vm b/cayenne-cgen/src/main/resources/templates/v1_2/embeddable-superclass.vm
new file mode 100644
index 0000000..95e39dc
--- /dev/null
+++ b/cayenne-cgen/src/main/resources/templates/v1_2/embeddable-superclass.vm
@@ -0,0 +1,112 @@
+##  Licensed to the Apache Software Foundation (ASF) under one
+##  or more contributor license agreements.  See the NOTICE file
+##  distributed with this work for additional information
+##  regarding copyright ownership.  The ASF licenses this file
+##  to you under the Apache License, Version 2.0 (the
+##  "License"); you may not use this file except in compliance
+##  with the License.  You may obtain a copy of the License at
+##
+##    http://www.apache.org/licenses/LICENSE-2.0
+##
+##  Unless required by applicable law or agreed to in writing,
+##  software distributed under the License is distributed on an
+##  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+##  KIND, either express or implied.  See the License for the
+##  specific language governing permissions and limitations
+##  under the License.
+##
+##  Terminology:
+## 
+##	Base class - super superclass of embeddable, usually java.lang.Object
+##  Super class - superclass of embeddable, ie,  org.apache.cayenne.art.auto._Embeddable
+##	Sub class - class of entity, ie, org.apache.cayenne.art.Embeddable
+##
+##  Keys of objects available in template are defined in 'org.apache.cayenne.gen.Artifact', namely:
+## 
+##    object - the Embeddable class: See org.apache.cayenne.map.Embeddable
+##    stringUtils - class for string "helper" functions: See org.apache.cayenne.gen.StringUtils
+##    importUtils - class for import statement management: See org.apache.cayenne.gen.ImportUtils
+##    superClassName
+##    superPackageName
+##    subClassName
+##    subPackageName
+##    baseClassName
+##    basePackageName 
+##
+##
+${importUtils.setPackage($superPackageName)}##
+${importUtils.addReservedType("${superPackageName}.${superClassName}")}##
+${importUtils.addType("${basePackageName}.${baseClassName}")}##
+${importUtils.addType("org.apache.cayenne.Persistent")}##
+#if(${object.Attributes} && !${object.Attributes.isEmpty()})
+${importUtils.addType('org.apache.cayenne.exp.Property')}##
+#end
+#foreach( $attr in ${object.Attributes} )
+$importUtils.addType(${attr.Type})##
+#end
+${importUtils.generate()}
+
+/** 
+ * Embeddable class ${superClassName} was generated by Cayenne.
+ * It is probably a good idea to avoid changing this class manually, 
+ * since it may be overwritten next time code is regenerated. 
+ * If you need to make any customizations, please use subclass. 
+ */
+public abstract class ${superClassName} extends ${baseClassName} {
+
+## Create property names
+#if( $createPropertyNames )
+#foreach( $attr in ${object.Attributes} )
+    public static final String ${stringUtils.capitalizedAsConstant($attr.Name)}_PROPERTY = "${attr.Name}";
+#end
+
+#end
+## Create Properties
+#foreach( $attr in ${object.Attributes} )
+    #set ( $type = "$importUtils.formatJavaType(${attr.Type}, false)" )
+    public static final Property<$type> ${stringUtils.capitalizedAsConstant($attr.Name)} = Property.create("${attr.Name}", ${stringUtils.stripGeneric($type)}.class);
+#end
+
+    // special properties injected by Cayenne
+    private Persistent owner;
+    private String embeddedProperty;
+    
+    // declared properties
+#foreach( $attr in ${object.Attributes} )
+    protected $importUtils.formatJavaType(${attr.Type}) $stringUtils.formatVariableName(${attr.Name});
+#end
+
+    // lifecycle methods
+    protected void propertyWillChange(String property, Object oldValue, Object newValue) {
+        if (owner != null && owner.getObjectContext() != null) {
+            owner.getObjectContext().propertyChanged(
+                    owner,
+                    embeddedProperty + "." + property,
+                    oldValue,
+                    newValue);
+        }
+    }
+
+    // declared getters and setters
+## Create attribute set/get methods
+#foreach( $attr in ${object.Attributes} )
+    public void set${stringUtils.capitalized($attr.Name)}($importUtils.formatJavaType(${attr.Type}) $stringUtils.formatVariableName(${attr.Name})) {
+        propertyWillChange("${attr.Name}", this.$stringUtils.formatVariableName(${attr.Name}), $stringUtils.formatVariableName(${attr.Name}));
+        this.$stringUtils.formatVariableName(${attr.Name}) = $stringUtils.formatVariableName(${attr.Name});
+    }
+#if ( $importUtils.isBoolean(${attr.Type}) )
+	public boolean is${stringUtils.capitalized($attr.Name)}() {
+        return $stringUtils.formatVariableName(${attr.Name});
+    }
+#elseif ( $importUtils.isNonBooleanPrimitive(${attr.Type}) )
+    public $importUtils.formatJavaType(${attr.Type}) get${stringUtils.capitalized($attr.Name)}() {
+        return $stringUtils.formatVariableName(${attr.Name});
+    }
+#else
+    public $importUtils.formatJavaType(${attr.Type}) get${stringUtils.capitalized($attr.Name)}() {
+        return $stringUtils.formatVariableName(${attr.Name});
+    }
+#end
+
+#end
+}

http://git-wip-us.apache.org/repos/asf/cayenne/blob/c63b6be2/cayenne-cgen/src/main/resources/templates/v1_2/singleclass.vm
----------------------------------------------------------------------
diff --git a/cayenne-cgen/src/main/resources/templates/v1_2/singleclass.vm b/cayenne-cgen/src/main/resources/templates/v1_2/singleclass.vm
new file mode 100644
index 0000000..53c6aa7
--- /dev/null
+++ b/cayenne-cgen/src/main/resources/templates/v1_2/singleclass.vm
@@ -0,0 +1,147 @@
+##   Licensed to the Apache Software Foundation (ASF) under one
+##  or more contributor license agreements.  See the NOTICE file
+##  distributed with this work for additional information
+##  regarding copyright ownership.  The ASF licenses this file
+##  to you under the Apache License, Version 2.0 (the
+##  "License"); you may not use this file except in compliance
+##  with the License.  You may obtain a copy of the License at
+##
+##    http://www.apache.org/licenses/LICENSE-2.0
+##
+##  Unless required by applicable law or agreed to in writing,
+##  software distributed under the License is distributed on an
+##  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+##  KIND, either express or implied.  See the License for the
+##  specific language governing permissions and limitations
+##  under the License.
+##
+##Terminology:
+##	Base class - super superclass of entity, ie, org.apache.cayenne.CayenneDataObject or MyBaseClass
+##  Super class - superclass of entity, ie,  org.apache.cayenne.art.auto._Artist
+##	Sub class - class of entity, ie, org.apache.cayenne.art.Artist
+##
+##  Classes available in template
+##    object (duplicated as 'objEntity') - the ObjEntity class: See org.apache.cayenne.map.ObjectEntity
+##    stringUtils - class for string "helper" functions: See org.apache.cayenne.gen.StringUtils
+##    entityUtils - class for entity "helper" functions: See org.apache.cayenne.gen.EntityUtils
+##    importUtils - class for import statement management: See org.apache.cayenne.gen.ImportUtils
+##    superClassName
+##    superPackageName
+##    subClassName
+##    subPackageName
+##    baseClassName
+##    basePackageName 
+##
+##
+${importUtils.setPackage($subPackageName)}##
+${importUtils.addReservedType("${subPackageName}.${subClassName}")}##
+${importUtils.addType("${basePackageName}.${baseClassName}")}##
+#if((${object.DeclaredAttributes} && !${object.DeclaredAttributes.isEmpty()}) || (${object.DeclaredRelationships} && !${object.DeclaredRelationships.isEmpty()}))
+${importUtils.addType('org.apache.cayenne.exp.Property')}##
+#end
+#foreach( $attr in ${object.DeclaredAttributes} )
+$importUtils.addType(${attr.Type})##
+#end
+#foreach( $rel in ${object.DeclaredRelationships} )
+$importUtils.addType(${rel.TargetEntity.ClassName})##
+#if(${rel.CollectionType})
+$importUtils.addType(${rel.CollectionType})##
+#end
+#end
+${importUtils.generate()}
+
+public#if("true" == "${object.isAbstract()}") abstract#end class ${subClassName} extends ${baseClassName} {
+
+    private static final long serialVersionUID = 1L;
+
+## Create property names
+#if( $createPropertyNames )
+#foreach( $attr in ${object.DeclaredAttributes} )
+    public static final String ${stringUtils.capitalizedAsConstant($attr.Name)}_PROPERTY = "${attr.Name}";
+#end
+#foreach( $rel in ${object.DeclaredRelationships} )
+    public static final String ${stringUtils.capitalizedAsConstant($rel.Name)}_PROPERTY = "${rel.Name}";
+#end
+
+#end
+#if( $object.DbEntity )
+#foreach( $idAttr in ${object.DbEntity.PrimaryKeys} )
+    public static final String ${stringUtils.capitalizedAsConstant($idAttr.Name)}_PK_COLUMN = "${idAttr.Name}";
+#end
+#end
+
+## Create Properties
+#foreach( $attr in ${object.DeclaredAttributes} )
+    #set ( $type = "$importUtils.formatJavaType(${attr.Type}, false)" )
+    public static final Property<$type> ${stringUtils.capitalizedAsConstant($attr.Name)} = Property.create("${attr.Name}", ${stringUtils.stripGeneric($type)}.class);
+#end
+#foreach( $rel in ${object.DeclaredRelationships} )
+#if( $rel.ToMany )
+#if ( ${rel.CollectionType} == "java.util.Map")
+    #set( $type = "$importUtils.formatJavaType($rel.CollectionType)<$importUtils.formatJavaType($entityUtils.getMapKeyType($rel)), $importUtils.formatJavaType($rel.TargetEntity.ClassName)>" )
+    public static final Property<$type> ${stringUtils.capitalizedAsConstant($rel.Name)} = Property.create("${rel.Name}", ${stringUtils.stripGeneric($type)}.class);
+#else
+    #set( $type = "$importUtils.formatJavaType($rel.CollectionType)<$importUtils.formatJavaType($rel.TargetEntity.ClassName)>" )
+    public static final Property<$type> ${stringUtils.capitalizedAsConstant($rel.Name)} = Property.create("${rel.Name}", ${stringUtils.stripGeneric($type)}.class);
+#end
+#else
+    #set( $type = "$importUtils.formatJavaType(${rel.TargetEntity.ClassName})" )
+    public static final Property<$type> ${stringUtils.capitalizedAsConstant($rel.Name)} = Property.create("${rel.Name}", ${stringUtils.stripGeneric($type)}.class);
+#end
+#end
+
+## Create attribute set/get methods
+#foreach( $attr in ${object.DeclaredAttributes} )
+#if ("true" != "${object.isReadOnly()}")
+    public void set${stringUtils.capitalized($attr.Name)}($importUtils.formatJavaType(${attr.Type}) $stringUtils.formatVariableName(${attr.Name})) {
+        writeProperty("${attr.Name}", $stringUtils.formatVariableName(${attr.Name}));
+    }
+#end
+#if ( $importUtils.isBoolean(${attr.Type}) )
+	public boolean is${stringUtils.capitalized($attr.Name)}() {
+        Boolean value = (Boolean)readProperty("${attr.Name}");
+        return (value != null) ? value.booleanValue() : false;
+    }
+#elseif ( $importUtils.isNonBooleanPrimitive(${attr.Type}) )
+    public ${importUtils.formatJavaType($attr.Type)} get${stringUtils.capitalized($attr.Name)}() {
+        Object value = readProperty("${attr.Name}");
+        return (value != null) ? ($importUtils.formatJavaTypeAsNonBooleanPrimitive(${attr.Type})) value : 0;
+    }
+#else
+    public $importUtils.formatJavaType(${attr.Type}) get${stringUtils.capitalized($attr.Name)}() {
+        return ($importUtils.formatJavaType(${attr.Type}))readProperty("${attr.Name}");
+    }
+#end
+
+#end
+##
+## Create list add/remove/get methods
+#foreach( $rel in ${object.DeclaredRelationships} )
+#if( $rel.ToMany )
+#if ( ! $rel.ReadOnly )    public void addTo${stringUtils.capitalized($rel.Name)}($importUtils.formatJavaType(${rel.TargetEntity.ClassName}) obj) {
+        addToManyTarget("${rel.name}", obj, true);
+    }
+    public void removeFrom${stringUtils.capitalized($rel.Name)}($importUtils.formatJavaType(${rel.TargetEntity.ClassName}) obj) {
+        removeToManyTarget("${rel.name}", obj, true);
+    }
+#end
+    public $importUtils.formatJavaType($rel.CollectionType) get${stringUtils.capitalized($rel.Name)}() {
+        return ($importUtils.formatJavaType($rel.CollectionType))readProperty("${rel.name}");
+    }
+#else
+#if ( ! ${object.isReadOnly()} && ! $rel.ReadOnly )
+    public void set${stringUtils.capitalized($rel.Name)}($importUtils.formatJavaType(${rel.TargetEntity.ClassName}) $stringUtils.formatVariableName(${rel.name})) {
+        setToOneTarget("${rel.name}", $stringUtils.formatVariableName(${rel.name}), true);
+    }
+#end
+    public $importUtils.formatJavaType(${rel.TargetEntity.ClassName}) get${stringUtils.capitalized($rel.Name)}() {
+        return ($importUtils.formatJavaType(${rel.TargetEntity.ClassName}))readProperty("${rel.name}");
+    }
+#end
+
+
+#end
+}
+
+
+

http://git-wip-us.apache.org/repos/asf/cayenne/blob/c63b6be2/cayenne-cgen/src/main/resources/templates/v1_2/subclass.vm
----------------------------------------------------------------------
diff --git a/cayenne-cgen/src/main/resources/templates/v1_2/subclass.vm b/cayenne-cgen/src/main/resources/templates/v1_2/subclass.vm
new file mode 100644
index 0000000..e31e658
--- /dev/null
+++ b/cayenne-cgen/src/main/resources/templates/v1_2/subclass.vm
@@ -0,0 +1,47 @@
+##   Licensed to the Apache Software Foundation (ASF) under one
+##  or more contributor license agreements.  See the NOTICE file
+##  distributed with this work for additional information
+##  regarding copyright ownership.  The ASF licenses this file
+##  to you under the Apache License, Version 2.0 (the
+##  "License"); you may not use this file except in compliance
+##  with the License.  You may obtain a copy of the License at
+##
+##    http://www.apache.org/licenses/LICENSE-2.0
+##
+##  Unless required by applicable law or agreed to in writing,
+##  software distributed under the License is distributed on an
+##  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+##  KIND, either express or implied.  See the License for the
+##  specific language governing permissions and limitations
+##  under the License.
+##
+##Terminology:
+##	Base class - super superclass of entity, ie, org.apache.cayenne.CayenneDataObject or MyBaseClass
+##  Super class - superclass of entity, ie,  org.apache.cayenne.art.auto._Artist
+##	Sub class - class of entity, ie, org.apache.cayenne.art.Artist
+##
+##  Classes available in template
+##    objEntity - the ObjEntity class: See org.apache.cayenne.map.ObjectEntity
+##    stringUtils - class for string "helper" functions: See org.apache.cayenne.gen.StringUtils
+##    entityUtils - class for entity "helper" functions: See org.apache.cayenne.gen.EntityUtils
+##    importUtils - class for import statement management: See org.apache.cayenne.gen.ImportUtils
+##
+##
+${importUtils.setPackage($subPackageName)}##
+${importUtils.addReservedType("${subPackageName}.${subClassName}")}##
+${importUtils.addType("${superPackageName}.${superClassName}")}##
+${importUtils.generate()}
+
+public#if("true" == "${object.isAbstract()}") abstract#end class ${subClassName} extends ${superClassName} {
+
+    private static final long serialVersionUID = 1L; 
+
+##callbacks
+#foreach($cbname in ${entityUtils.callbackNames})
+    @Override
+    protected void ${cbname}() {
+        //TODO: implement ${cbname}
+    }
+
+#end 
+}

http://git-wip-us.apache.org/repos/asf/cayenne/blob/c63b6be2/cayenne-cgen/src/main/resources/templates/v1_2/superclass.vm
----------------------------------------------------------------------
diff --git a/cayenne-cgen/src/main/resources/templates/v1_2/superclass.vm b/cayenne-cgen/src/main/resources/templates/v1_2/superclass.vm
new file mode 100644
index 0000000..7857189
--- /dev/null
+++ b/cayenne-cgen/src/main/resources/templates/v1_2/superclass.vm
@@ -0,0 +1,164 @@
+##   Licensed to the Apache Software Foundation (ASF) under one
+##  or more contributor license agreements.  See the NOTICE file
+##  distributed with this work for additional information
+##  regarding copyright ownership.  The ASF licenses this file
+##  to you under the Apache License, Version 2.0 (the
+##  "License"); you may not use this file except in compliance
+##  with the License.  You may obtain a copy of the License at
+##
+##    http://www.apache.org/licenses/LICENSE-2.0
+##
+##  Unless required by applicable law or agreed to in writing,
+##  software distributed under the License is distributed on an
+##  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+##  KIND, either express or implied.  See the License for the
+##  specific language governing permissions and limitations
+##  under the License.
+##
+##Terminology:
+##	Base class - super superclass of entity, ie, org.apache.cayenne.CayenneDataObject or MyBaseClass
+##  Super class - superclass of entity, ie,  org.apache.cayenne.art.auto._Artist
+##	Sub class - class of entity, ie, org.apache.cayenne.art.Artist
+##
+##  Classes available in template
+##    object (duplicated as 'objEntity') - the ObjEntity class: See org.apache.cayenne.map.ObjectEntity
+##    stringUtils - class for string "helper" functions: See org.apache.cayenne.gen.StringUtils
+##    entityUtils - class for entity "helper" functions: See org.apache.cayenne.gen.EntityUtils
+##    importUtils - class for import statement management: See org.apache.cayenne.gen.ImportUtils
+##    superClassName
+##    superPackageName
+##    subClassName
+##    subPackageName
+##    baseClassName
+##    basePackageName
+##
+${importUtils.setPackage($superPackageName)}##
+${importUtils.addReservedType("${superPackageName}.${superClassName}")}##
+${importUtils.addType("${basePackageName}.${baseClassName}")}##
+#if((${object.DeclaredAttributes} && !${object.DeclaredAttributes.isEmpty()}) || (${object.DeclaredRelationships} && !${object.DeclaredRelationships.isEmpty()}))
+${importUtils.addType('org.apache.cayenne.exp.Property')}##
+#end
+#foreach( $attr in ${object.DeclaredAttributes} )
+$importUtils.addType(${attr.Type})##
+#end
+#foreach( $rel in ${object.DeclaredRelationships} )
+$importUtils.addType(${rel.TargetEntity.ClassName})##
+#if(${rel.CollectionType}) 
+$importUtils.addType(${rel.CollectionType})##
+#end
+#end
+${importUtils.generate()}
+
+/**
+ * Class ${superClassName} was generated by Cayenne.
+ * It is probably a good idea to avoid changing this class manually,
+ * since it may be overwritten next time code is regenerated.
+ * If you need to make any customizations, please use subclass.
+ */
+public abstract class ${superClassName} extends ${baseClassName} {
+
+    private static final long serialVersionUID = 1L; 
+
+## Create property names
+#if( $createPropertyNames )
+#foreach( $attr in ${object.DeclaredAttributes} )
+    public static final String ${stringUtils.capitalizedAsConstant($attr.Name)}_PROPERTY = "${attr.Name}";
+#end
+#foreach( $rel in ${object.DeclaredRelationships} )
+    public static final String ${stringUtils.capitalizedAsConstant($rel.Name)}_PROPERTY = "${rel.Name}";
+#end
+
+#end
+#if( $object.DbEntity )
+#foreach( $idAttr in ${object.DbEntity.PrimaryKeys} )
+    public static final String ${stringUtils.capitalizedAsConstant($idAttr.Name)}_PK_COLUMN = "${idAttr.Name}";
+#end
+#end
+
+## Create Properties
+#foreach( $attr in ${object.DeclaredAttributes} )
+    #set ( $type = "$importUtils.formatJavaType(${attr.Type}, false)")
+    public static final Property<$type> ${stringUtils.capitalizedAsConstant($attr.Name)} = Property.create("${attr.Name}", ${stringUtils.stripGeneric($type)}.class);
+#end
+#foreach( $rel in ${object.DeclaredRelationships} )
+#if( $rel.ToMany )
+#if ( ${rel.CollectionType} == "java.util.Map")
+    #set( $type = "$importUtils.formatJavaType($rel.CollectionType)<$importUtils.formatJavaType($entityUtils.getMapKeyType($rel)), $importUtils.formatJavaType($rel.TargetEntity.ClassName)>" )
+    public static final Property<$type> ${stringUtils.capitalizedAsConstant($rel.Name)} = Property.create("${rel.Name}", ${stringUtils.stripGeneric($type)}.class);
+#else
+    #set( $type = "$importUtils.formatJavaType($rel.CollectionType)<$importUtils.formatJavaType($rel.TargetEntity.ClassName)>" )
+    public static final Property<$type> ${stringUtils.capitalizedAsConstant($rel.Name)} = Property.create("${rel.Name}", ${stringUtils.stripGeneric($type)}.class);
+#end
+#else
+    #set( $type = "$importUtils.formatJavaType(${rel.TargetEntity.ClassName})" )
+    public static final Property<$type> ${stringUtils.capitalizedAsConstant($rel.Name)} = Property.create("${rel.Name}", ${stringUtils.stripGeneric($type)}.class);
+#end
+#end
+
+## Create attribute set/get methods
+#foreach( $attr in ${object.DeclaredAttributes} )
+#if ("true" != "${object.isReadOnly()}")
+    public void set${stringUtils.capitalized($attr.Name)}($importUtils.formatJavaType(${attr.Type}) $stringUtils.formatVariableName(${attr.Name})) {
+        writeProperty("${attr.Name}", $stringUtils.formatVariableName(${attr.Name}));
+    }
+#end
+#if ( $importUtils.isBoolean(${attr.Type}) )
+	public boolean is${stringUtils.capitalized($attr.Name)}() {
+        Boolean value = (Boolean)readProperty("${attr.Name}");
+        return (value != null) ? value.booleanValue() : false;
+    }
+#elseif ( $importUtils.isNonBooleanPrimitive(${attr.Type}) )
+    public ${importUtils.formatJavaType($attr.Type)} get${stringUtils.capitalized($attr.Name)}() {
+        Object value = readProperty("${attr.Name}");
+        return (value != null) ? ($importUtils.formatJavaTypeAsNonBooleanPrimitive(${attr.Type})) value : 0;
+    }
+#else
+    public $importUtils.formatJavaType(${attr.Type}) get${stringUtils.capitalized($attr.Name)}() {
+        return ($importUtils.formatJavaType(${attr.Type}))readProperty("${attr.Name}");
+    }
+#end
+
+#end
+##
+## Create list add/remove/get methods
+#foreach( $rel in ${object.DeclaredRelationships} )
+#if( $rel.ToMany )
+#if ( ! $rel.ReadOnly )
+    public void addTo${stringUtils.capitalized($rel.Name)}($importUtils.formatJavaType(${rel.TargetEntity.ClassName}) obj) {
+        addToManyTarget("${rel.Name}", obj, true);
+    }
+    public void removeFrom${stringUtils.capitalized($rel.Name)}($importUtils.formatJavaType(${rel.TargetEntity.ClassName}) obj) {
+        removeToManyTarget("${rel.Name}", obj, true);
+    }
+#end
+    @SuppressWarnings("unchecked")
+#if ( ${rel.CollectionType} == "java.util.Map")
+    public $importUtils.formatJavaType($rel.CollectionType)<$importUtils.formatJavaType($entityUtils.getMapKeyType($rel)), $importUtils.formatJavaType($rel.TargetEntity.ClassName)> get${stringUtils.capitalized($rel.Name)}() {
+        return ($importUtils.formatJavaType($rel.CollectionType)<$importUtils.formatJavaType($entityUtils.getMapKeyType($rel)), $importUtils.formatJavaType($rel.TargetEntity.ClassName)>)readProperty("${rel.Name}");
+    }
+#else
+    public $importUtils.formatJavaType($rel.CollectionType)<$importUtils.formatJavaType($rel.TargetEntity.ClassName)> get${stringUtils.capitalized($rel.Name)}() {
+        return ($importUtils.formatJavaType($rel.CollectionType)<$importUtils.formatJavaType($rel.TargetEntity.ClassName)>)readProperty("${rel.Name}");
+    }
+#end
+#else
+#if ( !${object.isReadOnly()} && !$rel.ReadOnly )
+    public void set${stringUtils.capitalized($rel.Name)}($importUtils.formatJavaType(${rel.TargetEntity.ClassName}) $stringUtils.formatVariableName(${rel.name})) {
+        setToOneTarget("${rel.Name}", $stringUtils.formatVariableName(${rel.name}), true);
+    }
+#end
+
+    public $importUtils.formatJavaType(${rel.TargetEntity.ClassName}) get${stringUtils.capitalized($rel.Name)}() {
+        return ($importUtils.formatJavaType(${rel.TargetEntity.ClassName}))readProperty("${rel.Name}");
+    }
+#end
+
+
+#end
+##
+##callback methods
+#foreach($cbname in ${entityUtils.callbackNames})
+    protected abstract void ${cbname}();
+
+#end
+}

http://git-wip-us.apache.org/repos/asf/cayenne/blob/c63b6be2/cayenne-cgen/src/test/java/org/apache/cayenne/gen/ClassGenerationActionTest.java
----------------------------------------------------------------------
diff --git a/cayenne-cgen/src/test/java/org/apache/cayenne/gen/ClassGenerationActionTest.java b/cayenne-cgen/src/test/java/org/apache/cayenne/gen/ClassGenerationActionTest.java
new file mode 100644
index 0000000..c6e1885
--- /dev/null
+++ b/cayenne-cgen/src/test/java/org/apache/cayenne/gen/ClassGenerationActionTest.java
@@ -0,0 +1,256 @@
+/*****************************************************************
+ *   Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ ****************************************************************/
+
+package org.apache.cayenne.gen;
+
+import org.apache.cayenne.map.CallbackDescriptor;
+import org.apache.cayenne.map.DataMap;
+import org.apache.cayenne.map.ObjAttribute;
+import org.apache.cayenne.map.ObjEntity;
+import org.apache.cayenne.map.ObjRelationship;
+import org.apache.cayenne.map.QueryDescriptor;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+
+import java.io.StringWriter;
+import java.io.Writer;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
+public class ClassGenerationActionTest {
+
+	protected ClassGenerationAction action;
+	protected Collection<StringWriter> writers;
+
+	@Before
+	public void setUp() throws Exception {
+		this.writers = new ArrayList<StringWriter>(3);
+		this.action = new ClassGenerationAction() {
+
+			@Override
+			protected Writer openWriter(TemplateType templateType) throws Exception {
+				StringWriter writer = new StringWriter();
+				writers.add(writer);
+				return writer;
+			}
+		};
+	}
+
+	@After
+	public void tearDown() throws Exception {
+		action = null;
+		writers = null;
+	}
+
+	@Test
+	public void testExecuteArtifactPairsImports() throws Exception {
+
+		ObjEntity testEntity1 = new ObjEntity("TE1");
+		testEntity1.setClassName("org.example.TestClass1");
+
+		action.setMakePairs(true);
+		action.setSuperPkg("org.example.auto");
+
+		List<String> generated = execute(new EntityArtifact(testEntity1));
+		assertNotNull(generated);
+		assertEquals(2, generated.size());
+
+		String superclass = generated.get(0);
+		assertTrue(superclass, superclass.contains("package org.example.auto;"));
+		assertTrue(superclass, superclass.contains("import org.apache.cayenne.CayenneDataObject;"));
+
+		String subclass = generated.get(1);
+		assertTrue(subclass, subclass.contains("package org.example;"));
+		assertTrue(subclass, subclass.contains("import org.example.auto._TestClass1;"));
+	}
+
+	@Test
+	public void testExecuteArtifactPairsMapRelationships() throws Exception {
+
+		ObjEntity testEntity1 = new ObjEntity("TE1");
+		testEntity1.setClassName("org.example.TestClass1");
+
+		final ObjEntity testEntity2 = new ObjEntity("TE1");
+		testEntity2.setClassName("org.example.TestClass2");
+
+		ObjRelationship relationship = new ObjRelationship("xMap") {
+
+			private static final long serialVersionUID = 8042147877503405974L;
+
+			@Override
+			public boolean isToMany() {
+				return true;
+			}
+
+			@Override
+			public ObjEntity getTargetEntity() {
+				return testEntity2;
+			}
+		};
+		relationship.setCollectionType("java.util.Map");
+		testEntity1.addRelationship(relationship);
+
+		action.setMakePairs(true);
+
+		List<String> generated = execute(new EntityArtifact(testEntity1));
+		assertNotNull(generated);
+		assertEquals(2, generated.size());
+
+		String superclass = generated.get(0);
+		assertTrue(superclass, superclass.contains("import java.util.Map;"));
+	}
+
+	@Test
+	public void testExecuteArtifactPairsAttribute() throws Exception {
+
+		ObjEntity testEntity1 = new ObjEntity("TE1");
+		testEntity1.setClassName("org.example.TestClass1");
+
+		ObjAttribute attr = new ObjAttribute();
+		attr.setName("ID");
+		attr.setType("int");
+
+		ObjAttribute attr1 = new ObjAttribute();
+		attr1.setName("name");
+		attr1.setType("char");
+
+		testEntity1.addAttribute(attr);
+		testEntity1.addAttribute(attr1);
+
+		action.setMakePairs(true);
+
+		List<String> generated = execute(new EntityArtifact(testEntity1));
+		assertNotNull(generated);
+		assertEquals(2, generated.size());
+		String superclass = generated.get(0);
+
+		assertTrue(superclass, superclass.contains("public void setID(int ID)"));
+		assertTrue(superclass, superclass.contains("writeProperty(\"ID\", ID);"));
+
+		assertTrue(superclass, superclass.contains("public int getID()"));
+		assertTrue(superclass, superclass.contains("Object value = readProperty(\"ID\");"));
+		assertTrue(superclass, superclass.contains("return (value != null) ? (Integer) value : 0;"));
+
+		assertTrue(superclass, superclass.contains("public void setName(char name)"));
+		assertTrue(superclass, superclass.contains("writeProperty(\"name\", name);"));
+
+		assertTrue(superclass, superclass.contains("public char getName()"));
+		assertTrue(superclass, superclass.contains("Object value = readProperty(\"name\");"));
+		assertTrue(superclass, superclass.contains("return (value != null) ? (Character) value : 0;"));
+
+	}
+
+	@Test
+	public void testExecuteDataMapQueryNames() throws Exception {
+		runDataMapTest(false);
+	}
+
+	@Test
+	public void testExecuteClientDataMapQueryNames() throws Exception {
+		runDataMapTest(true);
+	}
+
+	private void runDataMapTest(boolean client) throws Exception {
+		QueryDescriptor descriptor = QueryDescriptor.selectQueryDescriptor();
+        descriptor.setName("TestQuery");
+
+		DataMap map = new DataMap();
+		map.addQueryDescriptor(descriptor);
+		map.setName("testmap");
+		List<String> generated;
+		if (client) {
+			map.setDefaultClientPackage("testpackage");
+			generated = execute(new ClientDataMapArtifact(map, map.getQueryDescriptors()));
+		} else {
+			map.setDefaultPackage("testpackage");
+			generated = execute(new DataMapArtifact(map, map.getQueryDescriptors()));
+		}
+		assertEquals(2, generated.size());
+		assertTrue(generated.get(0).contains("public static final String TEST_QUERY_QUERYNAME = \"TestQuery\""));
+	}
+
+	@Test
+	public void testCallbackMethodGeneration() throws Exception {
+		assertCallbacks(false);
+	}
+
+	@Test
+	public void testClientCallbackMethodGeneration() throws Exception {
+		assertCallbacks(true);
+	}
+
+	private void assertCallbacks(boolean isClient) throws Exception {
+		ObjEntity testEntity1 = new ObjEntity("TE1");
+		testEntity1.setClassName("org.example.TestClass1");
+		int i = 0;
+		for (CallbackDescriptor cb : testEntity1.getCallbackMap().getCallbacks()) {
+			cb.addCallbackMethod("cb" + i++);
+		}
+
+		if (isClient) {
+
+			action = new ClientClassGenerationAction() {
+				@Override
+				protected Writer openWriter(TemplateType templateType) throws Exception {
+					StringWriter writer = new StringWriter();
+					writers.add(writer);
+					return writer;
+				}
+
+			};
+
+		}
+
+		action.setMakePairs(true);
+
+		List<String> generated = execute(new EntityArtifact(testEntity1));
+		assertNotNull(generated);
+		assertEquals(2, generated.size());
+
+		String superclass = generated.get(0);
+
+		assertTrue(superclass, superclass.contains("public abstract class _TestClass1"));
+
+		for (int j = 0; j < i; j++) {
+			assertTrue(superclass, superclass.contains("protected abstract void cb" + j + "();"));
+		}
+
+		String subclass = generated.get(1);
+		for (int j = 0; j < i; j++) {
+			assertTrue(subclass, subclass.contains("protected void cb" + j + "() {"));
+		}
+	}
+
+	protected List<String> execute(Artifact artifact) throws Exception {
+
+		action.execute(artifact);
+
+		List<String> strings = new ArrayList<String>(writers.size());
+		for (StringWriter writer : writers) {
+			strings.add(writer.toString());
+		}
+		return strings;
+	}
+}

http://git-wip-us.apache.org/repos/asf/cayenne/blob/c63b6be2/cayenne-cgen/src/test/java/org/apache/cayenne/gen/ClassGenerationCase.java
----------------------------------------------------------------------
diff --git a/cayenne-cgen/src/test/java/org/apache/cayenne/gen/ClassGenerationCase.java b/cayenne-cgen/src/test/java/org/apache/cayenne/gen/ClassGenerationCase.java
new file mode 100644
index 0000000..44b709d
--- /dev/null
+++ b/cayenne-cgen/src/test/java/org/apache/cayenne/gen/ClassGenerationCase.java
@@ -0,0 +1,59 @@
+/*****************************************************************
+ *   Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ ****************************************************************/
+
+package org.apache.cayenne.gen;
+
+import org.apache.velocity.Template;
+import org.apache.velocity.app.VelocityEngine;
+import org.apache.velocity.context.Context;
+import org.apache.velocity.runtime.RuntimeConstants;
+import org.apache.velocity.runtime.log.NullLogSystem;
+import org.junit.Before;
+
+import java.io.StringWriter;
+import java.util.Properties;
+
+public class ClassGenerationCase {
+
+    private VelocityEngine velocityEngine;
+
+    @Before
+    public void setUp() throws Exception {
+        Properties props = new Properties();
+
+        // null logger that will prevent velocity.log from being generated
+        props.put(RuntimeConstants.RUNTIME_LOG_LOGSYSTEM_CLASS, NullLogSystem.class.getName());
+        props.put("resource.loader", "cayenne");
+        props.put("cayenne.resource.loader.class", ClassGeneratorResourceLoader.class.getName());
+        props.put("cayenne.resource.loader.cache", "false");
+
+        this.velocityEngine = new VelocityEngine();
+        this.velocityEngine.init(props);
+    }
+
+    protected String renderTemplate(String templateName, Context context) throws Exception {
+        StringWriter writer = new StringWriter();
+
+        Template template = velocityEngine.getTemplate(templateName);
+        template.merge(context, writer);
+
+        return writer.toString();
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/cayenne/blob/c63b6be2/cayenne-cgen/src/test/java/org/apache/cayenne/gen/ClientSuperClassGenerationTest.java
----------------------------------------------------------------------
diff --git a/cayenne-cgen/src/test/java/org/apache/cayenne/gen/ClientSuperClassGenerationTest.java b/cayenne-cgen/src/test/java/org/apache/cayenne/gen/ClientSuperClassGenerationTest.java
new file mode 100644
index 0000000..b690367
--- /dev/null
+++ b/cayenne-cgen/src/test/java/org/apache/cayenne/gen/ClientSuperClassGenerationTest.java
@@ -0,0 +1,86 @@
+/*****************************************************************
+ *   Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ ****************************************************************/
+
+package org.apache.cayenne.gen;
+
+import org.apache.cayenne.map.ObjAttribute;
+import org.apache.cayenne.map.ObjEntity;
+import org.apache.cayenne.map.ObjRelationship;
+import org.apache.velocity.VelocityContext;
+import org.junit.Test;
+
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
+public class ClientSuperClassGenerationTest extends ClassGenerationCase {
+
+    @Test
+    public void testNotContainsPropertyImport() throws Exception {
+        ObjEntity objEntity = new ObjEntity("TEST1");
+
+        VelocityContext context = new VelocityContext();
+        context.put(Artifact.OBJECT_KEY, objEntity);
+
+        String res = renderTemplate(ClientClassGenerationAction.SUPERCLASS_TEMPLATE, context);
+        assertFalse(res.contains("org.apache.cayenne.exp.Property"));
+    }
+
+    @Test
+    public void testContainsPropertyImportForAttributes() throws Exception {
+        ObjEntity objEntity = new ObjEntity("TEST1");
+        ObjAttribute attr = new ObjAttribute("attr");
+        objEntity.addAttribute(attr);
+
+        VelocityContext context = new VelocityContext();
+        context.put(Artifact.OBJECT_KEY, objEntity);
+
+        String res = renderTemplate(ClientClassGenerationAction.SUPERCLASS_TEMPLATE, context);
+        assertTrue(res.contains("org.apache.cayenne.exp.Property"));
+    }
+
+    @Test
+    public void testContainsPropertyImportForRelationships() throws Exception {
+        ObjEntity objEntity = new ObjEntity("TEST1");
+        ObjRelationship rel = new ObjRelationship("rel");
+        objEntity.addRelationship(rel);
+
+        VelocityContext context = new VelocityContext();
+        context.put(Artifact.OBJECT_KEY, objEntity);
+
+        String res = renderTemplate(ClientClassGenerationAction.SUPERCLASS_TEMPLATE, context);
+        assertTrue(res.contains("org.apache.cayenne.exp.Property"));
+    }
+
+    @Test
+    public void testContainsPropertyImport() throws Exception {
+        ObjEntity objEntity = new ObjEntity("TEST1");
+        ObjAttribute attr = new ObjAttribute("attr");
+        ObjRelationship rel = new ObjRelationship("rel");
+
+        objEntity.addAttribute(attr);
+        objEntity.addRelationship(rel);
+
+        VelocityContext context = new VelocityContext();
+        context.put(Artifact.OBJECT_KEY, objEntity);
+
+        String res = renderTemplate(ClientClassGenerationAction.SUPERCLASS_TEMPLATE, context);
+        assertTrue(res.contains("org.apache.cayenne.exp.Property"));
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/cayenne/blob/c63b6be2/cayenne-cgen/src/test/java/org/apache/cayenne/gen/EntityUtilsTest.java
----------------------------------------------------------------------
diff --git a/cayenne-cgen/src/test/java/org/apache/cayenne/gen/EntityUtilsTest.java b/cayenne-cgen/src/test/java/org/apache/cayenne/gen/EntityUtilsTest.java
new file mode 100644
index 0000000..21d7162
--- /dev/null
+++ b/cayenne-cgen/src/test/java/org/apache/cayenne/gen/EntityUtilsTest.java
@@ -0,0 +1,75 @@
+/*****************************************************************
+ *   Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ ****************************************************************/
+
+package org.apache.cayenne.gen;
+
+import org.apache.cayenne.map.CallbackDescriptor;
+import org.apache.cayenne.map.DataMap;
+import org.apache.cayenne.map.ObjEntity;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+
+import java.util.LinkedHashSet;
+import java.util.Set;
+
+import static org.junit.Assert.assertTrue;
+
+
+public class EntityUtilsTest {
+    
+    protected EntityUtils entityUtils = null;
+    protected DataMap dataMap = null;
+    protected ObjEntity objEntity = null;
+    
+    @Before
+    public void setUp() throws Exception {
+        dataMap = new DataMap();
+        objEntity = new ObjEntity();
+    }
+    
+    @After
+    public void tearDown() throws Exception {
+        dataMap = null;
+        objEntity = null;
+        entityUtils = null;
+    }
+
+    @Test
+    public void testAllCallbackNamesUnique() throws Exception {
+        
+        CallbackDescriptor[] callbacks = objEntity.getCallbackMap().getCallbacks();
+        for (int i = 0; i < callbacks.length; i++) {
+            callbacks[i].addCallbackMethod("callback1");
+            callbacks[i].addCallbackMethod("callback2");
+            callbacks[i].addCallbackMethod("callback3");
+        }
+        entityUtils = new EntityUtils(dataMap, objEntity, "TestBaseClass", "TestSuperClass", "TestSubClass");
+        
+        boolean hasNoDuplicates = true;
+        Set<String> callbackNames = new LinkedHashSet<String>();
+        for (String cbName : entityUtils.getCallbackNames()) {
+            if (!callbackNames.add(cbName)) {
+                hasNoDuplicates = false;
+            }
+        }
+        
+        assertTrue("Contains duplicate callback names.", hasNoDuplicates);
+    }
+}

http://git-wip-us.apache.org/repos/asf/cayenne/blob/c63b6be2/cayenne-cgen/src/test/java/org/apache/cayenne/gen/ImportUtilsTest.java
----------------------------------------------------------------------
diff --git a/cayenne-cgen/src/test/java/org/apache/cayenne/gen/ImportUtilsTest.java b/cayenne-cgen/src/test/java/org/apache/cayenne/gen/ImportUtilsTest.java
new file mode 100644
index 0000000..c6baa31
--- /dev/null
+++ b/cayenne-cgen/src/test/java/org/apache/cayenne/gen/ImportUtilsTest.java
@@ -0,0 +1,252 @@
+/*****************************************************************
+ *   Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ ****************************************************************/
+
+package org.apache.cayenne.gen;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
+public class ImportUtilsTest {
+
+    protected ImportUtils importUtils = null;
+
+    @Before
+    public void setUp() throws Exception {
+        importUtils = new ImportUtils();
+    }
+
+    @After
+    public void tearDown() throws Exception {
+        importUtils = null;
+    }
+
+    @Test
+    public void testSetPackageGeneratesPackageStatement() throws Exception {
+        final String packageName = "org.myPackage";
+        final String expectedPackageStatement = "package " + packageName + ";";
+
+        importUtils.setPackage(packageName);
+
+        String generatedStatements = importUtils.generate();
+        assertTrue("<"
+                + generatedStatements
+                + "> does not start with <"
+                + expectedPackageStatement
+                + ">", generatedStatements.startsWith(expectedPackageStatement));
+        assertEquals("package statement appears multiple times.", generatedStatements
+                .lastIndexOf(expectedPackageStatement), generatedStatements
+                .lastIndexOf(expectedPackageStatement));
+    }
+
+    @Test
+    public void testAddTypeGeneratesImportStatement() throws Exception {
+        final String type = "org.myPackage.myType";
+        final String expectedImportStatement = "import " + type + ";";
+
+        importUtils.addType(type);
+
+        String generatedStatements = importUtils.generate();
+        assertFalse("<"
+                + generatedStatements
+                + "> does not contain <"
+                + expectedImportStatement
+                + ">", !generatedStatements.contains(expectedImportStatement));
+        assertEquals("import statement appears multiple times.", generatedStatements
+                .lastIndexOf(expectedImportStatement), generatedStatements
+                .lastIndexOf(expectedImportStatement));
+    }
+
+    @Test
+    public void testAddReservedTypeGeneratesNoImportStatement() throws Exception {
+        final String type = "org.myPackage.myType";
+
+        importUtils.addReservedType(type);
+
+        String generatedStatements = importUtils.generate();
+        assertEquals(
+                "<" + generatedStatements + "> contains <" + type + ">",
+                -1,
+                generatedStatements.indexOf(type));
+    }
+
+    @Test
+    public void testAddTypeAfterReservedTypeGeneratesNoImportStatement() throws Exception {
+        final String baseType = "myType";
+        final String reservedType = "org.myPackage." + baseType;
+        final String nonReservedType = "org.myPackage2." + baseType;
+
+        importUtils.addReservedType(reservedType);
+        importUtils.addType(nonReservedType);
+
+        String generatedStatements = importUtils.generate();
+        assertEquals(
+                "<" + generatedStatements + "> contains <" + reservedType + ">",
+                -1,
+                generatedStatements.indexOf(reservedType));
+        assertEquals(
+                "<" + generatedStatements + "> contains <" + nonReservedType + ">",
+                -1,
+                generatedStatements.indexOf(nonReservedType));
+    }
+
+    @Test
+    public void testAddTypeAfterPackageReservedTypeGeneratesNoImportStatement()
+            throws Exception {
+        final String baseType = "myType";
+        final String packageType = "org.myPackage";
+        final String reservedType = packageType + "." + baseType;
+        final String nonReservedType = "org.myPackage2." + baseType;
+
+        importUtils.setPackage(packageType);
+        importUtils.addReservedType(reservedType);
+        importUtils.addType(nonReservedType);
+
+        String generatedStatements = importUtils.generate();
+
+        assertEquals(
+                "<" + generatedStatements + "> contains <" + reservedType + ">",
+                -1,
+                generatedStatements.indexOf(reservedType));
+        assertEquals(
+                "<" + generatedStatements + "> contains <" + nonReservedType + ">",
+                -1,
+                generatedStatements.indexOf(nonReservedType));
+    }
+
+    @Test
+    public void testAddTypeAfterTypeGeneratesNoImportStatement() throws Exception {
+        final String baseType = "myType";
+        final String firstType = "org.myPackage." + baseType;
+        final String secondType = "org.myPackage2." + baseType;
+
+        final String expectedImportStatement = "import " + firstType + ";";
+
+        importUtils.addType(firstType);
+        importUtils.addType(secondType);
+
+        String generatedStatements = importUtils.generate();
+
+        assertFalse("<"
+                + generatedStatements
+                + "> does not contain <"
+                + expectedImportStatement
+                + ">", !generatedStatements.contains(expectedImportStatement));
+        assertEquals("import statement appears multiple times.", generatedStatements
+                .lastIndexOf(expectedImportStatement), generatedStatements
+                .lastIndexOf(expectedImportStatement));
+
+        assertEquals(
+                "<" + generatedStatements + "> contains <" + secondType + ">",
+                -1,
+                generatedStatements.indexOf(secondType));
+    }
+
+    @Test
+    public void testAddSimilarTypeTwiceBeforeFormatJavaTypeGeneratesCorrectFQNs()
+            throws Exception {
+        final String baseType = "myType";
+        final String firstType = "org.myPackage." + baseType;
+        final String secondType = "org.myPackage2." + baseType;
+
+        importUtils.addType(firstType);
+        importUtils.addType(secondType);
+
+        assertEquals(baseType, importUtils.formatJavaType(firstType));
+        assertEquals(secondType, importUtils.formatJavaType(secondType));
+    }
+
+    @Test
+    public void testAddTypeBeforeFormatJavaTypeGeneratesCorrectFQNs() throws Exception {
+        final String baseType = "myType";
+        final String fullyQualifiedType = "org.myPackage." + baseType;
+
+        importUtils.addType(fullyQualifiedType);
+
+        assertEquals(baseType, importUtils.formatJavaType(fullyQualifiedType));
+    }
+
+    @Test
+    public void testAddReservedTypeBeforeFormatJavaTypeGeneratesCorrectFQNs()
+            throws Exception {
+        final String baseType = "myType";
+        final String fullyQualifiedType = "org.myPackage." + baseType;
+
+        importUtils.addReservedType(fullyQualifiedType);
+
+        assertEquals(fullyQualifiedType, importUtils.formatJavaType(fullyQualifiedType));
+    }
+
+    @Test
+    public void testFormatJavaTypeWithPrimitives() throws Exception {
+        assertEquals("int", importUtils.formatJavaType("int", true));
+        assertEquals("Integer", importUtils.formatJavaType("int", false));
+
+        assertEquals("char", importUtils.formatJavaType("char", true));
+        assertEquals("Character", importUtils
+                .formatJavaType("java.lang.Character", false));
+
+        assertEquals("double", importUtils.formatJavaType("java.lang.Double", true));
+        assertEquals("Double", importUtils.formatJavaType("java.lang.Double", false));
+
+        assertEquals("a.b.C", importUtils.formatJavaType("a.b.C", true));
+        assertEquals("a.b.C", importUtils.formatJavaType("a.b.C", false));
+    }
+
+    @Test
+    public void testFormatJavaTypeWithoutAddTypeGeneratesCorrectFQNs() throws Exception {
+        final String baseType = "myType";
+        final String fullyQualifiedType = "org.myPackage." + baseType;
+
+        assertEquals(fullyQualifiedType, importUtils.formatJavaType(fullyQualifiedType));
+    }
+
+    @Test
+    public void testPackageFormatJavaTypeWithoutAddTypeGeneratesCorrectFQNs()
+            throws Exception {
+        final String baseType = "myType";
+        final String packageType = "org.myPackage";
+        final String fullyQualifiedType = packageType + "." + baseType;
+
+        importUtils.setPackage(packageType);
+
+        assertEquals(baseType, importUtils.formatJavaType(fullyQualifiedType));
+    }
+
+    @Test
+    public void testFormatJavaType() {
+        assertEquals("x.X", importUtils.formatJavaType("x.X"));
+        assertEquals("X", importUtils.formatJavaType("java.lang.X"));
+        assertEquals("java.lang.x.X", importUtils.formatJavaType("java.lang.x.X"));
+    }
+
+    @Test
+    public void testJavaLangTypeFormatJavaTypeWithoutAddTypeGeneratesCorrectFQNs()
+            throws Exception {
+        final String baseType = "myType";
+        final String packageType = "java.lang";
+        final String fullyQualifiedType = packageType + "." + baseType;
+
+        assertEquals(baseType, importUtils.formatJavaType(fullyQualifiedType));
+    }
+}

http://git-wip-us.apache.org/repos/asf/cayenne/blob/c63b6be2/cayenne-cgen/src/test/java/org/apache/cayenne/gen/SingleClassGenerationTest.java
----------------------------------------------------------------------
diff --git a/cayenne-cgen/src/test/java/org/apache/cayenne/gen/SingleClassGenerationTest.java b/cayenne-cgen/src/test/java/org/apache/cayenne/gen/SingleClassGenerationTest.java
new file mode 100644
index 0000000..0bbe9e9
--- /dev/null
+++ b/cayenne-cgen/src/test/java/org/apache/cayenne/gen/SingleClassGenerationTest.java
@@ -0,0 +1,86 @@
+/*****************************************************************
+ *   Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ ****************************************************************/
+
+package org.apache.cayenne.gen;
+
+import org.apache.cayenne.map.ObjAttribute;
+import org.apache.cayenne.map.ObjEntity;
+import org.apache.cayenne.map.ObjRelationship;
+import org.apache.velocity.VelocityContext;
+import org.junit.Test;
+
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
+public class SingleClassGenerationTest extends ClassGenerationCase {
+
+    @Test
+    public void testNotContainsPropertyImport() throws Exception {
+        ObjEntity objEntity = new ObjEntity("TEST1");
+
+        VelocityContext context = new VelocityContext();
+        context.put(Artifact.OBJECT_KEY, objEntity);
+
+        String res = renderTemplate(ClassGenerationAction.SINGLE_CLASS_TEMPLATE, context);
+        assertFalse(res.contains("org.apache.cayenne.exp.Property"));
+    }
+
+    @Test
+    public void testContainsPropertyImportForAttributes() throws Exception {
+        ObjEntity objEntity = new ObjEntity("TEST1");
+        ObjAttribute attr = new ObjAttribute("attr");
+        objEntity.addAttribute(attr);
+
+        VelocityContext context = new VelocityContext();
+        context.put(Artifact.OBJECT_KEY, objEntity);
+
+        String res = renderTemplate(ClassGenerationAction.SINGLE_CLASS_TEMPLATE, context);
+        assertTrue(res.contains("org.apache.cayenne.exp.Property"));
+    }
+
+    @Test
+    public void testContainsPropertyImportForRelationships() throws Exception {
+        ObjEntity objEntity = new ObjEntity("TEST1");
+        ObjRelationship rel = new ObjRelationship("rel");
+        objEntity.addRelationship(rel);
+
+        VelocityContext context = new VelocityContext();
+        context.put(Artifact.OBJECT_KEY, objEntity);
+
+        String res = renderTemplate(ClassGenerationAction.SINGLE_CLASS_TEMPLATE, context);
+        assertTrue(res.contains("org.apache.cayenne.exp.Property"));
+    }
+
+    @Test
+    public void testContainsPropertyImport() throws Exception {
+        ObjEntity objEntity = new ObjEntity("TEST1");
+        ObjAttribute attr = new ObjAttribute("attr");
+        ObjRelationship rel = new ObjRelationship("rel");
+
+        objEntity.addAttribute(attr);
+        objEntity.addRelationship(rel);
+
+        VelocityContext context = new VelocityContext();
+        context.put(Artifact.OBJECT_KEY, objEntity);
+
+        String res = renderTemplate(ClassGenerationAction.SINGLE_CLASS_TEMPLATE, context);
+        assertTrue(res.contains("org.apache.cayenne.exp.Property"));
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/cayenne/blob/c63b6be2/cayenne-cgen/src/test/java/org/apache/cayenne/gen/StringUtilsTest.java
----------------------------------------------------------------------
diff --git a/cayenne-cgen/src/test/java/org/apache/cayenne/gen/StringUtilsTest.java b/cayenne-cgen/src/test/java/org/apache/cayenne/gen/StringUtilsTest.java
new file mode 100644
index 0000000..84e7e5e
--- /dev/null
+++ b/cayenne-cgen/src/test/java/org/apache/cayenne/gen/StringUtilsTest.java
@@ -0,0 +1,124 @@
+/*****************************************************************
+ *   Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ ****************************************************************/
+
+package org.apache.cayenne.gen;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+
+import static org.junit.Assert.assertEquals;
+
+public class StringUtilsTest {
+
+    protected StringUtils stringUtils;
+
+    @Before
+    public void setUp() throws Exception {
+        stringUtils = new StringUtils();
+    }
+
+    @After
+    public void tearDown() throws Exception {
+        stringUtils = null;
+    }
+
+    @Test
+    public void testPluralize() throws Exception {
+        assertEquals("Words", stringUtils.pluralize("Word"));
+        assertEquals("Statuses", stringUtils.pluralize("Status"));
+        assertEquals("Indexes", stringUtils.pluralize("Index"));
+        assertEquals("Factories", stringUtils.pluralize("Factory"));
+        assertEquals("", stringUtils.pluralize(""));
+        assertEquals(null, stringUtils.pluralize(null));
+    }
+
+
+    @Test
+    public void testCapitalizedAsConstant1() throws Exception {
+        String expected = "LAST_NAME";
+        assertEquals(expected, stringUtils.capitalizedAsConstant("LastName"));
+    }
+
+    @Test
+    public void testCapitalizedAsConstant2() throws Exception {
+        String expected = "A_CLASS";
+        assertEquals(expected, stringUtils.capitalizedAsConstant("aClass"));
+    }
+
+    @Test
+    public void testCapitalizedAsConstant3() throws Exception {
+        String expected = "VAR_A";
+        assertEquals(expected, stringUtils.capitalizedAsConstant("varA"));
+    }
+
+    @Test
+    public void testCapitalizedAsConstant4() throws Exception {
+        String expected = "LAST_NAME";
+        assertEquals(expected, stringUtils.capitalizedAsConstant("LAST_NAME"));
+    }
+
+    @Test
+    public void testCapitalizedAsConstant5() throws Exception {
+        String expected = "ABC_A";
+        assertEquals(expected, stringUtils.capitalizedAsConstant("abc_A"));
+    }
+
+    @Test
+    public void testCapitalizedAsConstant6() throws Exception {
+        String expected = "A123";
+        assertEquals(expected, stringUtils.capitalizedAsConstant("a123"));
+    }
+
+    @Test
+    public void testCapitalizedAsConstant7() throws Exception {
+        String expected = "AB_CDEF";
+        assertEquals(expected, stringUtils.capitalizedAsConstant("abCDEF"));
+    }
+
+    @Test
+    public void testCapitalizedAsConstant8() throws Exception {
+        String expected = "AB_CE";
+        assertEquals(expected, stringUtils.capitalizedAsConstant("abCe"));
+    }
+
+    @Test
+    public void testStripGeneric() throws Exception {
+        assertEquals("List", stringUtils.stripGeneric("List"));
+        assertEquals("List", stringUtils.stripGeneric("List<Integer>"));
+        assertEquals("List", stringUtils.stripGeneric("List<List<Map<Integer,List<String>>>>"));
+        assertEquals("List123", stringUtils.stripGeneric("List<List<Map<Integer,List<String>>>>123"));
+        assertEquals("List<Integer", stringUtils.stripGeneric("List<Integer"));
+    }
+
+    /**
+     * Test pattern expansion.
+     */
+    @Test
+    public void testReplaceWildcardInStringWithString() throws Exception {
+        assertEquals(null, stringUtils.replaceWildcardInStringWithString("*", null, "Entity"));
+        assertEquals("*.java", stringUtils.replaceWildcardInStringWithString(null, "*.java", "Entity"));
+        assertEquals("Entity.java", stringUtils.replaceWildcardInStringWithString("*", "*.java", "Entity"));
+        assertEquals("java.Entity", stringUtils.replaceWildcardInStringWithString("*", "java.*", "Entity"));
+        assertEquals("Entity.Entity", stringUtils.replaceWildcardInStringWithString("*", "*.*", "Entity"));
+        assertEquals("EntityEntity", stringUtils.replaceWildcardInStringWithString("*", "**", "Entity"));
+        assertEquals("EditEntityReport.vm", stringUtils.replaceWildcardInStringWithString("*", "Edit*Report.vm", "Entity"));
+        assertEquals("Entity", stringUtils.replaceWildcardInStringWithString("*", "*", "Entity"));
+    }
+}

http://git-wip-us.apache.org/repos/asf/cayenne/blob/c63b6be2/cayenne-cgen/src/test/java/org/apache/cayenne/gen/SuperClassGenerationTest.java
----------------------------------------------------------------------
diff --git a/cayenne-cgen/src/test/java/org/apache/cayenne/gen/SuperClassGenerationTest.java b/cayenne-cgen/src/test/java/org/apache/cayenne/gen/SuperClassGenerationTest.java
new file mode 100644
index 0000000..0a47d63
--- /dev/null
+++ b/cayenne-cgen/src/test/java/org/apache/cayenne/gen/SuperClassGenerationTest.java
@@ -0,0 +1,86 @@
+/*****************************************************************
+ *   Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ ****************************************************************/
+
+package org.apache.cayenne.gen;
+
+import org.apache.cayenne.map.ObjAttribute;
+import org.apache.cayenne.map.ObjEntity;
+import org.apache.cayenne.map.ObjRelationship;
+import org.apache.velocity.VelocityContext;
+import org.junit.Test;
+
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
+public class SuperClassGenerationTest extends ClassGenerationCase {
+
+    @Test
+    public void testNotContainsPropertyImport() throws Exception {
+        ObjEntity objEntity = new ObjEntity("TEST1");
+
+        VelocityContext context = new VelocityContext();
+        context.put(Artifact.OBJECT_KEY, objEntity);
+
+        String res = renderTemplate(ClassGenerationAction.SUPERCLASS_TEMPLATE, context);
+        assertFalse(res.contains("org.apache.cayenne.exp.Property"));
+    }
+
+    @Test
+    public void testContainsPropertyImportForAttributes() throws Exception {
+        ObjEntity objEntity = new ObjEntity("TEST1");
+        ObjAttribute attr = new ObjAttribute("attr");
+        objEntity.addAttribute(attr);
+
+        VelocityContext context = new VelocityContext();
+        context.put(Artifact.OBJECT_KEY, objEntity);
+
+        String res = renderTemplate(ClassGenerationAction.SUPERCLASS_TEMPLATE, context);
+        assertTrue(res.contains("org.apache.cayenne.exp.Property"));
+    }
+
+    @Test
+    public void testContainsPropertyImportForRelationships() throws Exception {
+        ObjEntity objEntity = new ObjEntity("TEST1");
+        ObjRelationship rel = new ObjRelationship("rel");
+        objEntity.addRelationship(rel);
+
+        VelocityContext context = new VelocityContext();
+        context.put(Artifact.OBJECT_KEY, objEntity);
+
+        String res = renderTemplate(ClassGenerationAction.SUPERCLASS_TEMPLATE, context);
+        assertTrue(res.contains("org.apache.cayenne.exp.Property"));
+    }
+
+    @Test
+    public void testContainsPropertyImport() throws Exception {
+        ObjEntity objEntity = new ObjEntity("TEST1");
+        ObjAttribute attr = new ObjAttribute("attr");
+        ObjRelationship rel = new ObjRelationship("rel");
+
+        objEntity.addAttribute(attr);
+        objEntity.addRelationship(rel);
+
+        VelocityContext context = new VelocityContext();
+        context.put(Artifact.OBJECT_KEY, objEntity);
+
+        String res = renderTemplate(ClassGenerationAction.SUPERCLASS_TEMPLATE, context);
+        assertTrue(res.contains("org.apache.cayenne.exp.Property"));
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/cayenne/blob/c63b6be2/cayenne-client-jetty/pom.xml
----------------------------------------------------------------------
diff --git a/cayenne-client-jetty/pom.xml b/cayenne-client-jetty/pom.xml
index 0f1b41c..0fae133 100644
--- a/cayenne-client-jetty/pom.xml
+++ b/cayenne-client-jetty/pom.xml
@@ -121,7 +121,7 @@
                     <target>1.8</target>
                 </configuration>
             </plugin>
-            <!-- This ensures LICESNE and NOTICE inclusion in all jars -->
+            <!-- This ensures LICENSE and NOTICE inclusion in all jars -->
             <plugin>
                 <artifactId>maven-remote-resources-plugin</artifactId>
                 <executions>

http://git-wip-us.apache.org/repos/asf/cayenne/blob/c63b6be2/cayenne-client/pom.xml
----------------------------------------------------------------------
diff --git a/cayenne-client/pom.xml b/cayenne-client/pom.xml
index 2d16644..a9112a5 100644
--- a/cayenne-client/pom.xml
+++ b/cayenne-client/pom.xml
@@ -93,7 +93,7 @@
 
 	<build>
 		<plugins>
-			<!-- This ensures LICESNE and NOTICE inclusion in all jars -->
+			<!-- This ensures LICENSE and NOTICE inclusion in all jars -->
             <plugin>
                 <artifactId>maven-remote-resources-plugin</artifactId>
                 <executions>

http://git-wip-us.apache.org/repos/asf/cayenne/blob/c63b6be2/cayenne-dbcp2/pom.xml
----------------------------------------------------------------------
diff --git a/cayenne-dbcp2/pom.xml b/cayenne-dbcp2/pom.xml
index b44c5af..35d9771 100644
--- a/cayenne-dbcp2/pom.xml
+++ b/cayenne-dbcp2/pom.xml
@@ -49,7 +49,7 @@
     </dependencies>
     <build>
         <plugins>
-            <!-- This ensures LICESNE and NOTICE inclusion in all jars -->
+            <!-- This ensures LICENSE and NOTICE inclusion in all jars -->
             <plugin>
                 <artifactId>maven-remote-resources-plugin</artifactId>
                 <executions>

http://git-wip-us.apache.org/repos/asf/cayenne/blob/c63b6be2/cayenne-dbsync/pom.xml
----------------------------------------------------------------------
diff --git a/cayenne-dbsync/pom.xml b/cayenne-dbsync/pom.xml
index d94de3f..367c671 100644
--- a/cayenne-dbsync/pom.xml
+++ b/cayenne-dbsync/pom.xml
@@ -96,7 +96,7 @@
 
 	<build>
 		<plugins>
-			<!-- This ensures LICESNE and NOTICE inclusion in all jars -->
+			<!-- This ensures LICENSE and NOTICE inclusion in all jars -->
             <plugin>
                 <artifactId>maven-remote-resources-plugin</artifactId>
                 <executions>

http://git-wip-us.apache.org/repos/asf/cayenne/blob/c63b6be2/cayenne-dbsync/src/main/java/org/apache/cayenne/dbsync/filter/NamePatternMatcher.java
----------------------------------------------------------------------
diff --git a/cayenne-dbsync/src/main/java/org/apache/cayenne/dbsync/filter/NamePatternMatcher.java b/cayenne-dbsync/src/main/java/org/apache/cayenne/dbsync/filter/NamePatternMatcher.java
index 66d2b96..cb379da 100644
--- a/cayenne-dbsync/src/main/java/org/apache/cayenne/dbsync/filter/NamePatternMatcher.java
+++ b/cayenne-dbsync/src/main/java/org/apache/cayenne/dbsync/filter/NamePatternMatcher.java
@@ -203,31 +203,4 @@ public class NamePatternMatcher implements NameFilter {
         return true;
     }
 
-    public static String replaceWildcardInStringWithString(
-            String wildcard,
-            String pattern,
-            String replacement) {
-
-        if (pattern == null || wildcard == null) {
-            return pattern;
-        }
-
-        StringBuilder buffer = new StringBuilder();
-        int lastPos = 0;
-        int wildCardPos = pattern.indexOf(wildcard);
-        while (wildCardPos != -1) {
-            if (lastPos != wildCardPos) {
-                buffer.append(pattern.substring(lastPos, wildCardPos));
-            }
-            buffer.append(replacement);
-            lastPos += wildCardPos + wildcard.length();
-            wildCardPos = pattern.indexOf(wildcard, lastPos);
-        }
-
-        if (lastPos < pattern.length()) {
-            buffer.append(pattern.substring(lastPos));
-        }
-
-        return buffer.toString();
-    }
 }