public SqlTypeDescriptor getDescriptor(int jdbcTypeCode) {
    SqlTypeDescriptor descriptor = descriptorMap.get(Integer.valueOf(jdbcTypeCode));
    if (descriptor != null) {
      return descriptor;
    }

    if (JdbcTypeNameMapper.isStandardTypeCode(jdbcTypeCode)) {
      log.debugf(
          "A standard JDBC type code [%s] was not defined in SqlTypeDescriptorRegistry",
          jdbcTypeCode);
    }

    // see if the typecode is part of a known type family...
    JdbcTypeFamilyInformation.Family family =
        JdbcTypeFamilyInformation.INSTANCE.locateJdbcTypeFamilyByTypeCode(jdbcTypeCode);
    if (family != null) {
      for (int potentialAlternateTypeCode : family.getTypeCodes()) {
        if (potentialAlternateTypeCode != jdbcTypeCode) {
          final SqlTypeDescriptor potentialAlternateDescriptor =
              descriptorMap.get(Integer.valueOf(potentialAlternateTypeCode));
          if (potentialAlternateDescriptor != null) {
            // todo : add a SqlTypeDescriptor.canBeAssignedFrom method...
            return potentialAlternateDescriptor;
          }

          if (JdbcTypeNameMapper.isStandardTypeCode(potentialAlternateTypeCode)) {
            log.debugf(
                "A standard JDBC type code [%s] was not defined in SqlTypeDescriptorRegistry",
                potentialAlternateTypeCode);
          }
        }
      }
    }

    // finally, create a new descriptor mapping to getObject/setObject for this type code...
    final ObjectSqlTypeDescriptor fallBackDescriptor = new ObjectSqlTypeDescriptor(jdbcTypeCode);
    addDescriptor(fallBackDescriptor);
    return fallBackDescriptor;
  }
 /** {@inheritDoc} */
 public final void bind(PreparedStatement st, J value, int index, WrapperOptions options)
     throws SQLException {
   if (value == null) {
     if (LOG.isTraceEnabled()) {
       LOG.trace(
           String.format(
               NULL_BIND_MSG_TEMPLATE,
               index,
               JdbcTypeNameMapper.getTypeName(sqlDescriptor.getSqlType())));
     }
     st.setNull(index, sqlDescriptor.getSqlType());
   } else {
     if (LOG.isTraceEnabled()) {
       LOG.trace(
           String.format(
               BIND_MSG_TEMPLATE,
               index,
               JdbcTypeNameMapper.getTypeName(sqlDescriptor.getSqlType()),
               getJavaDescriptor().extractLoggableRepresentation(value)));
     }
     doBind(st, value, index, options);
   }
 }
    private void validateColumn(Connection connection, String columnName, int expectedJdbcTypeCode)
        throws SQLException {
      DatabaseMetaData meta = connection.getMetaData();

      // DBs treat the meta information differently, in particular case sensitivity.
      // We need to use the meta information to find out how to treat names
      String tableNamePattern = generateFinalNamePattern(meta, SOME_ENTITY_TABLE_NAME);
      String columnNamePattern = generateFinalNamePattern(meta, columnName);

      ResultSet columnInfo = meta.getColumns(null, null, tableNamePattern, columnNamePattern);
      s.getTransactionCoordinator()
          .getJdbcCoordinator()
          .register(columnInfo, columnInfo.getStatement());
      assertTrue(columnInfo.next());
      int dataType = columnInfo.getInt("DATA_TYPE");
      s.getTransactionCoordinator()
          .getJdbcCoordinator()
          .release(columnInfo, columnInfo.getStatement());
      assertEquals(
          columnName,
          JdbcTypeNameMapper.getTypeName(expectedJdbcTypeCode),
          JdbcTypeNameMapper.getTypeName(dataType));
    }