micronaut-projects / micronaut-data

Ahead of Time Data Repositories
Apache License 2.0
467 stars 198 forks source link

Entities declared in `jpa.*.mapping-resources` still require `@Entity` and `@Id` annotations #2631

Open aaronjwhiteside opened 1 year ago

aaronjwhiteside commented 1 year ago

Expected Behavior

I should be able to define entity mappings without any annotations using by specifying the mappings in files supplied to the jpa.*.mapping-resources configuration.

Actual Behaviour

Any entity mappings defined by files from the jpa.*.mapping-resources configuration are still required to be annotated with @Entity and @Id or else any repositories you have define will get compile errors.

> Task :backend:services:mn-core-marketplace-service:kspKotlin FAILED
e: [ksp] Unable to implement Repository method: JpaLegalEntityEntityRepository.save(Object entity). No possible implementations found.
e: Error occurred in KSP, check log for detail

Steps To Reproduce

  1. Create a Micronaut Data JPA project
  2. Create a hbm mapping file for the entity.
  3. Remove all jpa annotations from the entity and try and compile the project.

Environment Information

MacOS JDK 17

Example Application

No response

Version

Micronaut Platform: 4.1.6

dstepanov commented 1 year ago

I don't think we want to support mapping using the Hibernate XML format. We might support JPA XML format in the future, which would require those files to be processed by the annotation processor and mirror the equivalent annotations.