Java Reference
In-Depth Information
<property name="show_sql">true</property>
<!-- Hibernate wants to be told about each class,
like a strict JPA implementation -->
<mapping class="domain.Address"/>
<mapping class="domain.Country"/>
<mapping class="domain.Person"/>
<mapping class="domain.Preference"/>
<mapping class="domain.model.Recording"/>
<mapping class="domain.model.MusicRecording"/>
<mapping class="domain.model.Track"/>
<mapping class="domain.model.VideoRecording"/>
<mapping class="domain.model.Actor"/>
<mapping class="domain.sales.Customer"/>
<mapping class="domain.sales.SalesPerson"/>
</session-factory>
</hibernate-configuration>
See Also
This example gives a quick look at JPA and Hibernate for storing and retrieving objects.
There is much more to JPA and Hibernate than I've covered here. There are several good
books on each. This
website
contains JPA information, articles, and links to many imple-
mentations. You'll also want to take a look at
the official Hibernate website
.
Finally, I main-
tain a separate
GitHub repo
with JPA and Hibernate demos.
The next few recipes concentrate on using the lower-level JDBC.
JDBC Setup and Connection
Problem
You want to access a database via JDBC.
Solution
Use
Class.forName()
and
DriverManager
.
getConnection()
.