1 package org.hibernate.jdbc; 3 4 import java.sql.SQLException ; 5 import java.util.HashMap ; 6 import java.util.Map ; 7 8 13 public class ColumnNameCache { 14 15 private final Map columnNameToIndexCache; 16 17 public ColumnNameCache(int columnCount) { 18 this.columnNameToIndexCache = new HashMap ( columnCount ); 20 } 21 22 public int getIndexForColumnName(String columnName, ResultSetWrapper rs)throws SQLException { 23 Integer cached = ( Integer ) columnNameToIndexCache.get( columnName ); 24 if ( cached != null ) { 25 return cached.intValue(); 26 } 27 else { 28 int index = rs.getTarget().findColumn( columnName ); 29 columnNameToIndexCache.put( columnName, new Integer (index) ); 30 return index; 31 } 32 } 33 } 34 | Popular Tags |