db-ojb-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Oliver Matz <oliver.m...@ppi.de>
Subject [OJB] Issue #OJB153 - NPE in TransactionImpl.assertFkAssignment (Null references a...
Date Mon, 31 Mar 2003 16:59:58 GMT
You can view the issue detail at the following URL:
<http://scarab.werken.com/scarab/issues/id/OJB153>

Type :        Defect
Issue Id :    OJB153
Reported by: Oliver Matz
             oliverm - (oliver.matz@ppi.de)

Details:

Platform: All
Operating system: windows 2000
Summary: NPE in TransactionImpl.assertFkAssignment (Null references and proxies)
Description: Suppose class A has a proxy reference b of type B.  Suppose that the database
schema does not have a foreign key constraint for the corresponding columns.  

If an instance a of class A is retrieved from the database and there is no corresponding B
value, then the a.b will be instatiated as a virtual proxy, and the first access to a field
might result in a NullPointerException.  

First variant where this happens is when Transaction.lock(a, ...) is called.  Stacktrace:

java.lang.NullPointerException	at
org.apache.ojb.odmg.TransactionImpl.assertFkAssignment(TransactionImpl.java:812)	at
org.apache.ojb.odmg.TransactionImpl.assignReferenceFKs(TransactionImpl.java:853)	at
org.apache.ojb.odmg.TransactionImpl.lock(TransactionImpl.java:260)

Second variant:

A getter is called. Stacktrace:
at org.apache.ojb.broker.accesslayer.IndirectionHandler.invoke(IndirectionHandler.java:256)
	at $Proxy0.getName(Unknown Source)
	at org.apache.ojb.broker.AbstractArticle.toString(AbstractArticle.java:10)
	at java.lang.String.valueOf(String.java:2177)
	at java.lang.StringBuffer.append(StringBuffer.java:361)
	at org.apache.ojb.odmg.NullProxyTest.testWithNullAccess(NullProxyTest.java:92)

A potential fix, which solves the first variant, is attached.  

Writing a test-case for this problem requires to introduce new tables in the junit datbase
schema, because currently the above situation cannot be established due to integrity constaints.
 See attached file NullProxyTest.java
Status: Unconfirmed


Mime
View raw message