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/04 22:07:02 UTC
cvs commit: db-ojb/src/java/org/apache/ojb/odmg TransactionImpl.java
thma 2003/04/04 12:07:02
Modified: src/java/org/apache/ojb/odmg TransactionImpl.java
Log:
OJB152 fixed: check in Oliver Matz's patch
Revision Changes Path
1.39 +20 -6 db-ojb/src/java/org/apache/ojb/odmg/TransactionImpl.java
Index: TransactionImpl.java
===================================================================
RCS file: /home/cvs/db-ojb/src/java/org/apache/ojb/odmg/TransactionImpl.java,v
retrieving revision 1.38
retrieving revision 1.39
diff -u -r1.38 -r1.39
--- TransactionImpl.java 25 Mar 2003 12:03:10 -0000 1.38
+++ TransactionImpl.java 4 Apr 2003 20:07:02 -0000 1.39
@@ -94,6 +94,7 @@
import java.util.Hashtable;
import java.util.Iterator;
import java.util.Vector;
+import java.util.Arrays;
//#ifdef JDK13
import java.lang.reflect.Proxy;
@@ -461,7 +462,7 @@
}
if (t instanceof LockNotGrantedException)
{
- throw (LockNotGrantedException) t;
+ throw (LockNotGrantedException) t;
}
else
{
@@ -767,6 +768,8 @@
}
// no Proxy:
+ if (objectToRegister == null)
+ return;
ObjectEnvelope envelope = objectEnvelopeTable.getByIdentity(new Identity(objectToRegister, getBroker()));
if ((envelope == null) || envelope.needsDelete())
{
@@ -820,11 +823,22 @@
refInstance = ih.getRealSubject();
}
- ClassDescriptor refCld = this.getBroker().getClassDescriptor(refInstance.getClass());
- Object[] refPkValues = getBroker().serviceBrokerHelper().getKeyValues(refCld, refInstance, false);
-
ClassDescriptor objCld = this.getBroker().getClassDescriptor(obj.getClass());
org.apache.ojb.broker.metadata.FieldDescriptor[] objFkFields = rds.getForeignKeyFieldDescriptors(objCld);
+
+ // oma: refInstance might be null in case of dangling foreign keys.
+ Object[] refPkValues;
+ if (refInstance != null)
+ {
+ ClassDescriptor refCld = this.getBroker().getClassDescriptor(refInstance.getClass());
+ refPkValues = getBroker().serviceBrokerHelper().getKeyValues(refCld, refInstance, false);
+ }
+ else
+ {
+ refPkValues = new Object[objFkFields.length];
+ Arrays.fill(refPkValues, null);
+ }
+
/**
* MBAIRD:
* objFkFields could end up being null in case of non-mapped indirection table of m:n relationship
@@ -1144,4 +1158,4 @@
useWriteLocks = odmgConfig.lockAssociationAsWrites();
useImplicitLocking = odmgConfig.useImplicitLocking();
}
-}
+}
\ No newline at end of file