cayenne-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aadamc...@apache.org
Subject svn commit: r602737 - in /cayenne/main/trunk/framework: cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/gen/ cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/tools/ cayenne-jdk1.5-unpublished/src/main/resources/dotemplates/v1_2/ ...
Date Sun, 09 Dec 2007 22:10:18 GMT
Author: aadamchik
Date: Sun Dec  9 14:10:17 2007
New Revision: 602737

URL: http://svn.apache.org/viewvc?rev=602737&view=rev
Log:
CAY-933 Embeddable classes - support class generation

Modified:
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/gen/ClassGenerationAction1_1.java
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/gen/EmbeddableArtifact.java
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/tools/CayenneGeneratorEntityFilterAction.java
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/tools/CayenneGeneratorTask.java
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/resources/dotemplates/v1_2/embeddable-singleclass.vm
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/resources/dotemplates/v1_2/embeddable-subclass.vm
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/resources/dotemplates/v1_2/embeddable-superclass.vm
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/tools/CayenneGeneratorTaskTest.java
    cayenne/main/trunk/framework/maven-cayenne-plugin/src/main/java/org/apache/cayenne/tools/CayenneGeneratorMojo.java

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/gen/ClassGenerationAction1_1.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/gen/ClassGenerationAction1_1.java?rev=602737&r1=602736&r2=602737&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/gen/ClassGenerationAction1_1.java
(original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/gen/ClassGenerationAction1_1.java
Sun Dec  9 14:10:17 2007
@@ -58,8 +58,7 @@
 
     @Override
     public void addEmbeddables(Collection<Embeddable> embeddables) {
-        throw new UnsupportedOperationException(
-                "Embeddables are not supported in 1.1 mode");
+        // noop - no embeddables support
     }
 
     @Override

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/gen/EmbeddableArtifact.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/gen/EmbeddableArtifact.java?rev=602737&r1=602736&r2=602737&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/gen/EmbeddableArtifact.java
(original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/gen/EmbeddableArtifact.java
Sun Dec  9 14:10:17 2007
@@ -48,7 +48,19 @@
     }
 
     public TemplateType[] getTemplateTypes(ArtifactGenerationMode mode) {
-        return null;
+        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) {

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/tools/CayenneGeneratorEntityFilterAction.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/tools/CayenneGeneratorEntityFilterAction.java?rev=602737&r1=602736&r2=602737&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/tools/CayenneGeneratorEntityFilterAction.java
(original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/tools/CayenneGeneratorEntityFilterAction.java
Sun Dec  9 14:10:17 2007
@@ -25,6 +25,7 @@
 import java.util.List;
 
 import org.apache.cayenne.map.DataMap;
+import org.apache.cayenne.map.Embeddable;
 import org.apache.cayenne.map.ObjEntity;
 
 /**
@@ -38,6 +39,26 @@
 
     private NamePatternMatcher nameFilter;
     private boolean client;
+
+    Collection<Embeddable> getFilteredEmbeddables(DataMap mainDataMap) {
+        List<Embeddable> embeddables = new ArrayList<Embeddable>(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 {

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/tools/CayenneGeneratorTask.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/tools/CayenneGeneratorTask.java?rev=602737&r1=602736&r2=602737&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/tools/CayenneGeneratorTask.java
(original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/tools/CayenneGeneratorTask.java
Sun Dec  9 14:10:17 2007
@@ -20,12 +20,13 @@
 
 import java.io.File;
 
+import org.apache.cayenne.gen.ArtifactsGenerationMode;
 import org.apache.cayenne.gen.ClassGenerationAction;
 import org.apache.cayenne.gen.ClassGenerationAction1_1;
 import org.apache.cayenne.gen.ClassGenerator;
-import org.apache.cayenne.gen.ArtifactsGenerationMode;
 import org.apache.cayenne.gen.ClientClassGenerationAction;
 import org.apache.cayenne.gen.DefaultClassGenerator;
+import org.apache.cayenne.map.DataMap;
 import org.apache.tools.ant.BuildException;
 import org.apache.tools.ant.types.Path;
 import org.apache.velocity.VelocityContext;
@@ -91,7 +92,8 @@
         action.setDestDir(destDir);
         action.setEncoding(encoding);
         action.setMakePairs(makepairs);
-        action.setArtifactsGenerationMode(ArtifactsGenerationMode.valueOf(mode.toLowerCase()));
+        action.setArtifactsGenerationMode(ArtifactsGenerationMode.valueOf(mode
+                .toLowerCase()));
         action.setOutputPattern(outputPattern);
         action.setOverwrite(overwrite);
         action.setSuperPkg(superpkg);
@@ -144,12 +146,15 @@
                 excludeEntitiesPattern));
 
         try {
+
+            DataMap dataMap = loadAction.getMainDataMap();
+
             ClassGenerationAction generatorAction = createGeneratorAction();
             generatorAction.setLogger(logger);
             generatorAction.setTimestamp(map.lastModified());
-            generatorAction.setDataMap(loadAction.getMainDataMap());
-            generatorAction.addEntities(filterAction.getFilteredEntities(loadAction
-                    .getMainDataMap()));
+            generatorAction.setDataMap(dataMap);
+            generatorAction.addEntities(filterAction.getFilteredEntities(dataMap));
+            generatorAction.addEmbeddables(filterAction.getFilteredEmbeddables(dataMap));
             generatorAction.execute();
         }
         catch (Exception e) {

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/resources/dotemplates/v1_2/embeddable-singleclass.vm
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/resources/dotemplates/v1_2/embeddable-singleclass.vm?rev=602737&r1=602736&r2=602737&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/resources/dotemplates/v1_2/embeddable-singleclass.vm
(original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/resources/dotemplates/v1_2/embeddable-singleclass.vm
Sun Dec  9 14:10:17 2007
@@ -15,16 +15,83 @@
 ##  specific language governing permissions and limitations
 ##  under the License.
 ##
-##Terminology:
+##  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
 ##
-##  Classes available in template
-##    embeddable - the Embeddable class: See org.apache.cayenne.map.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
-##    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 
 ##
 ##
-// singleclass
\ No newline at end of file
+${importUtils.setPackage($subPackageName)}##
+${importUtils.addReservedType("${subPackageName}.${subClassName}")}##
+${importUtils.addType("${basePackageName}.${baseClassName}")}##
+${importUtils.addType("org.apache.cayenne.Persistent")}##
+#foreach( $attr in ${object.Attributes} )
+$importUtils.addType(${attr.Type})##
+#end
+${importUtils.generate()}
+
+public abstract class ${subClassName} extends ${baseClassName} {
+
+## Create property names
+#foreach( $attr in ${object.Attributes} )
+    public static final String ${stringUtils.capitalizedAsConstant($attr.Name)}_PROPERTY
= "${attr.Name}";
+#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)}() {
+        Boolean value = (Boolean)readProperty("${attr.Name}");
+        return (value != null) ? value.booleanValue() : false;
+    }
+#elseif ( $importUtils.isNonBooleanPrimitive(${attr.Type}) )
+    public $classGen.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
+}

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/resources/dotemplates/v1_2/embeddable-subclass.vm
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/resources/dotemplates/v1_2/embeddable-subclass.vm?rev=602737&r1=602736&r2=602737&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/resources/dotemplates/v1_2/embeddable-subclass.vm
(original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/resources/dotemplates/v1_2/embeddable-subclass.vm
Sun Dec  9 14:10:17 2007
@@ -15,16 +15,31 @@
 ##  specific language governing permissions and limitations
 ##  under the License.
 ##
-##Terminology:
+##  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
 ##
-##  Classes available in template
-##    embeddable - the Embeddable class: See org.apache.cayenne.map.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
-##    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 
 ##
 ##
-// subclass
\ No newline at end of file
+${importUtils.setPackage($subPackageName)}##
+${importUtils.addReservedType("${subPackageName}.${subClassName}")}##
+${importUtils.addType("${superPackageName}.${superClassName}")}##
+${importUtils.generate()}
+
+
+public class ${subClassName} extends ${superClassName} {
+
+}
\ No newline at end of file

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/resources/dotemplates/v1_2/embeddable-superclass.vm
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/resources/dotemplates/v1_2/embeddable-superclass.vm?rev=602737&r1=602736&r2=602737&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/resources/dotemplates/v1_2/embeddable-superclass.vm
(original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/resources/dotemplates/v1_2/embeddable-superclass.vm
Sun Dec  9 14:10:17 2007
@@ -15,16 +15,89 @@
 ##  specific language governing permissions and limitations
 ##  under the License.
 ##
-##Terminology:
+##  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
 ##
-##  Classes available in template
-##    embeddable - the Embeddable class: See org.apache.cayenne.map.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
-##    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 
 ##
 ##
-// superclass
\ No newline at end of file
+${importUtils.setPackage($superPackageName)}##
+${importUtils.addReservedType("${superPackageName}.${superClassName}")}##
+${importUtils.addType("${basePackageName}.${baseClassName}")}##
+${importUtils.addType("org.apache.cayenne.Persistent")}##
+#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
+#foreach( $attr in ${object.Attributes} )
+    public static final String ${stringUtils.capitalizedAsConstant($attr.Name)}_PROPERTY
= "${attr.Name}";
+#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)}() {
+        Boolean value = (Boolean)readProperty("${attr.Name}");
+        return (value != null) ? value.booleanValue() : false;
+    }
+#elseif ( $importUtils.isNonBooleanPrimitive(${attr.Type}) )
+    public $classGen.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
+}

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/tools/CayenneGeneratorTaskTest.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/tools/CayenneGeneratorTaskTest.java?rev=602737&r1=602736&r2=602737&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/tools/CayenneGeneratorTaskTest.java
(original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/tools/CayenneGeneratorTaskTest.java
Sun Dec  9 14:10:17 2007
@@ -273,25 +273,25 @@
                 "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");
+        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) {

Modified: cayenne/main/trunk/framework/maven-cayenne-plugin/src/main/java/org/apache/cayenne/tools/CayenneGeneratorMojo.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/maven-cayenne-plugin/src/main/java/org/apache/cayenne/tools/CayenneGeneratorMojo.java?rev=602737&r1=602736&r2=602737&view=diff
==============================================================================
--- cayenne/main/trunk/framework/maven-cayenne-plugin/src/main/java/org/apache/cayenne/tools/CayenneGeneratorMojo.java
(original)
+++ cayenne/main/trunk/framework/maven-cayenne-plugin/src/main/java/org/apache/cayenne/tools/CayenneGeneratorMojo.java
Sun Dec  9 14:10:17 2007
@@ -26,6 +26,7 @@
 import org.apache.cayenne.gen.ClassGenerationAction1_1;
 import org.apache.cayenne.gen.ClassGenerator;
 import org.apache.cayenne.gen.ClientClassGenerationAction;
+import org.apache.cayenne.map.DataMap;
 import org.apache.commons.logging.Log;
 import org.apache.maven.plugin.AbstractMojo;
 import org.apache.maven.plugin.MojoExecutionException;
@@ -218,12 +219,14 @@
 		try {
 			loaderAction.setAdditionalDataMapFiles(convertAdditionalDataMaps());
 
+			DataMap dataMap = loaderAction.getMainDataMap();
+			
 			ClassGenerationAction generator = createGenerator();
 			generator.setLogger(logger);
 			generator.setTimestamp(map.lastModified());
-			generator.setDataMap(loaderAction.getMainDataMap());
-			generator.addEntities(filterAction.getFilteredEntities(loaderAction
-					.getMainDataMap()));
+			generator.setDataMap(dataMap);
+			generator.addEntities(filterAction.getFilteredEntities(dataMap));
+			generator.addEmbeddables(filterAction.getFilteredEmbeddables(dataMap));
 			generator.execute();
 		} catch (Exception e) {
 			throw new MojoExecutionException("Error generating classes: ", e);



Mime
View raw message