Hi max,
I haven't asked for a solution to my problem on this forum but I posted many posts on springframework forum and non of the replies I got solved my problem.
Any way, if you could provide me with a solution I would be very thankful.
Note:
- I'm using annotations and my hibernate configuration file is a .xml file not a .cfg file.(I'm not sure if this differs).
Regarding what I mean by automatically,
As i mentioned before I'm using spring framework. I have a file hibernate.xml that contains hibernate configuration.
In this file I configure a bean named session factory. Here is the code:
Code:
<bean id="sessionFactory"
class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean">
<property name="dataSource">
<ref bean="dataSource" />
</property>
<property name="configurationClass">
<value>org.hibernate.cfg.AnnotationConfiguration</value>
</property>
<property name="entityInterceptor">
<ref bean="auditLogInterceptor" />
</property>
<property name="mappingDirectoryLocations">
<list>
</list>
</property>
<property name="annotatedClasses">
<list>
<!-- Here I add the annotated classes -->
<value>com._4s_.banks.model.Bank</value>
<value>com._4s_.banks.model.accounts</value>
</list>
</property>
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">
${hibernate.dialect}
</prop>
<prop key="hibernate.show_sql">false</prop>
<prop key="hibernate.hbm2ddl.auto">update</prop>
<!--<prop key="hibernate.hbm2ddl.auto">create</prop> -->
</props>
</property>
</bean>
If you have a look at the property named hibernateProperties, you'll find a <prop> named "hibernate.hbm2dll.auto" and it takes a value "update" .
This causes the database to be updated with the new modifications whenever the application is reloaded.
That's what I'm looking for, I want these updates to be written to an external file whenever the application is reloaded as they are excuted in the database.
Code:
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">
${hibernate.dialect}
</prop>
<prop key="hibernate.show_sql">false</prop>
[b]<prop key="hibernate.hbm2ddl.auto">update</prop>[/b]
</props>
</property>
Hope I'm clear now.
Thanks in advance.