You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@cayenne.apache.org by Andrus Adamchik <aa...@gmail.com> on 2026/07/11 20:59:08 UTC

Model simplification - single file, no DataNodes?

I'd like to drastically simplify Cayenne projects:

1. Remove DataNode from the XML. DataNode modeling was an idea from the days of application servers to bypass JNDI insanity. It allowed a developer to quickly connect to a DB. The big problem was that DataSources had to be aware of their environment, so I never used the built in one for instance. There are custom factories, but if you are to use one, you are better off calling it on your own. So I'd rather move everything DataNode related to the runtime builder where it belongs:

CayenneRuntime.builder()
   .dataSource(defaultDS)
   .dataSource(specialDS, "map1", "map2")

or even

CayenneRuntime.builder()
   .dataSource(CayenneDataSource.of("jdbc:...."));

2. No multi-file projects ("cayenne-project.xml" should go away, just leaving DataMap files). I am still hesitant whether we should support more than one DataMap per XML (the only reason is cross-DM relationships, but that's a solid reason). For anything else, Cayenne has project merging facilities for a long time. So you supply multiple projects on startup:

CayenneRuntime.builder()
   .addConfig("p1.xml")
   .addConfig("p2.xml")

3. Remove ObjEntity callbacks support from XML. Just use annotations on entities. This is a runtime feature, not a "mapping" feature.

Thoughts?

Andrus

Callbacks [Re: Model simplification - single file, no DataNodes?]

Posted by Andrus Adamchik <aa...@gmail.com>.
I sat on it for some time, not making this change. But now that I got deeper into the mapping layer overhaul, I am starting to feel stronger about removing callbacks from the XML. They are just so different from all the other mapping artifacts. So they will be preserved in 5.0, but will be gone in 6.0. I hope it is not a huge inconvenience. 

Andrus


> On Jul 12, 2026, at 4:44 PM, Andrus Adamchik <aa...@gmail.com> wrote:
> 
> Hi Jurgen,
> 
> Thanks for the feedback. I actually thought this was the least controversial change of the three :) 
> 
> My thinking is that XML is about "mapping" between DB and Java, whereas callbacks are 100% about runtime object behavior unrelated to mapping. So it naturally belongs in Java and doesn't require an additional ORM abstraction (FWIW, I'd even get rid of annotations and let objects implement explicit callback interfaces for clarity and ease of processing). A similar earlier precedent was when we removed modeling of "listener" (non-entity) callbacks in XML in favor of doing it in the code.
> 
> Andrus
> 
> 
>> On Jul 12, 2026, at 4:16 AM, Jurgen Doll <ju...@ivoryemr.co.za> wrote:
>> 
>> Hi Andrus
>> 
>> With regards to (3) the "Removal of ObjEntity callbacks support from XML" I'm not particularly in favour of this.
>> I like seeing in the model which ObjEntity have whatever callbacks allocated to them.
>> It's like having one source of truth wrt the model, if it's removed then one has to switch between XML model and implementation to see this information.
>> 
>> Thanks, regards
>> Jurgen
> 


Re: Model simplification - single file, no DataNodes?

Posted by Andrus Adamchik <aa...@gmail.com>.
Hi Jurgen,

Thanks for the feedback. I actually thought this was the least controversial change of the three :) 

My thinking is that XML is about "mapping" between DB and Java, whereas callbacks are 100% about runtime object behavior unrelated to mapping. So it naturally belongs in Java and doesn't require an additional ORM abstraction (FWIW, I'd even get rid of annotations and let objects implement explicit callback interfaces for clarity and ease of processing). A similar earlier precedent was when we removed modeling of "listener" (non-entity) callbacks in XML in favor of doing it in the code.

Andrus


> On Jul 12, 2026, at 4:16 AM, Jurgen Doll <ju...@ivoryemr.co.za> wrote:
> 
> Hi Andrus
> 
> With regards to (3) the "Removal of ObjEntity callbacks support from XML" I'm not particularly in favour of this.
> I like seeing in the model which ObjEntity have whatever callbacks allocated to them.
> It's like having one source of truth wrt the model, if it's removed then one has to switch between XML model and implementation to see this information.
> 
> Thanks, regards
> Jurgen


Re: Model simplification - single file, no DataNodes?

Posted by Jurgen Doll <ju...@ivoryemr.co.za>.
Hi Andrus

With regards to (3) the "Removal of ObjEntity callbacks support from XML" I'm not particularly in favour of this.
I like seeing in the model which ObjEntity have whatever callbacks allocated to them.
It's like having one source of truth wrt the model, if it's removed then one has to switch between XML model and implementation to see this information.

Thanks, regards
Jurgen