You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cayenne.apache.org by aa...@apache.org on 2013/08/04 20:27:09 UTC

svn commit: r1510297 [1/2] - in /cayenne/main/trunk: framework/cayenne-core-unpublished/src/main/java/org/apache/cayenne/access/ framework/cayenne-core-unpublished/src/main/java/org/apache/cayenne/access/jdbc/ framework/cayenne-core-unpublished/src/mai...

Author: aadamchik
Date: Sun Aug  4 18:27:08 2013
New Revision: 1510297

URL: http://svn.apache.org/r1510297
Log:
correct attribute/rel return type in Obj/DbEntity

as a result can remove lots of unneeded casts
also some generics cleanup

Modified:
    cayenne/main/trunk/framework/cayenne-core-unpublished/src/main/java/org/apache/cayenne/access/DataDomainInsertBucket.java
    cayenne/main/trunk/framework/cayenne-core-unpublished/src/main/java/org/apache/cayenne/access/DbEntityClassDescriptor.java
    cayenne/main/trunk/framework/cayenne-core-unpublished/src/main/java/org/apache/cayenne/access/DbLoader.java
    cayenne/main/trunk/framework/cayenne-core-unpublished/src/main/java/org/apache/cayenne/access/jdbc/EJBQLDbPathTranslator.java
    cayenne/main/trunk/framework/cayenne-core-unpublished/src/main/java/org/apache/cayenne/access/jdbc/EJBQLIdColumnsTranslator.java
    cayenne/main/trunk/framework/cayenne-core-unpublished/src/main/java/org/apache/cayenne/access/jdbc/IdRowReader.java
    cayenne/main/trunk/framework/cayenne-core-unpublished/src/main/java/org/apache/cayenne/access/jdbc/SoftDeleteBatchQueryBuilder.java
    cayenne/main/trunk/framework/cayenne-core-unpublished/src/main/java/org/apache/cayenne/access/trans/SelectTranslator.java
    cayenne/main/trunk/framework/cayenne-core-unpublished/src/main/java/org/apache/cayenne/dba/JdbcAdapter.java
    cayenne/main/trunk/framework/cayenne-core-unpublished/src/main/java/org/apache/cayenne/dba/mysql/MySQLAdapter.java
    cayenne/main/trunk/framework/cayenne-core-unpublished/src/main/java/org/apache/cayenne/dba/sqlserver/SQLServerBatchAction.java
    cayenne/main/trunk/framework/cayenne-core-unpublished/src/main/java/org/apache/cayenne/map/DbAttribute.java
    cayenne/main/trunk/framework/cayenne-core-unpublished/src/main/java/org/apache/cayenne/map/DbEntity.java
    cayenne/main/trunk/framework/cayenne-core-unpublished/src/main/java/org/apache/cayenne/map/DbRelationship.java
    cayenne/main/trunk/framework/cayenne-core-unpublished/src/main/java/org/apache/cayenne/map/EntityResolver.java
    cayenne/main/trunk/framework/cayenne-core-unpublished/src/main/java/org/apache/cayenne/map/ObjAttribute.java
    cayenne/main/trunk/framework/cayenne-core-unpublished/src/main/java/org/apache/cayenne/reflect/PersistentDescriptorFactory.java
    cayenne/main/trunk/framework/cayenne-core-unpublished/src/test/java/org/apache/cayenne/CayenneDataObjectValidationTest.java
    cayenne/main/trunk/framework/cayenne-core-unpublished/src/test/java/org/apache/cayenne/access/DbLoaderTest.java
    cayenne/main/trunk/framework/cayenne-core-unpublished/src/test/java/org/apache/cayenne/access/IdentityColumnsTest.java
    cayenne/main/trunk/framework/cayenne-core-unpublished/src/test/java/org/apache/cayenne/access/jdbc/BatchActionLockingTest.java
    cayenne/main/trunk/framework/cayenne-core-unpublished/src/test/java/org/apache/cayenne/access/jdbc/SoftDeleteBatchQueryBuilderTest.java
    cayenne/main/trunk/framework/cayenne-core-unpublished/src/test/java/org/apache/cayenne/access/trans/DeleteBatchQueryBuilderTest.java
    cayenne/main/trunk/framework/cayenne-core-unpublished/src/test/java/org/apache/cayenne/dba/JdbcPkGeneratorTest.java
    cayenne/main/trunk/framework/cayenne-core-unpublished/src/test/java/org/apache/cayenne/map/DataMapTest.java
    cayenne/main/trunk/framework/cayenne-core-unpublished/src/test/java/org/apache/cayenne/map/DbEntityTest.java
    cayenne/main/trunk/framework/cayenne-core-unpublished/src/test/java/org/apache/cayenne/map/DbRelationshipTest.java
    cayenne/main/trunk/framework/cayenne-core-unpublished/src/test/java/org/apache/cayenne/map/ObjEntityTest.java
    cayenne/main/trunk/framework/cayenne-core-unpublished/src/test/java/org/apache/cayenne/unit/OracleUnitDbAdapter.java
    cayenne/main/trunk/framework/cayenne-core-unpublished/src/test/java/org/apache/cayenne/unit/SybaseUnitDbAdapter.java
    cayenne/main/trunk/framework/cayenne-wocompat-unpublished/src/main/java/org/apache/cayenne/wocompat/EOModelProcessor.java
    cayenne/main/trunk/framework/cayenne-wocompat-unpublished/src/test/java/org/apache/cayenne/wocompat/EOModelPrototypesTest.java
    cayenne/main/trunk/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/action/CreateRelationshipAction.java

Modified: cayenne/main/trunk/framework/cayenne-core-unpublished/src/main/java/org/apache/cayenne/access/DataDomainInsertBucket.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-core-unpublished/src/main/java/org/apache/cayenne/access/DataDomainInsertBucket.java?rev=1510297&r1=1510296&r2=1510297&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-core-unpublished/src/main/java/org/apache/cayenne/access/DataDomainInsertBucket.java (original)
+++ cayenne/main/trunk/framework/cayenne-core-unpublished/src/main/java/org/apache/cayenne/access/DataDomainInsertBucket.java Sun Aug  4 18:27:08 2013
@@ -21,7 +21,6 @@ package org.apache.cayenne.access;
 
 import java.util.Collection;
 import java.util.HashMap;
-import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
 
@@ -58,16 +57,14 @@ class DataDomainInsertBucket extends Dat
 
         for (DbEntity dbEntity : dbEntities) {
 
-            Collection<DbEntityClassDescriptor> descriptors = descriptorsByDbEntity
-                    .get(dbEntity);
+            Collection<DbEntityClassDescriptor> descriptors = descriptorsByDbEntity.get(dbEntity);
 
             InsertBatchQuery batch = new InsertBatchQuery(dbEntity, 27);
             for (DbEntityClassDescriptor descriptor : descriptors) {
 
                 diffBuilder.reset(descriptor);
 
-                List<Persistent> objects = objectsByDescriptor.get(descriptor
-                        .getClassDescriptor());
+                List<Persistent> objects = objectsByDescriptor.get(descriptor.getClassDescriptor());
                 if (objects.isEmpty()) {
                     continue;
                 }
@@ -77,10 +74,10 @@ class DataDomainInsertBucket extends Dat
                 sorter.sortObjectsForEntity(descriptor.getEntity(), objects, false);
 
                 for (Persistent o : objects) {
-                    Map<Object, Object> snapshot = diffBuilder.buildDBDiff(parent
-                            .objectDiff(o.getObjectId()));
+                    Map<Object, Object> snapshot = diffBuilder.buildDBDiff(parent.objectDiff(o.getObjectId()));
 
-                    // we need to insert even if there is no changes to default values
+                    // we need to insert even if there is no changes to default
+                    // values
                     // so creating an empty changes map
                     if (snapshot == null) {
                         snapshot = new HashMap<Object, Object>();
@@ -130,18 +127,16 @@ class DataDomainInsertBucket extends Dat
                 ObjAttribute objAttr = objEntity.getAttributeForDbAttribute(dbAttr);
                 if (objAttr != null) {
 
-                    Object value = descriptor.getClassDescriptor().getProperty(
-                            objAttr.getName()).readPropertyDirectly(object);
+                    Object value = descriptor.getClassDescriptor().getProperty(objAttr.getName())
+                            .readPropertyDirectly(object);
 
                     if (value != null) {
                         Class<?> javaClass = objAttr.getJavaClass();
-                        if (javaClass.isPrimitive()
-                                && value instanceof Number
-                                && ((Number) value).intValue() == 0) {
-                            // primitive 0 has to be treated as NULL, or otherwise we
+                        if (javaClass.isPrimitive() && value instanceof Number && ((Number) value).intValue() == 0) {
+                            // primitive 0 has to be treated as NULL, or
+                            // otherwise we
                             // can't generate PK for POJO's
-                        }
-                        else {
+                        } else {
 
                             idMap.put(dbAttrName, value);
                             continue;
@@ -159,11 +154,11 @@ class DataDomainInsertBucket extends Dat
                     continue;
                 }
 
-                // only a single key can be generated from DB... if this is done already
+                // only a single key can be generated from DB... if this is done
+                // already
                 // in this loop, we must bail out.
                 if (autoPkDone) {
-                    throw new CayenneRuntimeException(
-                            "Primary Key autogeneration only works for a single attribute.");
+                    throw new CayenneRuntimeException("Primary Key autogeneration only works for a single attribute.");
                 }
 
                 // finally, use database generation mechanism
@@ -171,10 +166,8 @@ class DataDomainInsertBucket extends Dat
                     Object pkValue = pkGenerator.generatePk(node, dbAttr);
                     idMap.put(dbAttrName, pkValue);
                     autoPkDone = true;
-                }
-                catch (Exception ex) {
-                    throw new CayenneRuntimeException("Error generating PK: "
-                            + ex.getMessage(), ex);
+                } catch (Exception ex) {
+                    throw new CayenneRuntimeException("Error generating PK: " + ex.getMessage(), ex);
                 }
             }
         }
@@ -182,10 +175,8 @@ class DataDomainInsertBucket extends Dat
 
     // TODO, andrus 4/12/2006 - move to DbAttribute in 2.0+
     boolean isPropagated(DbAttribute attribute) {
-        Iterator<?> it = attribute.getEntity().getRelationships().iterator();
-        while (it.hasNext()) {
 
-            DbRelationship dbRel = (DbRelationship) it.next();
+        for (DbRelationship dbRel : attribute.getEntity().getRelationships()) {
             if (!dbRel.isToMasterPK()) {
                 continue;
             }

Modified: cayenne/main/trunk/framework/cayenne-core-unpublished/src/main/java/org/apache/cayenne/access/DbEntityClassDescriptor.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-core-unpublished/src/main/java/org/apache/cayenne/access/DbEntityClassDescriptor.java?rev=1510297&r1=1510296&r2=1510297&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-core-unpublished/src/main/java/org/apache/cayenne/access/DbEntityClassDescriptor.java (original)
+++ cayenne/main/trunk/framework/cayenne-core-unpublished/src/main/java/org/apache/cayenne/access/DbEntityClassDescriptor.java Sun Aug  4 18:27:08 2013
@@ -64,7 +64,7 @@ class DbEntityClassDescriptor {
                     pathFromMaster.add((DbRelationship) object);
                 }
                 else if (object instanceof DbAttribute) {
-                    this.dbEntity = (DbEntity) ((DbAttribute) object).getEntity();
+                    this.dbEntity = ((DbAttribute) object).getEntity();
                 }
             }
         }

Modified: cayenne/main/trunk/framework/cayenne-core-unpublished/src/main/java/org/apache/cayenne/access/DbLoader.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-core-unpublished/src/main/java/org/apache/cayenne/access/DbLoader.java?rev=1510297&r1=1510296&r2=1510297&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-core-unpublished/src/main/java/org/apache/cayenne/access/DbLoader.java (original)
+++ cayenne/main/trunk/framework/cayenne-core-unpublished/src/main/java/org/apache/cayenne/access/DbLoader.java Sun Aug  4 18:27:08 2013
@@ -36,7 +36,6 @@ import java.util.Set;
 import org.apache.cayenne.CayenneException;
 import org.apache.cayenne.dba.DbAdapter;
 import org.apache.cayenne.dba.TypesMapping;
-
 import org.apache.cayenne.map.DataMap;
 import org.apache.cayenne.map.DbAttribute;
 import org.apache.cayenne.map.DbEntity;
@@ -67,14 +66,12 @@ public class DbLoader {
     // TODO: remove this hardcoded stuff once delegate starts to support
     // procedure
     // loading...
-    private static final Collection<String> EXCLUDED_PROCEDURES = Arrays
-            .asList("auto_pk_for_table", "auto_pk_for_table;1" /*
-                                                                * the last name
-                                                                * is some Mac OS
-                                                                * X Sybase
-                                                                * artifact
-                                                                */
-            );
+    private static final Collection<String> EXCLUDED_PROCEDURES = Arrays.asList("auto_pk_for_table",
+            "auto_pk_for_table;1" /*
+                                   * the last name is some Mac OS X Sybase
+                                   * artifact
+                                   */
+    );
 
     public static final String WILDCARD = "%";
 
@@ -92,8 +89,7 @@ public class DbLoader {
         int currentSuffix = 1;
         String relName = preferredName;
 
-        while (entity.getRelationship(relName) != null
-                || entity.getAttribute(relName) != null) {
+        while (entity.getRelationship(relName) != null || entity.getAttribute(relName) != null) {
             relName = preferredName + currentSuffix;
             currentSuffix++;
         }
@@ -115,18 +111,16 @@ public class DbLoader {
     /**
      * Creates new DbLoader.
      */
-    public DbLoader(Connection connection, DbAdapter adapter,
-            DbLoaderDelegate delegate) {
+    public DbLoader(Connection connection, DbAdapter adapter, DbLoaderDelegate delegate) {
         this(connection, adapter, delegate, new BasicNamingStrategy());
     }
 
     /**
      * Creates new DbLoader with specified naming strategy.
-     *
+     * 
      * @since 3.0
      */
-    public DbLoader(Connection connection, DbAdapter adapter,
-            DbLoaderDelegate delegate, NamingStrategy strategy) {
+    public DbLoader(Connection connection, DbAdapter adapter, DbLoaderDelegate delegate, NamingStrategy strategy) {
         this.adapter = adapter;
         this.connection = connection;
         this.delegate = delegate;
@@ -153,7 +147,7 @@ public class DbLoader {
     /**
      * Returns true if the generator should map all primary key columns as
      * ObjAttributes.
-     *
+     * 
      * @since 3.0
      */
     public boolean isCreatingMeaningfulPK() {
@@ -162,7 +156,7 @@ public class DbLoader {
 
     /**
      * Returns database connection used by this DbLoader.
-     *
+     * 
      * @since 3.0
      */
     public Connection getConnection() {
@@ -175,7 +169,7 @@ public class DbLoader {
      * {@link org.apache.cayenne.CayenneDataObject}. If generic class name is
      * null (which is the default), DbLoader will assign each entity a unique
      * class name derived from the table name.
-     *
+     * 
      * @since 1.2
      */
     public String getGenericClassName() {
@@ -188,7 +182,7 @@ public class DbLoader {
      * {@link org.apache.cayenne.CayenneDataObject}. If generic class name is
      * set to null (which is the default), DbLoader will assign each entity a
      * unique class name derived from the table name.
-     *
+     * 
      * @since 1.2
      */
     public void setGenericClassName(String genericClassName) {
@@ -197,7 +191,7 @@ public class DbLoader {
 
     /**
      * Returns DbAdapter associated with this DbLoader.
-     *
+     * 
      * @since 1.1
      */
     public DbAdapter getAdapter() {
@@ -214,7 +208,7 @@ public class DbLoader {
 
     /**
      * Retrieves catalogs for the database associated with this DbLoader.
-     *
+     * 
      * @return List with the catalog names, empty Array if none found.
      */
     public List<String> getCatalogs() throws SQLException {
@@ -234,7 +228,7 @@ public class DbLoader {
 
     /**
      * Retrieves the schemas for the database.
-     *
+     * 
      * @return List with the schema names, empty Array if none found.
      */
     public List<String> getSchemas() throws SQLException {
@@ -255,7 +249,7 @@ public class DbLoader {
     /**
      * Returns all the table types for the given database. Types may be such as
      * "TABLE", "VIEW", "SYSTEM TABLE", etc.
-     *
+     * 
      * @return List of Strings, empty array if nothing found.
      */
     public List<String> getTableTypes() throws SQLException {
@@ -275,7 +269,7 @@ public class DbLoader {
     /**
      * Returns all tables for given combination of the criteria. Tables returned
      * as DbEntities without any attributes or relationships.
-     *
+     * 
      * @param catalogPattern
      *            The name of the catalog, may be null.
      * @param schemaPattern
@@ -287,15 +281,14 @@ public class DbLoader {
      *            The types of table names to retrieve, null returns all types.
      * @return List of TableInfo objects, empty array if nothing found.
      */
-    public List<DbEntity> getTables(String catalogPattern,
-            String schemaPattern, String tableNamePattern, String[] types)
+    public List<DbEntity> getTables(String catalogPattern, String schemaPattern, String tableNamePattern, String[] types)
             throws SQLException {
 
         List<DbEntity> tables = new ArrayList<DbEntity>();
 
         if (logger.isDebugEnabled()) {
-            logger.debug("Read tables: catalog=" + catalogPattern + ", schema="
-                    + schemaPattern + ", tableNames=" + tableNamePattern);
+            logger.debug("Read tables: catalog=" + catalogPattern + ", schema=" + schemaPattern + ", tableNames="
+                    + tableNamePattern);
 
             if (types != null && types.length > 0) {
                 for (String type : types) {
@@ -304,8 +297,7 @@ public class DbLoader {
             }
         }
 
-        ResultSet rs = getMetaData().getTables(catalogPattern, schemaPattern,
-                tableNamePattern, types);
+        ResultSet rs = getMetaData().getTables(catalogPattern, schemaPattern, tableNamePattern, types);
 
         try {
             while (rs.next()) {
@@ -345,7 +337,7 @@ public class DbLoader {
 
     /**
      * Loads dbEntities for the specified tables.
-     *
+     * 
      * @param map
      *            DataMap to be populated with DbEntities.
      * @param tables
@@ -353,8 +345,7 @@ public class DbLoader {
      *            for which DbEntities must be created.
      * @return false if loading must be immediately aborted.
      */
-    public boolean loadDbEntities(DataMap map, List<? extends DbEntity> tables)
-            throws SQLException {
+    public boolean loadDbEntities(DataMap map, List<? extends DbEntity> tables) throws SQLException {
         this.dbEntityList = new ArrayList<DbEntity>();
         for (DbEntity dbEntity : tables) {
             // Check if there already is a DbEntity under such name
@@ -389,8 +380,8 @@ public class DbLoader {
             }
 
             // Create DbAttributes from column information --
-            ResultSet rs = getMetaData().getColumns(dbEntity.getCatalog(),
-                    dbEntity.getSchema(), dbEntity.getName(), "%");
+            ResultSet rs = getMetaData().getColumns(dbEntity.getCatalog(), dbEntity.getSchema(), dbEntity.getName(),
+                    "%");
 
             try {
                 while (rs.next()) {
@@ -405,8 +396,7 @@ public class DbLoader {
 
                     String tableName = rs.getString("TABLE_NAME");
                     if (!dbEntity.getName().equals(tableName)) {
-                        logger.info("Incorrectly returned columns for '"
-                                + tableName + ", skipping.");
+                        logger.info("Incorrectly returned columns for '" + tableName + ", skipping.");
                         continue;
                     }
 
@@ -428,9 +418,8 @@ public class DbLoader {
                     }
 
                     // create attribute delegating this task to adapter
-                    DbAttribute attr = adapter.buildAttribute(columnName,
-                            typeName, columnType, columnSize, decimalDigits,
-                            allowNulls);
+                    DbAttribute attr = adapter.buildAttribute(columnName, typeName, columnType, columnSize,
+                            decimalDigits, allowNulls);
 
                     if (adapter.supportsGeneratedKeys()) {
 
@@ -469,13 +458,11 @@ public class DbLoader {
         for (final DbEntity dbEntity : map.getDbEntities()) {
             if (tables.contains(dbEntity)) {
                 String tableName = dbEntity.getName();
-                ResultSet rs = metaData.getPrimaryKeys(dbEntity.getCatalog(),
-                        dbEntity.getSchema(), tableName);
+                ResultSet rs = metaData.getPrimaryKeys(dbEntity.getCatalog(), dbEntity.getSchema(), tableName);
                 try {
                     while (rs.next()) {
                         String columnName = rs.getString(4);
-                        DbAttribute attribute = (DbAttribute) dbEntity
-                                .getAttribute(columnName);
+                        DbAttribute attribute = dbEntity.getAttribute(columnName);
 
                         if (attribute != null) {
                             attribute.setPrimaryKey(true);
@@ -485,15 +472,12 @@ public class DbLoader {
                             // it is
                             // possible
                             // so just print the warning, and ignore
-                            logger.warn("Can't locate attribute for primary key: "
-                                    + columnName);
+                            logger.warn("Can't locate attribute for primary key: " + columnName);
                         }
 
                         String pkName = rs.getString(6);
-                        if ((pkName != null)
-                                && (dbEntity instanceof DetectedDbEntity)) {
-                            ((DetectedDbEntity) dbEntity)
-                                    .setPrimaryKeyName(pkName);
+                        if ((pkName != null) && (dbEntity instanceof DetectedDbEntity)) {
+                            ((DetectedDbEntity) dbEntity).setPrimaryKeyName(pkName);
                         }
                     }
                 } finally {
@@ -579,8 +563,7 @@ public class DbLoader {
         }
     }
 
-    private void loadDbRelationships(DbEntity pkEntity, DataMap map)
-            throws SQLException {
+    private void loadDbRelationships(DbEntity pkEntity, DataMap map) throws SQLException {
         DatabaseMetaData md = getMetaData();
         String pkEntName = pkEntity.getName();
 
@@ -588,12 +571,10 @@ public class DbLoader {
         ResultSet rs = null;
 
         try {
-            rs = md.getExportedKeys(pkEntity.getCatalog(),
-                    pkEntity.getSchema(), pkEntity.getName());
+            rs = md.getExportedKeys(pkEntity.getCatalog(), pkEntity.getSchema(), pkEntity.getName());
         } catch (SQLException cay182Ex) {
             // Sybase-specific - the line above blows on VIEWS, see CAY-182.
-            logger.info("Error getting relationships for '" + pkEntName
-                    + "', ignoring.");
+            logger.info("Error getting relationships for '" + pkEntName + "', ignoring.");
             return;
         }
 
@@ -618,8 +599,7 @@ public class DbLoader {
                 if (keySeq == 1) {
 
                     if (forwardRelationship != null) {
-                        postprocessMasterDbRelationship(forwardRelationship,
-                                key);
+                        postprocessMasterDbRelationship(forwardRelationship, key);
                         forwardRelationship = null;
                     }
 
@@ -634,28 +614,22 @@ public class DbLoader {
                     fkEntity = map.getDbEntity(fkEntityName);
 
                     if (fkEntity == null) {
-                        logger.info("FK warning: no entity found for name '"
-                                + fkEntityName + "'");
-                    } else if (skippedEntities.contains(pkEntity)
-                            && skippedEntities.contains(fkEntity)) {
+                        logger.info("FK warning: no entity found for name '" + fkEntityName + "'");
+                    } else if (skippedEntities.contains(pkEntity) && skippedEntities.contains(fkEntity)) {
                         // cay-479 - don't load relationships between two
                         // skipped entities.
                         continue;
                     } else {
                         // init relationship
-                        String forwardPreferredName = namingStrategy
-                                .createDbRelationshipName(key, true);
-                        forwardRelationship = new DbRelationship(uniqueRelName(
-                                pkEntity, forwardPreferredName));
+                        String forwardPreferredName = namingStrategy.createDbRelationshipName(key, true);
+                        forwardRelationship = new DbRelationship(uniqueRelName(pkEntity, forwardPreferredName));
 
                         forwardRelationship.setSourceEntity(pkEntity);
                         forwardRelationship.setTargetEntity(fkEntity);
                         pkEntity.addRelationship(forwardRelationship);
 
-                        String reversePreferredName = namingStrategy
-                                .createDbRelationshipName(key, false);
-                        reverseRelationship = new DbRelationshipDetected(
-                                uniqueRelName(fkEntity, reversePreferredName));
+                        String reversePreferredName = namingStrategy.createDbRelationshipName(key, false);
+                        reverseRelationship = new DbRelationshipDetected(uniqueRelName(fkEntity, reversePreferredName));
                         reverseRelationship.setFkName(fkName);
                         reverseRelationship.setToMany(false);
                         reverseRelationship.setSourceEntity(fkEntity);
@@ -670,29 +644,23 @@ public class DbLoader {
                     String fkName = key.getFKColumnName();
 
                     // skip invalid joins...
-                    DbAttribute pkAtt = (DbAttribute) pkEntity
-                            .getAttribute(pkName);
+                    DbAttribute pkAtt = pkEntity.getAttribute(pkName);
                     if (pkAtt == null) {
-                        logger.info("no attribute for declared primary key: "
-                                + pkName);
+                        logger.info("no attribute for declared primary key: " + pkName);
                         continue;
                     }
 
-                    DbAttribute fkAtt = (DbAttribute) fkEntity
-                            .getAttribute(fkName);
+                    DbAttribute fkAtt = fkEntity.getAttribute(fkName);
                     if (fkAtt == null) {
-                        logger.info("no attribute for declared foreign key: "
-                                + fkName);
+                        logger.info("no attribute for declared foreign key: " + fkName);
                         continue;
                     }
 
                     if (forwardRelationship != null) {
-                        forwardRelationship.addJoin(new DbJoin(
-                                forwardRelationship, pkName, fkName));
+                        forwardRelationship.addJoin(new DbJoin(forwardRelationship, pkName, fkName));
                     }
                     if (reverseRelationship != null) {
-                        reverseRelationship.addJoin(new DbJoin(
-                                reverseRelationship, fkName, pkName));
+                        reverseRelationship.addJoin(new DbJoin(reverseRelationship, fkName, pkName));
                     }
 
                 }
@@ -712,8 +680,7 @@ public class DbLoader {
      * Detects correct relationship multiplicity and "to dep pk" flag. Only
      * called on relationships from PK to FK, not the reverse ones.
      */
-    protected void postprocessMasterDbRelationship(DbRelationship relationship,
-            ExportedKey key) {
+    protected void postprocessMasterDbRelationship(DbRelationship relationship, ExportedKey key) {
         boolean toPK = true;
         List<DbJoin> joins = relationship.getJoins();
 
@@ -730,8 +697,7 @@ public class DbLoader {
 
         if (toPK) {
             toDependentPK = true;
-            if (((DbEntity) relationship.getTargetEntity()).getPrimaryKeys()
-                    .size() == joins.size()) {
+            if (((DbEntity) relationship.getTargetEntity()).getPrimaryKeys().size() == joins.size()) {
                 toMany = false;
             }
         }
@@ -740,8 +706,7 @@ public class DbLoader {
         if (!toMany) {
             Entity source = relationship.getSourceEntity();
             source.removeRelationship(relationship.getName());
-            relationship.setName(DbLoader.uniqueRelName(source,
-                    namingStrategy.createDbRelationshipName(key, false)));
+            relationship.setName(DbLoader.uniqueRelName(source, namingStrategy.createDbRelationshipName(key, false)));
             source.addRelationship(relationship);
         }
 
@@ -804,14 +769,13 @@ public class DbLoader {
      * Performs database reverse engineering and generates DataMap that contains
      * default mapping of the tables and views. By default will include regular
      * tables and views.
-     *
+     * 
      * @since 1.0.7
      * @deprecated since 3.2 use
      *             {@link #load(DataMap, String, String, String, String...)}
      *             method that supports catalogs.
      */
-    public DataMap loadDataMapFromDB(String schemaPattern, String tablePattern,
-            DataMap dataMap) throws SQLException {
+    public DataMap loadDataMapFromDB(String schemaPattern, String tablePattern, DataMap dataMap) throws SQLException {
 
         String[] types = getDefaultTableTypes();
         if (types.length == 0) {
@@ -826,13 +790,13 @@ public class DbLoader {
      * Performs database reverse engineering and generates DataMap object that
      * contains default mapping of the tables and views. Allows to limit types
      * of tables to read.
-     *
+     * 
      * @deprecated since 3.2 use
      *             {@link #load(DataMap, String, String, String, String...)}
      *             method that supports catalogs.
      */
-    public DataMap loadDataMapFromDB(String schemaPattern, String tablePattern,
-            String[] tableTypes, DataMap dataMap) throws SQLException {
+    public DataMap loadDataMapFromDB(String schemaPattern, String tablePattern, String[] tableTypes, DataMap dataMap)
+            throws SQLException {
         clearDataMap(dataMap);
 
         load(dataMap, null, schemaPattern, tablePattern, tableTypes);
@@ -852,19 +816,17 @@ public class DbLoader {
      * Performs database reverse engineering to match the specified catalog,
      * schema, table name and table type patterns and fills the specified
      * DataMap object with DB and object mapping info.
-     *
+     * 
      * @since 3.2
      */
-    public void load(DataMap dataMap, String catalogPattern,
-            String schemaPattern, String tablePattern, String... tableTypes)
-            throws SQLException {
+    public void load(DataMap dataMap, String catalogPattern, String schemaPattern, String tablePattern,
+            String... tableTypes) throws SQLException {
 
         if (tablePattern == null) {
             tablePattern = WILDCARD;
         }
 
-        List<DbEntity> tables = getTables(catalogPattern, schemaPattern,
-                tablePattern, tableTypes);
+        List<DbEntity> tables = getTables(catalogPattern, schemaPattern, tablePattern, tableTypes);
 
         if (loadDbEntities(dataMap, tables)) {
             loadDbRelationships(dataMap);
@@ -883,14 +845,13 @@ public class DbLoader {
      * currently this method is NOT CALLED from "loadDataMapFromDB" and should
      * be invoked explicitly by the user. </i>
      * </p>
-     *
+     * 
      * @since 1.1
      * @deprecated since 3.2 use
      *             {@link #loadProcedures(DataMap, String, String, String)} that
      *             supports "catalog" pattern.
      */
-    public void loadProceduresFromDB(String schemaPattern, String namePattern,
-            DataMap dataMap) throws SQLException {
+    public void loadProceduresFromDB(String schemaPattern, String namePattern, DataMap dataMap) throws SQLException {
         loadProcedures(dataMap, null, schemaPattern, namePattern);
     }
 
@@ -902,17 +863,16 @@ public class DbLoader {
      * currently this method is NOT CALLED from "loadDataMapFromDB" and should
      * be invoked explicitly by the user. </i>
      * </p>
-     *
+     * 
      * @since 3.2
      */
-    public void loadProcedures(DataMap dataMap, String catalogPattern,
-            String schemaPattern, String namePattern) throws SQLException {
+    public void loadProcedures(DataMap dataMap, String catalogPattern, String schemaPattern, String namePattern)
+            throws SQLException {
 
         Map<String, Procedure> procedures = null;
 
         // get procedures
-        ResultSet rs = getMetaData().getProcedures(catalogPattern,
-                schemaPattern, namePattern);
+        ResultSet rs = getMetaData().getProcedures(catalogPattern, schemaPattern, namePattern);
         try {
             while (rs.next()) {
                 String name = rs.getString("PROCEDURE_NAME");
@@ -958,8 +918,7 @@ public class DbLoader {
         }
 
         // get columns
-        ResultSet columnsRS = getMetaData().getProcedureColumns(null,
-                schemaPattern, namePattern, null);
+        ResultSet columnsRS = getMetaData().getProcedureColumns(null, schemaPattern, namePattern, null);
         try {
             while (columnsRS.next()) {
 
@@ -980,15 +939,13 @@ public class DbLoader {
                 // procedures
                 // yet...
                 if (type == DatabaseMetaData.procedureColumnResult) {
-                    logger.debug("skipping ResultSet column: " + key + "."
-                            + columnName);
+                    logger.debug("skipping ResultSet column: " + key + "." + columnName);
                 }
 
                 Procedure procedure = procedures.get(key);
 
                 if (procedure == null) {
-                    logger.info("invalid procedure column, no procedure found: "
-                            + key + "." + columnName);
+                    logger.info("invalid procedure column, no procedure found: " + key + "." + columnName);
                     continue;
                 }
 
@@ -996,12 +953,10 @@ public class DbLoader {
 
                 if (columnName == null) {
                     if (type == DatabaseMetaData.procedureColumnReturn) {
-                        logger.debug("null column name, assuming result column: "
-                                + key);
+                        logger.debug("null column name, assuming result column: " + key);
                         column.setName("_return_value");
                     } else {
-                        logger.info("invalid null column name, skipping column : "
-                                + key);
+                        logger.info("invalid null column name, skipping column : " + key);
                         continue;
                     }
                 }
@@ -1051,7 +1006,7 @@ public class DbLoader {
 
     /**
      * Sets new naming strategy for reverse engineering
-     *
+     * 
      * @since 3.0
      */
     public void setNamingStrategy(NamingStrategy strategy) {

Modified: cayenne/main/trunk/framework/cayenne-core-unpublished/src/main/java/org/apache/cayenne/access/jdbc/EJBQLDbPathTranslator.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-core-unpublished/src/main/java/org/apache/cayenne/access/jdbc/EJBQLDbPathTranslator.java?rev=1510297&r1=1510296&r2=1510297&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-core-unpublished/src/main/java/org/apache/cayenne/access/jdbc/EJBQLDbPathTranslator.java (original)
+++ cayenne/main/trunk/framework/cayenne-core-unpublished/src/main/java/org/apache/cayenne/access/jdbc/EJBQLDbPathTranslator.java Sun Aug  4 18:27:08 2013
@@ -133,7 +133,7 @@ public abstract class EJBQLDbPathTransla
     }
 
     private void processIntermediatePathComponent() {
-        DbRelationship relationship = (DbRelationship) currentEntity.getRelationship(lastPathComponent);
+        DbRelationship relationship = currentEntity.getRelationship(lastPathComponent);
         if (relationship == null) {
             throw new EJBQLException("Unknown relationship '" + lastPathComponent + "' for entity '"
                     + currentEntity.getName() + "'");
@@ -144,14 +144,14 @@ public abstract class EJBQLDbPathTransla
 
     private void processLastPathComponent() {
 
-        DbAttribute attribute = (DbAttribute) currentEntity.getAttribute(lastPathComponent);
+        DbAttribute attribute = currentEntity.getAttribute(lastPathComponent);
 
         if (attribute != null) {
             processTerminatingAttribute(attribute);
             return;
         }
 
-        DbRelationship relationship = (DbRelationship) currentEntity.getRelationship(lastPathComponent);
+        DbRelationship relationship = currentEntity.getRelationship(lastPathComponent);
         if (relationship != null) {
             processTerminatingRelationship(relationship);
             return;

Modified: cayenne/main/trunk/framework/cayenne-core-unpublished/src/main/java/org/apache/cayenne/access/jdbc/EJBQLIdColumnsTranslator.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-core-unpublished/src/main/java/org/apache/cayenne/access/jdbc/EJBQLIdColumnsTranslator.java?rev=1510297&r1=1510296&r2=1510297&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-core-unpublished/src/main/java/org/apache/cayenne/access/jdbc/EJBQLIdColumnsTranslator.java (original)
+++ cayenne/main/trunk/framework/cayenne-core-unpublished/src/main/java/org/apache/cayenne/access/jdbc/EJBQLIdColumnsTranslator.java Sun Aug  4 18:27:08 2013
@@ -52,8 +52,7 @@ class EJBQLIdColumnsTranslator extends E
         ObjEntity oe = descriptor.getEntity();
 
         for (ObjAttribute oa : oe.getPrimaryKeys()) {
-            DbAttribute t = (DbAttribute) oe.getDbEntity().getAttribute(
-                    oa.getDbAttributeName());
+            DbAttribute t = oe.getDbEntity().getAttribute(oa.getDbAttributeName());
             appendColumn(idVar, oa, t, fields, oa.getType());
         }
 

Modified: cayenne/main/trunk/framework/cayenne-core-unpublished/src/main/java/org/apache/cayenne/access/jdbc/IdRowReader.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-core-unpublished/src/main/java/org/apache/cayenne/access/jdbc/IdRowReader.java?rev=1510297&r1=1510296&r2=1510297&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-core-unpublished/src/main/java/org/apache/cayenne/access/jdbc/IdRowReader.java (original)
+++ cayenne/main/trunk/framework/cayenne-core-unpublished/src/main/java/org/apache/cayenne/access/jdbc/IdRowReader.java Sun Aug  4 18:27:08 2013
@@ -52,7 +52,7 @@ class IdRowReader<T> extends BaseRowRead
         int[] pk = new int[len];
         ColumnDescriptor[] columns = descriptor.getColumns();
         for (int i = 0, j = 0; i < columns.length; i++) {
-            DbAttribute a = (DbAttribute) dbEntity.getAttribute(columns[i].getName());
+            DbAttribute a = dbEntity.getAttribute(columns[i].getName());
             if (a != null && a.isPrimaryKey()) {
                 pk[j++] = i;
             }

Modified: cayenne/main/trunk/framework/cayenne-core-unpublished/src/main/java/org/apache/cayenne/access/jdbc/SoftDeleteBatchQueryBuilder.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-core-unpublished/src/main/java/org/apache/cayenne/access/jdbc/SoftDeleteBatchQueryBuilder.java?rev=1510297&r1=1510296&r2=1510297&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-core-unpublished/src/main/java/org/apache/cayenne/access/jdbc/SoftDeleteBatchQueryBuilder.java (original)
+++ cayenne/main/trunk/framework/cayenne-core-unpublished/src/main/java/org/apache/cayenne/access/jdbc/SoftDeleteBatchQueryBuilder.java Sun Aug  4 18:27:08 2013
@@ -78,7 +78,7 @@ public class SoftDeleteBatchQueryBuilder
      * @return whether 'soft' deletion should be used
      */
     protected boolean needSoftDelete(BatchQuery query) {
-        DbAttribute attr = (DbAttribute) query.getDbEntity().getAttribute(deletedFieldName);
+        DbAttribute attr = query.getDbEntity().getAttribute(deletedFieldName);
         return attr != null && attr.getType() == Types.BOOLEAN;
     }
 }

Modified: cayenne/main/trunk/framework/cayenne-core-unpublished/src/main/java/org/apache/cayenne/access/trans/SelectTranslator.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-core-unpublished/src/main/java/org/apache/cayenne/access/trans/SelectTranslator.java?rev=1510297&r1=1510296&r2=1510297&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-core-unpublished/src/main/java/org/apache/cayenne/access/trans/SelectTranslator.java (original)
+++ cayenne/main/trunk/framework/cayenne-core-unpublished/src/main/java/org/apache/cayenne/access/trans/SelectTranslator.java Sun Aug  4 18:27:08 2013
@@ -109,9 +109,9 @@ public class SelectTranslator extends Qu
      */
     @Override
     public String createSqlString() throws Exception {
-    	if (cachedSqlString != null)
-    		return cachedSqlString;
-    	
+        if (cachedSqlString != null)
+            return cachedSqlString;
+
         DataMap dataMap = queryMetadata.getDataMap();
         JoinStack joins = getJoinStack();
 
@@ -509,7 +509,7 @@ public class SelectTranslator extends Qu
 
             // synthetic objattributes can't reliably lookup their DbAttribute,
             // so do it manually..
-            DbAttribute dbAttribute = (DbAttribute) dbEntity.getAttribute(attribute.getDbAttributeName());
+            DbAttribute dbAttribute = dbEntity.getAttribute(attribute.getDbAttributeName());
             appendColumn(columns, attribute, dbAttribute, skipSet, null);
         }
 

Modified: cayenne/main/trunk/framework/cayenne-core-unpublished/src/main/java/org/apache/cayenne/dba/JdbcAdapter.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-core-unpublished/src/main/java/org/apache/cayenne/dba/JdbcAdapter.java?rev=1510297&r1=1510296&r2=1510297&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-core-unpublished/src/main/java/org/apache/cayenne/dba/JdbcAdapter.java (original)
+++ cayenne/main/trunk/framework/cayenne-core-unpublished/src/main/java/org/apache/cayenne/dba/JdbcAdapter.java Sun Aug  4 18:27:08 2013
@@ -94,7 +94,7 @@ public class JdbcAdapter implements DbAd
         this.setSupportsBatchUpdates(false);
         this.setSupportsUniqueConstraints(true);
         this.caseInsensitiveCollations = runtimeProperties.getBoolean(Constants.CI_PROPERTY, false);
-        
+
         // TODO: andrus 05.02.2010 - ideally this should be injected
         this.resourceLocator = new ClassLoaderResourceLocator();
 
@@ -260,7 +260,7 @@ public class JdbcAdapter implements DbAd
 
         sqlBuffer.append(" (");
         // columns
-        Iterator<?> it = entity.getAttributes().iterator();
+        Iterator<DbAttribute> it = entity.getAttributes().iterator();
         if (it.hasNext()) {
             boolean first = true;
             while (it.hasNext()) {
@@ -270,7 +270,7 @@ public class JdbcAdapter implements DbAd
                     sqlBuffer.append(", ");
                 }
 
-                DbAttribute column = (DbAttribute) it.next();
+                DbAttribute column = it.next();
 
                 // attribute may not be fully valid, do a simple check
                 if (column.getType() == TypesMapping.NOT_DEFINED) {
@@ -578,5 +578,5 @@ public class JdbcAdapter implements DbAd
     public void setBatchQueryBuilderFactory(BatchQueryBuilderFactory batchQueryBuilderFactory) {
         this.batchQueryBuilderFactory = batchQueryBuilderFactory;
     }
-    
+
 }

Modified: cayenne/main/trunk/framework/cayenne-core-unpublished/src/main/java/org/apache/cayenne/dba/mysql/MySQLAdapter.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-core-unpublished/src/main/java/org/apache/cayenne/dba/mysql/MySQLAdapter.java?rev=1510297&r1=1510296&r2=1510297&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-core-unpublished/src/main/java/org/apache/cayenne/dba/mysql/MySQLAdapter.java (original)
+++ cayenne/main/trunk/framework/cayenne-core-unpublished/src/main/java/org/apache/cayenne/dba/mysql/MySQLAdapter.java Sun Aug  4 18:27:08 2013
@@ -50,7 +50,6 @@ import org.apache.cayenne.di.Inject;
 import org.apache.cayenne.map.DbAttribute;
 import org.apache.cayenne.map.DbEntity;
 import org.apache.cayenne.map.DbRelationship;
-import org.apache.cayenne.map.Relationship;
 import org.apache.cayenne.merge.MergerFactory;
 import org.apache.cayenne.query.Query;
 import org.apache.cayenne.query.SQLAction;
@@ -276,13 +275,12 @@ public class MySQLAdapter extends JdbcAd
         // automatically when
         // constraint is defined, starting at MySQL 4.1.2
         if (supportsFkConstraints) {
-            for (Relationship r : entity.getRelationships()) {
-                DbRelationship relationship = (DbRelationship) r;
-                if (relationship.getJoins().size() > 0 && relationship.isToPK() && !relationship.isToDependentPK()) {
+            for (DbRelationship r : entity.getRelationships()) {
+                if (r.getJoins().size() > 0 && r.isToPK() && !r.isToDependentPK()) {
 
                     sqlBuffer.append(", KEY (");
 
-                    Iterator<DbAttribute> columns = relationship.getSourceAttributes().iterator();
+                    Iterator<DbAttribute> columns = r.getSourceAttributes().iterator();
                     DbAttribute column = columns.next();
                     sqlBuffer.append(quotingStrategy.quotedName(column));
 

Modified: cayenne/main/trunk/framework/cayenne-core-unpublished/src/main/java/org/apache/cayenne/dba/sqlserver/SQLServerBatchAction.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-core-unpublished/src/main/java/org/apache/cayenne/dba/sqlserver/SQLServerBatchAction.java?rev=1510297&r1=1510296&r2=1510297&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-core-unpublished/src/main/java/org/apache/cayenne/dba/sqlserver/SQLServerBatchAction.java (original)
+++ cayenne/main/trunk/framework/cayenne-core-unpublished/src/main/java/org/apache/cayenne/dba/sqlserver/SQLServerBatchAction.java Sun Aug  4 18:27:08 2013
@@ -27,7 +27,6 @@ import java.util.Collections;
 import org.apache.cayenne.access.OperationObserver;
 import org.apache.cayenne.access.jdbc.BatchAction;
 import org.apache.cayenne.dba.JdbcAdapter;
-import org.apache.cayenne.map.Attribute;
 import org.apache.cayenne.map.DbAttribute;
 import org.apache.cayenne.map.EntityResolver;
 import org.apache.cayenne.query.BatchQuery;
@@ -106,8 +105,8 @@ public class SQLServerBatchAction extend
         }
 
         // find identity attributes
-        for (Attribute attribute : query.getDbEntity().getAttributes()) {
-            if (((DbAttribute) attribute).isGenerated()) {
+        for (DbAttribute attribute : query.getDbEntity().getAttributes()) {
+            if (attribute.isGenerated()) {
                 return true;
             }
         }

Modified: cayenne/main/trunk/framework/cayenne-core-unpublished/src/main/java/org/apache/cayenne/map/DbAttribute.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-core-unpublished/src/main/java/org/apache/cayenne/map/DbAttribute.java?rev=1510297&r1=1510296&r2=1510297&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-core-unpublished/src/main/java/org/apache/cayenne/map/DbAttribute.java (original)
+++ cayenne/main/trunk/framework/cayenne-core-unpublished/src/main/java/org/apache/cayenne/map/DbAttribute.java Sun Aug  4 18:27:08 2013
@@ -48,8 +48,8 @@ public class DbAttribute extends Attribu
     protected boolean primaryKey;
 
     /**
-     * Defines whether this column value is generated by the database. Other terms for
-     * such columns are "auto-increment" or "identity".
+     * Defines whether this column value is generated by the database. Other
+     * terms for such columns are "auto-increment" or "identity".
      * 
      * @since 1.2
      */
@@ -66,7 +66,8 @@ public class DbAttribute extends Attribu
     /**
      * @since 3.0
      */
-    // must call it 'attributePrecison' as 'precision' in 1.2 really meant 'scale'
+    // must call it 'attributePrecison' as 'precision' in 1.2 really meant
+    // 'scale'
     protected int attributePrecision = -1;
 
     public DbAttribute() {
@@ -83,6 +84,11 @@ public class DbAttribute extends Attribu
         this.setEntity(entity);
     }
 
+    @Override
+    public DbEntity getEntity() {
+        return (DbEntity) super.getEntity();
+    }
+
     public <T> T acceptVisitor(ConfigurationNodeVisitor<T> visitor) {
         return visitor.visitDbAttribute(this);
     }
@@ -165,8 +171,8 @@ public class DbAttribute extends Attribu
     }
 
     /**
-     * Returns <code>true</code> if the DB column represented by this attribute is a
-     * foreign key, referencing another table.
+     * Returns <code>true</code> if the DB column represented by this attribute
+     * is a foreign key, referencing another table.
      * 
      * @since 1.1
      */
@@ -177,8 +183,8 @@ public class DbAttribute extends Attribu
             return false;
         }
 
-        for (Relationship relationship : getEntity().getRelationships()) {
-            for (DbJoin join : ((DbRelationship) relationship).getJoins()) {
+        for (DbRelationship relationship : getEntity().getRelationships()) {
+            for (DbJoin join : relationship.getJoins()) {
                 if (name.equals(join.getSourceName())) {
                     DbAttribute target = join.getTarget();
                     if (target != null && target.isPrimaryKey()) {
@@ -200,10 +206,7 @@ public class DbAttribute extends Attribu
 
             Entity e = this.getEntity();
             if (e instanceof DbAttributeListener) {
-                ((DbAttributeListener) e).dbAttributeChanged(new AttributeEvent(
-                        this,
-                        this,
-                        e));
+                ((DbAttributeListener) e).dbAttributeChanged(new AttributeEvent(this, this, e));
             }
         }
     }
@@ -224,15 +227,16 @@ public class DbAttribute extends Attribu
     }
 
     /**
-     * Sets the length of character or binary type or max num of digits for DECIMAL.
+     * Sets the length of character or binary type or max num of digits for
+     * DECIMAL.
      */
     public void setMaxLength(int maxLength) {
         this.maxLength = maxLength;
     }
 
     /**
-     * Returns true if this column value is generated by the database. Other terms for
-     * such columns are "auto-increment" or "identity".
+     * Returns true if this column value is generated by the database. Other
+     * terms for such columns are "auto-increment" or "identity".
      * 
      * @since 1.2
      */
@@ -251,10 +255,7 @@ public class DbAttribute extends Attribu
 
             Entity e = this.getEntity();
             if (e instanceof DbAttributeListener) {
-                ((DbAttributeListener) e).dbAttributeChanged(new AttributeEvent(
-                        this,
-                        this,
-                        e));
+                ((DbAttributeListener) e).dbAttributeChanged(new AttributeEvent(this, this, e));
             }
         }
     }
@@ -274,8 +275,8 @@ public class DbAttribute extends Attribu
     }
 
     /**
-     * Returns the number of digits after period for decimal attributes. Returns "-1" if
-     * not set.
+     * Returns the number of digits after period for decimal attributes. Returns
+     * "-1" if not set.
      * 
      * @since 3.0
      */

Modified: cayenne/main/trunk/framework/cayenne-core-unpublished/src/main/java/org/apache/cayenne/map/DbEntity.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-core-unpublished/src/main/java/org/apache/cayenne/map/DbEntity.java?rev=1510297&r1=1510296&r2=1510297&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-core-unpublished/src/main/java/org/apache/cayenne/map/DbEntity.java (original)
+++ cayenne/main/trunk/framework/cayenne-core-unpublished/src/main/java/org/apache/cayenne/map/DbEntity.java Sun Aug  4 18:27:08 2013
@@ -88,12 +88,12 @@ public class DbEntity extends Entity imp
         this();
         this.setName(name);
     }
-    
+
     @Override
     public DbRelationship getRelationship(String relName) {
         return (DbRelationship) super.getRelationship(relName);
     }
-    
+
     @Override
     public DbAttribute getAttribute(String attributeName) {
         return (DbAttribute) super.getAttribute(attributeName);
@@ -452,10 +452,9 @@ public class DbEntity extends Entity imp
                     }
 
                     // handle all of the relationships / joins that use the
-                    // changed
-                    // attribute
-                    for (Relationship rel : ent.getRelationships()) {
-                        for (DbJoin join : ((DbRelationship) rel).getJoins()) {
+                    // changed attribute
+                    for (DbRelationship rel : ent.getRelationships()) {
+                        for (DbJoin join : rel.getJoins()) {
                             if (join.getSource() == dbAttribute) {
                                 join.setSourceName(newName);
                             }
@@ -488,10 +487,9 @@ public class DbEntity extends Entity imp
             default:
                 // generic update
                 this.primaryKey.clear();
-                for (Object next : getAttributes()) {
-                    DbAttribute dba = (DbAttribute) next;
-                    if (dba.isPrimaryKey()) {
-                        this.primaryKey.add(dba);
+                for (DbAttribute next : getAttributes()) {
+                    if (next.isPrimaryKey()) {
+                        this.primaryKey.add(next);
                     }
                 }
             }
@@ -511,10 +509,9 @@ public class DbEntity extends Entity imp
             default:
                 // generic update
                 this.generatedAttributes.clear();
-                for (Object next : getAttributes()) {
-                    DbAttribute dba = (DbAttribute) next;
-                    if (dba.isGenerated()) {
-                        this.generatedAttributes.add(dba);
+                for (DbAttribute next : getAttributes()) {
+                    if (next.isGenerated()) {
+                        this.generatedAttributes.add(next);
                     }
                 }
             }

Modified: cayenne/main/trunk/framework/cayenne-core-unpublished/src/main/java/org/apache/cayenne/map/DbRelationship.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-core-unpublished/src/main/java/org/apache/cayenne/map/DbRelationship.java?rev=1510297&r1=1510296&r2=1510297&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-core-unpublished/src/main/java/org/apache/cayenne/map/DbRelationship.java (original)
+++ cayenne/main/trunk/framework/cayenne-core-unpublished/src/main/java/org/apache/cayenne/map/DbRelationship.java Sun Aug  4 18:27:08 2013
@@ -35,8 +35,8 @@ import org.apache.commons.collections.Co
 import org.apache.commons.collections.Transformer;
 
 /**
- * A DbRelationship is a descriptor of a database inter-table relationship based on one or
- * more primary key/foreign key pairs.
+ * A DbRelationship is a descriptor of a database inter-table relationship based
+ * on one or more primary key/foreign key pairs.
  */
 public class DbRelationship extends Relationship implements ConfigurationNode {
 
@@ -44,7 +44,8 @@ public class DbRelationship extends Rela
     protected List<DbJoin> joins = new ArrayList<DbJoin>(2);
 
     // Is relationship from source to target points to dependent primary
-    // key (primary key column of destination table that is also a FK to the source
+    // key (primary key column of destination table that is also a FK to the
+    // source
     // column)
     protected boolean toDependentPK;
 
@@ -55,12 +56,12 @@ public class DbRelationship extends Rela
     public DbRelationship(String name) {
         super(name);
     }
-    
+
     @Override
     public DbEntity getSourceEntity() {
         return (DbEntity) super.getSourceEntity();
     }
-    
+
     /**
      * @since 3.1
      */
@@ -100,8 +101,9 @@ public class DbRelationship extends Rela
     }
 
     /**
-     * Returns a target of this relationship. If relationship is not attached to a
-     * DbEntity, and DbEntity doesn't have a namespace, and exception is thrown.
+     * Returns a target of this relationship. If relationship is not attached to
+     * a DbEntity, and DbEntity doesn't have a namespace, and exception is
+     * thrown.
      */
     @Override
     public DbEntity getTargetEntity() {
@@ -140,8 +142,8 @@ public class DbRelationship extends Rela
     }
 
     /**
-     * Creates a new relationship with the same set of joins, but going in the opposite
-     * direction.
+     * Creates a new relationship with the same set of joins, but going in the
+     * opposite direction.
      * 
      * @since 1.0.5
      */
@@ -152,16 +154,15 @@ public class DbRelationship extends Rela
         reverse.setSourceEntity(targetEntity);
         reverse.setTargetEntityName(getSourceEntity().getName());
 
-        // TODO: andrus 12/24/2007 - one more case to handle - set reverse toDepPK = true
-        // if this relationship toDepPK is false, but the entities are joined on a PK...
+        // TODO: andrus 12/24/2007 - one more case to handle - set reverse
+        // toDepPK = true
+        // if this relationship toDepPK is false, but the entities are joined on
+        // a PK...
         // on the other hand, these can still be two independent entities...
 
-        if (isToDependentPK()
-                && !toMany
-                && joins.size() == targetEntity.getPrimaryKeys().size()) {
+        if (isToDependentPK() && !toMany && joins.size() == targetEntity.getPrimaryKeys().size()) {
             reverse.setToMany(false);
-        }
-        else {
+        } else {
             reverse.setToMany(!toMany);
         }
 
@@ -175,12 +176,12 @@ public class DbRelationship extends Rela
     }
 
     /**
-     * Returns DbRelationship that is the opposite of this DbRelationship. This means a
-     * relationship from this target entity to this source entity with the same join
-     * semantics. Returns null if no such relationship exists.
+     * Returns DbRelationship that is the opposite of this DbRelationship. This
+     * means a relationship from this target entity to this source entity with
+     * the same join semantics. Returns null if no such relationship exists.
      */
     public DbRelationship getReverseRelationship() {
-        Entity target = this.getTargetEntity();
+        DbEntity target = getTargetEntity();
 
         if (target == null) {
             return null;
@@ -194,11 +195,11 @@ public class DbRelationship extends Rela
         }
 
         TestJoin testJoin = new TestJoin(this);
-        for (Relationship rel : target.getRelationships()) {
+        for (DbRelationship rel : target.getRelationships()) {
             if (rel.getTargetEntity() != src)
                 continue;
 
-            List<DbJoin> otherJoins = ((DbRelationship) rel).getJoins();
+            List<DbJoin> otherJoins = rel.getJoins();
             if (otherJoins.size() != joins.size()) {
                 continue;
             }
@@ -215,7 +216,7 @@ public class DbRelationship extends Rela
             }
 
             if (joinsMatch) {
-                return (DbRelationship) rel;
+                return rel;
             }
         }
 
@@ -223,8 +224,8 @@ public class DbRelationship extends Rela
     }
 
     /**
-     * Returns true if the relationship points to at least one of the PK columns of the
-     * target entity.
+     * Returns true if the relationship points to at least one of the PK columns
+     * of the target entity.
      * 
      * @since 1.1
      */
@@ -263,8 +264,8 @@ public class DbRelationship extends Rela
     }
 
     /**
-     * Returns <code>true</code> if a method <code>isToDependentPK</code> of reverse
-     * relationship of this relationship returns <code>true</code>.
+     * Returns <code>true</code> if a method <code>isToDependentPK</code> of
+     * reverse relationship of this relationship returns <code>true</code>.
      */
     public boolean isToMasterPK() {
         if (isToMany() || isToDependentPK()) {
@@ -276,9 +277,9 @@ public class DbRelationship extends Rela
     }
 
     /**
-     * Returns <code>true</code> if relationship from source to target points to dependent
-     * primary key. Dependent PK is a primary key column of the destination table that is
-     * also a FK to the source column.
+     * Returns <code>true</code> if relationship from source to target points to
+     * dependent primary key. Dependent PK is a primary key column of the
+     * destination table that is also a FK to the source column.
      */
     public boolean isToDependentPK() {
         return toDependentPK;
@@ -301,8 +302,7 @@ public class DbRelationship extends Rela
             DbAttribute target = join.getTarget();
             DbAttribute source = join.getSource();
 
-            if ((target != null && !target.isPrimaryKey())
-                    || (source != null && !source.isPrimaryKey())) {
+            if ((target != null && !target.isPrimaryKey()) || (source != null && !source.isPrimaryKey())) {
                 return false;
             }
         }
@@ -311,8 +311,8 @@ public class DbRelationship extends Rela
     }
 
     /**
-     * Returns a list of joins. List is returned by reference, so any modifications of the
-     * list will affect this relationship.
+     * Returns a list of joins. List is returned by reference, so any
+     * modifications of the list will affect this relationship.
      */
     public List<DbJoin> getJoins() {
         return joins;
@@ -347,17 +347,15 @@ public class DbRelationship extends Rela
 
     /**
      * Creates a snapshot of primary key attributes of a target object of this
-     * relationship based on a snapshot of a source. Only "to-one" relationships are
-     * supported. Returns null if relationship does not point to an object. Throws
-     * CayenneRuntimeException if relationship is "to many" or if snapshot is missing id
-     * components.
+     * relationship based on a snapshot of a source. Only "to-one" relationships
+     * are supported. Returns null if relationship does not point to an object.
+     * Throws CayenneRuntimeException if relationship is "to many" or if
+     * snapshot is missing id components.
      */
-    public Map<String, Object> targetPkSnapshotWithSrcSnapshot(
-            Map<String, Object> srcSnapshot) {
+    public Map<String, Object> targetPkSnapshotWithSrcSnapshot(Map<String, Object> srcSnapshot) {
 
         if (isToMany()) {
-            throw new CayenneRuntimeException(
-                    "Only 'to one' relationships support this method.");
+            throw new CayenneRuntimeException("Only 'to one' relationships support this method.");
         }
 
         Map<String, Object> idMap;
@@ -372,8 +370,7 @@ public class DbRelationship extends Rela
             if (val == null) {
                 foundNulls++;
                 idMap = Collections.EMPTY_MAP;
-            }
-            else {
+            } else {
                 idMap = Collections.singletonMap(join.getTargetName(), val);
             }
         }
@@ -388,14 +385,14 @@ public class DbRelationship extends Rela
                 if (val == null) {
 
                     // some keys may be nulls and some not in case of multi-key
-                    // relationships where PK and FK partially overlap (see CAY-284)
+                    // relationships where PK and FK partially overlap (see
+                    // CAY-284)
                     if (!source.isMandatory()) {
                         return null;
                     }
 
                     foundNulls++;
-                }
-                else {
+                } else {
                     idMap.put(join.getTargetName(), val);
                 }
             }
@@ -403,23 +400,19 @@ public class DbRelationship extends Rela
 
         if (foundNulls == 0) {
             return idMap;
-        }
-        else if (foundNulls == numJoins) {
+        } else if (foundNulls == numJoins) {
             return null;
-        }
-        else {
-            throw new CayenneRuntimeException("Some parts of FK are missing in snapshot,"
-                    + " relationship: "
-                    + this);
+        } else {
+            throw new CayenneRuntimeException("Some parts of FK are missing in snapshot," + " relationship: " + this);
         }
     }
 
     /**
-     * Common code to srcSnapshotWithTargetSnapshot. Both are functionally the same,
-     * except for the name, and whether they operate on a toMany or a toOne.
+     * Common code to srcSnapshotWithTargetSnapshot. Both are functionally the
+     * same, except for the name, and whether they operate on a toMany or a
+     * toOne.
      */
-    private Map<String, Object> srcSnapshotWithTargetSnapshot(
-            Map<String, Object> targetSnapshot) {
+    private Map<String, Object> srcSnapshotWithTargetSnapshot(Map<String, Object> targetSnapshot) {
         int len = joins.size();
 
         // optimize for the most common single column join
@@ -442,15 +435,14 @@ public class DbRelationship extends Rela
 
     /**
      * Creates a snapshot of foreign key attributes of a source object of this
-     * relationship based on a snapshot of a target. Only "to-one" relationships are
-     * supported. Throws CayenneRuntimeException if relationship is "to many".
+     * relationship based on a snapshot of a target. Only "to-one" relationships
+     * are supported. Throws CayenneRuntimeException if relationship is
+     * "to many".
      */
-    public Map<String, Object> srcFkSnapshotWithTargetSnapshot(
-            Map<String, Object> targetSnapshot) {
+    public Map<String, Object> srcFkSnapshotWithTargetSnapshot(Map<String, Object> targetSnapshot) {
 
         if (isToMany()) {
-            throw new CayenneRuntimeException(
-                    "Only 'to one' relationships support this method.");
+            throw new CayenneRuntimeException("Only 'to one' relationships support this method.");
         }
 
         return srcSnapshotWithTargetSnapshot(targetSnapshot);
@@ -458,14 +450,13 @@ public class DbRelationship extends Rela
 
     /**
      * Creates a snapshot of primary key attributes of a source object of this
-     * relationship based on a snapshot of a target. Only "to-many" relationships are
-     * supported. Throws CayenneRuntimeException if relationship is "to one".
+     * relationship based on a snapshot of a target. Only "to-many"
+     * relationships are supported. Throws CayenneRuntimeException if
+     * relationship is "to one".
      */
-    public Map<String, Object> srcPkSnapshotWithTargetSnapshot(
-            Map<String, Object> targetSnapshot) {
+    public Map<String, Object> srcPkSnapshotWithTargetSnapshot(Map<String, Object> targetSnapshot) {
         if (!isToMany())
-            throw new CayenneRuntimeException(
-                    "Only 'to many' relationships support this method.");
+            throw new CayenneRuntimeException("Only 'to many' relationships support this method.");
         return srcSnapshotWithTargetSnapshot(targetSnapshot);
     }
 
@@ -475,7 +466,7 @@ public class DbRelationship extends Rela
     public void setToMany(boolean toMany) {
         this.toMany = toMany;
     }
-    
+
     @Override
     public boolean isMandatory() {
         for (DbJoin join : getJoins()) {
@@ -483,7 +474,7 @@ public class DbRelationship extends Rela
                 return true;
             }
         }
-        
+
         return false;
     }
 
@@ -526,8 +517,7 @@ public class DbRelationship extends Rela
             }
 
             DbJoin j = (DbJoin) o;
-            return j.relationship == this.relationship
-                    && Util.nullSafeEquals(j.sourceName, this.sourceName)
+            return j.relationship == this.relationship && Util.nullSafeEquals(j.sourceName, this.sourceName)
                     && Util.nullSafeEquals(j.targetName, this.targetName);
         }
     }

Modified: cayenne/main/trunk/framework/cayenne-core-unpublished/src/main/java/org/apache/cayenne/map/EntityResolver.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-core-unpublished/src/main/java/org/apache/cayenne/map/EntityResolver.java?rev=1510297&r1=1510296&r2=1510297&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-core-unpublished/src/main/java/org/apache/cayenne/map/EntityResolver.java (original)
+++ cayenne/main/trunk/framework/cayenne-core-unpublished/src/main/java/org/apache/cayenne/map/EntityResolver.java Sun Aug  4 18:27:08 2013
@@ -98,11 +98,11 @@ public class EntityResolver implements M
             for (DbEntity entity : map.getDbEntities()) {
 
                 // iterate by copy to avoid concurrency modification errors on
-                // reflexive
-                // relationships
-                Object[] relationships = entity.getRelationships().toArray();
-                for (int i = 0; i < relationships.length; i++) {
-                    DbRelationship relationship = (DbRelationship) relationships[i];
+                // reflexive relationships
+                DbRelationship[] relationships = entity.getRelationships().toArray(
+                        new DbRelationship[entity.getRelationships().size()]);
+
+                for (DbRelationship relationship : relationships) {
                     if (relationship.getReverseRelationship() == null) {
                         DbRelationship reverse = relationship.createReverseRelationship();
 

Modified: cayenne/main/trunk/framework/cayenne-core-unpublished/src/main/java/org/apache/cayenne/map/ObjAttribute.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-core-unpublished/src/main/java/org/apache/cayenne/map/ObjAttribute.java?rev=1510297&r1=1510296&r2=1510297&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-core-unpublished/src/main/java/org/apache/cayenne/map/ObjAttribute.java (original)
+++ cayenne/main/trunk/framework/cayenne-core-unpublished/src/main/java/org/apache/cayenne/map/ObjAttribute.java Sun Aug  4 18:27:08 2013
@@ -64,16 +64,21 @@ public class ObjAttribute extends Attrib
         setUsedForLocking(attribute.isUsedForLocking());
     }
 
+    @Override
+    public ObjEntity getEntity() {
+        return (ObjEntity) super.getEntity();
+    }
+
     /**
      * @since 3.1
      */
     public <T> T acceptVisitor(ConfigurationNodeVisitor<T> visitor) {
         return visitor.visitObjAttribute(this);
     }
-    
+
     /**
-     * Returns Java class of an object property described by this attribute. Wraps any
-     * thrown exceptions into CayenneRuntimeException.
+     * Returns Java class of an object property described by this attribute.
+     * Wraps any thrown exceptions into CayenneRuntimeException.
      */
     public Class<?> getJavaClass() {
         if (this.getType() == null) {
@@ -82,11 +87,8 @@ public class ObjAttribute extends Attrib
 
         try {
             return Util.getJavaClass(getType());
-        }
-        catch (ClassNotFoundException e) {
-            throw new CayenneRuntimeException("Failed to load class for name '"
-                    + this.getType()
-                    + "': "
+        } catch (ClassNotFoundException e) {
+            throw new CayenneRuntimeException("Failed to load class for name '" + this.getType() + "': "
                     + e.getMessage(), e);
         }
     }
@@ -112,8 +114,7 @@ public class ObjAttribute extends Attrib
 
         // If this obj attribute is mapped to db attribute
         if (getDbAttribute() != null
-                || (((ObjEntity) getEntity()).isAbstract() && !Util
-                        .isEmptyString(getDbAttributePath()))) {
+                || (((ObjEntity) getEntity()).isAbstract() && !Util.isEmptyString(getDbAttributePath()))) {
             encoder.print(" db-attribute-path=\"");
             encoder.print(Util.encodeXmlAttribute(getDbAttributePath()));
             encoder.print('\"');
@@ -123,16 +124,16 @@ public class ObjAttribute extends Attrib
     }
 
     /**
-     * Returns fully qualified Java class name of the object property represented by this
-     * attribute.
+     * Returns fully qualified Java class name of the object property
+     * represented by this attribute.
      */
     public String getType() {
         return type;
     }
 
     /**
-     * Sets the type of the data object property. Type is expected to be a fully qualified
-     * Java class name.
+     * Sets the type of the data object property. Type is expected to be a fully
+     * qualified Java class name.
      */
     public void setType(String type) {
         this.type = type;
@@ -242,7 +243,7 @@ public class ObjAttribute extends Attrib
 
         int lastPartStart = dbAttributePath.lastIndexOf('.');
         if (lastPartStart < 0) {
-            DbAttribute attribute = (DbAttribute) dbEnt.getAttribute(dbAttributePath);
+            DbAttribute attribute = dbEnt.getAttribute(dbAttributePath);
             if (attribute == null) {
                 return IteratorUtils.EMPTY_ITERATOR;
             }
@@ -254,8 +255,8 @@ public class ObjAttribute extends Attrib
 
     /**
      * Returns the the name of the mapped DbAttribute. This value is the same as
-     * "dbAttributePath" for regular attributes mapped to columns. It is equql to the last
-     * path component for the flattened attributes.
+     * "dbAttributePath" for regular attributes mapped to columns. It is equql
+     * to the last path component for the flattened attributes.
      */
     public String getDbAttributeName() {
         if (dbAttributePath == null) {
@@ -279,17 +280,18 @@ public class ObjAttribute extends Attrib
     }
 
     /**
-     * Returns a dot-separated path that starts in the root DbEntity that maps to this
-     * attribute's ObjEntity and spans zero or more relationships, always ending in a
-     * DbAttribute name.
+     * Returns a dot-separated path that starts in the root DbEntity that maps
+     * to this attribute's ObjEntity and spans zero or more relationships,
+     * always ending in a DbAttribute name.
      */
     public String getDbAttributePath() {
         return dbAttributePath;
     }
 
     /**
-     * Returns whether this attribute is "flattened", meaning that it points to a column
-     * from an entity other than the DbEntity mapped to the parent ObjEntity.
+     * Returns whether this attribute is "flattened", meaning that it points to
+     * a column from an entity other than the DbEntity mapped to the parent
+     * ObjEntity.
      * 
      * @since 3.0
      */
@@ -330,7 +332,8 @@ public class ObjAttribute extends Attrib
         DbAttribute dbAttribute = getDbAttribute();
         if (dbAttribute != null) {
 
-            // expose PK attribute names - the client may need those to build ObjectIds
+            // expose PK attribute names - the client may need those to build
+            // ObjectIds
             if (dbAttribute.isPrimaryKey()) {
                 attribute.setDbAttributePath(dbAttribute.getName());
                 attribute.setPrimaryKey(true);
@@ -344,26 +347,26 @@ public class ObjAttribute extends Attrib
 
         return attribute;
     }
-    
+
     /**
      * Updates DbAttributePath for this ObjAttribute
      */
     public void updateDbAttributePath() {
-        
+
         if (isFlattened()) {
             StringBuilder newDbAttributePath = new StringBuilder();
-            
+
             Iterator<CayenneMapEntry> dbPathIterator = getDbPathIterator();
-            
+
             while (dbPathIterator.hasNext()) {
                 CayenneMapEntry next = dbPathIterator.next();
-                
+
                 newDbAttributePath.append(next.getName());
                 if (next instanceof DbRelationship) {
                     newDbAttributePath.append('.');
                 }
             }
-            
+
             setDbAttributePath(newDbAttributePath.toString());
         }
     }

Modified: cayenne/main/trunk/framework/cayenne-core-unpublished/src/main/java/org/apache/cayenne/reflect/PersistentDescriptorFactory.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-core-unpublished/src/main/java/org/apache/cayenne/reflect/PersistentDescriptorFactory.java?rev=1510297&r1=1510296&r2=1510297&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-core-unpublished/src/main/java/org/apache/cayenne/reflect/PersistentDescriptorFactory.java (original)
+++ cayenne/main/trunk/framework/cayenne-core-unpublished/src/main/java/org/apache/cayenne/reflect/PersistentDescriptorFactory.java Sun Aug  4 18:27:08 2013
@@ -224,7 +224,7 @@ public abstract class PersistentDescript
                 public void startNode(Expression node, Expression parentNode) {
                     if (node.getType() == Expression.DB_PATH) {
                         String path = node.getOperand(0).toString();
-                        final DbAttribute attribute = (DbAttribute) dbEntity.getAttribute(path);
+                        final DbAttribute attribute = dbEntity.getAttribute(path);
                         if (attribute != null) {
 
                             ObjAttribute objectAttribute = descriptor.getEntity().getAttributeForDbAttribute(attribute);

Modified: cayenne/main/trunk/framework/cayenne-core-unpublished/src/test/java/org/apache/cayenne/CayenneDataObjectValidationTest.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-core-unpublished/src/test/java/org/apache/cayenne/CayenneDataObjectValidationTest.java?rev=1510297&r1=1510296&r2=1510297&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-core-unpublished/src/test/java/org/apache/cayenne/CayenneDataObjectValidationTest.java (original)
+++ cayenne/main/trunk/framework/cayenne-core-unpublished/src/test/java/org/apache/cayenne/CayenneDataObjectValidationTest.java Sun Aug  4 18:27:08 2013
@@ -23,7 +23,6 @@ import java.util.Date;
 import java.util.List;
 
 import org.apache.cayenne.di.Inject;
-import org.apache.cayenne.map.DbAttribute;
 import org.apache.cayenne.map.DbEntity;
 import org.apache.cayenne.testdo.testmap.Artist;
 import org.apache.cayenne.testdo.testmap.Exhibit;
@@ -94,7 +93,7 @@ public class CayenneDataObjectValidation
         Artist artist = context.newObject(Artist.class);
 
         DbEntity entity = context.getEntityResolver().getObjEntity(artist).getDbEntity();
-        int len = ((DbAttribute) entity.getAttribute("ARTIST_NAME")).getMaxLength();
+        int len = entity.getAttribute("ARTIST_NAME").getMaxLength();
         StringBuffer buf = new StringBuffer(len);
         for (int i = 0; i < len + 1; i++) {
             buf.append("c");