Skip to content

Commit 26c7eaf

Browse files
committed
Updata DDL for JDBC
1 parent 83fd3eb commit 26c7eaf

File tree

6 files changed

+107
-59
lines changed

6 files changed

+107
-59
lines changed

skill/src/main/java/jp/wicresoft/impl/SearchImpl.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
import jp.wicresoft.domain.SkillTitleMst;
1010
import jp.wicresoft.domain.StuffMeta;
1111
import jp.wicresoft.info.IndexViewInfo;
12+
import jp.wicresoft.jdbc.SkillSearchJdbcTemplate;
1213
import jp.wicresoft.repository.SkillTitleMstRepository;
1314
import jp.wicresoft.repository.StuffMetaRepository;
1415

@@ -21,12 +22,15 @@ public class SearchImpl {
2122
@Autowired
2223
StuffMetaRepository stuffMetaRepository;
2324

25+
@Autowired
26+
SkillSearchJdbcTemplate skillSearchJdbcTemplate;
27+
2428
public List<SkillTitleMst> getSkillNameList() {
2529
return skillTitleMstRepository.findAll();
2630
}
2731

2832
public List<IndexViewInfo> getSearchResultBySkill(List<Long> titleIds) {
29-
List<StuffMeta> stuffMetas = stuffMetaRepository.findByIds(titleIds);
33+
List<StuffMeta> stuffMetas = skillSearchJdbcTemplate.findByIds(titleIds);
3034
List<IndexViewInfo> indexViewInfos = new ArrayList<>();
3135
for (StuffMeta stuffMeta : stuffMetas) {
3236
indexViewInfos.add(new IndexViewInfo(stuffMeta));

skill/src/main/java/jp/wicresoft/info/IndexViewInfo.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -45,11 +45,11 @@ public class IndexViewInfo {
4545
*/
4646
public IndexViewInfo(StuffMeta stuffMeta) {
4747

48-
setId(stuffMeta.getId().toString());
48+
setId(String.valueOf(stuffMeta.getId()));
4949

5050
setName(stuffMeta.getName());
5151

52-
setAge(stuffMeta.getAge().toString());
52+
setAge(String.valueOf(stuffMeta.getAge()));
5353

5454
setSex(stuffMeta.isSex() ? "true" : "false");
5555

@@ -70,11 +70,11 @@ public StuffMeta toStuffMeta() {
7070
StuffMeta stuffMeta = new StuffMeta();
7171

7272
stuffMeta.setName(getName());
73-
stuffMeta.setAge(Long.parseLong(getAge()));
73+
stuffMeta.setAge(Integer.parseInt(getAge()));
7474
// TODO
7575
stuffMeta.setSex(false);
76-
stuffMeta.setExperienceYear(Long.parseLong(getExperienceYear()));
77-
stuffMeta.setPrice(Long.parseLong(getPrice()));
76+
stuffMeta.setExperienceYear(Integer.parseInt(getExperienceYear()));
77+
stuffMeta.setPrice(Integer.parseInt(getPrice()));
7878
stuffMeta.setNationality(getNationality());
7979
stuffMeta.setMember(isMember());
8080

skill_db/src/main/java/jp/wicresoft/domain/StuffMeta.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,19 +19,20 @@ public class StuffMeta implements Serializable{
1919

2020
@Id
2121
@GeneratedValue
22-
private Long id;
22+
private int id;
2323

2424
private String name;
2525

26-
private Long age;
26+
private int age;
2727

2828
private boolean sex;
2929

3030
private String nationality;
3131

32-
private Long experienceYear;
32+
private int experienceYear;
3333

34-
private Long price;
34+
private int price;
3535

3636
private boolean isMember;
37+
3738
}

skill_db/src/main/java/jp/wicresoft/jdbc/BasicJdbc.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ public <T> List<T> convertJdbcMapToBean(List<Map<String, Object>> mapList, Class
2727
}
2828
resultList.add(object);
2929
} catch (SecurityException | IllegalAccessException | IllegalArgumentException | InvocationTargetException | InstantiationException e) {
30-
// TODO Auto-generated catch block
3130
e.printStackTrace();
3231
}
3332
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
package jp.wicresoft.jdbc;
2+
3+
import java.util.List;
4+
import java.util.Map;
5+
6+
import org.springframework.beans.factory.annotation.Autowired;
7+
import org.springframework.jdbc.core.JdbcTemplate;
8+
import org.springframework.stereotype.Component;
9+
10+
import jp.wicresoft.domain.StuffMeta;
11+
12+
@Component
13+
public class SkillSearchJdbcTemplate extends BasicJdbc{
14+
15+
@Autowired
16+
JdbcTemplate jdbcTemplate;
17+
18+
public List<StuffMeta> findByIds(List<Long> titleIds) {
19+
String queryStr = "select meta.* "
20+
+ "from skill_version_mst v inner join stuff_skill s inner join stuff_meta meta "
21+
+ "on v.skill_title in (1) and v.skill_id = s.skill_id and s.stuff_id = meta.id;";
22+
List<Map<String, Object>> mapList = jdbcTemplate.queryForList(queryStr);
23+
return convertJdbcMapToBean(mapList, StuffMeta.class);
24+
}
25+
}

sql/skill_db.sql

Lines changed: 67 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,18 @@ ALTER DATABASE `skill` COLLATE 'utf8mb4_general_ci';
1616
USE `skill`;
1717

1818

19+
-- Dumping structure for ビュー skill.license_view
20+
DROP VIEW IF EXISTS `license_view`;
21+
-- Creating temporary table to overcome VIEW dependency errors
22+
CREATE TABLE `license_view` (
23+
`skill_id` INT(11) NOT NULL,
24+
`title_name` VARCHAR(50) NOT NULL COLLATE 'utf8mb4_general_ci',
25+
`version_name` VARCHAR(50) NOT NULL COLLATE 'utf8mb4_general_ci'
26+
) ENGINE=MyISAM;
27+
28+
1929
-- Dumping structure for テーブル skill.skill_category_mst
30+
DROP TABLE IF EXISTS `skill_category_mst`;
2031
CREATE TABLE IF NOT EXISTS `skill_category_mst` (
2132
`skill_category_id` int(11) NOT NULL AUTO_INCREMENT,
2233
`category_name` varchar(50) NOT NULL,
@@ -27,6 +38,7 @@ CREATE TABLE IF NOT EXISTS `skill_category_mst` (
2738

2839

2940
-- Dumping structure for テーブル skill.skill_title_mst
41+
DROP TABLE IF EXISTS `skill_title_mst`;
3042
CREATE TABLE IF NOT EXISTS `skill_title_mst` (
3143
`skill_title_id` int(11) NOT NULL AUTO_INCREMENT,
3244
`title_name` varchar(50) NOT NULL,
@@ -40,10 +52,11 @@ CREATE TABLE IF NOT EXISTS `skill_title_mst` (
4052

4153

4254
-- Dumping structure for テーブル skill.skill_version_mst
55+
DROP TABLE IF EXISTS `skill_version_mst`;
4356
CREATE TABLE IF NOT EXISTS `skill_version_mst` (
4457
`skill_id` int(11) NOT NULL AUTO_INCREMENT,
4558
`skill_title` int(11) NOT NULL,
46-
`version_name` varchar(50) NOT NULL,
59+
`version_name` varchar(50) NOT NULL DEFAULT '',
4760
PRIMARY KEY (`skill_id`),
4861
UNIQUE KEY `name_version` (`skill_title`,`version_name`),
4962
CONSTRAINT `SKILL_VERSION_MST_SKILL_TITLE_FK` FOREIGN KEY (`skill_title`) REFERENCES `skill_title_mst` (`skill_title_id`)
@@ -52,7 +65,18 @@ CREATE TABLE IF NOT EXISTS `skill_version_mst` (
5265
-- エクスポートするデータが選択されていません
5366

5467

68+
-- Dumping structure for ビュー skill.stuff_db
69+
DROP VIEW IF EXISTS `stuff_db`;
70+
-- Creating temporary table to overcome VIEW dependency errors
71+
CREATE TABLE `stuff_db` (
72+
`id` INT(11) NOT NULL,
73+
`stuff_id` INT(11) NOT NULL,
74+
`db_name` VARCHAR(101) NOT NULL COLLATE 'utf8mb4_general_ci'
75+
) ENGINE=MyISAM;
76+
77+
5578
-- Dumping structure for テーブル skill.stuff_db_back
79+
DROP TABLE IF EXISTS `stuff_db_back`;
5680
CREATE TABLE IF NOT EXISTS `stuff_db_back` (
5781
`id` int(11) NOT NULL AUTO_INCREMENT,
5882
`stuff_id` int(11) NOT NULL COMMENT '社員ナンバー',
@@ -66,7 +90,18 @@ CREATE TABLE IF NOT EXISTS `stuff_db_back` (
6690
-- エクスポートするデータが選択されていません
6791

6892

93+
-- Dumping structure for ビュー skill.stuff_develop_language
94+
DROP VIEW IF EXISTS `stuff_develop_language`;
95+
-- Creating temporary table to overcome VIEW dependency errors
96+
CREATE TABLE `stuff_develop_language` (
97+
`id` INT(11) NOT NULL,
98+
`stuff_id` INT(11) NOT NULL,
99+
`develop_language_name` VARCHAR(101) NOT NULL COLLATE 'utf8mb4_general_ci'
100+
) ENGINE=MyISAM;
101+
102+
69103
-- Dumping structure for テーブル skill.stuff_develop_language_back
104+
DROP TABLE IF EXISTS `stuff_develop_language_back`;
70105
CREATE TABLE IF NOT EXISTS `stuff_develop_language_back` (
71106
`id` int(11) NOT NULL AUTO_INCREMENT,
72107
`stuff_id` int(11) NOT NULL COMMENT '社員ナンバー',
@@ -79,7 +114,18 @@ CREATE TABLE IF NOT EXISTS `stuff_develop_language_back` (
79114
-- エクスポートするデータが選択されていません
80115

81116

117+
-- Dumping structure for ビュー skill.stuff_license
118+
DROP VIEW IF EXISTS `stuff_license`;
119+
-- Creating temporary table to overcome VIEW dependency errors
120+
CREATE TABLE `stuff_license` (
121+
`id` INT(11) NOT NULL,
122+
`stuff_id` INT(11) NOT NULL,
123+
`license_name` VARCHAR(101) NOT NULL COLLATE 'utf8mb4_general_ci'
124+
) ENGINE=MyISAM;
125+
126+
82127
-- Dumping structure for テーブル skill.stuff_license_back
128+
DROP TABLE IF EXISTS `stuff_license_back`;
83129
CREATE TABLE IF NOT EXISTS `stuff_license_back` (
84130
`id` int(11) NOT NULL AUTO_INCREMENT,
85131
`stuff_id` int(11) NOT NULL COMMENT '社員ナンバー',
@@ -93,22 +139,34 @@ CREATE TABLE IF NOT EXISTS `stuff_license_back` (
93139

94140

95141
-- Dumping structure for テーブル skill.stuff_meta
142+
DROP TABLE IF EXISTS `stuff_meta`;
96143
CREATE TABLE IF NOT EXISTS `stuff_meta` (
97144
`id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'ID',
98145
`name` varchar(50) NOT NULL COMMENT '名前',
99146
`age` int(11) NOT NULL COMMENT '年齢',
100-
`sex` tinyint(4) NOT NULL COMMENT '性別 1:男 0:女',
147+
`sex` tinyint(1) NOT NULL COMMENT '性別 1:男 0:女',
101148
`nationality` varchar(50) NOT NULL COMMENT '国籍',
102149
`experience_year` int(11) NOT NULL COMMENT '経験年数',
103150
`price` int(11) NOT NULL COMMENT '単価',
104-
`is_member` tinyint(4) NOT NULL COMMENT '自社社員 1:自社 0:他社',
151+
`is_member` tinyint(1) NOT NULL COMMENT '自社社員 1:自社 0:他社',
105152
PRIMARY KEY (`id`)
106153
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
107154

108155
-- エクスポートするデータが選択されていません
109156

110157

158+
-- Dumping structure for ビュー skill.stuff_os
159+
DROP VIEW IF EXISTS `stuff_os`;
160+
-- Creating temporary table to overcome VIEW dependency errors
161+
CREATE TABLE `stuff_os` (
162+
`id` INT(11) NOT NULL,
163+
`stuff_id` INT(11) NOT NULL,
164+
`os_name` VARCHAR(101) NOT NULL COLLATE 'utf8mb4_general_ci'
165+
) ENGINE=MyISAM;
166+
167+
111168
-- Dumping structure for テーブル skill.stuff_os_back
169+
DROP TABLE IF EXISTS `stuff_os_back`;
112170
CREATE TABLE IF NOT EXISTS `stuff_os_back` (
113171
`id` int(11) NOT NULL AUTO_INCREMENT,
114172
`stuff_id` int(11) NOT NULL COMMENT '社員ナンバー',
@@ -122,6 +180,7 @@ CREATE TABLE IF NOT EXISTS `stuff_os_back` (
122180

123181

124182
-- Dumping structure for テーブル skill.stuff_skill
183+
DROP TABLE IF EXISTS `stuff_skill`;
125184
CREATE TABLE IF NOT EXISTS `stuff_skill` (
126185
`stuff_id` int(11) NOT NULL,
127186
`skill_id` int(11) NOT NULL,
@@ -135,75 +194,35 @@ CREATE TABLE IF NOT EXISTS `stuff_skill` (
135194

136195

137196
-- Dumping structure for ビュー skill.license_view
138-
-- Creating temporary table to overcome VIEW dependency errors
139-
CREATE TABLE `license_view` (
140-
`skill_id` INT(11) NOT NULL,
141-
`title_name` VARCHAR(50) NOT NULL COLLATE 'utf8mb4_general_ci',
142-
`version_name` VARCHAR(50) NOT NULL COLLATE 'utf8mb4_general_ci'
143-
) ENGINE=MyISAM;
144-
145-
146-
-- Dumping structure for ビュー skill.stuff_db
147-
-- Creating temporary table to overcome VIEW dependency errors
148-
CREATE TABLE `stuff_db` (
149-
`id` INT(11) NOT NULL,
150-
`stuff_id` INT(11) NOT NULL,
151-
`db_name` VARCHAR(101) NOT NULL COLLATE 'utf8mb4_general_ci'
152-
) ENGINE=MyISAM;
153-
154-
155-
-- Dumping structure for ビュー skill.stuff_develop_language
156-
-- Creating temporary table to overcome VIEW dependency errors
157-
CREATE TABLE `stuff_develop_language` (
158-
`id` INT(11) NOT NULL,
159-
`stuff_id` INT(11) NOT NULL,
160-
`develop_language_name` VARCHAR(101) NOT NULL COLLATE 'utf8mb4_general_ci'
161-
) ENGINE=MyISAM;
162-
163-
164-
-- Dumping structure for ビュー skill.stuff_license
165-
-- Creating temporary table to overcome VIEW dependency errors
166-
CREATE TABLE `stuff_license` (
167-
`id` INT(11) NOT NULL,
168-
`stuff_id` INT(11) NOT NULL,
169-
`license_name` VARCHAR(101) NOT NULL COLLATE 'utf8mb4_general_ci'
170-
) ENGINE=MyISAM;
171-
172-
173-
-- Dumping structure for ビュー skill.stuff_os
174-
-- Creating temporary table to overcome VIEW dependency errors
175-
CREATE TABLE `stuff_os` (
176-
`id` INT(11) NOT NULL,
177-
`stuff_id` INT(11) NOT NULL,
178-
`os_name` VARCHAR(101) NOT NULL COLLATE 'utf8mb4_general_ci'
179-
) ENGINE=MyISAM;
180-
181-
182-
-- Dumping structure for ビュー skill.license_view
197+
DROP VIEW IF EXISTS `license_view`;
183198
-- Removing temporary table and create final VIEW structure
184199
DROP TABLE IF EXISTS `license_view`;
185200
CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `license_view` AS select `v`.`skill_id` AS `skill_id`,`t`.`title_name` AS `title_name`,`v`.`version_name` AS `version_name` from (`skill_title_mst` `t` join `skill_version_mst` `v` on((`t`.`skill_title_id` = `v`.`skill_title`)));
186201

187202

188203
-- Dumping structure for ビュー skill.stuff_db
204+
DROP VIEW IF EXISTS `stuff_db`;
189205
-- Removing temporary table and create final VIEW structure
190206
DROP TABLE IF EXISTS `stuff_db`;
191207
CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `stuff_db` AS select `v`.`skill_id` AS `id`,`s`.`stuff_id` AS `stuff_id`,concat(`t`.`title_name`,' ',`v`.`version_name`) AS `db_name` from ((`skill_title_mst` `t` join `skill_version_mst` `v`) join `stuff_skill` `s` on(((`t`.`skill_category` = 3) and (`t`.`skill_title_id` = `v`.`skill_title`) and (`v`.`skill_id` = `s`.`skill_id`))));
192208

193209

194210
-- Dumping structure for ビュー skill.stuff_develop_language
211+
DROP VIEW IF EXISTS `stuff_develop_language`;
195212
-- Removing temporary table and create final VIEW structure
196213
DROP TABLE IF EXISTS `stuff_develop_language`;
197214
CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `stuff_develop_language` AS select `v`.`skill_id` AS `id`,`s`.`stuff_id` AS `stuff_id`,concat(`t`.`title_name`,' ',`v`.`version_name`) AS `develop_language_name` from ((`skill_title_mst` `t` join `skill_version_mst` `v`) join `stuff_skill` `s` on(((`t`.`skill_category` = 4) and (`t`.`skill_title_id` = `v`.`skill_title`) and (`v`.`skill_id` = `s`.`skill_id`))));
198215

199216

200217
-- Dumping structure for ビュー skill.stuff_license
218+
DROP VIEW IF EXISTS `stuff_license`;
201219
-- Removing temporary table and create final VIEW structure
202220
DROP TABLE IF EXISTS `stuff_license`;
203221
CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `stuff_license` AS select `v`.`skill_id` AS `id`,`s`.`stuff_id` AS `stuff_id`,concat(`t`.`title_name`,' ',`v`.`version_name`) AS `license_name` from ((`skill_title_mst` `t` join `skill_version_mst` `v`) join `stuff_skill` `s` on(((`t`.`skill_category` = 1) and (`t`.`skill_title_id` = `v`.`skill_title`) and (`v`.`skill_id` = `s`.`skill_id`))));
204222

205223

206224
-- Dumping structure for ビュー skill.stuff_os
225+
DROP VIEW IF EXISTS `stuff_os`;
207226
-- Removing temporary table and create final VIEW structure
208227
DROP TABLE IF EXISTS `stuff_os`;
209228
CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `stuff_os` AS select `v`.`skill_id` AS `id`,`s`.`stuff_id` AS `stuff_id`,concat(`t`.`title_name`,' ',`v`.`version_name`) AS `os_name` from ((`skill_title_mst` `t` join `skill_version_mst` `v`) join `stuff_skill` `s` on(((`t`.`skill_category` = 2) and (`t`.`skill_title_id` = `v`.`skill_title`) and (`v`.`skill_id` = `s`.`skill_id`))));

0 commit comments

Comments
 (0)