mercredi 6 mai 2015

Reuse hibernate import.sql between dependent projects

To keep my programs modular my solutions share maven modules like:

  • Accounting solution
    • Geographic module (tables, data, services about cities, regions, countries)
    • Multicurrency solution (currencies, exchange rates, etc)
    • Other common project
    • Etc.
  • Online web
    • Geographic module (tables, data, services about cities, regions, countries)
    • Multicurrency solution (currencies, exchange rates, etc)
    • Batch file data importer
    • Etc.
  • Etc.

I use integration test and preload data with hibernate hbm2ddl.import_files. Each solution and module has it's own import.sql. So I have to stored in /src/test/resources/ a copy if the imports of this project and all its dependents modules. Hibernate configuration has:

<prop key="hibernate.hbm2ddl.auto">create-drop</prop>               
<prop key="hibernate.hbm2ddl.import_files">import_geographic.sql,import_currency.sql,import_files.sql, import_accounting.sql</prop>             

Everytime I update the data I need to update all solutions and dependent modules. I would like to have a single copy of every import_*.files in a maven friendly way. I thought of including them in a testing project but I do not know how to tell hibernate to look inside a .jar file.

Aucun commentaire:

Enregistrer un commentaire