Hello,

I am using OJB 0.9.8 and I am comparing the PersistenceBroker API to the
ODMG API.

I think I have encountered a bug. 

I have a class NodeOJB which has a reference to itsself.  The primary key
field is of type long,
and I have written a FieldConversion to BigDecimal. (see code snipplets at
the bottom.)

I can store instances of this class with the PersistenceBroker API, but I
get the following
exception when I use the ODMG API:

java.lang.IllegalArgumentException
        at
sun.reflect.UnsafeLongFieldAccessorImpl.set(UnsafeLongFieldAccessorImpl.java
:84)
        at java.lang.reflect.Field.set(Field.java:519)
        at
org.apache.ojb.broker.metadata.fieldaccess.PersistentFieldDefaultImpl.set(Pe
rsistentFieldDefaultImpl.java:146)
        at
org.apache.ojb.odmg.TransactionImpl.assertFkAssignment(TransactionImpl.java:
806)
        at
org.apache.ojb.odmg.TransactionImpl.assignReferenceFKs(TransactionImpl.java:
831)
        at
org.apache.ojb.odmg.TransactionImpl.lock(TransactionImpl.java:250)

I have debugged into the code and found out that the problem can be fixed
with the following  two
modifications in Identity.<init> and TransactionImpl.lockCollections(),
respectively.

But I think this solution is sub-optimal.  A better solution would be to
factor out
common code from the methods 
PersistenceBrokerImpl.assertFKAssignment() (which is used during
PersistenceProker.store()) and
odmg.TransactionImpl.assertFKAssignment()  (which is used during
odmg.Transaction.lock())

What do you think?

Oliver

------------------
U:\or-mappers\ojb\jakarta-ojb-0.9.8>diff
src\java\org\apache\ojb\broker\Identity.java
..\ojb-0.9.8-orig\src\java\org\apache\ojb\broker\Identity.java
144c144
<                 this.pkValues = cld.getKeyValues(objectToIdentitify,
false); 
---
>                 this.pkValues = cld.getKeyValues(objectToIdentitify);
405c405
< }
------------------
U:\or-mappers\ojb\jakarta-ojb-0.9.8>diff
src\java\org\apache\ojb\odmg\TransactionImpl.java
..\ojb-0.9.8-orig\src\java\org\apache\ojb\odmg\TransactionImpl.java
873c873
<                 Object[] objPkValues = cld.getKeyValues(newTxObject,
false); 
---
>                 Object[] objPkValues = cld.getKeyValues(newTxObject);
------------------

class NodeOJB
{
  long uid;
  NodeOJB rootNode;
  long rootNode_refid;
  ...
}

<class-descriptor class="de.ppi.neuwerk.repman.persistent.ojb.NodeOjb"
table="NODE">
...
<field-descriptor id="1" name="uid" column="UID" autoincrement="true"
primarykey="true" 
                        jdbc-type="NUMERIC"
conversion="LongToBigDecimalConversion" />
<field-descriptor id="5" name="rootNode_refid" column="ROOTNODE_FK" 
                        jdbc-type="NUMERIC"
conversion="LongToBigDecimalConversion"
/>
...
</class-descriptor>

-- 
  Dr. Oliver Matz
  ppi Media GmbH
  Deliusstra�e 10
  D-24114 Kiel
  phone +49 (0) 43 1-53 53-422
  fax           +49 (0) 43 1-53 53-2 22
  email mailto:[EMAIL PROTECTED]
  web   www.ppi.de



--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to