Pergunta

I have a data access layer represented by an Eclipse project. I use Hibernate 3 as persistence framework. So, in this project, I have my annotated entities and the resources used by Hibernate (persistence.xml, XXX.cfg.xml).

My question now is more about how QA and production. I have other projects that use this data access layer. Also, my entities may be modified during the project evolution. When I release one of these projects to QA, and that the data access layer has been modified (entities modifications), the QA database has to been modified accordingly. And that's the same for production.

What are the best practices for this scenario? I use Maven as build system. Do you think the use of hibernate3-maven-plugin is appropriated for this case?

Thanks for your help!

Foi útil?

Solução

I would recommend against using hibernate3-maven-plugin (with hbm2ddl.auto) in production/QA because it might have undesired/unexpected side effects. I think I read somewhere that the Hibernate creators themselves actually recommend against using hbm2ddl.auto in production.

It is best to just write your own SQL patches to change the database schema (It will be better optimised as well).

To keep track of the scripts we have directories (in source control) corresponding to a software version (example: 1.14.1) and all SQL patches for changes to run for a specific version (we make sure to keep them re-runnable without side effects) are kept there. When deploying 1.14.1 we run the required scripts for the software release (we also have a script that can automatically run all the required scripts but usually it is done manually).

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top