Esempio n. 1
0
  public static void main(String[] args) {
    try {
      Configuration cfg = new Configuration();

      boolean script = true;
      // If true then execute db updates, otherwise just generate and display updates
      boolean doUpdate = true;
      String propFile = null;

      for (int i = 0; i < args.length; i++) {
        if (args[i].startsWith("--")) {
          if (args[i].equals("--quiet")) {
            script = false;
          } else if (args[i].startsWith("--properties=")) {
            propFile = args[i].substring(13);
          } else if (args[i].startsWith("--config=")) {
            cfg.configure(args[i].substring(9));
          } else if (args[i].startsWith("--text")) {
            doUpdate = false;
          } else if (args[i].startsWith("--naming=")) {
            cfg.setNamingStrategy(
                (NamingStrategy) ReflectHelper.classForName(args[i].substring(9)).newInstance());
          }
        } else {
          cfg.addFile(args[i]);
        }
      }
      if (propFile != null) {
        Properties props = new Properties();
        props.load(new FileInputStream(propFile));
        new SchemaUpdate(cfg, props).execute(script, doUpdate);
      } else {
        new SchemaUpdate(cfg).execute(script, doUpdate);
      }
    } catch (Exception e) {
      log.error("Error running schema update", e);
      e.printStackTrace();
    }
  }
Esempio n. 2
0
  public IteratorImpl(
      ResultSet rs,
      PreparedStatement ps,
      SessionImplementor sess,
      Type[] types,
      String[][] columnNames,
      Class holderClass)
      throws HibernateException, SQLException {

    this.rs = rs;
    this.ps = ps;
    this.sess = sess;
    this.types = types;
    this.names = columnNames;

    if (holderClass != null) {
      holderConstructor = ReflectHelper.getConstructor(holderClass, types);
    }

    single = types.length == 1;

    postNext();
  }