Cayenne contains an algorithm to merge multiple projects [1], so you can have 
reusable ORM libraries. However, it does not alter entity structure (as I 
mentioned, there are no "mixins"). So you can use entities from another 
library, but you can't customize them. At least, not out of the box.

I actually like the mixin idea, and we can discuss this concept for the future 
versions. In the interim, you can hack it on your side by implementing a custom 
DataChannelDescriptorMerger [2] (subclassing 
DefaultDataChannelDescriptorMerger). 

Andrus


[1] https://cayenne.apache.org/docs/4.2/cayenne-guide/#merging-multiple-projects
[2] 
https://github.com/apache/cayenne/blob/master/cayenne/src/main/java/org/apache/cayenne/configuration/DataChannelDescriptorMerger.java

> On Sep 1, 2024, at 7:06 PM, Paul Hoadley <pa...@logicsquad.net> wrote:
> 
> Hi Andrus,
> 
> On 1 Sep 2024, at 23:53, Andrus Adamchik <aadamc...@gmail.com> wrote:
> 
>> So partial entities are essentially ORM model "mixins". A neat idea, but 
>> unfortunately not supported by Cayenne. So you'd need to recreate the 
>> contents of each partial entity insider every concrete entity.
> 
> Let me ask a more general question then. How do Cayenne users achieve code 
> reuse (or even entity/model reuse)? Presumably people aren't re-writing their 
> "User" entity, for example, from scratch for every application. Is there any 
> comparable approach for "reuse but customise"?
> 
> 
> -- 
> Paul Hoadley
> https://logicsquad.net/
> https://www.linkedin.com/company/logic-squad/
> 

Reply via email to