예제 #1
0
  protected String jToSql(String javaName, JClass currentClass)
      throws IOException, SchemaException {
    JField jf = currentClass.getFieldByName(javaName);
    if (jf == null)
      throw new SchemaException(
          "field " + javaName + " not a member of class " + currentClass.getClassName(),
          currentClass.getSchemaFileName());

    return jf.getSqlName();
  }
예제 #2
0
 protected String convertFields(String fields, JClass currentClass)
     throws SchemaException, IOException {
   Vector tokens = Tokenizer.tokenize(fields, ",", "/");
   Debugger.trace(fields + " token-size=" + tokens.size(), Debugger.VERBOSE);
   String sOut;
   if (tokens == null || tokens.size() < 1)
     throw new SchemaException(
         "Invalid constraint specification ", currentClass.getSchemaFileName());
   else sOut = jToSql((String) tokens.elementAt(0), currentClass);
   for (int j = 1; j < tokens.size(); j++) {
     sOut += "," + jToSql((String) tokens.elementAt(j), currentClass);
   }
   return sOut;
 }
예제 #3
0
  public void inlineField(JClass currentClass, JCompositeField jcf, HashSet fieldNames)
      throws IOException, SchemaException {

    JClass fieldClass = jcf.getJClass();
    Vector fields = new Vector(fieldClass.getAllFields().values());
    String primaryKey = fieldClass.getPrimaryKey();
    String prefix = jcf.getPrefix();
    for (int i = 0; i < fields.size(); i++) {
      JField jf = (JField) fields.elementAt(i);
      String sqlName = jf.getSqlName();

      if (!jf.isDbColumn() || sqlName.equals(primaryKey)) {
        // do nothing ..
      } else if (jf instanceof JCompositeField) {
        throw new SchemaException(
            "Composite Fields not allowed in inline objects", currentClass.getSchemaFileName());
      } else
        schemaFile.write(",\n\t" + prefix + "_" + sqlName + " " + getSqlOutType(currentClass, jf));
      fieldNames.add(prefix + "_" + sqlName);
    }
  }