cayenne-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aadamc...@apache.org
Subject svn commit: r397938 - in /incubator/cayenne/trunk/cayenne-jpa/src: main/java/org/apache/cayenne/jpa/bridge/ main/java/org/apache/cayenne/jpa/map/ test/java/org/apache/cayenne/jpa/bridge/ test/java/org/apache/cayenne/jpa/entity/cayenne/
Date Fri, 28 Apr 2006 16:00:26 GMT
Author: aadamchik
Date: Fri Apr 28 09:00:24 2006
New Revision: 397938

URL: http://svn.apache.org/viewcvs?rev=397938&view=rev
Log:
more DataMap converter stuff

Added:
    incubator/cayenne/trunk/cayenne-jpa/src/test/java/org/apache/cayenne/jpa/entity/cayenne/
    incubator/cayenne/trunk/cayenne-jpa/src/test/java/org/apache/cayenne/jpa/entity/cayenne/MockCayenneEntity1.java
    incubator/cayenne/trunk/cayenne-jpa/src/test/java/org/apache/cayenne/jpa/entity/cayenne/MockCayenneEntity2.java
    incubator/cayenne/trunk/cayenne-jpa/src/test/java/org/apache/cayenne/jpa/entity/cayenne/MockCayenneEntityMap1.java
Modified:
    incubator/cayenne/trunk/cayenne-jpa/src/main/java/org/apache/cayenne/jpa/bridge/DataMapConverter.java
    incubator/cayenne/trunk/cayenne-jpa/src/main/java/org/apache/cayenne/jpa/map/JpaAttribute.java
    incubator/cayenne/trunk/cayenne-jpa/src/main/java/org/apache/cayenne/jpa/map/JpaEntityMap.java
    incubator/cayenne/trunk/cayenne-jpa/src/test/java/org/apache/cayenne/jpa/bridge/DataMapConverterTest.java
    incubator/cayenne/trunk/cayenne-jpa/src/test/java/org/apache/cayenne/jpa/bridge/DataMapMappingAssertion.java

Modified: incubator/cayenne/trunk/cayenne-jpa/src/main/java/org/apache/cayenne/jpa/bridge/DataMapConverter.java
URL: http://svn.apache.org/viewcvs/incubator/cayenne/trunk/cayenne-jpa/src/main/java/org/apache/cayenne/jpa/bridge/DataMapConverter.java?rev=397938&r1=397937&r2=397938&view=diff
==============================================================================
--- incubator/cayenne/trunk/cayenne-jpa/src/main/java/org/apache/cayenne/jpa/bridge/DataMapConverter.java
(original)
+++ incubator/cayenne/trunk/cayenne-jpa/src/main/java/org/apache/cayenne/jpa/bridge/DataMapConverter.java
Fri Apr 28 09:00:24 2006
@@ -55,16 +55,25 @@
  */
 package org.apache.cayenne.jpa.bridge;
 
+import java.beans.PropertyDescriptor;
+import java.lang.reflect.Field;
+
+import org.apache.cayenne.jpa.JpaProviderException;
+import org.apache.cayenne.jpa.map.AccessType;
 import org.apache.cayenne.jpa.map.JpaAttribute;
 import org.apache.cayenne.jpa.map.JpaEntity;
 import org.apache.cayenne.jpa.map.JpaEntityMap;
 import org.apache.cayenne.jpa.map.JpaNamedQuery;
 import org.apache.cayenne.jpa.map.JpaQueryHint;
+import org.apache.cayenne.jpa.map.JpaTable;
 import org.apache.cayenne.util.BaseTreeVisitor;
 import org.apache.cayenne.util.HierarchicalTreeVisitor;
 import org.apache.cayenne.util.TraversalUtil;
 import org.objectstyle.cayenne.map.DataMap;
+import org.objectstyle.cayenne.map.DbEntity;
+import org.objectstyle.cayenne.map.ObjAttribute;
 import org.objectstyle.cayenne.map.ObjEntity;
+import org.objectstyle.cayenne.map.ObjRelationship;
 import org.objectstyle.cayenne.project.ProjectPath;
 import org.objectstyle.cayenne.util.Util;
 import org.objectstyle.cayenne.validation.SimpleValidationFailure;
@@ -112,41 +121,109 @@
         conflicts.addFailure(new SimpleValidationFailure(path.getObject(), message));
     }
 
+    /**
+     * Creates a stateless instance of the JpaEntityMap traversal visitor. This method is
+     * lazily invoked and cached by this object.
+     */
     protected HierarchicalTreeVisitor createVisitor() {
         BaseTreeVisitor visitor = new BaseTreeVisitor();
-        visitor.addChildVisitor(JpaEntity.class, new EntityVisitor());
-        visitor.addChildVisitor(JpaNamedQuery.class, new NamedQueryVisitor());
-
+        visitor.addChildVisitor(JpaEntity.class, new JpaEntityVisitor());
+        visitor.addChildVisitor(JpaNamedQuery.class, new JpaNamedQueryVisitor());
         return visitor;
     }
 
-    class EntityVisitor extends NestedVisitor {
+    class JpaAttributeVisitor extends NestedVisitor {
+
+        Class getAttributeType(ProjectPath path, String name) {
+            AccessType access = ((JpaEntityMap) path.getRoot()).getAccess();
+
+            Class objectClass = ((ObjEntity) targetPath.firstInstanceOf(ObjEntity.class))
+                    .getJavaClass();
+
+            try {
+                if (access == AccessType.FIELD) {
+                    return lookupFieldInHierarchy(objectClass, name).getType();
+                }
+                else {
+                    return new PropertyDescriptor(name, objectClass).getPropertyType();
+                }
+            }
+            catch (Exception e) {
+                throw new JpaProviderException("Error resolving attribute '"
+                        + name
+                        + "', access type:"
+                        + access, e);
+            }
+        }
+
+        Field lookupFieldInHierarchy(Class beanClass, String fieldName)
+                throws SecurityException, NoSuchFieldException {
+
+            try {
+                return beanClass.getDeclaredField(fieldName);
+            }
+            catch (NoSuchFieldException e) {
+
+                Class superClass = beanClass.getSuperclass();
+                if (superClass == null
+                        || superClass.getName().equals(Object.class.getName())) {
+                    throw e;
+                }
 
-        public EntityVisitor() {
-            addChildVisitor(JpaAttribute.class, new AttributeVisitor());
+                return lookupFieldInHierarchy(superClass, fieldName);
+            }
         }
 
         @Override
         Object createObject(ProjectPath path) {
-            JpaEntity jpaEntity = (JpaEntity) path.getObject();
-            ObjEntity cayenneEntity = new ObjEntity(jpaEntity.getName());
-            cayenneEntity.setClassName(jpaEntity.getClassName());
 
-            ((DataMap) targetPath.getObject()).addObjEntity(cayenneEntity);
+            JpaAttribute jpaAttribute = (JpaAttribute) path.getObject();
 
-            return cayenneEntity;
+            ObjEntity parentCayenneEntity = (ObjEntity) targetPath.getObject();
+
+            if (jpaAttribute.isTransient()) {
+
+            }
+            else if (jpaAttribute.isRelationship()) {
+                ObjRelationship cayenneRelationship = new ObjRelationship(jpaAttribute
+                        .getName());
+                
+                parentCayenneEntity.addRelationship(cayenneRelationship);
+                return cayenneRelationship;
+            }
+            else {
+                ObjAttribute cayenneAttribute = new ObjAttribute(jpaAttribute.getName());
+                cayenneAttribute.setType(getAttributeType(path, jpaAttribute.getName())
+                        .getName());
+
+                parentCayenneEntity.addAttribute(cayenneAttribute);
+                return cayenneAttribute;
+            }
+
+            return null;
         }
     }
 
-    class AttributeVisitor extends NestedVisitor {
+    class JpaEntityVisitor extends NestedVisitor {
+
+        public JpaEntityVisitor() {
+            addChildVisitor(JpaAttribute.class, new JpaAttributeVisitor());
+            addChildVisitor(JpaTable.class, new JpaTableVisitor());
+        }
 
         @Override
         Object createObject(ProjectPath path) {
-            return null;
+            JpaEntity jpaEntity = (JpaEntity) path.getObject();
+            ObjEntity cayenneEntity = new ObjEntity(jpaEntity.getName());
+            cayenneEntity.setClassName(jpaEntity.getClassName());
+
+            ((DataMap) targetPath.getObject()).addObjEntity(cayenneEntity);
+
+            return cayenneEntity;
         }
     }
 
-    class NamedQueryVisitor extends NestedVisitor {
+    class JpaNamedQueryVisitor extends NestedVisitor {
 
         @Override
         Object createObject(ProjectPath path) {
@@ -190,6 +267,27 @@
             ((DataMap) targetPath.firstInstanceOf(DataMap.class)).addQuery(cayenneQuery);
 
             return cayenneQuery;
+        }
+    }
+
+    class JpaTableVisitor extends NestedVisitor {
+
+        public JpaTableVisitor() {
+
+        }
+
+        @Override
+        Object createObject(ProjectPath path) {
+            JpaTable jpaTable = (JpaTable) path.getObject();
+            DbEntity cayenneEntity = new DbEntity(jpaTable.getName());
+            cayenneEntity.setCatalog(jpaTable.getCatalog());
+            cayenneEntity.setSchema(jpaTable.getSchema());
+
+            ObjEntity parentCayenneEntity = (ObjEntity) targetPath.getObject();
+            parentCayenneEntity.getDataMap().addDbEntity(cayenneEntity);
+            parentCayenneEntity.setDbEntity(cayenneEntity);
+
+            return cayenneEntity;
         }
     }
 

Modified: incubator/cayenne/trunk/cayenne-jpa/src/main/java/org/apache/cayenne/jpa/map/JpaAttribute.java
URL: http://svn.apache.org/viewcvs/incubator/cayenne/trunk/cayenne-jpa/src/main/java/org/apache/cayenne/jpa/map/JpaAttribute.java?rev=397938&r1=397937&r2=397938&view=diff
==============================================================================
--- incubator/cayenne/trunk/cayenne-jpa/src/main/java/org/apache/cayenne/jpa/map/JpaAttribute.java
(original)
+++ incubator/cayenne/trunk/cayenne-jpa/src/main/java/org/apache/cayenne/jpa/map/JpaAttribute.java
Fri Apr 28 09:00:24 2006
@@ -103,6 +103,17 @@
     protected String mapKey;
     protected String orderBy;
 
+    /**
+     * Returns true if attribute is one of {@link JpaManyToMany}, {@link JpaManyToOne},
+     * {@link JpaOneToMany}, {@link JpaOneToOne}.
+     */
+    public boolean isRelationship() {
+        return semantics == AttributeSemantics.MANY_TO_ONE
+                || semantics == AttributeSemantics.ONE_TO_MANY
+                || semantics == AttributeSemantics.ONE_TO_ONE
+                || semantics == AttributeSemantics.MANY_TO_MANY;
+    }
+
     public String getName() {
         return name;
     }
@@ -210,7 +221,7 @@
         this.column = column;
     }
 
-    @TreeNodeChild(type=JpaJoinColumn.class)
+    @TreeNodeChild(type = JpaJoinColumn.class)
     public Collection<JpaJoinColumn> getJoinColumns() {
         if (joinColumns == null) {
             joinColumns = new ArrayList<JpaJoinColumn>() {

Modified: incubator/cayenne/trunk/cayenne-jpa/src/main/java/org/apache/cayenne/jpa/map/JpaEntityMap.java
URL: http://svn.apache.org/viewcvs/incubator/cayenne/trunk/cayenne-jpa/src/main/java/org/apache/cayenne/jpa/map/JpaEntityMap.java?rev=397938&r1=397937&r2=397938&view=diff
==============================================================================
--- incubator/cayenne/trunk/cayenne-jpa/src/main/java/org/apache/cayenne/jpa/map/JpaEntityMap.java
(original)
+++ incubator/cayenne/trunk/cayenne-jpa/src/main/java/org/apache/cayenne/jpa/map/JpaEntityMap.java
Fri Apr 28 09:00:24 2006
@@ -35,6 +35,10 @@
     protected JpaEntityListeners defaultEntityListeners;
     protected Collection<CascadeType> cascades;
 
+    public JpaEntityMap() {
+        this.access = AccessType.FIELD;
+    }
+
     /**
      * Merges all entities from another map, overriding existing values.
      * 

Modified: incubator/cayenne/trunk/cayenne-jpa/src/test/java/org/apache/cayenne/jpa/bridge/DataMapConverterTest.java
URL: http://svn.apache.org/viewcvs/incubator/cayenne/trunk/cayenne-jpa/src/test/java/org/apache/cayenne/jpa/bridge/DataMapConverterTest.java?rev=397938&r1=397937&r2=397938&view=diff
==============================================================================
--- incubator/cayenne/trunk/cayenne-jpa/src/test/java/org/apache/cayenne/jpa/bridge/DataMapConverterTest.java
(original)
+++ incubator/cayenne/trunk/cayenne-jpa/src/test/java/org/apache/cayenne/jpa/bridge/DataMapConverterTest.java
Fri Apr 28 09:00:24 2006
@@ -58,18 +58,9 @@
 import junit.framework.TestCase;
 
 import org.apache.cayenne.jpa.conf.EntityMapAnnotationLoader;
-import org.apache.cayenne.jpa.entity.MockEmbed1;
-import org.apache.cayenne.jpa.entity.MockEmbed2;
-import org.apache.cayenne.jpa.entity.MockEntity1;
-import org.apache.cayenne.jpa.entity.MockEntity2;
-import org.apache.cayenne.jpa.entity.MockEntity3;
-import org.apache.cayenne.jpa.entity.MockEntity4;
-import org.apache.cayenne.jpa.entity.MockEntity5;
-import org.apache.cayenne.jpa.entity.MockEntityMap1;
-import org.apache.cayenne.jpa.entity.MockEntityMap2;
-import org.apache.cayenne.jpa.entity.MockMappedSuperclass1;
-import org.apache.cayenne.jpa.entity.MockMappedSuperclass2;
-import org.apache.cayenne.jpa.entity.MockMappedSuperclass3;
+import org.apache.cayenne.jpa.entity.cayenne.MockCayenneEntity1;
+import org.apache.cayenne.jpa.entity.cayenne.MockCayenneEntity2;
+import org.apache.cayenne.jpa.entity.cayenne.MockCayenneEntityMap1;
 import org.apache.cayenne.jpa.map.JpaEntityMap;
 import org.objectstyle.cayenne.map.DataMap;
 import org.objectstyle.cayenne.validation.ValidationResult;
@@ -100,21 +91,10 @@
         ValidationResult conflicts = new ValidationResult();
         EntityMapAnnotationLoader loader = new EntityMapAnnotationLoader(conflicts);
 
-        loader.loadClassMapping(map, MockEntity1.class);
-        loader.loadClassMapping(map, MockEntity2.class);
-        loader.loadClassMapping(map, MockEntity3.class);
-        loader.loadClassMapping(map, MockEntity4.class);
-        loader.loadClassMapping(map, MockEntity5.class);
-
-        loader.loadClassMapping(map, MockEmbed1.class);
-        loader.loadClassMapping(map, MockEmbed2.class);
-
-        loader.loadClassMapping(map, MockMappedSuperclass1.class);
-        loader.loadClassMapping(map, MockMappedSuperclass2.class);
-        loader.loadClassMapping(map, MockMappedSuperclass3.class);
+        loader.loadClassMapping(map, MockCayenneEntity1.class);
+        loader.loadClassMapping(map, MockCayenneEntity2.class);
 
-        loader.loadClassMapping(map, MockEntityMap1.class);
-        loader.loadClassMapping(map, MockEntityMap2.class);
+        loader.loadClassMapping(map, MockCayenneEntityMap1.class);
 
         assertFalse("Found conflicts: " + conflicts, conflicts.hasFailures());
 

Modified: incubator/cayenne/trunk/cayenne-jpa/src/test/java/org/apache/cayenne/jpa/bridge/DataMapMappingAssertion.java
URL: http://svn.apache.org/viewcvs/incubator/cayenne/trunk/cayenne-jpa/src/test/java/org/apache/cayenne/jpa/bridge/DataMapMappingAssertion.java?rev=397938&r1=397937&r2=397938&view=diff
==============================================================================
--- incubator/cayenne/trunk/cayenne-jpa/src/test/java/org/apache/cayenne/jpa/bridge/DataMapMappingAssertion.java
(original)
+++ incubator/cayenne/trunk/cayenne-jpa/src/test/java/org/apache/cayenne/jpa/bridge/DataMapMappingAssertion.java
Fri Apr 28 09:00:24 2006
@@ -59,12 +59,8 @@
 
 import junit.framework.Assert;
 
-import org.apache.cayenne.jpa.map.JpaEntity;
-import org.apache.cayenne.jpa.map.JpaNamedNativeQuery;
-import org.apache.cayenne.jpa.map.JpaNamedQuery;
-import org.apache.cayenne.jpa.map.JpaSecondaryTable;
-import org.apache.cayenne.jpa.map.JpaTable;
-import org.apache.cayenne.jpa.map.JpaUniqueConstraint;
+import org.apache.cayenne.jpa.entity.cayenne.MockCayenneEntity1;
+import org.apache.cayenne.jpa.entity.cayenne.MockCayenneEntity2;
 import org.objectstyle.cayenne.map.DataMap;
 import org.objectstyle.cayenne.map.DbEntity;
 import org.objectstyle.cayenne.map.ObjEntity;
@@ -76,67 +72,31 @@
         assertEquals("n1", dataMap.getName());
 
         assertNotNull(dataMap.getObjEntities());
-        assertEquals(5, dataMap.getObjEntities().size());
+        assertEquals(2, dataMap.getObjEntities().size());
         Iterator<ObjEntity> entityIt = dataMap.getObjEntities().iterator();
         assertEntity1(entityIt.next());
-        // assertEntity2(entityIt.next());
-        // assertEntity3(entityIt.next());
-        // assertEntity4(entityIt.next());
-        // assertEntity5(entityIt.next());
-
-        // TODO: NOT SUPPORTED YET - Embeddable
-        // assertNotNull(dataMap.getEmbeddables());
-        // assertEquals(2, dataMap.getEmbeddables().size());
-        // Iterator<JpaEmbeddable> embedIt = dataMap.getEmbeddables().iterator();
-        // assertEmbeddable1(embedIt.next());
-
-        // TODO: NOT SUPPORTED YET - Mapped Superclass
-        // assertNotNull(dataMap.getMappedSuperclasses());
-        // assertEquals(3, dataMap.getMappedSuperclasses().size());
-        // Iterator<JpaMappedSuperclass> mappedSuperclassIt = dataMap
-        // .getMappedSuperclasses()
-        // .iterator();
-        // assertMappedSuperclass1(mappedSuperclassIt.next());
-        // assertMappedSuperclass2(mappedSuperclassIt.next());
-        // assertMappedSuperclass3(mappedSuperclassIt.next());
-
-        // TODO: NOT SUPPORTED YET - EntityListeners
-        // assertEntityListeners(dataMap.getDefaultEntityListeners());
+        assertEntity2(entityIt.next());
 
         assertEquals(2, dataMap.getQueries().size());
-        // Iterator<Query> namedQueryIt = dataMap.getQueries().iterator();
-        // assertNamedQuery1(namedQueryIt.next());
-        // assertNamedQuery2(namedQueryIt.next());
-
-        // TODO: NOT SUPPORTED YET - Native Named Queries, however SQLTemplates are
-        // supported as named queries.
-        // assertEquals(2, entityMap.getNamedNativeQueries().size());
-        // Iterator<JpaNamedNativeQuery> namedNativeQueryIt = entityMap
-        // .getNamedNativeQueries()
-        // .iterator();
-        // assertNativeNamedQuery3(namedNativeQueryIt.next());
-        // assertNativeNamedQuery4(namedNativeQueryIt.next());
-
-        // TODO: NOT SUPPORTED YET - SQLResultSetMapping
-        // assertEquals(2, entityMap.getSqlResultSetMappings().size());
-        // assertSqlResultSetMapping(entityMap.getSqlResultSetMappings().iterator().next());
-
-        // TODO: NOT SUPPORTED YET - Sequencegenerators (In fact we can support that
-        // already...)
-        // assertEquals(2, entityMap.getSequenceGenerators().size());
-        // assertSequenceGenerator1(entityMap.getSequenceGenerators().iterator().next());
-
-        // TODO: NOT SUPPORTED YET - Table Generators (we can support that already)
-        // assertEquals(2, entityMap.getTableGenerators().size());
-        // assertTableGenerator(entityMap.getTableGenerators().iterator().next());
     }
 
     protected void assertEntity1(ObjEntity entity1) {
+
         assertNotNull(entity1);
-        assertEquals("MockEntity1", entity1.getName());
-        assertEquals("org.apache.cayenne.jpa.entity.MockEntity1", entity1.getClassName());
+        assertEquals("MockCayenneEntity1", entity1.getName());
+        assertEquals(MockCayenneEntity1.class.getName(), entity1.getClassName());
 
         assertTable(entity1.getDbEntity());
+
+        assertEquals(3, entity1.getAttributeMap().size());
+        assertEquals(4, entity1.getRelationshipMap().size());
+    }
+
+    protected void assertEntity2(ObjEntity entity2) {
+
+        assertNotNull(entity2);
+        assertEquals("MockCayenneEntity2", entity2.getName());
+        assertEquals(MockCayenneEntity2.class.getName(), entity2.getClassName());
     }
 
     protected void assertTable(DbEntity table) {

Added: incubator/cayenne/trunk/cayenne-jpa/src/test/java/org/apache/cayenne/jpa/entity/cayenne/MockCayenneEntity1.java
URL: http://svn.apache.org/viewcvs/incubator/cayenne/trunk/cayenne-jpa/src/test/java/org/apache/cayenne/jpa/entity/cayenne/MockCayenneEntity1.java?rev=397938&view=auto
==============================================================================
--- incubator/cayenne/trunk/cayenne-jpa/src/test/java/org/apache/cayenne/jpa/entity/cayenne/MockCayenneEntity1.java
(added)
+++ incubator/cayenne/trunk/cayenne-jpa/src/test/java/org/apache/cayenne/jpa/entity/cayenne/MockCayenneEntity1.java
Fri Apr 28 09:00:24 2006
@@ -0,0 +1,119 @@
+/* ====================================================================
+ * 
+ * The ObjectStyle Group Software License, version 1.1
+ * ObjectStyle Group - http://objectstyle.org/
+ * 
+ * Copyright (c) 2002-2005, Andrei (Andrus) Adamchik and individual authors
+ * of the software. All rights reserved.
+ * 
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in
+ *    the documentation and/or other materials provided with the
+ *    distribution.
+ * 
+ * 3. The end-user documentation included with the redistribution, if any,
+ *    must include the following acknowlegement:
+ *    "This product includes software developed by independent contributors
+ *    and hosted on ObjectStyle Group web site (http://objectstyle.org/)."
+ *    Alternately, this acknowlegement may appear in the software itself,
+ *    if and wherever such third-party acknowlegements normally appear.
+ * 
+ * 4. The names "ObjectStyle Group" and "Cayenne" must not be used to endorse
+ *    or promote products derived from this software without prior written
+ *    permission. For written permission, email
+ *    "andrus at objectstyle dot org".
+ * 
+ * 5. Products derived from this software may not be called "ObjectStyle"
+ *    or "Cayenne", nor may "ObjectStyle" or "Cayenne" appear in their
+ *    names without prior written permission.
+ * 
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED.  IN NO EVENT SHALL THE OBJECTSTYLE GROUP OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ * 
+ * This software consists of voluntary contributions made by many
+ * individuals and hosted on ObjectStyle Group web site.  For more
+ * information on the ObjectStyle Group, please see
+ * <http://objectstyle.org/>.
+ */
+package org.apache.cayenne.jpa.entity.cayenne;
+
+import javax.persistence.Basic;
+import javax.persistence.CascadeType;
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.FetchType;
+import javax.persistence.ManyToMany;
+import javax.persistence.ManyToOne;
+import javax.persistence.NamedQueries;
+import javax.persistence.NamedQuery;
+import javax.persistence.OneToMany;
+import javax.persistence.OneToOne;
+import javax.persistence.QueryHint;
+import javax.persistence.Table;
+import javax.persistence.Transient;
+import javax.persistence.Version;
+
+import org.apache.cayenne.jpa.entity.MockTargetEntity1;
+import org.apache.cayenne.jpa.entity.MockTargetEntity2;
+import org.objectstyle.cayenne.CayenneDataObject;
+
+@Entity
+@Table(name = "mock_persistent_1", catalog = "catalog1", schema = "schema1")
+@NamedQueries( {
+        @NamedQuery(name = "query1", query = "select x", hints = {
+                @QueryHint(name = "hint1", value = "value1"),
+                @QueryHint(name = "hint2", value = "value2")
+        }), @NamedQuery(name = "query2", query = "select y")
+})
+public class MockCayenneEntity1 extends CayenneDataObject {
+
+    @Basic
+    protected String attribute1;
+
+    @Version
+    protected int attribute2;
+
+    @OneToOne(targetEntity = MockTargetEntity1.class, fetch = FetchType.LAZY, optional =
true, mappedBy = "mb1", cascade = {
+            CascadeType.MERGE, CascadeType.PERSIST
+    })
+    protected int attribute3;
+
+    @OneToMany(targetEntity = MockTargetEntity2.class, fetch = FetchType.LAZY, mappedBy =
"mb2", cascade = {
+            CascadeType.MERGE, CascadeType.PERSIST
+    })
+    protected int attribute4;
+
+    @ManyToOne(targetEntity = MockTargetEntity1.class, fetch = FetchType.LAZY, optional =
true, cascade = {
+            CascadeType.MERGE, CascadeType.PERSIST
+    })
+    protected int attribute5;
+
+    @ManyToMany(targetEntity = MockTargetEntity1.class, fetch = FetchType.LAZY, mappedBy
= "mb4", cascade = {
+            CascadeType.MERGE, CascadeType.PERSIST
+    })
+    protected int attribute6;
+
+    @Transient
+    protected int attribute8;
+
+    @Column(name = "column9")
+    protected int attribute9;
+}

Added: incubator/cayenne/trunk/cayenne-jpa/src/test/java/org/apache/cayenne/jpa/entity/cayenne/MockCayenneEntity2.java
URL: http://svn.apache.org/viewcvs/incubator/cayenne/trunk/cayenne-jpa/src/test/java/org/apache/cayenne/jpa/entity/cayenne/MockCayenneEntity2.java?rev=397938&view=auto
==============================================================================
--- incubator/cayenne/trunk/cayenne-jpa/src/test/java/org/apache/cayenne/jpa/entity/cayenne/MockCayenneEntity2.java
(added)
+++ incubator/cayenne/trunk/cayenne-jpa/src/test/java/org/apache/cayenne/jpa/entity/cayenne/MockCayenneEntity2.java
Fri Apr 28 09:00:24 2006
@@ -0,0 +1,65 @@
+/* ====================================================================
+ * 
+ * The ObjectStyle Group Software License, version 1.1
+ * ObjectStyle Group - http://objectstyle.org/
+ * 
+ * Copyright (c) 2002-2005, Andrei (Andrus) Adamchik and individual authors
+ * of the software. All rights reserved.
+ * 
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in
+ *    the documentation and/or other materials provided with the
+ *    distribution.
+ * 
+ * 3. The end-user documentation included with the redistribution, if any,
+ *    must include the following acknowlegement:
+ *    "This product includes software developed by independent contributors
+ *    and hosted on ObjectStyle Group web site (http://objectstyle.org/)."
+ *    Alternately, this acknowlegement may appear in the software itself,
+ *    if and wherever such third-party acknowlegements normally appear.
+ * 
+ * 4. The names "ObjectStyle Group" and "Cayenne" must not be used to endorse
+ *    or promote products derived from this software without prior written
+ *    permission. For written permission, email
+ *    "andrus at objectstyle dot org".
+ * 
+ * 5. Products derived from this software may not be called "ObjectStyle"
+ *    or "Cayenne", nor may "ObjectStyle" or "Cayenne" appear in their
+ *    names without prior written permission.
+ * 
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED.  IN NO EVENT SHALL THE OBJECTSTYLE GROUP OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ * 
+ * This software consists of voluntary contributions made by many
+ * individuals and hosted on ObjectStyle Group web site.  For more
+ * information on the ObjectStyle Group, please see
+ * <http://objectstyle.org/>.
+ */
+package org.apache.cayenne.jpa.entity.cayenne;
+
+import javax.persistence.Entity;
+
+import org.objectstyle.cayenne.CayenneDataObject;
+
+@Entity
+public class MockCayenneEntity2 extends CayenneDataObject {
+
+}

Added: incubator/cayenne/trunk/cayenne-jpa/src/test/java/org/apache/cayenne/jpa/entity/cayenne/MockCayenneEntityMap1.java
URL: http://svn.apache.org/viewcvs/incubator/cayenne/trunk/cayenne-jpa/src/test/java/org/apache/cayenne/jpa/entity/cayenne/MockCayenneEntityMap1.java?rev=397938&view=auto
==============================================================================
--- incubator/cayenne/trunk/cayenne-jpa/src/test/java/org/apache/cayenne/jpa/entity/cayenne/MockCayenneEntityMap1.java
(added)
+++ incubator/cayenne/trunk/cayenne-jpa/src/test/java/org/apache/cayenne/jpa/entity/cayenne/MockCayenneEntityMap1.java
Fri Apr 28 09:00:24 2006
@@ -0,0 +1,70 @@
+/* ====================================================================
+ * 
+ * The ObjectStyle Group Software License, version 1.1
+ * ObjectStyle Group - http://objectstyle.org/
+ * 
+ * Copyright (c) 2002-2005, Andrei (Andrus) Adamchik and individual authors
+ * of the software. All rights reserved.
+ * 
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in
+ *    the documentation and/or other materials provided with the
+ *    distribution.
+ * 
+ * 3. The end-user documentation included with the redistribution, if any,
+ *    must include the following acknowlegement:
+ *    "This product includes software developed by independent contributors
+ *    and hosted on ObjectStyle Group web site (http://objectstyle.org/)."
+ *    Alternately, this acknowlegement may appear in the software itself,
+ *    if and wherever such third-party acknowlegements normally appear.
+ * 
+ * 4. The names "ObjectStyle Group" and "Cayenne" must not be used to endorse
+ *    or promote products derived from this software without prior written
+ *    permission. For written permission, email
+ *    "andrus at objectstyle dot org".
+ * 
+ * 5. Products derived from this software may not be called "ObjectStyle"
+ *    or "Cayenne", nor may "ObjectStyle" or "Cayenne" appear in their
+ *    names without prior written permission.
+ * 
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED.  IN NO EVENT SHALL THE OBJECTSTYLE GROUP OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ * 
+ * This software consists of voluntary contributions made by many
+ * individuals and hosted on ObjectStyle Group web site.  For more
+ * information on the ObjectStyle Group, please see
+ * <http://objectstyle.org/>.
+ */
+package org.apache.cayenne.jpa.entity.cayenne;
+
+import javax.persistence.NamedQueries;
+import javax.persistence.NamedQuery;
+import javax.persistence.QueryHint;
+
+@NamedQueries( {
+        @NamedQuery(name = "query1", query = "select x", hints = {
+                @QueryHint(name = "hint1", value = "value1"),
+                @QueryHint(name = "hint2", value = "value2")
+        }), @NamedQuery(name = "query2", query = "select y")
+})
+public class MockCayenneEntityMap1 {
+
+}



Mime
View raw message