cayenne-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Robert Zeigler <robe...@puregumption.com>
Subject Re: Relationships of unsaved object
Date Thu, 05 Jun 2008 18:11:32 GMT
Hi Mike,

Just to clarify, you can set an unregistered object as the target of a  
relationship without first registering the object; the trick is that  
the other end of the relationship has to be registered. :)

So you can't associated two unregistered objects together, but  
associating an unregistered object with a registered object will  
result in the auto-registration of your unregistered object.

As for DAO vs. cayenne "classic" architecture: Cayenne "classic" was  
modeled a lot after EOF.  So, you're right about different paradigms.

As for the merits of DAO... there are certainly merits to true DAO.   
But there are merits to the "classic cayenne" approach, as well.

As an example, a web application I wrote last year is capable, with  
two "pages/screens/whatever you want to call them" total, of adding,  
editing, and viewing over 30 different entities; the app also  
automatically "picks up" new objects added to the schema, and  
automatically picks up changes made to existing objects in the  
schema.  The "view" page lets you jump back and forth between entity  
relationships, and sorting on arbitrary attributes, and filtering.   
And the sorting all happens on the database side, as long as the  
property in question has an associated database path.  Although you  
could do this with a DAO approach, as well, cayenne's strengths of  
having rich objects, with rich metadata support, really go a long way  
to making this sort of thing doable.

Cheers,

Robert

On Jun 5, 2008, at 6/58:48 AM , Michał Morzywołek wrote:

> Thank you for your help.
>
> Of course i know about the newObject() method and so on :)
> What im really trying to do is to separate Caynne from POJOs so i  
> could set
> up "clear" DAO layer.
> I wanted to have "saving" instructions in the DAO objects - i was  
> going to
> use "registerObject()" method - and this is where the problems with
> relationships begin.
> I just have to registrate object to Cayenne before doing anything.In  
> my
> (maybe dumb) opinion is not exackly how DAO layer should work (have to
> "save" object before doing anything).
>
> As far as i understand Hibernate was created to fit DAO model - and  
> it works
> perfectly.
> Cayenne seems to have very different architecture in this matter.  
> With the
> need of registering the new objects in Cayenne (at the start) it's  
> hard to
> create perfectly "sterile" DAO layer.
> It is possible but its much slower then using newObject() method and  
> just
> "mixing it all".
> Cayenne wasn't created to work with "sterile" DAO layer, was it?:)
>
> Regards,
> Mike
>
> 2008/6/5 Aristedes Maniatis <ari@ish.com.au>:
>
>>
>> On 05/06/2008, at 10:34 PM, Michał Morzywołek wrote:
>>
>> Person p=new Person(); //not registered in cayenne
>>>
>>> after doing that i can't set any relationships (like with the  
>>> address).
>>> (1)
>>>
>>> After i register Person p in Cayenne i can set up relationships  
>>> but only
>>> with registered objects. (2)
>>>
>>> Is there any way to do such things? (1)(2)
>>> Or it is supposed to be like that?
>>>
>>
>> You will need to create your new object like this:
>>
>> Person p = (Person) context.newObject(Person.class);
>>
>>
>> Cayenne 3 does have the ability to work with POJOs, but traditional  
>> Cayenne
>> API differs from Hibernate in this important way. Have a look at
>> http://cayenne.apache.org/doc/tutorial-dataobjects.html for more
>> information.
>>
>> Ari Maniatis
>>
>>
>>
>> -------------------------->
>> ish
>> http://www.ish.com.au
>> Level 1, 30 Wilson Street Newtown 2042 Australia
>> phone +61 2 9550 5001   fax +61 2 9550 4001
>> GPG fingerprint CBFB 84B4 738D 4E87 5E5C  5EFA EF6A 7D2E 3E49 102A
>>
>>
>>


Mime
View raw message