Sometimes the createEntitymanagerFactory can take a while, specially if the database needs to be created.
I'm using Flyway for my database and started finding issues during migration. Looking at the logs it seems like I'm trying to migrate before the tables have been created. For example
Table "XINCO_CORE_USER" not found; SQL statement:
INSERT INTO `xinco_core_user` (`id`, `username`, `userpassword`, `last_name`, `first_name`, `email`, `status_number`, `attempts`, `last_modified`) VALUES (1, 'admin', '21232f297a57a5a743894a0e4a801fc3', 'Administrator', 'Xinco', 'admin@xinco.org', 1, 0, now()) [42102-168]
JPA is set up to create the tables. When I enable the logs in JPA it shows that the error above happens before JPA is done creating the database.
Is there a way to listen on the JPA database to know when it is ready? I only found listeners for entities themselves but nothing for the PersistenceManager life cycle.