You are viewing a plain text version of this content. The canonical link for it is here.
Posted to ojb-user@db.apache.org by Wesley Lemke <bu...@gmail.com> on 2004/12/02 22:51:19 UTC

Optimistic Locking Problem.

We are adding optimistic locking to our application.  To test it out I
have made a simple test case.  The application spawns two threads.

Thread A (ClientAdderDelay):  Reads an object from the database.  It
then checks the name of the ojbect.  If the name was 00000 it changes
it to 00001 and if the name was 00001 it changes it to 00000.  The
thread sleeps for 5 seconds and then stores the object.

Thread B (ClientAdder):  Does the same thing, but doesn't sleep 5
seconds between the read/store.

The main servlet starts thread A, then sleeps for 1 second and starts thread B.

The very first time I run the application everything works as it
should, Thread A and B both read 00000 from the database.  Thread B
then updates the row to be 00001.  Thread A gets and OptimisticLock
exception when it tries to store the object.

However all subsequent times that I run the application Thread A will
get the correct value from the database but thread B will get the
opposite value.  I am attaching the output, which will hopefully make
this more understandable.  The one difference I see is that the
Datasource gets a new connection the first time the Servlet is run,
but not the second...I wouldn't think that this would matter?

OUTPUT:

[12/2/04 15:47:56:436 CST] 797e3663 SystemErr     R
*************************** START ************************
[12/2/04 15:47:56:466 CST] 797e3663 SystemErr     R SERVLET:  Starting
ClientAdderDelay
[12/2/04 15:47:56:466 CST] 797e3663 SystemErr     R SERVLET:  Sleeping
1000 millis
[12/2/04 15:47:56:896 CST] 6de77661 Config        E
com.opensymphony.oscache.base.Config  Error reading
/oscache.properties in CacheAdministrator.loadProps()
java.lang.NullPointerException
[12/2/04 15:47:56:906 CST] 6de77661 Config        E
com.opensymphony.oscache.base.Config  Ensure the /oscache.properties
file is readable and in your classpath.
[12/2/04 15:47:56:916 CST] 6de77661 GeneralCacheA I
com.opensymphony.oscache.general.GeneralCacheAdministrator 
Constructed GeneralCacheAdministrator()
[12/2/04 15:47:56:916 CST] 6de77661 GeneralCacheA I
com.opensymphony.oscache.general.GeneralCacheAdministrator  Creating
new cache
[12/2/04 15:47:58:469 CST] 6de77661 DSConfigurati W DSRA0174W:
Warning: GenericDataStoreHelper is being used.
[12/2/04 15:47:58:629 CST] 6de77661 ConnectionFac I J2CA0122I:
Resource reference jdbc/ao79 could not be located, so default values
of the following are used: [Resource-ref settings]

	res-auth:                 1 (APPLICATION)
	res-isolation-level:      0 (TRANSACTION_NONE)
	res-sharing-scope:        true (SHAREABLE)
	res-resolution-control:   999 (undefined)
[Other attributes]

isCMP1_x:                 false (not CMP1.x)
isJMS:                 false (not JMS)

[12/2/04 15:47:58:669 CST] 6de77661 ConnectionFac I J2CA0107I:
Component-managed authentication alias not specified for connection
factory or datasource MySql Datasource on ao79.
[12/2/04 15:47:58:699 CST] 4b22f67d ConnectionFac I J2CA0122I:
Resource reference jdbc/ao79 could not be located, so default values
of the following are used: [Resource-ref settings]

	res-auth:                 1 (APPLICATION)
	res-isolation-level:      0 (TRANSACTION_NONE)
	res-sharing-scope:        true (SHAREABLE)
	res-resolution-control:   999 (undefined)
[Other attributes]

isCMP1_x:                 false (not CMP1.x)
isJMS:                 false (not JMS)

[12/2/04 15:47:58:699 CST] 6de77661 ConnectionMan W J2CA0075W: An
active transaction should be present while processing method
allocateMCWrapper.
[12/2/04 15:47:58:709 CST] 4b22f67d ConnectionMan W J2CA0075W: An
active transaction should be present while processing method
allocateMCWrapper.
[12/2/04 15:47:57:477 CST] 797e3663 SystemErr     R SERVLET:  Starting
ClientAdder
[12/2/04 15:47:57:477 CST] 797e3663 SystemErr     R SERVLET:  Joining
to ClientAdder
[12/2/04 15:47:59:170 CST] 4b22f67d WSRdbDataSour u Database version is
                                 3.23.41
[12/2/04 15:47:59:170 CST] 4b22f67d WSRdbDataSour u JDBC Driver version is
                                 mysql-connector-java-3.0.15-ga (
$Date: 2004/08/09 22:15:11 $, $Revision: 1.27.2.43 $ )
[12/2/04 15:47:59:250 CST] 4b22f67d ConnectionMan W J2CA0075W: An
active transaction should be present while processing method
initializeForUOW.
[12/2/04 15:47:59:250 CST] 6de77661 ConnectionMan W J2CA0075W: An
active transaction should be present while processing method
initializeForUOW.
[12/2/04 15:47:59:530 CST] 4b22f67d SystemErr     R CLIENTADDER: 
Before Update: 00000<br>
[12/2/04 15:47:59:560 CST] 4b22f67d SystemErr     R CLIENTADDER:
Changing name to 00001
[12/2/04 15:47:59:560 CST] 6de77661 SystemErr     R CLIENTADDERDELAY: 
Before Update: 00000<br>
[12/2/04 15:47:59:560 CST] 6de77661 SystemErr     R CLIENTADDERDELAY: 
Sleeping for 5000 millis
[12/2/04 15:47:59:570 CST] 4b22f67d ConnectionMan W J2CA0075W: An
active transaction should be present while processing method
allocateMCWrapper.
[12/2/04 15:47:59:570 CST] 4b22f67d ConnectionMan W J2CA0075W: An
active transaction should be present while processing method
initializeForUOW.
[12/2/04 15:47:59:590 CST] 4b22f67d SystemErr     R CLIENTADDER: 
After Update: 00001<br>
[12/2/04 15:47:59:590 CST] 797e3663 SystemErr     R SERVLET:  Joingin
to ClientAdderDelay
[12/2/04 15:48:04:557 CST] 6de77661 SystemErr     R CLIENTADDERDELAY:
Changing name to 00001
[12/2/04 15:48:04:617 CST] 6de77661 SystemErr     R
CLIENTADDERDELAY:org.apache.ojb.broker.OptimisticLockException: Object
has been modified by someone else
[12/2/04 15:48:04:617 CST] 6de77661 ConnectionMan W J2CA0075W: An
active transaction should be present while processing method
allocateMCWrapper.
[12/2/04 15:48:04:627 CST] 6de77661 ConnectionMan W J2CA0075W: An
active transaction should be present while processing method
initializeForUOW.
[12/2/04 15:48:04:637 CST] 6de77661 SystemErr     R CLIENTADDERDELAY: 
After Update: 00001<br>
[12/2/04 15:48:04:637 CST] 797e3663 SystemErr     R
*************************** END ************************
[12/2/04 15:48:47:729 CST] 797e3663 SystemErr     R
*************************** START ************************
[12/2/04 15:48:47:729 CST] 797e3663 SystemErr     R SERVLET:  Starting
ClientAdderDelay
[12/2/04 15:48:47:729 CST] 797e3663 SystemErr     R SERVLET:  Sleeping
1000 millis
[12/2/04 15:48:47:779 CST] 1ec7f672 ConnectionMan W J2CA0075W: An
active transaction should be present while processing method
allocateMCWrapper.
[12/2/04 15:48:47:840 CST] 1ec7f672 ConnectionMan W J2CA0075W: An
active transaction should be present while processing method
initializeForUOW.
[12/2/04 15:48:47:850 CST] 1ec7f672 SystemErr     R CLIENTADDERDELAY: 
Before Update: 00001<br>
[12/2/04 15:48:47:850 CST] 1ec7f672 SystemErr     R CLIENTADDERDELAY: 
Sleeping for 5000 millis
[12/2/04 15:48:48:931 CST] 797e3663 SystemErr     R SERVLET:  Starting
ClientAdder
[12/2/04 15:48:48:931 CST] 797e3663 SystemErr     R SERVLET:  Joining
to ClientAdder
[12/2/04 15:48:48:931 CST] 1ec0f672 ConnectionMan W J2CA0075W: An
active transaction should be present while processing method
allocateMCWrapper.
[12/2/04 15:48:49:031 CST] 1ec0f672 ConnectionMan W J2CA0075W: An
active transaction should be present while processing method
initializeForUOW.
[12/2/04 15:48:49:041 CST] 1ec0f672 SystemErr     R CLIENTADDER: 
Before Update: 00000<br>
[12/2/04 15:48:49:041 CST] 1ec0f672 SystemErr     R CLIENTADDER:
Changing name to 00001
[12/2/04 15:48:49:051 CST] 1ec0f672 ConnectionMan W J2CA0075W: An
active transaction should be present while processing method
allocateMCWrapper.
[12/2/04 15:48:49:061 CST] 1ec0f672 ConnectionMan W J2CA0075W: An
active transaction should be present while processing method
initializeForUOW.
[12/2/04 15:48:49:081 CST] 1ec0f672 SystemErr     R CLIENTADDER: 
After Update: 00001<br>
[12/2/04 15:48:49:081 CST] 797e3663 SystemErr     R SERVLET:  Joingin
to ClientAdderDelay
[12/2/04 15:48:52:857 CST] 1ec7f672 SystemErr     R CLIENTADDERDELAY:
Changing name to 00001
[12/2/04 15:48:52:857 CST] 1ec7f672 ConnectionMan W J2CA0075W: An
active transaction should be present while processing method
allocateMCWrapper.
[12/2/04 15:48:52:867 CST] 1ec7f672 ConnectionMan W J2CA0075W: An
active transaction should be present while processing method
initializeForUOW.
[12/2/04 15:48:52:877 CST] 1ec7f672 SystemErr     R CLIENTADDERDELAY: 
After Update: 00001<br>
[12/2/04 15:48:52:877 CST] 797e3663 SystemErr     R
*************************** END ************************

Let me know if any more information would be helpful...

---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-user-help@db.apache.org


Re: Problem with n:m association

Posted by Armin Waibel <ar...@apache.org>.
Thomas Papke wrote:

> Ok i have solved the problem.
> 
> There was no pk defined for my class called "meinung", because i develop 
> step by step and meinung was not yet complet (i found this with some 
> more debugging infos in ojb). So in detail there was not problem with my 
> n:m association.
> 
> So thanks for your help....
> But here you see that a better error message should occur - not only 
> devide by zero.
>

ok, will try add a better error message.

regards,
Armin


> Thomas
> 
> Armin Waibel schrieb:
> 
>>
>> Thomas Papke wrote:
>>
>>> Hi ...
>>>
>>> yes that could be the problem. For the tables "Produktgruppe" and 
>>> "Produkt", i have defined the primary keys in the deskriptor. The 
>>> table for decompose the n:m mapping "produkt_produktgruppe" - i have 
>>> nothing defined in the descriptor.
>>
>>
>>
>> As you are using a non-decomposed m:n relation the indirection table 
>> "produkt_produktgruppe" couldn't be a persistent class, so you 
>> shouldn't define a class-descriptor for the indirection table or set 
>> the FK fields from product and group as PK fields.
>>
>> regards,
>> Armin
>>
>>
>>> Because as described in the docs of ojb 
>>> http://db.apache.org/ojb/docu/guides/basic-technique.html#Support+for+Non-Decomposed+m%3An+Mappings 
>>> it should work.
>>>
>>> Did i something wrong?
>>> On the bottom of this email again the interessting parts of my 
>>> descriptor where you could see that i have defined the pk's for 
>>> produktgruppe and produkt in a correct way.
>>>
>>> Is the possibly a bug of ojb or is something necessary what is not 
>>> mentioned in the example for n:m ojb mapping?
>>>
>>> Thanks, Thomas
>>>
>>> Armin Waibel schrieb:
>>>
>>>> Hi Thomas,
>>>>
>>>> Thomas Papke wrote:
>>>>
>>>>> The excectly exception (after broker.getCollectionByQuery ...) i 
>>>>> got from ojb broker is:
>>>>>
>>>>> org.apache.ojb.broker.PersistenceBrokerException: 
>>>>> java.lang.ArithmeticException: / by zero
>>>>>
>>>>
>>>> In the source the causing line is
>>>>
>>>> at BasePrefetcher.<init>(BasePrefetcher.java:76)
>>>> ...
>>>> pkLimit = getPrefetchInLimit() / 
>>>> getItemClassDescriptor().getPkFields().length;
>>>> ...
>>>>
>>>> Seems that OJB get a persistent class without defined PK fields. 
>>>> Could this be the case?
>>>>
>>>> regards,
>>>> Armin
>>>>
>>>>
>>>>> Thomas Papke schrieb:
>>>>>
>>>>>> Thanks for your answer.
>>>>>>
>>>>>> I need the inId because its like ebay: in each productgroup there 
>>>>>> is a collection of "untergruppen/undergroups". And this works: i 
>>>>>> could add objects of produktgruppe and save them (so inId will 
>>>>>> store the reference to the main productgroup).
>>>>>>
>>>>>> The problem is not between productgroup and productgroup (1:n) - 
>>>>>> it is between Productgroup and Product (n:m)
>>>>>>
>>>>>> And why did i got a arithmetic exception (/ by zero) from the ojb 
>>>>>> core??
>>>>>>
>>>>>> I found also something strange:
>>>>>> The OJB Framwork and my Application runs in a Tomcat environment.
>>>>>> If i start tomcat and then my app - i got the error! If i start my 
>>>>>> app a seconde time everthing works fine ...
>>>>>>
>>>>>> Thanks for help, Thomas
>>>>>>
>>>>>>
>>>>>> Thomas Franke schrieb:
>>>>>>
>>>>>>> Thomas Papke wrote:
>>>>>>>
>>>>>>> Why you need the inId?
>>>>>>>
>>>>>>>
>>>>>>>> Here is my descriptor of the two classes:
>>>>>>>>
>>>>>>>> <class-descriptor
>>>>>>>>    class="de.ba.studi.chtp.model.Produktgruppe"
>>>>>>>>    table="Produktgruppe"
>>>>>>>>  >
>>>>>>>>    <field-descriptor
>>>>>>>>        name="id"
>>>>>>>>        column="id"
>>>>>>>>        jdbc-type="INTEGER"
>>>>>>>>        primarykey="true"
>>>>>>>>        autoincrement="true"
>>>>>>>>    >
>>>>>>>>    </field-descriptor>
>>>>>>>>    <field-descriptor
>>>>>>>>        name="inId"
>>>>>>>>        column="inId"
>>>>>>>>        jdbc-type="INTEGER"
>>>>>>>>    >
>>>>>>>>    </field-descriptor>
>>>>>>>>    <field-descriptor
>>>>>>>>        name="name"
>>>>>>>>        column="name"
>>>>>>>>        jdbc-type="VARCHAR"
>>>>>>>>    >
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>> I thing this can't work and I thing also it is a wrong design:
>>>>>>>
>>>>>>>>    </field-descriptor>
>>>>>>>>    <collection-descriptor
>>>>>>>>       name="produktgruppen"
>>>>>>>>       element-class-ref="de.ba.studi.chtp.model.Produktgruppe"
>>>>>>>>       orderby="inId"
>>>>>>>>       sort="DESC"
>>>>>>>>       auto-retrieve="true"
>>>>>>>>       auto-update="true"
>>>>>>>>       auto-delete="true"
>>>>>>>>    >
>>>>>>>>       <inverse-foreignkey field-ref="inId"/>
>>>>>>>>    </collection-descriptor>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>>    <collection-descriptor
>>>>>>>>       name="produkt"
>>>>>>>>       element-class-ref="de.ba.studi.chtp.model.Produkt"
>>>>>>>>       auto-retrieve="true"
>>>>>>>>       auto-update="true"
>>>>>>>>       indirection-table="produkt_produktgruppe"
>>>>>>>>  >
>>>>>>>>       <fk-pointing-to-this-class column="ProdGruppe_id"/>
>>>>>>>>       <fk-pointing-to-element-class column="Prod_Id"/>
>>>>>>>>  </collection-descriptor>
>>>>>>>> </class-descriptor>
>>>>>>>>
>>>>>>>
>>>>>>> Take into your Produkt class a collection descriptor with 
>>>>>>> Produktgruppe classes.
>>>>>>> For that case I would write a spezial mapping for Produktgruppe 
>>>>>>> without a collection with Produkt class.
>>>>>>>
>>>>>>>> <class-descriptor
>>>>>>>>    class="de.ba.studi.chtp.model.Produkt"
>>>>>>>>    table="Produkt"
>>>>>>>>  >
>>>>>>>>    <field-descriptor
>>>>>>>>        name="id"
>>>>>>>>        column="id"
>>>>>>>>        jdbc-type="INTEGER"
>>>>>>>>        primarykey="true"
>>>>>>>>        autoincrement="true"
>>>>>>>>    >
>>>>>>>>    </field-descriptor>
>>>>>>>>    <field-descriptor
>>>>>>>>        name="name"
>>>>>>>>        column="name"
>>>>>>>>        jdbc-type="VARCHAR"
>>>>>>>>    >
>>>>>>>>    </field-descriptor>
>>>>>>>>
>>>>>>>>
>>>>>>>>  <collection-descriptor
>>>>>>>>       name="meinung"
>>>>>>>>       element-class-ref="de.ba.studi.chtp.model.Meinung"
>>>>>>>>       auto-retrieve="true"
>>>>>>>>       auto-update="true"
>>>>>>>>  >
>>>>>>>>       <inverse-foreignkey field-ref="prod_id"/>
>>>>>>>>  </collection-descriptor>
>>>>>>>>   </class-descriptor>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>> --------------------------------------------------------------------- 
>>>>>>>
>>>>>>> To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
>>>>>>> For additional commands, e-mail: ojb-user-help@db.apache.org
>>>>>>>
>>>>>>>
>>>>>>
>>>>>> ---------------------------------------------------------------------
>>>>>> To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
>>>>>> For additional commands, e-mail: ojb-user-help@db.apache.org
>>>>>>
>>>>>>
>>>>>
>>>>> ---------------------------------------------------------------------
>>>>> To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
>>>>> For additional commands, e-mail: ojb-user-help@db.apache.org
>>>>>
>>>>>
>>>>>
>>>>
>>>> ---------------------------------------------------------------------
>>>> To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
>>>> For additional commands, e-mail: ojb-user-help@db.apache.org
>>>>
>>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
>>> For additional commands, e-mail: ojb-user-help@db.apache.org
>>>
>>>
>>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
>> For additional commands, e-mail: ojb-user-help@db.apache.org
>>
>>
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
> For additional commands, e-mail: ojb-user-help@db.apache.org
> 
> 
> 

---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-user-help@db.apache.org


Re: Problem with n:m association

Posted by Thomas Papke <we...@thopap.de>.
Ok i have solved the problem.

There was no pk defined for my class called "meinung", because i develop 
step by step and meinung was not yet complet (i found this with some 
more debugging infos in ojb). So in detail there was not problem with my 
n:m association.

So thanks for your help....
But here you see that a better error message should occur - not only 
devide by zero.

Thomas

Armin Waibel schrieb:

>
> Thomas Papke wrote:
>
>> Hi ...
>>
>> yes that could be the problem. For the tables "Produktgruppe" and 
>> "Produkt", i have defined the primary keys in the deskriptor. The 
>> table for decompose the n:m mapping "produkt_produktgruppe" - i have 
>> nothing defined in the descriptor.
>
>
> As you are using a non-decomposed m:n relation the indirection table 
> "produkt_produktgruppe" couldn't be a persistent class, so you 
> shouldn't define a class-descriptor for the indirection table or set 
> the FK fields from product and group as PK fields.
>
> regards,
> Armin
>
>
>> Because as described in the docs of ojb 
>> http://db.apache.org/ojb/docu/guides/basic-technique.html#Support+for+Non-Decomposed+m%3An+Mappings 
>> it should work.
>>
>> Did i something wrong?
>> On the bottom of this email again the interessting parts of my 
>> descriptor where you could see that i have defined the pk's for 
>> produktgruppe and produkt in a correct way.
>>
>> Is the possibly a bug of ojb or is something necessary what is not 
>> mentioned in the example for n:m ojb mapping?
>>
>> Thanks, Thomas
>>
>> Armin Waibel schrieb:
>>
>>> Hi Thomas,
>>>
>>> Thomas Papke wrote:
>>>
>>>> The excectly exception (after broker.getCollectionByQuery ...) i 
>>>> got from ojb broker is:
>>>>
>>>> org.apache.ojb.broker.PersistenceBrokerException: 
>>>> java.lang.ArithmeticException: / by zero
>>>>
>>>
>>> In the source the causing line is
>>>
>>> at BasePrefetcher.<init>(BasePrefetcher.java:76)
>>> ...
>>> pkLimit = getPrefetchInLimit() / 
>>> getItemClassDescriptor().getPkFields().length;
>>> ...
>>>
>>> Seems that OJB get a persistent class without defined PK fields. 
>>> Could this be the case?
>>>
>>> regards,
>>> Armin
>>>
>>>
>>>> Thomas Papke schrieb:
>>>>
>>>>> Thanks for your answer.
>>>>>
>>>>> I need the inId because its like ebay: in each productgroup there 
>>>>> is a collection of "untergruppen/undergroups". And this works: i 
>>>>> could add objects of produktgruppe and save them (so inId will 
>>>>> store the reference to the main productgroup).
>>>>>
>>>>> The problem is not between productgroup and productgroup (1:n) - 
>>>>> it is between Productgroup and Product (n:m)
>>>>>
>>>>> And why did i got a arithmetic exception (/ by zero) from the ojb 
>>>>> core??
>>>>>
>>>>> I found also something strange:
>>>>> The OJB Framwork and my Application runs in a Tomcat environment.
>>>>> If i start tomcat and then my app - i got the error! If i start my 
>>>>> app a seconde time everthing works fine ...
>>>>>
>>>>> Thanks for help, Thomas
>>>>>
>>>>>
>>>>> Thomas Franke schrieb:
>>>>>
>>>>>> Thomas Papke wrote:
>>>>>>
>>>>>> Why you need the inId?
>>>>>>
>>>>>>
>>>>>>> Here is my descriptor of the two classes:
>>>>>>>
>>>>>>> <class-descriptor
>>>>>>>    class="de.ba.studi.chtp.model.Produktgruppe"
>>>>>>>    table="Produktgruppe"
>>>>>>>  >
>>>>>>>    <field-descriptor
>>>>>>>        name="id"
>>>>>>>        column="id"
>>>>>>>        jdbc-type="INTEGER"
>>>>>>>        primarykey="true"
>>>>>>>        autoincrement="true"
>>>>>>>    >
>>>>>>>    </field-descriptor>
>>>>>>>    <field-descriptor
>>>>>>>        name="inId"
>>>>>>>        column="inId"
>>>>>>>        jdbc-type="INTEGER"
>>>>>>>    >
>>>>>>>    </field-descriptor>
>>>>>>>    <field-descriptor
>>>>>>>        name="name"
>>>>>>>        column="name"
>>>>>>>        jdbc-type="VARCHAR"
>>>>>>>    >
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>> I thing this can't work and I thing also it is a wrong design:
>>>>>>
>>>>>>>    </field-descriptor>
>>>>>>>    <collection-descriptor
>>>>>>>       name="produktgruppen"
>>>>>>>       element-class-ref="de.ba.studi.chtp.model.Produktgruppe"
>>>>>>>       orderby="inId"
>>>>>>>       sort="DESC"
>>>>>>>       auto-retrieve="true"
>>>>>>>       auto-update="true"
>>>>>>>       auto-delete="true"
>>>>>>>    >
>>>>>>>       <inverse-foreignkey field-ref="inId"/>
>>>>>>>    </collection-descriptor>
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>>>    <collection-descriptor
>>>>>>>       name="produkt"
>>>>>>>       element-class-ref="de.ba.studi.chtp.model.Produkt"
>>>>>>>       auto-retrieve="true"
>>>>>>>       auto-update="true"
>>>>>>>       indirection-table="produkt_produktgruppe"
>>>>>>>  >
>>>>>>>       <fk-pointing-to-this-class column="ProdGruppe_id"/>
>>>>>>>       <fk-pointing-to-element-class column="Prod_Id"/>
>>>>>>>  </collection-descriptor>
>>>>>>> </class-descriptor>
>>>>>>>
>>>>>>
>>>>>> Take into your Produkt class a collection descriptor with 
>>>>>> Produktgruppe classes.
>>>>>> For that case I would write a spezial mapping for Produktgruppe 
>>>>>> without a collection with Produkt class.
>>>>>>
>>>>>>> <class-descriptor
>>>>>>>    class="de.ba.studi.chtp.model.Produkt"
>>>>>>>    table="Produkt"
>>>>>>>  >
>>>>>>>    <field-descriptor
>>>>>>>        name="id"
>>>>>>>        column="id"
>>>>>>>        jdbc-type="INTEGER"
>>>>>>>        primarykey="true"
>>>>>>>        autoincrement="true"
>>>>>>>    >
>>>>>>>    </field-descriptor>
>>>>>>>    <field-descriptor
>>>>>>>        name="name"
>>>>>>>        column="name"
>>>>>>>        jdbc-type="VARCHAR"
>>>>>>>    >
>>>>>>>    </field-descriptor>
>>>>>>>
>>>>>>>
>>>>>>>  <collection-descriptor
>>>>>>>       name="meinung"
>>>>>>>       element-class-ref="de.ba.studi.chtp.model.Meinung"
>>>>>>>       auto-retrieve="true"
>>>>>>>       auto-update="true"
>>>>>>>  >
>>>>>>>       <inverse-foreignkey field-ref="prod_id"/>
>>>>>>>  </collection-descriptor>
>>>>>>>   </class-descriptor>
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>> --------------------------------------------------------------------- 
>>>>>>
>>>>>> To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
>>>>>> For additional commands, e-mail: ojb-user-help@db.apache.org
>>>>>>
>>>>>>
>>>>>
>>>>> ---------------------------------------------------------------------
>>>>> To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
>>>>> For additional commands, e-mail: ojb-user-help@db.apache.org
>>>>>
>>>>>
>>>>
>>>> ---------------------------------------------------------------------
>>>> To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
>>>> For additional commands, e-mail: ojb-user-help@db.apache.org
>>>>
>>>>
>>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
>>> For additional commands, e-mail: ojb-user-help@db.apache.org
>>>
>>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
>> For additional commands, e-mail: ojb-user-help@db.apache.org
>>
>>
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
> For additional commands, e-mail: ojb-user-help@db.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-user-help@db.apache.org


Re: Problem with n:m association

Posted by Armin Waibel <ar...@apache.org>.
Thomas Papke wrote:

> As you say, i have no no class-descriptor for the indirection table! I 
> also very strange why i only get the exception from ojb the first time 
> the application starts in the tomcat env. - the seconde time and so one 
> everthing works fine. After restart of tomcat (and the java vm) - the 
> same again :-/
>

Strange! Could you add some logging statements in BasePrefetcher 
constructor before field 'pkLimit' (which causing the exception). So we 
will see which persistent class cause the isssue.

regards,
Armin


> <class-descriptor
>    class="de.ba.studi.chtp.model.Produktgruppe"
>    table="Produktgruppe"
>  >
>    <field-descriptor
>        name="id"
>        column="id"
>        jdbc-type="INTEGER"
>        primarykey="true"
>        autoincrement="true"
>    >
>    </field-descriptor>
>    <field-descriptor
>        name="inId"
>        column="inId"
>        jdbc-type="INTEGER"
>    >
>    </field-descriptor>
>    <field-descriptor
>        name="name"
>        column="name"
>        jdbc-type="VARCHAR"
>    >
>    </field-descriptor>
>    <collection-descriptor
>       name="produktgruppen"
>       element-class-ref="de.ba.studi.chtp.model.Produktgruppe"
>       orderby="inId"
>       sort="DESC"
>       auto-retrieve="true"
>       auto-update="true"
>       auto-delete="true"
>    >
>       <inverse-foreignkey field-ref="inId"/>
>    </collection-descriptor>
>    <collection-descriptor
>       name="produkt"
>       element-class-ref="de.ba.studi.chtp.model.Produkt"
>       auto-retrieve="true"
>       auto-update="true"
>       indirection-table="produkt_produktgruppe"
>  >
> *      <fk-pointing-to-this-class column="ProdGruppe_id"/>
>       <fk-pointing-to-element-class column="Prod_Id"/>*
>  </collection-descriptor>
> </class-descriptor>
> 
> <class-descriptor
>    class="de.ba.studi.chtp.model.Produkt"
>    table="Produkt"
>  >
>    <field-descriptor
>        name="id"
>        column="id"
>        jdbc-type="INTEGER"
>        primarykey="true"
>        autoincrement="true"
>    >
>    </field-descriptor>
>    <field-descriptor
>        name="name"
>        column="name"
>        jdbc-type="VARCHAR"
>    >
>    </field-descriptor>
> 
> 
>  <collection-descriptor
>       name="meinung"
>       element-class-ref="de.ba.studi.chtp.model.Meinung"
>       auto-retrieve="true"
>       auto-update="true"
>  >
>       <inverse-foreignkey field-ref="prod_id"/>
>  </collection-descriptor>
>   </class-descriptor>
> 
> Thomas
> 
> Armin Waibel schrieb:
> 
>>
>> Thomas Papke wrote:
>>
>>> Hi ...
>>>
>>> yes that could be the problem. For the tables "Produktgruppe" and 
>>> "Produkt", i have defined the primary keys in the deskriptor. The 
>>> table for decompose the n:m mapping "produkt_produktgruppe" - i have 
>>> nothing defined in the descriptor.
>>
>>
>>
>> As you are using a non-decomposed m:n relation the indirection table 
>> "produkt_produktgruppe" couldn't be a persistent class, so you 
>> shouldn't define a class-descriptor for the indirection table or set 
>> the FK fields from product and group as PK fields.
>>
>> regards,
>> Armin
>>
>>
>>> Because as described in the docs of ojb 
>>> http://db.apache.org/ojb/docu/guides/basic-technique.html#Support+for+Non-Decomposed+m%3An+Mappings 
>>> it should work.
>>>
>>> Did i something wrong?
>>> On the bottom of this email again the interessting parts of my 
>>> descriptor where you could see that i have defined the pk's for 
>>> produktgruppe and produkt in a correct way.
>>>
>>> Is the possibly a bug of ojb or is something necessary what is not 
>>> mentioned in the example for n:m ojb mapping?
>>>
>>> Thanks, Thomas
>>>
>>> Armin Waibel schrieb:
>>>
>>>> Hi Thomas,
>>>>
>>>> Thomas Papke wrote:
>>>>
>>>>> The excectly exception (after broker.getCollectionByQuery ...) i 
>>>>> got from ojb broker is:
>>>>>
>>>>> org.apache.ojb.broker.PersistenceBrokerException: 
>>>>> java.lang.ArithmeticException: / by zero
>>>>>
>>>>
>>>> In the source the causing line is
>>>>
>>>> at BasePrefetcher.<init>(BasePrefetcher.java:76)
>>>> ...
>>>> pkLimit = getPrefetchInLimit() / 
>>>> getItemClassDescriptor().getPkFields().length;
>>>> ...
>>>>
>>>> Seems that OJB get a persistent class without defined PK fields. 
>>>> Could this be the case?
>>>>
>>>> regards,
>>>> Armin
>>>>
>>>>
>>>>> Thomas Papke schrieb:
>>>>>
>>>>>> Thanks for your answer.
>>>>>>
>>>>>> I need the inId because its like ebay: in each productgroup there 
>>>>>> is a collection of "untergruppen/undergroups". And this works: i 
>>>>>> could add objects of produktgruppe and save them (so inId will 
>>>>>> store the reference to the main productgroup).
>>>>>>
>>>>>> The problem is not between productgroup and productgroup (1:n) - 
>>>>>> it is between Productgroup and Product (n:m)
>>>>>>
>>>>>> And why did i got a arithmetic exception (/ by zero) from the ojb 
>>>>>> core??
>>>>>>
>>>>>> I found also something strange:
>>>>>> The OJB Framwork and my Application runs in a Tomcat environment.
>>>>>> If i start tomcat and then my app - i got the error! If i start my 
>>>>>> app a seconde time everthing works fine ...
>>>>>>
>>>>>> Thanks for help, Thomas
>>>>>>
>>>>>>
>>>>>> Thomas Franke schrieb:
>>>>>>
>>>>>>> Thomas Papke wrote:
>>>>>>>
>>>>>>> Why you need the inId?
>>>>>>>
>>>>>>>
>>>>>>>> Here is my descriptor of the two classes:
>>>>>>>>
>>>>>>>> <class-descriptor
>>>>>>>>    class="de.ba.studi.chtp.model.Produktgruppe"
>>>>>>>>    table="Produktgruppe"
>>>>>>>>  >
>>>>>>>>    <field-descriptor
>>>>>>>>        name="id"
>>>>>>>>        column="id"
>>>>>>>>        jdbc-type="INTEGER"
>>>>>>>>        primarykey="true"
>>>>>>>>        autoincrement="true"
>>>>>>>>    >
>>>>>>>>    </field-descriptor>
>>>>>>>>    <field-descriptor
>>>>>>>>        name="inId"
>>>>>>>>        column="inId"
>>>>>>>>        jdbc-type="INTEGER"
>>>>>>>>    >
>>>>>>>>    </field-descriptor>
>>>>>>>>    <field-descriptor
>>>>>>>>        name="name"
>>>>>>>>        column="name"
>>>>>>>>        jdbc-type="VARCHAR"
>>>>>>>>    >
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>> I thing this can't work and I thing also it is a wrong design:
>>>>>>>
>>>>>>>>    </field-descriptor>
>>>>>>>>    <collection-descriptor
>>>>>>>>       name="produktgruppen"
>>>>>>>>       element-class-ref="de.ba.studi.chtp.model.Produktgruppe"
>>>>>>>>       orderby="inId"
>>>>>>>>       sort="DESC"
>>>>>>>>       auto-retrieve="true"
>>>>>>>>       auto-update="true"
>>>>>>>>       auto-delete="true"
>>>>>>>>    >
>>>>>>>>       <inverse-foreignkey field-ref="inId"/>
>>>>>>>>    </collection-descriptor>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>>    <collection-descriptor
>>>>>>>>       name="produkt"
>>>>>>>>       element-class-ref="de.ba.studi.chtp.model.Produkt"
>>>>>>>>       auto-retrieve="true"
>>>>>>>>       auto-update="true"
>>>>>>>>       indirection-table="produkt_produktgruppe"
>>>>>>>>  >
>>>>>>>>       <fk-pointing-to-this-class column="ProdGruppe_id"/>
>>>>>>>>       <fk-pointing-to-element-class column="Prod_Id"/>
>>>>>>>>  </collection-descriptor>
>>>>>>>> </class-descriptor>
>>>>>>>>
>>>>>>>
>>>>>>> Take into your Produkt class a collection descriptor with 
>>>>>>> Produktgruppe classes.
>>>>>>> For that case I would write a spezial mapping for Produktgruppe 
>>>>>>> without a collection with Produkt class.
>>>>>>>
>>>>>>>> <class-descriptor
>>>>>>>>    class="de.ba.studi.chtp.model.Produkt"
>>>>>>>>    table="Produkt"
>>>>>>>>  >
>>>>>>>>    <field-descriptor
>>>>>>>>        name="id"
>>>>>>>>        column="id"
>>>>>>>>        jdbc-type="INTEGER"
>>>>>>>>        primarykey="true"
>>>>>>>>        autoincrement="true"
>>>>>>>>    >
>>>>>>>>    </field-descriptor>
>>>>>>>>    <field-descriptor
>>>>>>>>        name="name"
>>>>>>>>        column="name"
>>>>>>>>        jdbc-type="VARCHAR"
>>>>>>>>    >
>>>>>>>>    </field-descriptor>
>>>>>>>>
>>>>>>>>
>>>>>>>>  <collection-descriptor
>>>>>>>>       name="meinung"
>>>>>>>>       element-class-ref="de.ba.studi.chtp.model.Meinung"
>>>>>>>>       auto-retrieve="true"
>>>>>>>>       auto-update="true"
>>>>>>>>  >
>>>>>>>>       <inverse-foreignkey field-ref="prod_id"/>
>>>>>>>>  </collection-descriptor>
>>>>>>>>   </class-descriptor>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>> --------------------------------------------------------------------- 
>>>>>>>
>>>>>>> To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
>>>>>>> For additional commands, e-mail: ojb-user-help@db.apache.org
>>>>>>>
>>>>>>>
>>>>>>
>>>>>> ---------------------------------------------------------------------
>>>>>> To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
>>>>>> For additional commands, e-mail: ojb-user-help@db.apache.org
>>>>>>
>>>>>>
>>>>>
>>>>> ---------------------------------------------------------------------
>>>>> To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
>>>>> For additional commands, e-mail: ojb-user-help@db.apache.org
>>>>>
>>>>>
>>>>>
>>>>
>>>> ---------------------------------------------------------------------
>>>> To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
>>>> For additional commands, e-mail: ojb-user-help@db.apache.org
>>>>
>>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
>>> For additional commands, e-mail: ojb-user-help@db.apache.org
>>>
>>>
>>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
>> For additional commands, e-mail: ojb-user-help@db.apache.org
>>
>>
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
> For additional commands, e-mail: ojb-user-help@db.apache.org
> 
> 
> 

---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-user-help@db.apache.org


Re: Problem with n:m association

Posted by Thomas Papke <we...@thopap.de>.
As you say, i have no no class-descriptor for the indirection table! I 
also very strange why i only get the exception from ojb the first time 
the application starts in the tomcat env. - the seconde time and so one 
everthing works fine. After restart of tomcat (and the java vm) - the 
same again :-/

<class-descriptor
    class="de.ba.studi.chtp.model.Produktgruppe"
    table="Produktgruppe"
 >
    <field-descriptor
        name="id"
        column="id"
        jdbc-type="INTEGER"
        primarykey="true"
        autoincrement="true"
    >
    </field-descriptor>
    <field-descriptor
        name="inId"
        column="inId"
        jdbc-type="INTEGER"
    >
    </field-descriptor>
    <field-descriptor
        name="name"
        column="name"
        jdbc-type="VARCHAR"
    >
    </field-descriptor>
    <collection-descriptor
       name="produktgruppen"
       element-class-ref="de.ba.studi.chtp.model.Produktgruppe"
       orderby="inId"
       sort="DESC"
       auto-retrieve="true"
       auto-update="true"
       auto-delete="true"
    >
       <inverse-foreignkey field-ref="inId"/>
    </collection-descriptor>
    <collection-descriptor
       name="produkt"
       element-class-ref="de.ba.studi.chtp.model.Produkt"
       auto-retrieve="true"
       auto-update="true"
       indirection-table="produkt_produktgruppe"
  >
 *      <fk-pointing-to-this-class column="ProdGruppe_id"/>
       <fk-pointing-to-element-class column="Prod_Id"/>*
  </collection-descriptor>
</class-descriptor>

<class-descriptor
    class="de.ba.studi.chtp.model.Produkt"
    table="Produkt"
 >
    <field-descriptor
        name="id"
        column="id"
        jdbc-type="INTEGER"
        primarykey="true"
        autoincrement="true"
    >
    </field-descriptor>
    <field-descriptor
        name="name"
        column="name"
        jdbc-type="VARCHAR"
    >
    </field-descriptor>

 
  <collection-descriptor
       name="meinung"
       element-class-ref="de.ba.studi.chtp.model.Meinung"
       auto-retrieve="true"
       auto-update="true"
  >
       <inverse-foreignkey field-ref="prod_id"/>
  </collection-descriptor>
   
</class-descriptor>

Thomas

Armin Waibel schrieb:

>
> Thomas Papke wrote:
>
>> Hi ...
>>
>> yes that could be the problem. For the tables "Produktgruppe" and 
>> "Produkt", i have defined the primary keys in the deskriptor. The 
>> table for decompose the n:m mapping "produkt_produktgruppe" - i have 
>> nothing defined in the descriptor.
>
>
> As you are using a non-decomposed m:n relation the indirection table 
> "produkt_produktgruppe" couldn't be a persistent class, so you 
> shouldn't define a class-descriptor for the indirection table or set 
> the FK fields from product and group as PK fields.
>
> regards,
> Armin
>
>
>> Because as described in the docs of ojb 
>> http://db.apache.org/ojb/docu/guides/basic-technique.html#Support+for+Non-Decomposed+m%3An+Mappings 
>> it should work.
>>
>> Did i something wrong?
>> On the bottom of this email again the interessting parts of my 
>> descriptor where you could see that i have defined the pk's for 
>> produktgruppe and produkt in a correct way.
>>
>> Is the possibly a bug of ojb or is something necessary what is not 
>> mentioned in the example for n:m ojb mapping?
>>
>> Thanks, Thomas
>>
>> Armin Waibel schrieb:
>>
>>> Hi Thomas,
>>>
>>> Thomas Papke wrote:
>>>
>>>> The excectly exception (after broker.getCollectionByQuery ...) i 
>>>> got from ojb broker is:
>>>>
>>>> org.apache.ojb.broker.PersistenceBrokerException: 
>>>> java.lang.ArithmeticException: / by zero
>>>>
>>>
>>> In the source the causing line is
>>>
>>> at BasePrefetcher.<init>(BasePrefetcher.java:76)
>>> ...
>>> pkLimit = getPrefetchInLimit() / 
>>> getItemClassDescriptor().getPkFields().length;
>>> ...
>>>
>>> Seems that OJB get a persistent class without defined PK fields. 
>>> Could this be the case?
>>>
>>> regards,
>>> Armin
>>>
>>>
>>>> Thomas Papke schrieb:
>>>>
>>>>> Thanks for your answer.
>>>>>
>>>>> I need the inId because its like ebay: in each productgroup there 
>>>>> is a collection of "untergruppen/undergroups". And this works: i 
>>>>> could add objects of produktgruppe and save them (so inId will 
>>>>> store the reference to the main productgroup).
>>>>>
>>>>> The problem is not between productgroup and productgroup (1:n) - 
>>>>> it is between Productgroup and Product (n:m)
>>>>>
>>>>> And why did i got a arithmetic exception (/ by zero) from the ojb 
>>>>> core??
>>>>>
>>>>> I found also something strange:
>>>>> The OJB Framwork and my Application runs in a Tomcat environment.
>>>>> If i start tomcat and then my app - i got the error! If i start my 
>>>>> app a seconde time everthing works fine ...
>>>>>
>>>>> Thanks for help, Thomas
>>>>>
>>>>>
>>>>> Thomas Franke schrieb:
>>>>>
>>>>>> Thomas Papke wrote:
>>>>>>
>>>>>> Why you need the inId?
>>>>>>
>>>>>>
>>>>>>> Here is my descriptor of the two classes:
>>>>>>>
>>>>>>> <class-descriptor
>>>>>>>    class="de.ba.studi.chtp.model.Produktgruppe"
>>>>>>>    table="Produktgruppe"
>>>>>>>  >
>>>>>>>    <field-descriptor
>>>>>>>        name="id"
>>>>>>>        column="id"
>>>>>>>        jdbc-type="INTEGER"
>>>>>>>        primarykey="true"
>>>>>>>        autoincrement="true"
>>>>>>>    >
>>>>>>>    </field-descriptor>
>>>>>>>    <field-descriptor
>>>>>>>        name="inId"
>>>>>>>        column="inId"
>>>>>>>        jdbc-type="INTEGER"
>>>>>>>    >
>>>>>>>    </field-descriptor>
>>>>>>>    <field-descriptor
>>>>>>>        name="name"
>>>>>>>        column="name"
>>>>>>>        jdbc-type="VARCHAR"
>>>>>>>    >
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>> I thing this can't work and I thing also it is a wrong design:
>>>>>>
>>>>>>>    </field-descriptor>
>>>>>>>    <collection-descriptor
>>>>>>>       name="produktgruppen"
>>>>>>>       element-class-ref="de.ba.studi.chtp.model.Produktgruppe"
>>>>>>>       orderby="inId"
>>>>>>>       sort="DESC"
>>>>>>>       auto-retrieve="true"
>>>>>>>       auto-update="true"
>>>>>>>       auto-delete="true"
>>>>>>>    >
>>>>>>>       <inverse-foreignkey field-ref="inId"/>
>>>>>>>    </collection-descriptor>
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>>>    <collection-descriptor
>>>>>>>       name="produkt"
>>>>>>>       element-class-ref="de.ba.studi.chtp.model.Produkt"
>>>>>>>       auto-retrieve="true"
>>>>>>>       auto-update="true"
>>>>>>>       indirection-table="produkt_produktgruppe"
>>>>>>>  >
>>>>>>>       <fk-pointing-to-this-class column="ProdGruppe_id"/>
>>>>>>>       <fk-pointing-to-element-class column="Prod_Id"/>
>>>>>>>  </collection-descriptor>
>>>>>>> </class-descriptor>
>>>>>>>
>>>>>>
>>>>>> Take into your Produkt class a collection descriptor with 
>>>>>> Produktgruppe classes.
>>>>>> For that case I would write a spezial mapping for Produktgruppe 
>>>>>> without a collection with Produkt class.
>>>>>>
>>>>>>> <class-descriptor
>>>>>>>    class="de.ba.studi.chtp.model.Produkt"
>>>>>>>    table="Produkt"
>>>>>>>  >
>>>>>>>    <field-descriptor
>>>>>>>        name="id"
>>>>>>>        column="id"
>>>>>>>        jdbc-type="INTEGER"
>>>>>>>        primarykey="true"
>>>>>>>        autoincrement="true"
>>>>>>>    >
>>>>>>>    </field-descriptor>
>>>>>>>    <field-descriptor
>>>>>>>        name="name"
>>>>>>>        column="name"
>>>>>>>        jdbc-type="VARCHAR"
>>>>>>>    >
>>>>>>>    </field-descriptor>
>>>>>>>
>>>>>>>
>>>>>>>  <collection-descriptor
>>>>>>>       name="meinung"
>>>>>>>       element-class-ref="de.ba.studi.chtp.model.Meinung"
>>>>>>>       auto-retrieve="true"
>>>>>>>       auto-update="true"
>>>>>>>  >
>>>>>>>       <inverse-foreignkey field-ref="prod_id"/>
>>>>>>>  </collection-descriptor>
>>>>>>>   </class-descriptor>
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>> --------------------------------------------------------------------- 
>>>>>>
>>>>>> To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
>>>>>> For additional commands, e-mail: ojb-user-help@db.apache.org
>>>>>>
>>>>>>
>>>>>
>>>>> ---------------------------------------------------------------------
>>>>> To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
>>>>> For additional commands, e-mail: ojb-user-help@db.apache.org
>>>>>
>>>>>
>>>>
>>>> ---------------------------------------------------------------------
>>>> To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
>>>> For additional commands, e-mail: ojb-user-help@db.apache.org
>>>>
>>>>
>>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
>>> For additional commands, e-mail: ojb-user-help@db.apache.org
>>>
>>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
>> For additional commands, e-mail: ojb-user-help@db.apache.org
>>
>>
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
> For additional commands, e-mail: ojb-user-help@db.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-user-help@db.apache.org


Re: Problem with n:m association

Posted by Armin Waibel <ar...@apache.org>.
Thomas Papke wrote:

> Hi ...
> 
> yes that could be the problem. For the tables "Produktgruppe" and 
> "Produkt", i have defined the primary keys in the deskriptor. The table 
> for decompose the n:m mapping "produkt_produktgruppe" - i have nothing 
> defined in the descriptor.

As you are using a non-decomposed m:n relation the indirection table 
"produkt_produktgruppe" couldn't be a persistent class, so you shouldn't 
define a class-descriptor for the indirection table or set the FK fields 
from product and group as PK fields.

regards,
Armin


> Because as described in the docs of ojb 
> http://db.apache.org/ojb/docu/guides/basic-technique.html#Support+for+Non-Decomposed+m%3An+Mappings 
> it should work.
> 
> Did i something wrong?
> On the bottom of this email again the interessting parts of my 
> descriptor where you could see that i have defined the pk's for 
> produktgruppe and produkt in a correct way.
> 
> Is the possibly a bug of ojb or is something necessary what is not 
> mentioned in the example for n:m ojb mapping?
> 
> Thanks, Thomas
> 
> Armin Waibel schrieb:
> 
>> Hi Thomas,
>>
>> Thomas Papke wrote:
>>
>>> The excectly exception (after broker.getCollectionByQuery ...) i got 
>>> from ojb broker is:
>>>
>>> org.apache.ojb.broker.PersistenceBrokerException: 
>>> java.lang.ArithmeticException: / by zero
>>>
>>
>> In the source the causing line is
>>
>> at BasePrefetcher.<init>(BasePrefetcher.java:76)
>> ...
>> pkLimit = getPrefetchInLimit() / 
>> getItemClassDescriptor().getPkFields().length;
>> ...
>>
>> Seems that OJB get a persistent class without defined PK fields. Could 
>> this be the case?
>>
>> regards,
>> Armin
>>
>>
>>> Thomas Papke schrieb:
>>>
>>>> Thanks for your answer.
>>>>
>>>> I need the inId because its like ebay: in each productgroup there is 
>>>> a collection of "untergruppen/undergroups". And this works: i could 
>>>> add objects of produktgruppe and save them (so inId will store the 
>>>> reference to the main productgroup).
>>>>
>>>> The problem is not between productgroup and productgroup (1:n) - it 
>>>> is between Productgroup and Product (n:m)
>>>>
>>>> And why did i got a arithmetic exception (/ by zero) from the ojb 
>>>> core??
>>>>
>>>> I found also something strange:
>>>> The OJB Framwork and my Application runs in a Tomcat environment.
>>>> If i start tomcat and then my app - i got the error! If i start my 
>>>> app a seconde time everthing works fine ...
>>>>
>>>> Thanks for help, Thomas
>>>>
>>>>
>>>> Thomas Franke schrieb:
>>>>
>>>>> Thomas Papke wrote:
>>>>>
>>>>> Why you need the inId?
>>>>>
>>>>>
>>>>>> Here is my descriptor of the two classes:
>>>>>>
>>>>>> <class-descriptor
>>>>>>    class="de.ba.studi.chtp.model.Produktgruppe"
>>>>>>    table="Produktgruppe"
>>>>>>  >
>>>>>>    <field-descriptor
>>>>>>        name="id"
>>>>>>        column="id"
>>>>>>        jdbc-type="INTEGER"
>>>>>>        primarykey="true"
>>>>>>        autoincrement="true"
>>>>>>    >
>>>>>>    </field-descriptor>
>>>>>>    <field-descriptor
>>>>>>        name="inId"
>>>>>>        column="inId"
>>>>>>        jdbc-type="INTEGER"
>>>>>>    >
>>>>>>    </field-descriptor>
>>>>>>    <field-descriptor
>>>>>>        name="name"
>>>>>>        column="name"
>>>>>>        jdbc-type="VARCHAR"
>>>>>>    >
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>> I thing this can't work and I thing also it is a wrong design:
>>>>>
>>>>>>    </field-descriptor>
>>>>>>    <collection-descriptor
>>>>>>       name="produktgruppen"
>>>>>>       element-class-ref="de.ba.studi.chtp.model.Produktgruppe"
>>>>>>       orderby="inId"
>>>>>>       sort="DESC"
>>>>>>       auto-retrieve="true"
>>>>>>       auto-update="true"
>>>>>>       auto-delete="true"
>>>>>>    >
>>>>>>       <inverse-foreignkey field-ref="inId"/>
>>>>>>    </collection-descriptor>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>>    <collection-descriptor
>>>>>>       name="produkt"
>>>>>>       element-class-ref="de.ba.studi.chtp.model.Produkt"
>>>>>>       auto-retrieve="true"
>>>>>>       auto-update="true"
>>>>>>       indirection-table="produkt_produktgruppe"
>>>>>>  >
>>>>>>       <fk-pointing-to-this-class column="ProdGruppe_id"/>
>>>>>>       <fk-pointing-to-element-class column="Prod_Id"/>
>>>>>>  </collection-descriptor>
>>>>>> </class-descriptor>
>>>>>>
>>>>>
>>>>> Take into your Produkt class a collection descriptor with 
>>>>> Produktgruppe classes.
>>>>> For that case I would write a spezial mapping for Produktgruppe 
>>>>> without a collection with Produkt class.
>>>>>
>>>>>> <class-descriptor
>>>>>>    class="de.ba.studi.chtp.model.Produkt"
>>>>>>    table="Produkt"
>>>>>>  >
>>>>>>    <field-descriptor
>>>>>>        name="id"
>>>>>>        column="id"
>>>>>>        jdbc-type="INTEGER"
>>>>>>        primarykey="true"
>>>>>>        autoincrement="true"
>>>>>>    >
>>>>>>    </field-descriptor>
>>>>>>    <field-descriptor
>>>>>>        name="name"
>>>>>>        column="name"
>>>>>>        jdbc-type="VARCHAR"
>>>>>>    >
>>>>>>    </field-descriptor>
>>>>>>
>>>>>>
>>>>>>  <collection-descriptor
>>>>>>       name="meinung"
>>>>>>       element-class-ref="de.ba.studi.chtp.model.Meinung"
>>>>>>       auto-retrieve="true"
>>>>>>       auto-update="true"
>>>>>>  >
>>>>>>       <inverse-foreignkey field-ref="prod_id"/>
>>>>>>  </collection-descriptor>
>>>>>>   </class-descriptor>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>> ---------------------------------------------------------------------
>>>>> To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
>>>>> For additional commands, e-mail: ojb-user-help@db.apache.org
>>>>>
>>>>>
>>>>
>>>> ---------------------------------------------------------------------
>>>> To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
>>>> For additional commands, e-mail: ojb-user-help@db.apache.org
>>>>
>>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
>>> For additional commands, e-mail: ojb-user-help@db.apache.org
>>>
>>>
>>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
>> For additional commands, e-mail: ojb-user-help@db.apache.org
>>
>>
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
> For additional commands, e-mail: ojb-user-help@db.apache.org
> 
> 
> 

---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-user-help@db.apache.org


Re: Problem with n:m association

Posted by Thomas Papke <we...@thopap.de>.
Hi ...

yes that could be the problem. For the tables "Produktgruppe" and 
"Produkt", i have defined the primary keys in the deskriptor. The table 
for decompose the n:m mapping "produkt_produktgruppe" - i have nothing 
defined in the descriptor. Because as described in the docs of ojb 
http://db.apache.org/ojb/docu/guides/basic-technique.html#Support+for+Non-Decomposed+m%3An+Mappings 
it should work.

Did i something wrong?
On the bottom of this email again the interessting parts of my 
descriptor where you could see that i have defined the pk's for 
produktgruppe and produkt in a correct way.

Is the possibly a bug of ojb or is something necessary what is not 
mentioned in the example for n:m ojb mapping?

Thanks, Thomas

Armin Waibel schrieb:

> Hi Thomas,
>
> Thomas Papke wrote:
>
>> The excectly exception (after broker.getCollectionByQuery ...) i got 
>> from ojb broker is:
>>
>> org.apache.ojb.broker.PersistenceBrokerException: 
>> java.lang.ArithmeticException: / by zero
>>
>
> In the source the causing line is
>
> at BasePrefetcher.<init>(BasePrefetcher.java:76)
> ...
> pkLimit = getPrefetchInLimit() / 
> getItemClassDescriptor().getPkFields().length;
> ...
>
> Seems that OJB get a persistent class without defined PK fields. Could 
> this be the case?
>
> regards,
> Armin
>
>
>> Thomas Papke schrieb:
>>
>>> Thanks for your answer.
>>>
>>> I need the inId because its like ebay: in each productgroup there is 
>>> a collection of "untergruppen/undergroups". And this works: i could 
>>> add objects of produktgruppe and save them (so inId will store the 
>>> reference to the main productgroup).
>>>
>>> The problem is not between productgroup and productgroup (1:n) - it 
>>> is between Productgroup and Product (n:m)
>>>
>>> And why did i got a arithmetic exception (/ by zero) from the ojb 
>>> core??
>>>
>>> I found also something strange:
>>> The OJB Framwork and my Application runs in a Tomcat environment.
>>> If i start tomcat and then my app - i got the error! If i start my 
>>> app a seconde time everthing works fine ...
>>>
>>> Thanks for help, Thomas
>>>
>>>
>>> Thomas Franke schrieb:
>>>
>>>> Thomas Papke wrote:
>>>>
>>>> Why you need the inId?
>>>>
>>>>
>>>>> Here is my descriptor of the two classes:
>>>>>
>>>>> <class-descriptor
>>>>>    class="de.ba.studi.chtp.model.Produktgruppe"
>>>>>    table="Produktgruppe"
>>>>>  >
>>>>>    <field-descriptor
>>>>>        name="id"
>>>>>        column="id"
>>>>>        jdbc-type="INTEGER"
>>>>>        primarykey="true"
>>>>>        autoincrement="true"
>>>>>    >
>>>>>    </field-descriptor>
>>>>>    <field-descriptor
>>>>>        name="inId"
>>>>>        column="inId"
>>>>>        jdbc-type="INTEGER"
>>>>>    >
>>>>>    </field-descriptor>
>>>>>    <field-descriptor
>>>>>        name="name"
>>>>>        column="name"
>>>>>        jdbc-type="VARCHAR"
>>>>>    >
>>>>
>>>>
>>>>
>>>>
>>>>
>>>> I thing this can't work and I thing also it is a wrong design:
>>>>
>>>>>    </field-descriptor>
>>>>>    <collection-descriptor
>>>>>       name="produktgruppen"
>>>>>       element-class-ref="de.ba.studi.chtp.model.Produktgruppe"
>>>>>       orderby="inId"
>>>>>       sort="DESC"
>>>>>       auto-retrieve="true"
>>>>>       auto-update="true"
>>>>>       auto-delete="true"
>>>>>    >
>>>>>       <inverse-foreignkey field-ref="inId"/>
>>>>>    </collection-descriptor>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>>    <collection-descriptor
>>>>>       name="produkt"
>>>>>       element-class-ref="de.ba.studi.chtp.model.Produkt"
>>>>>       auto-retrieve="true"
>>>>>       auto-update="true"
>>>>>       indirection-table="produkt_produktgruppe"
>>>>>  >
>>>>>       <fk-pointing-to-this-class column="ProdGruppe_id"/>
>>>>>       <fk-pointing-to-element-class column="Prod_Id"/>
>>>>>  </collection-descriptor>
>>>>> </class-descriptor>
>>>>>
>>>>
>>>> Take into your Produkt class a collection descriptor with 
>>>> Produktgruppe classes.
>>>> For that case I would write a spezial mapping for Produktgruppe 
>>>> without a collection with Produkt class.
>>>>
>>>>> <class-descriptor
>>>>>    class="de.ba.studi.chtp.model.Produkt"
>>>>>    table="Produkt"
>>>>>  >
>>>>>    <field-descriptor
>>>>>        name="id"
>>>>>        column="id"
>>>>>        jdbc-type="INTEGER"
>>>>>        primarykey="true"
>>>>>        autoincrement="true"
>>>>>    >
>>>>>    </field-descriptor>
>>>>>    <field-descriptor
>>>>>        name="name"
>>>>>        column="name"
>>>>>        jdbc-type="VARCHAR"
>>>>>    >
>>>>>    </field-descriptor>
>>>>>
>>>>>
>>>>>  <collection-descriptor
>>>>>       name="meinung"
>>>>>       element-class-ref="de.ba.studi.chtp.model.Meinung"
>>>>>       auto-retrieve="true"
>>>>>       auto-update="true"
>>>>>  >
>>>>>       <inverse-foreignkey field-ref="prod_id"/>
>>>>>  </collection-descriptor>
>>>>>   </class-descriptor>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>> ---------------------------------------------------------------------
>>>> To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
>>>> For additional commands, e-mail: ojb-user-help@db.apache.org
>>>>
>>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
>>> For additional commands, e-mail: ojb-user-help@db.apache.org
>>>
>>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
>> For additional commands, e-mail: ojb-user-help@db.apache.org
>>
>>
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
> For additional commands, e-mail: ojb-user-help@db.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-user-help@db.apache.org


Re: Problem with n:m association

Posted by Armin Waibel <ar...@apache.org>.
Hi Thomas,

Thomas Papke wrote:
> The excectly exception (after broker.getCollectionByQuery ...) i got 
> from ojb broker is:
> 
> org.apache.ojb.broker.PersistenceBrokerException: 
> java.lang.ArithmeticException: / by zero
> 

In the source the causing line is

at BasePrefetcher.<init>(BasePrefetcher.java:76)
...
pkLimit = getPrefetchInLimit() / 
getItemClassDescriptor().getPkFields().length;
...

Seems that OJB get a persistent class without defined PK fields. Could 
this be the case?

regards,
Armin


> Thomas Papke schrieb:
> 
>> Thanks for your answer.
>>
>> I need the inId because its like ebay: in each productgroup there is a 
>> collection of "untergruppen/undergroups". And this works: i could add 
>> objects of produktgruppe and save them (so inId will store the 
>> reference to the main productgroup).
>>
>> The problem is not between productgroup and productgroup (1:n) - it is 
>> between Productgroup and Product (n:m)
>>
>> And why did i got a arithmetic exception (/ by zero) from the ojb core??
>>
>> I found also something strange:
>> The OJB Framwork and my Application runs in a Tomcat environment.
>> If i start tomcat and then my app - i got the error! If i start my app 
>> a seconde time everthing works fine ...
>>
>> Thanks for help, Thomas
>>
>>
>> Thomas Franke schrieb:
>>
>>> Thomas Papke wrote:
>>>
>>> Why you need the inId?
>>>
>>>
>>>> Here is my descriptor of the two classes:
>>>>
>>>> <class-descriptor
>>>>    class="de.ba.studi.chtp.model.Produktgruppe"
>>>>    table="Produktgruppe"
>>>>  >
>>>>    <field-descriptor
>>>>        name="id"
>>>>        column="id"
>>>>        jdbc-type="INTEGER"
>>>>        primarykey="true"
>>>>        autoincrement="true"
>>>>    >
>>>>    </field-descriptor>
>>>>    <field-descriptor
>>>>        name="inId"
>>>>        column="inId"
>>>>        jdbc-type="INTEGER"
>>>>    >
>>>>    </field-descriptor>
>>>>    <field-descriptor
>>>>        name="name"
>>>>        column="name"
>>>>        jdbc-type="VARCHAR"
>>>>    >
>>>
>>>
>>>
>>>
>>> I thing this can't work and I thing also it is a wrong design:
>>>
>>>>    </field-descriptor>
>>>>    <collection-descriptor
>>>>       name="produktgruppen"
>>>>       element-class-ref="de.ba.studi.chtp.model.Produktgruppe"
>>>>       orderby="inId"
>>>>       sort="DESC"
>>>>       auto-retrieve="true"
>>>>       auto-update="true"
>>>>       auto-delete="true"
>>>>    >
>>>>       <inverse-foreignkey field-ref="inId"/>
>>>>    </collection-descriptor>
>>>
>>>
>>>
>>>
>>>
>>>>    <collection-descriptor
>>>>       name="produkt"
>>>>       element-class-ref="de.ba.studi.chtp.model.Produkt"
>>>>       auto-retrieve="true"
>>>>       auto-update="true"
>>>>       indirection-table="produkt_produktgruppe"
>>>>  >
>>>>       <fk-pointing-to-this-class column="ProdGruppe_id"/>
>>>>       <fk-pointing-to-element-class column="Prod_Id"/>
>>>>  </collection-descriptor>
>>>> </class-descriptor>
>>>>
>>>
>>> Take into your Produkt class a collection descriptor with 
>>> Produktgruppe classes.
>>> For that case I would write a spezial mapping for Produktgruppe 
>>> without a collection with Produkt class.
>>>
>>>> <class-descriptor
>>>>    class="de.ba.studi.chtp.model.Produkt"
>>>>    table="Produkt"
>>>>  >
>>>>    <field-descriptor
>>>>        name="id"
>>>>        column="id"
>>>>        jdbc-type="INTEGER"
>>>>        primarykey="true"
>>>>        autoincrement="true"
>>>>    >
>>>>    </field-descriptor>
>>>>    <field-descriptor
>>>>        name="name"
>>>>        column="name"
>>>>        jdbc-type="VARCHAR"
>>>>    >
>>>>    </field-descriptor>
>>>>
>>>>
>>>>  <collection-descriptor
>>>>       name="meinung"
>>>>       element-class-ref="de.ba.studi.chtp.model.Meinung"
>>>>       auto-retrieve="true"
>>>>       auto-update="true"
>>>>  >
>>>>       <inverse-foreignkey field-ref="prod_id"/>
>>>>  </collection-descriptor>
>>>>   </class-descriptor>
>>>
>>>
>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
>>> For additional commands, e-mail: ojb-user-help@db.apache.org
>>>
>>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
>> For additional commands, e-mail: ojb-user-help@db.apache.org
>>
>>
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
> For additional commands, e-mail: ojb-user-help@db.apache.org
> 
> 
> 

---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-user-help@db.apache.org


Re: Problem with n:m association

Posted by Thomas Papke <we...@thopap.de>.
The excectly exception (after broker.getCollectionByQuery ...) i got 
from ojb broker is:

org.apache.ojb.broker.PersistenceBrokerException: 
java.lang.ArithmeticException: / by zero

Thomas Papke schrieb:

> Thanks for your answer.
>
> I need the inId because its like ebay: in each productgroup there is a 
> collection of "untergruppen/undergroups". And this works: i could add 
> objects of produktgruppe and save them (so inId will store the 
> reference to the main productgroup).
>
> The problem is not between productgroup and productgroup (1:n) - it is 
> between Productgroup and Product (n:m)
>
> And why did i got a arithmetic exception (/ by zero) from the ojb core??
>
> I found also something strange:
> The OJB Framwork and my Application runs in a Tomcat environment.
> If i start tomcat and then my app - i got the error! If i start my app 
> a seconde time everthing works fine ...
>
> Thanks for help, Thomas
>
>
> Thomas Franke schrieb:
>
>> Thomas Papke wrote:
>>
>> Why you need the inId?
>>
>>
>>> Here is my descriptor of the two classes:
>>>
>>> <class-descriptor
>>>    class="de.ba.studi.chtp.model.Produktgruppe"
>>>    table="Produktgruppe"
>>>  >
>>>    <field-descriptor
>>>        name="id"
>>>        column="id"
>>>        jdbc-type="INTEGER"
>>>        primarykey="true"
>>>        autoincrement="true"
>>>    >
>>>    </field-descriptor>
>>>    <field-descriptor
>>>        name="inId"
>>>        column="inId"
>>>        jdbc-type="INTEGER"
>>>    >
>>>    </field-descriptor>
>>>    <field-descriptor
>>>        name="name"
>>>        column="name"
>>>        jdbc-type="VARCHAR"
>>>    >
>>
>>
>>
>> I thing this can't work and I thing also it is a wrong design:
>>
>>>    </field-descriptor>
>>>    <collection-descriptor
>>>       name="produktgruppen"
>>>       element-class-ref="de.ba.studi.chtp.model.Produktgruppe"
>>>       orderby="inId"
>>>       sort="DESC"
>>>       auto-retrieve="true"
>>>       auto-update="true"
>>>       auto-delete="true"
>>>    >
>>>       <inverse-foreignkey field-ref="inId"/>
>>>    </collection-descriptor>
>>
>>
>>
>>
>>>    <collection-descriptor
>>>       name="produkt"
>>>       element-class-ref="de.ba.studi.chtp.model.Produkt"
>>>       auto-retrieve="true"
>>>       auto-update="true"
>>>       indirection-table="produkt_produktgruppe"
>>>  >
>>>       <fk-pointing-to-this-class column="ProdGruppe_id"/>
>>>       <fk-pointing-to-element-class column="Prod_Id"/>
>>>  </collection-descriptor>
>>> </class-descriptor>
>>>
>>
>> Take into your Produkt class a collection descriptor with 
>> Produktgruppe classes.
>> For that case I would write a spezial mapping for Produktgruppe 
>> without a collection with Produkt class.
>>
>>> <class-descriptor
>>>    class="de.ba.studi.chtp.model.Produkt"
>>>    table="Produkt"
>>>  >
>>>    <field-descriptor
>>>        name="id"
>>>        column="id"
>>>        jdbc-type="INTEGER"
>>>        primarykey="true"
>>>        autoincrement="true"
>>>    >
>>>    </field-descriptor>
>>>    <field-descriptor
>>>        name="name"
>>>        column="name"
>>>        jdbc-type="VARCHAR"
>>>    >
>>>    </field-descriptor>
>>>
>>>
>>>  <collection-descriptor
>>>       name="meinung"
>>>       element-class-ref="de.ba.studi.chtp.model.Meinung"
>>>       auto-retrieve="true"
>>>       auto-update="true"
>>>  >
>>>       <inverse-foreignkey field-ref="prod_id"/>
>>>  </collection-descriptor>
>>>   </class-descriptor>
>>
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
>> For additional commands, e-mail: ojb-user-help@db.apache.org
>>
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
> For additional commands, e-mail: ojb-user-help@db.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-user-help@db.apache.org


Re: Problem with n:m association

Posted by Thomas Franke <fr...@softenergy.de>.
Thomas Papke wrote:

> Did you use a Non-Decomposed mapping or manual-decomposing mapping with 
> a object as relation 
We use non-decomposed mappings and haven't any mappings for the 
intersection tables.
Do you have one or more mappings for your tables?
Sometimes there are problems, when there are differences between the 
mappings for the same table.

Here is one example:

<class-descriptor
class="de.mhr.wis.DBAdapter.rawdata.masterdata.AdressIdAndName"
table="adressen"
 >
  <field-descriptor id="1"
   name="adressen_id"
   column="adressen_id"
   jdbc-type="INTEGER"
   primarykey="true"
   autoincrement="true"
   access="readonly"
   sequence-name="ADRESSEN_ID_SEQ"
   />
   <field-descriptor id="2"
    name="name"
    column="name"
    jdbc-type="VARCHAR"
    nullable="true"
    />

  <collection-descriptor
   name="adressarten"
   collection-class=
     "org.apache.ojb.broker.util.
      collections.ManageableArrayList"
   element-class-ref=
     "de.mhr.wis.DBAdapter
     .ojbAdapter.administration.OjbAdressart"
   auto-retrieve="false"
   auto-update="false"
   indirection-table="adressen_adressart"
   >
   <fk-pointing-to-this-class column="adressen_id"/>
   <fk-pointing-to-element-class column="adressart_id"/>
  </collection-descriptor>
</class-descriptor>


<class-descriptor
		class="de.mhr.wis.DBAdapter.ojbAdapter.administration.OjbAdressart"
		table="adressart"
	>
		<field-descriptor
			name="adressartId"
			column="adressart_id"
			jdbc-type="INTEGER"
			primarykey="true"
			autoincrement="true"
			access="readonly"
			sequence-name="ADRESSART_ID_SEQ"
		/>
		<field-descriptor
			name="adressartName"
			column="adressart_name"
			jdbc-type="VARCHAR"
			nullable="true"
		/>
		<field-descriptor
			name="adresstypName"
			column="adresstyp_name"
			jdbc-type="VARCHAR"
			nullable="true"
		/>
		<field-descriptor
			name="adressart"
			column="adressart"
			jdbc-type="INTEGER"
			nullable="true"
		/>
		<field-descriptor
			name="adresstyp"
			column="adresstyp"
			jdbc-type="INTEGER"
			nullable="true"
		/>
		
	</class-descriptor>

regards

Thomas





---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-user-help@db.apache.org


Re: Problem with n:m association

Posted by Thomas Papke <we...@thopap.de>.
Did you use a Non-Decomposed mapping or manual-decomposing mapping with 
a object as relation 
(http://db.apache.org/ojb/docu/guides/basic-technique.html#Mapping+m%3An+associations)?

I think OJB has a problem with the non-decomposed mapping??? Could you 
send me the part of your descriptor where your application use n:m mapping?


Thanks, Thomas

Thomas Franke schrieb:

> Thomas Papke wrote:
>
>> I need the inId because its like ebay: in each productgroup there is 
>> a collection of "untergruppen/undergroups". And this works: i could 
>> add objects of produktgruppe and save them (so inId will store the 
>> reference to the main productgroup).
>
> I tought first on a problem that we had. Sorry, I was wrong. :)
>
>> The problem is not between productgroup and productgroup (1:n) - it 
>> is between Productgroup and Product (n:m)
>
> We have in our application similar relationships and our mappings look 
> like your mapping and it's working.
>
> regards
>
> Thomas
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
> For additional commands, e-mail: ojb-user-help@db.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-user-help@db.apache.org


Re: Problem with n:m association

Posted by Thomas Franke <fr...@softenergy.de>.
Thomas Papke wrote:

> I need the inId because its like ebay: in each productgroup there is a 
> collection of "untergruppen/undergroups". And this works: i could add 
> objects of produktgruppe and save them (so inId will store the reference 
> to the main productgroup).
I tought first on a problem that we had. Sorry, I was wrong. :)

> The problem is not between productgroup and productgroup (1:n) - it is 
> between Productgroup and Product (n:m)
We have in our application similar relationships and our mappings look 
like your mapping and it's working.

regards

Thomas

---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-user-help@db.apache.org


Re: Problem with n:m association

Posted by Thomas Papke <we...@thopap.de>.
Thanks for your answer.

I need the inId because its like ebay: in each productgroup there is a 
collection of "untergruppen/undergroups". And this works: i could add 
objects of produktgruppe and save them (so inId will store the reference 
to the main productgroup).

The problem is not between productgroup and productgroup (1:n) - it is 
between Productgroup and Product (n:m)

And why did i got a arithmetic exception (/ by zero) from the ojb core??

I found also something strange:
The OJB Framwork and my Application runs in a Tomcat environment.
If i start tomcat and then my app - i got the error! If i start my app a 
seconde time everthing works fine ...

Thanks for help, Thomas


Thomas Franke schrieb:

> Thomas Papke wrote:
>
> Why you need the inId?
>
>
>> Here is my descriptor of the two classes:
>>
>> <class-descriptor
>>    class="de.ba.studi.chtp.model.Produktgruppe"
>>    table="Produktgruppe"
>>  >
>>    <field-descriptor
>>        name="id"
>>        column="id"
>>        jdbc-type="INTEGER"
>>        primarykey="true"
>>        autoincrement="true"
>>    >
>>    </field-descriptor>
>>    <field-descriptor
>>        name="inId"
>>        column="inId"
>>        jdbc-type="INTEGER"
>>    >
>>    </field-descriptor>
>>    <field-descriptor
>>        name="name"
>>        column="name"
>>        jdbc-type="VARCHAR"
>>    >
>
>
> I thing this can't work and I thing also it is a wrong design:
>
>>    </field-descriptor>
>>    <collection-descriptor
>>       name="produktgruppen"
>>       element-class-ref="de.ba.studi.chtp.model.Produktgruppe"
>>       orderby="inId"
>>       sort="DESC"
>>       auto-retrieve="true"
>>       auto-update="true"
>>       auto-delete="true"
>>    >
>>       <inverse-foreignkey field-ref="inId"/>
>>    </collection-descriptor>
>
>
>
>>    <collection-descriptor
>>       name="produkt"
>>       element-class-ref="de.ba.studi.chtp.model.Produkt"
>>       auto-retrieve="true"
>>       auto-update="true"
>>       indirection-table="produkt_produktgruppe"
>>  >
>>       <fk-pointing-to-this-class column="ProdGruppe_id"/>
>>       <fk-pointing-to-element-class column="Prod_Id"/>
>>  </collection-descriptor>
>> </class-descriptor>
>>
>
> Take into your Produkt class a collection descriptor with 
> Produktgruppe classes.
> For that case I would write a spezial mapping for Produktgruppe 
> without a collection with Produkt class.
>
>> <class-descriptor
>>    class="de.ba.studi.chtp.model.Produkt"
>>    table="Produkt"
>>  >
>>    <field-descriptor
>>        name="id"
>>        column="id"
>>        jdbc-type="INTEGER"
>>        primarykey="true"
>>        autoincrement="true"
>>    >
>>    </field-descriptor>
>>    <field-descriptor
>>        name="name"
>>        column="name"
>>        jdbc-type="VARCHAR"
>>    >
>>    </field-descriptor>
>>
>>
>>  <collection-descriptor
>>       name="meinung"
>>       element-class-ref="de.ba.studi.chtp.model.Meinung"
>>       auto-retrieve="true"
>>       auto-update="true"
>>  >
>>       <inverse-foreignkey field-ref="prod_id"/>
>>  </collection-descriptor>
>>   </class-descriptor>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
> For additional commands, e-mail: ojb-user-help@db.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-user-help@db.apache.org


Re: Problem with n:m association

Posted by Thomas Franke <fr...@softenergy.de>.
Thomas Papke wrote:

Why you need the inId?


> Here is my descriptor of the two classes:
> 
> <class-descriptor
>    class="de.ba.studi.chtp.model.Produktgruppe"
>    table="Produktgruppe"
>  >
>    <field-descriptor
>        name="id"
>        column="id"
>        jdbc-type="INTEGER"
>        primarykey="true"
>        autoincrement="true"
>    >
>    </field-descriptor>
>    <field-descriptor
>        name="inId"
>        column="inId"
>        jdbc-type="INTEGER"
>    >
>    </field-descriptor>
>    <field-descriptor
>        name="name"
>        column="name"
>        jdbc-type="VARCHAR"
>    >

I thing this can't work and I thing also it is a wrong design:

>    </field-descriptor>
>    <collection-descriptor
>       name="produktgruppen"
>       element-class-ref="de.ba.studi.chtp.model.Produktgruppe"
>       orderby="inId"
>       sort="DESC"
>       auto-retrieve="true"
>       auto-update="true"
>       auto-delete="true"
>    >
>       <inverse-foreignkey field-ref="inId"/>
>    </collection-descriptor>


>    <collection-descriptor
>       name="produkt"
>       element-class-ref="de.ba.studi.chtp.model.Produkt"
>       auto-retrieve="true"
>       auto-update="true"
>       indirection-table="produkt_produktgruppe"
>  >
>       <fk-pointing-to-this-class column="ProdGruppe_id"/>
>       <fk-pointing-to-element-class column="Prod_Id"/>
>  </collection-descriptor>
> </class-descriptor>
> 

Take into your Produkt class a collection descriptor with Produktgruppe 
classes.
For that case I would write a spezial mapping for Produktgruppe without 
a collection with Produkt class.

> <class-descriptor
>    class="de.ba.studi.chtp.model.Produkt"
>    table="Produkt"
>  >
>    <field-descriptor
>        name="id"
>        column="id"
>        jdbc-type="INTEGER"
>        primarykey="true"
>        autoincrement="true"
>    >
>    </field-descriptor>
>    <field-descriptor
>        name="name"
>        column="name"
>        jdbc-type="VARCHAR"
>    >
>    </field-descriptor>
> 
> 
>  <collection-descriptor
>       name="meinung"
>       element-class-ref="de.ba.studi.chtp.model.Meinung"
>       auto-retrieve="true"
>       auto-update="true"
>  >
>       <inverse-foreignkey field-ref="prod_id"/>
>  </collection-descriptor>
>   </class-descriptor>

---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-user-help@db.apache.org


Problem with n:m association

Posted by Thomas Papke <we...@thopap.de>.
Hello ...

i have a problem with a n:m association in my example application.

I have a class productgroup "Produktgruppe" and a class product 
"Produkt". The productgroup should hold a collection of products, but a 
product could be in more than one productgroup. So i have a n:m association.

I have build 3 tables:
Produktgruppe with id, name, inid [inid because of 1:n association of 
the productgroups itself]
Produkt with id, name
Produkt_produktgruppe with produkt_id, produktgruppe_id

I have written the descriptor. If i start my application only with 
productgroups - everthing works perfect. I could also insert a product, 
which is correctly written to database. But if i restart my application 
i got:

java.lang.ArithmeticException: / by zero
    at 
org.apache.ojb.broker.accesslayer.BasePrefetcher.<init>(BasePrefetcher.java:76)
    at 
org.apache.ojb.broker.accesslayer.RelationshipPrefetcherImpl.<init>(RelationshipPrefetcherImpl.java:39)
    at 
org.apache.ojb.broker.accesslayer.CollectionPrefetcher.<init>(CollectionPrefetcher.java:60)
    at 
org.apache.ojb.broker.accesslayer.RelationshipPrefetcherFactory.createRelationshipPrefetcher(RelationshipPrefetcherFactory.java:46)
    at 
org.apache.ojb.broker.core.QueryReferenceBroker.performRetrievalTasks(QueryReferenceBroker.java:328)
    at 
org.apache.ojb.broker.core.QueryReferenceBroker.getCollectionByQuery(QueryReferenceBroker.java:167)
    at 
org.apache.ojb.broker.core.QueryReferenceBroker.getCollectionByQuery(QueryReferenceBroker.java:233)
    at 
org.apache.ojb.broker.core.QueryReferenceBroker.getCollectionByQuery(QueryReferenceBroker.java:253)
    at 
org.apache.ojb.broker.core.PersistenceBrokerImpl.getCollectionByQuery(PersistenceBrokerImpl.java:1217)
    at 
org.apache.ojb.broker.core.DelegatingPersistenceBroker.getCollectionByQuery(DelegatingPersistenceBroker.java:338)
    at 
org.apache.ojb.broker.core.DelegatingPersistenceBroker.getCollectionByQuery(DelegatingPersistenceBroker.java:338)
    at de.ba.studi.chtp.model.Portal.getProduktgruppen(Portal.java:122)
...

Here is my descriptor of the two classes:

<class-descriptor
    class="de.ba.studi.chtp.model.Produktgruppe"
    table="Produktgruppe"
 >
    <field-descriptor
        name="id"
        column="id"
        jdbc-type="INTEGER"
        primarykey="true"
        autoincrement="true"
    >
    </field-descriptor>
    <field-descriptor
        name="inId"
        column="inId"
        jdbc-type="INTEGER"
    >
    </field-descriptor>
    <field-descriptor
        name="name"
        column="name"
        jdbc-type="VARCHAR"
    >
    </field-descriptor>
    <collection-descriptor
       name="produktgruppen"
       element-class-ref="de.ba.studi.chtp.model.Produktgruppe"
       orderby="inId"
       sort="DESC"
       auto-retrieve="true"
       auto-update="true"
       auto-delete="true"
    >
       <inverse-foreignkey field-ref="inId"/>
    </collection-descriptor>
    <collection-descriptor
       name="produkt"
       element-class-ref="de.ba.studi.chtp.model.Produkt"
       auto-retrieve="true"
       auto-update="true"
       indirection-table="produkt_produktgruppe"
  >
       <fk-pointing-to-this-class column="ProdGruppe_id"/>
       <fk-pointing-to-element-class column="Prod_Id"/>
  </collection-descriptor>
</class-descriptor>

<class-descriptor
    class="de.ba.studi.chtp.model.Produkt"
    table="Produkt"
 >
    <field-descriptor
        name="id"
        column="id"
        jdbc-type="INTEGER"
        primarykey="true"
        autoincrement="true"
    >
    </field-descriptor>
    <field-descriptor
        name="name"
        column="name"
        jdbc-type="VARCHAR"
    >
    </field-descriptor>

 
  <collection-descriptor
       name="meinung"
       element-class-ref="de.ba.studi.chtp.model.Meinung"
       auto-retrieve="true"
       auto-update="true"
  >
       <inverse-foreignkey field-ref="prod_id"/>
  </collection-descriptor>
   
</class-descriptor>


Could anyone help?

Thanks, Thomas

---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-user-help@db.apache.org


RE: Optimistic Locking Problem.

Posted by Alessandro Colantoni <ac...@brujulatelecom.com>.
Hi Wesley.
The second time you run, the lock value of A is incremented (it passes
from 140 to 141). So A feels the store of B.
I don't understand if it passes  to the name to or it passes just to the
lock value. (Should be logic to name too.)




-----Mensaje original-----
De: Wesley Lemke [mailto:buck.lemke@gmail.com] 
Enviado el: lunes, 06 de diciembre de 2004 17:13
Para: OJB Users List
Asunto: Re: Optimistic Locking Problem.

I didn't have pb.close() in my code, Just the pb.commit().  I have
added pb.close now, and the same thing still happens.  The first time
I run the code the exception is thrown, but not after that.  Here is
the full log if it helps (the number after the ":" is the lock value):

[12/6/04 10:08:51:555 CST] 1693a8ea SystemErr     R
*************************** START ************************
[12/6/04 10:08:51:585 CST] 1693a8ea SystemErr     R SERVLET:  Starting
ClientAdderDelay
[12/6/04 10:08:51:585 CST] 1693a8ea SystemErr     R SERVLET:  Starting
ClientAdder
[12/6/04 10:08:51:585 CST] 1693a8ea SystemErr     R SERVLET:  Joining
to ClientAdder
[12/6/04 10:08:51:875 CST]  d54e8f9 Config        E
com.opensymphony.oscache.base.Config  Error reading
/oscache.properties in CacheAdministrator.loadProps()
java.lang.NullPointerException
[12/6/04 10:08:51:875 CST]  d54e8f9 Config        E
com.opensymphony.oscache.base.Config  Ensure the /oscache.properties
file is readable and in your classpath.
[12/6/04 10:08:51:885 CST]  d54e8f9 GeneralCacheA I
com.opensymphony.oscache.general.GeneralCacheAdministrator 
Constructed GeneralCacheAdministrator()
[12/6/04 10:08:51:885 CST]  d54e8f9 GeneralCacheA I
com.opensymphony.oscache.general.GeneralCacheAdministrator  Creating
new cache
[12/6/04 10:08:53:157 CST]  d5668f9 ConnectionFac I J2CA0122I:
Resource reference jdbc/ao79 could not be located, so default values
of the following are used: [Resource-ref settings]

	res-auth:                 1 (APPLICATION)
	res-isolation-level:      0 (TRANSACTION_NONE)
	res-sharing-scope:        true (SHAREABLE)
	res-resolution-control:   999 (undefined)
[Other attributes]

isCMP1_x:                 false (not CMP1.x)
isJMS:                 false (not JMS)

[12/6/04 10:08:53:167 CST]  d54e8f9 ConnectionFac I J2CA0122I:
Resource reference jdbc/ao79 could not be located, so default values
of the following are used: [Resource-ref settings]

	res-auth:                 1 (APPLICATION)
	res-isolation-level:      0 (TRANSACTION_NONE)
	res-sharing-scope:        true (SHAREABLE)
	res-resolution-control:   999 (undefined)
[Other attributes]

isCMP1_x:                 false (not CMP1.x)
isJMS:                 false (not JMS)

[12/6/04 10:08:53:167 CST]  d54e8f9 ConnectionMan W J2CA0075W: An
active transaction should be present while processing method
allocateMCWrapper.
[12/6/04 10:08:53:167 CST]  d5668f9 ConnectionMan W J2CA0075W: An
active transaction should be present while processing method
allocateMCWrapper.
[12/6/04 10:08:53:177 CST]  d54e8f9 ConnectionMan W J2CA0075W: An
active transaction should be present while processing method
initializeForUOW.
[12/6/04 10:08:53:177 CST]  d5668f9 ConnectionMan W J2CA0075W: An
active transaction should be present while processing method
initializeForUOW.
[12/6/04 10:08:53:537 CST]  d5668f9 SystemErr     R CLIENTADDER: 
Before Update: 00000:139
[12/6/04 10:08:53:537 CST]  d5668f9 SystemErr     R CLIENTADDER:
Changing name to 00001: 139
[12/6/04 10:08:53:537 CST]  d54e8f9 SystemErr     R CLIENTADDERDELAY: 
Before Update: 00000:139
[12/6/04 10:08:53:547 CST]  d54e8f9 SystemErr     R CLIENTADDERDELAY: 
Sleeping for 5000 millis
[12/6/04 10:08:53:547 CST]  d5668f9 ConnectionMan W J2CA0075W: An
active transaction should be present while processing method
allocateMCWrapper.
[12/6/04 10:08:53:597 CST]  d5668f9 ConnectionMan W J2CA0075W: An
active transaction should be present while processing method
initializeForUOW.
[12/6/04 10:08:53:608 CST]  d5668f9 SystemErr     R CLIENTADDER: 
After Update: 00001:140
[12/6/04 10:08:53:618 CST] 1693a8ea SystemErr     R SERVLET:  Joining
to ClientAdderDelay
[12/6/04 10:08:58:545 CST]  d54e8f9 SystemErr     R CLIENTADDERDELAY:
Changing name to 00001:139
[12/6/04 10:08:58:605 CST]  d54e8f9 SystemErr     R CLIENTADDERDELAY:
(140) org.apache.ojb.broker.OptimisticLockException: Object has been
modified by someone else
[12/6/04 10:08:58:605 CST]  d54e8f9 ConnectionMan W J2CA0075W: An
active transaction should be present while processing method
allocateMCWrapper.
[12/6/04 10:08:58:615 CST]  d54e8f9 ConnectionMan W J2CA0075W: An
active transaction should be present while processing method
initializeForUOW.
[12/6/04 10:08:58:625 CST]  d54e8f9 SystemErr     R CLIENTADDERDELAY: 
After Update: 00001:140
[12/6/04 10:08:58:625 CST] 1693a8ea SystemErr     R
*************************** END ************************
[12/6/04 10:08:58:735 CST] 1693a8ea OSEListenerDi E PLGN0021E: Servlet
Request Processor Exception: Virtual Host/WebGroup Not Found : The web
group /favicon.ico has not been defined
[12/6/04 10:09:07:698 CST] 1dcd68fe SystemErr     R
*************************** START ************************
[12/6/04 10:09:07:708 CST] 1dcd68fe SystemErr     R SERVLET:  Starting
ClientAdderDelay
[12/6/04 10:09:07:708 CST] 1dcd68fe SystemErr     R SERVLET:  Starting
ClientAdder
[12/6/04 10:09:07:708 CST] 1dcd68fe SystemErr     R SERVLET:  Joining
to ClientAdder
[12/6/04 10:09:07:708 CST]  12628e0 ConnectionMan W J2CA0075W: An
active transaction should be present while processing method
allocateMCWrapper.
[12/6/04 10:09:07:708 CST]  13ba8e0 ConnectionMan W J2CA0075W: An
active transaction should be present while processing method
allocateMCWrapper.
[12/6/04 10:09:07:748 CST]  12628e0 ConnectionMan W J2CA0075W: An
active transaction should be present while processing method
initializeForUOW.
[12/6/04 10:09:07:798 CST]  12628e0 SystemErr     R CLIENTADDERDELAY: 
Before Update: 00001:140
[12/6/04 10:09:07:798 CST]  12628e0 SystemErr     R CLIENTADDERDELAY: 
Sleeping for 5000 millis
[12/6/04 10:09:07:758 CST]  13ba8e0 ConnectionMan W J2CA0075W: An
active transaction should be present while processing method
initializeForUOW.
[12/6/04 10:09:07:828 CST]  13ba8e0 SystemErr     R CLIENTADDER: 
Before Update: 00001:140
[12/6/04 10:09:07:828 CST]  13ba8e0 SystemErr     R CLIENTADDER:
Changing name to 00000: 140
[12/6/04 10:09:07:848 CST]  13ba8e0 ConnectionMan W J2CA0075W: An
active transaction should be present while processing method
allocateMCWrapper.
[12/6/04 10:09:07:868 CST]  13ba8e0 ConnectionMan W J2CA0075W: An
active transaction should be present while processing method
initializeForUOW.
[12/6/04 10:09:07:918 CST]  13ba8e0 SystemErr     R CLIENTADDER: 
After Update: 00000:141
[12/6/04 10:09:07:918 CST] 1dcd68fe SystemErr     R SERVLET:  Joining
to ClientAdderDelay
[12/6/04 10:09:12:815 CST]  12628e0 SystemErr     R CLIENTADDERDELAY:
Changing name to 00000:141
[12/6/04 10:09:12:825 CST]  12628e0 ConnectionMan W J2CA0075W: An
active transaction should be present while processing method
allocateMCWrapper.
[12/6/04 10:09:12:825 CST]  12628e0 ConnectionMan W J2CA0075W: An
active transaction should be present while processing method
initializeForUOW.
[12/6/04 10:09:12:835 CST]  12628e0 SystemErr     R CLIENTADDERDELAY: 
After Update: 00000:142
[12/6/04 10:09:12:845 CST] 1dcd68fe SystemErr     R
*************************** END ************************



On Sat, 04 Dec 2004 15:13:09 -0500, Robert S. Sfeir
<ro...@codepuccino.com> wrote:
> Don't forget pb.close() when you're done.
> 
> R
> 
> 
> 
> 
> On 12/4/04 3:07 PM, "Wesley Lemke" <bu...@gmail.com> wrote:
> 
> > Right now I am using the PB.beginTransactoin, and PB.commit...
> >
> >
> > On Sat, 04 Dec 2004 18:53:43 +0100, Armin Waibel <ar...@apache.org>
wrote:
> >> Hi Wesley,
> >>
> >> Wesley Lemke wrote:
> >>
> >>> I am using the integer as the lock field.  On monday I can give it
a
> >>> shot with a timestamp.
> >>
> >> Integer is fine. There is a bug when using Timestamp values in
OJB1.0.1,
> >> so Integer is a better choice.
> >>
> >>> I just can't figure out why it works the first
> >>> time I run it, but then the exception is not thrown after that.
Could
> >>> it have something to do with the data source getting a new
connection
> >>> the first time?
> >>>
> >>
> >> hmm, if the used connections don't get committed side-effects could
> >> happen. Do you use PB-tx demarcation (PB.beginT...) (or JTA-tx when
in
> >> managed environment)?
> >>
> >> I checked in a multithreaded optimistic locking test in CVS branch
> >> OJB_1_0_RELEASE
> >>
> >>
http://cvs.apache.org/viewcvs.cgi/db-ojb/src/test/org/apache/ojb/broker/
Optim
> >>
isticLockingMultithreadedTest.java?rev=1.1.2.1&only_with_tag=OJB_1_0_REL
EASE&
> >> view=markup
> >>
> >> This test (multiple threads try to update the same object) seems to
work
> >> and case OLE when version conflict occur.
> >>
> >> regards,
> >> Armin
> >>
> >>
> >>
> >>
> >>>
> >>> On Fri, 03 Dec 2004 23:01:48 +0100, Armin Waibel
<ar...@apache.org> wrote:
> >>>
> >>>> Hi Wesley,
> >>>>
> >>>> I did a multithreaded test too - all seems ok.
> >>>> Do you use a Timestamp as lock field?
> >>>> Do you re-read the used object when writing fails (to get fresh
object
> >>>> with valid lock version)?
> >>>>
> >>>> regards,
> >>>> Armin
> >>>>
> >>>>
> >>>>
> >>>> Wesley Lemke wrote:
> >>>>
> >>>>
> >>>>> I am now printing the ackOptLock value, but still am only
getting the
> >>>>> OptimisticLock exception the first time I run the code after I
restart
> >>>>> the servlet containter.  Here is the log files of the first two
runs.
> >>>>>
> >>>>> *************************** START ************************
> >>>>> SERVLET:  Starting ClientAdderDelay
> >>>>> SERVLET:  Starting ClientAdder
> >>>>> SERVLET:  Joining to ClientAdder
> >>>>> CLIENTADDERDELAY:  Before Update: 00001:120
> >>>>> CLIENTADDERDELAY:  Sleeping for 5000 millis
> >>>>> CLIENTADDER:  Before Update: 00001:120
> >>>>> CLIENTADDER: Changing name to 00000: 120
> >>>>> CLIENTADDER:  After Update: 00000:121
> >>>>> SERVLET:  Joingin to ClientAdderDelay
> >>>>> CLIENTADDERDELAY: Changing name to 00000:120
> >>>>> CLIENTADDERDELAY: (121)
> >>>>> org.apache.ojb.broker.OptimisticLockException: Object has been
> >>>>> modified by someone else
> >>>>> CLIENTADDERDELAY:  After Update: 00000:121
> >>>>> *************************** END ************************
> >>>>>
> >>>>> *************************** START ************************
> >>>>> SERVLET:  Starting ClientAdderDelay
> >>>>> SERVLET:  Starting ClientAdder
> >>>>> SERVLET:  Joining to ClientAdder
> >>>>> CLIENTADDERDELAY:  Before Update: 00000:121
> >>>>> CLIENTADDERDELAY:  Sleeping for 5000 millis
> >>>>> CLIENTADDER:  Before Update: 00000:121
> >>>>> CLIENTADDER: Changing name to 00001: 121
> >>>>> CLIENTADDER:  After Update: 00001:122
> >>>>> SERVLET:  Joingin to ClientAdderDelay
> >>>>> CLIENTADDERDELAY: Changing name to 00001:122
> >>>>> CLIENTADDERDELAY:  After Update: 00001:123
> >>>>> *************************** END ************************
> >>>>>
> >>>>> Everything looks the same, to me except the first time the
exception
> >>>>> is thrown, and the database is only updated once, the second
time the
> >>>>> exception isn't thrown and the database is updated twice.
> >>>>>
> >>>>> Does anyone else have any suggestions on what I should try next?
> >>>>>
> >>>>> On Fri, 3 Dec 2004 10:25:04 +0100, Alessandro Colantoni
> >>>>> <ac...@brujulatelecom.com> wrote:
> >>>>>
> >>>>>
> >>>>>> Hi Wesley.
> >>>>>> I don't think the problem is the new connection.
> >>>>>> It looks like thread B do his job (the second time, of course)
after
> >>>>>> thread A has done his one.
> >>>>>> That's should be the reason you don't get the optimistic lock
Exception
> >>>>>> the second time (I don't see it).
> >>>>>> You should print the value of the ackOptLock parameter to have
more
> >>>>>> informations.
> >>>>>> I hope this help
> >>>>>>
> >>>>>> -----Mensaje original-----
> >>>>>> De: Wesley Lemke [mailto:buck.lemke@gmail.com]
> >>>>>> Enviado el: jueves, 02 de diciembre de 2004 22:51
> >>>>>> Para: OJB Users List
> >>>>>> Asunto: Optimistic Locking Problem.
> >>>>>>
> >>>>>>
> >>>>>>
> >>>>>> We are adding optimistic locking to our application.  To test
it out I
> >>>>>> have made a simple test case.  The application spawns two
threads.
> >>>>>>
> >>>>>> Thread A (ClientAdderDelay):  Reads an object from the
database.  It
> >>>>>> then checks the name of the ojbect.  If the name was 00000 it
changes
> >>>>>> it to 00001 and if the name was 00001 it changes it to 00000.
The
> >>>>>> thread sleeps for 5 seconds and then stores the object.
> >>>>>>
> >>>>>> Thread B (ClientAdder):  Does the same thing, but doesn't sleep
5
> >>>>>> seconds between the read/store.
> >>>>>>
> >>>>>> The main servlet starts thread A, then sleeps for 1 second and
starts
> >>>>>> thread B.
> >>>>>>
> >>>>>> The very first time I run the application everything works as
it
> >>>>>> should, Thread A and B both read 00000 from the database.
Thread B
> >>>>>> then updates the row to be 00001.  Thread A gets and
OptimisticLock
> >>>>>> exception when it tries to store the object.
> >>>>>>
> >>>>>> However all subsequent times that I run the application Thread
A will
> >>>>>> get the correct value from the database but thread B will get
the
> >>>>>> opposite value.  I am attaching the output, which will
hopefully make
> >>>>>> this more understandable.  The one difference I see is that the
> >>>>>> Datasource gets a new connection the first time the Servlet is
run,
> >>>>>> but not the second...I wouldn't think that this would matter?
> >>>>>>
> >>>>>> OUTPUT:
> >>>>>>
> >>>>>> [12/2/04 15:47:56:436 CST] 797e3663 SystemErr     R
> >>>>>> *************************** START ************************
> >>>>>> [12/2/04 15:47:56:466 CST] 797e3663 SystemErr     R SERVLET:
Starting
> >>>>>> ClientAdderDelay
> >>>>>> [12/2/04 15:47:56:466 CST] 797e3663 SystemErr     R SERVLET:
Sleeping
> >>>>>> 1000 millis
> >>>>>> [12/2/04 15:47:56:896 CST] 6de77661 Config        E
> >>>>>> com.opensymphony.oscache.base.Config  Error reading
> >>>>>> /oscache.properties in CacheAdministrator.loadProps()
> >>>>>> java.lang.NullPointerException
> >>>>>> [12/2/04 15:47:56:906 CST] 6de77661 Config        E
> >>>>>> com.opensymphony.oscache.base.Config  Ensure the
/oscache.properties
> >>>>>> file is readable and in your classpath.
> >>>>>> [12/2/04 15:47:56:916 CST] 6de77661 GeneralCacheA I
> >>>>>> com.opensymphony.oscache.general.GeneralCacheAdministrator
> >>>>>> Constructed GeneralCacheAdministrator()
> >>>>>> [12/2/04 15:47:56:916 CST] 6de77661 GeneralCacheA I
> >>>>>> com.opensymphony.oscache.general.GeneralCacheAdministrator
Creating
> >>>>>> new cache
> >>>>>> [12/2/04 15:47:58:469 CST] 6de77661 DSConfigurati W DSRA0174W:
> >>>>>> Warning: GenericDataStoreHelper is being used.
> >>>>>> [12/2/04 15:47:58:629 CST] 6de77661 ConnectionFac I J2CA0122I:
> >>>>>> Resource reference jdbc/ao79 could not be located, so default
values
> >>>>>> of the following are used: [Resource-ref settings]
> >>>>>>
> >>>>>>       res-auth:                 1 (APPLICATION)
> >>>>>>       res-isolation-level:      0 (TRANSACTION_NONE)
> >>>>>>       res-sharing-scope:        true (SHAREABLE)
> >>>>>>       res-resolution-control:   999 (undefined)
> >>>>>> [Other attributes]
> >>>>>>
> >>>>>> isCMP1_x:                 false (not CMP1.x)
> >>>>>> isJMS:                 false (not JMS)
> >>>>>>
> >>>>>> [12/2/04 15:47:58:669 CST] 6de77661 ConnectionFac I J2CA0107I:
> >>>>>> Component-managed authentication alias not specified for
connection
> >>>>>> factory or datasource MySql Datasource on ao79.
> >>>>>> [12/2/04 15:47:58:699 CST] 4b22f67d ConnectionFac I J2CA0122I:
> >>>>>> Resource reference jdbc/ao79 could not be located, so default
values
> >>>>>> of the following are used: [Resource-ref settings]
> >>>>>>
> >>>>>>       res-auth:                 1 (APPLICATION)
> >>>>>>       res-isolation-level:      0 (TRANSACTION_NONE)
> >>>>>>       res-sharing-scope:        true (SHAREABLE)
> >>>>>>       res-resolution-control:   999 (undefined)
> >>>>>> [Other attributes]
> >>>>>>
> >>>>>> isCMP1_x:                 false (not CMP1.x)
> >>>>>> isJMS:                 false (not JMS)
> >>>>>>
> >>>>>> [12/2/04 15:47:58:699 CST] 6de77661 ConnectionMan W J2CA0075W:
An
> >>>>>> active transaction should be present while processing method
> >>>>>> allocateMCWrapper.
> >>>>>> [12/2/04 15:47:58:709 CST] 4b22f67d ConnectionMan W J2CA0075W:
An
> >>>>>> active transaction should be present while processing method
> >>>>>> allocateMCWrapper.
> >>>>>> [12/2/04 15:47:57:477 CST] 797e3663 SystemErr     R SERVLET:
Starting
> >>>>>> ClientAdder
> >>>>>> [12/2/04 15:47:57:477 CST] 797e3663 SystemErr     R SERVLET:
Joining
> >>>>>> to ClientAdder
> >>>>>> [12/2/04 15:47:59:170 CST] 4b22f67d WSRdbDataSour u Database
version is
> >>>>>>                                3.23.41
> >>>>>> [12/2/04 15:47:59:170 CST] 4b22f67d WSRdbDataSour u JDBC Driver
version
> >>>>>> is
> >>>>>>                                mysql-connector-java-3.0.15-ga (
> >>>>>> $Date: 2004/08/09 22:15:11 $, $Revision: 1.27.2.43 $ )
> >>>>>> [12/2/04 15:47:59:250 CST] 4b22f67d ConnectionMan W J2CA0075W:
An
> >>>>>> active transaction should be present while processing method
> >>>>>> initializeForUOW.
> >>>>>> [12/2/04 15:47:59:250 CST] 6de77661 ConnectionMan W J2CA0075W:
An
> >>>>>> active transaction should be present while processing method
> >>>>>> initializeForUOW.
> >>>>>> [12/2/04 15:47:59:530 CST] 4b22f67d SystemErr     R
CLIENTADDER:
> >>>>>> Before Update: 00000<br>
> >>>>>> [12/2/04 15:47:59:560 CST] 4b22f67d SystemErr     R
CLIENTADDER:
> >>>>>> Changing name to 00001
> >>>>>> [12/2/04 15:47:59:560 CST] 6de77661 SystemErr     R
CLIENTADDERDELAY:
> >>>>>> Before Update: 00000<br>
> >>>>>> [12/2/04 15:47:59:560 CST] 6de77661 SystemErr     R
CLIENTADDERDELAY:
> >>>>>> Sleeping for 5000 millis
> >>>>>> [12/2/04 15:47:59:570 CST] 4b22f67d ConnectionMan W J2CA0075W:
An
> >>>>>> active transaction should be present while processing method
> >>>>>> allocateMCWrapper.
> >>>>>> [12/2/04 15:47:59:570 CST] 4b22f67d ConnectionMan W J2CA0075W:
An
> >>>>>> active transaction should be present while processing method
> >>>>>> initializeForUOW.
> >>>>>> [12/2/04 15:47:59:590 CST] 4b22f67d SystemErr     R
CLIENTADDER:
> >>>>>> After Update: 00001<br>
> >>>>>> [12/2/04 15:47:59:590 CST] 797e3663 SystemErr     R SERVLET:
Joingin
> >>>>>> to ClientAdderDelay
> >>>>>> [12/2/04 15:48:04:557 CST] 6de77661 SystemErr     R
CLIENTADDERDELAY:
> >>>>>> Changing name to 00001
> >>>>>> [12/2/04 15:48:04:617 CST] 6de77661 SystemErr     R
> >>>>>> CLIENTADDERDELAY:org.apache.ojb.broker.OptimisticLockException:
Object
> >>>>>> has been modified by someone else
> >>>>>> [12/2/04 15:48:04:617 CST] 6de77661 ConnectionMan W J2CA0075W:
An
> >>>>>> active transaction should be present while processing method
> >>>>>> allocateMCWrapper.
> >>>>>> [12/2/04 15:48:04:627 CST] 6de77661 ConnectionMan W J2CA0075W:
An
> >>>>>> active transaction should be present while processing method
> >>>>>> initializeForUOW.
> >>>>>> [12/2/04 15:48:04:637 CST] 6de77661 SystemErr     R
CLIENTADDERDELAY:
> >>>>>> After Update: 00001<br>
> >>>>>> [12/2/04 15:48:04:637 CST] 797e3663 SystemErr     R
> >>>>>> *************************** END ************************
> >>>>>> [12/2/04 15:48:47:729 CST] 797e3663 SystemErr     R
> >>>>>> *************************** START ************************
> >>>>>> [12/2/04 15:48:47:729 CST] 797e3663 SystemErr     R SERVLET:
Starting
> >>>>>> ClientAdderDelay
> >>>>>> [12/2/04 15:48:47:729 CST] 797e3663 SystemErr     R SERVLET:
Sleeping
> >>>>>> 1000 millis
> >>>>>> [12/2/04 15:48:47:779 CST] 1ec7f672 ConnectionMan W J2CA0075W:
An
> >>>>>> active transaction should be present while processing method
> >>>>>> allocateMCWrapper.
> >>>>>> [12/2/04 15:48:47:840 CST] 1ec7f672 ConnectionMan W J2CA0075W:
An
> >>>>>> active transaction should be present while processing method
> >>>>>> initializeForUOW.
> >>>>>> [12/2/04 15:48:47:850 CST] 1ec7f672 SystemErr     R
CLIENTADDERDELAY:
> >>>>>> Before Update: 00001<br>
> >>>>>> [12/2/04 15:48:47:850 CST] 1ec7f672 SystemErr     R
CLIENTADDERDELAY:
> >>>>>> Sleeping for 5000 millis
> >>>>>> [12/2/04 15:48:48:931 CST] 797e3663 SystemErr     R SERVLET:
Starting
> >>>>>> ClientAdder
> >>>>>> [12/2/04 15:48:48:931 CST] 797e3663 SystemErr     R SERVLET:
Joining
> >>>>>> to ClientAdder
> >>>>>> [12/2/04 15:48:48:931 CST] 1ec0f672 ConnectionMan W J2CA0075W:
An
> >>>>>> active transaction should be present while processing method
> >>>>>> allocateMCWrapper.
> >>>>>> [12/2/04 15:48:49:031 CST] 1ec0f672 ConnectionMan W J2CA0075W:
An
> >>>>>> active transaction should be present while processing method
> >>>>>> initializeForUOW.
> >>>>>> [12/2/04 15:48:49:041 CST] 1ec0f672 SystemErr     R
CLIENTADDER:
> >>>>>> Before Update: 00000<br>
> >>>>>> [12/2/04 15:48:49:041 CST] 1ec0f672 SystemErr     R
CLIENTADDER:
> >>>>>> Changing name to 00001
> >>>>>> [12/2/04 15:48:49:051 CST] 1ec0f672 ConnectionMan W J2CA0075W:
An
> >>>>>> active transaction should be present while processing method
> >>>>>> allocateMCWrapper.
> >>>>>> [12/2/04 15:48:49:061 CST] 1ec0f672 ConnectionMan W J2CA0075W:
An
> >>>>>> active transaction should be present while processing method
> >>>>>> initializeForUOW.
> >>>>>> [12/2/04 15:48:49:081 CST] 1ec0f672 SystemErr     R
CLIENTADDER:
> >>>>>> After Update: 00001<br>
> >>>>>> [12/2/04 15:48:49:081 CST] 797e3663 SystemErr     R SERVLET:
Joingin
> >>>>>> to ClientAdderDelay
> >>>>>> [12/2/04 15:48:52:857 CST] 1ec7f672 SystemErr     R
CLIENTADDERDELAY:
> >>>>>> Changing name to 00001
> >>>>>> [12/2/04 15:48:52:857 CST] 1ec7f672 ConnectionMan W J2CA0075W:
An
> >>>>>> active transaction should be present while processing method
> >>>>>> allocateMCWrapper.
> >>>>>> [12/2/04 15:48:52:867 CST] 1ec7f672 ConnectionMan W J2CA0075W:
An
> >>>>>> active transaction should be present while processing method
> >>>>>> initializeForUOW.
> >>>>>> [12/2/04 15:48:52:877 CST] 1ec7f672 SystemErr     R
CLIENTADDERDELAY:
> >>>>>> After Update: 00001<br>
> >>>>>> [12/2/04 15:48:52:877 CST] 797e3663 SystemErr     R
> >>>>>> *************************** END ************************
> >>>>>>
> >>>>>> Let me know if any more information would be helpful...
> >>>>>>
> >>>>>>
---------------------------------------------------------------------
> >>>>>> To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
> >>>>>> For additional commands, e-mail: ojb-user-help@db.apache.org
> >>>>>>
> >>>>>>
> >>>>>
> >>>>>
> >>>>>
---------------------------------------------------------------------
> >>>>> To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
> >>>>> For additional commands, e-mail: ojb-user-help@db.apache.org
> >>>>>
> >>>>>
> >>>>>
> >>>>
> >>>>
---------------------------------------------------------------------
> >>>>
> >>>>
> >>>> To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
> >>>> For additional commands, e-mail: ojb-user-help@db.apache.org
> >>>>
> >>>>
> >>>
> >>>
> >>>
---------------------------------------------------------------------
> >>
> >>
> >>> To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
> >>> For additional commands, e-mail: ojb-user-help@db.apache.org
> >>>
> >>>
> >>>
> >>
> >>
---------------------------------------------------------------------
> >> To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
> >> For additional commands, e-mail: ojb-user-help@db.apache.org
> >>
> >>
> > 
> >
---------------------------------------------------------------------
> > To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
> > For additional commands, e-mail: ojb-user-help@db.apache.org
> 
> 
> R
> 
> --
> Robert S. Sfeir
> Software Developer
> Codepuccino
> "Make everything as simple as possible, but not simpler." -- Einstein
> 
> http://www.codepuccino.com
> blog: http://blogs.codepuccino.com/dude
> 
> ---------------------------------------------------------------------
> 
> 
> To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
> For additional commands, e-mail: ojb-user-help@db.apache.org
> 
>

---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-user-help@db.apache.org




---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-user-help@db.apache.org


Re: Optimistic Locking Problem.

Posted by Wesley Lemke <bu...@gmail.com>.
I didn't have pb.close() in my code, Just the pb.commit().  I have
added pb.close now, and the same thing still happens.  The first time
I run the code the exception is thrown, but not after that.  Here is
the full log if it helps (the number after the ":" is the lock value):

[12/6/04 10:08:51:555 CST] 1693a8ea SystemErr     R
*************************** START ************************
[12/6/04 10:08:51:585 CST] 1693a8ea SystemErr     R SERVLET:  Starting
ClientAdderDelay
[12/6/04 10:08:51:585 CST] 1693a8ea SystemErr     R SERVLET:  Starting
ClientAdder
[12/6/04 10:08:51:585 CST] 1693a8ea SystemErr     R SERVLET:  Joining
to ClientAdder
[12/6/04 10:08:51:875 CST]  d54e8f9 Config        E
com.opensymphony.oscache.base.Config  Error reading
/oscache.properties in CacheAdministrator.loadProps()
java.lang.NullPointerException
[12/6/04 10:08:51:875 CST]  d54e8f9 Config        E
com.opensymphony.oscache.base.Config  Ensure the /oscache.properties
file is readable and in your classpath.
[12/6/04 10:08:51:885 CST]  d54e8f9 GeneralCacheA I
com.opensymphony.oscache.general.GeneralCacheAdministrator 
Constructed GeneralCacheAdministrator()
[12/6/04 10:08:51:885 CST]  d54e8f9 GeneralCacheA I
com.opensymphony.oscache.general.GeneralCacheAdministrator  Creating
new cache
[12/6/04 10:08:53:157 CST]  d5668f9 ConnectionFac I J2CA0122I:
Resource reference jdbc/ao79 could not be located, so default values
of the following are used: [Resource-ref settings]

	res-auth:                 1 (APPLICATION)
	res-isolation-level:      0 (TRANSACTION_NONE)
	res-sharing-scope:        true (SHAREABLE)
	res-resolution-control:   999 (undefined)
[Other attributes]

isCMP1_x:                 false (not CMP1.x)
isJMS:                 false (not JMS)

[12/6/04 10:08:53:167 CST]  d54e8f9 ConnectionFac I J2CA0122I:
Resource reference jdbc/ao79 could not be located, so default values
of the following are used: [Resource-ref settings]

	res-auth:                 1 (APPLICATION)
	res-isolation-level:      0 (TRANSACTION_NONE)
	res-sharing-scope:        true (SHAREABLE)
	res-resolution-control:   999 (undefined)
[Other attributes]

isCMP1_x:                 false (not CMP1.x)
isJMS:                 false (not JMS)

[12/6/04 10:08:53:167 CST]  d54e8f9 ConnectionMan W J2CA0075W: An
active transaction should be present while processing method
allocateMCWrapper.
[12/6/04 10:08:53:167 CST]  d5668f9 ConnectionMan W J2CA0075W: An
active transaction should be present while processing method
allocateMCWrapper.
[12/6/04 10:08:53:177 CST]  d54e8f9 ConnectionMan W J2CA0075W: An
active transaction should be present while processing method
initializeForUOW.
[12/6/04 10:08:53:177 CST]  d5668f9 ConnectionMan W J2CA0075W: An
active transaction should be present while processing method
initializeForUOW.
[12/6/04 10:08:53:537 CST]  d5668f9 SystemErr     R CLIENTADDER: 
Before Update: 00000:139
[12/6/04 10:08:53:537 CST]  d5668f9 SystemErr     R CLIENTADDER:
Changing name to 00001: 139
[12/6/04 10:08:53:537 CST]  d54e8f9 SystemErr     R CLIENTADDERDELAY: 
Before Update: 00000:139
[12/6/04 10:08:53:547 CST]  d54e8f9 SystemErr     R CLIENTADDERDELAY: 
Sleeping for 5000 millis
[12/6/04 10:08:53:547 CST]  d5668f9 ConnectionMan W J2CA0075W: An
active transaction should be present while processing method
allocateMCWrapper.
[12/6/04 10:08:53:597 CST]  d5668f9 ConnectionMan W J2CA0075W: An
active transaction should be present while processing method
initializeForUOW.
[12/6/04 10:08:53:608 CST]  d5668f9 SystemErr     R CLIENTADDER: 
After Update: 00001:140
[12/6/04 10:08:53:618 CST] 1693a8ea SystemErr     R SERVLET:  Joining
to ClientAdderDelay
[12/6/04 10:08:58:545 CST]  d54e8f9 SystemErr     R CLIENTADDERDELAY:
Changing name to 00001:139
[12/6/04 10:08:58:605 CST]  d54e8f9 SystemErr     R CLIENTADDERDELAY:
(140) org.apache.ojb.broker.OptimisticLockException: Object has been
modified by someone else
[12/6/04 10:08:58:605 CST]  d54e8f9 ConnectionMan W J2CA0075W: An
active transaction should be present while processing method
allocateMCWrapper.
[12/6/04 10:08:58:615 CST]  d54e8f9 ConnectionMan W J2CA0075W: An
active transaction should be present while processing method
initializeForUOW.
[12/6/04 10:08:58:625 CST]  d54e8f9 SystemErr     R CLIENTADDERDELAY: 
After Update: 00001:140
[12/6/04 10:08:58:625 CST] 1693a8ea SystemErr     R
*************************** END ************************
[12/6/04 10:08:58:735 CST] 1693a8ea OSEListenerDi E PLGN0021E: Servlet
Request Processor Exception: Virtual Host/WebGroup Not Found : The web
group /favicon.ico has not been defined
[12/6/04 10:09:07:698 CST] 1dcd68fe SystemErr     R
*************************** START ************************
[12/6/04 10:09:07:708 CST] 1dcd68fe SystemErr     R SERVLET:  Starting
ClientAdderDelay
[12/6/04 10:09:07:708 CST] 1dcd68fe SystemErr     R SERVLET:  Starting
ClientAdder
[12/6/04 10:09:07:708 CST] 1dcd68fe SystemErr     R SERVLET:  Joining
to ClientAdder
[12/6/04 10:09:07:708 CST]  12628e0 ConnectionMan W J2CA0075W: An
active transaction should be present while processing method
allocateMCWrapper.
[12/6/04 10:09:07:708 CST]  13ba8e0 ConnectionMan W J2CA0075W: An
active transaction should be present while processing method
allocateMCWrapper.
[12/6/04 10:09:07:748 CST]  12628e0 ConnectionMan W J2CA0075W: An
active transaction should be present while processing method
initializeForUOW.
[12/6/04 10:09:07:798 CST]  12628e0 SystemErr     R CLIENTADDERDELAY: 
Before Update: 00001:140
[12/6/04 10:09:07:798 CST]  12628e0 SystemErr     R CLIENTADDERDELAY: 
Sleeping for 5000 millis
[12/6/04 10:09:07:758 CST]  13ba8e0 ConnectionMan W J2CA0075W: An
active transaction should be present while processing method
initializeForUOW.
[12/6/04 10:09:07:828 CST]  13ba8e0 SystemErr     R CLIENTADDER: 
Before Update: 00001:140
[12/6/04 10:09:07:828 CST]  13ba8e0 SystemErr     R CLIENTADDER:
Changing name to 00000: 140
[12/6/04 10:09:07:848 CST]  13ba8e0 ConnectionMan W J2CA0075W: An
active transaction should be present while processing method
allocateMCWrapper.
[12/6/04 10:09:07:868 CST]  13ba8e0 ConnectionMan W J2CA0075W: An
active transaction should be present while processing method
initializeForUOW.
[12/6/04 10:09:07:918 CST]  13ba8e0 SystemErr     R CLIENTADDER: 
After Update: 00000:141
[12/6/04 10:09:07:918 CST] 1dcd68fe SystemErr     R SERVLET:  Joining
to ClientAdderDelay
[12/6/04 10:09:12:815 CST]  12628e0 SystemErr     R CLIENTADDERDELAY:
Changing name to 00000:141
[12/6/04 10:09:12:825 CST]  12628e0 ConnectionMan W J2CA0075W: An
active transaction should be present while processing method
allocateMCWrapper.
[12/6/04 10:09:12:825 CST]  12628e0 ConnectionMan W J2CA0075W: An
active transaction should be present while processing method
initializeForUOW.
[12/6/04 10:09:12:835 CST]  12628e0 SystemErr     R CLIENTADDERDELAY: 
After Update: 00000:142
[12/6/04 10:09:12:845 CST] 1dcd68fe SystemErr     R
*************************** END ************************



On Sat, 04 Dec 2004 15:13:09 -0500, Robert S. Sfeir
<ro...@codepuccino.com> wrote:
> Don't forget pb.close() when you're done.
> 
> R
> 
> 
> 
> 
> On 12/4/04 3:07 PM, "Wesley Lemke" <bu...@gmail.com> wrote:
> 
> > Right now I am using the PB.beginTransactoin, and PB.commit...
> >
> >
> > On Sat, 04 Dec 2004 18:53:43 +0100, Armin Waibel <ar...@apache.org> wrote:
> >> Hi Wesley,
> >>
> >> Wesley Lemke wrote:
> >>
> >>> I am using the integer as the lock field.  On monday I can give it a
> >>> shot with a timestamp.
> >>
> >> Integer is fine. There is a bug when using Timestamp values in OJB1.0.1,
> >> so Integer is a better choice.
> >>
> >>> I just can't figure out why it works the first
> >>> time I run it, but then the exception is not thrown after that.  Could
> >>> it have something to do with the data source getting a new connection
> >>> the first time?
> >>>
> >>
> >> hmm, if the used connections don't get committed side-effects could
> >> happen. Do you use PB-tx demarcation (PB.beginT...) (or JTA-tx when in
> >> managed environment)?
> >>
> >> I checked in a multithreaded optimistic locking test in CVS branch
> >> OJB_1_0_RELEASE
> >>
> >> http://cvs.apache.org/viewcvs.cgi/db-ojb/src/test/org/apache/ojb/broker/Optim
> >> isticLockingMultithreadedTest.java?rev=1.1.2.1&only_with_tag=OJB_1_0_RELEASE&
> >> view=markup
> >>
> >> This test (multiple threads try to update the same object) seems to work
> >> and case OLE when version conflict occur.
> >>
> >> regards,
> >> Armin
> >>
> >>
> >>
> >>
> >>>
> >>> On Fri, 03 Dec 2004 23:01:48 +0100, Armin Waibel <ar...@apache.org> wrote:
> >>>
> >>>> Hi Wesley,
> >>>>
> >>>> I did a multithreaded test too - all seems ok.
> >>>> Do you use a Timestamp as lock field?
> >>>> Do you re-read the used object when writing fails (to get fresh object
> >>>> with valid lock version)?
> >>>>
> >>>> regards,
> >>>> Armin
> >>>>
> >>>>
> >>>>
> >>>> Wesley Lemke wrote:
> >>>>
> >>>>
> >>>>> I am now printing the ackOptLock value, but still am only getting the
> >>>>> OptimisticLock exception the first time I run the code after I restart
> >>>>> the servlet containter.  Here is the log files of the first two runs.
> >>>>>
> >>>>> *************************** START ************************
> >>>>> SERVLET:  Starting ClientAdderDelay
> >>>>> SERVLET:  Starting ClientAdder
> >>>>> SERVLET:  Joining to ClientAdder
> >>>>> CLIENTADDERDELAY:  Before Update: 00001:120
> >>>>> CLIENTADDERDELAY:  Sleeping for 5000 millis
> >>>>> CLIENTADDER:  Before Update: 00001:120
> >>>>> CLIENTADDER: Changing name to 00000: 120
> >>>>> CLIENTADDER:  After Update: 00000:121
> >>>>> SERVLET:  Joingin to ClientAdderDelay
> >>>>> CLIENTADDERDELAY: Changing name to 00000:120
> >>>>> CLIENTADDERDELAY: (121)
> >>>>> org.apache.ojb.broker.OptimisticLockException: Object has been
> >>>>> modified by someone else
> >>>>> CLIENTADDERDELAY:  After Update: 00000:121
> >>>>> *************************** END ************************
> >>>>>
> >>>>> *************************** START ************************
> >>>>> SERVLET:  Starting ClientAdderDelay
> >>>>> SERVLET:  Starting ClientAdder
> >>>>> SERVLET:  Joining to ClientAdder
> >>>>> CLIENTADDERDELAY:  Before Update: 00000:121
> >>>>> CLIENTADDERDELAY:  Sleeping for 5000 millis
> >>>>> CLIENTADDER:  Before Update: 00000:121
> >>>>> CLIENTADDER: Changing name to 00001: 121
> >>>>> CLIENTADDER:  After Update: 00001:122
> >>>>> SERVLET:  Joingin to ClientAdderDelay
> >>>>> CLIENTADDERDELAY: Changing name to 00001:122
> >>>>> CLIENTADDERDELAY:  After Update: 00001:123
> >>>>> *************************** END ************************
> >>>>>
> >>>>> Everything looks the same, to me except the first time the exception
> >>>>> is thrown, and the database is only updated once, the second time the
> >>>>> exception isn't thrown and the database is updated twice.
> >>>>>
> >>>>> Does anyone else have any suggestions on what I should try next?
> >>>>>
> >>>>> On Fri, 3 Dec 2004 10:25:04 +0100, Alessandro Colantoni
> >>>>> <ac...@brujulatelecom.com> wrote:
> >>>>>
> >>>>>
> >>>>>> Hi Wesley.
> >>>>>> I don't think the problem is the new connection.
> >>>>>> It looks like thread B do his job (the second time, of course) after
> >>>>>> thread A has done his one.
> >>>>>> That's should be the reason you don't get the optimistic lock Exception
> >>>>>> the second time (I don't see it).
> >>>>>> You should print the value of the ackOptLock parameter to have more
> >>>>>> informations.
> >>>>>> I hope this help
> >>>>>>
> >>>>>> -----Mensaje original-----
> >>>>>> De: Wesley Lemke [mailto:buck.lemke@gmail.com]
> >>>>>> Enviado el: jueves, 02 de diciembre de 2004 22:51
> >>>>>> Para: OJB Users List
> >>>>>> Asunto: Optimistic Locking Problem.
> >>>>>>
> >>>>>>
> >>>>>>
> >>>>>> We are adding optimistic locking to our application.  To test it out I
> >>>>>> have made a simple test case.  The application spawns two threads.
> >>>>>>
> >>>>>> Thread A (ClientAdderDelay):  Reads an object from the database.  It
> >>>>>> then checks the name of the ojbect.  If the name was 00000 it changes
> >>>>>> it to 00001 and if the name was 00001 it changes it to 00000.  The
> >>>>>> thread sleeps for 5 seconds and then stores the object.
> >>>>>>
> >>>>>> Thread B (ClientAdder):  Does the same thing, but doesn't sleep 5
> >>>>>> seconds between the read/store.
> >>>>>>
> >>>>>> The main servlet starts thread A, then sleeps for 1 second and starts
> >>>>>> thread B.
> >>>>>>
> >>>>>> The very first time I run the application everything works as it
> >>>>>> should, Thread A and B both read 00000 from the database.  Thread B
> >>>>>> then updates the row to be 00001.  Thread A gets and OptimisticLock
> >>>>>> exception when it tries to store the object.
> >>>>>>
> >>>>>> However all subsequent times that I run the application Thread A will
> >>>>>> get the correct value from the database but thread B will get the
> >>>>>> opposite value.  I am attaching the output, which will hopefully make
> >>>>>> this more understandable.  The one difference I see is that the
> >>>>>> Datasource gets a new connection the first time the Servlet is run,
> >>>>>> but not the second...I wouldn't think that this would matter?
> >>>>>>
> >>>>>> OUTPUT:
> >>>>>>
> >>>>>> [12/2/04 15:47:56:436 CST] 797e3663 SystemErr     R
> >>>>>> *************************** START ************************
> >>>>>> [12/2/04 15:47:56:466 CST] 797e3663 SystemErr     R SERVLET:  Starting
> >>>>>> ClientAdderDelay
> >>>>>> [12/2/04 15:47:56:466 CST] 797e3663 SystemErr     R SERVLET:  Sleeping
> >>>>>> 1000 millis
> >>>>>> [12/2/04 15:47:56:896 CST] 6de77661 Config        E
> >>>>>> com.opensymphony.oscache.base.Config  Error reading
> >>>>>> /oscache.properties in CacheAdministrator.loadProps()
> >>>>>> java.lang.NullPointerException
> >>>>>> [12/2/04 15:47:56:906 CST] 6de77661 Config        E
> >>>>>> com.opensymphony.oscache.base.Config  Ensure the /oscache.properties
> >>>>>> file is readable and in your classpath.
> >>>>>> [12/2/04 15:47:56:916 CST] 6de77661 GeneralCacheA I
> >>>>>> com.opensymphony.oscache.general.GeneralCacheAdministrator
> >>>>>> Constructed GeneralCacheAdministrator()
> >>>>>> [12/2/04 15:47:56:916 CST] 6de77661 GeneralCacheA I
> >>>>>> com.opensymphony.oscache.general.GeneralCacheAdministrator  Creating
> >>>>>> new cache
> >>>>>> [12/2/04 15:47:58:469 CST] 6de77661 DSConfigurati W DSRA0174W:
> >>>>>> Warning: GenericDataStoreHelper is being used.
> >>>>>> [12/2/04 15:47:58:629 CST] 6de77661 ConnectionFac I J2CA0122I:
> >>>>>> Resource reference jdbc/ao79 could not be located, so default values
> >>>>>> of the following are used: [Resource-ref settings]
> >>>>>>
> >>>>>>       res-auth:                 1 (APPLICATION)
> >>>>>>       res-isolation-level:      0 (TRANSACTION_NONE)
> >>>>>>       res-sharing-scope:        true (SHAREABLE)
> >>>>>>       res-resolution-control:   999 (undefined)
> >>>>>> [Other attributes]
> >>>>>>
> >>>>>> isCMP1_x:                 false (not CMP1.x)
> >>>>>> isJMS:                 false (not JMS)
> >>>>>>
> >>>>>> [12/2/04 15:47:58:669 CST] 6de77661 ConnectionFac I J2CA0107I:
> >>>>>> Component-managed authentication alias not specified for connection
> >>>>>> factory or datasource MySql Datasource on ao79.
> >>>>>> [12/2/04 15:47:58:699 CST] 4b22f67d ConnectionFac I J2CA0122I:
> >>>>>> Resource reference jdbc/ao79 could not be located, so default values
> >>>>>> of the following are used: [Resource-ref settings]
> >>>>>>
> >>>>>>       res-auth:                 1 (APPLICATION)
> >>>>>>       res-isolation-level:      0 (TRANSACTION_NONE)
> >>>>>>       res-sharing-scope:        true (SHAREABLE)
> >>>>>>       res-resolution-control:   999 (undefined)
> >>>>>> [Other attributes]
> >>>>>>
> >>>>>> isCMP1_x:                 false (not CMP1.x)
> >>>>>> isJMS:                 false (not JMS)
> >>>>>>
> >>>>>> [12/2/04 15:47:58:699 CST] 6de77661 ConnectionMan W J2CA0075W: An
> >>>>>> active transaction should be present while processing method
> >>>>>> allocateMCWrapper.
> >>>>>> [12/2/04 15:47:58:709 CST] 4b22f67d ConnectionMan W J2CA0075W: An
> >>>>>> active transaction should be present while processing method
> >>>>>> allocateMCWrapper.
> >>>>>> [12/2/04 15:47:57:477 CST] 797e3663 SystemErr     R SERVLET:  Starting
> >>>>>> ClientAdder
> >>>>>> [12/2/04 15:47:57:477 CST] 797e3663 SystemErr     R SERVLET:  Joining
> >>>>>> to ClientAdder
> >>>>>> [12/2/04 15:47:59:170 CST] 4b22f67d WSRdbDataSour u Database version is
> >>>>>>                                3.23.41
> >>>>>> [12/2/04 15:47:59:170 CST] 4b22f67d WSRdbDataSour u JDBC Driver version
> >>>>>> is
> >>>>>>                                mysql-connector-java-3.0.15-ga (
> >>>>>> $Date: 2004/08/09 22:15:11 $, $Revision: 1.27.2.43 $ )
> >>>>>> [12/2/04 15:47:59:250 CST] 4b22f67d ConnectionMan W J2CA0075W: An
> >>>>>> active transaction should be present while processing method
> >>>>>> initializeForUOW.
> >>>>>> [12/2/04 15:47:59:250 CST] 6de77661 ConnectionMan W J2CA0075W: An
> >>>>>> active transaction should be present while processing method
> >>>>>> initializeForUOW.
> >>>>>> [12/2/04 15:47:59:530 CST] 4b22f67d SystemErr     R CLIENTADDER:
> >>>>>> Before Update: 00000<br>
> >>>>>> [12/2/04 15:47:59:560 CST] 4b22f67d SystemErr     R CLIENTADDER:
> >>>>>> Changing name to 00001
> >>>>>> [12/2/04 15:47:59:560 CST] 6de77661 SystemErr     R CLIENTADDERDELAY:
> >>>>>> Before Update: 00000<br>
> >>>>>> [12/2/04 15:47:59:560 CST] 6de77661 SystemErr     R CLIENTADDERDELAY:
> >>>>>> Sleeping for 5000 millis
> >>>>>> [12/2/04 15:47:59:570 CST] 4b22f67d ConnectionMan W J2CA0075W: An
> >>>>>> active transaction should be present while processing method
> >>>>>> allocateMCWrapper.
> >>>>>> [12/2/04 15:47:59:570 CST] 4b22f67d ConnectionMan W J2CA0075W: An
> >>>>>> active transaction should be present while processing method
> >>>>>> initializeForUOW.
> >>>>>> [12/2/04 15:47:59:590 CST] 4b22f67d SystemErr     R CLIENTADDER:
> >>>>>> After Update: 00001<br>
> >>>>>> [12/2/04 15:47:59:590 CST] 797e3663 SystemErr     R SERVLET:  Joingin
> >>>>>> to ClientAdderDelay
> >>>>>> [12/2/04 15:48:04:557 CST] 6de77661 SystemErr     R CLIENTADDERDELAY:
> >>>>>> Changing name to 00001
> >>>>>> [12/2/04 15:48:04:617 CST] 6de77661 SystemErr     R
> >>>>>> CLIENTADDERDELAY:org.apache.ojb.broker.OptimisticLockException: Object
> >>>>>> has been modified by someone else
> >>>>>> [12/2/04 15:48:04:617 CST] 6de77661 ConnectionMan W J2CA0075W: An
> >>>>>> active transaction should be present while processing method
> >>>>>> allocateMCWrapper.
> >>>>>> [12/2/04 15:48:04:627 CST] 6de77661 ConnectionMan W J2CA0075W: An
> >>>>>> active transaction should be present while processing method
> >>>>>> initializeForUOW.
> >>>>>> [12/2/04 15:48:04:637 CST] 6de77661 SystemErr     R CLIENTADDERDELAY:
> >>>>>> After Update: 00001<br>
> >>>>>> [12/2/04 15:48:04:637 CST] 797e3663 SystemErr     R
> >>>>>> *************************** END ************************
> >>>>>> [12/2/04 15:48:47:729 CST] 797e3663 SystemErr     R
> >>>>>> *************************** START ************************
> >>>>>> [12/2/04 15:48:47:729 CST] 797e3663 SystemErr     R SERVLET:  Starting
> >>>>>> ClientAdderDelay
> >>>>>> [12/2/04 15:48:47:729 CST] 797e3663 SystemErr     R SERVLET:  Sleeping
> >>>>>> 1000 millis
> >>>>>> [12/2/04 15:48:47:779 CST] 1ec7f672 ConnectionMan W J2CA0075W: An
> >>>>>> active transaction should be present while processing method
> >>>>>> allocateMCWrapper.
> >>>>>> [12/2/04 15:48:47:840 CST] 1ec7f672 ConnectionMan W J2CA0075W: An
> >>>>>> active transaction should be present while processing method
> >>>>>> initializeForUOW.
> >>>>>> [12/2/04 15:48:47:850 CST] 1ec7f672 SystemErr     R CLIENTADDERDELAY:
> >>>>>> Before Update: 00001<br>
> >>>>>> [12/2/04 15:48:47:850 CST] 1ec7f672 SystemErr     R CLIENTADDERDELAY:
> >>>>>> Sleeping for 5000 millis
> >>>>>> [12/2/04 15:48:48:931 CST] 797e3663 SystemErr     R SERVLET:  Starting
> >>>>>> ClientAdder
> >>>>>> [12/2/04 15:48:48:931 CST] 797e3663 SystemErr     R SERVLET:  Joining
> >>>>>> to ClientAdder
> >>>>>> [12/2/04 15:48:48:931 CST] 1ec0f672 ConnectionMan W J2CA0075W: An
> >>>>>> active transaction should be present while processing method
> >>>>>> allocateMCWrapper.
> >>>>>> [12/2/04 15:48:49:031 CST] 1ec0f672 ConnectionMan W J2CA0075W: An
> >>>>>> active transaction should be present while processing method
> >>>>>> initializeForUOW.
> >>>>>> [12/2/04 15:48:49:041 CST] 1ec0f672 SystemErr     R CLIENTADDER:
> >>>>>> Before Update: 00000<br>
> >>>>>> [12/2/04 15:48:49:041 CST] 1ec0f672 SystemErr     R CLIENTADDER:
> >>>>>> Changing name to 00001
> >>>>>> [12/2/04 15:48:49:051 CST] 1ec0f672 ConnectionMan W J2CA0075W: An
> >>>>>> active transaction should be present while processing method
> >>>>>> allocateMCWrapper.
> >>>>>> [12/2/04 15:48:49:061 CST] 1ec0f672 ConnectionMan W J2CA0075W: An
> >>>>>> active transaction should be present while processing method
> >>>>>> initializeForUOW.
> >>>>>> [12/2/04 15:48:49:081 CST] 1ec0f672 SystemErr     R CLIENTADDER:
> >>>>>> After Update: 00001<br>
> >>>>>> [12/2/04 15:48:49:081 CST] 797e3663 SystemErr     R SERVLET:  Joingin
> >>>>>> to ClientAdderDelay
> >>>>>> [12/2/04 15:48:52:857 CST] 1ec7f672 SystemErr     R CLIENTADDERDELAY:
> >>>>>> Changing name to 00001
> >>>>>> [12/2/04 15:48:52:857 CST] 1ec7f672 ConnectionMan W J2CA0075W: An
> >>>>>> active transaction should be present while processing method
> >>>>>> allocateMCWrapper.
> >>>>>> [12/2/04 15:48:52:867 CST] 1ec7f672 ConnectionMan W J2CA0075W: An
> >>>>>> active transaction should be present while processing method
> >>>>>> initializeForUOW.
> >>>>>> [12/2/04 15:48:52:877 CST] 1ec7f672 SystemErr     R CLIENTADDERDELAY:
> >>>>>> After Update: 00001<br>
> >>>>>> [12/2/04 15:48:52:877 CST] 797e3663 SystemErr     R
> >>>>>> *************************** END ************************
> >>>>>>
> >>>>>> Let me know if any more information would be helpful...
> >>>>>>
> >>>>>> ---------------------------------------------------------------------
> >>>>>> To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
> >>>>>> For additional commands, e-mail: ojb-user-help@db.apache.org
> >>>>>>
> >>>>>>
> >>>>>
> >>>>>
> >>>>> ---------------------------------------------------------------------
> >>>>> To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
> >>>>> For additional commands, e-mail: ojb-user-help@db.apache.org
> >>>>>
> >>>>>
> >>>>>
> >>>>
> >>>> ---------------------------------------------------------------------
> >>>>
> >>>>
> >>>> To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
> >>>> For additional commands, e-mail: ojb-user-help@db.apache.org
> >>>>
> >>>>
> >>>
> >>>
> >>> ---------------------------------------------------------------------
> >>
> >>
> >>> To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
> >>> For additional commands, e-mail: ojb-user-help@db.apache.org
> >>>
> >>>
> >>>
> >>
> >> ---------------------------------------------------------------------
> >> To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
> >> For additional commands, e-mail: ojb-user-help@db.apache.org
> >>
> >>
> > 
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
> > For additional commands, e-mail: ojb-user-help@db.apache.org
> 
> 
> R
> 
> --
> Robert S. Sfeir
> Software Developer
> Codepuccino
> "Make everything as simple as possible, but not simpler." -- Einstein
> 
> http://www.codepuccino.com
> blog: http://blogs.codepuccino.com/dude
> 
> ---------------------------------------------------------------------
> 
> 
> To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
> For additional commands, e-mail: ojb-user-help@db.apache.org
> 
>

---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-user-help@db.apache.org


Re: Optimistic Locking Problem.

Posted by "Robert S. Sfeir" <ro...@codepuccino.com>.
Don't forget pb.close() when you're done.

R


On 12/4/04 3:07 PM, "Wesley Lemke" <bu...@gmail.com> wrote:

> Right now I am using the PB.beginTransactoin, and PB.commit...
> 
> 
> On Sat, 04 Dec 2004 18:53:43 +0100, Armin Waibel <ar...@apache.org> wrote:
>> Hi Wesley,
>> 
>> Wesley Lemke wrote:
>> 
>>> I am using the integer as the lock field.  On monday I can give it a
>>> shot with a timestamp.
>> 
>> Integer is fine. There is a bug when using Timestamp values in OJB1.0.1,
>> so Integer is a better choice.
>> 
>>> I just can't figure out why it works the first
>>> time I run it, but then the exception is not thrown after that.  Could
>>> it have something to do with the data source getting a new connection
>>> the first time?
>>> 
>> 
>> hmm, if the used connections don't get committed side-effects could
>> happen. Do you use PB-tx demarcation (PB.beginT...) (or JTA-tx when in
>> managed environment)?
>> 
>> I checked in a multithreaded optimistic locking test in CVS branch
>> OJB_1_0_RELEASE
>> 
>> http://cvs.apache.org/viewcvs.cgi/db-ojb/src/test/org/apache/ojb/broker/Optim
>> isticLockingMultithreadedTest.java?rev=1.1.2.1&only_with_tag=OJB_1_0_RELEASE&
>> view=markup
>> 
>> This test (multiple threads try to update the same object) seems to work
>> and case OLE when version conflict occur.
>> 
>> regards,
>> Armin
>> 
>> 
>> 
>> 
>>> 
>>> On Fri, 03 Dec 2004 23:01:48 +0100, Armin Waibel <ar...@apache.org> wrote:
>>> 
>>>> Hi Wesley,
>>>> 
>>>> I did a multithreaded test too - all seems ok.
>>>> Do you use a Timestamp as lock field?
>>>> Do you re-read the used object when writing fails (to get fresh object
>>>> with valid lock version)?
>>>> 
>>>> regards,
>>>> Armin
>>>> 
>>>> 
>>>> 
>>>> Wesley Lemke wrote:
>>>> 
>>>> 
>>>>> I am now printing the ackOptLock value, but still am only getting the
>>>>> OptimisticLock exception the first time I run the code after I restart
>>>>> the servlet containter.  Here is the log files of the first two runs.
>>>>> 
>>>>> *************************** START ************************
>>>>> SERVLET:  Starting ClientAdderDelay
>>>>> SERVLET:  Starting ClientAdder
>>>>> SERVLET:  Joining to ClientAdder
>>>>> CLIENTADDERDELAY:  Before Update: 00001:120
>>>>> CLIENTADDERDELAY:  Sleeping for 5000 millis
>>>>> CLIENTADDER:  Before Update: 00001:120
>>>>> CLIENTADDER: Changing name to 00000: 120
>>>>> CLIENTADDER:  After Update: 00000:121
>>>>> SERVLET:  Joingin to ClientAdderDelay
>>>>> CLIENTADDERDELAY: Changing name to 00000:120
>>>>> CLIENTADDERDELAY: (121)
>>>>> org.apache.ojb.broker.OptimisticLockException: Object has been
>>>>> modified by someone else
>>>>> CLIENTADDERDELAY:  After Update: 00000:121
>>>>> *************************** END ************************
>>>>> 
>>>>> *************************** START ************************
>>>>> SERVLET:  Starting ClientAdderDelay
>>>>> SERVLET:  Starting ClientAdder
>>>>> SERVLET:  Joining to ClientAdder
>>>>> CLIENTADDERDELAY:  Before Update: 00000:121
>>>>> CLIENTADDERDELAY:  Sleeping for 5000 millis
>>>>> CLIENTADDER:  Before Update: 00000:121
>>>>> CLIENTADDER: Changing name to 00001: 121
>>>>> CLIENTADDER:  After Update: 00001:122
>>>>> SERVLET:  Joingin to ClientAdderDelay
>>>>> CLIENTADDERDELAY: Changing name to 00001:122
>>>>> CLIENTADDERDELAY:  After Update: 00001:123
>>>>> *************************** END ************************
>>>>> 
>>>>> Everything looks the same, to me except the first time the exception
>>>>> is thrown, and the database is only updated once, the second time the
>>>>> exception isn't thrown and the database is updated twice.
>>>>> 
>>>>> Does anyone else have any suggestions on what I should try next?
>>>>> 
>>>>> On Fri, 3 Dec 2004 10:25:04 +0100, Alessandro Colantoni
>>>>> <ac...@brujulatelecom.com> wrote:
>>>>> 
>>>>> 
>>>>>> Hi Wesley.
>>>>>> I don't think the problem is the new connection.
>>>>>> It looks like thread B do his job (the second time, of course) after
>>>>>> thread A has done his one.
>>>>>> That's should be the reason you don't get the optimistic lock Exception
>>>>>> the second time (I don't see it).
>>>>>> You should print the value of the ackOptLock parameter to have more
>>>>>> informations.
>>>>>> I hope this help
>>>>>> 
>>>>>> -----Mensaje original-----
>>>>>> De: Wesley Lemke [mailto:buck.lemke@gmail.com]
>>>>>> Enviado el: jueves, 02 de diciembre de 2004 22:51
>>>>>> Para: OJB Users List
>>>>>> Asunto: Optimistic Locking Problem.
>>>>>> 
>>>>>> 
>>>>>> 
>>>>>> We are adding optimistic locking to our application.  To test it out I
>>>>>> have made a simple test case.  The application spawns two threads.
>>>>>> 
>>>>>> Thread A (ClientAdderDelay):  Reads an object from the database.  It
>>>>>> then checks the name of the ojbect.  If the name was 00000 it changes
>>>>>> it to 00001 and if the name was 00001 it changes it to 00000.  The
>>>>>> thread sleeps for 5 seconds and then stores the object.
>>>>>> 
>>>>>> Thread B (ClientAdder):  Does the same thing, but doesn't sleep 5
>>>>>> seconds between the read/store.
>>>>>> 
>>>>>> The main servlet starts thread A, then sleeps for 1 second and starts
>>>>>> thread B.
>>>>>> 
>>>>>> The very first time I run the application everything works as it
>>>>>> should, Thread A and B both read 00000 from the database.  Thread B
>>>>>> then updates the row to be 00001.  Thread A gets and OptimisticLock
>>>>>> exception when it tries to store the object.
>>>>>> 
>>>>>> However all subsequent times that I run the application Thread A will
>>>>>> get the correct value from the database but thread B will get the
>>>>>> opposite value.  I am attaching the output, which will hopefully make
>>>>>> this more understandable.  The one difference I see is that the
>>>>>> Datasource gets a new connection the first time the Servlet is run,
>>>>>> but not the second...I wouldn't think that this would matter?
>>>>>> 
>>>>>> OUTPUT:
>>>>>> 
>>>>>> [12/2/04 15:47:56:436 CST] 797e3663 SystemErr     R
>>>>>> *************************** START ************************
>>>>>> [12/2/04 15:47:56:466 CST] 797e3663 SystemErr     R SERVLET:  Starting
>>>>>> ClientAdderDelay
>>>>>> [12/2/04 15:47:56:466 CST] 797e3663 SystemErr     R SERVLET:  Sleeping
>>>>>> 1000 millis
>>>>>> [12/2/04 15:47:56:896 CST] 6de77661 Config        E
>>>>>> com.opensymphony.oscache.base.Config  Error reading
>>>>>> /oscache.properties in CacheAdministrator.loadProps()
>>>>>> java.lang.NullPointerException
>>>>>> [12/2/04 15:47:56:906 CST] 6de77661 Config        E
>>>>>> com.opensymphony.oscache.base.Config  Ensure the /oscache.properties
>>>>>> file is readable and in your classpath.
>>>>>> [12/2/04 15:47:56:916 CST] 6de77661 GeneralCacheA I
>>>>>> com.opensymphony.oscache.general.GeneralCacheAdministrator
>>>>>> Constructed GeneralCacheAdministrator()
>>>>>> [12/2/04 15:47:56:916 CST] 6de77661 GeneralCacheA I
>>>>>> com.opensymphony.oscache.general.GeneralCacheAdministrator  Creating
>>>>>> new cache
>>>>>> [12/2/04 15:47:58:469 CST] 6de77661 DSConfigurati W DSRA0174W:
>>>>>> Warning: GenericDataStoreHelper is being used.
>>>>>> [12/2/04 15:47:58:629 CST] 6de77661 ConnectionFac I J2CA0122I:
>>>>>> Resource reference jdbc/ao79 could not be located, so default values
>>>>>> of the following are used: [Resource-ref settings]
>>>>>> 
>>>>>>       res-auth:                 1 (APPLICATION)
>>>>>>       res-isolation-level:      0 (TRANSACTION_NONE)
>>>>>>       res-sharing-scope:        true (SHAREABLE)
>>>>>>       res-resolution-control:   999 (undefined)
>>>>>> [Other attributes]
>>>>>> 
>>>>>> isCMP1_x:                 false (not CMP1.x)
>>>>>> isJMS:                 false (not JMS)
>>>>>> 
>>>>>> [12/2/04 15:47:58:669 CST] 6de77661 ConnectionFac I J2CA0107I:
>>>>>> Component-managed authentication alias not specified for connection
>>>>>> factory or datasource MySql Datasource on ao79.
>>>>>> [12/2/04 15:47:58:699 CST] 4b22f67d ConnectionFac I J2CA0122I:
>>>>>> Resource reference jdbc/ao79 could not be located, so default values
>>>>>> of the following are used: [Resource-ref settings]
>>>>>> 
>>>>>>       res-auth:                 1 (APPLICATION)
>>>>>>       res-isolation-level:      0 (TRANSACTION_NONE)
>>>>>>       res-sharing-scope:        true (SHAREABLE)
>>>>>>       res-resolution-control:   999 (undefined)
>>>>>> [Other attributes]
>>>>>> 
>>>>>> isCMP1_x:                 false (not CMP1.x)
>>>>>> isJMS:                 false (not JMS)
>>>>>> 
>>>>>> [12/2/04 15:47:58:699 CST] 6de77661 ConnectionMan W J2CA0075W: An
>>>>>> active transaction should be present while processing method
>>>>>> allocateMCWrapper.
>>>>>> [12/2/04 15:47:58:709 CST] 4b22f67d ConnectionMan W J2CA0075W: An
>>>>>> active transaction should be present while processing method
>>>>>> allocateMCWrapper.
>>>>>> [12/2/04 15:47:57:477 CST] 797e3663 SystemErr     R SERVLET:  Starting
>>>>>> ClientAdder
>>>>>> [12/2/04 15:47:57:477 CST] 797e3663 SystemErr     R SERVLET:  Joining
>>>>>> to ClientAdder
>>>>>> [12/2/04 15:47:59:170 CST] 4b22f67d WSRdbDataSour u Database version is
>>>>>>                                3.23.41
>>>>>> [12/2/04 15:47:59:170 CST] 4b22f67d WSRdbDataSour u JDBC Driver version
>>>>>> is
>>>>>>                                mysql-connector-java-3.0.15-ga (
>>>>>> $Date: 2004/08/09 22:15:11 $, $Revision: 1.27.2.43 $ )
>>>>>> [12/2/04 15:47:59:250 CST] 4b22f67d ConnectionMan W J2CA0075W: An
>>>>>> active transaction should be present while processing method
>>>>>> initializeForUOW.
>>>>>> [12/2/04 15:47:59:250 CST] 6de77661 ConnectionMan W J2CA0075W: An
>>>>>> active transaction should be present while processing method
>>>>>> initializeForUOW.
>>>>>> [12/2/04 15:47:59:530 CST] 4b22f67d SystemErr     R CLIENTADDER:
>>>>>> Before Update: 00000<br>
>>>>>> [12/2/04 15:47:59:560 CST] 4b22f67d SystemErr     R CLIENTADDER:
>>>>>> Changing name to 00001
>>>>>> [12/2/04 15:47:59:560 CST] 6de77661 SystemErr     R CLIENTADDERDELAY:
>>>>>> Before Update: 00000<br>
>>>>>> [12/2/04 15:47:59:560 CST] 6de77661 SystemErr     R CLIENTADDERDELAY:
>>>>>> Sleeping for 5000 millis
>>>>>> [12/2/04 15:47:59:570 CST] 4b22f67d ConnectionMan W J2CA0075W: An
>>>>>> active transaction should be present while processing method
>>>>>> allocateMCWrapper.
>>>>>> [12/2/04 15:47:59:570 CST] 4b22f67d ConnectionMan W J2CA0075W: An
>>>>>> active transaction should be present while processing method
>>>>>> initializeForUOW.
>>>>>> [12/2/04 15:47:59:590 CST] 4b22f67d SystemErr     R CLIENTADDER:
>>>>>> After Update: 00001<br>
>>>>>> [12/2/04 15:47:59:590 CST] 797e3663 SystemErr     R SERVLET:  Joingin
>>>>>> to ClientAdderDelay
>>>>>> [12/2/04 15:48:04:557 CST] 6de77661 SystemErr     R CLIENTADDERDELAY:
>>>>>> Changing name to 00001
>>>>>> [12/2/04 15:48:04:617 CST] 6de77661 SystemErr     R
>>>>>> CLIENTADDERDELAY:org.apache.ojb.broker.OptimisticLockException: Object
>>>>>> has been modified by someone else
>>>>>> [12/2/04 15:48:04:617 CST] 6de77661 ConnectionMan W J2CA0075W: An
>>>>>> active transaction should be present while processing method
>>>>>> allocateMCWrapper.
>>>>>> [12/2/04 15:48:04:627 CST] 6de77661 ConnectionMan W J2CA0075W: An
>>>>>> active transaction should be present while processing method
>>>>>> initializeForUOW.
>>>>>> [12/2/04 15:48:04:637 CST] 6de77661 SystemErr     R CLIENTADDERDELAY:
>>>>>> After Update: 00001<br>
>>>>>> [12/2/04 15:48:04:637 CST] 797e3663 SystemErr     R
>>>>>> *************************** END ************************
>>>>>> [12/2/04 15:48:47:729 CST] 797e3663 SystemErr     R
>>>>>> *************************** START ************************
>>>>>> [12/2/04 15:48:47:729 CST] 797e3663 SystemErr     R SERVLET:  Starting
>>>>>> ClientAdderDelay
>>>>>> [12/2/04 15:48:47:729 CST] 797e3663 SystemErr     R SERVLET:  Sleeping
>>>>>> 1000 millis
>>>>>> [12/2/04 15:48:47:779 CST] 1ec7f672 ConnectionMan W J2CA0075W: An
>>>>>> active transaction should be present while processing method
>>>>>> allocateMCWrapper.
>>>>>> [12/2/04 15:48:47:840 CST] 1ec7f672 ConnectionMan W J2CA0075W: An
>>>>>> active transaction should be present while processing method
>>>>>> initializeForUOW.
>>>>>> [12/2/04 15:48:47:850 CST] 1ec7f672 SystemErr     R CLIENTADDERDELAY:
>>>>>> Before Update: 00001<br>
>>>>>> [12/2/04 15:48:47:850 CST] 1ec7f672 SystemErr     R CLIENTADDERDELAY:
>>>>>> Sleeping for 5000 millis
>>>>>> [12/2/04 15:48:48:931 CST] 797e3663 SystemErr     R SERVLET:  Starting
>>>>>> ClientAdder
>>>>>> [12/2/04 15:48:48:931 CST] 797e3663 SystemErr     R SERVLET:  Joining
>>>>>> to ClientAdder
>>>>>> [12/2/04 15:48:48:931 CST] 1ec0f672 ConnectionMan W J2CA0075W: An
>>>>>> active transaction should be present while processing method
>>>>>> allocateMCWrapper.
>>>>>> [12/2/04 15:48:49:031 CST] 1ec0f672 ConnectionMan W J2CA0075W: An
>>>>>> active transaction should be present while processing method
>>>>>> initializeForUOW.
>>>>>> [12/2/04 15:48:49:041 CST] 1ec0f672 SystemErr     R CLIENTADDER:
>>>>>> Before Update: 00000<br>
>>>>>> [12/2/04 15:48:49:041 CST] 1ec0f672 SystemErr     R CLIENTADDER:
>>>>>> Changing name to 00001
>>>>>> [12/2/04 15:48:49:051 CST] 1ec0f672 ConnectionMan W J2CA0075W: An
>>>>>> active transaction should be present while processing method
>>>>>> allocateMCWrapper.
>>>>>> [12/2/04 15:48:49:061 CST] 1ec0f672 ConnectionMan W J2CA0075W: An
>>>>>> active transaction should be present while processing method
>>>>>> initializeForUOW.
>>>>>> [12/2/04 15:48:49:081 CST] 1ec0f672 SystemErr     R CLIENTADDER:
>>>>>> After Update: 00001<br>
>>>>>> [12/2/04 15:48:49:081 CST] 797e3663 SystemErr     R SERVLET:  Joingin
>>>>>> to ClientAdderDelay
>>>>>> [12/2/04 15:48:52:857 CST] 1ec7f672 SystemErr     R CLIENTADDERDELAY:
>>>>>> Changing name to 00001
>>>>>> [12/2/04 15:48:52:857 CST] 1ec7f672 ConnectionMan W J2CA0075W: An
>>>>>> active transaction should be present while processing method
>>>>>> allocateMCWrapper.
>>>>>> [12/2/04 15:48:52:867 CST] 1ec7f672 ConnectionMan W J2CA0075W: An
>>>>>> active transaction should be present while processing method
>>>>>> initializeForUOW.
>>>>>> [12/2/04 15:48:52:877 CST] 1ec7f672 SystemErr     R CLIENTADDERDELAY:
>>>>>> After Update: 00001<br>
>>>>>> [12/2/04 15:48:52:877 CST] 797e3663 SystemErr     R
>>>>>> *************************** END ************************
>>>>>> 
>>>>>> Let me know if any more information would be helpful...
>>>>>> 
>>>>>> ---------------------------------------------------------------------
>>>>>> To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
>>>>>> For additional commands, e-mail: ojb-user-help@db.apache.org
>>>>>> 
>>>>>> 
>>>>> 
>>>>> 
>>>>> ---------------------------------------------------------------------
>>>>> To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
>>>>> For additional commands, e-mail: ojb-user-help@db.apache.org
>>>>> 
>>>>> 
>>>>> 
>>>> 
>>>> ---------------------------------------------------------------------
>>>> 
>>>> 
>>>> To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
>>>> For additional commands, e-mail: ojb-user-help@db.apache.org
>>>> 
>>>> 
>>> 
>>> 
>>> ---------------------------------------------------------------------
>> 
>> 
>>> To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
>>> For additional commands, e-mail: ojb-user-help@db.apache.org
>>> 
>>> 
>>> 
>> 
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
>> For additional commands, e-mail: ojb-user-help@db.apache.org
>> 
>> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
> For additional commands, e-mail: ojb-user-help@db.apache.org


R

-- 
Robert S. Sfeir
Software Developer
Codepuccino
"Make everything as simple as possible, but not simpler." -- Einstein

http://www.codepuccino.com
blog: http://blogs.codepuccino.com/dude



---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-user-help@db.apache.org


Re: Optimistic Locking Problem.

Posted by Wesley Lemke <bu...@gmail.com>.
Right now I am using the PB.beginTransactoin, and PB.commit...


On Sat, 04 Dec 2004 18:53:43 +0100, Armin Waibel <ar...@apache.org> wrote:
> Hi Wesley,
> 
> Wesley Lemke wrote:
> 
> > I am using the integer as the lock field.  On monday I can give it a
> > shot with a timestamp.
> 
> Integer is fine. There is a bug when using Timestamp values in OJB1.0.1,
> so Integer is a better choice.
> 
> > I just can't figure out why it works the first
> > time I run it, but then the exception is not thrown after that.  Could
> > it have something to do with the data source getting a new connection
> > the first time?
> >
> 
> hmm, if the used connections don't get committed side-effects could
> happen. Do you use PB-tx demarcation (PB.beginT...) (or JTA-tx when in
> managed environment)?
> 
> I checked in a multithreaded optimistic locking test in CVS branch
> OJB_1_0_RELEASE
> 
> http://cvs.apache.org/viewcvs.cgi/db-ojb/src/test/org/apache/ojb/broker/OptimisticLockingMultithreadedTest.java?rev=1.1.2.1&only_with_tag=OJB_1_0_RELEASE&view=markup
> 
> This test (multiple threads try to update the same object) seems to work
> and case OLE when version conflict occur.
> 
> regards,
> Armin
> 
> 
> 
> 
> >
> > On Fri, 03 Dec 2004 23:01:48 +0100, Armin Waibel <ar...@apache.org> wrote:
> >
> >>Hi Wesley,
> >>
> >>I did a multithreaded test too - all seems ok.
> >>Do you use a Timestamp as lock field?
> >>Do you re-read the used object when writing fails (to get fresh object
> >>with valid lock version)?
> >>
> >>regards,
> >>Armin
> >>
> >>
> >>
> >>Wesley Lemke wrote:
> >>
> >>
> >>>I am now printing the ackOptLock value, but still am only getting the
> >>>OptimisticLock exception the first time I run the code after I restart
> >>>the servlet containter.  Here is the log files of the first two runs.
> >>>
> >>>*************************** START ************************
> >>>SERVLET:  Starting ClientAdderDelay
> >>>SERVLET:  Starting ClientAdder
> >>>SERVLET:  Joining to ClientAdder
> >>>CLIENTADDERDELAY:  Before Update: 00001:120
> >>>CLIENTADDERDELAY:  Sleeping for 5000 millis
> >>>CLIENTADDER:  Before Update: 00001:120
> >>>CLIENTADDER: Changing name to 00000: 120
> >>>CLIENTADDER:  After Update: 00000:121
> >>>SERVLET:  Joingin to ClientAdderDelay
> >>>CLIENTADDERDELAY: Changing name to 00000:120
> >>>CLIENTADDERDELAY: (121)
> >>>org.apache.ojb.broker.OptimisticLockException: Object has been
> >>>modified by someone else
> >>>CLIENTADDERDELAY:  After Update: 00000:121
> >>>*************************** END ************************
> >>>
> >>>*************************** START ************************
> >>>SERVLET:  Starting ClientAdderDelay
> >>>SERVLET:  Starting ClientAdder
> >>>SERVLET:  Joining to ClientAdder
> >>>CLIENTADDERDELAY:  Before Update: 00000:121
> >>>CLIENTADDERDELAY:  Sleeping for 5000 millis
> >>>CLIENTADDER:  Before Update: 00000:121
> >>>CLIENTADDER: Changing name to 00001: 121
> >>>CLIENTADDER:  After Update: 00001:122
> >>>SERVLET:  Joingin to ClientAdderDelay
> >>>CLIENTADDERDELAY: Changing name to 00001:122
> >>>CLIENTADDERDELAY:  After Update: 00001:123
> >>>*************************** END ************************
> >>>
> >>>Everything looks the same, to me except the first time the exception
> >>>is thrown, and the database is only updated once, the second time the
> >>>exception isn't thrown and the database is updated twice.
> >>>
> >>>Does anyone else have any suggestions on what I should try next?
> >>>
> >>>On Fri, 3 Dec 2004 10:25:04 +0100, Alessandro Colantoni
> >>><ac...@brujulatelecom.com> wrote:
> >>>
> >>>
> >>>>Hi Wesley.
> >>>>I don't think the problem is the new connection.
> >>>>It looks like thread B do his job (the second time, of course) after
> >>>>thread A has done his one.
> >>>>That's should be the reason you don't get the optimistic lock Exception
> >>>>the second time (I don't see it).
> >>>>You should print the value of the ackOptLock parameter to have more
> >>>>informations.
> >>>>I hope this help
> >>>>
> >>>>-----Mensaje original-----
> >>>>De: Wesley Lemke [mailto:buck.lemke@gmail.com]
> >>>>Enviado el: jueves, 02 de diciembre de 2004 22:51
> >>>>Para: OJB Users List
> >>>>Asunto: Optimistic Locking Problem.
> >>>>
> >>>>
> >>>>
> >>>>We are adding optimistic locking to our application.  To test it out I
> >>>>have made a simple test case.  The application spawns two threads.
> >>>>
> >>>>Thread A (ClientAdderDelay):  Reads an object from the database.  It
> >>>>then checks the name of the ojbect.  If the name was 00000 it changes
> >>>>it to 00001 and if the name was 00001 it changes it to 00000.  The
> >>>>thread sleeps for 5 seconds and then stores the object.
> >>>>
> >>>>Thread B (ClientAdder):  Does the same thing, but doesn't sleep 5
> >>>>seconds between the read/store.
> >>>>
> >>>>The main servlet starts thread A, then sleeps for 1 second and starts
> >>>>thread B.
> >>>>
> >>>>The very first time I run the application everything works as it
> >>>>should, Thread A and B both read 00000 from the database.  Thread B
> >>>>then updates the row to be 00001.  Thread A gets and OptimisticLock
> >>>>exception when it tries to store the object.
> >>>>
> >>>>However all subsequent times that I run the application Thread A will
> >>>>get the correct value from the database but thread B will get the
> >>>>opposite value.  I am attaching the output, which will hopefully make
> >>>>this more understandable.  The one difference I see is that the
> >>>>Datasource gets a new connection the first time the Servlet is run,
> >>>>but not the second...I wouldn't think that this would matter?
> >>>>
> >>>>OUTPUT:
> >>>>
> >>>>[12/2/04 15:47:56:436 CST] 797e3663 SystemErr     R
> >>>>*************************** START ************************
> >>>>[12/2/04 15:47:56:466 CST] 797e3663 SystemErr     R SERVLET:  Starting
> >>>>ClientAdderDelay
> >>>>[12/2/04 15:47:56:466 CST] 797e3663 SystemErr     R SERVLET:  Sleeping
> >>>>1000 millis
> >>>>[12/2/04 15:47:56:896 CST] 6de77661 Config        E
> >>>>com.opensymphony.oscache.base.Config  Error reading
> >>>>/oscache.properties in CacheAdministrator.loadProps()
> >>>>java.lang.NullPointerException
> >>>>[12/2/04 15:47:56:906 CST] 6de77661 Config        E
> >>>>com.opensymphony.oscache.base.Config  Ensure the /oscache.properties
> >>>>file is readable and in your classpath.
> >>>>[12/2/04 15:47:56:916 CST] 6de77661 GeneralCacheA I
> >>>>com.opensymphony.oscache.general.GeneralCacheAdministrator
> >>>>Constructed GeneralCacheAdministrator()
> >>>>[12/2/04 15:47:56:916 CST] 6de77661 GeneralCacheA I
> >>>>com.opensymphony.oscache.general.GeneralCacheAdministrator  Creating
> >>>>new cache
> >>>>[12/2/04 15:47:58:469 CST] 6de77661 DSConfigurati W DSRA0174W:
> >>>>Warning: GenericDataStoreHelper is being used.
> >>>>[12/2/04 15:47:58:629 CST] 6de77661 ConnectionFac I J2CA0122I:
> >>>>Resource reference jdbc/ao79 could not be located, so default values
> >>>>of the following are used: [Resource-ref settings]
> >>>>
> >>>>       res-auth:                 1 (APPLICATION)
> >>>>       res-isolation-level:      0 (TRANSACTION_NONE)
> >>>>       res-sharing-scope:        true (SHAREABLE)
> >>>>       res-resolution-control:   999 (undefined)
> >>>>[Other attributes]
> >>>>
> >>>>isCMP1_x:                 false (not CMP1.x)
> >>>>isJMS:                 false (not JMS)
> >>>>
> >>>>[12/2/04 15:47:58:669 CST] 6de77661 ConnectionFac I J2CA0107I:
> >>>>Component-managed authentication alias not specified for connection
> >>>>factory or datasource MySql Datasource on ao79.
> >>>>[12/2/04 15:47:58:699 CST] 4b22f67d ConnectionFac I J2CA0122I:
> >>>>Resource reference jdbc/ao79 could not be located, so default values
> >>>>of the following are used: [Resource-ref settings]
> >>>>
> >>>>       res-auth:                 1 (APPLICATION)
> >>>>       res-isolation-level:      0 (TRANSACTION_NONE)
> >>>>       res-sharing-scope:        true (SHAREABLE)
> >>>>       res-resolution-control:   999 (undefined)
> >>>>[Other attributes]
> >>>>
> >>>>isCMP1_x:                 false (not CMP1.x)
> >>>>isJMS:                 false (not JMS)
> >>>>
> >>>>[12/2/04 15:47:58:699 CST] 6de77661 ConnectionMan W J2CA0075W: An
> >>>>active transaction should be present while processing method
> >>>>allocateMCWrapper.
> >>>>[12/2/04 15:47:58:709 CST] 4b22f67d ConnectionMan W J2CA0075W: An
> >>>>active transaction should be present while processing method
> >>>>allocateMCWrapper.
> >>>>[12/2/04 15:47:57:477 CST] 797e3663 SystemErr     R SERVLET:  Starting
> >>>>ClientAdder
> >>>>[12/2/04 15:47:57:477 CST] 797e3663 SystemErr     R SERVLET:  Joining
> >>>>to ClientAdder
> >>>>[12/2/04 15:47:59:170 CST] 4b22f67d WSRdbDataSour u Database version is
> >>>>                                3.23.41
> >>>>[12/2/04 15:47:59:170 CST] 4b22f67d WSRdbDataSour u JDBC Driver version
> >>>>is
> >>>>                                mysql-connector-java-3.0.15-ga (
> >>>>$Date: 2004/08/09 22:15:11 $, $Revision: 1.27.2.43 $ )
> >>>>[12/2/04 15:47:59:250 CST] 4b22f67d ConnectionMan W J2CA0075W: An
> >>>>active transaction should be present while processing method
> >>>>initializeForUOW.
> >>>>[12/2/04 15:47:59:250 CST] 6de77661 ConnectionMan W J2CA0075W: An
> >>>>active transaction should be present while processing method
> >>>>initializeForUOW.
> >>>>[12/2/04 15:47:59:530 CST] 4b22f67d SystemErr     R CLIENTADDER:
> >>>>Before Update: 00000<br>
> >>>>[12/2/04 15:47:59:560 CST] 4b22f67d SystemErr     R CLIENTADDER:
> >>>>Changing name to 00001
> >>>>[12/2/04 15:47:59:560 CST] 6de77661 SystemErr     R CLIENTADDERDELAY:
> >>>>Before Update: 00000<br>
> >>>>[12/2/04 15:47:59:560 CST] 6de77661 SystemErr     R CLIENTADDERDELAY:
> >>>>Sleeping for 5000 millis
> >>>>[12/2/04 15:47:59:570 CST] 4b22f67d ConnectionMan W J2CA0075W: An
> >>>>active transaction should be present while processing method
> >>>>allocateMCWrapper.
> >>>>[12/2/04 15:47:59:570 CST] 4b22f67d ConnectionMan W J2CA0075W: An
> >>>>active transaction should be present while processing method
> >>>>initializeForUOW.
> >>>>[12/2/04 15:47:59:590 CST] 4b22f67d SystemErr     R CLIENTADDER:
> >>>>After Update: 00001<br>
> >>>>[12/2/04 15:47:59:590 CST] 797e3663 SystemErr     R SERVLET:  Joingin
> >>>>to ClientAdderDelay
> >>>>[12/2/04 15:48:04:557 CST] 6de77661 SystemErr     R CLIENTADDERDELAY:
> >>>>Changing name to 00001
> >>>>[12/2/04 15:48:04:617 CST] 6de77661 SystemErr     R
> >>>>CLIENTADDERDELAY:org.apache.ojb.broker.OptimisticLockException: Object
> >>>>has been modified by someone else
> >>>>[12/2/04 15:48:04:617 CST] 6de77661 ConnectionMan W J2CA0075W: An
> >>>>active transaction should be present while processing method
> >>>>allocateMCWrapper.
> >>>>[12/2/04 15:48:04:627 CST] 6de77661 ConnectionMan W J2CA0075W: An
> >>>>active transaction should be present while processing method
> >>>>initializeForUOW.
> >>>>[12/2/04 15:48:04:637 CST] 6de77661 SystemErr     R CLIENTADDERDELAY:
> >>>>After Update: 00001<br>
> >>>>[12/2/04 15:48:04:637 CST] 797e3663 SystemErr     R
> >>>>*************************** END ************************
> >>>>[12/2/04 15:48:47:729 CST] 797e3663 SystemErr     R
> >>>>*************************** START ************************
> >>>>[12/2/04 15:48:47:729 CST] 797e3663 SystemErr     R SERVLET:  Starting
> >>>>ClientAdderDelay
> >>>>[12/2/04 15:48:47:729 CST] 797e3663 SystemErr     R SERVLET:  Sleeping
> >>>>1000 millis
> >>>>[12/2/04 15:48:47:779 CST] 1ec7f672 ConnectionMan W J2CA0075W: An
> >>>>active transaction should be present while processing method
> >>>>allocateMCWrapper.
> >>>>[12/2/04 15:48:47:840 CST] 1ec7f672 ConnectionMan W J2CA0075W: An
> >>>>active transaction should be present while processing method
> >>>>initializeForUOW.
> >>>>[12/2/04 15:48:47:850 CST] 1ec7f672 SystemErr     R CLIENTADDERDELAY:
> >>>>Before Update: 00001<br>
> >>>>[12/2/04 15:48:47:850 CST] 1ec7f672 SystemErr     R CLIENTADDERDELAY:
> >>>>Sleeping for 5000 millis
> >>>>[12/2/04 15:48:48:931 CST] 797e3663 SystemErr     R SERVLET:  Starting
> >>>>ClientAdder
> >>>>[12/2/04 15:48:48:931 CST] 797e3663 SystemErr     R SERVLET:  Joining
> >>>>to ClientAdder
> >>>>[12/2/04 15:48:48:931 CST] 1ec0f672 ConnectionMan W J2CA0075W: An
> >>>>active transaction should be present while processing method
> >>>>allocateMCWrapper.
> >>>>[12/2/04 15:48:49:031 CST] 1ec0f672 ConnectionMan W J2CA0075W: An
> >>>>active transaction should be present while processing method
> >>>>initializeForUOW.
> >>>>[12/2/04 15:48:49:041 CST] 1ec0f672 SystemErr     R CLIENTADDER:
> >>>>Before Update: 00000<br>
> >>>>[12/2/04 15:48:49:041 CST] 1ec0f672 SystemErr     R CLIENTADDER:
> >>>>Changing name to 00001
> >>>>[12/2/04 15:48:49:051 CST] 1ec0f672 ConnectionMan W J2CA0075W: An
> >>>>active transaction should be present while processing method
> >>>>allocateMCWrapper.
> >>>>[12/2/04 15:48:49:061 CST] 1ec0f672 ConnectionMan W J2CA0075W: An
> >>>>active transaction should be present while processing method
> >>>>initializeForUOW.
> >>>>[12/2/04 15:48:49:081 CST] 1ec0f672 SystemErr     R CLIENTADDER:
> >>>>After Update: 00001<br>
> >>>>[12/2/04 15:48:49:081 CST] 797e3663 SystemErr     R SERVLET:  Joingin
> >>>>to ClientAdderDelay
> >>>>[12/2/04 15:48:52:857 CST] 1ec7f672 SystemErr     R CLIENTADDERDELAY:
> >>>>Changing name to 00001
> >>>>[12/2/04 15:48:52:857 CST] 1ec7f672 ConnectionMan W J2CA0075W: An
> >>>>active transaction should be present while processing method
> >>>>allocateMCWrapper.
> >>>>[12/2/04 15:48:52:867 CST] 1ec7f672 ConnectionMan W J2CA0075W: An
> >>>>active transaction should be present while processing method
> >>>>initializeForUOW.
> >>>>[12/2/04 15:48:52:877 CST] 1ec7f672 SystemErr     R CLIENTADDERDELAY:
> >>>>After Update: 00001<br>
> >>>>[12/2/04 15:48:52:877 CST] 797e3663 SystemErr     R
> >>>>*************************** END ************************
> >>>>
> >>>>Let me know if any more information would be helpful...
> >>>>
> >>>>---------------------------------------------------------------------
> >>>>To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
> >>>>For additional commands, e-mail: ojb-user-help@db.apache.org
> >>>>
> >>>>
> >>>
> >>>
> >>>---------------------------------------------------------------------
> >>>To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
> >>>For additional commands, e-mail: ojb-user-help@db.apache.org
> >>>
> >>>
> >>>
> >>
> >>---------------------------------------------------------------------
> >>
> >>
> >>To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
> >>For additional commands, e-mail: ojb-user-help@db.apache.org
> >>
> >>
> >
> > 
> > ---------------------------------------------------------------------
> 
> 
> > To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
> > For additional commands, e-mail: ojb-user-help@db.apache.org
> >
> >
> >
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
> For additional commands, e-mail: ojb-user-help@db.apache.org
> 
>

---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-user-help@db.apache.org


Re: Optimistic Locking Problem.

Posted by Armin Waibel <ar...@apache.org>.
Hi Wesley,

Wesley Lemke wrote:

> I am using the integer as the lock field.  On monday I can give it a
> shot with a timestamp.

Integer is fine. There is a bug when using Timestamp values in OJB1.0.1, 
so Integer is a better choice.

> I just can't figure out why it works the first
> time I run it, but then the exception is not thrown after that.  Could
> it have something to do with the data source getting a new connection
> the first time?
> 

hmm, if the used connections don't get committed side-effects could 
happen. Do you use PB-tx demarcation (PB.beginT...) (or JTA-tx when in 
managed environment)?

I checked in a multithreaded optimistic locking test in CVS branch 
OJB_1_0_RELEASE

http://cvs.apache.org/viewcvs.cgi/db-ojb/src/test/org/apache/ojb/broker/OptimisticLockingMultithreadedTest.java?rev=1.1.2.1&only_with_tag=OJB_1_0_RELEASE&view=markup

This test (multiple threads try to update the same object) seems to work 
and case OLE when version conflict occur.

regards,
Armin


> 
> On Fri, 03 Dec 2004 23:01:48 +0100, Armin Waibel <ar...@apache.org> wrote:
> 
>>Hi Wesley,
>>
>>I did a multithreaded test too - all seems ok.
>>Do you use a Timestamp as lock field?
>>Do you re-read the used object when writing fails (to get fresh object
>>with valid lock version)?
>>
>>regards,
>>Armin
>>
>>
>>
>>Wesley Lemke wrote:
>>
>>
>>>I am now printing the ackOptLock value, but still am only getting the
>>>OptimisticLock exception the first time I run the code after I restart
>>>the servlet containter.  Here is the log files of the first two runs.
>>>
>>>*************************** START ************************
>>>SERVLET:  Starting ClientAdderDelay
>>>SERVLET:  Starting ClientAdder
>>>SERVLET:  Joining to ClientAdder
>>>CLIENTADDERDELAY:  Before Update: 00001:120
>>>CLIENTADDERDELAY:  Sleeping for 5000 millis
>>>CLIENTADDER:  Before Update: 00001:120
>>>CLIENTADDER: Changing name to 00000: 120
>>>CLIENTADDER:  After Update: 00000:121
>>>SERVLET:  Joingin to ClientAdderDelay
>>>CLIENTADDERDELAY: Changing name to 00000:120
>>>CLIENTADDERDELAY: (121)
>>>org.apache.ojb.broker.OptimisticLockException: Object has been
>>>modified by someone else
>>>CLIENTADDERDELAY:  After Update: 00000:121
>>>*************************** END ************************
>>>
>>>*************************** START ************************
>>>SERVLET:  Starting ClientAdderDelay
>>>SERVLET:  Starting ClientAdder
>>>SERVLET:  Joining to ClientAdder
>>>CLIENTADDERDELAY:  Before Update: 00000:121
>>>CLIENTADDERDELAY:  Sleeping for 5000 millis
>>>CLIENTADDER:  Before Update: 00000:121
>>>CLIENTADDER: Changing name to 00001: 121
>>>CLIENTADDER:  After Update: 00001:122
>>>SERVLET:  Joingin to ClientAdderDelay
>>>CLIENTADDERDELAY: Changing name to 00001:122
>>>CLIENTADDERDELAY:  After Update: 00001:123
>>>*************************** END ************************
>>>
>>>Everything looks the same, to me except the first time the exception
>>>is thrown, and the database is only updated once, the second time the
>>>exception isn't thrown and the database is updated twice.
>>>
>>>Does anyone else have any suggestions on what I should try next?
>>>
>>>On Fri, 3 Dec 2004 10:25:04 +0100, Alessandro Colantoni
>>><ac...@brujulatelecom.com> wrote:
>>>
>>>
>>>>Hi Wesley.
>>>>I don't think the problem is the new connection.
>>>>It looks like thread B do his job (the second time, of course) after
>>>>thread A has done his one.
>>>>That's should be the reason you don't get the optimistic lock Exception
>>>>the second time (I don't see it).
>>>>You should print the value of the ackOptLock parameter to have more
>>>>informations.
>>>>I hope this help
>>>>
>>>>-----Mensaje original-----
>>>>De: Wesley Lemke [mailto:buck.lemke@gmail.com]
>>>>Enviado el: jueves, 02 de diciembre de 2004 22:51
>>>>Para: OJB Users List
>>>>Asunto: Optimistic Locking Problem.
>>>>
>>>>
>>>>
>>>>We are adding optimistic locking to our application.  To test it out I
>>>>have made a simple test case.  The application spawns two threads.
>>>>
>>>>Thread A (ClientAdderDelay):  Reads an object from the database.  It
>>>>then checks the name of the ojbect.  If the name was 00000 it changes
>>>>it to 00001 and if the name was 00001 it changes it to 00000.  The
>>>>thread sleeps for 5 seconds and then stores the object.
>>>>
>>>>Thread B (ClientAdder):  Does the same thing, but doesn't sleep 5
>>>>seconds between the read/store.
>>>>
>>>>The main servlet starts thread A, then sleeps for 1 second and starts
>>>>thread B.
>>>>
>>>>The very first time I run the application everything works as it
>>>>should, Thread A and B both read 00000 from the database.  Thread B
>>>>then updates the row to be 00001.  Thread A gets and OptimisticLock
>>>>exception when it tries to store the object.
>>>>
>>>>However all subsequent times that I run the application Thread A will
>>>>get the correct value from the database but thread B will get the
>>>>opposite value.  I am attaching the output, which will hopefully make
>>>>this more understandable.  The one difference I see is that the
>>>>Datasource gets a new connection the first time the Servlet is run,
>>>>but not the second...I wouldn't think that this would matter?
>>>>
>>>>OUTPUT:
>>>>
>>>>[12/2/04 15:47:56:436 CST] 797e3663 SystemErr     R
>>>>*************************** START ************************
>>>>[12/2/04 15:47:56:466 CST] 797e3663 SystemErr     R SERVLET:  Starting
>>>>ClientAdderDelay
>>>>[12/2/04 15:47:56:466 CST] 797e3663 SystemErr     R SERVLET:  Sleeping
>>>>1000 millis
>>>>[12/2/04 15:47:56:896 CST] 6de77661 Config        E
>>>>com.opensymphony.oscache.base.Config  Error reading
>>>>/oscache.properties in CacheAdministrator.loadProps()
>>>>java.lang.NullPointerException
>>>>[12/2/04 15:47:56:906 CST] 6de77661 Config        E
>>>>com.opensymphony.oscache.base.Config  Ensure the /oscache.properties
>>>>file is readable and in your classpath.
>>>>[12/2/04 15:47:56:916 CST] 6de77661 GeneralCacheA I
>>>>com.opensymphony.oscache.general.GeneralCacheAdministrator
>>>>Constructed GeneralCacheAdministrator()
>>>>[12/2/04 15:47:56:916 CST] 6de77661 GeneralCacheA I
>>>>com.opensymphony.oscache.general.GeneralCacheAdministrator  Creating
>>>>new cache
>>>>[12/2/04 15:47:58:469 CST] 6de77661 DSConfigurati W DSRA0174W:
>>>>Warning: GenericDataStoreHelper is being used.
>>>>[12/2/04 15:47:58:629 CST] 6de77661 ConnectionFac I J2CA0122I:
>>>>Resource reference jdbc/ao79 could not be located, so default values
>>>>of the following are used: [Resource-ref settings]
>>>>
>>>>       res-auth:                 1 (APPLICATION)
>>>>       res-isolation-level:      0 (TRANSACTION_NONE)
>>>>       res-sharing-scope:        true (SHAREABLE)
>>>>       res-resolution-control:   999 (undefined)
>>>>[Other attributes]
>>>>
>>>>isCMP1_x:                 false (not CMP1.x)
>>>>isJMS:                 false (not JMS)
>>>>
>>>>[12/2/04 15:47:58:669 CST] 6de77661 ConnectionFac I J2CA0107I:
>>>>Component-managed authentication alias not specified for connection
>>>>factory or datasource MySql Datasource on ao79.
>>>>[12/2/04 15:47:58:699 CST] 4b22f67d ConnectionFac I J2CA0122I:
>>>>Resource reference jdbc/ao79 could not be located, so default values
>>>>of the following are used: [Resource-ref settings]
>>>>
>>>>       res-auth:                 1 (APPLICATION)
>>>>       res-isolation-level:      0 (TRANSACTION_NONE)
>>>>       res-sharing-scope:        true (SHAREABLE)
>>>>       res-resolution-control:   999 (undefined)
>>>>[Other attributes]
>>>>
>>>>isCMP1_x:                 false (not CMP1.x)
>>>>isJMS:                 false (not JMS)
>>>>
>>>>[12/2/04 15:47:58:699 CST] 6de77661 ConnectionMan W J2CA0075W: An
>>>>active transaction should be present while processing method
>>>>allocateMCWrapper.
>>>>[12/2/04 15:47:58:709 CST] 4b22f67d ConnectionMan W J2CA0075W: An
>>>>active transaction should be present while processing method
>>>>allocateMCWrapper.
>>>>[12/2/04 15:47:57:477 CST] 797e3663 SystemErr     R SERVLET:  Starting
>>>>ClientAdder
>>>>[12/2/04 15:47:57:477 CST] 797e3663 SystemErr     R SERVLET:  Joining
>>>>to ClientAdder
>>>>[12/2/04 15:47:59:170 CST] 4b22f67d WSRdbDataSour u Database version is
>>>>                                3.23.41
>>>>[12/2/04 15:47:59:170 CST] 4b22f67d WSRdbDataSour u JDBC Driver version
>>>>is
>>>>                                mysql-connector-java-3.0.15-ga (
>>>>$Date: 2004/08/09 22:15:11 $, $Revision: 1.27.2.43 $ )
>>>>[12/2/04 15:47:59:250 CST] 4b22f67d ConnectionMan W J2CA0075W: An
>>>>active transaction should be present while processing method
>>>>initializeForUOW.
>>>>[12/2/04 15:47:59:250 CST] 6de77661 ConnectionMan W J2CA0075W: An
>>>>active transaction should be present while processing method
>>>>initializeForUOW.
>>>>[12/2/04 15:47:59:530 CST] 4b22f67d SystemErr     R CLIENTADDER:
>>>>Before Update: 00000<br>
>>>>[12/2/04 15:47:59:560 CST] 4b22f67d SystemErr     R CLIENTADDER:
>>>>Changing name to 00001
>>>>[12/2/04 15:47:59:560 CST] 6de77661 SystemErr     R CLIENTADDERDELAY:
>>>>Before Update: 00000<br>
>>>>[12/2/04 15:47:59:560 CST] 6de77661 SystemErr     R CLIENTADDERDELAY:
>>>>Sleeping for 5000 millis
>>>>[12/2/04 15:47:59:570 CST] 4b22f67d ConnectionMan W J2CA0075W: An
>>>>active transaction should be present while processing method
>>>>allocateMCWrapper.
>>>>[12/2/04 15:47:59:570 CST] 4b22f67d ConnectionMan W J2CA0075W: An
>>>>active transaction should be present while processing method
>>>>initializeForUOW.
>>>>[12/2/04 15:47:59:590 CST] 4b22f67d SystemErr     R CLIENTADDER:
>>>>After Update: 00001<br>
>>>>[12/2/04 15:47:59:590 CST] 797e3663 SystemErr     R SERVLET:  Joingin
>>>>to ClientAdderDelay
>>>>[12/2/04 15:48:04:557 CST] 6de77661 SystemErr     R CLIENTADDERDELAY:
>>>>Changing name to 00001
>>>>[12/2/04 15:48:04:617 CST] 6de77661 SystemErr     R
>>>>CLIENTADDERDELAY:org.apache.ojb.broker.OptimisticLockException: Object
>>>>has been modified by someone else
>>>>[12/2/04 15:48:04:617 CST] 6de77661 ConnectionMan W J2CA0075W: An
>>>>active transaction should be present while processing method
>>>>allocateMCWrapper.
>>>>[12/2/04 15:48:04:627 CST] 6de77661 ConnectionMan W J2CA0075W: An
>>>>active transaction should be present while processing method
>>>>initializeForUOW.
>>>>[12/2/04 15:48:04:637 CST] 6de77661 SystemErr     R CLIENTADDERDELAY:
>>>>After Update: 00001<br>
>>>>[12/2/04 15:48:04:637 CST] 797e3663 SystemErr     R
>>>>*************************** END ************************
>>>>[12/2/04 15:48:47:729 CST] 797e3663 SystemErr     R
>>>>*************************** START ************************
>>>>[12/2/04 15:48:47:729 CST] 797e3663 SystemErr     R SERVLET:  Starting
>>>>ClientAdderDelay
>>>>[12/2/04 15:48:47:729 CST] 797e3663 SystemErr     R SERVLET:  Sleeping
>>>>1000 millis
>>>>[12/2/04 15:48:47:779 CST] 1ec7f672 ConnectionMan W J2CA0075W: An
>>>>active transaction should be present while processing method
>>>>allocateMCWrapper.
>>>>[12/2/04 15:48:47:840 CST] 1ec7f672 ConnectionMan W J2CA0075W: An
>>>>active transaction should be present while processing method
>>>>initializeForUOW.
>>>>[12/2/04 15:48:47:850 CST] 1ec7f672 SystemErr     R CLIENTADDERDELAY:
>>>>Before Update: 00001<br>
>>>>[12/2/04 15:48:47:850 CST] 1ec7f672 SystemErr     R CLIENTADDERDELAY:
>>>>Sleeping for 5000 millis
>>>>[12/2/04 15:48:48:931 CST] 797e3663 SystemErr     R SERVLET:  Starting
>>>>ClientAdder
>>>>[12/2/04 15:48:48:931 CST] 797e3663 SystemErr     R SERVLET:  Joining
>>>>to ClientAdder
>>>>[12/2/04 15:48:48:931 CST] 1ec0f672 ConnectionMan W J2CA0075W: An
>>>>active transaction should be present while processing method
>>>>allocateMCWrapper.
>>>>[12/2/04 15:48:49:031 CST] 1ec0f672 ConnectionMan W J2CA0075W: An
>>>>active transaction should be present while processing method
>>>>initializeForUOW.
>>>>[12/2/04 15:48:49:041 CST] 1ec0f672 SystemErr     R CLIENTADDER:
>>>>Before Update: 00000<br>
>>>>[12/2/04 15:48:49:041 CST] 1ec0f672 SystemErr     R CLIENTADDER:
>>>>Changing name to 00001
>>>>[12/2/04 15:48:49:051 CST] 1ec0f672 ConnectionMan W J2CA0075W: An
>>>>active transaction should be present while processing method
>>>>allocateMCWrapper.
>>>>[12/2/04 15:48:49:061 CST] 1ec0f672 ConnectionMan W J2CA0075W: An
>>>>active transaction should be present while processing method
>>>>initializeForUOW.
>>>>[12/2/04 15:48:49:081 CST] 1ec0f672 SystemErr     R CLIENTADDER:
>>>>After Update: 00001<br>
>>>>[12/2/04 15:48:49:081 CST] 797e3663 SystemErr     R SERVLET:  Joingin
>>>>to ClientAdderDelay
>>>>[12/2/04 15:48:52:857 CST] 1ec7f672 SystemErr     R CLIENTADDERDELAY:
>>>>Changing name to 00001
>>>>[12/2/04 15:48:52:857 CST] 1ec7f672 ConnectionMan W J2CA0075W: An
>>>>active transaction should be present while processing method
>>>>allocateMCWrapper.
>>>>[12/2/04 15:48:52:867 CST] 1ec7f672 ConnectionMan W J2CA0075W: An
>>>>active transaction should be present while processing method
>>>>initializeForUOW.
>>>>[12/2/04 15:48:52:877 CST] 1ec7f672 SystemErr     R CLIENTADDERDELAY:
>>>>After Update: 00001<br>
>>>>[12/2/04 15:48:52:877 CST] 797e3663 SystemErr     R
>>>>*************************** END ************************
>>>>
>>>>Let me know if any more information would be helpful...
>>>>
>>>>---------------------------------------------------------------------
>>>>To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
>>>>For additional commands, e-mail: ojb-user-help@db.apache.org
>>>>
>>>>
>>>
>>>
>>>---------------------------------------------------------------------
>>>To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
>>>For additional commands, e-mail: ojb-user-help@db.apache.org
>>>
>>>
>>>
>>
>>---------------------------------------------------------------------
>>
>>
>>To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
>>For additional commands, e-mail: ojb-user-help@db.apache.org
>>
>>
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
> For additional commands, e-mail: ojb-user-help@db.apache.org
> 
> 
> 

---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-user-help@db.apache.org


Re: Optimistic Locking Problem.

Posted by Wesley Lemke <bu...@gmail.com>.
I am using the integer as the lock field.  On monday I can give it a
shot with a timestamp.  I just can't figure out why it works the first
time I run it, but then the exception is not thrown after that.  Could
it have something to do with the data source getting a new connection
the first time?


On Fri, 03 Dec 2004 23:01:48 +0100, Armin Waibel <ar...@apache.org> wrote:
> Hi Wesley,
> 
> I did a multithreaded test too - all seems ok.
> Do you use a Timestamp as lock field?
> Do you re-read the used object when writing fails (to get fresh object
> with valid lock version)?
> 
> regards,
> Armin
> 
> 
> 
> Wesley Lemke wrote:
> 
> > I am now printing the ackOptLock value, but still am only getting the
> > OptimisticLock exception the first time I run the code after I restart
> > the servlet containter.  Here is the log files of the first two runs.
> >
> > *************************** START ************************
> > SERVLET:  Starting ClientAdderDelay
> > SERVLET:  Starting ClientAdder
> > SERVLET:  Joining to ClientAdder
> > CLIENTADDERDELAY:  Before Update: 00001:120
> > CLIENTADDERDELAY:  Sleeping for 5000 millis
> > CLIENTADDER:  Before Update: 00001:120
> > CLIENTADDER: Changing name to 00000: 120
> > CLIENTADDER:  After Update: 00000:121
> > SERVLET:  Joingin to ClientAdderDelay
> > CLIENTADDERDELAY: Changing name to 00000:120
> > CLIENTADDERDELAY: (121)
> > org.apache.ojb.broker.OptimisticLockException: Object has been
> > modified by someone else
> > CLIENTADDERDELAY:  After Update: 00000:121
> > *************************** END ************************
> >
> > *************************** START ************************
> > SERVLET:  Starting ClientAdderDelay
> > SERVLET:  Starting ClientAdder
> > SERVLET:  Joining to ClientAdder
> > CLIENTADDERDELAY:  Before Update: 00000:121
> > CLIENTADDERDELAY:  Sleeping for 5000 millis
> > CLIENTADDER:  Before Update: 00000:121
> > CLIENTADDER: Changing name to 00001: 121
> > CLIENTADDER:  After Update: 00001:122
> > SERVLET:  Joingin to ClientAdderDelay
> > CLIENTADDERDELAY: Changing name to 00001:122
> > CLIENTADDERDELAY:  After Update: 00001:123
> > *************************** END ************************
> >
> > Everything looks the same, to me except the first time the exception
> > is thrown, and the database is only updated once, the second time the
> > exception isn't thrown and the database is updated twice.
> >
> > Does anyone else have any suggestions on what I should try next?
> >
> > On Fri, 3 Dec 2004 10:25:04 +0100, Alessandro Colantoni
> > <ac...@brujulatelecom.com> wrote:
> >
> >>Hi Wesley.
> >>I don't think the problem is the new connection.
> >>It looks like thread B do his job (the second time, of course) after
> >>thread A has done his one.
> >>That's should be the reason you don't get the optimistic lock Exception
> >>the second time (I don't see it).
> >>You should print the value of the ackOptLock parameter to have more
> >>informations.
> >> I hope this help
> >>
> >>-----Mensaje original-----
> >>De: Wesley Lemke [mailto:buck.lemke@gmail.com]
> >>Enviado el: jueves, 02 de diciembre de 2004 22:51
> >>Para: OJB Users List
> >>Asunto: Optimistic Locking Problem.
> >>
> >>
> >>
> >>We are adding optimistic locking to our application.  To test it out I
> >>have made a simple test case.  The application spawns two threads.
> >>
> >>Thread A (ClientAdderDelay):  Reads an object from the database.  It
> >>then checks the name of the ojbect.  If the name was 00000 it changes
> >>it to 00001 and if the name was 00001 it changes it to 00000.  The
> >>thread sleeps for 5 seconds and then stores the object.
> >>
> >>Thread B (ClientAdder):  Does the same thing, but doesn't sleep 5
> >>seconds between the read/store.
> >>
> >>The main servlet starts thread A, then sleeps for 1 second and starts
> >>thread B.
> >>
> >>The very first time I run the application everything works as it
> >>should, Thread A and B both read 00000 from the database.  Thread B
> >>then updates the row to be 00001.  Thread A gets and OptimisticLock
> >>exception when it tries to store the object.
> >>
> >>However all subsequent times that I run the application Thread A will
> >>get the correct value from the database but thread B will get the
> >>opposite value.  I am attaching the output, which will hopefully make
> >>this more understandable.  The one difference I see is that the
> >>Datasource gets a new connection the first time the Servlet is run,
> >>but not the second...I wouldn't think that this would matter?
> >>
> >>OUTPUT:
> >>
> >>[12/2/04 15:47:56:436 CST] 797e3663 SystemErr     R
> >>*************************** START ************************
> >>[12/2/04 15:47:56:466 CST] 797e3663 SystemErr     R SERVLET:  Starting
> >>ClientAdderDelay
> >>[12/2/04 15:47:56:466 CST] 797e3663 SystemErr     R SERVLET:  Sleeping
> >>1000 millis
> >>[12/2/04 15:47:56:896 CST] 6de77661 Config        E
> >>com.opensymphony.oscache.base.Config  Error reading
> >>/oscache.properties in CacheAdministrator.loadProps()
> >>java.lang.NullPointerException
> >>[12/2/04 15:47:56:906 CST] 6de77661 Config        E
> >>com.opensymphony.oscache.base.Config  Ensure the /oscache.properties
> >>file is readable and in your classpath.
> >>[12/2/04 15:47:56:916 CST] 6de77661 GeneralCacheA I
> >>com.opensymphony.oscache.general.GeneralCacheAdministrator
> >>Constructed GeneralCacheAdministrator()
> >>[12/2/04 15:47:56:916 CST] 6de77661 GeneralCacheA I
> >>com.opensymphony.oscache.general.GeneralCacheAdministrator  Creating
> >>new cache
> >>[12/2/04 15:47:58:469 CST] 6de77661 DSConfigurati W DSRA0174W:
> >>Warning: GenericDataStoreHelper is being used.
> >>[12/2/04 15:47:58:629 CST] 6de77661 ConnectionFac I J2CA0122I:
> >>Resource reference jdbc/ao79 could not be located, so default values
> >>of the following are used: [Resource-ref settings]
> >>
> >>        res-auth:                 1 (APPLICATION)
> >>        res-isolation-level:      0 (TRANSACTION_NONE)
> >>        res-sharing-scope:        true (SHAREABLE)
> >>        res-resolution-control:   999 (undefined)
> >>[Other attributes]
> >>
> >>isCMP1_x:                 false (not CMP1.x)
> >>isJMS:                 false (not JMS)
> >>
> >>[12/2/04 15:47:58:669 CST] 6de77661 ConnectionFac I J2CA0107I:
> >>Component-managed authentication alias not specified for connection
> >>factory or datasource MySql Datasource on ao79.
> >>[12/2/04 15:47:58:699 CST] 4b22f67d ConnectionFac I J2CA0122I:
> >>Resource reference jdbc/ao79 could not be located, so default values
> >>of the following are used: [Resource-ref settings]
> >>
> >>        res-auth:                 1 (APPLICATION)
> >>        res-isolation-level:      0 (TRANSACTION_NONE)
> >>        res-sharing-scope:        true (SHAREABLE)
> >>        res-resolution-control:   999 (undefined)
> >>[Other attributes]
> >>
> >>isCMP1_x:                 false (not CMP1.x)
> >>isJMS:                 false (not JMS)
> >>
> >>[12/2/04 15:47:58:699 CST] 6de77661 ConnectionMan W J2CA0075W: An
> >>active transaction should be present while processing method
> >>allocateMCWrapper.
> >>[12/2/04 15:47:58:709 CST] 4b22f67d ConnectionMan W J2CA0075W: An
> >>active transaction should be present while processing method
> >>allocateMCWrapper.
> >>[12/2/04 15:47:57:477 CST] 797e3663 SystemErr     R SERVLET:  Starting
> >>ClientAdder
> >>[12/2/04 15:47:57:477 CST] 797e3663 SystemErr     R SERVLET:  Joining
> >>to ClientAdder
> >>[12/2/04 15:47:59:170 CST] 4b22f67d WSRdbDataSour u Database version is
> >>                                 3.23.41
> >>[12/2/04 15:47:59:170 CST] 4b22f67d WSRdbDataSour u JDBC Driver version
> >>is
> >>                                 mysql-connector-java-3.0.15-ga (
> >>$Date: 2004/08/09 22:15:11 $, $Revision: 1.27.2.43 $ )
> >>[12/2/04 15:47:59:250 CST] 4b22f67d ConnectionMan W J2CA0075W: An
> >>active transaction should be present while processing method
> >>initializeForUOW.
> >>[12/2/04 15:47:59:250 CST] 6de77661 ConnectionMan W J2CA0075W: An
> >>active transaction should be present while processing method
> >>initializeForUOW.
> >>[12/2/04 15:47:59:530 CST] 4b22f67d SystemErr     R CLIENTADDER:
> >>Before Update: 00000<br>
> >>[12/2/04 15:47:59:560 CST] 4b22f67d SystemErr     R CLIENTADDER:
> >>Changing name to 00001
> >>[12/2/04 15:47:59:560 CST] 6de77661 SystemErr     R CLIENTADDERDELAY:
> >>Before Update: 00000<br>
> >>[12/2/04 15:47:59:560 CST] 6de77661 SystemErr     R CLIENTADDERDELAY:
> >>Sleeping for 5000 millis
> >>[12/2/04 15:47:59:570 CST] 4b22f67d ConnectionMan W J2CA0075W: An
> >>active transaction should be present while processing method
> >>allocateMCWrapper.
> >>[12/2/04 15:47:59:570 CST] 4b22f67d ConnectionMan W J2CA0075W: An
> >>active transaction should be present while processing method
> >>initializeForUOW.
> >>[12/2/04 15:47:59:590 CST] 4b22f67d SystemErr     R CLIENTADDER:
> >>After Update: 00001<br>
> >>[12/2/04 15:47:59:590 CST] 797e3663 SystemErr     R SERVLET:  Joingin
> >>to ClientAdderDelay
> >>[12/2/04 15:48:04:557 CST] 6de77661 SystemErr     R CLIENTADDERDELAY:
> >>Changing name to 00001
> >>[12/2/04 15:48:04:617 CST] 6de77661 SystemErr     R
> >>CLIENTADDERDELAY:org.apache.ojb.broker.OptimisticLockException: Object
> >>has been modified by someone else
> >>[12/2/04 15:48:04:617 CST] 6de77661 ConnectionMan W J2CA0075W: An
> >>active transaction should be present while processing method
> >>allocateMCWrapper.
> >>[12/2/04 15:48:04:627 CST] 6de77661 ConnectionMan W J2CA0075W: An
> >>active transaction should be present while processing method
> >>initializeForUOW.
> >>[12/2/04 15:48:04:637 CST] 6de77661 SystemErr     R CLIENTADDERDELAY:
> >>After Update: 00001<br>
> >>[12/2/04 15:48:04:637 CST] 797e3663 SystemErr     R
> >>*************************** END ************************
> >>[12/2/04 15:48:47:729 CST] 797e3663 SystemErr     R
> >>*************************** START ************************
> >>[12/2/04 15:48:47:729 CST] 797e3663 SystemErr     R SERVLET:  Starting
> >>ClientAdderDelay
> >>[12/2/04 15:48:47:729 CST] 797e3663 SystemErr     R SERVLET:  Sleeping
> >>1000 millis
> >>[12/2/04 15:48:47:779 CST] 1ec7f672 ConnectionMan W J2CA0075W: An
> >>active transaction should be present while processing method
> >>allocateMCWrapper.
> >>[12/2/04 15:48:47:840 CST] 1ec7f672 ConnectionMan W J2CA0075W: An
> >>active transaction should be present while processing method
> >>initializeForUOW.
> >>[12/2/04 15:48:47:850 CST] 1ec7f672 SystemErr     R CLIENTADDERDELAY:
> >>Before Update: 00001<br>
> >>[12/2/04 15:48:47:850 CST] 1ec7f672 SystemErr     R CLIENTADDERDELAY:
> >>Sleeping for 5000 millis
> >>[12/2/04 15:48:48:931 CST] 797e3663 SystemErr     R SERVLET:  Starting
> >>ClientAdder
> >>[12/2/04 15:48:48:931 CST] 797e3663 SystemErr     R SERVLET:  Joining
> >>to ClientAdder
> >>[12/2/04 15:48:48:931 CST] 1ec0f672 ConnectionMan W J2CA0075W: An
> >>active transaction should be present while processing method
> >>allocateMCWrapper.
> >>[12/2/04 15:48:49:031 CST] 1ec0f672 ConnectionMan W J2CA0075W: An
> >>active transaction should be present while processing method
> >>initializeForUOW.
> >>[12/2/04 15:48:49:041 CST] 1ec0f672 SystemErr     R CLIENTADDER:
> >>Before Update: 00000<br>
> >>[12/2/04 15:48:49:041 CST] 1ec0f672 SystemErr     R CLIENTADDER:
> >>Changing name to 00001
> >>[12/2/04 15:48:49:051 CST] 1ec0f672 ConnectionMan W J2CA0075W: An
> >>active transaction should be present while processing method
> >>allocateMCWrapper.
> >>[12/2/04 15:48:49:061 CST] 1ec0f672 ConnectionMan W J2CA0075W: An
> >>active transaction should be present while processing method
> >>initializeForUOW.
> >>[12/2/04 15:48:49:081 CST] 1ec0f672 SystemErr     R CLIENTADDER:
> >>After Update: 00001<br>
> >>[12/2/04 15:48:49:081 CST] 797e3663 SystemErr     R SERVLET:  Joingin
> >>to ClientAdderDelay
> >>[12/2/04 15:48:52:857 CST] 1ec7f672 SystemErr     R CLIENTADDERDELAY:
> >>Changing name to 00001
> >>[12/2/04 15:48:52:857 CST] 1ec7f672 ConnectionMan W J2CA0075W: An
> >>active transaction should be present while processing method
> >>allocateMCWrapper.
> >>[12/2/04 15:48:52:867 CST] 1ec7f672 ConnectionMan W J2CA0075W: An
> >>active transaction should be present while processing method
> >>initializeForUOW.
> >>[12/2/04 15:48:52:877 CST] 1ec7f672 SystemErr     R CLIENTADDERDELAY:
> >>After Update: 00001<br>
> >>[12/2/04 15:48:52:877 CST] 797e3663 SystemErr     R
> >>*************************** END ************************
> >>
> >>Let me know if any more information would be helpful...
> >>
> >>---------------------------------------------------------------------
> >>To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
> >>For additional commands, e-mail: ojb-user-help@db.apache.org
> >>
> >>
> >
> > 
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
> > For additional commands, e-mail: ojb-user-help@db.apache.org
> >
> >
> >
> 
> ---------------------------------------------------------------------
> 
> 
> To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
> For additional commands, e-mail: ojb-user-help@db.apache.org
> 
>

---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-user-help@db.apache.org


Re: Optimistic Locking Problem.

Posted by Armin Waibel <ar...@apache.org>.
Hi Wesley,

I did a multithreaded test too - all seems ok.
Do you use a Timestamp as lock field?
Do you re-read the used object when writing fails (to get fresh object 
with valid lock version)?

regards,
Armin

Wesley Lemke wrote:

> I am now printing the ackOptLock value, but still am only getting the
> OptimisticLock exception the first time I run the code after I restart
> the servlet containter.  Here is the log files of the first two runs.
> 
> *************************** START ************************
> SERVLET:  Starting ClientAdderDelay
> SERVLET:  Starting ClientAdder
> SERVLET:  Joining to ClientAdder
> CLIENTADDERDELAY:  Before Update: 00001:120
> CLIENTADDERDELAY:  Sleeping for 5000 millis
> CLIENTADDER:  Before Update: 00001:120
> CLIENTADDER: Changing name to 00000: 120
> CLIENTADDER:  After Update: 00000:121
> SERVLET:  Joingin to ClientAdderDelay
> CLIENTADDERDELAY: Changing name to 00000:120
> CLIENTADDERDELAY: (121)
> org.apache.ojb.broker.OptimisticLockException: Object has been
> modified by someone else
> CLIENTADDERDELAY:  After Update: 00000:121
> *************************** END ************************
> 
> *************************** START ************************
> SERVLET:  Starting ClientAdderDelay
> SERVLET:  Starting ClientAdder
> SERVLET:  Joining to ClientAdder
> CLIENTADDERDELAY:  Before Update: 00000:121
> CLIENTADDERDELAY:  Sleeping for 5000 millis
> CLIENTADDER:  Before Update: 00000:121
> CLIENTADDER: Changing name to 00001: 121
> CLIENTADDER:  After Update: 00001:122
> SERVLET:  Joingin to ClientAdderDelay
> CLIENTADDERDELAY: Changing name to 00001:122
> CLIENTADDERDELAY:  After Update: 00001:123
> *************************** END ************************
> 
> Everything looks the same, to me except the first time the exception
> is thrown, and the database is only updated once, the second time the
> exception isn't thrown and the database is updated twice.
> 
> Does anyone else have any suggestions on what I should try next?
> 
> On Fri, 3 Dec 2004 10:25:04 +0100, Alessandro Colantoni
> <ac...@brujulatelecom.com> wrote:
> 
>>Hi Wesley.
>>I don't think the problem is the new connection.
>>It looks like thread B do his job (the second time, of course) after
>>thread A has done his one.
>>That's should be the reason you don't get the optimistic lock Exception
>>the second time (I don't see it).
>>You should print the value of the ackOptLock parameter to have more
>>informations.
>> I hope this help
>>
>>-----Mensaje original-----
>>De: Wesley Lemke [mailto:buck.lemke@gmail.com]
>>Enviado el: jueves, 02 de diciembre de 2004 22:51
>>Para: OJB Users List
>>Asunto: Optimistic Locking Problem.
>>
>>
>>
>>We are adding optimistic locking to our application.  To test it out I
>>have made a simple test case.  The application spawns two threads.
>>
>>Thread A (ClientAdderDelay):  Reads an object from the database.  It
>>then checks the name of the ojbect.  If the name was 00000 it changes
>>it to 00001 and if the name was 00001 it changes it to 00000.  The
>>thread sleeps for 5 seconds and then stores the object.
>>
>>Thread B (ClientAdder):  Does the same thing, but doesn't sleep 5
>>seconds between the read/store.
>>
>>The main servlet starts thread A, then sleeps for 1 second and starts
>>thread B.
>>
>>The very first time I run the application everything works as it
>>should, Thread A and B both read 00000 from the database.  Thread B
>>then updates the row to be 00001.  Thread A gets and OptimisticLock
>>exception when it tries to store the object.
>>
>>However all subsequent times that I run the application Thread A will
>>get the correct value from the database but thread B will get the
>>opposite value.  I am attaching the output, which will hopefully make
>>this more understandable.  The one difference I see is that the
>>Datasource gets a new connection the first time the Servlet is run,
>>but not the second...I wouldn't think that this would matter?
>>
>>OUTPUT:
>>
>>[12/2/04 15:47:56:436 CST] 797e3663 SystemErr     R
>>*************************** START ************************
>>[12/2/04 15:47:56:466 CST] 797e3663 SystemErr     R SERVLET:  Starting
>>ClientAdderDelay
>>[12/2/04 15:47:56:466 CST] 797e3663 SystemErr     R SERVLET:  Sleeping
>>1000 millis
>>[12/2/04 15:47:56:896 CST] 6de77661 Config        E
>>com.opensymphony.oscache.base.Config  Error reading
>>/oscache.properties in CacheAdministrator.loadProps()
>>java.lang.NullPointerException
>>[12/2/04 15:47:56:906 CST] 6de77661 Config        E
>>com.opensymphony.oscache.base.Config  Ensure the /oscache.properties
>>file is readable and in your classpath.
>>[12/2/04 15:47:56:916 CST] 6de77661 GeneralCacheA I
>>com.opensymphony.oscache.general.GeneralCacheAdministrator
>>Constructed GeneralCacheAdministrator()
>>[12/2/04 15:47:56:916 CST] 6de77661 GeneralCacheA I
>>com.opensymphony.oscache.general.GeneralCacheAdministrator  Creating
>>new cache
>>[12/2/04 15:47:58:469 CST] 6de77661 DSConfigurati W DSRA0174W:
>>Warning: GenericDataStoreHelper is being used.
>>[12/2/04 15:47:58:629 CST] 6de77661 ConnectionFac I J2CA0122I:
>>Resource reference jdbc/ao79 could not be located, so default values
>>of the following are used: [Resource-ref settings]
>>
>>        res-auth:                 1 (APPLICATION)
>>        res-isolation-level:      0 (TRANSACTION_NONE)
>>        res-sharing-scope:        true (SHAREABLE)
>>        res-resolution-control:   999 (undefined)
>>[Other attributes]
>>
>>isCMP1_x:                 false (not CMP1.x)
>>isJMS:                 false (not JMS)
>>
>>[12/2/04 15:47:58:669 CST] 6de77661 ConnectionFac I J2CA0107I:
>>Component-managed authentication alias not specified for connection
>>factory or datasource MySql Datasource on ao79.
>>[12/2/04 15:47:58:699 CST] 4b22f67d ConnectionFac I J2CA0122I:
>>Resource reference jdbc/ao79 could not be located, so default values
>>of the following are used: [Resource-ref settings]
>>
>>        res-auth:                 1 (APPLICATION)
>>        res-isolation-level:      0 (TRANSACTION_NONE)
>>        res-sharing-scope:        true (SHAREABLE)
>>        res-resolution-control:   999 (undefined)
>>[Other attributes]
>>
>>isCMP1_x:                 false (not CMP1.x)
>>isJMS:                 false (not JMS)
>>
>>[12/2/04 15:47:58:699 CST] 6de77661 ConnectionMan W J2CA0075W: An
>>active transaction should be present while processing method
>>allocateMCWrapper.
>>[12/2/04 15:47:58:709 CST] 4b22f67d ConnectionMan W J2CA0075W: An
>>active transaction should be present while processing method
>>allocateMCWrapper.
>>[12/2/04 15:47:57:477 CST] 797e3663 SystemErr     R SERVLET:  Starting
>>ClientAdder
>>[12/2/04 15:47:57:477 CST] 797e3663 SystemErr     R SERVLET:  Joining
>>to ClientAdder
>>[12/2/04 15:47:59:170 CST] 4b22f67d WSRdbDataSour u Database version is
>>                                 3.23.41
>>[12/2/04 15:47:59:170 CST] 4b22f67d WSRdbDataSour u JDBC Driver version
>>is
>>                                 mysql-connector-java-3.0.15-ga (
>>$Date: 2004/08/09 22:15:11 $, $Revision: 1.27.2.43 $ )
>>[12/2/04 15:47:59:250 CST] 4b22f67d ConnectionMan W J2CA0075W: An
>>active transaction should be present while processing method
>>initializeForUOW.
>>[12/2/04 15:47:59:250 CST] 6de77661 ConnectionMan W J2CA0075W: An
>>active transaction should be present while processing method
>>initializeForUOW.
>>[12/2/04 15:47:59:530 CST] 4b22f67d SystemErr     R CLIENTADDER:
>>Before Update: 00000<br>
>>[12/2/04 15:47:59:560 CST] 4b22f67d SystemErr     R CLIENTADDER:
>>Changing name to 00001
>>[12/2/04 15:47:59:560 CST] 6de77661 SystemErr     R CLIENTADDERDELAY:
>>Before Update: 00000<br>
>>[12/2/04 15:47:59:560 CST] 6de77661 SystemErr     R CLIENTADDERDELAY:
>>Sleeping for 5000 millis
>>[12/2/04 15:47:59:570 CST] 4b22f67d ConnectionMan W J2CA0075W: An
>>active transaction should be present while processing method
>>allocateMCWrapper.
>>[12/2/04 15:47:59:570 CST] 4b22f67d ConnectionMan W J2CA0075W: An
>>active transaction should be present while processing method
>>initializeForUOW.
>>[12/2/04 15:47:59:590 CST] 4b22f67d SystemErr     R CLIENTADDER:
>>After Update: 00001<br>
>>[12/2/04 15:47:59:590 CST] 797e3663 SystemErr     R SERVLET:  Joingin
>>to ClientAdderDelay
>>[12/2/04 15:48:04:557 CST] 6de77661 SystemErr     R CLIENTADDERDELAY:
>>Changing name to 00001
>>[12/2/04 15:48:04:617 CST] 6de77661 SystemErr     R
>>CLIENTADDERDELAY:org.apache.ojb.broker.OptimisticLockException: Object
>>has been modified by someone else
>>[12/2/04 15:48:04:617 CST] 6de77661 ConnectionMan W J2CA0075W: An
>>active transaction should be present while processing method
>>allocateMCWrapper.
>>[12/2/04 15:48:04:627 CST] 6de77661 ConnectionMan W J2CA0075W: An
>>active transaction should be present while processing method
>>initializeForUOW.
>>[12/2/04 15:48:04:637 CST] 6de77661 SystemErr     R CLIENTADDERDELAY:
>>After Update: 00001<br>
>>[12/2/04 15:48:04:637 CST] 797e3663 SystemErr     R
>>*************************** END ************************
>>[12/2/04 15:48:47:729 CST] 797e3663 SystemErr     R
>>*************************** START ************************
>>[12/2/04 15:48:47:729 CST] 797e3663 SystemErr     R SERVLET:  Starting
>>ClientAdderDelay
>>[12/2/04 15:48:47:729 CST] 797e3663 SystemErr     R SERVLET:  Sleeping
>>1000 millis
>>[12/2/04 15:48:47:779 CST] 1ec7f672 ConnectionMan W J2CA0075W: An
>>active transaction should be present while processing method
>>allocateMCWrapper.
>>[12/2/04 15:48:47:840 CST] 1ec7f672 ConnectionMan W J2CA0075W: An
>>active transaction should be present while processing method
>>initializeForUOW.
>>[12/2/04 15:48:47:850 CST] 1ec7f672 SystemErr     R CLIENTADDERDELAY:
>>Before Update: 00001<br>
>>[12/2/04 15:48:47:850 CST] 1ec7f672 SystemErr     R CLIENTADDERDELAY:
>>Sleeping for 5000 millis
>>[12/2/04 15:48:48:931 CST] 797e3663 SystemErr     R SERVLET:  Starting
>>ClientAdder
>>[12/2/04 15:48:48:931 CST] 797e3663 SystemErr     R SERVLET:  Joining
>>to ClientAdder
>>[12/2/04 15:48:48:931 CST] 1ec0f672 ConnectionMan W J2CA0075W: An
>>active transaction should be present while processing method
>>allocateMCWrapper.
>>[12/2/04 15:48:49:031 CST] 1ec0f672 ConnectionMan W J2CA0075W: An
>>active transaction should be present while processing method
>>initializeForUOW.
>>[12/2/04 15:48:49:041 CST] 1ec0f672 SystemErr     R CLIENTADDER:
>>Before Update: 00000<br>
>>[12/2/04 15:48:49:041 CST] 1ec0f672 SystemErr     R CLIENTADDER:
>>Changing name to 00001
>>[12/2/04 15:48:49:051 CST] 1ec0f672 ConnectionMan W J2CA0075W: An
>>active transaction should be present while processing method
>>allocateMCWrapper.
>>[12/2/04 15:48:49:061 CST] 1ec0f672 ConnectionMan W J2CA0075W: An
>>active transaction should be present while processing method
>>initializeForUOW.
>>[12/2/04 15:48:49:081 CST] 1ec0f672 SystemErr     R CLIENTADDER:
>>After Update: 00001<br>
>>[12/2/04 15:48:49:081 CST] 797e3663 SystemErr     R SERVLET:  Joingin
>>to ClientAdderDelay
>>[12/2/04 15:48:52:857 CST] 1ec7f672 SystemErr     R CLIENTADDERDELAY:
>>Changing name to 00001
>>[12/2/04 15:48:52:857 CST] 1ec7f672 ConnectionMan W J2CA0075W: An
>>active transaction should be present while processing method
>>allocateMCWrapper.
>>[12/2/04 15:48:52:867 CST] 1ec7f672 ConnectionMan W J2CA0075W: An
>>active transaction should be present while processing method
>>initializeForUOW.
>>[12/2/04 15:48:52:877 CST] 1ec7f672 SystemErr     R CLIENTADDERDELAY:
>>After Update: 00001<br>
>>[12/2/04 15:48:52:877 CST] 797e3663 SystemErr     R
>>*************************** END ************************
>>
>>Let me know if any more information would be helpful...
>>
>>---------------------------------------------------------------------
>>To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
>>For additional commands, e-mail: ojb-user-help@db.apache.org
>>
>>
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
> For additional commands, e-mail: ojb-user-help@db.apache.org
> 
> 
> 

---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-user-help@db.apache.org


Re: Optimistic Locking Problem.

Posted by Wesley Lemke <bu...@gmail.com>.
I am now printing the ackOptLock value, but still am only getting the
OptimisticLock exception the first time I run the code after I restart
the servlet containter.  Here is the log files of the first two runs.

*************************** START ************************
SERVLET:  Starting ClientAdderDelay
SERVLET:  Starting ClientAdder
SERVLET:  Joining to ClientAdder
CLIENTADDERDELAY:  Before Update: 00001:120
CLIENTADDERDELAY:  Sleeping for 5000 millis
CLIENTADDER:  Before Update: 00001:120
CLIENTADDER: Changing name to 00000: 120
CLIENTADDER:  After Update: 00000:121
SERVLET:  Joingin to ClientAdderDelay
CLIENTADDERDELAY: Changing name to 00000:120
CLIENTADDERDELAY: (121)
org.apache.ojb.broker.OptimisticLockException: Object has been
modified by someone else
CLIENTADDERDELAY:  After Update: 00000:121
*************************** END ************************

*************************** START ************************
SERVLET:  Starting ClientAdderDelay
SERVLET:  Starting ClientAdder
SERVLET:  Joining to ClientAdder
CLIENTADDERDELAY:  Before Update: 00000:121
CLIENTADDERDELAY:  Sleeping for 5000 millis
CLIENTADDER:  Before Update: 00000:121
CLIENTADDER: Changing name to 00001: 121
CLIENTADDER:  After Update: 00001:122
SERVLET:  Joingin to ClientAdderDelay
CLIENTADDERDELAY: Changing name to 00001:122
CLIENTADDERDELAY:  After Update: 00001:123
*************************** END ************************

Everything looks the same, to me except the first time the exception
is thrown, and the database is only updated once, the second time the
exception isn't thrown and the database is updated twice.

Does anyone else have any suggestions on what I should try next?

On Fri, 3 Dec 2004 10:25:04 +0100, Alessandro Colantoni
<ac...@brujulatelecom.com> wrote:
> Hi Wesley.
> I don't think the problem is the new connection.
> It looks like thread B do his job (the second time, of course) after
> thread A has done his one.
> That's should be the reason you don't get the optimistic lock Exception
> the second time (I don't see it).
> You should print the value of the ackOptLock parameter to have more
> informations.
>  I hope this help
> 
> -----Mensaje original-----
> De: Wesley Lemke [mailto:buck.lemke@gmail.com]
> Enviado el: jueves, 02 de diciembre de 2004 22:51
> Para: OJB Users List
> Asunto: Optimistic Locking Problem.
> 
> 
> 
> We are adding optimistic locking to our application.  To test it out I
> have made a simple test case.  The application spawns two threads.
> 
> Thread A (ClientAdderDelay):  Reads an object from the database.  It
> then checks the name of the ojbect.  If the name was 00000 it changes
> it to 00001 and if the name was 00001 it changes it to 00000.  The
> thread sleeps for 5 seconds and then stores the object.
> 
> Thread B (ClientAdder):  Does the same thing, but doesn't sleep 5
> seconds between the read/store.
> 
> The main servlet starts thread A, then sleeps for 1 second and starts
> thread B.
> 
> The very first time I run the application everything works as it
> should, Thread A and B both read 00000 from the database.  Thread B
> then updates the row to be 00001.  Thread A gets and OptimisticLock
> exception when it tries to store the object.
> 
> However all subsequent times that I run the application Thread A will
> get the correct value from the database but thread B will get the
> opposite value.  I am attaching the output, which will hopefully make
> this more understandable.  The one difference I see is that the
> Datasource gets a new connection the first time the Servlet is run,
> but not the second...I wouldn't think that this would matter?
> 
> OUTPUT:
> 
> [12/2/04 15:47:56:436 CST] 797e3663 SystemErr     R
> *************************** START ************************
> [12/2/04 15:47:56:466 CST] 797e3663 SystemErr     R SERVLET:  Starting
> ClientAdderDelay
> [12/2/04 15:47:56:466 CST] 797e3663 SystemErr     R SERVLET:  Sleeping
> 1000 millis
> [12/2/04 15:47:56:896 CST] 6de77661 Config        E
> com.opensymphony.oscache.base.Config  Error reading
> /oscache.properties in CacheAdministrator.loadProps()
> java.lang.NullPointerException
> [12/2/04 15:47:56:906 CST] 6de77661 Config        E
> com.opensymphony.oscache.base.Config  Ensure the /oscache.properties
> file is readable and in your classpath.
> [12/2/04 15:47:56:916 CST] 6de77661 GeneralCacheA I
> com.opensymphony.oscache.general.GeneralCacheAdministrator
> Constructed GeneralCacheAdministrator()
> [12/2/04 15:47:56:916 CST] 6de77661 GeneralCacheA I
> com.opensymphony.oscache.general.GeneralCacheAdministrator  Creating
> new cache
> [12/2/04 15:47:58:469 CST] 6de77661 DSConfigurati W DSRA0174W:
> Warning: GenericDataStoreHelper is being used.
> [12/2/04 15:47:58:629 CST] 6de77661 ConnectionFac I J2CA0122I:
> Resource reference jdbc/ao79 could not be located, so default values
> of the following are used: [Resource-ref settings]
> 
>         res-auth:                 1 (APPLICATION)
>         res-isolation-level:      0 (TRANSACTION_NONE)
>         res-sharing-scope:        true (SHAREABLE)
>         res-resolution-control:   999 (undefined)
> [Other attributes]
> 
> isCMP1_x:                 false (not CMP1.x)
> isJMS:                 false (not JMS)
> 
> [12/2/04 15:47:58:669 CST] 6de77661 ConnectionFac I J2CA0107I:
> Component-managed authentication alias not specified for connection
> factory or datasource MySql Datasource on ao79.
> [12/2/04 15:47:58:699 CST] 4b22f67d ConnectionFac I J2CA0122I:
> Resource reference jdbc/ao79 could not be located, so default values
> of the following are used: [Resource-ref settings]
> 
>         res-auth:                 1 (APPLICATION)
>         res-isolation-level:      0 (TRANSACTION_NONE)
>         res-sharing-scope:        true (SHAREABLE)
>         res-resolution-control:   999 (undefined)
> [Other attributes]
> 
> isCMP1_x:                 false (not CMP1.x)
> isJMS:                 false (not JMS)
> 
> [12/2/04 15:47:58:699 CST] 6de77661 ConnectionMan W J2CA0075W: An
> active transaction should be present while processing method
> allocateMCWrapper.
> [12/2/04 15:47:58:709 CST] 4b22f67d ConnectionMan W J2CA0075W: An
> active transaction should be present while processing method
> allocateMCWrapper.
> [12/2/04 15:47:57:477 CST] 797e3663 SystemErr     R SERVLET:  Starting
> ClientAdder
> [12/2/04 15:47:57:477 CST] 797e3663 SystemErr     R SERVLET:  Joining
> to ClientAdder
> [12/2/04 15:47:59:170 CST] 4b22f67d WSRdbDataSour u Database version is
>                                  3.23.41
> [12/2/04 15:47:59:170 CST] 4b22f67d WSRdbDataSour u JDBC Driver version
> is
>                                  mysql-connector-java-3.0.15-ga (
> $Date: 2004/08/09 22:15:11 $, $Revision: 1.27.2.43 $ )
> [12/2/04 15:47:59:250 CST] 4b22f67d ConnectionMan W J2CA0075W: An
> active transaction should be present while processing method
> initializeForUOW.
> [12/2/04 15:47:59:250 CST] 6de77661 ConnectionMan W J2CA0075W: An
> active transaction should be present while processing method
> initializeForUOW.
> [12/2/04 15:47:59:530 CST] 4b22f67d SystemErr     R CLIENTADDER:
> Before Update: 00000<br>
> [12/2/04 15:47:59:560 CST] 4b22f67d SystemErr     R CLIENTADDER:
> Changing name to 00001
> [12/2/04 15:47:59:560 CST] 6de77661 SystemErr     R CLIENTADDERDELAY:
> Before Update: 00000<br>
> [12/2/04 15:47:59:560 CST] 6de77661 SystemErr     R CLIENTADDERDELAY:
> Sleeping for 5000 millis
> [12/2/04 15:47:59:570 CST] 4b22f67d ConnectionMan W J2CA0075W: An
> active transaction should be present while processing method
> allocateMCWrapper.
> [12/2/04 15:47:59:570 CST] 4b22f67d ConnectionMan W J2CA0075W: An
> active transaction should be present while processing method
> initializeForUOW.
> [12/2/04 15:47:59:590 CST] 4b22f67d SystemErr     R CLIENTADDER:
> After Update: 00001<br>
> [12/2/04 15:47:59:590 CST] 797e3663 SystemErr     R SERVLET:  Joingin
> to ClientAdderDelay
> [12/2/04 15:48:04:557 CST] 6de77661 SystemErr     R CLIENTADDERDELAY:
> Changing name to 00001
> [12/2/04 15:48:04:617 CST] 6de77661 SystemErr     R
> CLIENTADDERDELAY:org.apache.ojb.broker.OptimisticLockException: Object
> has been modified by someone else
> [12/2/04 15:48:04:617 CST] 6de77661 ConnectionMan W J2CA0075W: An
> active transaction should be present while processing method
> allocateMCWrapper.
> [12/2/04 15:48:04:627 CST] 6de77661 ConnectionMan W J2CA0075W: An
> active transaction should be present while processing method
> initializeForUOW.
> [12/2/04 15:48:04:637 CST] 6de77661 SystemErr     R CLIENTADDERDELAY:
> After Update: 00001<br>
> [12/2/04 15:48:04:637 CST] 797e3663 SystemErr     R
> *************************** END ************************
> [12/2/04 15:48:47:729 CST] 797e3663 SystemErr     R
> *************************** START ************************
> [12/2/04 15:48:47:729 CST] 797e3663 SystemErr     R SERVLET:  Starting
> ClientAdderDelay
> [12/2/04 15:48:47:729 CST] 797e3663 SystemErr     R SERVLET:  Sleeping
> 1000 millis
> [12/2/04 15:48:47:779 CST] 1ec7f672 ConnectionMan W J2CA0075W: An
> active transaction should be present while processing method
> allocateMCWrapper.
> [12/2/04 15:48:47:840 CST] 1ec7f672 ConnectionMan W J2CA0075W: An
> active transaction should be present while processing method
> initializeForUOW.
> [12/2/04 15:48:47:850 CST] 1ec7f672 SystemErr     R CLIENTADDERDELAY:
> Before Update: 00001<br>
> [12/2/04 15:48:47:850 CST] 1ec7f672 SystemErr     R CLIENTADDERDELAY:
> Sleeping for 5000 millis
> [12/2/04 15:48:48:931 CST] 797e3663 SystemErr     R SERVLET:  Starting
> ClientAdder
> [12/2/04 15:48:48:931 CST] 797e3663 SystemErr     R SERVLET:  Joining
> to ClientAdder
> [12/2/04 15:48:48:931 CST] 1ec0f672 ConnectionMan W J2CA0075W: An
> active transaction should be present while processing method
> allocateMCWrapper.
> [12/2/04 15:48:49:031 CST] 1ec0f672 ConnectionMan W J2CA0075W: An
> active transaction should be present while processing method
> initializeForUOW.
> [12/2/04 15:48:49:041 CST] 1ec0f672 SystemErr     R CLIENTADDER:
> Before Update: 00000<br>
> [12/2/04 15:48:49:041 CST] 1ec0f672 SystemErr     R CLIENTADDER:
> Changing name to 00001
> [12/2/04 15:48:49:051 CST] 1ec0f672 ConnectionMan W J2CA0075W: An
> active transaction should be present while processing method
> allocateMCWrapper.
> [12/2/04 15:48:49:061 CST] 1ec0f672 ConnectionMan W J2CA0075W: An
> active transaction should be present while processing method
> initializeForUOW.
> [12/2/04 15:48:49:081 CST] 1ec0f672 SystemErr     R CLIENTADDER:
> After Update: 00001<br>
> [12/2/04 15:48:49:081 CST] 797e3663 SystemErr     R SERVLET:  Joingin
> to ClientAdderDelay
> [12/2/04 15:48:52:857 CST] 1ec7f672 SystemErr     R CLIENTADDERDELAY:
> Changing name to 00001
> [12/2/04 15:48:52:857 CST] 1ec7f672 ConnectionMan W J2CA0075W: An
> active transaction should be present while processing method
> allocateMCWrapper.
> [12/2/04 15:48:52:867 CST] 1ec7f672 ConnectionMan W J2CA0075W: An
> active transaction should be present while processing method
> initializeForUOW.
> [12/2/04 15:48:52:877 CST] 1ec7f672 SystemErr     R CLIENTADDERDELAY:
> After Update: 00001<br>
> [12/2/04 15:48:52:877 CST] 797e3663 SystemErr     R
> *************************** END ************************
> 
> Let me know if any more information would be helpful...
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
> For additional commands, e-mail: ojb-user-help@db.apache.org
> 
>

---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-user-help@db.apache.org


RE: Optimistic Locking Problem.

Posted by Alessandro Colantoni <ac...@brujulatelecom.com>.
Hi Wesley.
I don't think the problem is the new connection.
It looks like thread B do his job (the second time, of course) after
thread A has done his one.
That's should be the reason you don't get the optimistic lock Exception
the second time (I don't see it).
You should print the value of the ackOptLock parameter to have more
informations.
 I hope this help


-----Mensaje original-----
De: Wesley Lemke [mailto:buck.lemke@gmail.com] 
Enviado el: jueves, 02 de diciembre de 2004 22:51
Para: OJB Users List
Asunto: Optimistic Locking Problem.

We are adding optimistic locking to our application.  To test it out I
have made a simple test case.  The application spawns two threads.

Thread A (ClientAdderDelay):  Reads an object from the database.  It
then checks the name of the ojbect.  If the name was 00000 it changes
it to 00001 and if the name was 00001 it changes it to 00000.  The
thread sleeps for 5 seconds and then stores the object.

Thread B (ClientAdder):  Does the same thing, but doesn't sleep 5
seconds between the read/store.

The main servlet starts thread A, then sleeps for 1 second and starts
thread B.

The very first time I run the application everything works as it
should, Thread A and B both read 00000 from the database.  Thread B
then updates the row to be 00001.  Thread A gets and OptimisticLock
exception when it tries to store the object.

However all subsequent times that I run the application Thread A will
get the correct value from the database but thread B will get the
opposite value.  I am attaching the output, which will hopefully make
this more understandable.  The one difference I see is that the
Datasource gets a new connection the first time the Servlet is run,
but not the second...I wouldn't think that this would matter?

OUTPUT:

[12/2/04 15:47:56:436 CST] 797e3663 SystemErr     R
*************************** START ************************
[12/2/04 15:47:56:466 CST] 797e3663 SystemErr     R SERVLET:  Starting
ClientAdderDelay
[12/2/04 15:47:56:466 CST] 797e3663 SystemErr     R SERVLET:  Sleeping
1000 millis
[12/2/04 15:47:56:896 CST] 6de77661 Config        E
com.opensymphony.oscache.base.Config  Error reading
/oscache.properties in CacheAdministrator.loadProps()
java.lang.NullPointerException
[12/2/04 15:47:56:906 CST] 6de77661 Config        E
com.opensymphony.oscache.base.Config  Ensure the /oscache.properties
file is readable and in your classpath.
[12/2/04 15:47:56:916 CST] 6de77661 GeneralCacheA I
com.opensymphony.oscache.general.GeneralCacheAdministrator 
Constructed GeneralCacheAdministrator()
[12/2/04 15:47:56:916 CST] 6de77661 GeneralCacheA I
com.opensymphony.oscache.general.GeneralCacheAdministrator  Creating
new cache
[12/2/04 15:47:58:469 CST] 6de77661 DSConfigurati W DSRA0174W:
Warning: GenericDataStoreHelper is being used.
[12/2/04 15:47:58:629 CST] 6de77661 ConnectionFac I J2CA0122I:
Resource reference jdbc/ao79 could not be located, so default values
of the following are used: [Resource-ref settings]

	res-auth:                 1 (APPLICATION)
	res-isolation-level:      0 (TRANSACTION_NONE)
	res-sharing-scope:        true (SHAREABLE)
	res-resolution-control:   999 (undefined)
[Other attributes]

isCMP1_x:                 false (not CMP1.x)
isJMS:                 false (not JMS)

[12/2/04 15:47:58:669 CST] 6de77661 ConnectionFac I J2CA0107I:
Component-managed authentication alias not specified for connection
factory or datasource MySql Datasource on ao79.
[12/2/04 15:47:58:699 CST] 4b22f67d ConnectionFac I J2CA0122I:
Resource reference jdbc/ao79 could not be located, so default values
of the following are used: [Resource-ref settings]

	res-auth:                 1 (APPLICATION)
	res-isolation-level:      0 (TRANSACTION_NONE)
	res-sharing-scope:        true (SHAREABLE)
	res-resolution-control:   999 (undefined)
[Other attributes]

isCMP1_x:                 false (not CMP1.x)
isJMS:                 false (not JMS)

[12/2/04 15:47:58:699 CST] 6de77661 ConnectionMan W J2CA0075W: An
active transaction should be present while processing method
allocateMCWrapper.
[12/2/04 15:47:58:709 CST] 4b22f67d ConnectionMan W J2CA0075W: An
active transaction should be present while processing method
allocateMCWrapper.
[12/2/04 15:47:57:477 CST] 797e3663 SystemErr     R SERVLET:  Starting
ClientAdder
[12/2/04 15:47:57:477 CST] 797e3663 SystemErr     R SERVLET:  Joining
to ClientAdder
[12/2/04 15:47:59:170 CST] 4b22f67d WSRdbDataSour u Database version is
                                 3.23.41
[12/2/04 15:47:59:170 CST] 4b22f67d WSRdbDataSour u JDBC Driver version
is
                                 mysql-connector-java-3.0.15-ga (
$Date: 2004/08/09 22:15:11 $, $Revision: 1.27.2.43 $ )
[12/2/04 15:47:59:250 CST] 4b22f67d ConnectionMan W J2CA0075W: An
active transaction should be present while processing method
initializeForUOW.
[12/2/04 15:47:59:250 CST] 6de77661 ConnectionMan W J2CA0075W: An
active transaction should be present while processing method
initializeForUOW.
[12/2/04 15:47:59:530 CST] 4b22f67d SystemErr     R CLIENTADDER: 
Before Update: 00000<br>
[12/2/04 15:47:59:560 CST] 4b22f67d SystemErr     R CLIENTADDER:
Changing name to 00001
[12/2/04 15:47:59:560 CST] 6de77661 SystemErr     R CLIENTADDERDELAY: 
Before Update: 00000<br>
[12/2/04 15:47:59:560 CST] 6de77661 SystemErr     R CLIENTADDERDELAY: 
Sleeping for 5000 millis
[12/2/04 15:47:59:570 CST] 4b22f67d ConnectionMan W J2CA0075W: An
active transaction should be present while processing method
allocateMCWrapper.
[12/2/04 15:47:59:570 CST] 4b22f67d ConnectionMan W J2CA0075W: An
active transaction should be present while processing method
initializeForUOW.
[12/2/04 15:47:59:590 CST] 4b22f67d SystemErr     R CLIENTADDER: 
After Update: 00001<br>
[12/2/04 15:47:59:590 CST] 797e3663 SystemErr     R SERVLET:  Joingin
to ClientAdderDelay
[12/2/04 15:48:04:557 CST] 6de77661 SystemErr     R CLIENTADDERDELAY:
Changing name to 00001
[12/2/04 15:48:04:617 CST] 6de77661 SystemErr     R
CLIENTADDERDELAY:org.apache.ojb.broker.OptimisticLockException: Object
has been modified by someone else
[12/2/04 15:48:04:617 CST] 6de77661 ConnectionMan W J2CA0075W: An
active transaction should be present while processing method
allocateMCWrapper.
[12/2/04 15:48:04:627 CST] 6de77661 ConnectionMan W J2CA0075W: An
active transaction should be present while processing method
initializeForUOW.
[12/2/04 15:48:04:637 CST] 6de77661 SystemErr     R CLIENTADDERDELAY: 
After Update: 00001<br>
[12/2/04 15:48:04:637 CST] 797e3663 SystemErr     R
*************************** END ************************
[12/2/04 15:48:47:729 CST] 797e3663 SystemErr     R
*************************** START ************************
[12/2/04 15:48:47:729 CST] 797e3663 SystemErr     R SERVLET:  Starting
ClientAdderDelay
[12/2/04 15:48:47:729 CST] 797e3663 SystemErr     R SERVLET:  Sleeping
1000 millis
[12/2/04 15:48:47:779 CST] 1ec7f672 ConnectionMan W J2CA0075W: An
active transaction should be present while processing method
allocateMCWrapper.
[12/2/04 15:48:47:840 CST] 1ec7f672 ConnectionMan W J2CA0075W: An
active transaction should be present while processing method
initializeForUOW.
[12/2/04 15:48:47:850 CST] 1ec7f672 SystemErr     R CLIENTADDERDELAY: 
Before Update: 00001<br>
[12/2/04 15:48:47:850 CST] 1ec7f672 SystemErr     R CLIENTADDERDELAY: 
Sleeping for 5000 millis
[12/2/04 15:48:48:931 CST] 797e3663 SystemErr     R SERVLET:  Starting
ClientAdder
[12/2/04 15:48:48:931 CST] 797e3663 SystemErr     R SERVLET:  Joining
to ClientAdder
[12/2/04 15:48:48:931 CST] 1ec0f672 ConnectionMan W J2CA0075W: An
active transaction should be present while processing method
allocateMCWrapper.
[12/2/04 15:48:49:031 CST] 1ec0f672 ConnectionMan W J2CA0075W: An
active transaction should be present while processing method
initializeForUOW.
[12/2/04 15:48:49:041 CST] 1ec0f672 SystemErr     R CLIENTADDER: 
Before Update: 00000<br>
[12/2/04 15:48:49:041 CST] 1ec0f672 SystemErr     R CLIENTADDER:
Changing name to 00001
[12/2/04 15:48:49:051 CST] 1ec0f672 ConnectionMan W J2CA0075W: An
active transaction should be present while processing method
allocateMCWrapper.
[12/2/04 15:48:49:061 CST] 1ec0f672 ConnectionMan W J2CA0075W: An
active transaction should be present while processing method
initializeForUOW.
[12/2/04 15:48:49:081 CST] 1ec0f672 SystemErr     R CLIENTADDER: 
After Update: 00001<br>
[12/2/04 15:48:49:081 CST] 797e3663 SystemErr     R SERVLET:  Joingin
to ClientAdderDelay
[12/2/04 15:48:52:857 CST] 1ec7f672 SystemErr     R CLIENTADDERDELAY:
Changing name to 00001
[12/2/04 15:48:52:857 CST] 1ec7f672 ConnectionMan W J2CA0075W: An
active transaction should be present while processing method
allocateMCWrapper.
[12/2/04 15:48:52:867 CST] 1ec7f672 ConnectionMan W J2CA0075W: An
active transaction should be present while processing method
initializeForUOW.
[12/2/04 15:48:52:877 CST] 1ec7f672 SystemErr     R CLIENTADDERDELAY: 
After Update: 00001<br>
[12/2/04 15:48:52:877 CST] 797e3663 SystemErr     R
*************************** END ************************

Let me know if any more information would be helpful...

---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-user-help@db.apache.org




---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-user-help@db.apache.org