java.sql.SQLException: The Connection.setTypeMap(Map) method is not implemented.
5 个解决方案
#1
贴源码
#2
配置文件如下:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN"
"http://www.springframework.org/dtd/spring-beans.dtd">
<beans>
<!-- 定义c3p0数据源 -->
<bean id = "database"
class="com.mchange.v2.c3p0.ComboPooledDataSource"
destroy-method="close">
<!-- 指定数据库连接驱动 -->
<property name= "driverClass" value="net.sourceforge.jtds.jdbc.Driver"/>
<!-- 指定连接数据库 -->
<property name="jdbcUrl" value = "jdbc:jtds:sqlserver://127.0.0.1:1433/Mtr" />
<!-- 指定数据库的连接用户名-->
<property name="user" value ="sa" />
<property name="password" value ="sa" />
<!-- 指定连接数据库连接池的最大连接数 -->
<property name="maxPoolSize" value="60"/>
<!-- 指定连接数据库连接池的最小连接数 -->
<property name="minPoolSize" value="20"/>
<!-- 指定连接数据库连接池的初始化连接数 -->
<property name="initialPoolSize" value="20"/>
<!-- 指定连接数据库连接池的连接的最大空闲时间 -->
<property name="maxIdleTime" value="20"/>
</bean>
<bean id="sessionFactory"
class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
<property name="dataSource">
<ref bean="database" />
</property>
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">
org.hibernate.dialect.MySQLDialect
</prop>
</props>
</property>
<property name="mappingResources">
<list>
<value>ksec/lql/dao/Employee.hbm.xml</value>
</list>
</property>
</bean>
<bean id="mathBean" class="ksec.lql.service.employeeModSerImpl" />
<bean id="SpringContextUtil " class="ksec.lql.db.SpringContextUtil" lazy-init="false"/>
<!--装配实现类-->
<bean id="EmployeeDAO" class="ksec.lql.dao.EmployeeDAO">
<property name="sessionFactory">
<ref bean="sessionFactory" />
</property>
</bean>
</beans>
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN"
"http://www.springframework.org/dtd/spring-beans.dtd">
<beans>
<!-- 定义c3p0数据源 -->
<bean id = "database"
class="com.mchange.v2.c3p0.ComboPooledDataSource"
destroy-method="close">
<!-- 指定数据库连接驱动 -->
<property name= "driverClass" value="net.sourceforge.jtds.jdbc.Driver"/>
<!-- 指定连接数据库 -->
<property name="jdbcUrl" value = "jdbc:jtds:sqlserver://127.0.0.1:1433/Mtr" />
<!-- 指定数据库的连接用户名-->
<property name="user" value ="sa" />
<property name="password" value ="sa" />
<!-- 指定连接数据库连接池的最大连接数 -->
<property name="maxPoolSize" value="60"/>
<!-- 指定连接数据库连接池的最小连接数 -->
<property name="minPoolSize" value="20"/>
<!-- 指定连接数据库连接池的初始化连接数 -->
<property name="initialPoolSize" value="20"/>
<!-- 指定连接数据库连接池的连接的最大空闲时间 -->
<property name="maxIdleTime" value="20"/>
</bean>
<bean id="sessionFactory"
class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
<property name="dataSource">
<ref bean="database" />
</property>
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">
org.hibernate.dialect.MySQLDialect
</prop>
</props>
</property>
<property name="mappingResources">
<list>
<value>ksec/lql/dao/Employee.hbm.xml</value>
</list>
</property>
</bean>
<bean id="mathBean" class="ksec.lql.service.employeeModSerImpl" />
<bean id="SpringContextUtil " class="ksec.lql.db.SpringContextUtil" lazy-init="false"/>
<!--装配实现类-->
<bean id="EmployeeDAO" class="ksec.lql.dao.EmployeeDAO">
<property name="sessionFactory">
<ref bean="sessionFactory" />
</property>
</bean>
</beans>
#3
package ksec.lql.dao;
/**
* Employee generated by MyEclipse Persistence Tools
*/
public class Employee implements java.io.Serializable {
// Fields
private String empId;
private String empName;
private String sex;
private String loginName;
private String passWord;
// Constructors
/** default constructor */
public Employee() {
}
/** minimal constructor */
public Employee(String empId, String empName, String loginName) {
this.empId = empId;
this.empName = empName;
this.loginName = loginName;
}
/** full constructor */
public Employee(String empId, String empName, String sex, String loginName,
String passWord) {
this.empId = empId;
this.empName = empName;
this.sex = sex;
this.loginName = loginName;
this.passWord = passWord;
}
// Property accessors
public String getEmpId() {
return this.empId;
}
public void setEmpId(String empId) {
this.empId = empId;
}
public String getEmpName() {
return this.empName;
}
public void setEmpName(String empName) {
this.empName = empName;
}
public String getSex() {
return this.sex;
}
public void setSex(String sex) {
this.sex = sex;
}
public String getLoginName() {
return this.loginName;
}
public void setLoginName(String loginName) {
this.loginName = loginName;
}
public String getPassWord() {
return this.passWord;
}
public void setPassWord(String passWord) {
this.passWord = passWord;
}
}
/**
* Employee generated by MyEclipse Persistence Tools
*/
public class Employee implements java.io.Serializable {
// Fields
private String empId;
private String empName;
private String sex;
private String loginName;
private String passWord;
// Constructors
/** default constructor */
public Employee() {
}
/** minimal constructor */
public Employee(String empId, String empName, String loginName) {
this.empId = empId;
this.empName = empName;
this.loginName = loginName;
}
/** full constructor */
public Employee(String empId, String empName, String sex, String loginName,
String passWord) {
this.empId = empId;
this.empName = empName;
this.sex = sex;
this.loginName = loginName;
this.passWord = passWord;
}
// Property accessors
public String getEmpId() {
return this.empId;
}
public void setEmpId(String empId) {
this.empId = empId;
}
public String getEmpName() {
return this.empName;
}
public void setEmpName(String empName) {
this.empName = empName;
}
public String getSex() {
return this.sex;
}
public void setSex(String sex) {
this.sex = sex;
}
public String getLoginName() {
return this.loginName;
}
public void setLoginName(String loginName) {
this.loginName = loginName;
}
public String getPassWord() {
return this.passWord;
}
public void setPassWord(String passWord) {
this.passWord = passWord;
}
}
#4
Dao文件
package ksec.lql.dao;
import java.util.List;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.hibernate.LockMode;
import org.springframework.context.ApplicationContext;
import org.springframework.orm.hibernate3.support.HibernateDaoSupport;
/**
* Data access object (DAO) for domain model class Employee.
*
* @see ksec.lql.dao.Employee
* @author MyEclipse Persistence Tools
*/
public class EmployeeDAO extends HibernateDaoSupport {
private static final Log log = LogFactory.getLog(EmployeeDAO.class);
// property constants
public static final String EMP_NAME = "empName";
public static final String SEX = "sex";
public static final String LOGIN_NAME = "loginName";
public static final String PASS_WORD = "passWord";
protected void initDao() {
// do nothing
}
public void save(Employee transientInstance) {
log.debug("saving Employee instance");
try {
getHibernateTemplate().save(transientInstance);
log.debug("save successful");
} catch (RuntimeException re) {
log.error("save failed", re);
throw re;
}
}
public void delete(Employee persistentInstance) {
log.debug("deleting Employee instance");
try {
getHibernateTemplate().delete(persistentInstance);
log.debug("delete successful");
} catch (RuntimeException re) {
log.error("delete failed", re);
throw re;
}
}
public Employee findById(java.lang.String id) {
log.debug("getting Employee instance with id: " + id);
try {
Employee instance = (Employee) getHibernateTemplate().get(
"ksec.lql.dao.Employee", id);
return instance;
} catch (RuntimeException re) {
log.error("get failed", re);
throw re;
}
}
public List findByExample(Employee instance) {
log.debug("finding Employee instance by example");
try {
List results = getHibernateTemplate().findByExample(instance);
log.debug("find by example successful, result size: "
+ results.size());
return results;
} catch (RuntimeException re) {
log.error("find by example failed", re);
throw re;
}
}
public List findByProperty(String propertyName, Object value) {
log.debug("finding Employee instance with property: " + propertyName
+ ", value: " + value);
try {
String queryString = "from Employee as model where model."
+ propertyName + "= ?";
return getHibernateTemplate().find(queryString, value);
} catch (RuntimeException re) {
log.error("find by property name failed", re);
throw re;
}
}
public List findByEmpName(Object empName) {
return findByProperty(EMP_NAME, empName);
}
public List findBySex(Object sex) {
return findByProperty(SEX, sex);
}
public List findByLoginName(Object loginName) {
return findByProperty(LOGIN_NAME, loginName);
}
public List findByPassWord(Object passWord) {
return findByProperty(PASS_WORD, passWord);
}
public List findAll() {
log.debug("finding all Employee instances");
try {
String queryString = "from Employee";
return getHibernateTemplate().find(queryString);
} catch (RuntimeException re) {
log.error("find all failed", re);
throw re;
}
}
public Employee merge(Employee detachedInstance) {
log.debug("merging Employee instance");
try {
Employee result = (Employee) getHibernateTemplate().merge(
detachedInstance);
log.debug("merge successful");
return result;
} catch (RuntimeException re) {
log.error("merge failed", re);
throw re;
}
}
public void attachDirty(Employee instance) {
log.debug("attaching dirty Employee instance");
try {
getHibernateTemplate().saveOrUpdate(instance);
log.debug("attach successful");
} catch (RuntimeException re) {
log.error("attach failed", re);
throw re;
}
}
public void attachClean(Employee instance) {
log.debug("attaching clean Employee instance");
try {
getHibernateTemplate().lock(instance, LockMode.NONE);
log.debug("attach successful");
} catch (RuntimeException re) {
log.error("attach failed", re);
throw re;
}
}
public static EmployeeDAO getFromApplicationContext(ApplicationContext ctx) {
return (EmployeeDAO) ctx.getBean("EmployeeDAO");
}
}
package ksec.lql.dao;
import java.util.List;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.hibernate.LockMode;
import org.springframework.context.ApplicationContext;
import org.springframework.orm.hibernate3.support.HibernateDaoSupport;
/**
* Data access object (DAO) for domain model class Employee.
*
* @see ksec.lql.dao.Employee
* @author MyEclipse Persistence Tools
*/
public class EmployeeDAO extends HibernateDaoSupport {
private static final Log log = LogFactory.getLog(EmployeeDAO.class);
// property constants
public static final String EMP_NAME = "empName";
public static final String SEX = "sex";
public static final String LOGIN_NAME = "loginName";
public static final String PASS_WORD = "passWord";
protected void initDao() {
// do nothing
}
public void save(Employee transientInstance) {
log.debug("saving Employee instance");
try {
getHibernateTemplate().save(transientInstance);
log.debug("save successful");
} catch (RuntimeException re) {
log.error("save failed", re);
throw re;
}
}
public void delete(Employee persistentInstance) {
log.debug("deleting Employee instance");
try {
getHibernateTemplate().delete(persistentInstance);
log.debug("delete successful");
} catch (RuntimeException re) {
log.error("delete failed", re);
throw re;
}
}
public Employee findById(java.lang.String id) {
log.debug("getting Employee instance with id: " + id);
try {
Employee instance = (Employee) getHibernateTemplate().get(
"ksec.lql.dao.Employee", id);
return instance;
} catch (RuntimeException re) {
log.error("get failed", re);
throw re;
}
}
public List findByExample(Employee instance) {
log.debug("finding Employee instance by example");
try {
List results = getHibernateTemplate().findByExample(instance);
log.debug("find by example successful, result size: "
+ results.size());
return results;
} catch (RuntimeException re) {
log.error("find by example failed", re);
throw re;
}
}
public List findByProperty(String propertyName, Object value) {
log.debug("finding Employee instance with property: " + propertyName
+ ", value: " + value);
try {
String queryString = "from Employee as model where model."
+ propertyName + "= ?";
return getHibernateTemplate().find(queryString, value);
} catch (RuntimeException re) {
log.error("find by property name failed", re);
throw re;
}
}
public List findByEmpName(Object empName) {
return findByProperty(EMP_NAME, empName);
}
public List findBySex(Object sex) {
return findByProperty(SEX, sex);
}
public List findByLoginName(Object loginName) {
return findByProperty(LOGIN_NAME, loginName);
}
public List findByPassWord(Object passWord) {
return findByProperty(PASS_WORD, passWord);
}
public List findAll() {
log.debug("finding all Employee instances");
try {
String queryString = "from Employee";
return getHibernateTemplate().find(queryString);
} catch (RuntimeException re) {
log.error("find all failed", re);
throw re;
}
}
public Employee merge(Employee detachedInstance) {
log.debug("merging Employee instance");
try {
Employee result = (Employee) getHibernateTemplate().merge(
detachedInstance);
log.debug("merge successful");
return result;
} catch (RuntimeException re) {
log.error("merge failed", re);
throw re;
}
}
public void attachDirty(Employee instance) {
log.debug("attaching dirty Employee instance");
try {
getHibernateTemplate().saveOrUpdate(instance);
log.debug("attach successful");
} catch (RuntimeException re) {
log.error("attach failed", re);
throw re;
}
}
public void attachClean(Employee instance) {
log.debug("attaching clean Employee instance");
try {
getHibernateTemplate().lock(instance, LockMode.NONE);
log.debug("attach successful");
} catch (RuntimeException re) {
log.error("attach failed", re);
throw re;
}
}
public static EmployeeDAO getFromApplicationContext(ApplicationContext ctx) {
return (EmployeeDAO) ctx.getBean("EmployeeDAO");
}
}
#5
应该是setMapType的问题吧,仔细去检查一下啊
#1
贴源码
#2
配置文件如下:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN"
"http://www.springframework.org/dtd/spring-beans.dtd">
<beans>
<!-- 定义c3p0数据源 -->
<bean id = "database"
class="com.mchange.v2.c3p0.ComboPooledDataSource"
destroy-method="close">
<!-- 指定数据库连接驱动 -->
<property name= "driverClass" value="net.sourceforge.jtds.jdbc.Driver"/>
<!-- 指定连接数据库 -->
<property name="jdbcUrl" value = "jdbc:jtds:sqlserver://127.0.0.1:1433/Mtr" />
<!-- 指定数据库的连接用户名-->
<property name="user" value ="sa" />
<property name="password" value ="sa" />
<!-- 指定连接数据库连接池的最大连接数 -->
<property name="maxPoolSize" value="60"/>
<!-- 指定连接数据库连接池的最小连接数 -->
<property name="minPoolSize" value="20"/>
<!-- 指定连接数据库连接池的初始化连接数 -->
<property name="initialPoolSize" value="20"/>
<!-- 指定连接数据库连接池的连接的最大空闲时间 -->
<property name="maxIdleTime" value="20"/>
</bean>
<bean id="sessionFactory"
class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
<property name="dataSource">
<ref bean="database" />
</property>
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">
org.hibernate.dialect.MySQLDialect
</prop>
</props>
</property>
<property name="mappingResources">
<list>
<value>ksec/lql/dao/Employee.hbm.xml</value>
</list>
</property>
</bean>
<bean id="mathBean" class="ksec.lql.service.employeeModSerImpl" />
<bean id="SpringContextUtil " class="ksec.lql.db.SpringContextUtil" lazy-init="false"/>
<!--装配实现类-->
<bean id="EmployeeDAO" class="ksec.lql.dao.EmployeeDAO">
<property name="sessionFactory">
<ref bean="sessionFactory" />
</property>
</bean>
</beans>
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN"
"http://www.springframework.org/dtd/spring-beans.dtd">
<beans>
<!-- 定义c3p0数据源 -->
<bean id = "database"
class="com.mchange.v2.c3p0.ComboPooledDataSource"
destroy-method="close">
<!-- 指定数据库连接驱动 -->
<property name= "driverClass" value="net.sourceforge.jtds.jdbc.Driver"/>
<!-- 指定连接数据库 -->
<property name="jdbcUrl" value = "jdbc:jtds:sqlserver://127.0.0.1:1433/Mtr" />
<!-- 指定数据库的连接用户名-->
<property name="user" value ="sa" />
<property name="password" value ="sa" />
<!-- 指定连接数据库连接池的最大连接数 -->
<property name="maxPoolSize" value="60"/>
<!-- 指定连接数据库连接池的最小连接数 -->
<property name="minPoolSize" value="20"/>
<!-- 指定连接数据库连接池的初始化连接数 -->
<property name="initialPoolSize" value="20"/>
<!-- 指定连接数据库连接池的连接的最大空闲时间 -->
<property name="maxIdleTime" value="20"/>
</bean>
<bean id="sessionFactory"
class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
<property name="dataSource">
<ref bean="database" />
</property>
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">
org.hibernate.dialect.MySQLDialect
</prop>
</props>
</property>
<property name="mappingResources">
<list>
<value>ksec/lql/dao/Employee.hbm.xml</value>
</list>
</property>
</bean>
<bean id="mathBean" class="ksec.lql.service.employeeModSerImpl" />
<bean id="SpringContextUtil " class="ksec.lql.db.SpringContextUtil" lazy-init="false"/>
<!--装配实现类-->
<bean id="EmployeeDAO" class="ksec.lql.dao.EmployeeDAO">
<property name="sessionFactory">
<ref bean="sessionFactory" />
</property>
</bean>
</beans>
#3
package ksec.lql.dao;
/**
* Employee generated by MyEclipse Persistence Tools
*/
public class Employee implements java.io.Serializable {
// Fields
private String empId;
private String empName;
private String sex;
private String loginName;
private String passWord;
// Constructors
/** default constructor */
public Employee() {
}
/** minimal constructor */
public Employee(String empId, String empName, String loginName) {
this.empId = empId;
this.empName = empName;
this.loginName = loginName;
}
/** full constructor */
public Employee(String empId, String empName, String sex, String loginName,
String passWord) {
this.empId = empId;
this.empName = empName;
this.sex = sex;
this.loginName = loginName;
this.passWord = passWord;
}
// Property accessors
public String getEmpId() {
return this.empId;
}
public void setEmpId(String empId) {
this.empId = empId;
}
public String getEmpName() {
return this.empName;
}
public void setEmpName(String empName) {
this.empName = empName;
}
public String getSex() {
return this.sex;
}
public void setSex(String sex) {
this.sex = sex;
}
public String getLoginName() {
return this.loginName;
}
public void setLoginName(String loginName) {
this.loginName = loginName;
}
public String getPassWord() {
return this.passWord;
}
public void setPassWord(String passWord) {
this.passWord = passWord;
}
}
/**
* Employee generated by MyEclipse Persistence Tools
*/
public class Employee implements java.io.Serializable {
// Fields
private String empId;
private String empName;
private String sex;
private String loginName;
private String passWord;
// Constructors
/** default constructor */
public Employee() {
}
/** minimal constructor */
public Employee(String empId, String empName, String loginName) {
this.empId = empId;
this.empName = empName;
this.loginName = loginName;
}
/** full constructor */
public Employee(String empId, String empName, String sex, String loginName,
String passWord) {
this.empId = empId;
this.empName = empName;
this.sex = sex;
this.loginName = loginName;
this.passWord = passWord;
}
// Property accessors
public String getEmpId() {
return this.empId;
}
public void setEmpId(String empId) {
this.empId = empId;
}
public String getEmpName() {
return this.empName;
}
public void setEmpName(String empName) {
this.empName = empName;
}
public String getSex() {
return this.sex;
}
public void setSex(String sex) {
this.sex = sex;
}
public String getLoginName() {
return this.loginName;
}
public void setLoginName(String loginName) {
this.loginName = loginName;
}
public String getPassWord() {
return this.passWord;
}
public void setPassWord(String passWord) {
this.passWord = passWord;
}
}
#4
Dao文件
package ksec.lql.dao;
import java.util.List;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.hibernate.LockMode;
import org.springframework.context.ApplicationContext;
import org.springframework.orm.hibernate3.support.HibernateDaoSupport;
/**
* Data access object (DAO) for domain model class Employee.
*
* @see ksec.lql.dao.Employee
* @author MyEclipse Persistence Tools
*/
public class EmployeeDAO extends HibernateDaoSupport {
private static final Log log = LogFactory.getLog(EmployeeDAO.class);
// property constants
public static final String EMP_NAME = "empName";
public static final String SEX = "sex";
public static final String LOGIN_NAME = "loginName";
public static final String PASS_WORD = "passWord";
protected void initDao() {
// do nothing
}
public void save(Employee transientInstance) {
log.debug("saving Employee instance");
try {
getHibernateTemplate().save(transientInstance);
log.debug("save successful");
} catch (RuntimeException re) {
log.error("save failed", re);
throw re;
}
}
public void delete(Employee persistentInstance) {
log.debug("deleting Employee instance");
try {
getHibernateTemplate().delete(persistentInstance);
log.debug("delete successful");
} catch (RuntimeException re) {
log.error("delete failed", re);
throw re;
}
}
public Employee findById(java.lang.String id) {
log.debug("getting Employee instance with id: " + id);
try {
Employee instance = (Employee) getHibernateTemplate().get(
"ksec.lql.dao.Employee", id);
return instance;
} catch (RuntimeException re) {
log.error("get failed", re);
throw re;
}
}
public List findByExample(Employee instance) {
log.debug("finding Employee instance by example");
try {
List results = getHibernateTemplate().findByExample(instance);
log.debug("find by example successful, result size: "
+ results.size());
return results;
} catch (RuntimeException re) {
log.error("find by example failed", re);
throw re;
}
}
public List findByProperty(String propertyName, Object value) {
log.debug("finding Employee instance with property: " + propertyName
+ ", value: " + value);
try {
String queryString = "from Employee as model where model."
+ propertyName + "= ?";
return getHibernateTemplate().find(queryString, value);
} catch (RuntimeException re) {
log.error("find by property name failed", re);
throw re;
}
}
public List findByEmpName(Object empName) {
return findByProperty(EMP_NAME, empName);
}
public List findBySex(Object sex) {
return findByProperty(SEX, sex);
}
public List findByLoginName(Object loginName) {
return findByProperty(LOGIN_NAME, loginName);
}
public List findByPassWord(Object passWord) {
return findByProperty(PASS_WORD, passWord);
}
public List findAll() {
log.debug("finding all Employee instances");
try {
String queryString = "from Employee";
return getHibernateTemplate().find(queryString);
} catch (RuntimeException re) {
log.error("find all failed", re);
throw re;
}
}
public Employee merge(Employee detachedInstance) {
log.debug("merging Employee instance");
try {
Employee result = (Employee) getHibernateTemplate().merge(
detachedInstance);
log.debug("merge successful");
return result;
} catch (RuntimeException re) {
log.error("merge failed", re);
throw re;
}
}
public void attachDirty(Employee instance) {
log.debug("attaching dirty Employee instance");
try {
getHibernateTemplate().saveOrUpdate(instance);
log.debug("attach successful");
} catch (RuntimeException re) {
log.error("attach failed", re);
throw re;
}
}
public void attachClean(Employee instance) {
log.debug("attaching clean Employee instance");
try {
getHibernateTemplate().lock(instance, LockMode.NONE);
log.debug("attach successful");
} catch (RuntimeException re) {
log.error("attach failed", re);
throw re;
}
}
public static EmployeeDAO getFromApplicationContext(ApplicationContext ctx) {
return (EmployeeDAO) ctx.getBean("EmployeeDAO");
}
}
package ksec.lql.dao;
import java.util.List;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.hibernate.LockMode;
import org.springframework.context.ApplicationContext;
import org.springframework.orm.hibernate3.support.HibernateDaoSupport;
/**
* Data access object (DAO) for domain model class Employee.
*
* @see ksec.lql.dao.Employee
* @author MyEclipse Persistence Tools
*/
public class EmployeeDAO extends HibernateDaoSupport {
private static final Log log = LogFactory.getLog(EmployeeDAO.class);
// property constants
public static final String EMP_NAME = "empName";
public static final String SEX = "sex";
public static final String LOGIN_NAME = "loginName";
public static final String PASS_WORD = "passWord";
protected void initDao() {
// do nothing
}
public void save(Employee transientInstance) {
log.debug("saving Employee instance");
try {
getHibernateTemplate().save(transientInstance);
log.debug("save successful");
} catch (RuntimeException re) {
log.error("save failed", re);
throw re;
}
}
public void delete(Employee persistentInstance) {
log.debug("deleting Employee instance");
try {
getHibernateTemplate().delete(persistentInstance);
log.debug("delete successful");
} catch (RuntimeException re) {
log.error("delete failed", re);
throw re;
}
}
public Employee findById(java.lang.String id) {
log.debug("getting Employee instance with id: " + id);
try {
Employee instance = (Employee) getHibernateTemplate().get(
"ksec.lql.dao.Employee", id);
return instance;
} catch (RuntimeException re) {
log.error("get failed", re);
throw re;
}
}
public List findByExample(Employee instance) {
log.debug("finding Employee instance by example");
try {
List results = getHibernateTemplate().findByExample(instance);
log.debug("find by example successful, result size: "
+ results.size());
return results;
} catch (RuntimeException re) {
log.error("find by example failed", re);
throw re;
}
}
public List findByProperty(String propertyName, Object value) {
log.debug("finding Employee instance with property: " + propertyName
+ ", value: " + value);
try {
String queryString = "from Employee as model where model."
+ propertyName + "= ?";
return getHibernateTemplate().find(queryString, value);
} catch (RuntimeException re) {
log.error("find by property name failed", re);
throw re;
}
}
public List findByEmpName(Object empName) {
return findByProperty(EMP_NAME, empName);
}
public List findBySex(Object sex) {
return findByProperty(SEX, sex);
}
public List findByLoginName(Object loginName) {
return findByProperty(LOGIN_NAME, loginName);
}
public List findByPassWord(Object passWord) {
return findByProperty(PASS_WORD, passWord);
}
public List findAll() {
log.debug("finding all Employee instances");
try {
String queryString = "from Employee";
return getHibernateTemplate().find(queryString);
} catch (RuntimeException re) {
log.error("find all failed", re);
throw re;
}
}
public Employee merge(Employee detachedInstance) {
log.debug("merging Employee instance");
try {
Employee result = (Employee) getHibernateTemplate().merge(
detachedInstance);
log.debug("merge successful");
return result;
} catch (RuntimeException re) {
log.error("merge failed", re);
throw re;
}
}
public void attachDirty(Employee instance) {
log.debug("attaching dirty Employee instance");
try {
getHibernateTemplate().saveOrUpdate(instance);
log.debug("attach successful");
} catch (RuntimeException re) {
log.error("attach failed", re);
throw re;
}
}
public void attachClean(Employee instance) {
log.debug("attaching clean Employee instance");
try {
getHibernateTemplate().lock(instance, LockMode.NONE);
log.debug("attach successful");
} catch (RuntimeException re) {
log.error("attach failed", re);
throw re;
}
}
public static EmployeeDAO getFromApplicationContext(ApplicationContext ctx) {
return (EmployeeDAO) ctx.getBean("EmployeeDAO");
}
}
#5
应该是setMapType的问题吧,仔细去检查一下啊