/** * Get the base probe for configuration. It should never be run! Instead use makeProbe() to make a * copy which you can run. * * @return the base probe generating it if necessary or null if one cannot be generated (e.g. no * selected sequence) */ Probe<?> getBaseProbe() { // if there is no base probe and the sequence is not null then generate a new base probe for the // sequence if (_baseProbe == null && _sequence != null) { try { if (_sequence instanceof Ring) { final TransferMapTracker tracker = AlgorithmFactory.createTransferMapTracker(_sequence); _baseProbe = ProbeFactory.getTransferMapProbe(_sequence, tracker); } else { final ParticleTracker tracker = AlgorithmFactory.createParticleTracker(_sequence); _baseProbe = ProbeFactory.createParticleProbe(_sequence, tracker); } } catch (Exception exception) { throw new RuntimeException("Exception making a new probe.", exception); } } return _baseProbe; }
private void initializeBeanResults(ResultSet rs) { try { ClassInfo classInfo = ClassInfo.getInstance(getResultClass()); String[] propertyNames = classInfo.getWriteablePropertyNames(); Map propertyMap = new HashMap(); for (int i = 0; i < propertyNames.length; i++) { propertyMap.put(propertyNames[i].toUpperCase(java.util.Locale.ENGLISH), propertyNames[i]); } List resultMappingList = new ArrayList(); ResultSetMetaData rsmd = rs.getMetaData(); for (int i = 0, n = rsmd.getColumnCount(); i < n; i++) { String columnName = getColumnIdentifier(rsmd, i + 1); String upperColumnName = columnName.toUpperCase(java.util.Locale.ENGLISH); String matchedProp = (String) propertyMap.get(upperColumnName); Class type = null; if (matchedProp == null) { Probe p = ProbeFactory.getProbe(this.getResultClass()); try { type = p.getPropertyTypeForSetter(this.getResultClass(), columnName); } catch (Exception e) { // TODO - add logging to this class? } } else { type = classInfo.getSetterType(matchedProp); } if (type != null || matchedProp != null) { ResultMapping resultMapping = new ResultMapping(); resultMapping.setPropertyName((matchedProp != null ? matchedProp : columnName)); resultMapping.setColumnName(columnName); resultMapping.setColumnIndex(i + 1); resultMapping.setTypeHandler( getDelegate().getTypeHandlerFactory().getTypeHandler(type)); // map SQL to JDBC type resultMappingList.add(resultMapping); } } setResultMappingList(resultMappingList); } catch (SQLException e) { throw new RuntimeException("Error automapping columns. Cause: " + e); } }