Examples of OObjectDatabaseTx


Examples of com.orientechnologies.orient.object.db.OObjectDatabaseTx

  private Profile           p;
  private int               expectedHookState;

  @Parameters(value = "url")
  public HookTxTest(String iURL) {
    database = new OObjectDatabaseTx(iURL);
  }
View Full Code Here

Examples of com.orientechnologies.orient.object.db.OObjectDatabaseTx

  @Test(dependsOnMethods = "testDeleteRollback")
  public void clean() {
    database.close();

    database = new OObjectDatabaseTx(url).open("admin", "admin");
    try {
      database.delete(profile);
      database.delete(account);

    } finally {
View Full Code Here

Examples of com.orientechnologies.orient.object.db.OObjectDatabaseTx

  public void beforeClass() throws Exception {
    super.beforeClass();

    database.close();

    database = new OObjectDatabaseTx(url + "_objectschema");
    ODatabaseHelper.createDatabase(database, url + "_objectschema", getStorageType());
    database.close();
    try {
      ODatabaseDocumentTx exportDatabase = new ODatabaseDocumentTx(url);
      exportDatabase.open("admin", "admin");
View Full Code Here

Examples of com.orientechnologies.orient.object.db.OObjectDatabaseTx

    super.afterClass();
  }

  @Test
  public void createAnnotatedObjects() {
    database = new OObjectDatabaseTx(url).open("admin", "admin");
    database.getEntityManager().registerEntityClasses("com.orientechnologies.orient.test.domain.business");
    database.getEntityManager().registerEntityClasses("com.orientechnologies.orient.test.domain.whiz");
    database.getEntityManager().registerEntityClasses("com.orientechnologies.orient.test.domain.base");
    Country austria = new Country("Austria");
    City graz = new City(austria, "Graz");
View Full Code Here

Examples of com.orientechnologies.orient.object.db.OObjectDatabaseTx

  @Test(dependsOnMethods = "testDeleteRollback")
  public void clean() {
    database.close();

    database = new OObjectDatabaseTx(url).open("admin", "admin");
    try {
      database.delete(profile);
      database.delete(account);

    } finally {
View Full Code Here

Examples of com.orientechnologies.orient.object.db.OObjectDatabaseTx

  OJPAEntityManager(EntityManagerFactory entityManagerFactory, OJPAProperties properties) {
    this.properties = properties;
    this.emFactory = entityManagerFactory;

    this.database = new OObjectDatabaseTx(properties.getURL());
    database.open(properties.getUser(), properties.getPassword());
    if (properties.isEntityClasses()) {
      database.getEntityManager().registerEntityClasses(properties.getEntityClasses());
    }
    transaction = new OJPAEntityTransaction(database);
View Full Code Here

Examples of com.orientechnologies.orient.object.db.OObjectDatabaseTx

   */
  @SuppressWarnings("unused")
  @Test
  public void testRollbackWithRemove() {
    // check if the database exists and clean before running tests
    OObjectDatabaseTx database = new OObjectDatabaseTx(url);
    database.open("admin", "admin");

    try {
      Account account = new Account();
      account.setName("John Grisham");
      account = database.save(account);

      Address address1 = new Address();
      address1.setStreet("Mulholland drive");

      Address address2 = new Address();
      address2.setStreet("Via Veneto");

      List<Address> addresses = new ArrayList<Address>();
      addresses.add(address1);
      addresses.add(address2);
      account.setAddresses(addresses);

      account = database.save(account);

      database.commit();

      String originalName = account.getName();

      database.begin(TXTYPE.OPTIMISTIC);

      Assert.assertEquals(account.getAddresses().size(), 2);
      account.getAddresses().remove(1); // delete one of the objects in the Books collection to see how rollback behaves
      Assert.assertEquals(account.getAddresses().size(), 1);
      account.setName("New Name"); // change an attribute to see if the change is rolled back
      account = database.save(account);

      Assert.assertEquals(account.getAddresses().size(), 1); // before rollback this is fine because one of the books was removed

      database.rollback(); // rollback the transaction

      account = database.reload(account, true); // ignore cache, get a copy of author from the datastore
      Assert.assertEquals(account.getAddresses().size(), 2); // this is fine, author still linked to 2 books
      Assert.assertEquals(account.getName(), originalName); // name is restored

      int bookCount = 0;
      for (Address b : database.browseClass(Address.class)) {
        if (b.getStreet().equals("Mulholland drive") || b.getStreet().equals("Via Veneto"))
          bookCount++;
      }
      Assert.assertEquals(bookCount, 2); // this fails, only 1 entry in the datastore :(
    } finally {
      database.close();
    }
  }
View Full Code Here

Examples of com.orientechnologies.orient.object.db.OObjectDatabaseTx

  }
    }

    @Test
    public void reproduce() throws Exception {
  final OObjectDatabaseTx db = new OObjectDatabaseTx(
    "memory:CustomDatatypeTest");
  db.create();

  // WrappedString custom datatype registration (storing it as
  // OType.STRING)
  OObjectSerializerContext serializerContext = new OObjectSerializerContext();
  serializerContext.bind(new OObjectSerializer<WrappedString, String>() {
      @Override
      public String serializeFieldValue(Class<?> iClass,
        WrappedString iFieldValue) {
    return iFieldValue.getValue();
      }

      @Override
      public WrappedString unserializeFieldValue(Class<?> iClass,
        String iFieldValue) {
    final WrappedString result = new WrappedString();
    result.setValue(iFieldValue);
    return result;
      }
  });
  OObjectSerializerHelper.bindSerializerContext(WrappedString.class,
    serializerContext);

  // we want schema to be generated
  db.setAutomaticSchemaGeneration(true);

  // register our entity
  db.getEntityManager().registerEntityClass(Entity.class);

  // Validate DB did figure out schema properly
  Assert.assertEquals(db.getMetadata().getSchema().getClass(Entity.class)
    .getProperty("data").getType(), OType.STRING);
    }
View Full Code Here

Examples of com.orientechnologies.orient.object.db.OObjectDatabaseTx

public class OVersionSerializationTest {
  private OObjectDatabaseTx database;

  @BeforeClass
  protected void setUp() throws Exception {
    database = new OObjectDatabaseTx("memory:OVersionSerializationTest");
    database.create();

    database.getEntityManager().registerEntityClass(EntityStringVersion.class);
    database.getEntityManager().registerEntityClass(EntityObjectVersion.class);
    database.getEntityManager().registerEntityClass(EntityExactVersionType.class);
View Full Code Here

Examples of com.orientechnologies.orient.object.db.OObjectDatabaseTx

  private OObjectDatabaseTx databaseTx;

  @BeforeClass
  protected void setUp() throws Exception {
    databaseTx = new OObjectDatabaseTx("memory:OObjectEntitySerializerTest");
    databaseTx.create();

    databaseTx.getEntityManager().registerEntityClass(ExactEntity.class);

  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.