micronaut-projects / micronaut-projects/micronaut-data

Detect at compile time if the argument type for an entity is not the entity type

Open
#557 1 comment 0 reactions 0 assignees View on GitHub
type: improvement
Dominant language
Java
Stars
482
Forks
229
Avg merge
1d 7h
Merged PRs (30d)
32

Description

I tried to write an update method that just took the ID of an association, since the association id is stored in the table. Note this is a JDBC repository

`int update(@Id Long id, String name, Long category);`

```
@Relation(value = Relation.Kind.MANY_TO_ONE)
private Category category;
```

It failed at runtime trying to get a bean introspection for `Long`

Ideally it would be possible to do what I tried, however an error at compile time is an improvement

Contributor guide

Open the contributing guide

Research direction

Start by reproducing the JDBC repository update declaration with a Long argument for the Category association, then trace the compile-time validation that currently permits it to reach runtime bean introspection. Done means either the association ID form works as requested or an actionable compile-time error identifies that the argument type must be Category.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
database
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.