![]() ![]() If you set this value to update, on the other hand, Hibernate will only create the database if it doesn't already exist, and will update any existing tables to match your current domain model. Setting this property to create-drop will create a brand-new database each time you start the application, which is great for integration tests, but not so hot anywhere else. Configuring Hibernate to update your database schema automatically All you need to do is to set the property, as shown in Listing 1. Getting Hibernate to update your database schema automatically is easy enough. First steps: Updating your database schema ![]() So Hibernate creates and updates the database schema all by itself, and you don't have to worry about arcane SQL scripts. Even better, Hibernate comes with a great tool that lets you generate the database schema automatically. ![]() With annotations, you don't need to bother with XML mapping files, and you can leverage the usually sensible default behavior to drastically reduce the amount of code you need to maintain. Hibernate 3 annotations are a great way to manage your database persistence. In this article, Java Power Tools author John Ferguson Smart shows you how to generate database schemas automatically with Hibernate while still making your DBA happy. Back in the real world, however, you still need to account for the sometimes obscure naming conventions used by your database administrator. Without much effort, you can get Hibernate to generate your database schema automatically, dispensing entirely with SQL scripts. For a Java developer, Hibernate 3 annotations offer a terrific way to model the domain layer. ![]()
0 Comments
Leave a Reply. |