文档介绍:在Eclipse中使用Hibernate
Working with Hibernate in Eclipse
Editor's Note: With our survey results showing a huge interest in Hibernate, we thought this would be a good week to bring back this piece, by the author of O'Reilly's Hibernate book, on how to use Hibernate with Eclipse, which was also a top vote-getter in the poll.
Introduction
I recently started using Eclipse as my development environment, in part because of its support for the many platforms on which I develop, and in part because Eclipse is a great example of the power of an open, extensible environment in which people all around the world can contribute. I'm beginning to investigate the extensions people e up with. For example, I use a little plugin called XMLBuddy to work with XML files, and it's very helpful. So I became curious about whether anyone had written plugins to work with Hibernate, since I've done so much of that recently in putting together the Developer's Notebook. It turns out there are several such efforts underway; in this article we will explore one of them--the Hibernate Synchronizer.
Hibernate Synchronizer
Of the plugins I've found so far, the Hibernate Synchronizer interested me most because it seems to best support the kind of mapping-centric workflow I adopted throughout my Developer's Notebook. (Hibernate can be used in many different ways, so check out the other plugins available; these may be more helpful if your environment calls for another approach.) In fact, the Hibernate Synchronizer plugin removes the need for you to think about updating your Java code when you change your mapping document. In a very Eclipse-like way, it automatically updates the Java code as you edit the mapping. But it goes even farther than Hibernate's built-in code generation tools by creating a pair of classes for each mapped object. It "owns" a base class, which it rewrites at will as you change the mapping, and gives you a subclass that extends this base class, where you can put business logic