Hi Martin,

That's incorrect regarding mixins, they are separate classes from the
domain object to which they contribute.

For example, the class Customer_firstName is a property mixin,
Customer_updateName is an action mixin.

Regarding FacetFactory, you can take at our source code and you'll find
lots of examples, but before you start first do think what you want your
programming model to look like. I do suspect you'll end up with something
very similar to our mixins.

We can jump on a call if you want, but otherwise, hope that helps.

Dan.

On Mon, 24 Mar 2025, 07:54 Martin Schelldorfer,
<[email protected]> wrote:

> Hi Dan,
> We're flexible and can use JPA or JDO for persistence.
>
> As of my understanding mixins require to modify the original generated
> classes with annotations.
> This is what we want to avoid.
>
> I think FacetFactory is the better option in this case and to modify the
> prog model programmatically.
> Is there an example how to use FacetFactory?
>
> Regards,
> Martin
>
> -----Original Message-----
> From: Dan Haywood <[email protected]>
> Sent: Wednesday, March 5, 2025 2:52 PM
> To: [email protected]
> Subject: Re: use Causeway without modifying Domain Entity classes
>
> Hi Martin,
>
> There's a couple of things to consider here.
>
> First, regarding the persistence metadmodel: when you say these are
> generated domain entities, (as Andi asks) are you generating them as either
> JPA or JDO annotated classes?  If so, then that's fine.  Otherwise, I
> suppose you'll need to provide the ORM-specific metadata in XML files.
>
> Second, regarding Causeway's own metamodel, the easiest solution would be
> to write a bunch of mixins (properties, collections or actions) that
> surface the features that you want.  eg
>
> @Generated
> public class Customer {
>
>     private String firstName;
>     private String lastName;
>
> }
>
> @Property
> @RequiredArgsConstructor
> public class Customer_firstName {
>     private final Customer customer;
>     public String prop() { return customer.firstName; } }
>
> @Action(semantics=IDEMPOTENT)
> @RequiredArgsConstructor
> public class Customer_updateName {
>     private final Customer customer;
>     public Customer act(String firstName, String lastName) {
>         customer.firstName = firstName; customer.lastName = lastName;
>         return customer;
>     }
> }
>
> If you can generate getters, then Causeway will (unless configured not to)
> automatically detect the properties and collections, of course.
>
> Another way to go, which is more powerful but more work, would be to write
> your own FacetFactory's, which can bring in the semantics from wherever you
> want.  For example, you could define a companion class (like a C# partial),
> and merge in its semantics (like a mixin, I suppose, but for the entire
> class).
>
> Let me know if you want more details on the FacetFactory notion.
>
> Cheers
> Dan
>
>
> On Wed, 5 Mar 2025, 11:11 Andi Huber, <[email protected]> wrote:
>
> > Hi Martin,
> >
> > which Causeway version are you on and what persistence mechanism are
> > you using (JDO, JPA or other)?
> >
> > I'm not familiar with openapi-generator, but perhaps it can be
> > configured to emit custom type annotations. Otherwise there are ways
> > to hook into Causeway, but I guess I'm not going into details, until
> > other options are explored.
> >
> > Cheers,
> > Andi Huber
> >
> > On 2025/03/05 10:51:41 Martin Schelldorfer wrote:
> > > Hi,
> > >
> > > We are generating our Domain Entities (Java classes) from an OpenAPI
> > json with openapi-generator.
> > >
> > > To use Causeway annotations in Domain Entity Classes are required.
> > >
> > >
> > >
> > > We don't want to modify the generated Domain Entity Classes.
> > >
> > > What is the best approach to use Causeway without modifying original
> > Domain Entity Classes?
> > >
> > > Derived classes could be an option but makes maintenance more
> > > difficult
> > and expensive...
> > >
> > >
> > >
> > >
> > >
> > >
> > > Freundliche Grüsse / Best Regards
> > > Martin Schelldorfer
> > >
> > >  <http://www.e-switch.ch/>
> > >
> > > e-switch Solutions AG
> > > Consulting, Software and Services
> > > Wolleraustrasse 41b
> > >
> > > CH-8807 Freienbach
> > >
> > >
> > > T
> > >
> > > +41 55 416 11 62
> > >
> > >
> > > M
> > >
> > > +41 79 941 11 62
> > >
> > >  <mailto:[email protected]>
> > [email protected]
> > >  <http://www.e-switch.ch/> www.e-switch.ch
> > >
> > >
> > >
> > > Geschäftsführer: Thorsten Waldner
> > > Handelsregister: CHE-105.346.021
> > >
> > >
> > >
> > >
> > >
> > >
> >
>

Reply via email to