Skip to content

Commit 1a008f6

Browse files
committed
Many-to-many Set and Order By
1 parent 0350579 commit 1a008f6

File tree

2 files changed

+17
-14
lines changed

2 files changed

+17
-14
lines changed

HibernateSpringBootManyToManySetAndOrderBy/src/main/resources/application.properties

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ spring.datasource.password=root
55
spring.jpa.hibernate.ddl-auto=create
66
spring.jpa.show-sql=true
77

8-
spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.MySQL5Dialect
8+
spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.MySQL8Dialect
99

1010
spring.datasource.initialization-mode=always
1111
spring.datasource.platform=mysql
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,18 @@
1-
insert into author (age, name, genre, id) values (23, "Mark Janel", "Anthology", 1);
2-
insert into author (age, name, genre, id) values (51, "Quartis Young", "Anthology", 2);
3-
insert into author (age, name, genre, id) values (38, "Alicia Tom", "Anthology", 3);
4-
insert into author (age, name, genre, id) values (56, "Katy Loin", "Anthology", 4);
5-
insert into author (age, name, genre, id) values (38, "Martin Leon", "Anthology", 5);
6-
insert into author (age, name, genre, id) values (56, "Qart Pinkil", "Anthology", 6);
1+
-- insert authors
2+
INSERT INTO author (`age`, `name`, `genre`, `id`) VALUES (23, "Mark Janel", "Anthology", 1);
3+
INSERT INTO author (`age`, `name`, `genre`, `id`) VALUES (51, "Quartis Young", "Anthology", 2);
4+
INSERT INTO author (`age`, `name`, `genre`, `id`) VALUES (38, "Alicia Tom", "Anthology", 3);
5+
INSERT INTO author (`age`, `name`, `genre`, `id`) VALUES (56, "Katy Loin", "Anthology", 4);
6+
INSERT INTO author (`age`, `name`, `genre`, `id`) VALUES (38, "Martin Leon", "Anthology", 5);
7+
INSERT INTO author (`age`, `name`, `genre`, `id`) VALUES (56, "Qart Pinkil", "Anthology", 6);
78

8-
insert into book (isbn, title, id) values ("001-all", "Encyclopedia", 1);
9+
-- insert books
10+
INSERT INTO book (`isbn`, `title`, `id`) VALUES ("001-all", "Encyclopedia", 1);
911

10-
insert into author_book (author_id, book_id) values (1, 1);
11-
insert into author_book (author_id, book_id) values (2, 1);
12-
insert into author_book (author_id, book_id) values (3, 1);
13-
insert into author_book (author_id, book_id) values (4, 1);
14-
insert into author_book (author_id, book_id) values (5, 1);
15-
insert into author_book (author_id, book_id) values (6, 1);
12+
-- insert in the junction table
13+
INSERT INTO author_book (`author_id`, `book_id`) VALUES (1, 1);
14+
INSERT INTO author_book (`author_id`, `book_id`) VALUES (2, 1);
15+
INSERT INTO author_book (`author_id`, `book_id`) VALUES (3, 1);
16+
INSERT INTO author_book (`author_id`, `book_id`) VALUES (4, 1);
17+
INSERT INTO author_book (`author_id`, `book_id`) VALUES (5, 1);
18+
INSERT INTO author_book (`author_id`, `book_id`) VALUES (6, 1);

0 commit comments

Comments
 (0)