Skip to content

[Use Case]: Annotations for use with Jakarta Persistence #470

@gavinking

Description

@gavinking

As a ...

  • Application user/user of the configuration itself
  • API user (application developer)
  • SPI user (container or runtime developer)
  • Specification implementer

I need to be able to ...

write a portable repository backed by JPA.

Which enables me to ...

be more independent of the Jakarta Data provider.

Additional information

So I know we all said we didn't want to do this in this release. But with all the machinery we've defined, it's now frankly trivial.

We would add:

  • lifecycle annotations @Persist, @Merge, @Refresh, @Lock, @Remove, and @Detach, and
  • query annotations @JPQL and I guess also @SQL

in new package jakarta.data.orm.

The semantics of the lifecycle annotations are completely defined by the JPA spec. Because they're specific to JPA/ORM, we have zero work to do, it's just a @see annotation that points to the corresponding operation of EntityManager.

It's similarly clear what @JPQL does. On the other hand, perhaps we don't need it and all we need to do is give people explicit permission to put their JPQL in the @Query annotation. (I can see arguments both ways.)

Finally, if I recall correctly, at some stage someone (Otavio I guess) had proposed a built-in JpaRepository. I don't argue that we need it, but if you all still want it, it's completely trivial to define in terms of the annotations listed above.

So why is this now so easy when previously it was "hard". Well, before, we were trying to shoehorn JPA into the existing @Save annotation or whatever. But now that our model of lifecycle annotations is extensible, it's no longer hard.

Dunno. I guess I feel like it's now become a bit hard to justify not doing it.

Reactions?

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions