Problem with hibernate.hbm2ddl.auto : drop-create
Hi there,
I am having a problem with my configuration.
I am writing a spring application and I us the config from one of the spring data rest example apps.
If I use the config as is, I have the problem, that old data is kept, even after a server restart. (Posted another message about this before)
Therefore, I wanted to add the hibernate.hbm2ddl.auto : drop-create to the config (The block that's comment in the code blow).
But, if I add that option I get the error:
org.hsqldb.HsqlException: user lacks privilege or object not found
If I remove the option, everything works fine again.
Does anyone have a tip on how to solve this error? Google couldn't help...
Thanks
Dominik
Code:
@Bean public DataSource dataSource() {
EmbeddedDatabaseBuilder builder = new EmbeddedDatabaseBuilder();
return builder.setType(EmbeddedDatabaseType.HSQL).build();
}
@Bean public EntityManagerFactory entityManagerFactory() {
HibernateJpaVendorAdapter vendorAdapter = new HibernateJpaVendorAdapter();
vendorAdapter.setDatabase(Database.HSQL);
vendorAdapter.setGenerateDdl(true);
LocalContainerEntityManagerFactoryBean factory = new LocalContainerEntityManagerFactoryBean();
/* Properties jpaProperties = new Properties();
jpaProperties.setProperty("hibernate.hbm2ddl.auto", "drop-create");
jpaProperties.setProperty("hibernate.show_sql", "true");
jpaProperties.setProperty("hibernate.dialect", "org.hibernate.dialect.HSQLDialect");
factory.setJpaProperties(jpaProperties);
*/
factory.setJpaVendorAdapter(vendorAdapter);
factory.setPackagesToScan("de.cab.test1.domain");
factory.setDataSource(dataSource());
factory.afterPropertiesSet();
return factory.getObject();
}
@Bean public JpaDialect jpaDialect() {
return new HibernateJpaDialect();
}
@Bean public PlatformTransactionManager transactionManager() {
JpaTransactionManager txManager = new JpaTransactionManager();
txManager.setEntityManagerFactory(entityManagerFactory());
return txManager;
}