db-ojb-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From arm...@apache.org
Subject cvs commit: db-ojb/src/java/org/apache/ojb/broker/metadata/torque TorqueTablePreprocessor.java TorqueRepositoryGenerator.java TorqueForeignKeyGenerator.java TorqueFieldGenerator.java
Date Wed, 02 Apr 2003 07:40:50 GMT
arminw      2003/04/01 23:40:50

  Modified:    src/test/org/apache/ojb repository.dtd
               src/java/org/apache/ojb/broker/metadata
                        RepositoryXmlHandler.java RepositoryTags.java
                        RepositoryElements.java IndexDescriptor.java
                        FieldDescriptor.java ClassDescriptor.java
               src/java/org/apache/ojb/broker/metadata/torque
                        TorqueTablePreprocessor.java
                        TorqueRepositoryGenerator.java
                        TorqueForeignKeyGenerator.java
                        TorqueFieldGenerator.java
  Log:
  patch by Chris Greenlee (thanks),
  first attempt to get the TorqueRepositoryGenerator
  work again. the generated torque script isn't
  perfect. the changed classes need some more review.
  
  Revision  Changes    Path
  1.39      +22 -4     db-ojb/src/test/org/apache/ojb/repository.dtd
  
  Index: repository.dtd
  ===================================================================
  RCS file: /home/cvs/db-ojb/src/test/org/apache/ojb/repository.dtd,v
  retrieving revision 1.38
  retrieving revision 1.39
  diff -u -r1.38 -r1.39
  --- repository.dtd	1 Apr 2003 14:06:11 -0000	1.38
  +++ repository.dtd	2 Apr 2003 07:40:49 -0000	1.39
  @@ -282,7 +282,9 @@
   <!ELEMENT class-descriptor
   	((documentation?, extent-class+, attribute*) |
   	(documentation?, extent-class*, field-descriptor+,
  -	 reference-descriptor*, collection-descriptor*, attribute*))>
  +	 reference-descriptor*, collection-descriptor*,
  +     index-descriptor*, attribute*))>
  +
   
   <!--
   	The class attribute contains the full qualified name of the specified class.
  @@ -414,11 +416,11 @@
   
   	The scale attribute can be used to specify a scale setting, if
   	required by the jdbc-type of the underlying database column.
  -	
  +
   	The access attribute specifies the accessibility of the field.
   	"readonly" marks fields that are not to modified. "readwrite" marks
   	fields that may be read and written to. "anonymous" marks anonymous fields.
  -	An anonymous field has a database representation (column) but no 
  +	An anonymous field has a database representation (column) but no
   	corresponding Java attribute. Hence the name of such a field does not
   	refer to a Java attribute of the class, but is used as a unique
   	identifier only.
  @@ -678,4 +680,20 @@
   	attribute*)>
   <!ATTLIST query-customizer
   	class CDATA #REQUIRED
  ->
  \ No newline at end of file
  +>
  +
  +<!--
  +    An index-descriptor describes an index by listing its columns.  It may be
  +    unique or not.
  +-->
  +<!ELEMENT index-descriptor (documentation?, index-column+)>
  +<!ATTLIST index-descriptor
  +    name CDATA #REQUIRED
  +    unique (true | false) "false">
  +
  +<!--
  +    An index-column is just the name of a column in an index.
  +-->
  +<!ELEMENT index-column (documentation?)>
  +<!ATTLIST index-column
  +    name CDATA #REQUIRED>
  
  
  
  1.37      +28 -5     db-ojb/src/java/org/apache/ojb/broker/metadata/RepositoryXmlHandler.java
  
  Index: RepositoryXmlHandler.java
  ===================================================================
  RCS file: /home/cvs/db-ojb/src/java/org/apache/ojb/broker/metadata/RepositoryXmlHandler.java,v
  retrieving revision 1.36
  retrieving revision 1.37
  diff -u -r1.36 -r1.37
  --- RepositoryXmlHandler.java	30 Mar 2003 15:01:09 -0000	1.36
  +++ RepositoryXmlHandler.java	2 Apr 2003 07:40:49 -0000	1.37
  @@ -84,6 +84,7 @@
       private FieldDescriptor m_CurrentFLD;
       private ObjectReferenceDescriptor m_CurrentORD;
       private CollectionDescriptor m_CurrentCOD;
  +    private IndexDescriptor m_CurrentIndexDescriptor;
       private String m_CurrentString;
       /** holds custom attributes */
       private AttributeContainer m_CurrentAttrContainer;
  @@ -706,11 +707,11 @@
                           break;
                       }
                       case QUERY_CUSTOMIZER:
  -                        {    
  +                        {
                               // set collection-class attribute
                               String className = atts.getValue("class");
                               QueryCustomizer queryCust;
  -                        
  +
                               if (className != null)
                               {
                                   if (isDebug) logger.debug("     " + "class" + ": " + className);
  @@ -720,6 +721,18 @@
                               }
                               break;
                           }
  +                    case INDEX_DESCRIPTOR:
  +                        {
  +                            m_CurrentIndexDescriptor = new IndexDescriptor();
  +                            m_CurrentIndexDescriptor.setName(atts.getValue(tags.getTagById(NAME)));
  +                            m_CurrentIndexDescriptor.setUnique(new Boolean(atts.getValue(tags.getTagById(UNIQUE))).booleanValue());
  +                            break;
  +                        }
  +                    case INDEX_COLUMN:
  +                        {
  +                            m_CurrentIndexDescriptor.getIndexColumns().add(atts.getValue(tags.getTagById(NAME)));
  +                            break;
  +                        }
                   default :
                       {
                           // nop
  @@ -837,11 +850,21 @@
                           break;
                       }
                   case QUERY_CUSTOMIZER:
  -                    {    
  +                    {
                           m_CurrentAttrContainer = m_CurrentCOD;
                           break;
                       }
  -
  +                case INDEX_DESCRIPTOR:
  +                    {
  +                        m_CurrentCLD.getIndexes().add(m_CurrentIndexDescriptor);
  +                        m_CurrentIndexDescriptor = null;
  +                        break;
  +                    }
  +                case INDEX_COLUMN:
  +                    {
  +                        // ignore; all processing done in startElement
  +                        break;
  +                    }
                       // handle failure:
                   default :
                       {
  
  
  
  1.25      +5 -0      db-ojb/src/java/org/apache/ojb/broker/metadata/RepositoryTags.java
  
  Index: RepositoryTags.java
  ===================================================================
  RCS file: /home/cvs/db-ojb/src/java/org/apache/ojb/broker/metadata/RepositoryTags.java,v
  retrieving revision 1.24
  retrieving revision 1.25
  diff -u -r1.24 -r1.25
  --- RepositoryTags.java	30 Mar 2003 15:01:09 -0000	1.24
  +++ RepositoryTags.java	2 Apr 2003 07:40:50 -0000	1.25
  @@ -155,6 +155,11 @@
           table.put("proxy", new Integer(PROXY_REFERENCE));
           table.put("sort", new Integer(SORT));
   
  +        table.put("index-descriptor", new Integer(INDEX_DESCRIPTOR));
  +        table.put("index-column", new Integer(INDEX_COLUMN));
  +        table.put("unique", new Integer(UNIQUE));
  +        table.put("name", new Integer(NAME));
  +
           table.put(PoolConfiguration.MAX_ACTIVE, new Integer(CON_MAX_ACTIVE));
           table.put(PoolConfiguration.MAX_IDLE, new Integer(CON_MAX_IDLE));
           table.put(PoolConfiguration.MAX_WAIT, new Integer(CON_MAX_WAIT));
  
  
  
  1.23      +7 -2      db-ojb/src/java/org/apache/ojb/broker/metadata/RepositoryElements.java
  
  Index: RepositoryElements.java
  ===================================================================
  RCS file: /home/cvs/db-ojb/src/java/org/apache/ojb/broker/metadata/RepositoryElements.java,v
  retrieving revision 1.22
  retrieving revision 1.23
  diff -u -r1.22 -r1.23
  --- RepositoryElements.java	30 Mar 2003 15:01:09 -0000	1.22
  +++ RepositoryElements.java	2 Apr 2003 07:40:50 -0000	1.23
  @@ -157,9 +157,14 @@
       public static final int QUERY_CUSTOMIZER = 92;
       public static final int INITIALIZATION_METHOD = 93;
   
  +    public static final int INDEX_DESCRIPTOR = 94;
  +    public static final int INDEX_COLUMN = 95;
  +    public static final int UNIQUE = 96;
  +    public static final int NAME = 97;
  +
       // maintain a next id to keep track where we are
  -    static final int _NEXT = 95;
  -    
  +    static final int _NEXT = 98;
  +
       public static final String TAG_ACCESS_ANONYMOUS = "anonymous";
       public static final String TAG_ACCESS_READONLY  = "readonly";
       public static final String TAG_ACCESS_READWRITE = "readwrite";
  
  
  
  1.5       +38 -2     db-ojb/src/java/org/apache/ojb/broker/metadata/IndexDescriptor.java
  
  Index: IndexDescriptor.java
  ===================================================================
  RCS file: /home/cvs/db-ojb/src/java/org/apache/ojb/broker/metadata/IndexDescriptor.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- IndexDescriptor.java	13 Mar 2003 19:51:18 -0000	1.4
  +++ IndexDescriptor.java	2 Apr 2003 07:40:50 -0000	1.5
  @@ -54,14 +54,18 @@
    * <http://www.apache.org/>.
    */
   
  +import org.apache.commons.lang.SystemUtils;
  +import org.apache.ojb.broker.accesslayer.conversions.FieldConversionDefaultImpl;
  +
   import java.util.Vector;
  +import java.io.Serializable;
   
   /**
    *
    *
    * @version $Id$
    */
  -public class IndexDescriptor
  +public class IndexDescriptor implements XmlCapable, Serializable
   {
       private String name;
       private boolean unique;
  @@ -96,4 +100,36 @@
       {
           this.indexColumns = indexColumns;
       }
  +
  +    /*
  +     * @see XmlCapable#toXML()
  +     */
  +    public String toXML()
  +    {
  +        RepositoryTags tags = RepositoryTags.getInstance();
  +        String eol = SystemUtils.LINE_SEPARATOR;
  +
  +        //opening tag + attributes
  +        String result = "      <" + tags.getTagById(INDEX_DESCRIPTOR) + " ";
  +
  +        // index name
  +        result += tags.getAttribute(NAME, getName()) + " ";
  +
  +        // unique attribute
  +        result += tags.getAttribute(UNIQUE, ""+isUnique()) + ">" + eol;
  +
  +        // index columns
  +        for (int i = 0; i < indexColumns.size(); i++) {
  +            String name = (String) indexColumns.elementAt(i);
  +            result += "                " + tags.getOpeningTagNonClosingById(INDEX_COLUMN)
+ " ";
  +            result += tags.getAttribute(NAME, name);
  +            result += " />" + eol;
  +        }
  +
  +        // closing tag
  +        result += "      " + tags.getClosingTagById(INDEX_DESCRIPTOR) + " "+eol;
  +
  +        return result;
  +    }
  +
   }
  
  
  
  1.18      +7 -1      db-ojb/src/java/org/apache/ojb/broker/metadata/FieldDescriptor.java
  
  Index: FieldDescriptor.java
  ===================================================================
  RCS file: /home/cvs/db-ojb/src/java/org/apache/ojb/broker/metadata/FieldDescriptor.java,v
  retrieving revision 1.17
  retrieving revision 1.18
  diff -u -r1.17 -r1.18
  --- FieldDescriptor.java	26 Mar 2003 10:37:56 -0000	1.17
  +++ FieldDescriptor.java	2 Apr 2003 07:40:50 -0000	1.18
  @@ -57,6 +57,7 @@
   import org.apache.commons.lang.builder.ToStringBuilder;
   import org.apache.commons.lang.builder.ToStringStyle;
   import org.apache.commons.lang.SystemUtils;
  +import org.apache.commons.lang.SerializationUtils;
   import org.apache.ojb.broker.OJBRuntimeException;
   import org.apache.ojb.broker.accesslayer.conversions.FieldConversion;
   import org.apache.ojb.broker.accesslayer.conversions.FieldConversionDefaultImpl;
  @@ -64,6 +65,7 @@
   
   import java.sql.Types;
   import java.util.Comparator;
  +import java.io.Serializable;
   
   /**
    * A FieldDescriptor holds the mapping information for a specific member-variable
  @@ -74,7 +76,7 @@
    *
    * @author <a href="mailto:thma@apache.org">Thomas Mahler<a>
    */
  -public class FieldDescriptor extends AttributeDescriptorBase implements XmlCapable
  +public class FieldDescriptor extends AttributeDescriptorBase implements XmlCapable, Serializable
   {
       private int m_ColNo;
       private String m_ColumnName;
  @@ -535,5 +537,9 @@
   
           result += "      />" + eol;
           return result;
  +    }
  +
  +    public Object clone() {
  +        return SerializationUtils.deserialize(SerializationUtils.serialize(this));
       }
   }
  
  
  
  1.52      +24 -17    db-ojb/src/java/org/apache/ojb/broker/metadata/ClassDescriptor.java
  
  Index: ClassDescriptor.java
  ===================================================================
  RCS file: /home/cvs/db-ojb/src/java/org/apache/ojb/broker/metadata/ClassDescriptor.java,v
  retrieving revision 1.51
  retrieving revision 1.52
  diff -u -r1.51 -r1.52
  --- ClassDescriptor.java	26 Mar 2003 10:37:55 -0000	1.51
  +++ ClassDescriptor.java	2 Apr 2003 07:40:50 -0000	1.52
  @@ -198,12 +198,12 @@
        * does the described class represent an interface?
        */
       private boolean isInterface = false;
  -    
  +
       /**
        * the zero argument constructor for this class
        */
       private transient Constructor zeroArgumentConstructor = null;
  -    
  +
       /**
        * the constructor defined by m_Class to initialze all scalar attributes
        * described in m_FieldDescriptions
  @@ -225,19 +225,19 @@
       private Map m_fieldDescriptorNameMap = new HashMap();
       private Map m_collectionDescriptorNameMap = new HashMap();
       private Map m_objectReferenceDescriptorsNameMap = new HashMap();
  -    
  +
       /**
        * optional method to be invoked after instance fields are initialized
        */
       private transient Method initializationMethod;
   
   
  -    
  +
       /**
        * whether we have already tried to look up the zero argument constructor
        */
       private transient boolean alreadyLookedupZeroArguments = false;
  -    
  +
       private static final Class[] NO_PARAMS = {};
   
   
  @@ -270,7 +270,7 @@
               Configuration config = configurator.getConfigurationFor(null);
               Class rrClass = config.getClass("RowReaderDefaultClass",
                   RowReaderDefaultImpl.class);
  -     
  +
               setRowReader(rrClass.getName());
           }
           return this.rowReader;
  @@ -1036,14 +1036,14 @@
                   try
                   {
                       zeroArgumentConstructor = getClassOfObject().getDeclaredConstructor(NO_PARAMS);
  -     
  +
                       //we found one, now let's make it accessible
                       zeroArgumentConstructor.setAccessible(true);
                   }
                   catch (NoSuchMethodException e2)
                   {
                       //out of options, log the fact and let the method return null
  -     
  +
                       LoggerFactory.getDefaultLogger().warn(this.getClass().getName() + ":
" +
                           "No zero argument constructor defined for "
                           + this.getClassOfObject());
  @@ -1052,7 +1052,7 @@
   
              alreadyLookedupZeroArguments = true;
           }
  -  
  +
           return zeroArgumentConstructor;
       }
   
  @@ -1176,7 +1176,7 @@
               result += "        " + tags.getAttribute(ACCEPT_LOCKS, "false") + eol;
           }
           // sequence manager attribute not yet implemented
  -               
  +
           // initialization method is optional
           if (this.getInitializationMethod() != null)
           {
  @@ -1231,6 +1231,13 @@
               {
                   result += ((CollectionDescriptor) cols.get(i)).toXML();
               }
  +
  +            // write optional IndexDescriptors
  +            for (int i = 0; i < indexes.size(); i++)
  +            {
  +                IndexDescriptor indexDescriptor = (IndexDescriptor) indexes.elementAt(i);
  +                result += indexDescriptor.toXML();
  +            }
           }
           result += "  " + tags.getClosingTagById(CLASS_DESCRIPTOR);
           return result;
  @@ -1457,7 +1464,7 @@
                   append("fieldDescriptions", getFieldDescriptions()).
                   toString();
       }
  -    
  +
       /**
        * sets the initialization method for this descriptor
        */
  @@ -1471,13 +1478,13 @@
   				throw new MetadataException("Initialization methods must be zero argument methods:
"
   					+ newMethod.getClass().getName() + "." + newMethod.getName());
   			}
  -			
  +
   			// make it accessible if it's not already
   			if (!newMethod.isAccessible())
   			{
   				newMethod.setAccessible(true);
   			}
  -		}		
  +		}
   		this.initializationMethod = newMethod;
   	}
   
  @@ -1487,7 +1494,7 @@
   	public void setInitializationMethod(String newMethodName)
   	{
   		Method newMethod = null;
  -		
  +
   		if (newMethodName != null)
   		{
   			try
  @@ -1508,10 +1515,10 @@
   					throw new MetadataException("Invalid initialization method, there is not"
   						+ " a zero argument method named " + newMethodName
   						+ " on class " + getClassOfObject().getName() + ".");
  -				}				
  +				}
   			}
   		}
  -		
  +
   		setInitializationMethod(newMethod);
   	}
   
  
  
  
  1.3       +8 -1      db-ojb/src/java/org/apache/ojb/broker/metadata/torque/TorqueTablePreprocessor.java
  
  Index: TorqueTablePreprocessor.java
  ===================================================================
  RCS file: /home/cvs/db-ojb/src/java/org/apache/ojb/broker/metadata/torque/TorqueTablePreprocessor.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- TorqueTablePreprocessor.java	17 Jun 2002 19:34:11 -0000	1.2
  +++ TorqueTablePreprocessor.java	2 Apr 2003 07:40:50 -0000	1.3
  @@ -74,7 +74,14 @@
           Iterator classDescriptorIterators = this.repository.iterator();
           while (classDescriptorIterators.hasNext()) {
               ClassDescriptor cd = (ClassDescriptor) classDescriptorIterators.next();
  -            buildStandardTable(cd);
  +            if(cd.isAbstract() || cd.isInterface())
  +            {
  +                System.out.println("Skip table build for abstract base class / interface
called "+cd.getClassNameOfObject());
  +            }
  +            else
  +            {
  +                buildStandardTable(cd);
  +            }
           }
       }
   
  
  
  
  1.4       +2 -0      db-ojb/src/java/org/apache/ojb/broker/metadata/torque/TorqueRepositoryGenerator.java
  
  Index: TorqueRepositoryGenerator.java
  ===================================================================
  RCS file: /home/cvs/db-ojb/src/java/org/apache/ojb/broker/metadata/torque/TorqueRepositoryGenerator.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- TorqueRepositoryGenerator.java	24 Dec 2002 13:14:35 -0000	1.3
  +++ TorqueRepositoryGenerator.java	2 Apr 2003 07:40:50 -0000	1.4
  @@ -56,6 +56,7 @@
   
   import org.apache.ojb.broker.metadata.DescriptorRepository;
   import org.apache.ojb.broker.metadata.RepositoryPersistor;
  +import org.apache.ojb.broker.metadata.ClassDescriptor;
   
   import java.io.FileWriter;
   import java.io.IOException;
  @@ -71,6 +72,7 @@
       {
           RepositoryPersistor persistor = new RepositoryPersistor();
           DescriptorRepository repository = persistor.readDescriptorRepository(xmlInputFile);
  +
           this.tablePreprocessor = new TorqueTablePreprocessor(repository);
           this.tablePreprocessor.buildStandardTables();
           this.tableGenerator = new TorqueTableGenerator(repository, ignoreAutoIncrement);
  
  
  
  1.5       +33 -17    db-ojb/src/java/org/apache/ojb/broker/metadata/torque/TorqueForeignKeyGenerator.java
  
  Index: TorqueForeignKeyGenerator.java
  ===================================================================
  RCS file: /home/cvs/db-ojb/src/java/org/apache/ojb/broker/metadata/torque/TorqueForeignKeyGenerator.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- TorqueForeignKeyGenerator.java	2 Jan 2003 21:27:19 -0000	1.4
  +++ TorqueForeignKeyGenerator.java	2 Apr 2003 07:40:50 -0000	1.5
  @@ -78,8 +78,15 @@
           Iterator classDescriptorIterators = this.repository.iterator();
           while (classDescriptorIterators.hasNext()) {
               ClassDescriptor cd = (ClassDescriptor) classDescriptorIterators.next();
  -            buildConstraints(cd);
  -            buildOneToOneConstraints(cd);
  +            if(cd.isAbstract() || cd.isInterface())
  +            {
  +                System.out.println("Skip constraint build for abstract class/ interface
"+cd.getClassNameOfObject());
  +            }
  +            else
  +            {
  +                buildConstraints(cd);
  +                buildOneToOneConstraints(cd);
  +            }
           }
       }
   
  @@ -133,10 +140,11 @@
               String columnName = (String) keys[i];
   
               FieldDescriptor foreignColumn = cd.getPkFields()[i];
  -            String foreignColumnName = foreignColumn.getColumnName();
  +            String foreignColumnName = foreignColumn.getPersistentField().getName();
               buildReferenceForColumn(buffer, columnName, foreignColumnName);
  -
  -            columns.add(foreignColumn);
  +            FieldDescriptor fieldDescriptor = (FieldDescriptor)foreignColumn.clone();
  +            fieldDescriptor.setColumnName(columnName);
  +            columns.add(fieldDescriptor);
           }
           buffer.append("        </foreign-key>\n");
   
  @@ -167,19 +175,27 @@
           buildForeignKeyHeader(foreignClassDescriptor.getFullTableName(), buffer);
   
           for (int i = 0; i < foreignKeyIndices.size(); i++) {
  -	    String columnName;
  -	    Object obj = foreignKeyIndices.get(i);
  -	    
  -	    if (obj instanceof Integer) 
  -	    {
  +            String columnName = null;
  +            Object obj = foreignKeyIndices.get(i);
  +
  +            if (obj instanceof Integer)
  +            {
                   int foreignKeyIndex = ((Integer) obj).intValue();
  -        	columnName = classDescriptor.getFieldDescriptorByIndex(foreignKeyIndex).getColumnName();
  -	    }
  -	    else
  -	    {
  -        	columnName = classDescriptor.getFieldDescriptorByName((String) obj).getColumnName();
  -	    }
  -    
  +                columnName = classDescriptor.getFieldDescriptorByIndex(foreignKeyIndex).getColumnName();
  +            }
  +            else
  +            {
  +//                    System.out.println("## object: "+obj+" cld is interface: "+classDescriptor.isInterface()+
  +//                                            " cld is abstract "+classDescriptor.isAbstract());
  +                    FieldDescriptor fld = classDescriptor.getFieldDescriptorByName((String)
obj);
  +                    if(fld == null)
  +                    {
  +                        System.err.println("FieldDescriptor for foreign key parameter \n"+
  +                                obj+" was not found in ClassDescriptor \n"+classDescriptor);
  +                    }
  +                    else columnName = fld.getColumnName();
  +            }
  +
               FieldDescriptor foreignColumn = foreignClassDescriptor.getPkFields()[i];
               String foreignColumnName = foreignColumn.getColumnName();
               buildReferenceForColumn(buffer, columnName, foreignColumnName);
  
  
  
  1.3       +7 -5      db-ojb/src/java/org/apache/ojb/broker/metadata/torque/TorqueFieldGenerator.java
  
  Index: TorqueFieldGenerator.java
  ===================================================================
  RCS file: /home/cvs/db-ojb/src/java/org/apache/ojb/broker/metadata/torque/TorqueFieldGenerator.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- TorqueFieldGenerator.java	17 Jun 2002 19:34:11 -0000	1.2
  +++ TorqueFieldGenerator.java	2 Apr 2003 07:40:50 -0000	1.3
  @@ -70,7 +70,7 @@
           if (descriptors != null) {
               for (int i = 0; i < descriptors.length; i++) {
                   FieldDescriptor descriptor = descriptors[i];
  -                generateFieldDescriptor(descriptor, descriptor.isRequired(), descriptor.isAutoIncrement(),
descriptor.isPrimaryKey(), buffer);
  +                generateFieldDescriptor(descriptor, descriptor.getColumnName(), descriptor.isRequired(),
descriptor.isAutoIncrement(), descriptor.isPrimaryKey(), buffer);
               }
           }
       }
  @@ -79,16 +79,18 @@
           if (descriptors != null) {
               for (int i = 0; i < descriptors.length; i++) {
                   FieldDescriptor descriptor = descriptors[i];
  -                generateFieldDescriptor(descriptor, true, false, true, buffer);
  +                StringBuffer fieldBuffer = new StringBuffer();
  +                generateFieldDescriptor(descriptor, descriptor.getColumnName(), true, false,
true, fieldBuffer);
  +                buffer.append(fieldBuffer);
               }
           }
       }
   
  -    private void generateFieldDescriptor(FieldDescriptor descriptor, boolean isRequired,
boolean isAutoIncrement, boolean isPrimaryKey, StringBuffer buffer) {
  +    private void generateFieldDescriptor(FieldDescriptor descriptor, String fieldName,
boolean isRequired, boolean isAutoIncrement, boolean isPrimaryKey, StringBuffer buffer) {
           buffer.append("        <column name=\"");
  -        buffer.append(descriptor.getColumnName());
  +        buffer.append(fieldName);
           buffer.append("\" required=\"");
  -        buffer.append(isRequired);
  +        buffer.append(isRequired || isPrimaryKey);
           if (!this.ignoreAutoIncrement) {
               buffer.append("\" autoIncrement=\"");
               buffer.append(isAutoIncrement);
  
  
  

Mime
View raw message