I am using hibernate in the persistance layer in a Maven project and I'm really new to this. Sometimes, when performing read operations from the database through jpa/hibernate some of the tables are dropped. The project doesn't implement that kind of functionality. Is this a known issue? The actions are only read actions.
2 Answers
Now I finally found the answer. Seems like some config in the integration tests made them run against wrong db(the one where the tables were dropped), not the im-db we wanted to use. And the integration tests are supposed to do a drop, but then no new tables could be created. So the answer to this question is loosley coupled to the problem but rather to our incorrect configuration. but maybe this answer can make other's having the same problem think twice about this.
I am new to hibernate as well, but I do remember there is a setting in hibernate.xml or persistence.xml where you can specify that vendor drops and generate the schema, tables everytime you run that application.
The following property will create the tables on app startup and when next time you run the application it will not regenerate the tables if already exist.
<property name="hbm2ddl.auto" value="create"/>
Where as the value of "create-drop" will create the table and drop at the end of session.
<property name="hbm2ddl.auto" value="create-drop"/>
Have a look at this documentation Jboss reference
Hope it helps.