db-ojb-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From to...@apache.org
Subject cvs commit: db-ojb/lib xdoclet-ojb-module-1.2.1.jar
Date Thu, 08 Jul 2004 23:05:41 GMT
tomdz       2004/07/08 16:05:41

  Modified:    src/xdoclet/java/src/xdoclet/modules/ojb/constraints
                        ModelConstraints.java
                        ClassDescriptorConstraints.java
               lib      xdoclet-ojb-module-1.2.1.jar
  Log:
  Added warning if no primary key is defined for a class that has generate-table-info=true
  Fixed checks for number of primary keys = number of foreign keys for references/collections
so that they now cover all classes/interfaces that have generate-table-info=true
  
  Revision  Changes    Path
  1.7       +2 -4      db-ojb/src/xdoclet/java/src/xdoclet/modules/ojb/constraints/ModelConstraints.java
  
  Index: ModelConstraints.java
  ===================================================================
  RCS file: /home/cvs/db-ojb/src/xdoclet/java/src/xdoclet/modules/ojb/constraints/ModelConstraints.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- ModelConstraints.java	10 Jun 2004 22:34:23 -0000	1.6
  +++ ModelConstraints.java	8 Jul 2004 23:05:41 -0000	1.7
  @@ -237,9 +237,8 @@
               {
                   queue.add(it.next());
               }
  -            if (!elementClass.canBeInstantiated())
  +            if (!elementClass.getBooleanProperty(PropertyHelper.OJB_PROPERTY_GENERATE_TABLE_INFO,
true))
               {
  -                // we don't check abstract classes/interfaces
                   continue;
               }
               try
  @@ -366,9 +365,8 @@
               {
                   queue.add(it.next());
               }
  -            if (!referencedClass.canBeInstantiated())
  +            if (!referencedClass.getBooleanProperty(PropertyHelper.OJB_PROPERTY_GENERATE_TABLE_INFO,
true))
               {
  -                // we don't check abstract classes/interfaces
                   continue;
               }
               primFields = referencedClass.getPrimaryKeys();
  
  
  
  1.6       +26 -0     db-ojb/src/xdoclet/java/src/xdoclet/modules/ojb/constraints/ClassDescriptorConstraints.java
  
  Index: ClassDescriptorConstraints.java
  ===================================================================
  RCS file: /home/cvs/db-ojb/src/xdoclet/java/src/xdoclet/modules/ojb/constraints/ClassDescriptorConstraints.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- ClassDescriptorConstraints.java	5 Apr 2004 00:32:30 -0000	1.5
  +++ ClassDescriptorConstraints.java	8 Jul 2004 23:05:41 -0000	1.6
  @@ -20,6 +20,7 @@
   import java.util.*;
   
   import xdoclet.modules.ojb.CommaListIterator;
  +import xdoclet.modules.ojb.LogHelper;
   import xdoclet.modules.ojb.model.*;
   
   /**
  @@ -48,6 +49,7 @@
           ensureTableIfNecessary(classDef, checkLevel);
           checkFactoryClassAndMethod(classDef, checkLevel);
           checkInitializationMethod(classDef, checkLevel);
  +        checkPrimaryKey(classDef, checkLevel);
           checkProxyPrefetchingLimit(classDef, checkLevel);
           checkRowReader(classDef, checkLevel);
           checkObjectCache(classDef, checkLevel);
  @@ -362,6 +364,30 @@
           if (Modifier.isStatic(mods) || Modifier.isAbstract(mods))
           {
               throw new ConstraintException("The initialization-method "+initMethodName+"
in class "+classDef.getName()+" must be a concrete instance method");
  +        }
  +    }
  +
  +    /**
  +     * Checks whether given class descriptor has a primary key.
  +     * 
  +     * @param classDef   The class descriptor
  +     * @param checkLevel The current check level (this constraint is only checked in strict)
  +     * @exception ConstraintException If the constraint has been violated
  +     */
  +    private void checkPrimaryKey(ClassDescriptorDef classDef, String checkLevel) throws
ConstraintException
  +    {
  +        if (CHECKLEVEL_NONE.equals(checkLevel))
  +        {
  +            return;
  +        }
  +
  +        if (classDef.getBooleanProperty(PropertyHelper.OJB_PROPERTY_GENERATE_TABLE_INFO,
true) &&
  +            classDef.getPrimaryKeys().isEmpty())
  +        {
  +            LogHelper.warn(true,
  +                           getClass(),
  +                           "checkPrimaryKey",
  +                           "The class "+classDef.getName()+" has no primary key");
           }
       }
   
  
  
  
  1.4       +81 -87    db-ojb/lib/xdoclet-ojb-module-1.2.1.jar
  
  	<<Binary file>>
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-dev-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-dev-help@db.apache.org


Mime
View raw message