• R/O
  • SSH
  • HTTPS

Commit

Tags
No Tags

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

Commit MetaInfo

Revision150 (tree)
Time2015-11-19 20:09:54
Authort_nakayama1971

Log Message

(empty log message)

Change Summary

Incremental Difference

--- trunk/framework/pjSvc/src/project/base/QueryAbstract.java (revision 149)
+++ trunk/framework/pjSvc/src/project/base/QueryAbstract.java (revision 150)
@@ -1,18 +1,14 @@
11 package project.base;
22
33 import java.nio.charset.Charset;
4-import java.sql.ResultSet;
5-import java.sql.ResultSetMetaData;
6-import java.sql.SQLException;
74 import java.util.HashMap;
85 import java.util.Map;
96 import java.util.Objects;
107
11-import online.model.UniModel;
12-import online.model.UniModelImpl;
138 import common.db.JdbcSource;
149 import common.sql.QueryUtil;
1510 import core.util.bean.CamelCase;
11+import online.model.UniModel;
1612
1713 /**
1814 * クエリ親クラス
@@ -85,97 +81,6 @@
8581 }
8682
8783 /**
88- * 汎用モデル初期化
89- *
90- * @param rs 結果セット
91- * @return 汎用モデル
92- * @throws SQLException SQL例外
93- */
94- protected final UniModel initModel(final ResultSet rs) throws SQLException {
95- UniModel ret = new UniModelImpl();
96-
97- ResultSetMetaData rsmd = rs.getMetaData();
98- for (int i = 1; i <= rsmd.getColumnCount(); i++) {
99- ret.noValue(toCamelCase(rsmd.getColumnLabel(i)));
100- }
101-
102- return ret;
103- }
104-
105- /**
106- * 値追加
107- * @param um 汎用モデル
108- * @param rs 結果セット
109- * @param i カラム位置
110- * @throws SQLException SQL例外
111- */
112- protected final void addValue(final UniModel um,
113- final ResultSet rs, final int i) throws SQLException {
114- boolean added = false;
115- ResultSetMetaData rsmd = rs.getMetaData();
116- String key = toCamelCase(rsmd.getColumnLabel(i));
117- switch (rsmd.getColumnType(i)) {
118- case java.sql.Types.DATE:
119- um.addValue(key, rs.getDate(i));
120- added = true;
121- break;
122- case java.sql.Types.TIME:
123- um.addValue(key, rs.getTime(i));
124- added = true;
125- break;
126- case java.sql.Types.TIMESTAMP:
127- um.addValue(key, rs.getTimestamp(i));
128- added = true;
129- break;
130- case java.sql.Types.CHAR:
131- case java.sql.Types.VARCHAR:
132- um.addValue(key, rs.getString(i));
133- added = true;
134- break;
135- case java.sql.Types.NUMERIC:
136- case java.sql.Types.DECIMAL:
137- um.addValue(key, rs.getBigDecimal(i));
138- added = true;
139- break;
140- default:
141- break;
142- }
143-
144- if (added) {
145- return;
146- }
147-
148- switch (rsmd.getColumnType(i)) {
149- case java.sql.Types.SMALLINT:
150- case java.sql.Types.INTEGER:
151- if (rs.getObject(i) == null) {
152- um.addValue(key, Integer.class.cast(null));
153- } else {
154- um.addValue(key, Integer.valueOf(rs.getInt(i)));
155- }
156- break;
157- case java.sql.Types.BIGINT:
158- if (rs.getObject(i) == null) {
159- um.addValue(key, Long.class.cast(null));
160- } else {
161- um.addValue(key, Long.valueOf(rs.getLong(i)));
162- }
163- break;
164- case java.sql.Types.DOUBLE:
165- case java.sql.Types.FLOAT:
166- if (rs.getObject(i) == null) {
167- um.addValue(key, Double.class.cast(null));
168- } else {
169- um.addValue(key, Double.valueOf(rs.getDouble(i)));
170- }
171- break;
172- default:
173- um.addValue(key, rs.getString(i));
174- break;
175- }
176- }
177-
178- /**
17984 * CamelCase化
18085 * @param val 文字列
18186 * @return CamelCase文字列
--- trunk/framework/pjSvc/src/project/svc/generic/QueryService.java (revision 149)
+++ trunk/framework/pjSvc/src/project/svc/generic/QueryService.java (revision 150)
@@ -58,7 +58,7 @@
5858 */
5959 @Override
6060 public boolean callback(final ResultSet rs) throws SQLException {
61- this.model.putAll(super.initModel(rs));
61+ this.model.putAll(initModel(rs));
6262
6363 boolean ret = false;
6464 ResultSetMetaData rsmd = rs.getMetaData();
@@ -65,7 +65,7 @@
6565 while (rs.next()) {
6666 ret = true;
6767 for (int i = 1; i <= rsmd.getColumnCount(); i++) {
68- super.addValue(this.model, rs, i);
68+ addValue(this.model, rs, i);
6969 }
7070 }
7171 return ret;
@@ -72,6 +72,97 @@
7272 }
7373
7474 /**
75+ * 汎用モデル初期化
76+ *
77+ * @param rs 結果セット
78+ * @return 汎用モデル
79+ * @throws SQLException SQL例外
80+ */
81+ private UniModel initModel(final ResultSet rs) throws SQLException {
82+ UniModel ret = new UniModelImpl();
83+
84+ ResultSetMetaData rsmd = rs.getMetaData();
85+ for (int i = 1; i <= rsmd.getColumnCount(); i++) {
86+ ret.noValue(toCamelCase(rsmd.getColumnLabel(i)));
87+ }
88+
89+ return ret;
90+ }
91+
92+ /**
93+ * 値追加
94+ * @param um 汎用モデル
95+ * @param rs 結果セット
96+ * @param i カラム位置
97+ * @throws SQLException SQL例外
98+ */
99+ private void addValue(final UniModel um,
100+ final ResultSet rs, final int i) throws SQLException {
101+ boolean added = false;
102+ ResultSetMetaData rsmd = rs.getMetaData();
103+ String key = toCamelCase(rsmd.getColumnLabel(i));
104+ switch (rsmd.getColumnType(i)) {
105+ case java.sql.Types.DATE:
106+ um.addValue(key, rs.getDate(i));
107+ added = true;
108+ break;
109+ case java.sql.Types.TIME:
110+ um.addValue(key, rs.getTime(i));
111+ added = true;
112+ break;
113+ case java.sql.Types.TIMESTAMP:
114+ um.addValue(key, rs.getTimestamp(i));
115+ added = true;
116+ break;
117+ case java.sql.Types.CHAR:
118+ case java.sql.Types.VARCHAR:
119+ um.addValue(key, rs.getString(i));
120+ added = true;
121+ break;
122+ case java.sql.Types.NUMERIC:
123+ case java.sql.Types.DECIMAL:
124+ um.addValue(key, rs.getBigDecimal(i));
125+ added = true;
126+ break;
127+ default:
128+ break;
129+ }
130+
131+ if (added) {
132+ return;
133+ }
134+
135+ switch (rsmd.getColumnType(i)) {
136+ case java.sql.Types.SMALLINT:
137+ case java.sql.Types.INTEGER:
138+ if (rs.getObject(i) == null) {
139+ um.addValue(key, Integer.class.cast(null));
140+ } else {
141+ um.addValue(key, Integer.valueOf(rs.getInt(i)));
142+ }
143+ break;
144+ case java.sql.Types.BIGINT:
145+ if (rs.getObject(i) == null) {
146+ um.addValue(key, Long.class.cast(null));
147+ } else {
148+ um.addValue(key, Long.valueOf(rs.getLong(i)));
149+ }
150+ break;
151+ case java.sql.Types.DOUBLE:
152+ case java.sql.Types.FLOAT:
153+ if (rs.getObject(i) == null) {
154+ um.addValue(key, Double.class.cast(null));
155+ } else {
156+ um.addValue(key, Double.valueOf(rs.getDouble(i)));
157+ }
158+ break;
159+ default:
160+ um.addValue(key, rs.getString(i));
161+ break;
162+ }
163+ }
164+
165+ /**
75166 * @see common.sql.SelectQuery#makeParam()
76167 */
77168 @Override