Return-Path: Delivered-To: apmail-db-ojb-dev-archive@www.apache.org Received: (qmail 41277 invoked from network); 2 Oct 2003 05:22:35 -0000 Received: from daedalus.apache.org (HELO mail.apache.org) (208.185.179.12) by minotaur-2.apache.org with SMTP; 2 Oct 2003 05:22:35 -0000 Received: (qmail 79240 invoked by uid 500); 2 Oct 2003 05:22:12 -0000 Delivered-To: apmail-db-ojb-dev-archive@db.apache.org Received: (qmail 79201 invoked by uid 500); 2 Oct 2003 05:22:12 -0000 Mailing-List: contact ojb-dev-help@db.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Subscribe: List-Help: List-Post: List-Id: "OJB Developers List" Reply-To: "OJB Developers List" Delivered-To: mailing list ojb-dev@db.apache.org Received: (qmail 26930 invoked from network); 1 Oct 2003 08:33:39 -0000 Message-ID: <3F7A9170.4030302@voila.fr> Date: Wed, 01 Oct 2003 10:33:52 +0200 From: Philippe Hacquin User-Agent: Mozilla/5.0 (Windows; U; Win98; en-US; rv:1.4) Gecko/20030624 Netscape/7.1 (ax) X-Accept-Language: fr, en-us, en MIME-Version: 1.0 To: OJB Developers List Subject: Re: ODMG Tutorial Take 1 References: <3F7A7003.80808@web.de> In-Reply-To: <3F7A7003.80808@web.de> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N X-Spam-Rating: minotaur-2.apache.org 1.6.2 0/1000/N 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