You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@cayenne.apache.org by Randy Leonard <ra...@hotmail.com> on 2006/07/15 22:13:46 UTC

One application, multiple models

It seems Cayenne requires one holistic model for an application (e.g. one 
Cayenne.xml file).  Is this true?  Can I break up the model into multiple 
sub-models (e.g. nodes and maps) and distribute throughout my class library?

For example, my architecture consists of multiple Eclipse projects (e.g. 
foundation, various business logic domains, user interface, etc.), most of 
which require their own model.  These projects are subsequently combined as 
required to form executables.

EOF had let me divide my model as required, and it would be dynamically 
combine the sub-models into a larger holistic models as it located them 
within the runtime.  I would like to do something similar here.

So some questions:
1. Is there only one cayenne.xml file permitted per executable?
2. Can I hand-edit cayenne.xml to reference various nodes and maps in 
various projects?
3. What will happen if cayenne.xml references 5 nodes in 5 distinct 
projects, but only 3 of those projects are linked into an application?

On the latter point, I understand the need to ensure cross-model 
relationships do not introduce "class not found" errors.  But any other 
concerns?

Thanks,
Randy



Re: One application, multiple models

Posted by Andrus Adamchik <an...@objectstyle.org>.
Runtime stack supports what you are describing, but the stack loading  
mechanism (Configuration, ConfigLoaderDelegate, RuntimeLoadDelegate)  
does not at the moment. We are planning to improve this soon [1]. But  
you can still achieve this in a number of ways.

For instance you can subclass DefaultConfiguration, overriding  
"initialize" to load multiple cayenne.xml files available on  
classpath (ClassLoader.getResources("cayenne.xml")) and merging them  
together by domain name.

Now answering your specific questions...

> 1. Is there only one cayenne.xml file permitted per executable?

Yes, only if you use DefaultConfiguration, but you can subclass it  
and override the loading logic (see above).

> 2. Can I hand-edit cayenne.xml to reference various nodes and maps  
> in various projects?

Absolutely.

> 3. What will happen if cayenne.xml references 5 nodes in 5 distinct  
> projects, but only 3 of those projects are linked into an application?

IIRC failed pieces do not generate an exception. They are simply  
logged and can be accessed via Configuration.getLoadStatus().

Andrus

[1] http://objectstyle.org/confluence/display/CAY/3.0+Wish+List


On Jul 15, 2006, at 4:13 PM, Randy Leonard wrote:

> It seems Cayenne requires one holistic model for an application  
> (e.g. one Cayenne.xml file).  Is this true?  Can I break up the  
> model into multiple sub-models (e.g. nodes and maps) and distribute  
> throughout my class library?
>
> For example, my architecture consists of multiple Eclipse projects  
> (e.g. foundation, various business logic domains, user interface,  
> etc.), most of which require their own model.  These projects are  
> subsequently combined as required to form executables.
>
> EOF had let me divide my model as required, and it would be  
> dynamically combine the sub-models into a larger holistic models as  
> it located them within the runtime.  I would like to do something  
> similar here.
>
> So some questions:
> 1. Is there only one cayenne.xml file permitted per executable?
> 2. Can I hand-edit cayenne.xml to reference various nodes and maps  
> in various projects?
> 3. What will happen if cayenne.xml references 5 nodes in 5 distinct  
> projects, but only 3 of those projects are linked into an application?
>
> On the latter point, I understand the need to ensure cross-model  
> relationships do not introduce "class not found" errors.  But any  
> other concerns?
>
> Thanks,
> Randy
>
>
>