JdbcTemplateEx.java 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727
  1. package com.acc.common.jdbc;
  2. import java.sql.Connection;
  3. import java.sql.PreparedStatement;
  4. import java.sql.ResultSet;
  5. import java.sql.SQLException;
  6. import java.sql.Types;
  7. import java.util.ArrayList;
  8. import java.util.HashMap;
  9. import java.util.Iterator;
  10. import java.util.List;
  11. import java.util.Map;
  12. import javax.sql.DataSource;
  13. import org.springframework.context.ApplicationContext;
  14. import org.springframework.dao.DataAccessException;
  15. import org.springframework.dao.IncorrectResultSizeDataAccessException;
  16. import org.springframework.dao.InvalidDataAccessApiUsageException;
  17. import org.springframework.jdbc.core.BatchPreparedStatementSetter;
  18. import org.springframework.jdbc.core.ColumnMapRowMapper;
  19. import org.springframework.jdbc.core.JdbcTemplate;
  20. import org.springframework.jdbc.core.ParameterDisposer;
  21. import org.springframework.jdbc.core.PreparedStatementCallback;
  22. import org.springframework.jdbc.core.PreparedStatementCreator;
  23. import org.springframework.jdbc.core.PreparedStatementSetter;
  24. import org.springframework.jdbc.core.ResultSetExtractor;
  25. import org.springframework.jdbc.core.RowMapper;
  26. import org.springframework.jdbc.core.RowMapperResultSetExtractor;
  27. import org.springframework.jdbc.core.SingleColumnRowMapper;
  28. import org.springframework.jdbc.core.SqlProvider;
  29. import org.springframework.jdbc.core.SqlTypeValue;
  30. import org.springframework.jdbc.core.StatementCreatorUtils;
  31. import org.springframework.jdbc.core.support.SqlLobValue;
  32. import org.springframework.jdbc.support.JdbcUtils;
  33. import org.springframework.jdbc.support.incrementer.AbstractSequenceMaxValueIncrementer;
  34. import org.springframework.util.Assert;
  35. import com.acc.common.jdbc.oracle.OracleTypes;
  36. import com.acc.common.spring.ApplicationFactory;
  37. public class JdbcTemplateEx extends JdbcTemplate
  38. {
  39. // 1
  40. private int firstResult;
  41. // 2
  42. private int lastResult;
  43. // 3
  44. public int getFirstResult()
  45. {
  46. return firstResult;
  47. }
  48. // 4
  49. public void setLastResult(int lastResult)
  50. {
  51. if (lastResult < 1)
  52. throw new InvalidDataAccessApiUsageException("lastResult cannot less 1 ");
  53. this.lastResult = lastResult;
  54. }
  55. // 5
  56. public void setFirstResult(int firstResult)
  57. {
  58. if (firstResult < 1)
  59. throw new InvalidDataAccessApiUsageException("firstResult cannot less 1 ");
  60. this.firstResult = firstResult;
  61. }
  62. // 6
  63. public int getLastResult()
  64. {
  65. return lastResult;
  66. }
  67. // 7
  68. public JdbcTemplateEx()
  69. {
  70. super();
  71. firstResult = 1;
  72. lastResult = Integer.MAX_VALUE;
  73. }
  74. // 8
  75. public JdbcTemplateEx(DataSource dataSource)
  76. {
  77. super(dataSource);
  78. firstResult = 1;
  79. lastResult = Integer.MAX_VALUE;
  80. }
  81. // 9
  82. public void insertMap(Map map, String tableName) throws DataAccessException
  83. {
  84. String keyStr = "( ";
  85. String valueStr = "( ";
  86. Object[] args = new Object[map.size()];
  87. Iterator it = map.keySet().iterator();
  88. for (int j = 0; it.hasNext(); j++)
  89. {
  90. String key = (String) it.next();
  91. keyStr = keyStr + key + ",";
  92. valueStr = valueStr + "?,";
  93. args[j] = map.get(key);
  94. }
  95. keyStr = keyStr.substring(0, keyStr.length() - 1) + " ) ";
  96. valueStr = valueStr.substring(0, valueStr.length() - 1) + " ) ";
  97. String insertSql = "insert into " + tableName + " " + keyStr + " values " + valueStr;
  98. update(insertSql, args);
  99. }
  100. // 10
  101. private void setPrimaryKey(Map map, String tableName, String primaryKeyName)
  102. {
  103. Object pkvalue = map.get(primaryKeyName);
  104. if (pkvalue == null)
  105. throw new InvalidDataAccessApiUsageException("PrimaryKey '" + primaryKeyName
  106. + "' cannot find in map");
  107. if (pkvalue.toString().equals("-1"))
  108. {
  109. IDTableMaxValueIncrementer increamenter = new IDTableMaxValueIncrementer(this
  110. .getDataSource(), tableName);
  111. if (pkvalue instanceof Long)
  112. {
  113. map.put(primaryKeyName, new Long(increamenter.nextLongValue()));
  114. }
  115. else if (pkvalue instanceof Integer)
  116. {
  117. map.put(primaryKeyName, new Integer(increamenter.nextIntValue()));
  118. }
  119. else if (pkvalue instanceof String)
  120. {
  121. map.put(primaryKeyName, increamenter.nextStringValue());
  122. }
  123. else
  124. {
  125. throw new InvalidDataAccessApiUsageException("PrimaryKey '" + primaryKeyName
  126. + "' value can't cast Long/Integer/String");
  127. }
  128. }
  129. if (pkvalue.toString().equals("-2"))
  130. {
  131. AbstractSequenceMaxValueIncrementer incrementer = getSequenceIncrementer(tableName);
  132. if (incrementer == null) return;
  133. incrementer.setIncrementerName(incrementer.getIncrementerName() + tableName);
  134. if (pkvalue instanceof Long)
  135. {
  136. map.put(primaryKeyName, new Long(incrementer.nextLongValue()));
  137. }
  138. else if (pkvalue instanceof Integer)
  139. {
  140. map.put(primaryKeyName, new Integer(incrementer.nextIntValue()));
  141. }
  142. else if (pkvalue instanceof String)
  143. {
  144. map.put(primaryKeyName, incrementer.nextStringValue());
  145. }
  146. else
  147. {
  148. throw new InvalidDataAccessApiUsageException("PrimaryKey '" + primaryKeyName
  149. + "' value can't cast Long/Integer/String");
  150. }
  151. }
  152. }
  153. // 11
  154. public Object insertMap(Map map, String tableName, String primaryKeyName)
  155. throws DataAccessException
  156. {
  157. LobHelper lobhelper = getLobHelper();
  158. this.setPrimaryKey(map, tableName, primaryKeyName);
  159. String keyStr = "( ";
  160. String valueStr = "( ";
  161. Object[] args = new Object[map.size()];
  162. int[] types = new int[map.size()];
  163. Iterator it = map.keySet().iterator();
  164. int j = 0;
  165. while (it.hasNext())
  166. {
  167. String key = (String) it.next();
  168. Object val = map.get(key);
  169. if (val != null)
  170. {
  171. keyStr = keyStr + key + ",";
  172. valueStr = valueStr + "?,";
  173. args[j] = lobhelper.getObjectTransLob(val);
  174. types[j] = OracleTypes.getTypeByObject(args[j]);
  175. j++;
  176. }
  177. }
  178. keyStr = keyStr.substring(0, keyStr.length() - 1) + " ) ";
  179. valueStr = valueStr.substring(0, valueStr.length() - 1) + " ) ";
  180. String insertSql = "insert into " + tableName + " " + keyStr + " values " + valueStr;
  181. update(insertSql, args, types);
  182. return map.get(primaryKeyName);
  183. }
  184. // 12
  185. public void updateMap(Map map, String tableName, String primaryKeyName)
  186. throws DataAccessException
  187. {
  188. LobHelper lobhelper = getLobHelper();
  189. Object pkvalue = map.get(primaryKeyName);
  190. if (pkvalue == null)
  191. throw new InvalidDataAccessApiUsageException("Primary Key doesn't exist in Map");
  192. Object[] args = new Object[map.size()];
  193. int[] types = new int[map.size()];
  194. Iterator it = map.keySet().iterator();
  195. String updateSql = "update " + tableName + " set ";
  196. int j = 0;
  197. while (it.hasNext())
  198. {
  199. String keyName = (String) it.next();
  200. if (primaryKeyName.equalsIgnoreCase(keyName)) continue;
  201. updateSql = updateSql + keyName + " = ?,";
  202. args[j] = lobhelper.getObjectTransLob(map.get(keyName));
  203. types[j] = OracleTypes.getTypeByObject(args[j]);
  204. j++;
  205. }
  206. args[map.size() - 1] = pkvalue;
  207. types[map.size() - 1] = OracleTypes.getTypeByObject(args[map.size() - 1]);
  208. updateSql = updateSql.substring(0, updateSql.length() - 1) + " where ";
  209. updateSql = updateSql + primaryKeyName + " = ? ";
  210. update(updateSql, args, types);
  211. }
  212. // 13
  213. public long getQueryCount(String sql) throws DataAccessException
  214. {
  215. if (sql == null || sql.equals(""))
  216. {
  217. return 0;
  218. }
  219. String lowercaseSql = sql.toLowerCase();
  220. int fromLocation = lowercaseSql.indexOf(" from ");
  221. sql = "select count(*) as count " + sql.substring(fromLocation, sql.length());
  222. if (lowercaseSql.indexOf("/*not-order*/") == -1)
  223. {
  224. lowercaseSql = sql.toLowerCase();
  225. int orderbyLocation = lowercaseSql.indexOf(" order by");
  226. if (lowercaseSql.indexOf("order by") != -1)
  227. {
  228. sql = sql.substring(0, orderbyLocation);
  229. }
  230. }
  231. return this.queryForLong(sql);
  232. }
  233. // 14
  234. public long getQueryCount(String sql, Object args[]) throws DataAccessException
  235. {
  236. if (sql == null || sql.equals(""))
  237. {
  238. return 0;
  239. }
  240. String lowercaseSql = sql.toLowerCase();
  241. int fromLocation = lowercaseSql.indexOf(" from ");
  242. sql = "select count(*) as count " + sql.substring(fromLocation, sql.length());
  243. lowercaseSql = sql.toLowerCase();
  244. int orderbyLocation = lowercaseSql.indexOf(" order by");
  245. if (lowercaseSql.indexOf("order by") != -1)
  246. {
  247. sql = sql.substring(0, orderbyLocation);
  248. }
  249. return this.queryForLong(sql, args);
  250. }
  251. // 16
  252. public List queryEx(String sql, RowMapper rowMapper) throws DataAccessException
  253. {
  254. return (List) this.query(sql, new RowCallbackHandlerResultSetExtractor(rowMapper));
  255. }
  256. // 17
  257. protected Object queryEx(PreparedStatementCreator psc, final PreparedStatementSetter pss,
  258. final ResultSetExtractor rse) throws DataAccessException
  259. {
  260. return super.query(psc, pss, rse);
  261. }
  262. // 18
  263. public Object queryEx(PreparedStatementCreator psc, ResultSetExtractor rse)
  264. throws DataAccessException
  265. {
  266. return queryEx(psc, null, rse);
  267. }
  268. // 19
  269. public Object queryEx(String sql, PreparedStatementSetter pss, final ResultSetExtractor rse)
  270. throws DataAccessException
  271. {
  272. if (sql == null)
  273. {
  274. throw new InvalidDataAccessApiUsageException("SQL may not be null");
  275. }
  276. return queryEx(new SimplePreparedStatementCreator(sql), pss, rse);
  277. }
  278. // 20
  279. public Object query(String sql, Object[] args, int[] argTypes, ResultSetExtractor rse)
  280. throws DataAccessException
  281. {
  282. return query(sql, new ArgTypePreparedStatementSetter(args, argTypes), rse);
  283. }
  284. // 21
  285. public Object query(String sql, Object[] args, ResultSetExtractor rse)
  286. throws DataAccessException
  287. {
  288. return query(sql, new ArgPreparedStatementSetter(args), rse);
  289. }
  290. // 25
  291. public List queryEx(String sql, Object[] args, ResultSetExtractor rch)
  292. throws DataAccessException
  293. {
  294. return (List) queryEx(sql, new ArgPreparedStatementSetter(args), rch);
  295. }
  296. // 26
  297. public List query(PreparedStatementCreator psc, RowMapper rowMapper) throws DataAccessException
  298. {
  299. return (List) queryEx(psc, new RowMapperResultSetExtractor(rowMapper));
  300. }
  301. // 29
  302. public List queryEx(String sql, Object[] args, RowMapper rowMapper) throws DataAccessException
  303. {
  304. return queryEx(sql, args, new RowCallbackHandlerResultSetExtractor(rowMapper));
  305. }
  306. // 30
  307. private static class SimplePreparedStatementCreator implements PreparedStatementCreator,
  308. SqlProvider
  309. {
  310. private final String sql;
  311. public SimplePreparedStatementCreator(String sql)
  312. {
  313. this.sql = sql;
  314. }
  315. public PreparedStatement createPreparedStatement(Connection con) throws SQLException
  316. {
  317. return con.prepareStatement(this.sql);
  318. }
  319. public String getSql()
  320. {
  321. return sql;
  322. }
  323. }
  324. // 31
  325. private static class ArgPreparedStatementSetter implements PreparedStatementSetter,
  326. ParameterDisposer
  327. {
  328. private final Object[] args;
  329. public ArgPreparedStatementSetter(Object[] args)
  330. {
  331. this.args = args;
  332. }
  333. public void setValues(PreparedStatement ps) throws SQLException
  334. {
  335. if (this.args == null) return;
  336. for (int i = 0; i < this.args.length; i++)
  337. {
  338. if (args[i] instanceof SqlLobValue)
  339. {
  340. StatementCreatorUtils.setParameterValue(ps, i + 1, Types.CLOB, null,
  341. this.args[i]);
  342. }
  343. else
  344. {
  345. StatementCreatorUtils.setParameterValue(ps, i + 1, SqlTypeValue.TYPE_UNKNOWN,
  346. null, this.args[i]);
  347. }
  348. }
  349. }
  350. public void cleanupParameters()
  351. {
  352. StatementCreatorUtils.cleanupParameters(this.args);
  353. }
  354. }
  355. // 32
  356. private static class ArgTypePreparedStatementSetter implements PreparedStatementSetter,
  357. ParameterDisposer
  358. {
  359. private final Object[] args;
  360. private final int[] argTypes;
  361. public ArgTypePreparedStatementSetter(Object[] args, int[] argTypes)
  362. {
  363. if ((args != null && argTypes == null) || (args == null && argTypes != null)
  364. || (args != null && args.length != argTypes.length))
  365. {
  366. throw new InvalidDataAccessApiUsageException(
  367. "args and argTypes parameters must match");
  368. }
  369. this.args = args;
  370. this.argTypes = argTypes;
  371. }
  372. public void setValues(PreparedStatement ps) throws SQLException
  373. {
  374. if (this.args == null) return;
  375. for (int i = 0; i < this.args.length; i++)
  376. {
  377. StatementCreatorUtils.setParameterValue(ps, i + 1, this.argTypes[i], null,
  378. this.args[i]);
  379. }
  380. }
  381. public void cleanupParameters()
  382. {
  383. StatementCreatorUtils.cleanupParameters(this.args);
  384. }
  385. }
  386. // 33
  387. private class RowCallbackHandlerResultSetExtractor<T> implements ResultSetExtractor<List<T>>
  388. {
  389. private final RowMapper<T> rowMapper;
  390. private final int rowsExpected;
  391. /**
  392. * Create a new RowMapperResultSetExtractor.
  393. *
  394. * @param rowMapper the RowMapper which creates an object for each row
  395. */
  396. public RowCallbackHandlerResultSetExtractor(RowMapper<T> rowMapper)
  397. {
  398. this(rowMapper, 0);
  399. }
  400. /**
  401. * Create a new RowMapperResultSetExtractor.
  402. *
  403. * @param rowMapper the RowMapper which creates an object for each row
  404. * @param rowsExpected the number of expected rows (just used for optimized collection
  405. * handling)
  406. */
  407. public RowCallbackHandlerResultSetExtractor(RowMapper<T> rowMapper, int rowsExpected)
  408. {
  409. Assert.notNull(rowMapper, "RowMapper is required");
  410. this.rowMapper = rowMapper;
  411. this.rowsExpected = rowsExpected;
  412. }
  413. public List<T> extractData(ResultSet rs) throws SQLException
  414. {
  415. List<T> results = (this.rowsExpected > 0 ? new ArrayList<T>(this.rowsExpected)
  416. : new ArrayList<T>());
  417. int rowNum = 0;
  418. boolean isnext = true;
  419. int start = JdbcTemplateEx.this.getFirstResult();
  420. int end = JdbcTemplateEx.this.getLastResult();
  421. if (start > end)
  422. throw new SQLException(
  423. "JdbcTemplateEx Start postion greator than JdbcTemplateEx end");
  424. for (int i = 1; i <= start; i++)
  425. {
  426. isnext = rs.next();
  427. }
  428. for (int i = start; i <= end && isnext; i++)
  429. {
  430. int x = 1;
  431. results.add(this.rowMapper.mapRow(rs, x++));
  432. isnext = rs.next();
  433. }
  434. return results;
  435. }
  436. }
  437. // 34
  438. public List queryForList(String sql, Class elementType) throws DataAccessException
  439. {
  440. return queryEx(sql, new SingleColumnRowMapper(elementType));
  441. }
  442. // 35
  443. public List queryForList(String sql) throws DataAccessException
  444. {
  445. return queryEx(sql, this.getColumnMapRowMapperEx());
  446. }
  447. // 37
  448. public List queryForList(String sql, final Object[] args, Class elementType)
  449. throws DataAccessException
  450. {
  451. return queryEx(sql, args, new SingleColumnRowMapper(elementType));
  452. }
  453. // 39
  454. public List queryForList(String sql, final Object[] args) throws DataAccessException
  455. {
  456. return queryEx(sql, args, this.getColumnMapRowMapperEx());
  457. }
  458. // 39
  459. public List queryForList(String sql, final String arg) throws DataAccessException
  460. {
  461. return queryEx(sql, new Object[] { arg }, this.getColumnMapRowMapperEx());
  462. }
  463. // 40
  464. public Map queryForMap(String sql, Object[] args, int[] argTypes) throws DataAccessException
  465. {
  466. try
  467. {
  468. return (Map) queryForObject(sql, args, argTypes, this.getColumnMapRowMapperEx());
  469. }
  470. catch (IncorrectResultSizeDataAccessException e)
  471. {
  472. return new HashMap();
  473. }
  474. }
  475. // 41
  476. public Map queryForMap(String sql) throws DataAccessException
  477. {
  478. try
  479. {
  480. return (Map) queryForObject(sql, this.getColumnMapRowMapperEx());
  481. }
  482. catch (IncorrectResultSizeDataAccessException e)
  483. {
  484. return new HashMap();
  485. }
  486. }
  487. // 42
  488. public Map queryForMap(String sql, Object[] args) throws DataAccessException
  489. {
  490. try
  491. {
  492. return (Map) queryForObject(sql, args, this.getColumnMapRowMapperEx());
  493. }
  494. catch (IncorrectResultSizeDataAccessException e)
  495. {
  496. return new HashMap();
  497. }
  498. }
  499. public Map queryForMap(String sql, String arg) throws DataAccessException
  500. {
  501. try
  502. {
  503. return (Map) queryForObject(sql, new Object[] { arg }, this.getColumnMapRowMapperEx());
  504. }
  505. catch (IncorrectResultSizeDataAccessException e)
  506. {
  507. return new HashMap();
  508. }
  509. }
  510. // 43
  511. public String queryForString(String sql) throws DataAccessException
  512. {
  513. try
  514. {
  515. return (String) queryForObject(sql, String.class);
  516. }
  517. catch (IncorrectResultSizeDataAccessException e)
  518. {
  519. return "";
  520. }
  521. }
  522. // 44
  523. public String queryForString(String sql, Object args[]) throws DataAccessException
  524. {
  525. try
  526. {
  527. return (String) queryForObject(sql, args, String.class);
  528. }
  529. catch (IncorrectResultSizeDataAccessException e)
  530. {
  531. return "";
  532. }
  533. }
  534. // 45
  535. public int update(String sql, final Object[] args) throws DataAccessException
  536. {
  537. return update(sql, new ArgPreparedStatementSetter(args));
  538. }
  539. // 45
  540. public int update(String sql, final Object[] args, int[] types) throws DataAccessException
  541. {
  542. return super.update(sql, args, types);
  543. }
  544. // 46
  545. public int[] batchUpdate(String sql, final BatchPreparedStatementSetter pss)
  546. throws DataAccessException
  547. {
  548. if (logger.isDebugEnabled())
  549. {
  550. logger.debug("Executing SQL batch update [" + sql + "]");
  551. }
  552. return (int[]) execute(sql, new PreparedStatementCallback()
  553. {
  554. public Object doInPreparedStatement(PreparedStatement ps) throws SQLException
  555. {
  556. try
  557. {
  558. int batchSize = pss.getBatchSize();
  559. if (JdbcUtils.supportsBatchUpdates(ps.getConnection()))
  560. {
  561. for (int i = 0; i < batchSize; i++)
  562. {
  563. pss.setValues(ps, i);
  564. ps.addBatch();
  565. }
  566. return ps.executeBatch();
  567. }
  568. else
  569. {
  570. int[] rowsAffected = new int[batchSize];
  571. for (int i = 0; i < batchSize; i++)
  572. {
  573. pss.setValues(ps, i);
  574. rowsAffected[i] = ps.executeUpdate();
  575. }
  576. return rowsAffected;
  577. }
  578. }
  579. finally
  580. {
  581. if (pss instanceof ParameterDisposer)
  582. {
  583. ((ParameterDisposer) pss).cleanupParameters();
  584. }
  585. }
  586. }
  587. });
  588. }
  589. // 47
  590. public boolean hasResult(String sql) throws DataAccessException
  591. {
  592. this.setFirstResult(1);
  593. this.setLastResult(1);
  594. List list = queryForList(sql);
  595. this.setFirstResult(1);
  596. this.setLastResult(Integer.MAX_VALUE);
  597. if (list == null) return false;
  598. if (list.size() == 0) return false;
  599. return true;
  600. }
  601. // 48
  602. public boolean hasResult(String sql, Object args[]) throws DataAccessException
  603. {
  604. this.setFirstResult(1);
  605. this.setLastResult(1);
  606. List list = queryForList(sql, args);
  607. this.setFirstResult(1);
  608. this.setLastResult(Integer.MAX_VALUE);
  609. if (list == null) return false;
  610. if (list.size() == 0) return false;
  611. return true;
  612. }
  613. // 49
  614. private LobHelper getLobHelper()
  615. {
  616. ApplicationContext ctx = ApplicationFactory.getContext();
  617. if (ctx.containsBeanDefinition("lobHelper"))
  618. {
  619. return (LobHelper) ctx.getBean("lobHelper");
  620. }
  621. return null;
  622. }
  623. // 50
  624. private RowMapper getColumnMapRowMapperEx()
  625. {
  626. ApplicationContext ctx = ApplicationFactory.getContext();
  627. if (ctx.containsBeanDefinition("dataTypeMapping"))
  628. {
  629. return (RowMapper) ctx.getBean("dataTypeMapping");
  630. }
  631. return new ColumnMapRowMapper();
  632. }
  633. // 51
  634. private AbstractSequenceMaxValueIncrementer getSequenceIncrementer(String tableName)
  635. {
  636. ApplicationContext ctx = ApplicationFactory.getContext();
  637. if (ctx.containsBeanDefinition("SequenceIncrementer"))
  638. {
  639. AbstractSequenceMaxValueIncrementer sequenceIncrementer = (AbstractSequenceMaxValueIncrementer) ctx
  640. .getBean("SequenceIncrementer");
  641. sequenceIncrementer.setDataSource(this.getDataSource());
  642. return sequenceIncrementer;
  643. }
  644. return null;
  645. }
  646. }