Kotlin data class implementing Java interface

The problem here is that Kotlin loads the Java class Entity first and it sees getId as a function, not as a getter of some property. A property getter in a Kotlin class cannot override a function, so the property id is not bound as an implementation of the getId function.

To workaround this, you should override the original function getId in your Kotlin class. Doing so will result in JVM signature clash between your new function and id's getter in the bytecode, so you should also prevent the compiler from generating the getter by making the property private:

data class Video(
    private val id: Long,
    ...
): Entity {
    override fun getId() = id

    ...
}

Note that this answer has been adapted from here: https://stackoverflow.com/a/32971284/288456


If this is your whole data class then you're not overriding getId(). I see that you have a property called id and Kotlin should generate a getter for that but that won't be marked with the override keyword which you need to indicate that you're overriding an abstract function.

-- EDIT -- Alexander beat me to it! His answer is better anyway! ;)