Does anyone know how I can import the file import.sql only once?
Basically I have multiple entitymanagers. Each time an entitymanager is created it tries to import the sql from import.sql (so says the hibernate docs). However this results in an Exception the second time an EM is created.
Isn’t there a way to find out during runtime if the import file has already been used?
Ok, I am not sure this is the best way, but it is an easy solution. If you create the Entitymanager like this (below) you just need to remove the property “hibernate.hbm2ddl.auto” once the first EntityManager is created:
Besides I have seen that the import.sql allows terms like “DROP TABLE IF EXISTS”. I initially missed that, as I was used to working with Oracle and this also caused errors like “user lacks privilege or object not found : SOME_TABLE”