Java Reference
In-Depth Information
<property name="lastName" />
<property name="address1" />
<property name="address2" />
<property name="city" />
<property name="state" />
<property name="postalCode" />
<property name="country" />
If you have used Hibernate before, the file in listing 11.2 will be obvious to you—
it is a fairly simple table mapping. If you have not used Hibernate before, it may
not be so clear. What this configuration file does is map the properties from our
Account bean to columns in our account table in the database . It also tells
Hibernate how we want to generate the id property in the bean for newly created
database rows
The actual DAO implementation
The Java source code for the DAO implementation is more verbose, because we
are mapping the Account table to several different classes of objects. This is a bit
more difficult with Hibernate, as listing 11.3 shows.
Listing 11.3
Hibernate implementation of our Account DAO interface
public class AccountDaoImpl
extends HibernateDaoTemplate
implements AccountDao {
private static final Log log =
public AccountDaoImpl(DaoManager daoManager) {
log.debug("Creating instance of " + getClass());
Inserts new account
public Integer insert(Account account) {
try {
} catch (HibernateException e) {
throw new DaoException(e);
return account.getAccountId();
Search WWH ::

Custom Search