2
2
:source-highlighter: highlight.js
3
3
Rashidi Zin <rashidi @zin.my >
4
4
1.0, July 13, 2025
5
- :toc:
6
5
:nofooter:
7
6
:icons: font
8
7
:url-quickref: https://github.com/rashidi/spring-boot-tutorials/tree/master/data-rest-composite-id
@@ -21,7 +20,7 @@ This example demonstrates how to implement and expose entities with composite ID
21
20
22
21
== Entity Classes
23
22
24
- In this example, we have two entity classes: `Book`[$ {source-main}/book/Book.java] and `Author`[$ {source-main}/book/Author.java].
23
+ In this example, we have two entity classes: link: {source-main}/book/Book.java[`Book` ] and link: {source-main}/book/Author.java[`Author` ].
25
24
Both use composite IDs implemented as embedded classes.
26
25
27
26
=== Book Entity
@@ -233,13 +232,13 @@ void create() {
233
232
.post().uri("/books")
234
233
.content("""
235
234
{
236
- "isbn": "9781509827829 ",
235
+ "isbn": "9781402745777 ",
237
236
"title": "The Jungle Book",
238
237
"author": "http://localhost/authors/100"
239
238
}
240
239
""")
241
240
.assertThat().headers()
242
- .extracting(LOCATION).asString().isEqualTo("http://localhost/books/9781509827829 ");
241
+ .extracting(LOCATION).asString().isEqualTo("http://localhost/books/9781402745777 ");
243
242
}
244
243
----
245
244
@@ -251,8 +250,8 @@ This test creates a Book with an ISBN, title, and author reference, then verifie
251
250
----
252
251
@Test
253
252
@Sql(statements = {
254
- "INSERT INTO author (id, first_name, last_name) VALUES (100 , 'Rudyard', 'Kipling')",
255
- "INSERT INTO book (prefix, registration_group, registrant, publication, check_digit, author_id, title) VALUES (978, 1, 509, 82782, 9, 100 , 'The Jungle Book')"
253
+ "INSERT INTO author (id, first_name, last_name) VALUES (200 , 'Rudyard', 'Kipling')",
254
+ "INSERT INTO book (prefix, registration_group, registrant, publication, check_digit, author_id, title) VALUES (978, 1, 509, 82782, 9, 200 , 'The Jungle Book')"
256
255
})
257
256
@DisplayName("Given a book is available When I request by its ISBN Then its information should be returned")
258
257
void get() {
0 commit comments