Java Reference
In-Depth Information
<property name="hibernate.dialect"
"net.sf.hibernate.dialect.PostgreSQLDialect" />
<property name="map.Account"
"${DaoHomeRes}/hibernate/Account.hbm.xml" />
<dao interface="${DaoHome}.AccountDao"
As was discussed in chapter 10 (section 10.2.2), the HIBERNATE transaction man-
ager simply expects that the properties you would normally put in the hiber- file are listed as properties to the <transactionManager> element.
Because we wanted to keep our source tree clean, we did not put the Hiber-
nate mapping file for the Account bean ( Account.hbm.xml ) in the same package as
our Account bean, but instead added it to the configuration by using a map. prop-
erty that added it to our Hibernate configuration. Remember, it is all about keep-
ing the implementation of the data access separate from the interface.
Mapping the Account table
The mapping file, shown in listing 11.2, is very simple, because we map directly
from the properties files to the columns that have the same names, and there are
no related entities.
Listing 11.2
Hibernate mapping file for our Account table
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping
PUBLIC "-//Hibernate/Hibernate Mapping DTD//EN"
<id name="accountId" type="int" column="accountid">
<generator class="sequence">
<property name="username" />
<property name="password" />
<property name="firstName" />
Mapping table
to a class
Hooking up sequence
for ID generation
Search WWH ::

Custom Search