I have migrated a Spring Boot application to Spring Boot 3 and compiled a native image. The application is exposing a simple entity using Spring Data REST (see code below).
During application startup it terminates with complaining that no identifier property has been detected.
Caused by: org.hibernate.AnnotationException: Entity 'at.martinahrer.cd.model.Address' has no identifier (every '@Entity' class must declare or inherit at least one '@Id' or '@EmbeddedId' property)
So it looks like the mapping information of the base class providing the @Id annnotated id property has been lost.
After copying the code of AbstractPersistable to my code base and rebuilding the native image the application starts properly and works.
package at.martinahrer.cd.model;
import lombok.Getter;
import lombok.Setter;
import org.springframework.data.jpa.domain.AbstractPersistable;
import jakarta.persistence.Entity;
@Entity
@Getter
@Setter
public class Address extends AbstractPersistable<Long> {
private String line1;
private String line2;
private String zip;
private String city;
private String state;
private String country;
}
So is some more configuration required? I added the hibernate plugin as this is suggested by the wizards of start.spring.io.