question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Unable to implement Repository method with java repository and Kotlin data class as Entity

See original GitHub issue

Task List

  • Steps to reproduce provided
  • Stacktrace (if present) provided
  • Example that reproduces the problem uploaded to Github
  • Full description of the issue provided (see below)

Steps to Reproduce

  1. Create Micronaut Data application in Java
  2. Create Kotlin data class as Entity
  3. Create JdbcRepository for Entity in Java
  4. Build project

Expected Behaviour

Project should build without error.

Actual Behaviour

Gradle build fails at step kaptKotlin with message:

> Task :kaptKotlin
e: error: Unable to implement Repository method: BookRepository.update(Object arg0). Invalid query method [update] of repository [de.braeluca.javakotlin.BookRepository]: No id found for name entity: null
> Task :kaptKotlin FAILED

Environment Information

  • Operating System: Windows 10
  • Micronaut Version: 1.3.0.RC1
  • JDK Version: 1.8

Example Application

However, if you replace @Id with @EmbeddedId and make corresponding changes to Entity and Repository, it will work just fine.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

4reactions
graemerochercommented, Feb 20, 2020

The annotation has to be applied to the field:

@field:Id
var id: String? = null
0reactions
braelucacommented, Feb 20, 2020

Thanks it works now

Read more comments on GitHub >

github_iconTop Results From Across the Web

Micronaut Unable to implement Repository method ...
Hmm entity is OK. This exception is often caused by missing @Entity annotation. But not in this case. Can you try to remove...
Read more >
Micronaut Framework/questions - micronautfw/questions - Gitter
Is micronaut-data having issues with Kotlin data classes? First I had to use @field:Id ... @Id val id => error: Unable to implement...
Read more >
Working with Kotlin and JPA - Baeldung
In this tutorial, we'll explore how to use Kotlin Classes as JPA entities. 2. Dependencies.
Read more >
Spring Data JDBC - Reference Documentation
This prevents Spring Data to try to create an instance of it directly and failing because it can't determine the entity for that...
Read more >
Micronaut Data - GitHub Pages
You can use Java 16 records or Kotlin immutable data classes. Integrated support for R2DBC, ... Querying - define a repository method to...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found