quarkusio / quarkus

Quarkus: Supersonic Subatomic Java.
https://quarkus.io
Apache License 2.0
13.82k stars 2.69k forks source link

Panache: Incorporate features from EBean ORM for Panache or join development effort? #31792

Open tmulle opened 1 year ago

tmulle commented 1 year ago

Description

One of the legacy projects I'm working on converting from a Play/Scala/EBean ORM application to run on Quarkus uses EBean ORM instead of JPA/Hibernate. It was written 10+ years ago.

I want to be 100% quarkus eco-system so I can work with the DEV mode.

And unfortunately, EBean doesn't work with quarkus DEV mode, and the developer is only one person.

During the conversion of the data layer I find EBean has a lot of nice syntax for building queries that Panache I think could benefit from if you want to make it a "simplified" Hibernate alternative.

I'm not affiliated with EBean in anyway, just was introduced through my current conversion.

I think it might be worth while for the developers of Panache to reach out to the creator of EBean (if you haven't already) and maybe work together to join forces on JPA persistence.

The author claims he does a lot of things "correctly" that Hibernate gets wrong, and he does other "optimizations", etc.

I can't validate those, I just really like the syntax of building queries. I find myself having to manually rewrite the old legacy code into raw JPA/HQL when I have to search on more than one field/criteria in Panache.

For example, here is how I have to rewrite queries, not terrible for this example, but gets pretty involved when the criteria because larger with more fields and things like iLike, ne, gt, etc.

// EBean
List<CrumbModel> allModels = CrumbModel.find.query().where().ne("modelName", "ALL").order().asc("modelName").findList();

// Panache
List<CrumbModel> allModels = CrumbModel.list("modelName != :name", Sort.ascending("modelName"), Parameters.with("name", "ALL"));

Here is another example of doing FETCHES in EBean:

if (currUser.isPrivleged()) {
            expOrg = OrgUser.find.query().fetch("user").where().like("user.email", term);
        } else {
            expOrg = OrgUser.find.query().fetch("user").where().eq("org.orgId", currUser.getOrg().getOrgId()).like("user.email", term);
        }

Just a thought...

https://ebean.io

Implementation ideas

No response

quarkus-bot[bot] commented 1 year ago

/cc @FroMage (panache), @loicmathieu (panache)

melloware commented 1 year ago

@tmulle have you checked out JPA streamer instead of Panache? It looks more like EBean.

See: https://github.com/quarkiverse/quarkus-jpastreamer

rbygrave commented 1 year ago

JPA streamer

Ebean query beans are similar to JPA streamer - https://ebean.io/docs/query/query-beans ... for writing queries in a more type safe manor.

With Ebean query beans (type safe) you'd write that first query as:

List<CrumbModel> allModels = 
  new QCrumbModel()
    .modelName.ne("ALL")
    .orderBy().modelName.asc()
    .findList();

... QCrumbModel as a "query bean" that is generated via an annotation processor.