Package com.orientechnologies.orient.core.sql

Examples of com.orientechnologies.orient.core.sql.OCommandSQL


  @Test
  public void updateWithWildcards() {
    database.open("admin", "admin");

    int updated = (Integer) database.command(new OCommandSQL("update Profile set sex = ? where sex = 'male' limit 1")).execute(
        "male");

    Assert.assertEquals(updated, 1);

    database.close();
View Full Code Here


    doc.field("gender", "fmale");
    doc.save();
    checkUpdatedDoc(database, "Raf", "Torino", "fmale");

    /* THESE COMMANDS ARE OK */
    OCommandSQL updatecommand = new OCommandSQL("update Person set gender = 'female' where name = 'Raf'");
    database.command(updatecommand).execute("Raf");
    checkUpdatedDoc(database, "Raf", "Torino", "female");

    updatecommand = new OCommandSQL("update Person set city = 'Turin' where name = ?");
    database.command(updatecommand).execute("Raf");
    checkUpdatedDoc(database, "Raf", "Turin", "female");

    updatecommand = new OCommandSQL("update Person set gender = ? where name = 'Raf'");
    database.command(updatecommand).execute("F");
    checkUpdatedDoc(database, "Raf", "Turin", "F");

    updatecommand = new OCommandSQL("update Person set gender = ?, city = ? where name = 'Raf'");
    database.command(updatecommand).execute("FEMALE", "TORINO");
    checkUpdatedDoc(database, "Raf", "TORINO", "FEMALE");

    updatecommand = new OCommandSQL("update Person set gender = ? where name = ?");
    database.command(updatecommand).execute("f", "Raf");
    checkUpdatedDoc(database, "Raf", "TORINO", "f");

    database.close();
  }
View Full Code Here

  }

  public synchronized OIndex createIndex(final String iName, final String iType, final OType iKeyType,
      final int[] iClusterIdsToIndex, OIndexCallback iCallback, final OProgressListener iProgressListener, final boolean iAutomatic) {
    final String text = String.format(QUERY_CREATE, iName, iType, iKeyType);
    getDatabase().command(new OCommandSQL(text)).execute();

    document.setIdentity(new ORecordId(document.getDatabase().getStorage().getConfiguration().indexMgrRecordId));
    reload();

    return indexes.get(iName.toLowerCase());
View Full Code Here

    return indexes.get(iName.toLowerCase());
  }

  public synchronized OIndexManager dropIndex(final String iIndexName) {
    final String text = String.format(QUERY_DROP, iIndexName);
    getDatabase().command(new OCommandSQL(text)).execute();

    // REMOVE THE INDEX LOCALLY
    indexes.remove(iIndexName.toLowerCase());

    return this;
View Full Code Here

    return this;
  }

  public <DB extends ODatabase> DB setStatus(final STATUS status) {
    final String cmd = String.format("alter database status %s", status.toString());
    command(new OCommandSQL(cmd)).execute();
    return (DB) this;
  }
View Full Code Here

            cmd.append(' ');

          cmd.append(iClusterIds[i]);
        }

      getDatabase().command(new OCommandSQL(cmd.toString())).execute();
      getDatabase().reload();

      if (classes.containsKey(key))
        return classes.get(key);
      else
View Full Code Here

            + " can't be dropped since has sub classes. Remove the dependencies before to drop it again");

      final StringBuilder cmd = new StringBuilder("drop class ");
      cmd.append(iClassName);

      getDatabase().command(new OCommandSQL(cmd.toString())).execute();
      getDatabase().reload();
      reload();

    } finally {
      lock.releaseExclusiveLock();
View Full Code Here

   * @return the object itself.
   */
  public OClass setSuperClass(final OClass iSuperClass) {
    document.getDatabase().checkSecurity(ODatabaseSecurityResources.SCHEMA, ORole.PERMISSION_UPDATE);
    final String cmd = String.format("alter class %s superclass %s", name, iSuperClass.getName());
    document.getDatabase().command(new OCommandSQL(cmd)).execute();
    setSuperClassInternal(iSuperClass);
    return this;
  }
View Full Code Here

  }

  public OClass setName(final String iName) {
    document.getDatabase().checkSecurity(ODatabaseSecurityResources.SCHEMA, ORole.PERMISSION_UPDATE);
    final String cmd = String.format("alter class %s name %s", name, iName);
    document.getDatabase().command(new OCommandSQL(cmd)).execute();
    name = iName;
    return this;
  }
View Full Code Here

  }

  public OClass setShortName(final String iShortName) {
    document.getDatabase().checkSecurity(ODatabaseSecurityResources.SCHEMA, ORole.PERMISSION_UPDATE);
    final String cmd = String.format("alter class %s shortname %s", name, iShortName);
    document.getDatabase().command(new OCommandSQL(cmd)).execute();
    setShortNameInternal(iShortName);
    return this;
  }
View Full Code Here

TOP

Related Classes of com.orientechnologies.orient.core.sql.OCommandSQL

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.