You are viewing a plain text version of this content. The canonical link for it is here.
Posted to ojb-dev@db.apache.org by th...@apache.org on 2003/04/11 23:00:01 UTC
cvs commit: db-ojb/src/jdori/org/apache/ojb/jdori/sql OjbFieldManager.java
thma 2003/04/11 14:00:01
Modified: src/jdori/org/apache/ojb/jdori/sql OjbFieldManager.java
Log:
fix problem in field-manager
Revision Changes Path
1.2 +18 -4 db-ojb/src/jdori/org/apache/ojb/jdori/sql/OjbFieldManager.java
Index: OjbFieldManager.java
===================================================================
RCS file: /home/cvs/db-ojb/src/jdori/org/apache/ojb/jdori/sql/OjbFieldManager.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- OjbFieldManager.java 24 Dec 2002 12:06:01 -0000 1.1
+++ OjbFieldManager.java 11 Apr 2003 21:00:01 -0000 1.2
@@ -57,8 +57,8 @@
import javax.jdo.spi.PersistenceCapable;
import org.apache.ojb.broker.PersistenceBroker;
+import org.apache.ojb.broker.metadata.AttributeDescriptorBase;
import org.apache.ojb.broker.metadata.ClassDescriptor;
-import org.apache.ojb.broker.metadata.FieldDescriptor;
import com.sun.jdori.FieldManager;
import com.sun.jdori.common.model.jdo.RuntimeJDOModelFactoryImpl;
@@ -304,14 +304,28 @@
return attributeName;
}
+ /**
+ * retrieve the value of attribute[fieldNum] from the object.
+ * @return Object the value of attribute[fieldNum]
+ */
Object getValue(int fieldNum)
{
String attributeName = getAttributeName(fieldNum);
-
ClassDescriptor cld = broker.getClassDescriptor(pc.getClass());
- FieldDescriptor fld = cld.getFieldDescriptorByName(attributeName);
+
+ // field could a primitive typed attribute...
+ AttributeDescriptorBase fld = cld.getFieldDescriptorByName(attributeName);
+ // field could a reference attribute...
+ if (fld == null)
+ {
+ fld = cld.getObjectReferenceDescriptorByName(attributeName);
+ }
+ // or it could be a collection attribute:
+ if (fld == null)
+ {
+ fld = cld.getCollectionDescriptorByName(attributeName);
+ }
Object value = fld.getPersistentField().get(pc);
return value;
}
-
}