I\'d like to expose all IDs using a Spring Rest interface.
I know that per default an ID like this will not be exposed via the rest interface:
@I
I discovered that if you name the @Id field 'Id' it will display in the JSON if you have a public getter for the Id. The Id will show up as a JSON key called 'id'
For example: @Id @Column(name="PERSON_ROLE_ID") private Long Id;
This also works for @EmbeddedId fields called 'Id' as well as long as it has a public getter. In this case the fields of the Id will show up as a JSON object.
For example: @EmbeddedId private PrimaryKey Id;
Surprisingly this is case sensitive, calling id 'id' doesn't work even though it would be a more conventional name for a Java field.
I should say that I discovered this completely by accident so I don't know if this is an accepted convention or will work with previous or future versions of Spring Data and REST. Therefore I have included the relevant parts of my maven pom just incase it's sensittive to versions...
org.springframework.boot
spring-boot-starter-parent
1.4.0.RELEASE
UTF-8
UTF-8
1.8
org.springframework.boot
spring-boot-starter-data-jpa
org.springframework.boot
spring-boot-starter-test
test
org.springframework.boot
spring-boot-starter-data-rest
com.oracle
ojdbc7
12.1.0.2
com.h2database
h2