I found a fix for the problem. It's not an OJB bug. I changed the PK(and
FK) types in the classes from Long to Integer. Everything seems to work
OK now. It is still strange to me that it worked in some cases but not
in others and that's why I didn't suspect a data type problem initially.
It was also strange that the failure occurred at different iterations of
the loop sometimes. It seems that pushing to the db wasn't a problem.
The problem surfaced when OJB tries to populate the classes from the
DB(I think). Maybe it worked in some cases which OJB got the data from
cache instead of the DB. I say this because I put some println's in the
data retrieval code of OJB and noticed that they were only printed on
the failing loop iteration. That leads me to believe that the successful
iterations may have been loaded from cache instead of the db.

Cheers,
Ken

On Sun, 2003-02-02 at 08:43, Ken Brewer wrote:
> Everything is there in the original email. Scroll below the stack trace
> or search for '**** PERSISTENT CLASS UNIT'. You may want to try it with
> many different loop settings because it may behave differently at
> different CPU/Mem combinations.
> 
> On Sun, 2003-02-02 at 09:27, Thomas Mahler wrote:
> > Hi Ken,
> > 
> > As I was concerned that your report might reveal a severe bug
> > I rewrote your testcase against classes we have already in our 
> > testsuite. Here is the code:
> >      public void testMassOperations()
> >      {
> >          for (int i = 100; i < 200; i++)
> >          {
> >              broker.beginTransaction();
> >              ProductGroup pg = new ProductGroup();
> >              pg.setId(i);
> >              pg.setGroupName("1-1 test productgroup " + i);
> >              broker.store(pg);
> >              broker.commitTransaction();
> >          }
> >          for (int i = 100; i < 200; i++)
> >          {
> >              broker.beginTransaction();
> >              Article article = Article.createInstance();
> >              article.setArticleId(i);
> >              article.setArticleName("1-1 test article " + i);
> >              article.setProductGroupId(i);
> >              broker.retrieveReference(article, "productGroup");
> >              broker.store(article);
> >              broker.commitTransaction();
> >          }
> >      }
> > 
> > I tested it several times with 100 iterations. This test does *not* fail!
> > IMO this indicates that there is no bug in the tested OJB functionality.
> > I assume there is something wrong in your mapping repository.
> > Please post the code of your persistent classes Payee and Unit and the 
> > respective class-descriptors from the repository.xml.
> > 
> > cheers,
> > Thomas
> > 
> > 
> > Ken Brewer wrote:
> > > This is a very strange concerning problem and I think it may be a SEVERE
> > > BUG. This post is long but I've tried to include everything necessary to
> > > reproduce the problem. It was very difficult to craft the test code to
> > > reproduce the problem because it's very erratic.
> > > 
> > > I'm trying to import my test data from flat text files and so I'm
> > > populating foreign keys rather than the objects themselves then calling
> > > PersistenceBroker.retrieveReference(?,?). I'm importing each class of
> > > objects from flat text files one file at a time. The text files contain
> > > the foreign keys and the objects are populated with them. In other
> > > words, I'm not traversing the object graph from top to bottom while
> > > importing but setting the foreign keys such that, after all data is
> > > imported, OJB should have no problem materializing the object graph. The
> > > database was generated by OJB using the autobuild=true property in
> > > OJB.properties. I don't think this problem is related to data contraints
> > > in any way. These are all simple 1:1 associations.
> > > 
> > > I've pasted in all the code etc below necessary to reproduce the
> > > problem.
> > > 
> > > Thanks for your help in advance,
> > > 
> > > -Ken
> > > 
> > > ****THE TEST CODE TO REPRODUCE THE PROBLEM
> > > ****IMPORTANT NOTE****
> > > THE LOOP COUNTERS ARE AT 44. ALL DATA IS IMPORTED SUCCESSFULLY IF
> > > COUNTERS ARE <41. BETWEEN 41 AND 51 It FAILS SOMETIMES. >51 IT ALWAYS
> > > FAILS. IF THE LOOP IS MADE INTO ONE LOOP INSTEAD OF TWO, BY COMMENTING
> > > THE TWO LINES BELOW STARTING WITH ****, THEN IT ALWAYS WORKS, EVEN AT
> > > 100 LOOPS! WHEN IT FAILS, IT FAILS AT THE LINE MARKED ****FAILS.
> > > 
> > >     public void test() {        
> > >         try {
> > >             for (int i = 1; i < 44; i++) {
> > >                 db.beginTransaction();
> > >                 Payee payee = new Payee();
> > >                 payee.setPK(new Long(i));
> > >                 payee.setName("test payee " + i);    
> > >                 System.out.println(payee.toString());
> > >                 db.store(payee);
> > >                 db.commitTransaction();
> > > ****        }
> > > ****        for (int i = 1; i < 44; i++) {
> > >                 db.beginTransaction();
> > >                 Unit unit = new Unit();
> > >                 unit.setPK(new Long(i));
> > >                 unit.setDescr("test unit " + i);
> > >                 unit.setOwnerFK(new Long(i));
> > >                 System.out.println(unit.toString());
> > > ****FAILS       db.retrieveReference(unit, "owner");
> > >                 db.store(unit);                
> > >                 db.commitTransaction();
> > >             }
> > >             
> > >         } catch (Exception e1) {
> > >             e1.printStackTrace();
> > >         }            
> > >     }
> > > 
> > > ****THE STACK TRACE
> > > 
> > > [org.apache.ojb.broker.ta.PersistenceBrokerFactoryDefaultImpl] INFO:
> > > Create PersistenceBroker instance pool, pool configuration was
> > > {whenExhaustedAction=0, maxIdle=-1, maxActive=100, maxWait=2000,
> > > numTestsPerEvictionRun=10, testWhileIdle=false, testOnReturn=false,
> > > timeBetweenEvictionRunsMillis=-1, minEvictableIdleIimeMillis=600000,
> > > testOnBorrow=false}
> > > [DEFAULT] INFO: OJB Descriptor Repository:
> > > file:/opt/projects/pm/classes/repository.xml
> > > [DEFAULT] INFO: ...Finished parsing. Took 1606 msecs
> > > [DEFAULT] INFO: OJB Descriptor Repository:
> > > file:/opt/projects/pm/classes/repository.xml
> > > [DEFAULT] INFO: ...Finished parsing. Took 191 msecs
> > > [DEFAULT] INFO: OJB Descriptor Repository:
> > > file:/opt/projects/pm/classes/repository.xml
> > > [DEFAULT] INFO: ...Finished parsing. Took 238 msecs
> > > [org.apache.ojb.broker.util.sequence.SequenceManagerFactory] INFO: Use
> > > sequence manager class: class
> > > org.apache.ojb.broker.util.sequence.SequenceManagerHiLoImpl
> > > [org.apache.ojb.broker.accesslayer.ConnectionFactoryPooledImpl] INFO:
> > > Create connection pool for JdbcDescriptorKey 1917968236
> > > [org.apache.ojb.broker.accesslayer.ConnectionFactoryPooledImpl] INFO:
> > > Create new connection pool for
> > > org.apache.ojb.broker.metadata.JdbcConnectionDescriptor,
> > >  used descriptor: JdbcConnectionDescriptor
> > > DBMS:Hsqldb
> > > DRIVER: org.hsqldb.jdbcDriver
> > > PROTOCOL: jdbc
> > > SUBPROTOCOL: hsqldb
> > > DBALIAS: hsql://localhost
> > > USERNAME: sa
> > > PASSWORD: 
> > > EAGER RELEASE: false
> > > pool configuration was: {whenExhaustedAction=0, maxIdle=-1,
> > > maxActive=21, maxWait=5000, numTestsPerEvictionRun=10,
> > > testWhileIdle=false, testOnReturn=false,
> > > timeBetweenEvictionRunsMillis=-1, minEvictableIdleIimeMillis=600000,
> > > testOnBorrow=true}
> > > [Payee: PK = 1, address = null, addressFK = null, isOwner = null,
> > > isTenant = null, isVendor = null, name = test payee 1]
> > > [Payee: PK = 2, address = null, addressFK = null, isOwner = null,
> > > isTenant = null, isVendor = null, name = test payee 2]
> > > [Payee: PK = 3, address = null, addressFK = null, isOwner = null,
> > > isTenant = null, isVendor = null, name = test payee 3]
> > > [Payee: PK = 4, address = null, addressFK = null, isOwner = null,
> > > isTenant = null, isVendor = null, name = test payee 4]
> > > [Payee: PK = 5, address = null, addressFK = null, isOwner = null,
> > > isTenant = null, isVendor = null, name = test payee 5]
> > > [Payee: PK = 6, address = null, addressFK = null, isOwner = null,
> > > isTenant = null, isVendor = null, name = test payee 6]
> > > [Payee: PK = 7, address = null, addressFK = null, isOwner = null,
> > > isTenant = null, isVendor = null, name = test payee 7]
> > > [Payee: PK = 8, address = null, addressFK = null, isOwner = null,
> > > isTenant = null, isVendor = null, name = test payee 8]
> > > [Payee: PK = 9, address = null, addressFK = null, isOwner = null,
> > > isTenant = null, isVendor = null, name = test payee 9]
> > > [Payee: PK = 10, address = null, addressFK = null, isOwner = null,
> > > isTenant = null, isVendor = null, name = test payee 10]
> > > [Payee: PK = 11, address = null, addressFK = null, isOwner = null,
> > > isTenant = null, isVendor = null, name = test payee 11]
> > > [Payee: PK = 12, address = null, addressFK = null, isOwner = null,
> > > isTenant = null, isVendor = null, name = test payee 12]
> > > [Payee: PK = 13, address = null, addressFK = null, isOwner = null,
> > > isTenant = null, isVendor = null, name = test payee 13]
> > > [Payee: PK = 14, address = null, addressFK = null, isOwner = null,
> > > isTenant = null, isVendor = null, name = test payee 14]
> > > [Payee: PK = 15, address = null, addressFK = null, isOwner = null,
> > > isTenant = null, isVendor = null, name = test payee 15]
> > > [Payee: PK = 16, address = null, addressFK = null, isOwner = null,
> > > isTenant = null, isVendor = null, name = test payee 16]
> > > [Payee: PK = 17, address = null, addressFK = null, isOwner = null,
> > > isTenant = null, isVendor = null, name = test payee 17]
> > > [Payee: PK = 18, address = null, addressFK = null, isOwner = null,
> > > isTenant = null, isVendor = null, name = test payee 18]
> > > [Payee: PK = 19, address = null, addressFK = null, isOwner = null,
> > > isTenant = null, isVendor = null, name = test payee 19]
> > > [Payee: PK = 20, address = null, addressFK = null, isOwner = null,
> > > isTenant = null, isVendor = null, name = test payee 20]
> > > [Payee: PK = 21, address = null, addressFK = null, isOwner = null,
> > > isTenant = null, isVendor = null, name = test payee 21]
> > > [Payee: PK = 22, address = null, addressFK = null, isOwner = null,
> > > isTenant = null, isVendor = null, name = test payee 22]
> > > [Payee: PK = 23, address = null, addressFK = null, isOwner = null,
> > > isTenant = null, isVendor = null, name = test payee 23]
> > > [Payee: PK = 24, address = null, addressFK = null, isOwner = null,
> > > isTenant = null, isVendor = null, name = test payee 24]
> > > [Payee: PK = 25, address = null, addressFK = null, isOwner = null,
> > > isTenant = null, isVendor = null, name = test payee 25]
> > > [Payee: PK = 26, address = null, addressFK = null, isOwner = null,
> > > isTenant = null, isVendor = null, name = test payee 26]
> > > [Payee: PK = 27, address = null, addressFK = null, isOwner = null,
> > > isTenant = null, isVendor = null, name = test payee 27]
> > > [Payee: PK = 28, address = null, addressFK = null, isOwner = null,
> > > isTenant = null, isVendor = null, name = test payee 28]
> > > [Payee: PK = 29, address = null, addressFK = null, isOwner = null,
> > > isTenant = null, isVendor = null, name = test payee 29]
> > > [Payee: PK = 30, address = null, addressFK = null, isOwner = null,
> > > isTenant = null, isVendor = null, name = test payee 30]
> > > [Payee: PK = 31, address = null, addressFK = null, isOwner = null,
> > > isTenant = null, isVendor = null, name = test payee 31]
> > > [Payee: PK = 32, address = null, addressFK = null, isOwner = null,
> > > isTenant = null, isVendor = null, name = test payee 32]
> > > [Payee: PK = 33, address = null, addressFK = null, isOwner = null,
> > > isTenant = null, isVendor = null, name = test payee 33]
> > > [Payee: PK = 34, address = null, addressFK = null, isOwner = null,
> > > isTenant = null, isVendor = null, name = test payee 34]
> > > [Payee: PK = 35, address = null, addressFK = null, isOwner = null,
> > > isTenant = null, isVendor = null, name = test payee 35]
> > > [Payee: PK = 36, address = null, addressFK = null, isOwner = null,
> > > isTenant = null, isVendor = null, name = test payee 36]
> > > [Payee: PK = 37, address = null, addressFK = null, isOwner = null,
> > > isTenant = null, isVendor = null, name = test payee 37]
> > > [Payee: PK = 38, address = null, addressFK = null, isOwner = null,
> > > isTenant = null, isVendor = null, name = test payee 38]
> > > [Payee: PK = 39, address = null, addressFK = null, isOwner = null,
> > > isTenant = null, isVendor = null, name = test payee 39]
> > > [Payee: PK = 40, address = null, addressFK = null, isOwner = null,
> > > isTenant = null, isVendor = null, name = test payee 40]
> > > [Payee: PK = 41, address = null, addressFK = null, isOwner = null,
> > > isTenant = null, isVendor = null, name = test payee 41]
> > > [Payee: PK = 42, address = null, addressFK = null, isOwner = null,
> > > isTenant = null, isVendor = null, name = test payee 42]
> > > [Payee: PK = 43, address = null, addressFK = null, isOwner = null,
> > > isTenant = null, isVendor = null, name = test payee 43]
> > > [Unit: PK = 1, address = null, addressFK = null, descr = test unit 1,
> > > isCommercial = null, owner = null, ownerFK = 1]
> > > [Unit: PK = 2, address = null, addressFK = null, descr = test unit 2,
> > > isCommercial = null, owner = null, ownerFK = 2]
> > > [Unit: PK = 3, address = null, addressFK = null, descr = test unit 3,
> > > isCommercial = null, owner = null, ownerFK = 3]
> > > [Unit: PK = 4, address = null, addressFK = null, descr = test unit 4,
> > > isCommercial = null, owner = null, ownerFK = 4]
> > > [Unit: PK = 5, address = null, addressFK = null, descr = test unit 5,
> > > isCommercial = null, owner = null, ownerFK = 5]
> > > [Unit: PK = 6, address = null, addressFK = null, descr = test unit 6,
> > > isCommercial = null, owner = null, ownerFK = 6]
> > > [Unit: PK = 7, address = null, addressFK = null, descr = test unit 7,
> > > isCommercial = null, owner = null, ownerFK = 7]
> > > [Unit: PK = 8, address = null, addressFK = null, descr = test unit 8,
> > > isCommercial = null, owner = null, ownerFK = 8]
> > > [Unit: PK = 9, address = null, addressFK = null, descr = test unit 9,
> > > isCommercial = null, owner = null, ownerFK = 9]
> > > [org.apache.ojb.broker.accesslayer.JdbcAccess] ERROR:
> > > PersistenceBrokerException during the execution of materializeObject:
> > > Unable to build object instance (MAYBE you don't have a constructor
> > > available):class com.microremedies.pm.persist.ojb.Payee: Error setting
> > > field:PK in object:com.microremedies.pm.persist.ojb.Payee
> > > Unable to build object instance (MAYBE you don't have a constructor
> > > available):class com.microremedies.pm.persist.ojb.Payee: Error setting
> > > field:PK in object:com.microremedies.pm.persist.ojb.Payee
> > > java.lang.IllegalArgumentException
> > >         at
> > > 
>sun.reflect.UnsafeObjectFieldAccessorImpl.set(UnsafeObjectFieldAccessorImpl.java:63)
> > >         at java.lang.reflect.Field.set(Field.java:519)
> > >         at
> > > 
>org.apache.ojb.broker.metadata.fieldaccess.PersistentFieldDefaultImpl.set(PersistentFieldDefaultImpl.java:146)
> > >         at
> > > 
>org.apache.ojb.broker.accesslayer.RowReaderDefaultImpl.buildWithReflection(RowReaderDefaultImpl.java:228)
> > >         at
> > > 
>org.apache.ojb.broker.accesslayer.RowReaderDefaultImpl.readObjectFrom(RowReaderDefaultImpl.java:108)
> > >         at
> > > 
>org.apache.ojb.broker.accesslayer.JdbcAccess.materializeObject(JdbcAccess.java:444)
> > >         at
> > > 
>org.apache.ojb.broker.singlevm.PersistenceBrokerImpl.getDBObject(PersistenceBrokerImpl.java:1424)
> > >         at
> > > 
>org.apache.ojb.broker.singlevm.PersistenceBrokerImpl.getObjectByIdentity(PersistenceBrokerImpl.java:1767)
> > >         at
> > > 
>org.apache.ojb.broker.singlevm.PersistenceBrokerImpl.getReferencedObject(PersistenceBrokerImpl.java:1195)
> > >         at
> > > 
>org.apache.ojb.broker.singlevm.PersistenceBrokerImpl.retrieveReference(PersistenceBrokerImpl.java:999)
> > >         at
> > > 
>org.apache.ojb.broker.singlevm.PersistenceBrokerImpl.retrieveReference(PersistenceBrokerImpl.java:955)
> > >         at
> > > 
>org.apache.ojb.broker.singlevm.DelegatingPersistenceBroker.retrieveReference(DelegatingPersistenceBroker.java:179)
> > >         at
> > > com.microremedies.pm.persist.ojb.Migration.test(Migration.java:59)
> > >         at
> > > com.microremedies.pm.persist.ojb.Migration.doit(Migration.java:34)
> > >         at
> > > com.microremedies.pm.persist.ojb.Migration.main(Migration.java:24)
> > > rethrown as org.apache.ojb.broker.metadata.MetadataException: Error
> > > setting field:PK in object:com.microremedies.pm.persist.ojb.Payee
> > >         at
> > > 
>org.apache.ojb.broker.metadata.fieldaccess.PersistentFieldDefaultImpl.set(PersistentFieldDefaultImpl.java:162)
> > >         at
> > > 
>org.apache.ojb.broker.accesslayer.RowReaderDefaultImpl.buildWithReflection(RowReaderDefaultImpl.java:228)
> > >         at
> > > 
>org.apache.ojb.broker.accesslayer.RowReaderDefaultImpl.readObjectFrom(RowReaderDefaultImpl.java:108)
> > >         at
> > > 
>org.apache.ojb.broker.accesslayer.JdbcAccess.materializeObject(JdbcAccess.java:444)
> > >         at
> > > 
>org.apache.ojb.broker.singlevm.PersistenceBrokerImpl.getDBObject(PersistenceBrokerImpl.java:1424)
> > >         at
> > > 
>org.apache.ojb.broker.singlevm.PersistenceBrokerImpl.getObjectByIdentity(PersistenceBrokerImpl.java:1767)
> > >         at
> > > 
>org.apache.ojb.broker.singlevm.PersistenceBrokerImpl.getReferencedObject(PersistenceBrokerImpl.java:1195)
> > >         at
> > > 
>org.apache.ojb.broker.singlevm.PersistenceBrokerImpl.retrieveReference(PersistenceBrokerImpl.java:999)
> > >         at
> > > 
>org.apache.ojb.broker.singlevm.PersistenceBrokerImpl.retrieveReference(PersistenceBrokerImpl.java:955)
> > >         at
> > > 
>org.apache.ojb.broker.singlevm.DelegatingPersistenceBroker.retrieveReference(DelegatingPersistenceBroker.java:179)
> > >         at
> > > com.microremedies.pm.persist.ojb.Migration.test(Migration.java:59)
> > >         at
> > > com.microremedies.pm.persist.ojb.Migration.doit(Migration.java:34)
> > >         at
> > > com.microremedies.pm.persist.ojb.Migration.main(Migration.java:24)
> > > Caused by: java.lang.IllegalArgumentException
> > >         at
> > > 
>sun.reflect.UnsafeObjectFieldAccessorImpl.set(UnsafeObjectFieldAccessorImpl.java:63)
> > >         at java.lang.reflect.Field.set(Field.java:519)
> > >         at
> > > 
>org.apache.ojb.broker.metadata.fieldaccess.PersistentFieldDefaultImpl.set(PersistentFieldDefaultImpl.java:146)
> > >         ... 12 more
> > > rethrown as org.apache.ojb.broker.PersistenceBrokerException: Unable to
> > > build object instance (MAYBE you don't have a constructor
> > > available):class com.microremedies.pm.persist.ojb.Payee: Error setting
> > > field:PK in object:com.microremedies.pm.persist.ojb.Payee
> > >         at
> > > 
>org.apache.ojb.broker.accesslayer.RowReaderDefaultImpl.buildWithReflection(RowReaderDefaultImpl.java:234)
> > >         at
> > > 
>org.apache.ojb.broker.accesslayer.RowReaderDefaultImpl.readObjectFrom(RowReaderDefaultImpl.java:108)
> > >         at
> > > 
>org.apache.ojb.broker.accesslayer.JdbcAccess.materializeObject(JdbcAccess.java:444)
> > >         at
> > > 
>org.apache.ojb.broker.singlevm.PersistenceBrokerImpl.getDBObject(PersistenceBrokerImpl.java:1424)
> > >         at
> > > 
>org.apache.ojb.broker.singlevm.PersistenceBrokerImpl.getObjectByIdentity(PersistenceBrokerImpl.java:1767)
> > >         at
> > > 
>org.apache.ojb.broker.singlevm.PersistenceBrokerImpl.getReferencedObject(PersistenceBrokerImpl.java:1195)
> > >         at
> > > 
>org.apache.ojb.broker.singlevm.PersistenceBrokerImpl.retrieveReference(PersistenceBrokerImpl.java:999)
> > >         at
> > > 
>org.apache.ojb.broker.singlevm.PersistenceBrokerImpl.retrieveReference(PersistenceBrokerImpl.java:955)
> > >         at
> > > 
>org.apache.ojb.broker.singlevm.DelegatingPersistenceBroker.retrieveReference(DelegatingPersistenceBroker.java:179)
> > >         at
> > > com.microremedies.pm.persist.ojb.Migration.test(Migration.java:59)
> > >         at
> > > com.microremedies.pm.persist.ojb.Migration.doit(Migration.java:34)
> > >         at
> > > com.microremedies.pm.persist.ojb.Migration.main(Migration.java:24)
> > > Caused by: org.apache.ojb.broker.metadata.MetadataException: Error
> > > setting field:PK in object:com.microremedies.pm.persist.ojb.Payee
> > >         at
> > > 
>org.apache.ojb.broker.metadata.fieldaccess.PersistentFieldDefaultImpl.set(PersistentFieldDefaultImpl.java:162)
> > >         at
> > > 
>org.apache.ojb.broker.accesslayer.RowReaderDefaultImpl.buildWithReflection(RowReaderDefaultImpl.java:228)
> > >         ... 11 more
> > > Caused by: java.lang.IllegalArgumentException
> > >         at
> > > 
>sun.reflect.UnsafeObjectFieldAccessorImpl.set(UnsafeObjectFieldAccessorImpl.java:63)
> > >         at java.lang.reflect.Field.set(Field.java:519)
> > >         at
> > > 
>org.apache.ojb.broker.metadata.fieldaccess.PersistentFieldDefaultImpl.set(PersistentFieldDefaultImpl.java:146)
> > >         ... 12 more
> > > [org.apache.ojb.broker.accesslayer.ConnectionManager] INFO: Rollback was
> > > called, do rollback on current connection
> > > org.hsqldb.jdbcConnection@1a99561
> > > java.lang.IllegalArgumentException
> > >         at
> > > 
>sun.reflect.UnsafeObjectFieldAccessorImpl.set(UnsafeObjectFieldAccessorImpl.java:63)
> > >         at java.lang.reflect.Field.set(Field.java:519)
> > >         at
> > > 
>org.apache.ojb.broker.metadata.fieldaccess.PersistentFieldDefaultImpl.set(PersistentFieldDefaultImpl.java:146)
> > >         at
> > > 
>org.apache.ojb.broker.accesslayer.RowReaderDefaultImpl.buildWithReflection(RowReaderDefaultImpl.java:228)
> > >         at
> > > 
>org.apache.ojb.broker.accesslayer.RowReaderDefaultImpl.readObjectFrom(RowReaderDefaultImpl.java:108)
> > >         at
> > > 
>org.apache.ojb.broker.accesslayer.JdbcAccess.materializeObject(JdbcAccess.java:444)
> > >         at
> > > 
>org.apache.ojb.broker.singlevm.PersistenceBrokerImpl.getDBObject(PersistenceBrokerImpl.java:1424)
> > >         at
> > > 
>org.apache.ojb.broker.singlevm.PersistenceBrokerImpl.getObjectByIdentity(PersistenceBrokerImpl.java:1767)
> > >         at
> > > 
>org.apache.ojb.broker.singlevm.PersistenceBrokerImpl.getReferencedObject(PersistenceBrokerImpl.java:1195)
> > >         at
> > > 
>org.apache.ojb.broker.singlevm.PersistenceBrokerImpl.retrieveReference(PersistenceBrokerImpl.java:999)
> > >         at
> > > 
>org.apache.ojb.broker.singlevm.PersistenceBrokerImpl.retrieveReference(PersistenceBrokerImpl.java:955)
> > >         at
> > > 
>org.apache.ojb.broker.singlevm.DelegatingPersistenceBroker.retrieveReference(DelegatingPersistenceBroker.java:179)
> > >         at
> > > com.microremedies.pm.persist.ojb.Migration.test(Migration.java:59)
> > >         at
> > > com.microremedies.pm.persist.ojb.Migration.doit(Migration.java:34)
> > >         at
> > > com.microremedies.pm.persist.ojb.Migration.main(Migration.java:24)
> > > rethrown as org.apache.ojb.broker.metadata.MetadataException: Error
> > > setting field:PK in object:com.microremedies.pm.persist.ojb.Payee
> > >         at
> > > 
>org.apache.ojb.broker.metadata.fieldaccess.PersistentFieldDefaultImpl.set(PersistentFieldDefaultImpl.java:162)
> > >         at
> > > 
>org.apache.ojb.broker.accesslayer.RowReaderDefaultImpl.buildWithReflection(RowReaderDefaultImpl.java:228)
> > >         at
> > > 
>org.apache.ojb.broker.accesslayer.RowReaderDefaultImpl.readObjectFrom(RowReaderDefaultImpl.java:108)
> > >         at
> > > 
>org.apache.ojb.broker.accesslayer.JdbcAccess.materializeObject(JdbcAccess.java:444)
> > >         at
> > > 
>org.apache.ojb.broker.singlevm.PersistenceBrokerImpl.getDBObject(PersistenceBrokerImpl.java:1424)
> > >         at
> > > 
>org.apache.ojb.broker.singlevm.PersistenceBrokerImpl.getObjectByIdentity(PersistenceBrokerImpl.java:1767)
> > >         at
> > > 
>org.apache.ojb.broker.singlevm.PersistenceBrokerImpl.getReferencedObject(PersistenceBrokerImpl.java:1195)
> > >         at
> > > 
>org.apache.ojb.broker.singlevm.PersistenceBrokerImpl.retrieveReference(PersistenceBrokerImpl.java:999)
> > >         at
> > > 
>org.apache.ojb.broker.singlevm.PersistenceBrokerImpl.retrieveReference(PersistenceBrokerImpl.java:955)
> > >         at
> > > 
>org.apache.ojb.broker.singlevm.DelegatingPersistenceBroker.retrieveReference(DelegatingPersistenceBroker.java:179)
> > >         at
> > > com.microremedies.pm.persist.ojb.Migration.test(Migration.java:59)
> > >         at
> > > com.microremedies.pm.persist.ojb.Migration.doit(Migration.java:34)
> > >         at
> > > com.microremedies.pm.persist.ojb.Migration.main(Migration.java:24)
> > > Caused by: java.lang.IllegalArgumentException
> > >         at
> > > 
>sun.reflect.UnsafeObjectFieldAccessorImpl.set(UnsafeObjectFieldAccessorImpl.java:63)
> > >         at java.lang.reflect.Field.set(Field.java:519)
> > >         at
> > > 
>org.apache.ojb.broker.metadata.fieldaccess.PersistentFieldDefaultImpl.set(PersistentFieldDefaultImpl.java:146)
> > >         ... 12 more
> > > rethrown as org.apache.ojb.broker.PersistenceBrokerException: Unable to
> > > build object instance (MAYBE you don't have a constructor
> > > available):class com.microremedies.pm.persist.ojb.Payee: Error setting
> > > field:PK in object:com.microremedies.pm.persist.ojb.Payee
> > >         at
> > > 
>org.apache.ojb.broker.accesslayer.RowReaderDefaultImpl.buildWithReflection(RowReaderDefaultImpl.java:234)
> > >         at
> > > 
>org.apache.ojb.broker.accesslayer.RowReaderDefaultImpl.readObjectFrom(RowReaderDefaultImpl.java:108)
> > >         at
> > > 
>org.apache.ojb.broker.accesslayer.JdbcAccess.materializeObject(JdbcAccess.java:444)
> > >         at
> > > 
>org.apache.ojb.broker.singlevm.PersistenceBrokerImpl.getDBObject(PersistenceBrokerImpl.java:1424)
> > >         at
> > > 
>org.apache.ojb.broker.singlevm.PersistenceBrokerImpl.getObjectByIdentity(PersistenceBrokerImpl.java:1767)
> > >         at
> > > 
>org.apache.ojb.broker.singlevm.PersistenceBrokerImpl.getReferencedObject(PersistenceBrokerImpl.java:1195)
> > >         at
> > > 
>org.apache.ojb.broker.singlevm.PersistenceBrokerImpl.retrieveReference(PersistenceBrokerImpl.java:999)
> > >         at
> > > 
>org.apache.ojb.broker.singlevm.PersistenceBrokerImpl.retrieveReference(PersistenceBrokerImpl.java:955)
> > >         at
> > > 
>org.apache.ojb.broker.singlevm.DelegatingPersistenceBroker.retrieveReference(DelegatingPersistenceBroker.java:179)
> > >         at
> > > com.microremedies.pm.persist.ojb.Migration.test(Migration.java:59)
> > >         at
> > > com.microremedies.pm.persist.ojb.Migration.doit(Migration.java:34)
> > >         at
> > > com.microremedies.pm.persist.ojb.Migration.main(Migration.java:24)
> > > Caused by: org.apache.ojb.broker.metadata.MetadataException: Error
> > > setting field:PK in object:com.microremedies.pm.persist.ojb.Payee
> > >         at
> > > 
>org.apache.ojb.broker.metadata.fieldaccess.PersistentFieldDefaultImpl.set(PersistentFieldDefaultImpl.java:162)
> > >         at
> > > 
>org.apache.ojb.broker.accesslayer.RowReaderDefaultImpl.buildWithReflection(RowReaderDefaultImpl.java:228)
> > >         ... 11 more
> > > Caused by: java.lang.IllegalArgumentException
> > >         at
> > > 
>sun.reflect.UnsafeObjectFieldAccessorImpl.set(UnsafeObjectFieldAccessorImpl.java:63)
> > >         at java.lang.reflect.Field.set(Field.java:519)
> > >         at
> > > 
>org.apache.ojb.broker.metadata.fieldaccess.PersistentFieldDefaultImpl.set(PersistentFieldDefaultImpl.java:146)
> > >         ... 12 more
> > > 
> > > 
> > > ****PERSISTENT CLASS UNIT
> > > 
> > > package com.microremedies.pm.persist.ojb;
> > > import java.beans.*;
> > > import com.microremedies.pm.persist.inf.*;
> > > public class Unit extends EntityBase {    
> > >     private Payee owner;    
> > >     private Long ownerFK;
> > >     private Long addressFK;
> > >     private Address address;
> > >     private Boolean isCommercial;
> > >     private String descr;
> > >     private Long PK;
> > > 
> > >     public void setPK(Long PK) {
> > >         this.PK = PK;
> > >     }
> > >     public Long getPK() {
> > >         return PK;
> > >     }
> > >     public Payee getOwner() {
> > >         return this.owner;
> > >     }
> > >     public void setOwner(Payee owner) {
> > >         this.owner = owner;
> > >     }
> > >     public void setOwnerFK(Long ownerFK) {
> > >         this.ownerFK = ownerFK;
> > >     }
> > >     public Long getOwnerFK() {
> > >         return ownerFK;
> > >     }
> > >     public void setAddressFK(Long addressFK) {
> > >         this.addressFK = addressFK;
> > >     }
> > >     public Long getAddressFK() {
> > >         return addressFK;
> > >     }
> > >     public Address getAddress() {
> > >         return this.address;
> > >     }
> > >     public void setAddress(Address address) {
> > >         this.address = address;
> > >     }
> > >     public Boolean getIsCommercial() {
> > >         return this.isCommercial;
> > >     }
> > >     public void setIsCommercial(Boolean isCommercial) {
> > >         this.isCommercial = isCommercial;
> > >     }
> > >     public String getDescr() {
> > >         return this.descr;
> > >     }
> > >     public void setDescr(String descr) {
> > >         this.descr = descr;
> > >     }    
> > > 
> > > }
> > > 
> > > ****PERSISTENT CLASS PAYEE
> > > 
> > > package com.microremedies.pm.persist.ojb;
> > > import com.microremedies.pm.persist.inf.*;
> > > public class Payee extends EntityBase {
> > >     private Long PK;    
> > >     private Address address;
> > >     private Long addressFK;
> > >     private Boolean isOwner;
> > >     private Boolean isTenant;
> > >     private Boolean isVendor;
> > >     private String name;
> > >     
> > >     public Payee() {
> > >     }
> > >     public Boolean getIsOwner() {
> > >         return this.isOwner;
> > >     }
> > >     public void setIsOwner(Boolean param) {
> > >         this.isOwner = param;
> > >     }        
> > >     public Boolean getIsTenant() {
> > >         return this.isTenant;
> > >     }
> > >     public void setIsTenant(Boolean param) {
> > >         this.isTenant = param;
> > >     }        
> > >     public Boolean getIsVendor() {
> > >         return this.isVendor;
> > >     }
> > >     public void setIsVendor(Boolean param) {
> > >         this.isVendor = param;
> > >     }        
> > >     public String getName() {
> > >         return this.name;
> > >     }
> > >     public void setName(String param) {
> > >         this.name = param;
> > >     }
> > >     public Long getPK() {
> > >         return this.PK;
> > >     }
> > >     public void setPK(Long param) {
> > >         this.PK = param;
> > >     }
> > >     public void setAddress(Address address) {
> > >         this.address = address;
> > >     }
> > >     public Address getAddress() {
> > >         return this.address;
> > >     }
> > >     public void setAddressFK(Long addressFK) {
> > >         this.addressFK = addressFK;
> > >     }
> > >     public Long getAddressFK() {
> > >         return this.addressFK;
> > >     }       
> > > }
> > > 
> > > ****A SIMPLE SUPERCLASS PROVING ONLY A TOSTRING METHOD
> > > 
> > > package com.microremedies.pm.persist.inf;
> > > import java.beans.*;
> > > public class EntityBase {    
> > >     public String toString() {
> > >         StringBuffer buf = new StringBuffer();        
> > >         try {
> > >             BeanInfo bi =
> > > Introspector.getBeanInfo(this.getClass(),EntityBase.class);
> > >             PropertyDescriptor[] props = bi.getPropertyDescriptors();
> > >             String name = this.getClass().getName();
> > >             name = name.substring(name.lastIndexOf(".") + 1);
> > >             buf.append("[" + name + ": ");
> > >             for (int i = 0; i < props.length; i++) {
> > >                 PropertyDescriptor prop = props[i];
> > >                 buf.append(prop.getName() + " = " +
> > > prop.getReadMethod().invoke(this,null));
> > >                 if (i != (props.length - 1))
> > >                     buf.append(", ");
> > >             }            
> > >             buf.append("]");
> > >         } catch (Exception ex) {
> > >             ex.printStackTrace();
> > >         }
> > >         return buf.toString();
> > >     }    
> > >     
> > > }
> > > 
> > > ****CLASS DESCRIPTORS FOR EACH
> > > 
> > > <class-descriptor class="com.microremedies.pm.persist.ojb.Payee"
> > > table="PAYEE">
> > > <field-descriptor id="1" name="PK" column="PK" jdbc-type="INTEGER"
> > > primarykey="true" autoincrement="true"/>
> > > <field-descriptor id="2" name="addressFK" column="ADDRESS_FK"
> > > jdbc-type="INTEGER"/>
> > > <field-descriptor id="3" name="name" column="NAME" jdbc-type="VARCHAR"/>
> > > <field-descriptor id="4" name="isOwner" column="ISOWNER"
> > > jdbc-type="BIT"/>
> > > <field-descriptor id="5" name="isTenant" column="ISTENANT"
> > > jdbc-type="BIT"/>
> > > <field-descriptor id="6" name="isVendor" column="ISVENDOR"
> > > jdbc-type="BIT"/>
> > > <reference-descriptor name="address"
> > > class-ref="com.microremedies.pm.persist.ojb.Address"
> > > auto-retrieve="true" auto-update="false" auto-delete="false">
> > > <foreignkey field-id-ref="2"/>
> > > </reference-descriptor>
> > > </class-descriptor>
> > > 
> > > <class-descriptor class="com.microremedies.pm.persist.ojb.Unit"
> > > table="UNIT">
> > > <field-descriptor id="1" name="PK" column="PK" jdbc-type="INTEGER"
> > > primarykey="true" autoincrement="true"/>
> > > <field-descriptor id="2" name="ownerFK" column="OWNER_FK"
> > > jdbc-type="INTEGER"/>
> > > <field-descriptor id="3" name="addressFK" column="ADDRESS_FK"
> > > jdbc-type="INTEGER"/>
> > > <field-descriptor id="4" name="isCommercial" column="ISCOMMERCIAL"
> > > jdbc-type="BIT"/>
> > > <field-descriptor id="5" name="descr" column="DESCR"
> > > jdbc-type="VARCHAR"/>
> > > <reference-descriptor name="owner"
> > > class-ref="com.microremedies.pm.persist.ojb.Payee" auto-retrieve="true"
> > > auto-update="false" auto-delete="false">
> > > <foreignkey field-id-ref="2"/>
> > > </reference-descriptor>
> > > <reference-descriptor name="address"
> > > class-ref="com.microremedies.pm.persist.ojb.Address"
> > > auto-retrieve="true" auto-update="false" auto-delete="false">
> > > <foreignkey field-id-ref="3"/>
> > > </reference-descriptor>
> > > </class-descriptor>
> > > 
> > > ****OJB.PROPERTIES
> > > 
> > > repositoryFile=repository.xml
> > > useSerializedRepository=false
> > > useServer=false
> > > BrokerServers=localhost\:2001
> > > ServerThreadCount=10
> > > BrokerPoolSize=10
> > > UseCompression=false
> > > 
>PersistenceBrokerFactoryClass=org.apache.ojb.broker.ta.PersistenceBrokerFactoryDefaultImpl
> > > PersistenceBrokerClass=org.apache.ojb.broker.singlevm.PersistenceBrokerImpl
> > > maxActive=100
> > > maxIdle=-1
> > > maxWait=2000
> > > timeBetweenEvictionRunsMillis=-1
> > > minEvictableIdleTimeMillis=1000000
> > > whenExhaustedAction=0
> > > 
>ConnectionFactoryClass=org.apache.ojb.broker.accesslayer.ConnectionFactoryPooledImpl
> > > maxConnectionsInPool=21
> > > useAutoCommit=1
> > > ignoreAutoCommitExceptions=false
> > > SqlGeneratorClass=org.apache.ojb.broker.accesslayer.sql.SqlGeneratorDefaultImpl
> > > SequenceManagerClass=org.apache.ojb.broker.util.sequence.SequenceManagerHiLoImpl
> > > SequenceManagerGrabSize=10
> > > SequenceManagerGlobalIDs=false
> > > ObjectCacheClass=org.apache.ojb.broker.cache.ObjectCacheDefaultImpl
> > > LockManagerClass=org.apache.ojb.odmg.locking.LockManagerDefaultImpl
> > > LockMapClass=org.apache.ojb.odmg.locking.InMemoryLockMapImpl
> > > LockTimeout=60000
> > > ImplicitLocking=true
> > > LockAssociations=WRITE
> > > LoggerClass=org.apache.ojb.broker.util.logging.PoorMansLoggerImpl
> > > LoggerConfigFile=log4j.properties
> > > DEFAULT.LogLevel=INFO
> > > org.apache.ojb.broker.singlevm.PersistenceBrokerImpl.LogLevel=INFO
> > > org.apache.ojb.broker.PersistenceBrokerFactory.LogLevel=INFO
> > > org.apache.ojb.broker.server.PersistenceBrokerClient.LogLevel=INFO
> > > org.apache.ojb.broker.server.RequestProcessor.LogLevel=INFO
> > > org.apache.ojb.broker.server.BrokerPool.LogLevel=INFO
> > > org.apache.ojb.broker.metadata.RepositoryXmlHandler.LogLevel=INFO
> > > org.apache.ojb.broker.accesslayer.JdbcAccess.LogLevel=INFO
> > > org.apache.ojb.broker.accesslayer.RsIterator.LogLevel=INFO
> > > org.apache.ojb.broker.accesslayer.StatementsForClass.LogLevel=INFO
> > > org.apache.ojb.broker.accesslayer.sql.SqlGeneratorDefaultImpl.LogLevel=INFO
> > > ODMG.LogLevel=INFO
> > > JDO.LogLevel=INFO
> > > performance.LogLevel=INFO
> > > soda.LogLevel=INFO
> > > ConfigurableFactory.LogLevel=INFO
> > > OqlCollectionClass=org.apache.ojb.odmg.collections.DListImpl
> > > SqlInLimit=200
> > > 
>PersistentFieldClass=org.apache.ojb.broker.metadata.fieldaccess.PersistentFieldDefaultImpl
> > > OJBTxManagerClass=org.apache.ojb.odmg.LocalTxManager
> > > 
>JTATransactionManagerClass=org.apache.ojb.otm.transaction.factory.JBossTransactionManagerFactory
> > > autobuild=true
> > > 
> > > 
> > > 
> > > ---------------------------------------------------------------------
> > > To unsubscribe, e-mail: [EMAIL PROTECTED]
> > > For additional commands, e-mail: [EMAIL PROTECTED]
> > > 
> > > 
> > 
> > 
> > 
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: [EMAIL PROTECTED]
> > For additional commands, e-mail: [EMAIL PROTECTED]
> 



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

Reply via email to