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 ow <on...@yahoo.com> on 2003/06/28 09:38:42 UTC

Optimistic locking, dependent objects, etc

Hi,

A few questions about OJB:

1. Suppose a proxy is used to represent a whole collection. Does a
"session/transaction" have to be opened prior to accessing this collection for
the first time?

2. I believe OptimisticLockException will be thrown with ODMG API if the record
was deleted/modified. Can optimistic locking be used with PB API? How is the
optimistic locking implemented, is it a check for the number of updated
records?

3. Does OJB support dependent objects? E.g. Person object has properties
streetAddress, city, state, zipCode. Can streetAddress, city, state, zipCode
properties be mapped to the dependent object Address that is contained by
Person?

4. OJB supports mapping of direct SQL to a class, doesn�t it?

Thanks in advance





__________________________________
Do you Yahoo!?
SBC Yahoo! DSL - Now only $29.95 per month!
http://sbc.yahoo.com

Re: Optimistic locking, dependent objects, etc

Posted by Thomas Mahler <th...@web.de>.
hi ow,

ow wrote:
> Hi,
> 
> A few questions about OJB:
> 
> 1. Suppose a proxy is used to represent a whole collection. Does a
> "session/transaction" have to be opened prior to accessing this collection for
> the first time?

open transaction is not required.

> 
> 2. I believe OptimisticLockException will be thrown with ODMG API if the record
> was deleted/modified. Can optimistic locking be used with PB API?

yes!

> How is the
> optimistic locking implemented, is it a check for the number of updated
> records?

it's implemented as an additional predicate in the where clause:
instead of
UPDATE table SET column = Expression
	WHERE id = 23

the following statement is executed:
UPDATE table SET column = Expression
	WHERE id = 23
         AND VERSION = 3

Using this additional predicate we avoid udpdates in case the version 
has changed.
OJB supports INT and Timestamp columns as optimistic locking fields.
Usage is explained in the FAQ.

> 3. Does OJB support dependent objects? 
Yes,

> E.g. Person object has properties
> streetAddress, city, state, zipCode. Can streetAddress, city, state, zipCode
> properties be mapped to the dependent object Address that is contained by
> Person?

You have to tell OJB to use a PersistenField implementation supporting 
this in OJB.properties first, as it is not yet implemented in the 
default implementation:

PersistentFieldClass=org.apache.ojb.broker.metadata.fieldaccess.PersistentNestedFieldMaxPerformanceImpl

if your class has an attribute "address" of type Adress,
the mapping for the "streetAddress" attribute of "address" would look 
like follows:

       <field-descriptor id="10"
          name="adress->streetAddress"
          column="ADR_STREET"
          jdbc-type="VARCHAR"
       />

> 
> 4. OJB supports mapping of direct SQL to a class, doesn’t it?
Yes, there is a liitle section in the FAQ on this topc. Query.html also 
contains some more details

cheers,
Thomas


> 
> Thanks in advance
> 
> 
> 
> 
> 
> __________________________________
> Do you Yahoo!?
> SBC Yahoo! DSL - Now only $29.95 per month!
> http://sbc.yahoo.com
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
> For additional commands, e-mail: ojb-user-help@db.apache.org
> 
>