这是Dao里验证登录的代码:
@Override
public List<Customer> findAllCustomer()
{
return (List<Customer>)getHibernateTemplate().find("from Customer");
}

public List<Customer> findByNameAndPass(Customer customer)
{
return (List<Customer>)getHibernateTemplate()
.find("from customer_table c where c.username = ? and c.password=?"
, customer.getUsername(), customer.getPassword());
}下面是Customer.hbm.xml:
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE hibernate-mapping PUBLIC 
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd">
<hibernate-mapping package="com.kevin.domain">
<class name="Customer" table="customer_table" discriminator-value="1">
<!-- 使用只读缓存 -->
<!-- <cache usage="read-write"/>-->
<!-- 映射标识属性 -->
<id name="id" type="int" column="id">
<!-- 指定使用identity主键生成策略 -->
<generator class="identity"/>
</id>
<!-- 映射普通属性 -->
<property name="username" column="username" type="string" not-null="true" length="50"/>
<property name="password" column="password" type="string" not-null="true" length="50"/>
<property name="name" column="name" type="string" not-null="true" length="50" />
<property name="email" column="email" type="string" not-null="true" length="50" />
</class>
</hibernate-mapping>下面是applicationContext.xml里关于Customer和CustomerDao的配置:
<property name="mappingResources">
<list>
<!-- 以下用来列出Hibernate映射文件 -->
<value>org/crazyit/app/domain/Person.hbm.xml</value>
<value>com/kevin/domain/Customer.hbm.xml</value>
</list>
</property><bean id="customerDao" class=
"com.kevin.dao.impl.CustomerDaoHibernate">
<!-- 注入持久化操作所需的SessionFactory -->
<property name="sessionFactory" ref="sessionFactory"/>
</bean>