micronaut-projects / micronaut-projects/micronaut-data

@TypeDef doesn't compile reliably

Open
#3,356 12 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

type: bug
Dominant language
Java
Stars
482
Forks
229
Avg merge
1d 7h
Merged PRs (30d)
32

Description

Expected Behavior
@TypeDef(type = DataType.STRING, converter = TaskHandleToStringConverter.class)
public interface TaskHandle {
...
}

@Singleton
class TaskHandleToStringConverter implements AttributeConverter<TaskHandle, String> {
...
}

@MappedEntity
public record WidgetTaskMetadata(@Id TaskHandle id, String requestIpAddress) {}

@JdbcRepository(dialect = Dialect.ORACLE)
public interface WidgetTaskMetadataRepository extends CrudRepository<WidgetTaskMetadata, String> {}

The above should compile consistently without errors.

Actual Behaviour

@TypeDef is sometimes ignored.

error: Unable to implement Repository method: WidgetTaskMetadataRepository.findById(Object id). Parameter [java.lang.String id] is not compatible with property [io.micronaut.tasks.api.TaskHandle id] of entity: com.oracle.labs.graalflow.sample.WidgetTaskMetadata

This seems to happen when I change things in the area of this code. For instance, I just removed a generic type parameter from TaskHandle and now it's broken, although this should not have made any difference to this feature (it's removed everywhere). I've tried doing clean builds with the Gradle build cache disabled, but no luck.

Steps To Reproduce

No response

Environment Information

No response

Example Application

No response

Version

4.7.6

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the @TypeDef, AttributeConverter, WidgetTaskMetadata, and WidgetTaskMetadataRepository declarations in the report, then investigate why @TypeDef is sometimes ignored during compilation. Reproduce the mismatch where findById expects String but the entity property is TaskHandle, and verify that clean builds remain consistent after changes to TaskHandle generics.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
backend, databases
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.