Re: Migrating from EOF → Cayenne: partial e ntities

Andrus Adamchik <[email protected]> Sun, 1 Sep 2024 10:23:09 -0400
Newsgroups gmane.comp.java.cayenne.user
Message-ID <[email protected]>
Hi Paul,

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.

Andrus

> On Aug 31, 2024, at 9:51 PM, Paul Hoadley <[email protected]> wrote:
> 
> Hello,
> 
> As part of a review of how we might migrate from EOF → Cayenne, I ran into our usage of Project Wonder's "partial entities":
> 
> https://jenkins.wocommunity.org/job/Wonder7/lastSuccessfulBuild/javadoc/er/extensions/partials/package-summary.html
> 
> In brief, this feature allows you to have a "base" entity, say "User", which you might have in a library-style project shared by multiple applications. Maybe it has attributes like "firstName", "lastName" and "password". Then, at the application level, you can create a "partial" entity, say "FooUser", on the "User" base entity. Maybe FooUser has an attribute "isSupervisor", relevant only to this app. At runtime, the models are merged such that User is the union of its properties and FooUser's properties, and the underlying table has all of these columns. The backing classes are distinct, though: in general, you'd work with Users, but if you need a FooUser, you ask the relevant User for its FooUser. The win is that you're not re-inventing User for every new app. It resembles single table inheritance, but FooUser is not a subclass of User.
> 
> How would I do this in Cayenne?
> 
> 
> -- 
> Paul Hoadley
> https://logicsquad.net/
> https://www.linkedin.com/company/logic-squad/
>