tomdz 2005/08/20 12:56:55
Modified: src/xdoclet/java/src/xdoclet/modules/ojb/constraints
ModelConstraints.java
lib xdoclet-ojb-module-1.2.3.jar
Log:
Added two warnings regarding misuse of the remote-foreignkey to the XDoclet
module(OJB-67)
Revision Changes Path
1.11 +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.10
retrieving revision 1.11
diff -u -r1.10 -r1.11
--- ModelConstraints.java 19 Jun 2005 13:53:33 -0000 1.10
+++ ModelConstraints.java 20 Aug 2005 19:56:55 -0000 1.11
@@ -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);
1.3 +132 -296 db-ojb/lib/xdoclet-ojb-module-1.2.3.jar
<<Binary file>>
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]