Return-Path: Delivered-To: apmail-cayenne-user-archive@www.apache.org Received: (qmail 85664 invoked from network); 22 Jul 2009 18:21:16 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 22 Jul 2009 18:21:16 -0000 Received: (qmail 88895 invoked by uid 500); 22 Jul 2009 18:22:21 -0000 Delivered-To: apmail-cayenne-user-archive@cayenne.apache.org Received: (qmail 88882 invoked by uid 500); 22 Jul 2009 18:22:21 -0000 Mailing-List: contact user-help@cayenne.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: user@cayenne.apache.org Delivered-To: mailing list user@cayenne.apache.org Received: (qmail 88841 invoked by uid 99); 22 Jul 2009 18:22:21 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 22 Jul 2009 18:22:21 +0000 X-ASF-Spam-Status: No, hits=-0.0 required=10.0 tests=SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of mkienenb@gmail.com designates 209.85.146.183 as permitted sender) Received: from [209.85.146.183] (HELO wa-out-1112.google.com) (209.85.146.183) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 22 Jul 2009 18:22:13 +0000 Received: by wa-out-1112.google.com with SMTP id n7so66833wag.20 for ; Wed, 22 Jul 2009 11:21:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:in-reply-to:references :from:date:message-id:subject:to:content-type :content-transfer-encoding; bh=90w2HVyWueDim2PK/y3Sw+wr1zSgPzjZzrJH7mBIrTg=; b=elWU2EOSMIO1JzmMqqaMHGklDD4JKEqy0SW6YSUMqSeoI1/QMcwUXarhxbopsph+td /vvkQPkkNelvBkETTqTIQos/8QidljDnw1fLah+Np6pY0dPX8pshgdTijln+L1OCefFH i/67nsxTEQ/liGR66Mn2Mzm/2caIyoo6dai+4= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :content-type:content-transfer-encoding; b=qj6uBF9BklCzYu1o1b0hAPpmUpdWnGxu0Xjez7l9/jLYf+cjbaqOOB1JMZebkK+siR 5P15O1BBFb8WzYTrQjiKmUXus7m8NcFdJAcib9M+gMX0dcUOu1MPJymSoDIEMyQd0l+6 M2cuGmlObFOnsu1mzxDCSDQ16HD89pKe0N9nA= MIME-Version: 1.0 Received: by 10.220.95.129 with SMTP id d1mr1001032vcn.51.1248286912318; Wed, 22 Jul 2009 11:21:52 -0700 (PDT) In-Reply-To: References: From: Mike Kienenberger Date: Wed, 22 Jul 2009 14:21:32 -0400 Message-ID: <8f985b960907221121o1bc70fbfwae3090c7451067ef@mail.gmail.com> Subject: Re: Modification and deletion of data objects To: user@cayenne.apache.org Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-Virus-Checked: Checked by ClamAV on apache.org I'm not aware of anyone else using separate objects for the business level. I use the DataObjects as the business level objects. Yes, if you decide to manually recreate data objects from business objects, there will be some overhead. If I had to go that route, I'd create a central management class and have it cache what objects I already know exist in the data context the first time I reference them rather than searching through the data context lists each time. One possiblity you could consider is to generate interfaces for your DataObjects and then pass the interface rather than the DataObject concrete class. This is what I tend to do in my projects. That way, you can hide all of the Cayenne-specific methods from your other code if you want. Other than some dependencies on Cayenne classes and a couple of other methods, there's not a lot of difference between a Cayenne data object and a "cayenne-free" business representation of the same data. On Wed, Jul 22, 2009 at 2:15 PM, sridhar devatha wrote: > andrus, it is not clear(thank for reply though), i have to try over weeke= nd. > moreover, i can not use context, getEntityName in business object. I wrot= e > business object to data object conversion in data object class it self. s= o I > can use cayenne java api. =A0I have to do it in the data object class whi= ch is > sub class _data object, as it will have reference of business object. But= , > any way I am just surprised to see that there is no modification example > code. Nobody uses cayenne data object from view layer to business/service > layer to data access layer in web or enterprise applications(because it i= s > cayenne data object with several other sensitive methods available. even = if > the methods are not there. I don't want to couple all the layers. ). I do= n't > want to expose that sensitive object. more concrete examples will make it > easier for new developers like me. > I think what Mike Kienenberger(thanks mike , that is what I am also think= ing > at least. by the way what do you say about andrus reply) is telling may b= e > correct. then i have to go thru all the new and modified registered objec= ts > in the data context to see if there is any thing existing. clearly this k= ind > of searching will make it difficult for every data object updation and > deletion. what do you say. > > On Wed, Jul 22, 2009 at 3:45 PM, Andrus Adamchik = wrote: > >> In your business object you will need to know 3 things to map it to a >> Cayenne object: entity name, id, state (new or already persistent). Then= you >> can do something like this (pseudo code of course): >> >> X businessObject =3D ...; >> DataObject cayenneObject; >> Class cayenneObjectClass =3D context.getEntityResolver(). >> =A0 =A0 =A0 getClassDescriptor(businessObject.getEntityName()).getObject= Class(); >> if(bObject.isNew()) { >> =A0cayenneObject =3D context.newObject(cayenneObjectClass); >> } >> else { >> =A0cayenneObject =3D DataObjectUtils.objectForPK(cayenneObjectClass, >> businessObject.getId()); >> } >> >> // merge fields... >> >> Hope I answered the right question. >> >> Andrus >> >> >> On Jul 22, 2009, at 7:47 AM, sridhar devatha wrote: >> >> =A0Hi, >>> >>> I have view layer, business layer and data access layer. Each have >>> separate >>> class for carrying data. But, in data access layer, the object / class >>> used >>> for carrying data is respective data objects. I don't send these object= s >>> beyond my data access layer. Rather I create business objects populated >>> with >>> data object data. When the business functions call data access layer fo= r >>> any >>> of the CRUD operations, they pass these business objects. I convert the= se >>> business objects to data objects(So, I will create data object every ti= me >>> I >>> need to convert business object to data object. So, what happens when t= he >>> two data objects(one dataobject is created while retrieving data. We se= nd >>> the data as business object to business layer. one data object is creat= ed >>> when the user returns the modified =A0data in the form of business obje= ct) >>> of >>> the same class exist with the same data? How can I modify and delete th= e >>> respective rows of these data objects? Please answer any body. I did no= t >>> find any example that does the modification. >>> >>> >>> Yours Sincerely, >>> Devatha Sridhar >>> >> >> > > > -- > > Yours Sincerely, > Devatha Sridhar >