db-ojb-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Philippe Hacquin <phacq...@voila.fr>
Subject Re: ODMG Tutorial Take 1
Date Wed, 01 Oct 2003 08:33:52 GMT
Hi Thomas,

just my point of view regarding "long transactions" and the tutorial. 
When I started using OJB a few months ago, I would have liked to quickly 
get a clear view of a  good software architecture for my web 
application. I think the ODMG tutorial should promote in a few words a 
good separation between the usual three tiers of a web app. The 
presentation layer should not deal with objects pertaining to the data 
layer, they should instead work on value objects. The business logic 
layer should handle requests in a transaction to the data layer, on 
behalf of the presentation layer, and return responses in value objects.
When the data has been updated in the presentation layer, the business 
logic should receive it in a value object, then update it by a request 
in the data layer, in another transaction.

tx.markDirty() should also be avoided if you do not want to introduce in 
your app an adherence to the OJB implementation of ODMG, but I agree 
this is a matter of concern for the developer of an application, not  
for OJB developers. ;-)

Chuck Cavaness clearly explains these patterns in "Programming Jakarta 
Struts", but unfortunately he does not dive much into using OJB and the 
ODMG API for updates.

So, in my opinion, "tx.markDirty(product)" could be in a FAQ, but not in 
the tutorial. (BTW, I guess you meant TransactionImpl instead of 
TransactionExt).

Thomas Mahler wrote:

> [...]

> Another thing that I'd like to see added in the update section is 
> about long transactions. A lot of users are using the odmg API in web 
> applications, where business objects are modified in the GUI and then 
> persisted by a DAO. So Objects are not modified within a transaction.
> This is really FAQ and I'd be happy if it'd be answered in the tutorial!
>
> to make sure that OJB can still persist the changes made outside the 
> transaction we need the following code:
>
>     public static void persistChanges(Product product)
>     {
>         Implementation impl = OJB.getInstance();
>         TransactionExt tx = (TransactionExt) impl.newTransaction();
>         tx.markDirty(product);
>         tx.commit();
>     }
>
> where TransactionExt is an OJB specific extension to the ODMG 
> Transaction interface that contains helper methods to obtain the 
> underlying PB or to mark objects for DELETE or UPDATE.
>
> thanks,
> Thomas
>
>
>



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


Mime
View raw message