persistence@glassfish.java.net

Re: Idea for optimistic concurrency extension

From: Adam Bien <abien_at_adam-bien.com>
Date: Thu, 10 Aug 2006 09:27:19 +0200

Craig,



Craig L Russell schrieb:
> Hi Adam,
>
> On Aug 9, 2006, at 4:05 AM, Adam Bien wrote:
>
>> I discussed the following idea already with craig at the JAOO 2005.
>>
>> Problem:
>>
>> If you detach a persistent entity send it to client, then back, the
>> "before image" is lost.
>> In this case you need a version number or timestamp. You can have a
>> problem, in case you are working with a legacy database - it is often
>> hard or not allowed to change the schema.
>>
>> Now the following idea: why not send the before image together with
>> the entity?
>> As a improvement also only the where statement could be sent over the
>> wire. This should be sufficient to detect the collisions,
>
> Yes, sending the before-image across and maintaining the change list
> in the detached entity would allow you to compare the columns in the
> database with the fields in the before-image (in the WHERE clause of
> the UPDATE statement).
>
> Of course, this would require using a serialization protocol that
> sends change information along with the state. Which implies that you
> have a specialized readObject/writeObject on both ends of the
> serialization. Which implies that you cannot use the POJO class as-is
> unless you provide this specialized serialization behavior as part of
> your class definition, or have your persistence provider enhance the
> class before use, and install the enhanced class on both client and
> server.

Yes. This is right. But it could be sufficient only to send the
where-clause with already bounded values as String. So we would need
only one additional transient String attribute
to store the query and serialize only this attribute. The where-clause
could be also injected....
>>
>> I'm not sure, whether this list is the right place to discuss the
>> things - but I think such a feature would be unique...
>
> It's as good a place as any...
>
> Craig
>>
>> greetings,
>>
>> adam
>>
>> --Dipl. Inf. adam bien
>> BEA Technical Director
>> Sun Certified Java Programmer
>> Sun Certified Enterprise Java Architect Sun Enterprise Java Trainer
>> Mobile: 0049(0)170 280 3144
>> eMail: abien_at_adam-bien.com
>> Homepage: www.adam-bien.com
>> Weblog: http://www.adam-bien.com/roller/page/abien ----------
>> Book author:
>> Enterprise Architekturen
>> entwickler.press 2006
>> ISBN: 393504299X
>> and Enterprise Java Frameworks, J2EE Patterns, J2EE HotSpots and Struts.
>
> Craig Russell
> Architect, Sun Java Enterprise System http://java.sun.com/products/jdo
> 408 276-5638 mailto:Craig.Russell_at_sun.com
> P.S. A good JDO? O, Gasp!
>