public synchronized BeanFactory<B> getFactory() {
    if (factory != null) return factory;
    String[] priKeyNames = getPrimaryKeyNamesFromTable();
    factory =
        new GoogleSQLFactory<B>(
            beanClass, tableName, priKeyNames, connectionPool, printSQL, referencedFactories);
    factory.setDebugOutput(printSQL);

    for (Property p : factory.properties) {
      if (p instanceof SelfReferencedBeanProperty) {
        SelfReferencedBeanProperty selfRefProp = (SelfReferencedBeanProperty) p;
        selfRefProp.setFactory(factory);
      }
    }

    return factory;
  }
 public synchronized void setDebugOutput(Writer writer) {
   printSQL = writer;
   if (factory != null) factory.setDebugOutput(printSQL);
 }