andrus, it is not clear(thank for reply though), i have to try over weekend.
moreover, i can not use context, getEntityName in business object. I wrote
business object to data object conversion in data object class it self. so I
can use cayenne java api. I have to do it in the data object class which 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 is
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 don'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 thinking
at least. by the way what do you say about andrus reply) is telling may be
correct. then i have to go thru all the new and modified registered objects
in the data context to see if there is any thing existing. clearly this kind
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 <andru..bjectstyle.org>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 = ...;
> DataObject cayenneObject;
> Class cayenneObjectClass = context.getEntityResolver().
> getClassDescriptor(businessObject.getEntityName()).getObjectClass();
> if(bObject.isNew()) {
> cayenneObject = context.newObject(cayenneObjectClass);
> }
> else {
> cayenneObject = 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:
>
> Hi,
>>
>> 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 objects
>> beyond my data access layer. Rather I create business objects populated
>> with
>> data object data. When the business functions call data access layer for
>> any
>> of the CRUD operations, they pass these business objects. I convert these
>> business objects to data objects(So, I will create data object every time
>> I
>> need to convert business object to data object. So, what happens when the
>> two data objects(one dataobject is created while retrieving data. We send
>> the data as business object to business layer. one data object is created
>> when the user returns the modified data in the form of business object)
>> of
>> the same class exist with the same data? How can I modify and delete the
>> respective rows of these data objects? Please answer any body. I did not
>> find any example that does the modification.
>>
>>
>> Yours Sincerely,
>> Devatha Sridhar
>>
>
>
--Yours Sincerely, Devatha Sridhar
This archive was generated by hypermail 2.0.0 : Wed Jul 22 2009 - 14:15:54 EDT