1 16 17 package org.springframework.jdbc.object; 18 19 import org.springframework.jdbc.core.PreparedStatementCreator; 20 import org.springframework.jdbc.core.PreparedStatementCreatorFactory; 21 import org.springframework.jdbc.core.PreparedStatementSetter; 22 import org.springframework.jdbc.core.namedparam.NamedParameterUtils; 23 24 35 public abstract class SqlOperation extends RdbmsOperation { 36 37 41 private PreparedStatementCreatorFactory preparedStatementFactory; 42 43 44 48 protected final void compileInternal() { 49 this.preparedStatementFactory = new PreparedStatementCreatorFactory(getSql(), getDeclaredParameters()); 50 this.preparedStatementFactory.setResultSetType(getResultSetType()); 51 this.preparedStatementFactory.setUpdatableResults(isUpdatableResults()); 52 this.preparedStatementFactory.setReturnGeneratedKeys(isReturnGeneratedKeys()); 53 if (getGeneratedKeysColumnNames() != null) { 54 this.preparedStatementFactory.setGeneratedKeysColumnNames(getGeneratedKeysColumnNames()); 55 } 56 this.preparedStatementFactory.setNativeJdbcExtractor(getJdbcTemplate().getNativeJdbcExtractor()); 57 this.preparedStatementFactory.setSqlToUse(NamedParameterUtils.parseSqlStatementIntoString(getSql())); 58 59 onCompileInternal(); 60 } 61 62 67 protected void onCompileInternal() { 68 } 69 70 71 76 protected final PreparedStatementSetter newPreparedStatementSetter(Object [] params) { 77 return this.preparedStatementFactory.newPreparedStatementSetter(params); 78 } 79 80 85 protected final PreparedStatementCreator newPreparedStatementCreator(Object [] params) { 86 return this.preparedStatementFactory.newPreparedStatementCreator(params); 87 } 88 89 96 protected final PreparedStatementCreator newPreparedStatementCreator(String sqlToUse, Object [] params) { 97 return this.preparedStatementFactory.newPreparedStatementCreator(sqlToUse, params); 98 } 99 100 } 101 | Popular Tags |