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