Java Reference
In-Depth Information
Now run the application. You should see the following output, which confirms that a
Notepad entity and 100 associated Note entities have been persisted to the database:
Creating test notepad...
Test notepad created.
You can now switch back to the Hibernate Console perspective in order to browse this data.
Browsing the Model
Back in the Hibernate Console perspective, you can access the contents of the object model
using the Session Factory node of the console configuration view. This node is named after the
SessionFactory object created and maintained internally by the Hibernate Eclipse plug-in
tools when you drill down into the console configuration view.
n Tip If you manage to put the internal SessionFactory object into a bad state, it is possible to close
and re-create it from the configuration view's context menu when the configuration view is collapsed to
a single node.
Opening the Session factory node, you will see nodes representing each of the mapped
classes. Drilling down further, you can see a representation of the mapped fields and attrib-
utes (along with a graphical representation of the association rules, primary keys, and so on,
where appropriate).
If you double-click the mapped class, all the instances of the class in the database will be
retrieved, and a toString representation will be displayed in the Hibernate Query Result view.
As you can see from Figure B-16, the generated HQL query to produce this information is
shown in a second tabbed pane (further queries will be added as new tabs within this window).
The column is numbered, as no column name can be specified. Note that we have overridden
the Notepad class's toString() method to ensure that a human-readable representation of the
class contents is displayed in this view.
Figure B-16. The Hibernate Query Result view of the mapped Notepad class
All results of queries generated manually or automatically through the Hibernate Console
perspective will be displayed in the Hibernate Query Result view.
Search WWH ::




Custom Search