tomdz 2005/08/20 12:50:06
Modified: lib Tag: OJB_1_0_RELEASE xdoclet-ojb-module-1.2.3.jar
src/xdoclet/java/src/xdoclet/modules/ojb/constraints Tag:
OJB_1_0_RELEASE ModelConstraints.java
Log:
Added two warnings regarding misuse of the remote-foreignkey to the XDoclet
module(OJB-67)
Revision Changes Path
No revision
No revision
1.1.2.3 +138 -138 db-ojb/lib/xdoclet-ojb-module-1.2.3.jar
<<Binary file>>
No revision
No revision
1.6.2.7 +24 -0
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.2.6
retrieving revision 1.6.2.7
diff -u -r1.6.2.6 -r1.6.2.7
--- ModelConstraints.java 18 Jun 2005 14:16:33 -0000 1.6.2.6
+++ ModelConstraints.java 20 Aug 2005 19:50:06 -0000 1.6.2.7
@@ -22,6 +22,7 @@
import org.apache.commons.collections.SequencedHashMap;
import xdoclet.modules.ojb.CommaListIterator;
+import xdoclet.modules.ojb.LogHelper;
import xdoclet.modules.ojb.model.ClassDescriptorDef;
import xdoclet.modules.ojb.model.CollectionDescriptorDef;
import xdoclet.modules.ojb.model.FeatureDescriptorDef;
@@ -447,6 +448,18 @@
collDef.setProperty(PropertyHelper.OJB_PROPERTY_REMOTE_FOREIGNKEY, remoteKeys2);
}
}
+
+ // issue a warning if the foreignkey and remote-foreignkey columns
are the same (issue OJB-67)
+ String remoteForeignkey =
collDef.getProperty(PropertyHelper.OJB_PROPERTY_REMOTE_FOREIGNKEY);
+
+ if (CommaListIterator.sameLists(foreignkey, remoteForeignkey))
+ {
+ LogHelper.warn(true,
+ getClass(),
+ "checkIndirectionTable",
+ "The remote foreignkey ("+remoteForeignkey+") for
the collection "+collDef.getName()+" in class "+collDef.getOwner().getName()+"
is identical (ignoring case) to the foreign key ("+foreignkey+").");
+ }
+
// for torque we generate names for the m:n relation that are unique
across inheritance
// but only if we don't have inherited collections
if (collDef.getOriginal() != null)
@@ -501,6 +514,17 @@
throw new ConstraintException("The collection
"+collDef.getName()+" in class "+collDef.getOwner().getName()+" has no
foreignkeys");
}
+ String remoteForeignkey =
collDef.getProperty(PropertyHelper.OJB_PROPERTY_REMOTE_FOREIGNKEY);
+
+ if ((remoteForeignkey != null) && (remoteForeignkey.length() > 0))
+ {
+ // warning because a remote-foreignkey was specified for a 1:n
collection (issue OJB-67)
+ LogHelper.warn(true,
+ getClass(),
+ "checkCollectionForeignkeys",
+ "For the collection "+collDef.getName()+" in
class "+collDef.getOwner().getName()+", a remote foreignkey was specified
though it is a 1:n, not a m:n collection");
+ }
+
ClassDescriptorDef ownerClass =
(ClassDescriptorDef)collDef.getOwner();
ArrayList primFields = ownerClass.getPrimaryKeys();
String elementClassName =
collDef.getProperty(PropertyHelper.OJB_PROPERTY_ELEMENT_CLASS_REF);
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]