I'm trying to build a spring roo project using hibernate and an oracle database. The oracle database contains tables used by another application.
I have an entity User that already 开发者_StackOverflow中文版exists in the database, containing thousands of users and shared by another application.
My new roo project contains the user entity and also some others. The persistence.xml is configured with the following property:
<property name="hibernate.hbm2ddl.auto" value="update"/>
On the first deployment of the app, hibernate fails because there are no tables for the entities. Changing the value to "create" fixes this, but wipes the user table :(
Is there a way around this? What I would like to do is this
- property value is "create" but the User entity is excluded somehow
- Deploy application, tables are created etc. Existing User table is used.
- Stop application
- Modify property value to "update"
- No data loss :)
Many thanks.
There must be a better way to do this, but here is a quick hack which will get you rolling with your desired steps:
- Rename the table in your Hibernate mapping to
user_unused
- Modify property value to
create
- Deploy application, tables are created etc, existing
user
table is unaltered. - Stop application
- Rename the table in your Hibernate mapping to
user
- Modify property value to
update
- Delete the
user_unused
database table that was created by Hibernate in step 1
I remember from some hibernate forum that this feature is not available yet from hibernate. So here is another hack. You may use false for 'creat' and true for 'update'. off-course you would be required to have all classes configured in that case.
精彩评论