Closed
Description
AbstractPersistable
defines a protected
setter for the id
property which will by default be omitted by the framework support only considering public
methods. This results in the following reflection configuration
{
"name": "org.springframework.data.jpa.domain.AbstractPersistable",
"methods": [
{
"name": "isNew",
"parameterTypes": [ ]
},
{
"name": "getId",
"parameterTypes": [ ]
}
]
},
Also the @Id
annotation is present directly on the id
property which would in turn not get registered if the field does not show up in the reflection config. Because of all this the JPA mapping for the id
property does not work as expected preventing application start.
Caused by: org.hibernate.AnnotationException: Entity '...' has no identifier (every '@Entity' class must declare or inherit at least one '@Id' or '@EmbeddedId' property)
Till the issue is solved one may use RuntimeHintsRegistrar
providing the required hints as outlined below.
@SpringBootApplication
@ImportRuntimeHints(ApplicationHints.class)
public class Application {
// ...
static class ApplicationHints implements RuntimeHintsRegistrar {
public void registerHints(RuntimeHints hints, ClassLoader classLoader) {
hints.reflection().registerType(AbstractPersistable.class, DECLARED_FIELDS, INVOKE_DECLARED_METHODS);
}
}
}