I have a question about initializing data in Spring-Boot. I have this :
@PostConstruct
public void run() {
try {
upload(path);
logger.info("Seeding dictionary database...");
} catch (IOException e) {
//.....
}
}
run() method read .json file and fills the database with information from the file when the app starts. But I also have a .sql file that also fills the database when starts. The table created from initialization from the .sql file is related to the table created from the .json file
When app starts i have
INSERT INTO "USER_DICTIONARY"("DICTIONARY_ID", "USER_ID") VALUES (1, 0)
I have this line in my import.sql but this causes errors because DICTIONARY_ID doesn't exist jet because it comes from .json file which is loaded after import.sql The data retrieved from the .json file is needed to correctly map this table when the sql file is executing.
Is it possible to execute my run() methody before executing .sql file, or can it be solved in some other way ? If so, please help me find the answer.
