• 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

Revision69 (tree)
Time2015-08-20 23:45:46
Authort_nakayama1971

Log Message

(empty log message)

Change Summary

Incremental Difference

--- trunk/framework/fwBase/src/common/db/dao/hibernate/MainDao.java (revision 68)
+++ trunk/framework/fwBase/src/common/db/dao/hibernate/MainDao.java (revision 69)
@@ -18,7 +18,6 @@
1818 import common.db.dao.DaoConstraintException;
1919 import common.db.dao.DaoLockException;
2020 import common.db.dao.DaoPropertyException;
21-
2221 import core.exception.PhysicalException;
2322 import core.exception.ThrowableUtil;
2423
@@ -205,10 +204,9 @@
205204 /**
206205 * フラッシュ処理
207206 *
208- * @param session セションオブジェクト
209207 */
210208 @Override
211- protected final void flushSession(final Session session, final Serializable item) {
209+ protected final void flushSession(final Serializable item) {
212210 return;
213211 }
214212 }
--- trunk/framework/fwBase/src/common/db/dao/hibernate/BaseDao.java (revision 68)
+++ trunk/framework/fwBase/src/common/db/dao/hibernate/BaseDao.java (revision 69)
@@ -173,15 +173,14 @@
173173 */
174174 private <T> T find(final Class<T> cls, final Serializable id, final LockOptions lo) {
175175 try {
176- // セションオブジェクト取得
177- Session session = getSession();
178176 // トランザクション開始
179177 beginTransaction();
180178 // 読込
181- Object obj = session.load(cls, id, lo);
182- session.evict(obj);
179+ Object obj = getSession().load(cls, id, lo);
180+ getSession().evict(obj);
183181 return cls.cast(obj);
184182 } catch (final ObjectNotFoundException ex) {
183+ LogManager.getLogger().info(ex.getMessage());
185184 return null;
186185 } catch (final HibernateException ex) {
187186 ThrowableUtil.error(ex);
@@ -200,16 +199,12 @@
200199 toNull(item);
201200 try {
202201 if (isEntity(item.getClass())) {
203- // セションオブジェクト取得
204- Session session = getSession();
205- if (session.contains(item) && session.isReadOnly(item)) {
206- session.evict(item);
207- }
202+ evict(item);
208203 // トランザクション開始
209204 beginTransaction();
210205 // 保存
211- session.save(item);
212- flushSession(session, item);
206+ getSession().save(item);
207+ flushSession(item);
213208 } else {
214209 setId(item);
215210 List<Object> param = new ArrayList<>();
@@ -260,16 +255,12 @@
260255 // NULL可項目NULL化
261256 toNull(item);
262257 try {
263- // セションオブジェクト取得
264- Session session = getSession();
265- if (session.contains(item) && session.isReadOnly(item)) {
266- session.evict(item);
267- }
258+ evict(item);
268259 // トランザクション開始
269260 beginTransaction();
270261 // 更新
271- session.merge(item);
272- flushSession(session, item);
262+ getSession().merge(item);
263+ flushSession(item);
273264 } catch (final LockAcquisitionException ex) {
274265 LogManager.getLogger().info(ex.getMessage());
275266 throw new DaoLockException(ex, this.noWait);
@@ -298,16 +289,12 @@
298289 toNull(item);
299290 try {
300291 if (isEntity(item.getClass())) {
301- // セションオブジェクト取得
302- Session session = getSession();
303- if (session.contains(item) && session.isReadOnly(item)) {
304- session.evict(item);
305- }
292+ evict(item);
306293 // トランザクション開始
307294 beginTransaction();
308295 // 更新
309- session.update(item);
310- flushSession(session, item);
296+ getSession().update(item);
297+ flushSession(item);
311298 } else {
312299 List<Object> param = new ArrayList<>();
313300 execute(EntityUtil.toUpdateSql(item, param),
@@ -347,16 +334,12 @@
347334 public final boolean delete(final Serializable item) {
348335 try {
349336 if (isEntity(item.getClass())) {
350- // セションオブジェクト取得
351- Session session = getSession();
352- if (session.contains(item) && session.isReadOnly(item)) {
353- session.evict(item);
354- }
337+ evict(item);
355338 // トランザクション開始
356339 beginTransaction();
357340 // 削除処理
358- session.delete(item);
359- flushSession(session, item);
341+ getSession().delete(item);
342+ flushSession(item);
360343 } else {
361344 List<Object> param = new ArrayList<>();
362345 execute(EntityUtil.toDeleteSql(item, param),
@@ -380,6 +363,16 @@
380363 }
381364
382365 /**
366+ * 分離
367+ * @param item 対象モデル
368+ */
369+ private void evict(final Serializable item) {
370+ if (getSession().contains(item) && getSession().isReadOnly(item)) {
371+ getSession().evict(item);
372+ }
373+ }
374+
375+ /**
383376 * ネイティブSQLクエリ実行
384377 * @param <T> ジェネリックス
385378 *
@@ -391,16 +384,14 @@
391384 @Override
392385 public final <T> T select(final Class<T> cls, final String query, final Object... vals) {
393386 try {
394- // セションオブジェクト取得
395- Session session = getSession();
396387 // トランザクション開始
397388 beginTransaction();
398389
399- List<T> list = createQuery(session, getRecordClass(cls),
390+ List<T> list = createQuery(getSession(), getRecordClass(cls),
400391 query, vals).setReadOnly(true).setMaxResults(1).list();
401392 if (list != null && !list.isEmpty()) {
402393 if (isEntity(cls)) {
403- session.evict(list.get(0));
394+ getSession().evict(list.get(0));
404395 } else if (cls != null && !isJavaClass(cls)) {
405396 return EntityUtil.toEntity(Factory.cast(list.get(0)), cls);
406397 }
@@ -408,6 +399,7 @@
408399 }
409400 return null;
410401 } catch (final ObjectNotFoundException | DataException ex) {
402+ LogManager.getLogger().info(ex.getMessage());
411403 return null;
412404 } catch (final HibernateException ex) {
413405 ThrowableUtil.error(ex);
@@ -431,17 +423,16 @@
431423 }
432424
433425 try {
434- // セションオブジェクト取得
435- Session session = getSession();
436426 // トランザクション開始
437427 beginTransaction();
438428
439- List<T> list = createQuery(session, getRecordClass(cls), addFor(query), vals).list();
429+ List<T> list = createQuery(getSession(),
430+ getRecordClass(cls), addFor(query), vals).list();
440431 if (list == null || list.isEmpty()) {
441432 return null;
442433 } else if (list.size() == 1) {
443434 if (isEntity(cls)) {
444- session.evict(list.get(0));
435+ getSession().evict(list.get(0));
445436 } else if (cls != null) {
446437 return EntityUtil.toEntity(Factory.cast(list.get(0)), cls);
447438 }
@@ -450,6 +441,7 @@
450441
451442 throw new IllegalStateException("More than one record is selected.");
452443 } catch (final ObjectNotFoundException | DataException ex) {
444+ LogManager.getLogger().info(ex.getMessage());
453445 return null;
454446 } catch (final LockAcquisitionException ex) {
455447 LogManager.getLogger().info(ex.getMessage());
@@ -484,19 +476,18 @@
484476 public final <T> List<T> selectAll(final Class<T> cls,
485477 final String query, final Object... vals) {
486478 try {
487- // セションオブジェクト取得
488- Session session = getSession();
489479 // トランザクション開始
490480 beginTransaction();
491481
492482 // String sql = query.replaceAll(" [Ff][Oo][Rr] .*", "");
493- List<T> list = createQuery(
494- session, getRecordClass(cls), query, vals).setReadOnly(true).list();
483+ List<T> list = createQuery(getSession(),
484+ getRecordClass(cls), query, vals).setReadOnly(true).list();
495485 if (cls != null && !isEntity(cls) && !isJavaClass(cls)) {
496486 return EntityUtil.toEntityList(Factory.cast(list), cls);
497487 }
498488 return list;
499489 } catch (final ObjectNotFoundException | DataException ex) {
490+ LogManager.getLogger().info(ex.getMessage());
500491 return null;
501492 } catch (final HibernateException ex) {
502493 ThrowableUtil.error(ex);
@@ -522,13 +513,11 @@
522513 @Override
523514 public final int execute(final String query, final Object... vals) {
524515 try {
525- // セションオブジェクト取得
526- Session session = getSession();
527516 // トランザクション開始
528517 beginTransaction();
529518
530- session.flush();
531- SQLQuery sql = createQuery(session, null, query, vals);
519+ getSession().flush();
520+ SQLQuery sql = createQuery(getSession(), null, query, vals);
532521 return sql.executeUpdate();
533522 } catch (final LockAcquisitionException ex) {
534523 LogManager.getLogger().info(ex.getMessage());
@@ -553,9 +542,8 @@
553542 HibernateJdbcWork.class.cast(work).setDialect(this.config.getDialect());
554543 }
555544 try {
556- Session session = getSession();
557545 beginTransaction();
558- session.doWork(new WorkWrap(work));
546+ getSession().doWork(new WorkWrap(work));
559547 } catch (final HibernateException ex) {
560548 ThrowableUtil.error(ex);
561549 throw new PhysicalException(ex);
@@ -658,10 +646,9 @@
658646 /**
659647 * 同期化
660648 *
661- * @param session セション
662649 * @param item 挿入対象モデル
663650 */
664- protected abstract void flushSession(final Session session, final Serializable item);
651+ protected abstract void flushSession(final Serializable item);
665652
666653 /**
667654 * 更新用処理確認
--- trunk/framework/fwBase/src/common/db/dao/hibernate/JtaDao.java (revision 68)
+++ trunk/framework/fwBase/src/common/db/dao/hibernate/JtaDao.java (revision 69)
@@ -139,12 +139,11 @@
139139 /**
140140 * フラッシュ処理
141141 *
142- * @param session セションオブジェクト
143142 */
144143 @Override
145- protected final void flushSession(final Session session, final Serializable item) {
146- session.flush();
147- session.evict(item);
144+ protected final void flushSession(final Serializable item) {
145+ getSession().flush();
146+ getSession().evict(item);
148147 }
149148
150149 /**