コード例 #1
0
  @Test
  public void testPropertyNameToColumnName2() {
    ColumnNamingStrategy cns = new ColumnNamingStrategy();

    assertEquals("FOO", cns.convertPropertyNameToColumnName("foo"));
    assertEquals("FOO_BOO", cns.convertPropertyNameToColumnName("fooBoo"));

    cns.setUppercase(false);

    assertEquals("foo", cns.convertPropertyNameToColumnName("foo"));
    assertEquals("foo_boo", cns.convertPropertyNameToColumnName("fooBoo"));

    cns.setSplitCamelCase(false);

    assertEquals("foo", cns.convertPropertyNameToColumnName("foo"));
    assertEquals("fooboo", cns.convertPropertyNameToColumnName("fooBoo"));
    assertEquals("fooboo", cns.convertPropertyNameToColumnName("FOOBOO"));

    cns.setChangeCase(false);

    assertEquals("foo", cns.convertPropertyNameToColumnName("foo"));
    assertEquals("fooBoo", cns.convertPropertyNameToColumnName("fooBoo"));
    assertEquals("FOOBOO", cns.convertPropertyNameToColumnName("FOOBOO"));
  }
コード例 #2
0
 static String convertPropertyNameToColumnName(String propertyName, boolean toUpperCase) {
   ColumnNamingStrategy columnNamingStrategy = new ColumnNamingStrategy();
   columnNamingStrategy.setUppercase(toUpperCase);
   return columnNamingStrategy.convertPropertyNameToColumnName(propertyName);
 }