tomdz 2005/06/18 07:16:33
Modified: src/xdoclet/test/xdoclet/modules/ojb/tests Tag:
OJB_1_0_RELEASE
ReferenceTagClassRefAttributeTests.java
ClassTagSimpleTests.java
CollectionTagElementClassRefAttributeTests.java
AnonymousFieldTagTests.java
src/xdoclet/java/src/xdoclet/modules/ojb/model Tag:
OJB_1_0_RELEASE ModelDef.java
ClassDescriptorDef.java TorqueModelDef.java
CollectionDescriptorDef.java
src/xdoclet/java/src/xdoclet/modules/ojb/constraints Tag:
OJB_1_0_RELEASE ClassDescriptorConstraints.java
InheritanceHelper.java
CollectionDescriptorConstraints.java
ReferenceDescriptorConstraints.java
ModelConstraints.java
lib Tag: OJB_1_0_RELEASE xdoclet-ojb-module-1.2.3.jar
Log:
Fixed handling of inner/nested classes
Revision Changes Path
No revision
No revision
1.6.2.2 +153 -0
db-ojb/src/xdoclet/test/xdoclet/modules/ojb/tests/ReferenceTagClassRefAttributeTests.java
Index: ReferenceTagClassRefAttributeTests.java
===================================================================
RCS file:
/home/cvs/db-ojb/src/xdoclet/test/xdoclet/modules/ojb/tests/ReferenceTagClassRefAttributeTests.java,v
retrieving revision 1.6.2.1
retrieving revision 1.6.2.2
diff -u -r1.6.2.1 -r1.6.2.2
--- ReferenceTagClassRefAttributeTests.java 17 Mar 2005 23:49:10 -0000
1.6.2.1
+++ ReferenceTagClassRefAttributeTests.java 18 Jun 2005 14:16:33 -0000
1.6.2.2
@@ -1069,4 +1069,157 @@
"</database>",
runTorqueXDoclet(TORQUE_DEST_FILE, "ojbtest"));
}
+
+ // Test: no class-ref attribute specified, type of variable is nested
class with ojb.class tag
+ public void testClassRef19()
+ {
+ addClass(
+ "test.A",
+ "package test;\n"+
+ "/** @ojb.class */\n"+
+ "public class A {\n"+
+ "/** @ojb.field */\n"+
+ " private int attrKey;\n"+
+ "/** @ojb.reference foreignkey=\"attrKey\" */\n"+
+ " private test.B.Inner attr;\n"+
+ "}\n");
+ addClass(
+ "test.B",
+ "package test;\n"+
+ "public class B {\n"+
+ " /** @ojb.class */\n"+
+ " public static class Inner {\n"+
+ " /** @ojb.field primarykey=\"true\" */\n"+
+ " private int id;\n"+
+ " }\n"+
+ "}\n");
+
+ assertEqualsOjbDescriptorFile(
+ "<class-descriptor\n"+
+ " class=\"test.A\"\n"+
+ " table=\"A\"\n"+
+ ">\n"+
+ " <field-descriptor\n"+
+ " name=\"attrKey\"\n"+
+ " column=\"attrKey\"\n"+
+ " jdbc-type=\"INTEGER\"\n"+
+ " >\n"+
+ " </field-descriptor>\n"+
+ " <reference-descriptor\n"+
+ " name=\"attr\"\n"+
+ " class-ref=\"test.B$Inner\"\n"+
+ " >\n"+
+ " <foreignkey field-ref=\"attrKey\"/>\n"+
+ " </reference-descriptor>\n"+
+ "</class-descriptor>\n"+
+ "<class-descriptor\n"+
+ " class=\"test.B$Inner\"\n"+
+ " table=\"Inner\"\n"+
+ ">\n"+
+ " <field-descriptor\n"+
+ " name=\"id\"\n"+
+ " column=\"id\"\n"+
+ " jdbc-type=\"INTEGER\"\n"+
+ " primarykey=\"true\"\n"+
+ " >\n"+
+ " </field-descriptor>\n"+
+ "</class-descriptor>",
+ runOjbXDoclet(OJB_DEST_FILE));
+ assertEqualsTorqueSchemaFile(
+ "<database name=\"ojbtest\">\n"+
+ " <table name=\"A\">\n"+
+ " <column name=\"attrKey\"\n"+
+ " javaName=\"attrKey\"\n"+
+ " type=\"INTEGER\"\n"+
+ " />\n"+
+ " <foreign-key foreignTable=\"Inner\">\n"+
+ " <reference local=\"attrKey\" foreign=\"id\"/>\n"+
+ " </foreign-key>\n"+
+ " </table>\n"+
+ " <table name=\"Inner\">\n"+
+ " <column name=\"id\"\n"+
+ " javaName=\"id\"\n"+
+ " type=\"INTEGER\"\n"+
+ " primaryKey=\"true\"\n"+
+ " required=\"true\"\n"+
+ " />\n"+
+ " </table>\n"+
+ "</database>",
+ runTorqueXDoclet(TORQUE_DEST_FILE, "ojbtest"));
+ }
+
+ // Test: class-ref attribute points to a persistent inner class and uses
"$"
+ public void testClassRef20()
+ {
+ addClass(
+ "test.A",
+ "package test;\n"+
+ "/** @ojb.class */\n"+
+ "public class A {\n"+
+ " /** @ojb.class */\n"+
+ " public class Inner {\n"+
+ " /** @ojb.field primarykey=\"true\" */\n"+
+ " private int id;\n"+
+ " }\n"+
+ " /** @ojb.field */\n"+
+ " private int attrKey;\n"+
+ " /** @ojb.reference foreignkey=\"attrKey\"\n"+
+ " * class-ref=\"test.A$Inner\"\n"+
+ " */\n"+
+ " private Object attr;\n"+
+ "}\n");
+
+ assertEqualsOjbDescriptorFile(
+ "<class-descriptor\n"+
+ " class=\"test.A\"\n"+
+ " table=\"A\"\n"+
+ ">\n"+
+ " <field-descriptor\n"+
+ " name=\"attrKey\"\n"+
+ " column=\"attrKey\"\n"+
+ " jdbc-type=\"INTEGER\"\n"+
+ " >\n"+
+ " </field-descriptor>\n"+
+ " <reference-descriptor\n"+
+ " name=\"attr\"\n"+
+ " class-ref=\"test.A$Inner\"\n"+
+ " >\n"+
+ " <foreignkey field-ref=\"attrKey\"/>\n"+
+ " </reference-descriptor>\n"+
+ "</class-descriptor>\n"+
+ "<class-descriptor\n"+
+ " class=\"test.A$Inner\"\n"+
+ " table=\"Inner\"\n"+
+ ">\n"+
+ " <field-descriptor\n"+
+ " name=\"id\"\n"+
+ " column=\"id\"\n"+
+ " jdbc-type=\"INTEGER\"\n"+
+ " primarykey=\"true\"\n"+
+ " >\n"+
+ " </field-descriptor>\n"+
+ "</class-descriptor>",
+ runOjbXDoclet(OJB_DEST_FILE));
+ assertEqualsTorqueSchemaFile(
+ "<database name=\"ojbtest\">\n"+
+ " <table name=\"A\">\n"+
+ " <column name=\"attrKey\"\n"+
+ " javaName=\"attrKey\"\n"+
+ " type=\"INTEGER\"\n"+
+ " />\n"+
+ " <foreign-key foreignTable=\"Inner\">\n"+
+ " <reference local=\"attrKey\" foreign=\"id\"/>\n"+
+ " </foreign-key>\n"+
+ " </table>\n"+
+ " <table name=\"Inner\">\n"+
+ " <column name=\"id\"\n"+
+ " javaName=\"id\"\n"+
+ " type=\"INTEGER\"\n"+
+ " primaryKey=\"true\"\n"+
+ " required=\"true\"\n"+
+ " />\n"+
+ " </table>\n"+
+ "</database>",
+ runTorqueXDoclet(TORQUE_DEST_FILE, "ojbtest"));
+ }
}
1.3.2.1 +74 -15
db-ojb/src/xdoclet/test/xdoclet/modules/ojb/tests/ClassTagSimpleTests.java
Index: ClassTagSimpleTests.java
===================================================================
RCS file:
/home/cvs/db-ojb/src/xdoclet/test/xdoclet/modules/ojb/tests/ClassTagSimpleTests.java,v
retrieving revision 1.3
retrieving revision 1.3.2.1
diff -u -r1.3 -r1.3.2.1
--- ClassTagSimpleTests.java 5 Apr 2004 12:16:17 -0000 1.3
+++ ClassTagSimpleTests.java 18 Jun 2005 14:16:33 -0000 1.3.2.1
@@ -55,23 +55,25 @@
public void testSimple2()
{
addClass(
- "A",
+ "test.A",
+ "package test;\n"+
"/** @ojb.class */\n"+
"public class A {}\n");
addClass(
- "B",
+ "test.B",
+ "package test;\n"+
"/** @ojb.class */\n"+
"public class B extends A {}\n");
assertEqualsOjbDescriptorFile(
"<class-descriptor\n"+
- " class=\"A\"\n"+
+ " class=\"test.A\"\n"+
" table=\"A\"\n"+
">\n"+
- " <extent-class class-ref=\"B\"/>\n"+
+ " <extent-class class-ref=\"test.B\"/>\n"+
"</class-descriptor>\n"+
"<class-descriptor\n"+
- " class=\"B\"\n"+
+ " class=\"test.B\"\n"+
" table=\"B\"\n"+
">\n"+
"</class-descriptor>",
@@ -90,39 +92,44 @@
public void testSimple3()
{
addClass(
- "A",
+ "test.A",
+ "package test;\n"+
"/** @ojb.class */\n"+
"public class A {}\n");
addClass(
- "B",
+ "test.B",
+ "package test;\n"+
"public class B extends A {}\n");
addClass(
- "C",
+ "test.C",
+ "package test;\n"+
"/** @ojb.class */\n"+
"public class C extends B {}\n");
addClass(
- "D",
+ "test.D",
+ "package test;\n"+
"public class D extends C {}\n");
addClass(
- "E",
+ "test.E",
+ "package test;\n"+
"/** @ojb.class */\n"+
"public class E extends D {}\n");
assertEqualsOjbDescriptorFile(
"<class-descriptor\n"+
- " class=\"A\"\n"+
+ " class=\"test.A\"\n"+
" table=\"A\"\n"+
">\n"+
- " <extent-class class-ref=\"C\"/>\n"+
+ " <extent-class class-ref=\"test.C\"/>\n"+
"</class-descriptor>\n"+
"<class-descriptor\n"+
- " class=\"C\"\n"+
+ " class=\"test.C\"\n"+
" table=\"C\"\n"+
">\n"+
- " <extent-class class-ref=\"E\"/>\n"+
+ " <extent-class class-ref=\"test.E\"/>\n"+
"</class-descriptor>\n"+
"<class-descriptor\n"+
- " class=\"E\"\n"+
+ " class=\"test.E\"\n"+
" table=\"E\"\n"+
">\n"+
"</class-descriptor>",
@@ -138,4 +145,56 @@
"</database>",
runTorqueXDoclet(TORQUE_DEST_FILE, "ojbtest"));
}
+
+ // Basic test: no attributes, three classes with one a nested class
+ public void testSimple4()
+ {
+ addClass(
+ "test.A",
+ "package test;\n"+
+ "/** @ojb.class */\n"+
+ "public class A {}\n");
+ addClass(
+ "test.B",
+ "package test;\n"+
+ "public class B {\n"+
+ " /** @ojb.class */\n"+
+ " public static class Nested extends A {}\n"+
+ "}\n");
+ addClass(
+ "test.C",
+ "package test;\n"+
+ "/** @ojb.class */\n"+
+ "public class C extends test.B.Nested {}\n");
+
+ assertEqualsOjbDescriptorFile(
+ "<class-descriptor\n"+
+ " class=\"test.A\"\n"+
+ " table=\"A\"\n"+
+ ">\n"+
+ " <extent-class class-ref=\"test.B$Nested\"/>\n"+
+ "</class-descriptor>\n"+
+ "<class-descriptor\n"+
+ " class=\"test.B$Nested\"\n"+
+ " table=\"Nested\"\n"+
+ ">\n"+
+ " <extent-class class-ref=\"test.C\"/>\n"+
+ "</class-descriptor>\n"+
+ "<class-descriptor\n"+
+ " class=\"test.C\"\n"+
+ " table=\"C\"\n"+
+ ">\n"+
+ "</class-descriptor>",
+ runOjbXDoclet(OJB_DEST_FILE));
+ assertEqualsTorqueSchemaFile(
+ "<database name=\"ojbtest\">\n"+
+ " <table name=\"A\">\n"+
+ " </table>\n"+
+ " <table name=\"C\">\n"+
+ " </table>\n"+
+ " <table name=\"Nested\">\n"+
+ " </table>\n"+
+ "</database>",
+ runTorqueXDoclet(TORQUE_DEST_FILE, "ojbtest"));
+ }
}
1.5.2.2 +160 -0
db-ojb/src/xdoclet/test/xdoclet/modules/ojb/tests/CollectionTagElementClassRefAttributeTests.java
Index: CollectionTagElementClassRefAttributeTests.java
===================================================================
RCS file:
/home/cvs/db-ojb/src/xdoclet/test/xdoclet/modules/ojb/tests/CollectionTagElementClassRefAttributeTests.java,v
retrieving revision 1.5.2.1
retrieving revision 1.5.2.2
diff -u -r1.5.2.1 -r1.5.2.2
--- CollectionTagElementClassRefAttributeTests.java 1 Mar 2005 21:54:06
-0000 1.5.2.1
+++ CollectionTagElementClassRefAttributeTests.java 18 Jun 2005 14:16:33
-0000 1.5.2.2
@@ -758,4 +758,164 @@
"</database>",
runTorqueXDoclet(TORQUE_DEST_FILE, taskProps,
torqueSubTaskProps));
}
+
+ // Test: value points to a persistent nested class
+ public void testElementClassRef15()
+ {
+ addClass(
+ "test.A",
+ "package test;\n"+
+ "/** @ojb.class */\n" +
+ "public class A {\n"+
+ " /** @ojb.field primarykey=\"true\" */\n"+
+ " private int id;\n"+
+ " /** @ojb.collection element-class-ref=\"test.B.Inner\"\n"+
+ " * foreignkey=\"aid\"\n"+
+ " */\n"+
+ " private java.util.List attr;\n"+
+ "}");
+ addClass(
+ "test.B",
+ "package test;\n"+
+ "public class B {\n"+
+ " /** @ojb.class */\n"+
+ " public class Inner {\n"+
+ " /** @ojb.field */\n"+
+ " private int aid;\n"+
+ " }\n"+
+ "}\n");
+
+ assertEqualsOjbDescriptorFile(
+ "<class-descriptor\n"+
+ " class=\"test.A\"\n"+
+ " table=\"A\"\n"+
+ ">\n"+
+ " <field-descriptor\n"+
+ " name=\"id\"\n"+
+ " column=\"id\"\n"+
+ " jdbc-type=\"INTEGER\"\n"+
+ " primarykey=\"true\"\n"+
+ " >\n"+
+ " </field-descriptor>\n"+
+ " <collection-descriptor\n"+
+ " name=\"attr\"\n"+
+ " element-class-ref=\"test.B$Inner\"\n"+
+ " >\n"+
+ " <inverse-foreignkey field-ref=\"aid\"/>\n"+
+ " </collection-descriptor>\n"+
+ "</class-descriptor>\n"+
+ "<class-descriptor\n"+
+ " class=\"test.B$Inner\"\n"+
+ " table=\"Inner\"\n"+
+ ">\n"+
+ " <field-descriptor\n"+
+ " name=\"aid\"\n"+
+ " column=\"aid\"\n"+
+ " jdbc-type=\"INTEGER\"\n"+
+ " >\n"+
+ " </field-descriptor>\n"+
+ "</class-descriptor>",
+ runOjbXDoclet(OJB_DEST_FILE));
+ assertEqualsTorqueSchemaFile(
+ "<database name=\"ojbtest\">\n"+
+ " <table name=\"A\">\n"+
+ " <column name=\"id\"\n"+
+ " javaName=\"id\"\n"+
+ " type=\"INTEGER\"\n"+
+ " primaryKey=\"true\"\n"+
+ " required=\"true\"\n"+
+ " />\n"+
+ " </table>\n"+
+ " <table name=\"Inner\">\n"+
+ " <column name=\"aid\"\n"+
+ " javaName=\"aid\"\n"+
+ " type=\"INTEGER\"\n"+
+ " />\n"+
+ " <foreign-key foreignTable=\"A\">\n"+
+ " <reference local=\"aid\" foreign=\"id\"/>\n"+
+ " </foreign-key>\n"+
+ " </table>\n"+
+ "</database>",
+ runTorqueXDoclet(TORQUE_DEST_FILE, "ojbtest"));
+ }
+
+ // Test: value points to a persistent nested class where the reference
uses "$"
+ public void testElementClassRef16()
+ {
+ addClass(
+ "test.A",
+ "package test;\n"+
+ "/** @ojb.class */\n" +
+ "public class A {\n"+
+ " /** @ojb.field primarykey=\"true\" */\n"+
+ " private int id;\n"+
+ " /** @ojb.collection element-class-ref=\"test.B$Inner\"\n"+
+ " * foreignkey=\"aid\"\n"+
+ " */\n"+
+ " private java.util.List attr;\n"+
+ "}");
+ addClass(
+ "test.B",
+ "package test;\n"+
+ "public class B {\n"+
+ " /** @ojb.class */\n"+
+ " public class Inner {\n"+
+ " /** @ojb.field */\n"+
+ " private int aid;\n"+
+ " }\n"+
+ "}\n");
+
+ assertEqualsOjbDescriptorFile(
+ "<class-descriptor\n"+
+ " class=\"test.A\"\n"+
+ " table=\"A\"\n"+
+ ">\n"+
+ " <field-descriptor\n"+
+ " name=\"id\"\n"+
+ " column=\"id\"\n"+
+ " jdbc-type=\"INTEGER\"\n"+
+ " primarykey=\"true\"\n"+
+ " >\n"+
+ " </field-descriptor>\n"+
+ " <collection-descriptor\n"+
+ " name=\"attr\"\n"+
+ " element-class-ref=\"test.B$Inner\"\n"+
+ " >\n"+
+ " <inverse-foreignkey field-ref=\"aid\"/>\n"+
+ " </collection-descriptor>\n"+
+ "</class-descriptor>\n"+
+ "<class-descriptor\n"+
+ " class=\"test.B$Inner\"\n"+
+ " table=\"Inner\"\n"+
+ ">\n"+
+ " <field-descriptor\n"+
+ " name=\"aid\"\n"+
+ " column=\"aid\"\n"+
+ " jdbc-type=\"INTEGER\"\n"+
+ " >\n"+
+ " </field-descriptor>\n"+
+ "</class-descriptor>",
+ runOjbXDoclet(OJB_DEST_FILE));
+ assertEqualsTorqueSchemaFile(
+ "<database name=\"ojbtest\">\n"+
+ " <table name=\"A\">\n"+
+ " <column name=\"id\"\n"+
+ " javaName=\"id\"\n"+
+ " type=\"INTEGER\"\n"+
+ " primaryKey=\"true\"\n"+
+ " required=\"true\"\n"+
+ " />\n"+
+ " </table>\n"+
+ " <table name=\"Inner\">\n"+
+ " <column name=\"aid\"\n"+
+ " javaName=\"aid\"\n"+
+ " type=\"INTEGER\"\n"+
+ " />\n"+
+ " <foreign-key foreignTable=\"A\">\n"+
+ " <reference local=\"aid\" foreign=\"id\"/>\n"+
+ " </foreign-key>\n"+
+ " </table>\n"+
+ "</database>",
+ runTorqueXDoclet(TORQUE_DEST_FILE, "ojbtest"));
+ }
}
1.4.2.2 +1 -1
db-ojb/src/xdoclet/test/xdoclet/modules/ojb/tests/AnonymousFieldTagTests.java
Index: AnonymousFieldTagTests.java
===================================================================
RCS file:
/home/cvs/db-ojb/src/xdoclet/test/xdoclet/modules/ojb/tests/AnonymousFieldTagTests.java,v
retrieving revision 1.4.2.1
retrieving revision 1.4.2.2
diff -u -r1.4.2.1 -r1.4.2.2
--- AnonymousFieldTagTests.java 17 Nov 2004 21:18:16 -0000 1.4.2.1
+++ AnonymousFieldTagTests.java 18 Jun 2005 14:16:33 -0000 1.4.2.2
@@ -37,7 +37,7 @@
"package test;\n"+
"/** @ojb.class\n" +
" * @ojb.field name=\"attr\"\n"+
- " * jdbc-type=\"INTEGER\""+
+ " * jdbc-type=\"INTEGER\"\n"+
" */\n"+
"public class A {}\n");
No revision
No revision
1.5.2.1 +8 -4
db-ojb/src/xdoclet/java/src/xdoclet/modules/ojb/model/ModelDef.java
Index: ModelDef.java
===================================================================
RCS file:
/home/cvs/db-ojb/src/xdoclet/java/src/xdoclet/modules/ojb/model/ModelDef.java,v
retrieving revision 1.5
retrieving revision 1.5.2.1
diff -u -r1.5 -r1.5.2.1
--- ModelDef.java 5 Apr 2004 00:32:31 -0000 1.5
+++ ModelDef.java 18 Jun 2005 14:16:33 -0000 1.5.2.1
@@ -47,18 +47,20 @@
*/
public boolean hasClass(String qualifiedName)
{
- return _classDefs.containsKey(qualifiedName);
+ return _classDefs.containsKey(qualifiedName.replace('$', '.'));
}
/**
- * Returns the class descriptor of the given name contained in this
model.
+ * Returns the class descriptor of the given name contained in this
model. The name can be both
+ * a fully qualified name as per java spec or a classloader-compatible
full name (which uses
+ * '$' for inner/nested classes).
*
* @param qualifiedName The qualified name
* @return The class descriptor or <code>null</code> if there is no such
class in this model
*/
public ClassDescriptorDef getClass(String qualifiedName)
{
- return (ClassDescriptorDef)_classDefs.get(qualifiedName);
+ return (ClassDescriptorDef)_classDefs.get(qualifiedName.replace('$',
'.'));
}
/**
@@ -70,7 +72,9 @@
public void addClass(ClassDescriptorDef classDef)
{
classDef.setOwner(this);
- _classDefs.put(classDef.getName(), classDef);
+ // Regardless of the format of the class name, we're using the fully
qualified format
+ // This is safe because of the package & class naming constraints of
the Java language
+ _classDefs.put(classDef.getQualifiedName(), classDef);
}
/**
1.7.2.2 +26 -2
db-ojb/src/xdoclet/java/src/xdoclet/modules/ojb/model/ClassDescriptorDef.java
Index: ClassDescriptorDef.java
===================================================================
RCS file:
/home/cvs/db-ojb/src/xdoclet/java/src/xdoclet/modules/ojb/model/ClassDescriptorDef.java,v
retrieving revision 1.7.2.1
retrieving revision 1.7.2.2
diff -u -r1.7.2.1 -r1.7.2.2
--- ClassDescriptorDef.java 15 Mar 2005 23:58:30 -0000 1.7.2.1
+++ ClassDescriptorDef.java 18 Jun 2005 14:16:33 -0000 1.7.2.2
@@ -25,7 +25,7 @@
/**
* Definition of a class for the ojb repository file.
*
- * @author <a href="mailto:[EMAIL PROTECTED]">Thomas Dudziak ([EMAIL
PROTECTED])</a>
+ * @author <a href="mailto:[EMAIL PROTECTED]">Thomas Dudziak</a>
*/
public class ClassDescriptorDef extends DefBase
{
@@ -64,7 +64,7 @@
*/
public ClassDescriptorDef(XClass origin)
{
- super(origin.getQualifiedName());
+ super(origin.getTransformedQualifiedName());
_origin = origin;
}
@@ -79,6 +79,30 @@
}
/**
+ * Returns the qualified name of this class as per Java spec.
+ *
+ * @return The qualified name
+ */
+ public String getQualifiedName()
+ {
+ return getName().replace('$', '.');
+ }
+
+ /**
+ * Returns the default table name for this class which is the
unqualified class name.
+ *
+ * @return The default table name
+ */
+ public String getDefaultTableName()
+ {
+ String name = getName();
+ int lastDotPos = name.lastIndexOf('.');
+ int lastDollarPos = name.lastIndexOf('$');
+
+ return lastDollarPos > lastDotPos ? name.substring(lastDollarPos +
1) : name.substring(lastDotPos + 1);
+ }
+
+ /**
* Determines whether this class descriptor has been processed.
*
* @return <code>true</code> if this class descriptor has been processed
1.6.2.8 +7 -4
db-ojb/src/xdoclet/java/src/xdoclet/modules/ojb/model/TorqueModelDef.java
Index: TorqueModelDef.java
===================================================================
RCS file:
/home/cvs/db-ojb/src/xdoclet/java/src/xdoclet/modules/ojb/model/TorqueModelDef.java,v
retrieving revision 1.6.2.7
retrieving revision 1.6.2.8
diff -u -r1.6.2.7 -r1.6.2.8
--- TorqueModelDef.java 17 Mar 2005 23:49:10 -0000 1.6.2.7
+++ TorqueModelDef.java 18 Jun 2005 14:16:33 -0000 1.6.2.8
@@ -210,7 +210,8 @@
// local fields = foreignkey fields of the reference
// remote fields = primarykeys of the referenced type
ClassDescriptorDef ownerClassDef =
(ClassDescriptorDef)refDef.getOwner();
- ClassDescriptorDef referencedClassDef =
((ModelDef)ownerClassDef.getOwner()).getClass(refDef.getProperty(PropertyHelper.OJB_PROPERTY_CLASS_REF));
+ String targetClassName =
refDef.getProperty(PropertyHelper.OJB_PROPERTY_CLASS_REF);
+ ClassDescriptorDef referencedClassDef =
((ModelDef)ownerClassDef.getOwner()).getClass(targetClassName);
// we can add a foreignkey only if the target type and all its
subtypes either
// map to the same table or do not map to a table at all
@@ -255,8 +256,9 @@
// remote table = table of collection owner
// local fields = foreignkey fields in the element type
// remote fields = primarykeys of the collection owner type
- ClassDescriptorDef ownerClassDef =
(ClassDescriptorDef)collDef.getOwner();
- ClassDescriptorDef elementClassDef =
((ModelDef)ownerClassDef.getOwner()).getClass(collDef.getProperty(PropertyHelper.OJB_PROPERTY_ELEMENT_CLASS_REF));
+ ClassDescriptorDef ownerClassDef =
(ClassDescriptorDef)collDef.getOwner();
+ String elementClassName =
collDef.getProperty(PropertyHelper.OJB_PROPERTY_ELEMENT_CLASS_REF);
+ ClassDescriptorDef elementClassDef =
((ModelDef)ownerClassDef.getOwner()).getClass(elementClassName);
// we can only generate foreignkeys if the collection itself is not
shared by
// several classes in the hierarchy
@@ -543,7 +545,8 @@
// remote columns = columns of corresponding primarykeys in
ownerclass/elementclass
ClassDescriptorDef ownerClassDef =
(ClassDescriptorDef)collDef.getOwner();
ModelDef modelDef =
(ModelDef)ownerClassDef.getOwner();
- ClassDescriptorDef elementClassDef =
modelDef.getClass(collDef.getProperty(PropertyHelper.OJB_PROPERTY_ELEMENT_CLASS_REF));
+ String elementClassName =
collDef.getProperty(PropertyHelper.OJB_PROPERTY_ELEMENT_CLASS_REF);
+ ClassDescriptorDef elementClassDef =
modelDef.getClass(elementClassName);
ArrayList localPrimFields = ownerClassDef.getPrimaryKeys();
ArrayList remotePrimFields =
elementClassDef.getPrimaryKeys();
String localKeyList =
collDef.getProperty(PropertyHelper.OJB_PROPERTY_FOREIGNKEY);
1.5.2.3 +7 -6
db-ojb/src/xdoclet/java/src/xdoclet/modules/ojb/model/CollectionDescriptorDef.java
Index: CollectionDescriptorDef.java
===================================================================
RCS file:
/home/cvs/db-ojb/src/xdoclet/java/src/xdoclet/modules/ojb/model/CollectionDescriptorDef.java,v
retrieving revision 1.5.2.2
retrieving revision 1.5.2.3
diff -u -r1.5.2.2 -r1.5.2.3
--- CollectionDescriptorDef.java 16 Mar 2005 23:54:33 -0000 1.5.2.2
+++ CollectionDescriptorDef.java 18 Jun 2005 14:16:33 -0000 1.5.2.3
@@ -58,12 +58,13 @@
{
return null;
}
- ModelDef modelDef =
(ModelDef)getOwner().getOwner();
- ClassDescriptorDef elementClass =
modelDef.getClass(getProperty(PropertyHelper.OJB_PROPERTY_ELEMENT_CLASS_REF));
- String indirTable =
getProperty(PropertyHelper.OJB_PROPERTY_INDIRECTION_TABLE);
- boolean hasRemoteKey =
hasProperty(PropertyHelper.OJB_PROPERTY_REMOTE_FOREIGNKEY);
- String remoteKey =
getProperty(PropertyHelper.OJB_PROPERTY_REMOTE_FOREIGNKEY);
- CollectionDescriptorDef remoteCollDef = null;
+ ModelDef modelDef =
(ModelDef)getOwner().getOwner();
+ String elementClassName =
getProperty(PropertyHelper.OJB_PROPERTY_ELEMENT_CLASS_REF);
+ ClassDescriptorDef elementClass =
modelDef.getClass(elementClassName);
+ String indirTable =
getProperty(PropertyHelper.OJB_PROPERTY_INDIRECTION_TABLE);
+ boolean hasRemoteKey =
hasProperty(PropertyHelper.OJB_PROPERTY_REMOTE_FOREIGNKEY);
+ String remoteKey =
getProperty(PropertyHelper.OJB_PROPERTY_REMOTE_FOREIGNKEY);
+ CollectionDescriptorDef remoteCollDef = null;
// find the collection in the element class that has the same
indirection table
for (Iterator it = elementClass.getCollections(); it.hasNext();)
No revision
No revision
1.5.2.3 +1 -3
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.2.2
retrieving revision 1.5.2.3
diff -u -r1.5.2.2 -r1.5.2.3
--- ClassDescriptorConstraints.java 22 Mar 2005 21:38:17 -0000 1.5.2.2
+++ ClassDescriptorConstraints.java 18 Jun 2005 14:16:33 -0000 1.5.2.3
@@ -209,9 +209,7 @@
{
if (!classDef.hasProperty(PropertyHelper.OJB_PROPERTY_TABLE))
{
- String name = classDef.getName();
-
- classDef.setProperty(PropertyHelper.OJB_PROPERTY_TABLE,
name.substring(name.lastIndexOf('.') + 1));
+ classDef.setProperty(PropertyHelper.OJB_PROPERTY_TABLE,
classDef.getDefaultTableName());
}
}
}
1.3.2.1 +8 -6
db-ojb/src/xdoclet/java/src/xdoclet/modules/ojb/constraints/InheritanceHelper.java
Index: InheritanceHelper.java
===================================================================
RCS file:
/home/cvs/db-ojb/src/xdoclet/java/src/xdoclet/modules/ojb/constraints/InheritanceHelper.java,v
retrieving revision 1.3
retrieving revision 1.3.2.1
diff -u -r1.3 -r1.3.2.1
--- InheritanceHelper.java 5 Apr 2004 00:32:30 -0000 1.3
+++ InheritanceHelper.java 18 Jun 2005 14:16:33 -0000 1.3.2.1
@@ -57,7 +57,9 @@
*/
public boolean isSameOrSubTypeOf(XClass type, String baseType, boolean
checkActualClasses) throws ClassNotFoundException
{
- if (type.getQualifiedName().equals(baseType))
+ String qualifiedBaseType = baseType.replace('$', '.');
+
+ if (type.getQualifiedName().equals(qualifiedBaseType))
{
return true;
}
@@ -72,7 +74,7 @@
{
curType = (XClass)queue.get(0);
queue.remove(0);
- if (baseType.equals(curType.getQualifiedName()))
+ if (qualifiedBaseType.equals(curType.getQualifiedName()))
{
return true;
}
@@ -93,7 +95,7 @@
}
// if not found, we try via actual classes
- return checkActualClasses ? isSameOrSubTypeOf(type.getName(),
baseType) : false;
+ return checkActualClasses ? isSameOrSubTypeOf(type.getName(),
qualifiedBaseType) : false;
}
/**
@@ -107,7 +109,7 @@
*/
public boolean isSameOrSubTypeOf(ClassDescriptorDef type, String
baseType, boolean checkActualClasses) throws ClassNotFoundException
{
- if (type.getName().equals(baseType))
+ if (type.getQualifiedName().equals(baseType.replace('$', '.')))
{
return true;
}
@@ -131,7 +133,7 @@
*/
public boolean isSameOrSubTypeOf(String type, String baseType) throws
ClassNotFoundException
{
- return type.equals(baseType) ? true :
isSameOrSubTypeOf(getClass(type), baseType);
+ return type.replace('$', '.').equals(baseType.replace('$', '.')) ?
true : isSameOrSubTypeOf(getClass(type), baseType);
}
/**
@@ -144,6 +146,6 @@
*/
public boolean isSameOrSubTypeOf(Class type, String baseType) throws
ClassNotFoundException
{
- return type.getName().equals(baseType) ? true :
getClass(baseType).isAssignableFrom(type);
+ return type.getName().equals(baseType.replace('$', '.')) ? true :
getClass(baseType).isAssignableFrom(type);
}
}
1.4.2.2 +4 -1
db-ojb/src/xdoclet/java/src/xdoclet/modules/ojb/constraints/CollectionDescriptorConstraints.java
Index: CollectionDescriptorConstraints.java
===================================================================
RCS file:
/home/cvs/db-ojb/src/xdoclet/java/src/xdoclet/modules/ojb/constraints/CollectionDescriptorConstraints.java,v
retrieving revision 1.4.2.1
retrieving revision 1.4.2.2
diff -u -r1.4.2.1 -r1.4.2.2
--- CollectionDescriptorConstraints.java 16 Mar 2005 23:54:34 -0000
1.4.2.1
+++ CollectionDescriptorConstraints.java 18 Jun 2005 14:16:33 -0000
1.4.2.2
@@ -113,6 +113,8 @@
throw new ConstraintException("Could not find the class
"+ex.getMessage()+" on the classpath while checking the collection
"+collDef.getName()+" in class "+collDef.getOwner().getName());
}
}
+ // we're adjusting the property to use the classloader-compatible
form
+ collDef.setProperty(PropertyHelper.OJB_PROPERTY_ELEMENT_CLASS_REF,
elementClassDef.getName());
}
/**
@@ -237,7 +239,8 @@
}
ClassDescriptorDef ownerClass =
(ClassDescriptorDef)collDef.getOwner();
- ClassDescriptorDef elementClass =
((ModelDef)ownerClass.getOwner()).getClass(collDef.getProperty(PropertyHelper.OJB_PROPERTY_ELEMENT_CLASS_REF));
+ String elementClassName =
collDef.getProperty(PropertyHelper.OJB_PROPERTY_ELEMENT_CLASS_REF).replace('$',
'.');
+ ClassDescriptorDef elementClass =
((ModelDef)ownerClass.getOwner()).getClass(elementClassName);
FieldDescriptorDef fieldDef;
String token;
String fieldName;
1.4.2.1 +3 -1
db-ojb/src/xdoclet/java/src/xdoclet/modules/ojb/constraints/ReferenceDescriptorConstraints.java
Index: ReferenceDescriptorConstraints.java
===================================================================
RCS file:
/home/cvs/db-ojb/src/xdoclet/java/src/xdoclet/modules/ojb/constraints/ReferenceDescriptorConstraints.java,v
retrieving revision 1.4
retrieving revision 1.4.2.1
diff -u -r1.4 -r1.4.2.1
--- ReferenceDescriptorConstraints.java 5 Apr 2004 00:32:30 -0000
1.4
+++ ReferenceDescriptorConstraints.java 18 Jun 2005 14:16:33 -0000
1.4.2.1
@@ -73,7 +73,7 @@
ModelDef model =
(ModelDef)ownerClassDef.getOwner();
String targetClassName =
refDef.getProperty(PropertyHelper.OJB_PROPERTY_CLASS_REF);
ClassDescriptorDef targetClassDef = model.getClass(targetClassName);
-
+
if (targetClassDef == null)
{
throw new ConstraintException("The class "+targetClassName+"
referenced by "+refDef.getName()+" in class "+ownerClassDef.getName()+" is
unknown or not persistent");
@@ -113,5 +113,7 @@
throw new ConstraintException("Could not find the class
"+ex.getMessage()+" on the classpath while checking the reference
"+refDef.getName()+" in class "+refDef.getOwner().getName());
}
}
+ // we're adjusting the property to use the classloader-compatible
form
+ refDef.setProperty(PropertyHelper.OJB_PROPERTY_CLASS_REF,
targetClassDef.getName());
}
}
1.6.2.6 +32 -21
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.5
retrieving revision 1.6.2.6
diff -u -r1.6.2.5 -r1.6.2.6
--- ModelConstraints.java 16 Mar 2005 23:54:34 -0000 1.6.2.5
+++ ModelConstraints.java 18 Jun 2005 14:16:33 -0000 1.6.2.6
@@ -107,7 +107,8 @@
*/
private void ensureReferencedPKs(ModelDef modelDef,
ReferenceDescriptorDef refDef) throws ConstraintException
{
- ClassDescriptorDef targetClassDef =
modelDef.getClass(refDef.getProperty(PropertyHelper.OJB_PROPERTY_CLASS_REF));
+ String targetClassName =
refDef.getProperty(PropertyHelper.OJB_PROPERTY_CLASS_REF);
+ ClassDescriptorDef targetClassDef =
modelDef.getClass(targetClassName);
ensurePKsFromHierarchy(targetClassDef);
}
@@ -122,7 +123,8 @@
*/
private void ensureReferencedPKs(ModelDef modelDef,
CollectionDescriptorDef collDef) throws ConstraintException
{
- ClassDescriptorDef elementClassDef =
modelDef.getClass(collDef.getProperty(PropertyHelper.OJB_PROPERTY_ELEMENT_CLASS_REF));
+ String elementClassName =
collDef.getProperty(PropertyHelper.OJB_PROPERTY_ELEMENT_CLASS_REF);
+ ClassDescriptorDef elementClassDef =
modelDef.getClass(elementClassName);
String indirTable =
collDef.getProperty(PropertyHelper.OJB_PROPERTY_INDIRECTION_TABLE);
String localKey =
collDef.getProperty(PropertyHelper.OJB_PROPERTY_FOREIGNKEY);
String remoteKey =
collDef.getProperty(PropertyHelper.OJB_PROPERTY_REMOTE_FOREIGNKEY);
@@ -195,10 +197,11 @@
*/
private void ensureReferencedFKs(ModelDef modelDef,
CollectionDescriptorDef collDef) throws ConstraintException
{
- ClassDescriptorDef elementClassDef =
modelDef.getClass(collDef.getProperty(PropertyHelper.OJB_PROPERTY_ELEMENT_CLASS_REF));
- String fkFieldNames =
collDef.getProperty(PropertyHelper.OJB_PROPERTY_FOREIGNKEY);
- ArrayList missingFields = new ArrayList();
- SequencedHashMap fkFields = new SequencedHashMap();
+ String elementClassName =
collDef.getProperty(PropertyHelper.OJB_PROPERTY_ELEMENT_CLASS_REF);
+ ClassDescriptorDef elementClassDef =
modelDef.getClass(elementClassName);
+ String fkFieldNames =
collDef.getProperty(PropertyHelper.OJB_PROPERTY_FOREIGNKEY);
+ ArrayList missingFields = new ArrayList();
+ SequencedHashMap fkFields = new SequencedHashMap();
// first we gather all field names
for (CommaListIterator it = new CommaListIterator(fkFieldNames);
it.hasNext();)
@@ -412,8 +415,9 @@
// we know that the class is present because the collection
constraints have been checked already
// TODO: we must check whether there is a collection at the other
side; if the type does not map to a
// table then we have to check its subtypes
- ClassDescriptorDef elementClass =
modelDef.getClass(collDef.getProperty(PropertyHelper.OJB_PROPERTY_ELEMENT_CLASS_REF));
- CollectionDescriptorDef remoteCollDef =
collDef.getRemoteCollection();
+ String elementClassName =
collDef.getProperty(PropertyHelper.OJB_PROPERTY_ELEMENT_CLASS_REF);
+ ClassDescriptorDef elementClass =
modelDef.getClass(elementClassName);
+ CollectionDescriptorDef remoteCollDef =
collDef.getRemoteCollection();
if (remoteCollDef == null)
{
@@ -497,9 +501,10 @@
throw new ConstraintException("The collection
"+collDef.getName()+" in class "+collDef.getOwner().getName()+" has no
foreignkeys");
}
- ClassDescriptorDef ownerClass =
(ClassDescriptorDef)collDef.getOwner();
- ArrayList primFields = ownerClass.getPrimaryKeys();
- ArrayList queue = new ArrayList();
+ ClassDescriptorDef ownerClass =
(ClassDescriptorDef)collDef.getOwner();
+ ArrayList primFields = ownerClass.getPrimaryKeys();
+ String elementClassName =
collDef.getProperty(PropertyHelper.OJB_PROPERTY_ELEMENT_CLASS_REF);
+ ArrayList queue = new ArrayList();
ClassDescriptorDef elementClass;
ArrayList keyFields;
FieldDescriptorDef keyField;
@@ -508,7 +513,7 @@
String keyType;
// we know that the class is present because the collection
constraints have been checked already
-
queue.add(modelDef.getClass(collDef.getProperty(PropertyHelper.OJB_PROPERTY_ELEMENT_CLASS_REF)));
+ queue.add(modelDef.getClass(elementClassName));
while (!queue.isEmpty())
{
elementClass = (ClassDescriptorDef)queue.get(0);
@@ -633,14 +638,15 @@
// for the referenced class and any subtype that is instantiable
(i.e. not an interface or abstract class)
// there must be the same number of primary keys and the jdbc types
of the primary keys must
// match the jdbc types of the foreignkeys (in the correct order)
- ArrayList queue = new ArrayList();
+ String targetClassName =
refDef.getProperty(PropertyHelper.OJB_PROPERTY_CLASS_REF);
+ ArrayList queue = new ArrayList();
ClassDescriptorDef referencedClass;
ArrayList primFields;
FieldDescriptorDef primField;
String primType;
String keyType;
-
queue.add(modelDef.getClass(refDef.getProperty(PropertyHelper.OJB_PROPERTY_CLASS_REF)));
+ queue.add(modelDef.getClass(targetClassName));
while (!queue.isEmpty())
{
@@ -800,20 +806,23 @@
*/
private CollectionDescriptorDef usedByCollection(ModelDef modelDef,
FieldDescriptorDef fieldDef, boolean elementClassSuffices)
{
- ClassDescriptorDef ownerClass =
(ClassDescriptorDef)fieldDef.getOwner();
- String name = fieldDef.getName();
+ ClassDescriptorDef ownerClass =
(ClassDescriptorDef)fieldDef.getOwner();
+ String ownerClassName =
ownerClass.getQualifiedName();
+ String name = fieldDef.getName();
ClassDescriptorDef classDef;
CollectionDescriptorDef collDef;
+ String elementClassName;
for (Iterator classIt = modelDef.getClasses(); classIt.hasNext();)
{
classDef = (ClassDescriptorDef)classIt.next();
for (Iterator collIt = classDef.getCollections();
collIt.hasNext();)
{
- collDef = (CollectionDescriptorDef)collIt.next();
+ collDef = (CollectionDescriptorDef)collIt.next();
+ elementClassName =
collDef.getProperty(PropertyHelper.OJB_PROPERTY_ELEMENT_CLASS_REF).replace('$',
'.');
// if the owner class of the field is the element class of a
normal collection
// and the field is a foreignkey of this collection
- if
(ownerClass.getName().equals(collDef.getProperty(PropertyHelper.OJB_PROPERTY_ELEMENT_CLASS_REF)))
+ if (ownerClassName.equals(elementClassName))
{
if
(collDef.hasProperty(PropertyHelper.OJB_PROPERTY_INDIRECTION_TABLE))
{
@@ -843,9 +852,10 @@
*/
private ReferenceDescriptorDef usedByReference(ModelDef modelDef,
FieldDescriptorDef fieldDef)
{
- String ownerClassName =
fieldDef.getOwner().getName();
+ String ownerClassName =
((ClassDescriptorDef)fieldDef.getOwner()).getQualifiedName();
ClassDescriptorDef classDef;
ReferenceDescriptorDef refDef;
+ String targetClassName;
// only relevant for primarykey fields
if
(PropertyHelper.toBoolean(fieldDef.getProperty(PropertyHelper.OJB_PROPERTY_PRIMARYKEY),
false))
@@ -855,8 +865,9 @@
classDef = (ClassDescriptorDef)classIt.next();
for (Iterator refIt = classDef.getReferences();
refIt.hasNext();)
{
- refDef = (ReferenceDescriptorDef)refIt.next();
- if
(ownerClassName.equals(refDef.getProperty(PropertyHelper.OJB_PROPERTY_CLASS_REF)))
+ refDef = (ReferenceDescriptorDef)refIt.next();
+ targetClassName =
refDef.getProperty(PropertyHelper.OJB_PROPERTY_CLASS_REF).replace('$', '.');
+ if (ownerClassName.equals(targetClassName))
{
// the field is a primary key of the class
referenced by this reference descriptor
return refDef;
No revision
No revision
1.1.2.2 +277 -246 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]