I have a Java EE application which use SQL Server Express as backend database. When we deploy new version sometime we need to change the database: add tables, add columns, remove columns, merge tables, merge column, etc.
Until today we use offline SQL scripts to modify the database but this solution is not scalable and very error-prune.
We start use a singleton startup bean which has @PostConstruct decorated method to add and remove data which is used by the system during deployment.
We now want to also issue DML statements so we can upgrade our database during deployment and eliminate the SQL scripts once and for all.
- Has anyone try to do it, is that good direction?
- Should we use entityManager.unwrap method or simply inject the JDBC DataSource resource into our singleton startup bean?