Hi,

that's (not?) really strange!
But I think it could be a little problematic to set an
autoincrement, primary key field (zonaDbId) as the
locking field (locking="true") of the persistent object.

Try to use a separate field to do optimistic locking.

regards,
Armin

----- Original Message -----
From: "Ajitesh Das" <[EMAIL PROTECTED]>
To: "OJB Users List" <[EMAIL PROTECTED]>
Sent: Wednesday, February 26, 2003 6:09 PM
Subject: RE: Brrow broker from pool is failing : OptimisticLockException
in PB Api


> Here is my class descriptor:
>     <class-descriptor
>             class="com.acme.ZonaSample"
>             table="ZONA_TABLE"
>         >
>         <field-descriptor id="1"
>             name="zonaDbId"
>             column="ID"
>             jdbc-type="INTEGER"
>             primarykey="true"
>             nullable="false"
>             indexed="true"
>             autoincrement="true"
>             locking="true"
>             default-fetch="false"
>         />
>         <field-descriptor id="2"
>             name="attr1"
>             column="a1"
>             jdbc-type="BIGINT"
>             primarykey="false"
>             nullable="true"
>             indexed="true"
>             autoincrement="false"
>             locking="false"
>             default-fetch="false"
>         />
>         <field-descriptor id="3"
>             name="attr2"
>             column="a2"
>             jdbc-type="INTEGER"
>             primarykey="false"
>             nullable="true"
>             indexed="true"
>             autoincrement="false"
>             locking="false"
>             default-fetch="false"
>         />
>         <field-descriptor id="4"
>             name="attr3"
>             column="a3"
>             jdbc-type="BIGINT"
>             primarykey="false"
>             nullable="true"
>             indexed="true"
>             autoincrement="false"
>             locking="false"
>             default-fetch="false"
>         />
>     </class-descriptor>
>
>
> -----Original Message-----
> From: Armin Waibel [mailto:[EMAIL PROTECTED]
> Sent: Wed 2/26/2003 2:50 AM
> To: OJB Users List
> Cc:
> Subject: Re: Brrow broker from pool is failing :
OptimisticLockException in PB Api
>
>
>
> Hi,
>
> need some more info.
> Please send the class-descriptor of
> your 'persistentObject'
>
> regards,
> Armin
>
> ----- Original Message -----
> From: "Ajitesh Das" <[EMAIL PROTECTED]>
> To: "OJB Users List Armin Waibel"
> <[EMAIL PROTECTED]@code-au-lait.de>; "OJB Users List"
> <[EMAIL PROTECTED]>
> Sent: Wednesday, February 26, 2003 11:34 AM
> Subject: RE: Brrow broker from pool is failing :
OptimisticLockException
> in PB Api
>
>
> > Hi Armin :
> >   Thanks for your reply.
> > >first, it seems that you mix the JDO-api with the PB-api in your
code
> > >PersistenceManager --> JDO
> > >PersistenceBroker (PB), PersistenceBrokerFactory (PBF)--> PB-api
> > >maybe a typo.
> > yes this is a Typo. I am  just playing PB api
> >
> > > I get this "Brrow broker from pool is failing" exception after
some
> > >success write.
> > >Think you forget to call the close method of the PB after use.
> > >PB.close() returns
> > >the broker to broker pool managed by PBF.
> >
> >
> > Here are the tries I have made :
> >
> >   case 1* If I put PB.close() ... I get exception saying
> "OprimisticLockException: Some body using the object"
> >
> >  case 2* If I do not use PB.close() ....I ran out of Broker pool.
> >
> > here is the structure I am using
> >
> >   Loop :
> >
> >    < condition>
> >
> >    new PersistentObject()
> >
> >   set values;
> >
> >  PB = PersistenceBrokerFactory.defaultPersistenceBroker();
> >
> >  PB.beginTx();
> >
> >  PB.store(myObj)
> >
> >  PB.commitTx()
> >
> > PB.close() // tried with and without this
> >
> >
> > I have also tried with a static var ...holding obj reference of PB
> during my application initialization.
> >
> > I am still getting Optimistic Lock Exception .... similar to case 2.
> >
> > thanks
> >
> > ~ajitesh
> >
> >
> >
> >
> >
> > ----- Original Message -----
> > From: "Ajitesh Das" <[EMAIL PROTECTED]>
> > To: "OJB Users List" <[EMAIL PROTECTED]>; "OJB Users List"
> > <[EMAIL PROTECTED]>; "OJB Users List" <[EMAIL PROTECTED]>;
> > "OJB Users List" <[EMAIL PROTECTED]>
> > Sent: Wednesday, February 26, 2003 10:45 AM
> > Subject: Brrow broker from pool is failing : OptimisticLockException
> in
> > PB Api
> >
> >
> > > * Here is my issue :
> > > -          When I save the "Broker" object reference  in a static
> > variable and use that in multiple context
> > > I get Optimistic Lock exception.
> > > - If I do not save the Broker object reference :
> > >           //  pm = PersistenceManager.getInstance(); // return
> > Broker.defaultPersistenceBroker()
> > >          pm = PersistenceBrokerFactory.defaultPersistenceBroker();
> > >
> > > I get this "Brrow broker from pool is failing" exception after
some
> > success write.  I need to import a big data set into db table from a
> CSV
> > file and I make this in a *big* loop.
> > >
> > > Please advise.
> > >
> > > =========================================
> > > java.util.NoSuchElementException
> > >  at
> >
>
org.apache.commons.pool.impl.GenericKeyedObjectPool.borrowObject(Generic
> > KeyedObjectPool.java:758)
> > >  at
> >
>
org.apache.ojb.broker.ta.PersistenceBrokerFactoryDefaultImpl.createPersi
> > stenceBroker(Unknown Source)
> > >  at
> >
>
org.apache.ojb.broker.ta.PersistenceBrokerFactoryDefaultImpl.defaultPers
> > istenceBroker(Unknown Source)
> > >  at
> >
>
org.apache.ojb.broker.PersistenceBrokerFactory.defaultPersistenceBroker(
> > Unknown Source)
> > >  at org.apache.ojb.broker.Identity.<init>(Unknown Source)
> > >  at
org.apache.ojb.broker.cache.ObjectCacheDefaultImpl.cache(Unknown
> > Source)
> > >  at
> >
org.apache.ojb.broker.singlevm.PersistenceBrokerImpl.storeToDb(Unknown
> > Source)
> > >  at
> org.apache.ojb.broker.singlevm.PersistenceBrokerImpl.store(Unknown
> > Source)
> > >  at
> org.apache.ojb.broker.singlevm.PersistenceBrokerImpl.store(Unknown
> > Source)
> > >  at
> org.apache.ojb.broker.singlevm.PersistenceBrokerImpl.store(Unknown
> > Source)
> > >  at
> >
>
org.apache.ojb.broker.singlevm.DelegatingPersistenceBroker.store(Unknown
> > Source)
> > >  at
> >
>
org.apache.ojb.broker.util.sequence.SequenceGenerator.getNextSequence(Un
> > known Source)
> > >  at
> >
>
org.apache.ojb.broker.util.sequence.SequenceManagerHiLoImpl.getUniqueId(
> > Unknown Source)
> > >  at
> >
>
org.apache.ojb.broker.singlevm.PersistenceBrokerImpl.getUniqueId(Unknown
> > Source)
> > >  at
> >
>
org.apache.ojb.broker.singlevm.DelegatingPersistenceBroker.getUniqueId(U
> > nknown Source)
> > >  at
> >
>
org.apache.ojb.broker.metadata.ClassDescriptor.getAutoIncrementValue(Unk
> > nown Source)
> > >  at
> >
>
org.apache.ojb.broker.metadata.ClassDescriptor.getKeyValuesForObject(Unk
> > nown Source)
> > >  at
> > org.apache.ojb.broker.metadata.ClassDescriptor.getKeyValues(Unknown
> > Source)
> > >  at
> > org.apache.ojb.broker.metadata.ClassDescriptor.getKeyValues(Unknown
> > Source)
> > >  at org.apache.ojb.broker.Identity.<init>(Unknown Source)
> > >  at
> org.apache.ojb.broker.singlevm.PersistenceBrokerImpl.store(Unknown
> > Source)
> > >  at
> org.apache.ojb.broker.singlevm.PersistenceBrokerImpl.store(Unknown
> > Source)
> > >  at
> >
>
org.apache.ojb.broker.singlevm.DelegatingPersistenceBroker.store(Unknown
> > Source)
> > >
> > >
> > > -----Original Message-----
> > > From: Ajitesh Das
> > > Sent: Wed 2/26/2003 1:20 AM
> > > To: OJB Users List; OJB Users List; OJB Users List
> > > Cc:
> > > Subject: RE: OptimisticLockException in PB Api
> > >
> > >
> > >
> > > I have checked org.apache.ojb.tutorial1.UCEnterNewProduct.apply()
> ...
> > my main2() method is also same in nature..how come urs is woking and
> > mine is not :(
> > >
> > >
> > >         -----Original Message-----
> > >         From: Ajitesh Das
> > >         Sent: Wed 2/26/2003 1:14 AM
> > >         To: OJB Users List; OJB Users List
> > >         Cc:
> > >         Subject: OptimisticLockException in PB Api
> > >
> > >
> > >
> > >         I was trying a simple Test program. where I am setting a
set
> > of objects and what to write them  in a DB.I am using PB Api. The
very
> > first write is a success but throwing exception from 2nd write
> onwards.
> > What I am doing wrong ?
> > >
> > >         org.apache.ojb.broker.OptimisticLockException: Object has
> been
> > modified by someone else
> > >          at Test1.main2(Test1.java:64)
> > >          at Test1.<init>(Test1.java:23)
> > >          at Test1.main(Test1.java:27)
> > >         Caused by: org.apache.ojb.broker.OptimisticLockException:
> > Object has been modified by someone else
> > >          at
> > org.apache.ojb.broker.accesslayer.JdbcAccess.executeUpdate(Unknown
> > Source)
> > >          at
> >
org.apache.ojb.broker.singlevm.PersistenceBrokerImpl.storeToDb(Unknown
> > Source)
> > >          at
> > org.apache.ojb.broker.singlevm.PersistenceBrokerImpl.store(Unknown
> > Source)
> > >          at
> > org.apache.ojb.broker.singlevm.PersistenceBrokerImpl.store(Unknown
> > Source)
> > >          at
> > org.apache.ojb.broker.singlevm.PersistenceBrokerImpl.store(Unknown
> > Source)
> > >          at
> >
>
org.apache.ojb.broker.singlevm.DelegatingPersistenceBroker.store(Unknown
> > Source)
> > >
> > >         Here is my caller method:
> > >
> > >         public Test1 ()
> > >          {
> > >           main2();
> > >           main2();
> > >          }
> > >
> > >         And here is the called method
> > >
> > >             public void main2 ( )
> > >         {
> > >             PersistenceManager pm = null;
> > >             Transaction tx = null;
> > >             Sample zs = new Sample();
> > >             zs.setAttr1((long)10);
> > >             zs.setAttr2(30);
> > >              zs.setAttr3((long)40);
> > >
> > >             try {
> > >              pm = PersistenceManager.getInstance(); // return
> > Broker.defaultPersistenceBroker()
> > >              pm.beginTransaction();
> > >              pm.Store(zs);
> > >              pm.commitTransaction();
> > >
> > >          }
> > >          catch (Exception ex) {
> > >              ex.printStackTrace();
> > >              System.out.println("Error in Test1 1 ");
> > >              try {
> > >                  if ( tx != null )
> > >                       pm.abortTransaction();
> > >
> > >              catch (Exception ex1) {
> > >              }
> > >          }
> > >
> > >
> > >
> > >
> > >
> > >
> > >
> > >
> >
> >
>
> ---------------------------------------------------------------------
> > 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