Reputation: 1712
I have a Spring MVC web setup with a Spring ORM/Hibernate persistence layer. I have configured my LocalContainerEntityManagerFactoryBean
to auto-scan for persistence entities on a package so I don't need persistence xml configuration.
How can I set up my beans configuration so it shows the generated queries and refreshes the database with model changes on startup?
Upvotes: 2
Views: 866
Reputation: 34766
LocalContainerEntityManagerFactoryBean
extends AbstractEntityManagerFactoryBean
, which contains setJpaProperties(Properties)
method. You can pass custom properties to this bean using this method.
Properties properties = new Properties();
properties.put("hibernate.show_sql", "true");
properties.put("hibernate.hbm2ddl.auto", "create-drop");
entityManagerFactoryBean.setJpaProperties(properties);
Or if you want to do it on the Spring config files:
<bean id="entityManagerFactory" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
...
<property name="jpaProperties">
<props>
<prop key="hibernate.show_sql">true</prop>
<prop key="hibernate.hbm2ddl.auto">create-drop</prop>
</props>
</property>
...
</bean>
Upvotes: 1