I'd like to expose all IDs using a Spring Rest interface.
I know that per default an ID like this
@Id
@GeneratedValue(strategy=GenerationType.IDENTITY)
@Column(unique=true, nullable=false)
private Long id;
@Configuration
public class RepositoryConfig extends RepositoryRestMvcConfiguration {
@Override
protected void configureRepositoryRestConfiguration(RepositoryRestConfiguration config) {
config.exposeIdsFor(User.class);
}
Currently, there is no way to do this provided by SDR. This issue on the SDR Jira tracker gives some explanation as to why this isn't (and perhaps shouldn't) be possible.
The argument is basically that since the IDs are already contained within the self
links in the response, you don't need to expose them as properties of the object itself.
That said, you may be able to use reflection to retrieve all classes that have a javax.persistence.Id
annotation and then call RepositoryRestConfiguration#exposeIdsFor(Class<?>... domainTypes)
.