micronaut-projects / micronaut-projects/micronaut-data
@TypeDef doesn't compile reliably
Nobody has claimed this yet.
- 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
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- 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