Cześć,
Zacznę od tego, że szukałem na różnych forach rozwiązania tego problemu, niestety wszystkie proponowane rozwiązania u mnie nie działały. Piszę projekt imitujący zachowanie bloga, chciałem zacząć pisać testy integracyjne z wykorzystaniem JUnit 5 i bazy H2 inmemory.
Problem jest taki:
Failed to execute SQL script statement #1 of URL [file:/E:/IntelliJ%20IDEA/projects/blog_mj/out/test/resources/data.sql]: insert into user (created_date, email, last_updated_date, password, username) values ( '2018-12-28 00:51:33', 'lizak0@live.com', '2018-05-03 13:31:25', 'nkfmVFGsXF', 'munwins0'); nested exception is org.h2.jdbc.JdbcSQLException: Unique index or primary key violation: "UK_OB8KQYQQGMEFL0ACO34AKDTPE_INDEX_2 ON PUBLIC.USER(EMAIL) VALUES ('lizak0@live.com', 1)"; SQL statement:
insert into user (created_date, email, last_updated_date, password, username) values ( '2018-12-28 00:51:33', 'lizak0@live.com', '2018-05-03 13:31:25', 'nkfmVFGsXF', 'munwins0')
Dzieje się to przy próbie odpalenia testu integracyjnego, wtedy, kiedy aplikacja próbuje załadować kontekst. Plik .sql, z którego robię inserty:
insert into user (created_date, email, last_updated_date, password, username)
values ( '2018-12-28 00:51:33', 'lizak0@live.com', '2018-05-03 13:31:25', 'nkfmVFGsXF', 'munwins0');
insert into user (created_date, email, last_updated_date, password, username)
values ('2019-03-10 14:14:49', 'dchallin1@disqus.com', '2018-08-18 23:35:15', 'U6qZxNg7MHLY', 'fknibb1');
insert into user ( created_date, email, last_updated_date, password, username)
values ( '2018-08-26 22:38:12', 'enattriss2@wired.com', '2018-06-25 06:20:44', 'x4ZgJPYdr0', 'vchippindale2');
insert into user ( created_date, email, last_updated_date, password, username)
values ( '2018-08-02 07:39:46', 'tbarrett3@ca.gov', '2018-09-06 13:34:16', 'PNL635jpw', 'ccanniffe3');
insert into user ( created_date, email, last_updated_date, password, username)
values ( '2018-05-31 22:28:19', 'wverity4@home.pl', '2018-04-20 05:51:20', 'khL3XK', 'epochin4');
Z tych komunikatów, to jeśli dobrze rozumiem, zaburzyłem unikalność na kolumnie email, tylko że w insertach nigdzie nie mam duplikatów. Wie ktoś jak rozwiązać problem? Byłbym bardzo wdzięczny :D