SSH_spring4.2_hibernate5完整示例代码
hibernate-release-5.0.2.Final spring-framework-4.2.1.RELEASE 数据库是 mysql 数据库的连接符 jdbc:mysql://localhost:3306/test_db?useUnicode=true&characterEncoding=UTF-8 放在jdbc.properties 文件中 创建完成数据库test_db后,在eclipse中,执行 @Test public void testSaveMore() 由hibernate5 根据映射文件Person.hbm.xml自动生成person表,表结构可参考如下sql语句 /* Navicat MySQL Data Transfer Source Server : MYSQL56 Source Server Version : 50624 Source Host : localhost:3306 Source Database : test_db Target Server Type : MYSQL Target Server Version : 50624 File Encoding : 65001 Date: 2015-10-27 11:16:43 */ SET FOREIGN_KEY_CHECKS=0; -- ---------------------------- -- Table structure for `person` -- ---------------------------- DROP TABLE IF EXISTS `person`; CREATE TABLE `person` ( `id` int(11) NOT NULL AUTO_INCREMENT, `name` varchar(10) NOT NULL, PRIMARY KEY (`id`) ) ENGINE=InnoDB AUTO_INCREMENT=22 DEFAULT CHARSET=utf8; -- ---------------------------- -- Records of person -- ---------------------------- INSERT INTO `person` VALUES ('1', '小张'); INSERT INTO `person` VALUES ('12', '测试数据0'); INSERT INTO `person` VALUES ('13', '测试数据1'); INSERT INTO `person` VALUES ('14', '测试数据2'); INSERT INTO `person` VALUES ('15', '测试数据3'); INSERT INTO `person` VALUES ('16', '测试数据4'); INSERT INTO `person` VALUES ('17', '测试数据5'); INSERT INTO `person` VALUES ('18', '测试数据6'); INSERT INTO `person` VALUES ('19', '测试数据7'); INSERT INTO `person` VALUES ('20', '测试数据8'); INSERT INTO `person` VALUES ('21', '测试数据9');
- 1
- 粉丝: 17
- 资源: 176
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
- 1
- 2
前往页