spring,hibernate,dao操作数据库模…
来源:互联网 发布:淘宝站内营销手段 编辑:程序博客网 时间:2024/05/21 11:17
table:
create table users
(
id int auto_increment not null primary key,
name varchar(32) not null,
password varchar(32) not null
);
select * from users
insert into users (name,password) values('text','text');
insert into users(name,password) select name,password fromusers;
dao:
package com.ssh.dao;
import java.util.List;
import com.ssh.orm.Users;
public interface UsersDao {
public boolean insert(Users users) throws Exception;
public Users select(int id) throws Exception;
public boolean update(Users users) throws Exception;
public boolean delete(int id) throws Exception;
public List selectAll() throws Exception;
public List selectAllByPage(int curPage, int lineSize) throwsException;
public int getCount() throws Exception;
}
daoImpl:
package com.ssh.dao.impl;
import java.util.List;
import org.hibernate.Query;
importorg.springframework.orm.hibernate3.support.HibernateDaoSupport;
import com.ssh.dao.UsersDao;
import com.ssh.orm.Users;
public class UsersDaoImpl extends HibernateDaoSupport implementsUsersDao {
public boolean delete(int id) throws Exception {
}
public boolean insert(Users users) throws Exception {
}
public Users select(int id) throws Exception {
}
public boolean update(Users users) throws Exception {
}
public List selectAll() throws Exception {
}
public List selectAllByPage(int curPage, int lineSize) throwsException {
}
public int getCount() throws Exception {
}
}
operate:
package com.ssh.text;
import java.util.List;
import org.springframework.context.ApplicationContext;
importorg.springframework.context.support.ClassPathXmlApplicationC
import com.ssh.dao.impl.UsersDaoImpl;
import com.ssh.orm.Users;
public class Text {
public static void main(String[] args) throws Exception {
}
}
applicationContext.xml:
<?xml version="1.0"encoding="UTF-8"?>
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN""http://www.springframework.org/dtd/spring-beans.dtd">
<beans>
<bean id="dataSource"
</bean>
<beanid="sessionFactory"
</bean>
</bean>
<bean id="userDao" class="com.ssh.dao.UsersDao"abstract="true"></bean>
<bean id="userDaoImpl"class="com.ssh.dao.impl.UsersDaoImpl"
</bean>
</beans>
Hibernate映射文件和Users 类不在写出。
- spring,hibernate,dao操作数据库模…
- Spring与Hibernate Dao中操作数据库的另外方式
- Hibernate 数据库操作 DAO 实例
- Spring使用DAO完成数据库操作
- Spring的DAO模块数据库操作实例
- spring-hibernate 简单dao
- Spring+Hibernate整合框架下DAO的数据库访问方法
- Spring中常用的操作数据库的(Dao)方法
- DAO 操作数据库
- 数据库操作dao文件
- DAO数据库操作
- VC DAO 操作数据库
- spring boot 拦截器 注入dao 操作数据库时dao 为null
- DAO测试策略(spring, hibernate)
- Hibernate泛型Dao(依赖spring)
- hibernate的DAO写不进数据库
- 使用Spring+Hibernate同时操作两个数据库
- spring结合hibernate的数据库操作
- Spring学习2—Spring容器
- Spring学习8- SSH需要的jar…
- 关于得到子!!childhtml 关于------- magento getChildHtml() 与getChildChildHtml()
- ssh配置文件大全
- hibenate.hbm2ddl.auto属性详解
- spring,hibernate,dao操作数据库模…
- HibernateDaoSupport和 Hiber…
- struts1文件上传
- java代码修改服务器自动重启
- 比较LINQ to Entities的AsQueryable和AsEnumerable方法
- java 文件下载(含POI)
- Struts1 文件上传(含poi)
- 关于改 服务器时间的 测试
- MyEclipse 默认工作空间的设…