public void testIsWritablePropertyNull() {
   NoRead nr = new NoRead();
   BeanWrapper bw = new BeanWrapperImpl(nr);
   try {
     bw.isWritableProperty(null);
     fail("Can't inquire into writability of null property");
   } catch (BeansException ex) {
     // expected
   }
 }
  @Test
  public void acceptAndClearClassLoader() throws Exception {
    BeanWrapper bw = new BeanWrapperImpl(TestBean.class);
    assertTrue(bw.isWritableProperty("name"));
    assertTrue(bw.isWritableProperty("age"));
    assertTrue(CachedIntrospectionResults.strongClassCache.containsKey(TestBean.class));

    ClassLoader child = new OverridingClassLoader(getClass().getClassLoader());
    Class<?> tbClass = child.loadClass("org.springframework.tests.sample.beans.TestBean");
    assertFalse(CachedIntrospectionResults.strongClassCache.containsKey(tbClass));
    CachedIntrospectionResults.acceptClassLoader(child);
    bw = new BeanWrapperImpl(tbClass);
    assertTrue(bw.isWritableProperty("name"));
    assertTrue(bw.isWritableProperty("age"));
    assertTrue(CachedIntrospectionResults.strongClassCache.containsKey(tbClass));
    CachedIntrospectionResults.clearClassLoader(child);
    assertFalse(CachedIntrospectionResults.strongClassCache.containsKey(tbClass));

    assertTrue(CachedIntrospectionResults.strongClassCache.containsKey(TestBean.class));
  }
  /**
   * Extract the values for all attributes in the struct.
   *
   * <p>Utilizes public setters and result set metadata.
   *
   * @see java.sql.ResultSetMetaData
   */
  public Object fromStruct(STRUCT struct) throws SQLException {
    Assert.state(this.mappedClass != null, "Mapped class was not specified");
    Object mappedObject = BeanUtils.instantiateClass(this.mappedClass);
    BeanWrapper bw = PropertyAccessorFactory.forBeanPropertyAccess(mappedObject);
    initBeanWrapper(bw);

    ResultSetMetaData rsmd = struct.getDescriptor().getMetaData();
    Object[] attr = struct.getAttributes();
    int columnCount = rsmd.getColumnCount();
    for (int index = 1; index <= columnCount; index++) {
      String column = JdbcUtils.lookupColumnName(rsmd, index).toLowerCase();
      PropertyDescriptor pd = (PropertyDescriptor) this.mappedFields.get(column);
      if (pd != null) {
        Object value = attr[index - 1];
        if (logger.isDebugEnabled()) {
          logger.debug(
              "Mapping column '"
                  + column
                  + "' to property '"
                  + pd.getName()
                  + "' of type "
                  + pd.getPropertyType());
        }
        if (bw.isWritableProperty(pd.getName())) {
          try {
            bw.setPropertyValue(pd.getName(), value);
          } catch (Exception e) {
            e.printStackTrace();
          }
        } else {
          // Если нету сеттера для проперти не нужно кидать ошибку!
          logger.warn(
              "Unable to access the setter for "
                  + pd.getName()
                  + ".  Check that "
                  + "set"
                  + StringUtils.capitalize(pd.getName())
                  + " is declared and has public access.");
        }
      }
    }

    return mappedObject;
  }