svn commit: r495677 [6/9] - in /db/ojb/trunk: ./ profile/ src/java/org/apache/ojb/broker/ src/java/org/apache/ojb/broker/accesslayer/ src/java/org/apache/ojb/broker/accesslayer/batch/ src/java/org/apache/ojb/broker/accesslayer/sql/ src/java/org/apache/...

[email protected]
Newsgroups gmane.comp.jakarta.ojb.devel
Message-ID <[email protected]>
Modified: db/ojb/trunk/src/java/org/apache/ojb/broker/metadata/ClassDescriptor.java
URL: http://svn.apache.org/viewvc/db/ojb/trunk/src/java/org/apache/ojb/broker/metadata/ClassDescriptor.java?view=diff&rev=495677&r1=495676&r2=495677
==============================================================================
--- db/ojb/trunk/src/java/org/apache/ojb/broker/metadata/ClassDescriptor.java (original)
+++ db/ojb/trunk/src/java/org/apache/ojb/broker/metadata/ClassDescriptor.java Fri Jan 12 10:19:39 2007
@@ -35,10 +35,10 @@
 import org.apache.commons.lang.SystemUtils;
 import org.apache.commons.lang.builder.ToStringBuilder;
 import org.apache.commons.lang.builder.ToStringStyle;
-import org.apache.ojb.broker.PersistenceBrokerException;
 import org.apache.ojb.broker.locking.IsolationLevels;
 import org.apache.ojb.broker.util.ClassHelper;
 import org.apache.ojb.broker.util.SqlHelper;
+import org.apache.ojb.broker.util.XmlHelper;
 import org.apache.ojb.broker.util.logging.LoggerFactory;
 
 /**
@@ -148,14 +148,7 @@
 //    private Vector superPersistentFieldDescriptors = null;
     /** The class name of the row reader specifically configured for this class */
     private String rowReaderClassName = null;
-    /**
-     * the class that this class extends
-     */
-    private String superClass;
-    /**
-     * reference column for the superclass
-     */
-    private int superClassFieldRef;
+
     /**
      * the proxy class for the described class, may be null
      */
@@ -190,6 +183,7 @@
     //-----------------------------------------------------------------
     //-----------------------------------------------------------------
     private FieldDescriptor m_autoIncrementField = null;
+    private FieldDescriptor[] autoIncrementFields = null;
     private FieldDescriptor m_discriminatorField = null;
     /**
      * the FieldDescriptors for the primitive attributes
@@ -223,7 +217,7 @@
     /**
      * the list of classes in the extent of this class. can be empty
      */
-    private Vector extentClasses = new Vector();
+    private List extentClasses = new ArrayList();
     /**
      * the list of class names in the extent of this class. can be empty
      */
@@ -242,7 +236,7 @@
     //-----------------------------------------------------------------
     //-----------------------------------------------------------------
 
-
+    
     //---------------------------------------------------------------
     /**
      * Constructor declaration
@@ -270,22 +264,6 @@
         getRepository().registerSuperClassMultipleJoinedTables(this);
     }
 
-//    /**
-//     * @deprecated no longer needed map class on multi joined table
-//     */
-//    public void setSuperPersistentFieldDescriptors(Vector superPersistentFieldDescriptors)
-//    {
-//        this.superPersistentFieldDescriptors = superPersistentFieldDescriptors;
-//    }
-//
-//    /**
-//     * @deprecated no longer needed map class on multi joined table
-//     */
-//    public Vector getSuperPersistentFieldDescriptors()
-//    {
-//        return superPersistentFieldDescriptors;
-//    }
-
     /**
      * Returns the appropriate {@link ObjectCacheDescriptor}
      * or <code>null</code> if not specified.
@@ -368,13 +346,7 @@
             Arrays.sort(m_FieldDescriptions, FieldDescriptor.getComparator());
         }
 
-        m_fieldDescriptorNameMap = null;
-        m_PkFieldDescriptors = null;
-        m_nonPkFieldDescriptors = null;
-        m_lockingFieldDescriptors = null;
-        m_RwFieldDescriptors = null;
-        m_RwNonPkFieldDescriptors = null;
-        lobFields = null;
+        resetConvenienceFields();
     }
 
     public boolean removeFieldDescriptor(FieldDescriptor fld)
@@ -386,6 +358,13 @@
         result = list.remove(fld);
         m_FieldDescriptions = (FieldDescriptor[]) list.toArray(new FieldDescriptor[list.size()]);
 
+        resetConvenienceFields();
+
+        return result;
+    }
+
+    protected void resetConvenienceFields()
+    {
         m_fieldDescriptorNameMap = null;
         m_PkFieldDescriptors = null;
         m_nonPkFieldDescriptors = null;
@@ -393,7 +372,8 @@
         m_RwFieldDescriptors = null;
         m_RwNonPkFieldDescriptors = null;
         lobFields = null;
-        return result;
+        m_autoIncrementField = null;
+        autoIncrementFields = null;
     }
 
     /**
@@ -619,7 +599,7 @@
      * Creation date: (02.02.2001 17:49:11)
      * @return java.util.Vector
      */
-    public synchronized Vector getExtentClasses()
+    public synchronized List getExtentClasses()
     {
         if (extentClassNames.size() != extentClasses.size())
         {
@@ -826,37 +806,6 @@
     {
         return getFieldDescriptorForPath(aPath, null);
     }
-/*
-arminw:
-TODO: this feature doesn't work, so remove this in future
-*/
-    /**
-     *
-     * @return this classes FieldDescriptor's as well as it's parents and so on and so on
-     */
-    public FieldDescriptor[] getFieldDescriptorsInHeirarchy()
-    {
-        if (superClass == null)
-        {
-            return getFieldDescriptions();
-        }
-        ClassDescriptor cldSuper = getRepository().getDescriptorFor(superClass);
-        return appendFieldDescriptorArrays(
-            getFieldDescriptions(),
-            cldSuper.getFieldDescriptorsInHeirarchy());
-    }
-
-    private FieldDescriptor[] appendFieldDescriptorArrays(
-        FieldDescriptor[] fieldDescriptions,
-        FieldDescriptor[] fieldDescriptorsInHeirarchy)
-    {
-        // take the 2 arrays and add them into one
-        int size = fieldDescriptions.length + fieldDescriptorsInHeirarchy.length;
-        FieldDescriptor[] newArray = new FieldDescriptor[size];
-        System.arraycopy(fieldDescriptions, 0, newArray, 0, fieldDescriptions.length);
-        System.arraycopy(fieldDescriptorsInHeirarchy, 0, newArray, fieldDescriptions.length, fieldDescriptorsInHeirarchy.length);
-        return newArray;
-    }
 
     /**
      * Returns the first found autoincrement field
@@ -893,15 +842,23 @@
         return m_autoIncrementField;
     }
 
+    /**
+     * Returns all fields declared as 'autoIncrement' fields.
+     */
     public FieldDescriptor[] getAutoIncrementFields()
     {
-        ArrayList result = new ArrayList();
-        for (int i = 0; i < m_FieldDescriptions.length; i++)
+        if(autoIncrementFields == null)
         {
-            FieldDescriptor field = m_FieldDescriptions[i];
-            if(field.isAutoIncrement()) result.add(field);
+            ArrayList result = new ArrayList();
+            FieldDescriptor[] fields = getFieldDescriptor(false);
+            for (int i = 0; i < fields.length; i++)
+            {
+                FieldDescriptor field = fields[i];
+                if(field.isAutoIncrement()) result.add(field);
+            }
+            autoIncrementFields = (FieldDescriptor[]) result.toArray(new FieldDescriptor[result.size()]);
         }
-        return (FieldDescriptor[]) result.toArray(new FieldDescriptor[result.size()]);
+        return autoIncrementFields;
     }
 
     /**
@@ -943,14 +900,7 @@
             // 1.a if descriptor describes an interface: take PK fields from an implementors ClassDescriptor
             if (!isMappedToTable())
             {
-                if (getExtentClasses().size() == 0)
-                {
-                    throw new PersistenceBrokerException(
-                        "No Implementors declared for interface "
-                            + this.getClassOfObject().getName());
-                }
-                Class implementor = (Class) getExtentClasses().get(0);
-                ClassDescriptor implCld = this.getRepository().getDescriptorFor(implementor);
+                ClassDescriptor implCld = this.getRepository().findFirstConcreteClass(this);
                 m_PkFieldDescriptors = implCld.getPkFields();
             }
             else
@@ -1237,39 +1187,6 @@
     }
 
     /**
-     * Set name of the super class.
-     */
-    public void setSuperClass(String classname)
-    {
-        this.superClass = classname;
-    }
-
-    /**
-     * Return the super class or <code>null</code>
-     * if not declared in repository file.
-     */
-    public String getSuperClass()
-    {
-        return superClass;
-    }
-
-    /**
-     * TODO drop this method?
-     */
-    public void setSuperClassFieldRef(int fieldId)
-    {
-        this.superClassFieldRef = fieldId;
-    }
-
-    /**
-     * TODO drop this method?
-     */
-    public int getSuperClassFieldRef()
-    {
-        return superClassFieldRef;
-    }
-
-    /**
      * Return true, if the described class is
      * an 'interface'. That is if the class is <b>not</b> mapped to a table.
      * @deprecated use ! isMappedToTable()
@@ -1832,8 +1749,14 @@
             /*
             arminw: only return no-PK fields, because all PK fields are declared
             in sub-class too.
+            TODO: add all fields with inherited fields, because it could be the case that
+            the field is overridden in sub-class but we have to populate the "real" field of the
+            class object not only all fields reflected by the last sub-class object.
+            Check for side-effects, e.g. if a collection-descriptor is mapped in each sub-class
+            or a collection-descriptor is overridden in a sub-class.
             */
-            FieldDescriptor[] superFlds = getSuperClassDescriptor().getFieldDescriptorNonPk(true);
+            FieldDescriptor[] superFlds = getSuperClassDescriptor().getFieldDescriptor(withInherited);
+            //FieldDescriptor[] superFlds = getSuperClassDescriptor().getFieldDescriptorNonPk(true);
             if(m_FieldDescriptions == null)
             {
                 m_FieldDescriptions = new FieldDescriptor[0];
@@ -1924,6 +1847,15 @@
         return lobFields;
     }
 
+    public Class getTopLevelClass()
+    {
+        return getRepository().getTopLevelClass(getClassOfObject());
+    }
+
+    public ClassDescriptor getTopLevelClassDescriptor()
+    {
+        return getRepository().getTopLevelDescriptor(getClassOfObject());
+    }
 
     /**
      * Return a string representation of this class.
@@ -2145,8 +2077,8 @@
             }
             result.append( eol );
 
-            // write custom attributes
-            result.append(super.toXML("      "));
+            // custom attributes
+            XmlHelper.appendSerializedAttributes(result, "        ", getAttributes());
             result.append( eol );
 
             // Write out the procedures

Modified: db/ojb/trunk/src/java/org/apache/ojb/broker/metadata/CollectionDescriptor.java
URL: http://svn.apache.org/viewvc/db/ojb/trunk/src/java/org/apache/ojb/broker/metadata/CollectionDescriptor.java?view=diff&rev=495677&r1=495676&r2=495677
==============================================================================
--- db/ojb/trunk/src/java/org/apache/ojb/broker/metadata/CollectionDescriptor.java (original)
+++ db/ojb/trunk/src/java/org/apache/ojb/broker/metadata/CollectionDescriptor.java Fri Jan 12 10:19:39 2007
@@ -38,6 +38,7 @@
 {
     private static final long serialVersionUID = -8570280662286424937L;
 
+    private IndirectionTableDescriptor indirectionTableDescriptor;
     /**
      * Represents the type of the collection, if set to null,
      * a java.util.Vector will be used.
@@ -64,6 +65,18 @@
         super(descriptor);
     }
 
+    public IndirectionTableDescriptor getIndirectionTableDescriptor()
+    {
+        if(indirectionTableDescriptor == null)
+        {
+            if(isMtoNRelation())
+            {
+                indirectionTableDescriptor = new IndirectionTableDescriptor(this);
+            }
+        }
+        return indirectionTableDescriptor;
+    }
+
     /**
      * Override method from base class to declare foreign key
      * field as inverse.
@@ -391,29 +404,32 @@
     {
         if (m_hasProxyItems == null)
         {
-            DescriptorRepository repo = getClassDescriptor().getRepository();
-            ClassDescriptor cld = getItemClassDescriptor();
-            if (cld.getProxyClass() != null)
-            {
-                m_hasProxyItems = Boolean.TRUE;
-            }
-            else
+            m_hasProxyItems = hasProxyItems(getItemClassDescriptor());
+        }
+
+        return m_hasProxyItems.booleanValue();
+    }
+
+    private static Boolean hasProxyItems(ClassDescriptor cld)
+    {
+        Boolean result = Boolean.FALSE;
+        if (cld.getProxyClass() != null)
+        {
+            result = Boolean.TRUE;
+        }
+        else if(cld.isExtent())
+        {
+            Collection extents = cld.getRepository().getAllConcreteSubclassDescriptors(cld);
+            for (Iterator it = extents.iterator(); it.hasNext(); )
             {
-                Collection extents = cld.getExtentClasses();
-                m_hasProxyItems = Boolean.FALSE;
-                for (Iterator it = extents.iterator(); it.hasNext(); )
+                ClassDescriptor ext = (ClassDescriptor) it.next();
+                if (ext.getProxyClass() != null)
                 {
-                    Class ext = (Class) it.next();
-                    ClassDescriptor cldExt = repo.getDescriptorFor(ext);
-                    if (cldExt.getProxyClass() != null)
-                    {
-                        m_hasProxyItems = Boolean.TRUE;
-                        break;
-                    }
+                    result = Boolean.TRUE;
+                    break;
                 }
             }
         }
-
-        return (m_hasProxyItems.booleanValue());
+        return result;
     }
 }

Modified: db/ojb/trunk/src/java/org/apache/ojb/broker/metadata/ConnectionDescriptorXmlHandler.java
URL: http://svn.apache.org/viewvc/db/ojb/trunk/src/java/org/apache/ojb/broker/metadata/ConnectionDescriptorXmlHandler.java?view=diff&rev=495677&r1=495676&r2=495677
==============================================================================
--- db/ojb/trunk/src/java/org/apache/ojb/broker/metadata/ConnectionDescriptorXmlHandler.java (original)
+++ db/ojb/trunk/src/java/org/apache/ojb/broker/metadata/ConnectionDescriptorXmlHandler.java Fri Jan 12 10:19:39 2007
@@ -263,7 +263,7 @@
                             String strategy = atts.getValue(RepositoryTags.getTagById(STRATEGY));
                             if(checkString(strategy))
                             {
-                                ocd.setCachingStrategy(ClassHelper.getClass(strategy));
+                                ocd.setCachingPreparer(ClassHelper.getClass(strategy));
                                 if (isDebug) logger.debug("     " + RepositoryTags.getTagById(STRATEGY) + ": " + strategy);
                             }
                             String timeout = atts.getValue(RepositoryTags.getTagById(TIMEOUT));
@@ -277,18 +277,15 @@
                     }
                 case SEQUENCE_MANAGER:
                     {
-                        if (isDebug) logger.debug("    > " + RepositoryTags.getTagById(SEQUENCE_MANAGER));
-                        if(m_CurrentJCD != null)
+                        if(this.currentAttributeContainer != null)
                         {
-                            SequenceDescriptor sd = m_CurrentJCD.getSequenceDescriptor();
-                            sd.setJdbcConnectionDescriptor(m_CurrentJCD);
-                            this.currentAttributeContainer = sd;
                             String className = atts.getValue(RepositoryTags.getTagById(CLASS_NAME));
-                            if(checkString(className))
-                            {
-                                if (isDebug) logger.debug("     " + RepositoryTags.getTagById(CLASS_NAME) + ": " + className);
-                                sd.setSequenceManagerClass(ClassHelper.getClass(className));
-                            }
+                            SequenceDescriptor currentSequenceDescriptor = new SequenceDescriptor();
+                            this.currentAttributeContainer = currentSequenceDescriptor;
+                            this.m_CurrentJCD.setSequenceDescriptor(currentSequenceDescriptor);
+                            if (isDebug) logger.debug("    > " + RepositoryTags.getTagById(SEQUENCE_MANAGER));
+                            if (isDebug) logger.debug("     " + RepositoryTags.getTagById(CLASS_NAME) + ": " + className);
+                            if (checkString(className)) currentSequenceDescriptor.setSequenceManagerClass(className);
                         }
                         break;
                     }

Modified: db/ojb/trunk/src/java/org/apache/ojb/broker/metadata/ConnectionFactoryDescriptor.java
URL: http://svn.apache.org/viewvc/db/ojb/trunk/src/java/org/apache/ojb/broker/metadata/ConnectionFactoryDescriptor.java?view=diff&rev=495677&r1=495676&r2=495677
==============================================================================
--- db/ojb/trunk/src/java/org/apache/ojb/broker/metadata/ConnectionFactoryDescriptor.java (original)
+++ db/ojb/trunk/src/java/org/apache/ojb/broker/metadata/ConnectionFactoryDescriptor.java Fri Jan 12 10:19:39 2007
@@ -22,6 +22,7 @@
 import org.apache.commons.lang.SystemUtils;
 import org.apache.commons.lang.builder.ToStringBuilder;
 import org.apache.ojb.broker.accesslayer.ConnectionFactoryPooledImpl;
+import org.apache.ojb.broker.util.XmlHelper;
 
 
 /**
@@ -31,12 +32,11 @@
  * Every new instantiated <code>ConnectionFactoryDescriptor</code> was
  * associated with default connection pool attributes.
  *
- * @author <a href="mailto:[email protected]">Armin Waibel</a>
  * @version $Id$
  */
 public class ConnectionFactoryDescriptor extends DescriptorBase implements XmlCapable
 {
-	private static final long serialVersionUID = -3071461685659671879L;
+    private static final long serialVersionUID = -3071461685659671879L;
 
     /** Configuration attribute name for JDBC fetchSize hint. */
     public static final String PROP_FETCH_SIZE = "ojb.fetchSize";
@@ -190,9 +190,10 @@
         ToStringBuilder buf = new ToStringBuilder(this);
         buf.append("connectionFactoryClass", connectionFactoryClass)
             .append("validationQuery", validationQuery)
-            .append("customAttributes", super.toString())
+            .append("poolProperties", poolProperties)
             .append("jdbcProperties", jdbcProperties)
-            .append("dbcpProperties", dbcpProperties);
+            .append("dbcpProperties", dbcpProperties)
+            .append("customAttributes", super.toString());
         return buf.toString();
 
     }
@@ -204,10 +205,11 @@
         buf.append( "      " );
         buf.append( RepositoryTags.getOpeningTagNonClosingById(CONNECTION_FACTORY) );
         buf.append( eol );
-        buf.append("         " + RepositoryTags.getAttribute(RepositoryElements.CLASS_NAME, getConnectionFactoryClass().getName()));
+        buf.append("         ").append(RepositoryTags.getAttribute(
+                RepositoryElements.CLASS_NAME, getConnectionFactoryClass().getName()));
         buf.append( eol );
-        buf.append("         " + RepositoryTags.getAttribute(RepositoryElements.VALIDATION_QUERY,
-                 (getValidationQuery()!=null ? getValidationQuery() : "")) + eol);
+        buf.append("         ").append(RepositoryTags.getAttribute(RepositoryElements.VALIDATION_QUERY,
+                (getValidationQuery() != null ? getValidationQuery() : ""))).append(eol);
         buf.append( "      >" );
         buf.append( eol );
         buf.append( "         <!-- " );
@@ -218,7 +220,7 @@
         buf.append( eol );
         buf.append( "         -->" );
         buf.append( eol );
-        buf.append( super.toXML("         ") );
+        XmlHelper.appendSerializedAttributes(buf, "         ", getAttributes());
         buf.append( "      " );
         buf.append( RepositoryTags.getClosingTagById(CONNECTION_FACTORY));
         buf.append( eol );

Modified: db/ojb/trunk/src/java/org/apache/ojb/broker/metadata/DeleteProcedureDescriptor.java
URL: http://svn.apache.org/viewvc/db/ojb/trunk/src/java/org/apache/ojb/broker/metadata/DeleteProcedureDescriptor.java?view=diff&rev=495677&r1=495676&r2=495677
==============================================================================
--- db/ojb/trunk/src/java/org/apache/ojb/broker/metadata/DeleteProcedureDescriptor.java (original)
+++ db/ojb/trunk/src/java/org/apache/ojb/broker/metadata/DeleteProcedureDescriptor.java Fri Jan 12 10:19:39 2007
@@ -107,11 +107,6 @@
         result.append( RepositoryTags.getOpeningTagNonClosingById( DELETE_PROCEDURE ) );
         result.append( " " );
         result.append( RepositoryTags.getAttribute( NAME, this.getName() ) );
-        if( this.hasReturnValue() )
-        {
-            result.append( " " );
-            result.append( RepositoryTags.getAttribute( RETURN_FIELD_REF, this.getReturnValueFieldRefName() ) );
-        }
         result.append( " " );
         result.append( RepositoryTags.getAttribute( INCLUDE_PK_FIELDS_ONLY, String.valueOf( this.getIncludePkFieldsOnly() ) ) );
         result.append( ">" );
@@ -142,13 +137,9 @@
      */
     public String toString()
     {
-        ToStringBuilder buf = new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE);
-        buf.append("name", this.getName());
+        ToStringBuilder buf = new ToStringBuilder(this);
         buf.append("includePkFieldsOnly", this.getIncludePkFieldsOnly());
-        if (this.hasReturnValue())
-        {
-            buf.append("returnFieldRefName", this.getReturnValueFieldRefName());
-        }
+        buf.append(super.toString());
         return buf.toString();
     }
 }

Modified: db/ojb/trunk/src/java/org/apache/ojb/broker/metadata/DescriptorBase.java
URL: http://svn.apache.org/viewvc/db/ojb/trunk/src/java/org/apache/ojb/broker/metadata/DescriptorBase.java?view=diff&rev=495677&r1=495676&r2=495677
==============================================================================
--- db/ojb/trunk/src/java/org/apache/ojb/broker/metadata/DescriptorBase.java (original)
+++ db/ojb/trunk/src/java/org/apache/ojb/broker/metadata/DescriptorBase.java Fri Jan 12 10:19:39 2007
@@ -19,51 +19,29 @@
 import java.util.HashSet;
 import java.util.Properties;
 import java.util.Set;
-import java.util.Iterator;
-import java.util.Map;
 
-import org.apache.commons.lang.SystemUtils;
+import org.apache.ojb.broker.util.logging.LoggerFactory;
 
 /**
- * base class for all Descriptors. It is used to implement the AttributeContainer
+ * Base class for mapping descriptor classes. It is used to implement the {@link AttributeContainer}
  * interface which provides mechanics for user defined attributes.
- * @author Thomas Mahler
+ *
+ * @version $Id: $
  */
-class DescriptorBase implements AttributeContainer, Serializable
+abstract public class DescriptorBase implements AttributeContainer, Serializable
 {
-	static final long serialVersionUID = 713914612744155925L;
-    /** holds user defined attributes */
-    private Properties attributes = new Properties();
-
+    static final long serialVersionUID = 713914612744155925L;
     /**
-     * Constructor for DescriptorBase.
+     * holds user defined attributes
      */
-    public DescriptorBase()
-    {
-    }
-
-    public Properties getAttributes()
-    {
-        return attributes;
-    }
-
-    public void addAttributes(Map attributes)
-    {
-        this.attributes.putAll(attributes);
-    }
+    private Properties attributes;
 
     /**
-     * Returns an array of the names of all atributes of this descriptor.
-     * 
-     * @return The list of attribute names (will not be <code>null</code>)
+     * Constructor for DescriptorBase.
      */
-    public String[] getAttributeNames()
+    public DescriptorBase()
     {
-        Set      keys   = (attributes == null ? new HashSet() : attributes.keySet());
-        String[] result = new String[keys.size()];
-
-        keys.toArray(result);
-        return result;
+        attributes = new Properties();
     }
 
     /**
@@ -72,8 +50,12 @@
     public void addAttribute(String attributeName, String attributeValue)
     {
         // Don't allow null attribute names.
-        if (attributeName == null)
+        if(attributeName == null || attributeValue == null)
         {
+            LoggerFactory.getDefaultLogger().error(
+                    "[" + this.getClass().getName()
+                            + "] Illegal Attribute add - value or key is null: key="
+                            + attributeName + " value=" + attributeValue);
             return;
         }
         // Add the entry.
@@ -85,10 +67,10 @@
      */
     public String getAttribute(String attributeName, String defaultValue)
     {
-        String result = defaultValue;
-        if (attributes != null)
+        String result = attributes.getProperty(attributeName);
+        if(result == null)
         {
-            result = attributes.getProperty(attributeName, defaultValue);
+            result = defaultValue;
         }
         return result;
     }
@@ -101,27 +83,46 @@
         return this.getAttribute(attributeName, null);
     }
 
-    public String toXML(String space)
+    /**
+     * Return the custom/configuration properties.
+     *
+     * @return The current properties.
+     */
+    public Properties getAttributes()
+    {
+        return attributes;
+    }
+
+    /**
+     * Set the custom/configuration properties.
+     *
+     * @param properties Set the properties, <em>null</em> will be ignored.
+     */
+    public void setAttributes(Properties properties)
     {
-        String eol = SystemUtils.LINE_SEPARATOR;
-        Properties prop = getAttributes();
-        if(prop == null || prop.isEmpty()) return "";
-
-        StringBuffer buf = new StringBuffer(512);
-        Iterator it = prop.entrySet().iterator();
-        while(it.hasNext())
+        if(properties != null)
         {
-            Map.Entry entry = (Map.Entry) it.next();
-            String key = (String) entry.getKey();
-            String value = (String) entry.getValue();
-            buf.append(space + "<attribute attribute-name=\"");
-            buf.append(key);
-            buf.append("\" attribute-value=\"");
-            buf.append(value);
-            buf.append("\"/>");
-            buf.append(eol);
+            this.attributes = properties;
         }
-        return buf.toString();
+    }
+
+    public void addAttributes(Properties attributes)
+    {
+        if(attributes != null) this.attributes.putAll(attributes);
+    }
+
+    /**
+     * Returns an array of the names of all atributes of this descriptor.
+     *
+     * @return The list of attribute names (will not be <code>null</code>)
+     */
+    public String[] getAttributeNames()
+    {
+        Set keys = (attributes == null ? new HashSet() : attributes.keySet());
+        String[] result = new String[keys.size()];
+
+        keys.toArray(result);
+        return result;
     }
 
     public String toString()

Modified: db/ojb/trunk/src/java/org/apache/ojb/broker/metadata/DescriptorRepository.java
URL: http://svn.apache.org/viewvc/db/ojb/trunk/src/java/org/apache/ojb/broker/metadata/DescriptorRepository.java?view=diff&rev=495677&r1=495676&r2=495677
==============================================================================
--- db/ojb/trunk/src/java/org/apache/ojb/broker/metadata/DescriptorRepository.java (original)
+++ db/ojb/trunk/src/java/org/apache/ojb/broker/metadata/DescriptorRepository.java Fri Jan 12 10:19:39 2007
@@ -19,12 +19,11 @@
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.HashMap;
+import java.util.HashSet;
 import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
-import java.util.Vector;
 import java.util.Set;
-import java.util.HashSet;
 
 import org.apache.commons.collections.set.ListOrderedSet;
 import org.apache.commons.lang.SystemUtils;
@@ -33,8 +32,8 @@
 import org.apache.ojb.broker.OJBRuntimeException;
 import org.apache.ojb.broker.locking.IsolationLevels;
 import org.apache.ojb.broker.util.ClassHelper;
-import org.apache.ojb.broker.util.logging.LoggerFactory;
 import org.apache.ojb.broker.util.logging.Logger;
+import org.apache.ojb.broker.util.logging.LoggerFactory;
 
 /**
  * The repository containing all object mapping and manipulation information of
@@ -43,8 +42,6 @@
  * Note: Be careful when use references of this class or caching instances of this class,
  * because instances could become invalid (see {@link MetadataManager}).
  *
- * @author <a href="mailto:[email protected]">Thomas Mahler<a>
- * @author <a href="mailto:[email protected]">Leandro Rodrigo Saad Cruz<a>
  * @version $Id$
  */
 public final class DescriptorRepository extends DescriptorBase
@@ -134,11 +131,7 @@
                 m_topLevelClassTable.remove(extClass);
                 // clear map with first concrete classes, because the removed
                 // extent could be such a first found concrete class
-                if (m_firstConcreteClassMap != null)
-                {
-                    m_firstConcreteClassMap.clear();
-                    m_firstConcreteClassMap = null;
-                }
+                m_firstConcreteClassMap = null;
             }
         }
     }
@@ -170,6 +163,7 @@
                     // walk the super-references
                     cld = getDescriptorFor(clazz).getSuperClassDescriptor();
                 }
+
                 if (cld != null)
                 {
                     // fix by Mark Rowell
@@ -197,6 +191,20 @@
     }
 
     /**
+     * Returns the top level (extent) {@link ClassDescriptor} to which the given class belongs.
+     * This may be a (abstract) base-class, an interface or the given class
+     * itself if given class is not defined as an extent in other class
+     * descriptors.
+     *
+     * @throws ClassNotPersistenceCapableException if clazz is not persistence capable,
+     * i.e. if clazz is not defined in the DescriptorRepository.
+     */
+    public ClassDescriptor getTopLevelDescriptor(Class clazz) throws ClassNotPersistenceCapableException
+    {
+        return getDescriptorFor(getTopLevelClass(clazz));
+    }
+
+    /**
      * @return all field descriptors for a class that belongs to a set of classes mapped
      * to the same table, otherwise the select queries produced won't contain the necessary
      * information to materialize extents mapped to the same class.
@@ -210,7 +218,7 @@
         FieldDescriptor[] retval = (FieldDescriptor[]) m_multiMappedTableMap.get(targetCld.getClassNameOfObject());
         if (retval == null)
         {
-            synchronized (m_multiMappedTableMap)
+            synchronized (this)
             {
                 retval = getAllMappedColumns(getClassesMappedToSameTable(targetCld));
                 m_multiMappedTableMap.put(targetCld.getClassNameOfObject(), retval);
@@ -227,15 +235,14 @@
              "If you do not use the SELECT-list order to access data,
               then you can lose the stream data."
          */
-        List allFieldDescriptors = new Vector();
+        List allFieldDescriptors = new ArrayList();
 
         Set visitedColumns = new HashSet();
-        Iterator it = classDescriptors.iterator();
         ClassDescriptor temp;
         FieldDescriptor[] fields;
-        while (it.hasNext())
+        for (int k = 0; k < classDescriptors.size(); k++)
         {
-            temp = (ClassDescriptor) it.next();
+            temp = (ClassDescriptor) classDescriptors.get(k);
             fields = temp.getFieldDescriptions();
             if (fields != null)
             {
@@ -275,7 +282,11 @@
         */
         Iterator iter = ((HashMap)descriptorTable.clone()).values().iterator();
         List retval = new ArrayList();
-        // make sure that target class is at first position
+        /*
+        make sure that target class is at first position
+        this is mandatory, because only this way we can guarantee to extract
+        the correct field-descriptor in method #getAllMappedColumns
+        */
         retval.add(targetCld);
         while (iter.hasNext())
         {
@@ -341,10 +352,10 @@
     }
 
     /**
-     * Utility method to discover all concrete subclasses of a given super class.
-     * This method was introduced in order to get Extent Aware Iterators.
+     * Utility method to discover all concrete sub-classes {@link ClassDescriptor}
+     * of a given super class.
      *
-     * @return a Collection of ClassDescriptor objects
+     * @return a collection of ClassDescriptor objects
      */
     public Collection getAllConcreteSubclassDescriptors(ClassDescriptor aCld)
     {
@@ -627,7 +638,7 @@
         Iterator i = this.iterator();
         while (i.hasNext())
         {
-            buf.append(((XmlCapable) i.next()).toXML() + eol);
+            buf.append(((XmlCapable) i.next()).toXML()).append(eol);
         }
         return buf.toString();
     }

Modified: db/ojb/trunk/src/java/org/apache/ojb/broker/metadata/FieldDescriptor.java
URL: http://svn.apache.org/viewvc/db/ojb/trunk/src/java/org/apache/ojb/broker/metadata/FieldDescriptor.java?view=diff&rev=495677&r1=495676&r2=495677
==============================================================================
--- db/ojb/trunk/src/java/org/apache/ojb/broker/metadata/FieldDescriptor.java (original)
+++ db/ojb/trunk/src/java/org/apache/ojb/broker/metadata/FieldDescriptor.java Fri Jan 12 10:19:39 2007
@@ -34,6 +34,7 @@
 import org.apache.ojb.broker.accesslayer.ResultSetAndStatement;
 import org.apache.ojb.broker.metadata.fieldaccess.AnonymousPersistentField;
 import org.apache.ojb.broker.util.ClassHelper;
+import org.apache.ojb.broker.util.XmlHelper;
 
 /**
  * A FieldDescriptor holds the mapping information for a specific member-variable
@@ -42,12 +43,11 @@
  * Note: Be careful when use references of this class or caching instances of this class,
  * because instances could become invalid (see {@link MetadataManager}).
  *
- * @author <a href="mailto:[email protected]">Thomas Mahler<a>
  * @version $Id$
  */
 public class FieldDescriptor extends AttributeDescriptorBase implements XmlCapable, Serializable
 {
-	private static final long serialVersionUID = 7865777758296851949L;
+	private static final long serialVersionUID = 8231802073685958561L;
 
     public static final String ACCESS_ANONYMOUS = RepositoryElements.TAG_ACCESS_ANONYMOUS;
     public static final String ACCESS_READONLY = RepositoryElements.TAG_ACCESS_READONLY;
@@ -57,6 +57,7 @@
 
     private int m_ColNo;
     private String m_ColumnName;
+    private String m_FullColumnName;
     private String m_ColumnType;
     private boolean m_IsKeyField = false;
     private boolean indexed = false;
@@ -81,6 +82,7 @@
     // dbms to update all lock columns eg using triggers
     private boolean updateLock = true;
     private String m_access;
+    private SequenceDescriptor sequenceDescriptor;
 
     /**
      * returns a comparator that allows to sort a Vector of FieldMappingDecriptors
@@ -122,6 +124,12 @@
         m_ColNo = id;
     }
 
+    public void setClassDescriptor(ClassDescriptor classDescriptor)
+    {
+        super.setClassDescriptor(classDescriptor);
+        m_FullColumnName = null;
+    }
+
     /**
      * Return the name of the mapped database column.
      *
@@ -142,7 +150,11 @@
      */
     public String getFullColumnName()
     {
-        return getClassDescriptor().getFullTableName() + "." + getColumnName();
+        if(m_FullColumnName == null)
+        {
+            m_FullColumnName = getClassDescriptor().getFullTableName() + "." + getColumnName();
+        }
+        return m_FullColumnName;
     }
 
     public void setColumnName(String str)
@@ -266,8 +278,8 @@
         buf.append("isAutoincrement", m_autoIncrement);
         buf.append("access", m_access);
         buf.append("sequenceName", m_sequenceName);
-        buf.append("nullCheck", nullCheck.toString());
         buf.append("jdbcType", m_jdbcType);
+        buf.append("null-check", nullCheck);
         buf.append("super_class_fields ", "=> " + super.toString());
         buf.append(SystemUtils.LINE_SEPARATOR);
         return buf.toString();
@@ -332,7 +344,7 @@
         // if no explicit class is specified use the default implementation
         if (nullCheck == null)
         {
-        	nullCheck = new NullCheckDefaultImpl();
+            nullCheck = new NullCheckDefaultImpl();
         }
         return nullCheck;
     }
@@ -564,17 +576,17 @@
      * Reads in the value of the field/column represented by this <code>FieldDescriptor</code>.
      *
      * @param rs_stmt The current used {@link org.apache.ojb.broker.accesslayer.ResultSetAndStatement} instance.
-     * @param convert If set <em>true</em> a
+     * @param convertToJava If set <em>true</em> a
      * {@link org.apache.ojb.broker.accesslayer.conversions.FieldConversion#sqlToJava(Object)} conversion call
      * is done.
      * @return The read in value of this field.
      * @throws SQLException
      */
-    public Object readValue(final ResultSetAndStatement rs_stmt, boolean convert)
+    public Object readValue(final ResultSetAndStatement rs_stmt, boolean convertToJava)
             throws SQLException
     {
         int idx = rs_stmt.m_sql.getColumnIndex(this);
-        return readValue(rs_stmt, idx, convert);
+        return readValue(rs_stmt, idx, convertToJava);
     }
 
     /**
@@ -582,18 +594,18 @@
      *
      * @param rs_stmt The current used {@link org.apache.ojb.broker.accesslayer.ResultSetAndStatement} instance.
      * @param index The result set column index.
-     * @param convert If set <em>true</em> a
+     * @param convertToJava If set <em>true</em> a
      * {@link org.apache.ojb.broker.accesslayer.conversions.FieldConversion#sqlToJava(Object)} conversion call
      * is done.
      * @return The read in value of this field.
      * @throws SQLException
      */
-    public Object readValue(final ResultSetAndStatement rs_stmt, int index, boolean convert)
+    public Object readValue(final ResultSetAndStatement rs_stmt, int index, boolean convertToJava)
             throws SQLException
     {
         Object val = getJdbcType().getObjectFromColumn(rs_stmt.m_rs, null, getColumnName(), index);
         val = rs_stmt.m_platform.postPrepareReadInValue(this, val);
-        if(convert) val = getFieldConversion().sqlToJava(val);
+        if(convertToJava) val = getFieldConversion().sqlToJava(val);
         if(isLobFieldType())
         {
             val = rs_stmt.m_broker.serviceLobHelper().wrapLobField(this, val);
@@ -625,6 +637,46 @@
         }
         return val;
     }
+    
+    /**
+     * Return a sql-type based copy of the value represented by this
+     * field. The value was transformed to the sql-type using
+     * {@link org.apache.ojb.broker.accesslayer.conversions.FieldConversion#javaToSql(Object)}
+     * and the copy is based on {@link FieldType#copy(Object)}).
+     *
+     * @param source The source object (normally the whole POJO)
+     * @return A sql-type based copy the value represented by this field.
+     */
+    public Object getCopyOfValue(final Object source)
+    {
+        // get the value
+        Object value = getPersistentField().get(source);
+        // convert value to a supported sql type, because we only
+        // can copy this type
+        value = getFieldConversion().javaToSql(value);
+        // copy the sql type
+        value = getJdbcType().getFieldType().copy(value);
+        return value;
+    }
+
+    /**
+     * Get the associated {@link SequenceDescriptor} or <em>null</em>
+     * if not specified.
+     */
+    public SequenceDescriptor getSequenceDescriptor()
+    {
+        return sequenceDescriptor;
+    }
+
+    /**
+     * Set the associated {@link SequenceDescriptor}, if not set the
+     * {@link org.apache.ojb.broker.util.sequence.SequenceManager} specified
+     * in {@link JdbcConnectionDescriptor} is used.
+     */
+    public void setSequenceDescriptor(SequenceDescriptor sequenceDescriptor)
+    {
+        this.sequenceDescriptor = sequenceDescriptor;
+    }
 
     /*
      * @see XmlCapable#toXML()
@@ -746,7 +798,7 @@
         result.append( "      />" );
         result.append( eol );
         // custom attributes
-        result.append(super.toXML("        "));
+        XmlHelper.appendSerializedAttributes(result, "        ", getAttributes());
         result.append( eol );
         return result.toString();
     }

Modified: db/ojb/trunk/src/java/org/apache/ojb/broker/metadata/FieldType.java
URL: http://svn.apache.org/viewvc/db/ojb/trunk/src/java/org/apache/ojb/broker/metadata/FieldType.java?view=diff&rev=495677&r1=495676&r2=495677
==============================================================================
--- db/ojb/trunk/src/java/org/apache/ojb/broker/metadata/FieldType.java (original)
+++ db/ojb/trunk/src/java/org/apache/ojb/broker/metadata/FieldType.java Fri Jan 12 10:19:39 2007
@@ -25,6 +25,9 @@
  * <p/>
  * We differ two types of fields, <em>immutable</em> (like Integer, Long, String, ...) and <em>mutable</em>
  * (like Date, byte[], most SQL3 datatypes, ...).
+ * <p/>
+ * Take care of correct implementation of {@link #hashCode()} and {@link #equals(Object)}. All <em>FieldType</em>
+ * of the same class must be equals.
  *
  * @version $Id$
  */

Modified: db/ojb/trunk/src/java/org/apache/ojb/broker/metadata/FieldTypes.java
URL: http://svn.apache.org/viewvc/db/ojb/trunk/src/java/org/apache/ojb/broker/metadata/FieldTypes.java?view=diff&rev=495677&r1=495676&r2=495677
==============================================================================
--- db/ojb/trunk/src/java/org/apache/ojb/broker/metadata/FieldTypes.java (original)
+++ db/ojb/trunk/src/java/org/apache/ojb/broker/metadata/FieldTypes.java Fri Jan 12 10:19:39 2007
@@ -47,12 +47,29 @@
     abstract static class BaseFieldType implements FieldType
     {
         /**
+         * The hash code is the hash code of the class.
+         */
+        public int hashCode()
+        {
+            return getClass().hashCode();
+        }
+
+        /**
+         * Returns <em>true</em> if both classes are equals.
+         */
+        public boolean equals(Object obj)
+        {
+            if(this == obj) return true;
+            return obj != null && getClass().equals(obj.getClass());
+        }
+
+        /**
          * Helper method to copy an object if possible.
          *
          * @param toCopy The object to copy.
          * @return The copy of the object or <em>null</em> clone is not supported.
          */
-        private Object copyIfCloneable(Object toCopy)
+        private Object copyIfCloneable(final Object toCopy)
         {
             Object result = null;
             if(toCopy instanceof Cloneable)
@@ -83,7 +100,7 @@
          * @param toCopy The object to copy.
          * @return The copy of the object or <em>null</em> if serialization is not supported.
          */
-        private Object copyIfSerializeable(Object toCopy)
+        private Object copyIfSerializeable(final Object toCopy)
         {
             Object result = null;
             if(toCopy instanceof Serializable)
@@ -101,7 +118,7 @@
          * @param toCopy The object to copy.
          * @return The copy result.
          */
-        Object copyIfPossible(Object toCopy)
+        Object copyIfPossible(final Object toCopy)
         {
             Object copy = copyIfCloneable(toCopy);
             if(copy == null)
@@ -131,12 +148,12 @@
             return false;
         }
 
-        public Object copy(Object source)
+        public Object copy(final Object source)
         {
             return source;
         }
 
-        public boolean equals(Object firstValue, Object secondValue)
+        public boolean equals(final Object firstValue, final Object secondValue)
         {
             return ObjectUtils.equals(firstValue, secondValue);
         }
@@ -150,13 +167,21 @@
             return true;
         }
 
-        public boolean equals(Object firstValue, Object secondValue)
+        public boolean equals(final Object firstValue, final Object secondValue)
         {
             return ObjectUtils.equals(firstValue, secondValue);
         }
     }
 
     /**
+     * Special case of field - the 'null' field.
+     */
+    static class NullFieldType extends ImmutableFieldType
+    {
+
+    }
+
+    /**
      * Base class for LOB fields implemented as mutable field.
      */
     static class LobFieldType extends MutableFieldType
@@ -173,7 +198,7 @@
          * @param fieldValue The value to copy.
          * @return A decoupled locator instance.
          */
-        public Object copy(Object fieldValue)
+        public Object copy(final Object fieldValue)
         {
             if(fieldValue != null)
             {
@@ -195,7 +220,7 @@
          * @param secondValue Second value to compare.
          * @return The comparision state of both fields.
          */
-        public boolean equals(Object firstValue, Object secondValue)
+        public boolean equals(final Object firstValue, final Object secondValue)
         {
             LobHandle first = (LobHandle) firstValue;
             LobHandle second = (LobHandle) secondValue;
@@ -279,7 +304,7 @@
     public static class StructFieldType extends MutableFieldType
     {
         // TODO: does this make sense?? or Struct instances always Locator objects?
-        public Object copy(Object fieldValue)
+        public Object copy(final Object fieldValue)
         {
             if(fieldValue == null) return null;
 
@@ -295,7 +320,7 @@
      */
     public static class JavaObjectFieldType extends MutableFieldType
     {
-        public Object copy(Object fieldValue)
+        public Object copy(final Object fieldValue)
         {
             if(fieldValue == null) return null;
 
@@ -306,20 +331,20 @@
 
     public static class ByteArrayFieldType extends MutableFieldType
     {
-        public Object copy(Object fieldValue)
+        public Object copy(final Object fieldValue)
         {
             byte[] result = null;
             if(fieldValue != null)
             {
-                byte[] source = (byte[]) fieldValue;
+                final byte[] source = (byte[]) fieldValue;
                 int length = source.length;
                 result = new byte[length];
-                System.arraycopy(fieldValue, 0, result, 0, length);
+                System.arraycopy(source, 0, result, 0, length);
             }
             return result;
         }
 
-        public boolean equals(Object firstValue, Object secondValue)
+        public boolean equals(final Object firstValue, final Object secondValue)
         {
             return Arrays.equals((byte[]) firstValue, (byte[]) secondValue);
         }
@@ -327,7 +352,7 @@
 
     public static class DateFieldType extends MutableFieldType
     {
-        public Object copy(Object fieldValue)
+        public Object copy(final Object fieldValue)
         {
             Date source = (Date) fieldValue;
             return source != null ? new Date(source.getTime()) : null;
@@ -336,7 +361,7 @@
 
     public static class TimeFieldType extends MutableFieldType
     {
-        public Object copy(Object fieldValue)
+        public Object copy(final Object fieldValue)
         {
             Time source = (Time) fieldValue;
             return source != null ? new Time(source.getTime()) : null;
@@ -345,7 +370,7 @@
 
     public static class TimestampFieldType extends MutableFieldType
     {
-        public Object copy(Object fieldValue)
+        public Object copy(final Object fieldValue)
         {
             Timestamp result = null;
             if(fieldValue != null)
@@ -359,7 +384,7 @@
 
     public static class URLFieldType extends MutableFieldType
     {
-        public Object copy(Object fieldValue)
+        public Object copy(final Object fieldValue)
         {
             URL url = (URL) fieldValue;
             try

Modified: db/ojb/trunk/src/java/org/apache/ojb/broker/metadata/IndexDescriptor.java
URL: http://svn.apache.org/viewvc/db/ojb/trunk/src/java/org/apache/ojb/broker/metadata/IndexDescriptor.java?view=diff&rev=495677&r1=495676&r2=495677
==============================================================================
--- db/ojb/trunk/src/java/org/apache/ojb/broker/metadata/IndexDescriptor.java (original)
+++ db/ojb/trunk/src/java/org/apache/ojb/broker/metadata/IndexDescriptor.java Fri Jan 12 10:19:39 2007
@@ -15,17 +15,17 @@
  * limitations under the License.
  */
 
-import org.apache.commons.lang.SystemUtils;
-
 import java.util.Vector;
-import java.io.Serializable;
+
+import org.apache.commons.lang.SystemUtils;
+import org.apache.ojb.broker.util.XmlHelper;
 
 /**
  *
  *
  * @version $Id$
  */
-public class IndexDescriptor implements XmlCapable, Serializable
+public class IndexDescriptor extends DescriptorBase implements XmlCapable
 {
 	private static final long serialVersionUID = -1722513568634970108L;
     private String name;
@@ -98,6 +98,16 @@
 
         // closing tag
         result.append( "      " );
+        result.append( "         <!-- " );
+        result.append( eol );
+        result.append( "         Add custom index properties here, using custom attributes" );
+        result.append( eol );
+        result.append( "         e.g. <attribute attribute-name=\"myKey\" attribute-value=\"myValue\"/>" );
+        result.append( eol );
+        result.append( "         -->" );
+        result.append( eol );
+        XmlHelper.appendSerializedAttributes(result, "         ", getAttributes());
+        result.append( " " );
         result.append( RepositoryTags.getClosingTagById( INDEX_DESCRIPTOR ) );
         result.append( " " );
         result.append( eol );

Modified: db/ojb/trunk/src/java/org/apache/ojb/broker/metadata/InsertProcedureDescriptor.java
URL: http://svn.apache.org/viewvc/db/ojb/trunk/src/java/org/apache/ojb/broker/metadata/InsertProcedureDescriptor.java?view=diff&rev=495677&r1=495676&r2=495677
==============================================================================
--- db/ojb/trunk/src/java/org/apache/ojb/broker/metadata/InsertProcedureDescriptor.java (original)
+++ db/ojb/trunk/src/java/org/apache/ojb/broker/metadata/InsertProcedureDescriptor.java Fri Jan 12 10:19:39 2007
@@ -105,11 +105,6 @@
         result.append( RepositoryTags.getOpeningTagNonClosingById( INSERT_PROCEDURE ) );
         result.append( " " );
         result.append( RepositoryTags.getAttribute( NAME, this.getName() ) );
-        if( this.hasReturnValue() )
-        {
-            result.append( " " );
-            result.append( RepositoryTags.getAttribute( RETURN_FIELD_REF, this.getReturnValueFieldRefName() ) );
-        }
         result.append( " " );
         result.append( RepositoryTags.getAttribute( INCLUDE_ALL_FIELDS, String.valueOf( this.getIncludeAllFields() ) ) );
         result.append( ">" );
@@ -140,13 +135,9 @@
      */
     public String toString()
     {
-        ToStringBuilder buf = new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE);
-        buf.append("name", this.getName());
+        ToStringBuilder buf = new ToStringBuilder(this);
         buf.append("includeAllFields", this.getIncludeAllFields());
-        if (this.hasReturnValue())
-        {
-            buf.append("returnFieldRefName", this.getReturnValueFieldRefName());
-        }
+        buf.append(super.toString());
         return buf.toString();
     }
 }

Modified: db/ojb/trunk/src/java/org/apache/ojb/broker/metadata/JdbcConnectionDescriptor.java
URL: http://svn.apache.org/viewvc/db/ojb/trunk/src/java/org/apache/ojb/broker/metadata/JdbcConnectionDescriptor.java?view=diff&rev=495677&r1=495676&r2=495677
==============================================================================
--- db/ojb/trunk/src/java/org/apache/ojb/broker/metadata/JdbcConnectionDescriptor.java (original)
+++ db/ojb/trunk/src/java/org/apache/ojb/broker/metadata/JdbcConnectionDescriptor.java Fri Jan 12 10:19:39 2007
@@ -27,17 +27,17 @@
 import org.apache.ojb.broker.platforms.PlatformFactory;
 import org.apache.ojb.broker.util.logging.Logger;
 import org.apache.ojb.broker.util.logging.LoggerFactory;
+import org.apache.ojb.broker.util.XmlHelper;
 
 /**
  * JdbcConnectionDescriptor describes all relevant parameters of
  * JDBC Connections used by the PersistenceBroker
  *
- * @author <a href="mailto:[email protected]">Thomas Mahler<a>
  * @version $Id$
  */
 public class JdbcConnectionDescriptor extends DescriptorBase implements Serializable, XmlCapable
 {
-	private static final long serialVersionUID = -600900924512028960L;
+    private static final long serialVersionUID = -600900924512028960L;
     private Logger logger = LoggerFactory.getLogger(JdbcConnectionDescriptor.class);
 
     public static final int AUTO_COMMIT_IGNORE_STATE = 0;
@@ -63,9 +63,9 @@
     private SequenceDescriptor sequenceDescriptor;
     private ObjectCacheDescriptor objectCacheDescriptor;
     private BatchDescriptor batchDescriptor;
-    private transient DataSource dataSource;
 
-    private transient PlatformFactory platformFactory;
+    private transient DataSource dataSource;
+    private transient Platform platform;
 
     /**
      * Constructor declaration
@@ -73,7 +73,7 @@
     public JdbcConnectionDescriptor()
     {
         cpd = new ConnectionFactoryDescriptor();
-        sequenceDescriptor = new SequenceDescriptor(this);
+        sequenceDescriptor = new SequenceDescriptor();
         objectCacheDescriptor = new ObjectCacheDescriptor(this);
         batchDescriptor = new BatchDescriptor();
     }
@@ -112,7 +112,7 @@
      */
     public DataSource getDataSource()
     {
-        return dataSource;        
+        return dataSource;
     }
 
     /**
@@ -410,22 +410,22 @@
 
     public boolean getBatchMode()
     {
-    	return m_batchMode;
+        return m_batchMode;
     }
 
     public void setBatchMode(boolean flag)
     {
-    	m_batchMode = flag;
+        m_batchMode = flag;
     }
 
     public Platform getPlatform()
     {
         // no need to synchronize, dosen't matter if we use different instances
-        if(platformFactory == null)
+        if(platform == null)
         {
-            platformFactory = new PlatformFactory();
+            platform = PlatformFactory.getPlatformFor(this);
         }
-        return platformFactory.getPlatformFor(this);
+        return platform;
     }
 
     /**
@@ -559,6 +559,17 @@
         }
         strReturn.append( eol );
         strReturn.append( "  " );
+        strReturn.append("         <!-- ");
+        strReturn.append(eol);
+        strReturn.append("         Add custom connection properties here.");
+        strReturn.append(eol);
+        strReturn.append("         e.g. <attribute attribute-name=\"myKey\" attribute-value=\"myValue\"/>");
+        strReturn.append(eol);
+        strReturn.append("         -->");
+        strReturn.append(eol);
+        XmlHelper.appendSerializedAttributes(strReturn, "         ", getAttributes());
+        strReturn.append( eol );
+        strReturn.append( eol );
         strReturn.append( RepositoryTags.getClosingTagById( JDBC_CONNECTION_DESCRIPTOR ) );
         strReturn.append( eol );
         return strReturn.toString();

Modified: db/ojb/trunk/src/java/org/apache/ojb/broker/metadata/JdbcType.java
URL: http://svn.apache.org/viewvc/db/ojb/trunk/src/java/org/apache/ojb/broker/metadata/JdbcType.java?view=diff&rev=495677&r1=495676&r2=495677
==============================================================================
--- db/ojb/trunk/src/java/org/apache/ojb/broker/metadata/JdbcType.java (original)
+++ db/ojb/trunk/src/java/org/apache/ojb/broker/metadata/JdbcType.java Fri Jan 12 10:19:39 2007
@@ -25,6 +25,9 @@
 /**
  * Represents a jdbc sql type object defined by the JDBC 3.0 specification to handle
  * data conversion (see JDBC 3.0 specification <em>Appendix B, Data Type Conversion Tables</em>).
+ * <p/>
+ * Take care of correct implementation of {@link #hashCode()} and {@link #equals(Object)}. All <em>JdbcType</em>
+ * of the same class (with same {@link FieldType}) must be equals.
  *
  * @see FieldType
  * @version $Id$

Modified: db/ojb/trunk/src/java/org/apache/ojb/broker/metadata/JdbcTypes.java
URL: http://svn.apache.org/viewvc/db/ojb/trunk/src/java/org/apache/ojb/broker/metadata/JdbcTypes.java?view=diff&rev=495677&r1=495676&r2=495677
==============================================================================
--- db/ojb/trunk/src/java/org/apache/ojb/broker/metadata/JdbcTypes.java (original)
+++ db/ojb/trunk/src/java/org/apache/ojb/broker/metadata/JdbcTypes.java Fri Jan 12 10:19:39 2007
@@ -57,14 +57,40 @@
 
         protected BaseType()
         {
-            fieldType = lookupFieldType();
+            fieldType = createFieldType();
+        }
+
+        public boolean equals(Object obj)
+        {
+            if(this == obj) return true;
+            boolean result = false;
+            if(obj instanceof JdbcType)
+            {
+                JdbcType other = (JdbcType) obj;
+                result = this.getType() == other.getType() && this.getFieldType().equals(other.getFieldType());
+            }
+            return result;
+        }
+
+        public int hashCode()
+        {
+            return getType();
+        }
+
+        public String toString()
+        {
+            return new ToStringBuilder(this)
+                    .append("jdbcType", getType())
+                    .append("jdbcTypeString", JdbcTypesHelper.getSqlTypeAsString(getType()))
+                    .append("associatedFieldType", getFieldType())
+                    .toString();
         }
 
         /**
          * This method is responsible to associate the {@link FieldType}
          * of this {@link JdbcType}.
          */
-        FieldType lookupFieldType()
+        FieldType createFieldType()
         {
             return JdbcTypesHelper.newFieldType(this);
         }
@@ -104,22 +130,6 @@
         */
         // abstract Object readValueFromStatement(CallableStatement stmt, String columnName) throws SQLException;
 
-        public boolean equals(Object obj)
-        {
-            if(this == obj) return true;
-            boolean result = false;
-            if(obj instanceof JdbcType)
-            {
-                result = this.getType() == ((JdbcType) obj).getType();
-            }
-            return result;
-        }
-
-        public int hashCode()
-        {
-            return getType();
-        }
-
         public FieldType getFieldType()
         {
             return fieldType;
@@ -162,15 +172,6 @@
             }
         }
 
-        public String toString()
-        {
-            return new ToStringBuilder(this)
-                    .append("jdbcType", getType())
-                    .append("jdbcTypeString", JdbcTypesHelper.getSqlTypeAsString(getType()))
-                    .append("associatedFieldType", getFieldType())
-                    .toString();
-        }
-
 //      // not used in code, but maybe useful in further versions
 //        public Object getObjectFromColumn(CallableStatement stmt, String columnName) throws SQLException
 //        {
@@ -185,6 +186,35 @@
     }
 
 
+
+    public static final class T_Null extends JdbcTypes.BaseType
+    {
+        Object readValueFromResultSet(final ResultSet rs, final String columnName) throws SQLException
+        {
+            return null;
+        }
+
+        Object readValueFromResultSet(final ResultSet rs, final int columnIndex) throws SQLException
+        {
+            return null;
+        }
+
+        Object readValueFromStatement(final CallableStatement stmt, final int columnIndex) throws SQLException
+        {
+            return null;
+        }
+
+        public Object sequenceKeyConversion(Long identifier) throws SequenceManagerException
+        {
+            throw new UnsupportedOperationException("Not supported");
+        }
+
+        public int getType()
+        {
+            return Types.NULL;
+        }
+    }
+
     public static final class T_Char extends JdbcTypes.BaseType
     {
 		private static final long serialVersionUID = 1L;
@@ -1054,7 +1084,7 @@
             throw new SequenceManagerException("Not supported sequence key type 'CLOB'");
         }
 
-        FieldType lookupFieldType()
+        FieldType createFieldType()
         {
             return new FieldTypes.StringFieldType();
         }
@@ -1137,7 +1167,7 @@
             throw new SequenceManagerException("Not supported sequence key type 'BLOB'");
         }
 
-        FieldType lookupFieldType()
+        FieldType createFieldType()
         {
             return new FieldTypes.ByteArrayFieldType();
         }

Modified: db/ojb/trunk/src/java/org/apache/ojb/broker/metadata/JdbcTypesHelper.java
URL: http://svn.apache.org/viewvc/db/ojb/trunk/src/java/org/apache/ojb/broker/metadata/JdbcTypesHelper.java?view=diff&rev=495677&r1=495676&r2=495677
==============================================================================
--- db/ojb/trunk/src/java/org/apache/ojb/broker/metadata/JdbcTypesHelper.java (original)
+++ db/ojb/trunk/src/java/org/apache/ojb/broker/metadata/JdbcTypesHelper.java Fri Jan 12 10:19:39 2007
@@ -141,29 +141,6 @@
     }
 
     /**
-     * Lookup the {@link JdbcType} by name. If name was not found an exception
-     * is thrown.
-     *
-     * @param typeName The name of the JDBC type as String, e.g. 'bigint', 'integer'...
-     */
-    public static JdbcType getJdbcTypeByName(String typeName, PersistentField field)
-    {
-        /*
-        arminw:
-        Some user reported problems when using OJB with non-default Localization. The
-        conversion of sql type names e.g. Turkish 'BIGINT' to lower case will not match 'bigint'
-        Hope that the specification of the localization will fix this.
-        */
-        JdbcType result = (JdbcType) jdbcObjectTypesFromName.get(typeName.toLowerCase(Locale.ENGLISH));
-        if (result == null)
-        {
-            throw new OJBRuntimeException("The type " + typeName + " can not be handled by OJB." +
-                    " Please specify only types as defined by java.sql.Types.");
-        }
-        return result;
-    }
-
-    /**
      * Set the {@link JdbcType} by name.
      * @param typeName Name of the type
      * @param type the type
@@ -227,6 +204,8 @@
         else if (fieldType.equalsIgnoreCase(Struct.class.getName()))
             result = getJdbcTypeByName("struct");
 //#ifdef JDBC30
+        else if (fieldType.equalsIgnoreCase(Boolean.class.getName()) || fieldType.equalsIgnoreCase("boolean"))
+            result = getJdbcTypeByName("boolean");
         else if (fieldType.equalsIgnoreCase(URL.class.getName()))
             result = getJdbcTypeByName("datalink");
 //#endif
@@ -380,10 +359,9 @@
             case Types.OTHER:
                 result = new FieldTypes.JavaObjectFieldType();
                 break;
-//
-//            case Types.NULL:
-//                result = new NullFieldType();
-//                break;
+            case Types.NULL:
+                result = new FieldTypes.NullFieldType();
+                break;
 
 //#ifdef JDBC30
             case Types.BOOLEAN:
@@ -401,4 +379,4 @@
         //result.setSqlType(jdbcType);
         return result;
     }
-        }
+}

Modified: db/ojb/trunk/src/java/org/apache/ojb/broker/metadata/ObjectCacheDescriptor.java
URL: http://svn.apache.org/viewvc/db/ojb/trunk/src/java/org/apache/ojb/broker/metadata/ObjectCacheDescriptor.java?view=diff&rev=495677&r1=495676&r2=495677
==============================================================================
--- db/ojb/trunk/src/java/org/apache/ojb/broker/metadata/ObjectCacheDescriptor.java (original)
+++ db/ojb/trunk/src/java/org/apache/ojb/broker/metadata/ObjectCacheDescriptor.java Fri Jan 12 10:19:39 2007
@@ -1,18 +1,18 @@
 package org.apache.ojb.broker.metadata;
 
+import java.io.Serializable;
 import java.util.ArrayList;
 import java.util.StringTokenizer;
-import java.io.Serializable;
 
-import org.apache.commons.lang.SystemUtils;
 import org.apache.commons.lang.ArrayUtils;
+import org.apache.commons.lang.SystemUtils;
 import org.apache.commons.lang.builder.ToStringBuilder;
 import org.apache.commons.lang.builder.ToStringStyle;
-import org.apache.ojb.broker.cache.CachingStrategy;
-import org.apache.ojb.broker.cache.CachingStrategyDefaultImpl;
+import org.apache.ojb.broker.cache.CachingPipe;
+import org.apache.ojb.broker.cache.CachingPipeNoopImpl;
 import org.apache.ojb.broker.cache.ObjectCache;
 import org.apache.ojb.broker.cache.ObjectCacheDefaultImpl;
-import org.apache.ojb.broker.cache.ObjectCacheExt;
+import org.apache.ojb.broker.util.XmlHelper;
 
 /* Copyright 2003-2004 The Apache Software Foundation
  *
@@ -37,10 +37,10 @@
     public static final String CACHE_EXCLUDES_STRING = "cacheExcludes";
     private static final String REGION_PREFIX = "ojb_";
     private static final Class DEF_OBJECT_CACHE = ObjectCacheDefaultImpl.class;
-    private static final Class DEF_CACHE_STRATEGY = CachingStrategyDefaultImpl.class;
+    private static final Class DEF_CACHE_STRATEGY = CachingPipeNoopImpl.class;
 
     private Class objectCache;
-    private Class cachingStrategy;
+    private Class cachingPreparer;
     private Integer timeout;
     private String region;
     private ParentWrapper parent;
@@ -69,7 +69,7 @@
     protected void init()
     {
         objectCache = DEF_OBJECT_CACHE;
-        cachingStrategy = DEF_CACHE_STRATEGY;
+        cachingPreparer = DEF_CACHE_STRATEGY;
         timeout = null;
     }
 
@@ -136,7 +136,7 @@
 
     public boolean isExcluded(Class targetClass)
     {
-        if(excludedPackages != null)
+        if(excludedPackages != null && targetClass != null)
         {
             String name = targetClass.getName();
             for(int i = 0; i < excludedPackages.length; i++)
@@ -187,7 +187,7 @@
             else
             {
                 ClassDescriptor cld = parent.cld;
-                region = REGION_PREFIX + cld.getRepository().getTopLevelClass(cld.getClassOfObject()).getName();
+                region = REGION_PREFIX + cld.getTopLevelClass().getName();
             }
         }
         return region;
@@ -219,43 +219,42 @@
      * Set the {@link org.apache.ojb.broker.cache.ObjectCache}
      * implementation class.
      *
-     * @param objectCache The {@link org.apache.ojb.broker.cache.ObjectCache} or
-     *                    {@link org.apache.ojb.broker.cache.ObjectCacheExt} implemetnation class.
+     * @param objectCache The {@link org.apache.ojb.broker.cache.ObjectCache} implemetnation class.
      */
     public void setObjectCache(Class objectCache)
     {
-        if(ObjectCache.class.isAssignableFrom(objectCache) || ObjectCacheExt.class.isAssignableFrom(objectCache))
+        if(ObjectCache.class.isAssignableFrom(objectCache))
         {
             this.objectCache = objectCache;
         }
         else
         {
             throw new MetadataException("Specified class " + objectCache
-                    + " is not a sub-class of " + ObjectCache.class + " or " + ObjectCacheExt.class);
+                    + " is not a sub-class of " + ObjectCache.class + ".");
         }
     }
 
     /**
-     * Return the {@link org.apache.ojb.broker.cache.CachingStrategy} implementation class.
+     * Return the {@link org.apache.ojb.broker.cache.CachingPipe} implementation class.
      */
-    public Class getCachingStrategy()
+    public Class getCachingPreparer()
     {
-        return cachingStrategy;
+        return cachingPreparer;
     }
 
     /**
-     * Set the {@link org.apache.ojb.broker.cache.CachingStrategy}.
+     * Set the {@link org.apache.ojb.broker.cache.CachingPipe}.
      */
-    public void setCachingStrategy(Class cachingStrategy)
+    public void setCachingPreparer(Class cachingPreparer)
     {
-        if(CachingStrategy.class.isAssignableFrom(cachingStrategy))
+        if(CachingPipe.class.isAssignableFrom(cachingPreparer))
         {
-            this.cachingStrategy = cachingStrategy;
+            this.cachingPreparer = cachingPreparer;
         }
         else
         {
-            throw new MetadataException("Specified class " + cachingStrategy
-                    + " is not a sub-class of " + CachingStrategy.class);
+            throw new MetadataException("Specified class " + cachingPreparer
+                    + " is not a sub-class of " + CachingPipe.class);
         }
     }
 
@@ -275,7 +274,7 @@
         buf.append("region", getRegion())
                 .append("parent", parent.toString())
                 .append("objectCache", getObjectCache())
-                .append("cachingStrategy", getCachingStrategy())
+                .append("cachingPreparer", getCachingPreparer())
                 .append("excludedPackages", (getExcludedPackages() != null ? ArrayUtils.toString(getExcludedPackages()) : null))
                 .append(super.toString());
         return buf.toString();
@@ -301,7 +300,7 @@
         buf.append(eol);
         buf.append("         -->");
         buf.append(eol);
-        buf.append(super.toXML("         "));
+        XmlHelper.appendSerializedAttributes(buf, "         ", getAttributes());
         buf.append("      ");
         buf.append(RepositoryTags.getClosingTagById(OBJECT_CACHE));
         buf.append(eol);

Modified: db/ojb/trunk/src/java/org/apache/ojb/broker/metadata/ObjectReferenceDescriptor.java
URL: http://svn.apache.org/viewvc/db/ojb/trunk/src/java/org/apache/ojb/broker/metadata/ObjectReferenceDescriptor.java?view=diff&rev=495677&r1=495676&r2=495677
==============================================================================
--- db/ojb/trunk/src/java/org/apache/ojb/broker/metadata/ObjectReferenceDescriptor.java (original)
+++ db/ojb/trunk/src/java/org/apache/ojb/broker/metadata/ObjectReferenceDescriptor.java Fri Jan 12 10:19:39 2007
@@ -35,8 +35,7 @@
  * Note: Be careful when use references of this class or caching instances of this class,
  * because instances could become invalid (see {@link MetadataManager}).
  *
- * @author <a href="mailto:[email protected]">Thomas Mahler<a>
- *
+ * @version $Id: $
  */
 public class ObjectReferenceDescriptor extends AttributeDescriptorBase implements XmlCapable
 {
@@ -97,6 +96,79 @@
         }
         return m_ProxyOfItems;
     }
+
+    /**
+     * Answer the FieldDescriptors for the Foreignkey-Target-Fields.
+     * These Fields are the Primarykey-Fields of the targetCld in most cases
+     * @param targetCld the classdescriptor to get the fields from
+     */
+    public FieldDescriptor[] getForeignKeyTargetFieldDescriptors(ClassDescriptor targetCld)
+    {
+        FieldDescriptor[] fkFieldDescriptors = (FieldDescriptor[]) m_fkTargetFieldMap.get(targetCld);
+
+        if (fkFieldDescriptors == null)
+        {
+            List fkFields = getForeignKeyFields();
+            FieldDescriptor pkFields[] = targetCld.getPkFields();
+
+            // get FieldDescriptor for each index from Class-descriptor
+            // In a many-to-many relationship Fk-Fields vector will be null.
+            if (fkFields != null)
+            {
+                if (!targetCld.isMappedToTable())
+                {
+                    //exchange interface class descriptor with first concrete class
+                    targetCld = targetCld.getRepository().findFirstConcreteClass(targetCld);
+                }
+                List ret = new ArrayList();
+
+                for (int i = 0; i < fkFields.size(); i++)
+                {
+                    ForeignKey fk = (ForeignKey) fkFields.get(i);
+                    FieldDescriptor fkfd;
+
+                    // if a target-field-ref is available use it
+                    if (fk.targetField != null)
+                    {
+                        fkfd = targetCld.getFieldDescriptorByName(fk.targetField);
+                        if (fkfd == null)
+                        {
+                            ClassDescriptor tmp = targetCld;
+                            while(tmp.getSuperClassDescriptor() != null)
+                            {
+                                fkfd = tmp.getFieldDescriptorByName((String) fk.fkField);
+                                if(fkfd != null)
+                                {
+                                    break;
+                                }
+                                else
+                                {
+                                    tmp = tmp.getSuperClassDescriptor();
+                                }
+                            }
+                        }
+                        if (fkfd == null)
+                        {
+                            throw new OJBRuntimeException("Incorrect or not found target-field reference name '"
+                                    + fk.targetField + "' in descriptor " + this + " for class-descriptor '"
+                                    + targetCld.getClassNameOfObject() + "'");
+                        }
+                    }
+                    // otherwise use the pks of the target class
+                    else
+                    {
+                        fkfd = pkFields[i];
+                    }
+
+                    ret.add(fkfd);
+                }
+
+                fkFieldDescriptors = (FieldDescriptor[]) ret.toArray(new FieldDescriptor[ret.size()]);
+                m_fkTargetFieldMap.put(targetCld, fkFieldDescriptors);
+            }
+        }
+        return fkFieldDescriptors;
+    }
    
     /**
      * Answer the FieldDescriptors for the Foreignkey-Fields.
@@ -105,22 +177,19 @@
     public FieldDescriptor[] getForeignKeyFieldDescriptors(ClassDescriptor cld)
     {
         FieldDescriptor[] fkFieldDescriptors = (FieldDescriptor[]) m_fkFieldMap.get(cld);
-        
         if (fkFieldDescriptors == null)
         {
+			// collect list of indices of Fk-Fields
             List fkFields = getForeignKeyFields();
             
             // get FieldDescriptor for each index from Class-descriptor
-            // In a many-to-many relationship Fk-Fields vector will be null.
+            // In a many-to-many relationship fkFields list will be 'null'.
             if (fkFields != null)
             {
                 if (!cld.isMappedToTable())
                 {
                     //exchange interface class descriptor with first concrete class
-                    Vector extents = cld.getExtentClasses();
-                    // TODO: Check for side-effects
-                    Class firstConcreteClass = (Class) extents.get(0);
-                    cld = getClassDescriptor().getRepository().getDescriptorFor(firstConcreteClass);
+                    cld = cld.getRepository().findFirstConcreteClass(cld);
                 }
                 List ret = new ArrayList();
                 for (int i = 0; i < fkFields.size(); i++)
@@ -153,11 +222,12 @@
                             tmp = tmp.getSuperClassDescriptor();
                         }
                     }
+
                     if (fkfd == null)
                     {
                         throw new OJBRuntimeException("Incorrect or not found field reference name '"
                                 + fk.fkField + "' in descriptor " + this + " for class-descriptor '"
-                                + (cld != null ? cld.getClassNameOfObject() : null) + "'");
+                                + (cld != null ? cld.getClassNameOfObject() + "'" : "'null'"));
                     }
                     ret.add(fkfd);
                 }
@@ -198,80 +268,9 @@
         return result;
     }
 
-    /**
-     * Answer the FieldDescriptors for the Foreignkey-Target-Fields.
-     * These Fields are the Primarykey-Fields of the targetCld in most cases
-     * @param targetCld the classdescriptor to get the fields from
-     */
-    public FieldDescriptor[] getForeignKeyTargetFieldDescriptors(ClassDescriptor targetCld)
+    protected ClassDescriptor getDescriptorFor(Class aClass)
     {
-        FieldDescriptor[] fkFieldDescriptors = (FieldDescriptor[]) m_fkTargetFieldMap.get(targetCld);
-        
-        if (fkFieldDescriptors == null)
-        {
-            List fkFields = getForeignKeyFields();
-            FieldDescriptor pkFields[] = targetCld.getPkFields();
-            
-            // get FieldDescriptor for each index from Class-descriptor
-            // In a many-to-many relationship Fk-Fields vector will be null.
-            if (fkFields != null)
-            {
-                if (!targetCld.isMappedToTable())
-                {
-                    //exchange interface class descriptor with first concrete class
-                    Vector extents = targetCld.getExtentClasses();
-                    // TODO: Check for side-effects
-                    Class firstConcreteClass = (Class) extents.get(0);
-                    targetCld = getClassDescriptor().getRepository().getDescriptorFor(firstConcreteClass);
-                }
-                List ret = new ArrayList();
-
-                for (int i = 0; i < fkFields.size(); i++)
-                {
-                    ForeignKey fk = (ForeignKey) fkFields.get(i);
-                    FieldDescriptor fkfd;
-                    
-                    // if a target-field-ref is available use it
-                    if (fk.targetField != null)
-                    {
-                        fkfd = targetCld.getFieldDescriptorByName(fk.targetField);
-                        if (fkfd == null)
-                        {
-                            ClassDescriptor tmp = targetCld;
-                            while(tmp.getSuperClassDescriptor() != null)
-                            {
-                                fkfd = tmp.getFieldDescriptorByName((String) fk.fkField);
-                                if(fkfd != null)
-                                {
-                                    break;
-                                }
-                                else
-                                {
-                                    tmp = tmp.getSuperClassDescriptor();
-                                }
-                            }
-                        }
-                        if (fkfd == null)
-                        {
-                            throw new OJBRuntimeException("Incorrect or not found target-field reference name '"
-                                    + fk.targetField + "' in descriptor " + this + " for class-descriptor '"
-                                    + targetCld.getClassNameOfObject() + "'");
-                        }
-                    }
-                    // otherwise use the pks of the target class
-                    else
-                    {
-                        fkfd = pkFields[i];
-                    }
-                                      
-                    ret.add(fkfd);
-                }
-                
-                fkFieldDescriptors = (FieldDescriptor[]) ret.toArray(new FieldDescriptor[ret.size()]);
-                m_fkTargetFieldMap.put(targetCld, fkFieldDescriptors);
-            }
-        }
-        return fkFieldDescriptors;
+        return getClassDescriptor().getRepository().getDescriptorFor(aClass);
     }
     
     /**
@@ -299,7 +298,7 @@
      */
     public String getItemClassName()
     {
-        return m_ClassOfItems != null ? m_ClassOfItems.getName() : null;
+        return this.m_ClassOfItems != null ? this.m_ClassOfItems.getName() : null;
     }
 
     /**
@@ -308,6 +307,7 @@
      */
     public void setItemClass(Class c)
     {
+        m_ClassDescriptorOfItems = null;
         m_ClassOfItems = c;
     }
 
@@ -641,20 +641,20 @@
             return false;
         }
 
-        /**
-         * Returns <em>true</em> if a foreign key to the referenced object is
-         * declared, else <em>false</em> is returned.
-         */
-        public boolean hasForeignKey()
-        {
-            /*
-            arminw: Currently we don't have a ForeignKey descriptor object and
-            a official xml-element to support FK settings. As a workaround I introduce
-            a custom-attribute to handle FK settings in collection-/reference-decriptor
-            */
-            String result = getAttribute("fk");
-            return result != null && result.equalsIgnoreCase("true");
-        }
+//        /**
+//         * Returns <em>true</em> if a foreign key to the referenced object is
+//         * declared, else <em>false</em> is returned.
+//         */
+//        public boolean hasForeignKey()
+//        {
+//            /*
+//            arminw: Currently we don't have a ForeignKey descriptor object and
+//            a official xml-element to support FK settings. As a workaround I introduce
+//            a custom-attribute to handle FK settings in collection-/reference-decriptor
+//            */
+//            String result = getAttribute("fk");
+//            return result != null && result.equalsIgnoreCase("true");
+//        }
 
     /**
      * Returns <em>true</em> if a foreign key constraint to the referenced object is
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.