Return-Path: Delivered-To: apmail-db-ojb-dev-archive@www.apache.org Received: (qmail 65077 invoked from network); 8 Jul 2004 23:05:47 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur-2.apache.org with SMTP; 8 Jul 2004 23:05:47 -0000 Received: (qmail 97666 invoked by uid 500); 8 Jul 2004 23:05:47 -0000 Delivered-To: apmail-db-ojb-dev-archive@db.apache.org Received: (qmail 97418 invoked by uid 500); 8 Jul 2004 23:05:45 -0000 Mailing-List: contact ojb-dev-help@db.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Subscribe: List-Help: List-Post: List-Id: "OJB Developers List" Reply-To: "OJB Developers List" Delivered-To: mailing list ojb-dev@db.apache.org Received: (qmail 97395 invoked by uid 500); 8 Jul 2004 23:05:45 -0000 Received: (qmail 97390 invoked by uid 99); 8 Jul 2004 23:05:45 -0000 X-ASF-Spam-Status: No, hits=0.5 required=10.0 tests=ALL_TRUSTED,NO_REAL_NAME X-Spam-Check-By: apache.org Received: from [209.237.227.194] (HELO minotaur.apache.org) (209.237.227.194) by apache.org (qpsmtpd/0.27.1) with SMTP; Thu, 08 Jul 2004 16:05:41 -0700 Received: (qmail 65048 invoked by uid 1797); 8 Jul 2004 23:05:41 -0000 Date: 8 Jul 2004 23:05:41 -0000 Message-ID: <20040708230541.65047.qmail@minotaur.apache.org> From: tomdz@apache.org To: db-ojb-cvs@apache.org Subject: cvs commit: db-ojb/lib xdoclet-ojb-module-1.2.1.jar X-Virus-Checked: Checked X-Spam-Rating: minotaur-2.apache.org 1.6.2 0/1000/N 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 <> --------------------------------------------------------------------- To unsubscribe, e-mail: ojb-dev-unsubscribe@db.apache.org For additional commands, e-mail: ojb-dev-help@db.apache.org