Package org.neo4j.graphdb

Examples of org.neo4j.graphdb.GraphDatabaseService.beginTx()


        try (Transaction tx = database.beginTx()) {
            database.createNode();
            tx.success();
        }

        try (Transaction tx = database.beginTx()) {
            assertTrue(asList(0L, 1L).contains(random(at(database).getAllNodes()).getId()));
            assertTrue(asList(0L, 1L).contains(random(at(database).getAllNodes()).getId()));
            assertTrue(asList(0L, 1L).contains(random(at(database).getAllNodes()).getId()));
            assertTrue(asList(0L, 1L).contains(random(at(database).getAllNodes()).getId()));
            assertTrue(asList(0L, 1L).contains(random(at(database).getAllNodes()).getId()));
View Full Code Here


    @Test
    public void shouldIncludeCorrectRelationships() {
        GraphDatabaseService database = new TestGraphDatabaseFactory().newImpermanentDatabase();

        try (Transaction tx = database.beginTx()) {
            Node n = database.createNode(label("Test"));
            n.setProperty("test", "test");
            Node internal = database.createNode(label(GA_PREFIX + "test"));

            assertTrue(of(IncludeAllBusinessNodes.getInstance(), IncludeNodes.all()).include(n));
View Full Code Here

    @Test
    public void shouldIncludeCorrectRelationships() {
        GraphDatabaseService database = new TestGraphDatabaseFactory().newImpermanentDatabase();

        try (Transaction tx = database.beginTx()) {
            Node n1 = database.createNode();
            Node n2 = database.createNode();
            Relationship r = n1.createRelationshipTo(n2, withName("TEST"));
            r.setProperty("test", "test");
View Full Code Here

                .setConfig(RUNTIME_ENABLED, "true")
                .setConfig(TestModuleBootstrapper.MODULE_ENABLED, TestModuleBootstrapper.MODULE_ENABLED.getDefaultValue())
                .setConfig(TestModuleBootstrapper.MODULE_CONFIG, TestModuleBootstrapper.MODULE_CONFIG.getDefaultValue())
                .newGraphDatabase();

        try (Transaction tx = database.beginTx()) {
            database.createNode(); //tx just to kick off Runtime init
            tx.success();
        }

        assertEquals(1, TEST_RUNTIME_MODULES.size());
View Full Code Here

                .setConfig("com.graphaware.module.wrong2.1", "com.not.existent.Bootstrapper")
                .setConfig(TestModuleBootstrapper.MODULE_ENABLED, TestModuleBootstrapper.MODULE_ENABLED.getDefaultValue())
                .setConfig(TestModuleBootstrapper.MODULE_CONFIG, TestModuleBootstrapper.MODULE_CONFIG.getDefaultValue())
                .newGraphDatabase();

        try (Transaction tx = database.beginTx()) {
            database.createNode();
            tx.success();
        }

        assertEquals(1, TEST_RUNTIME_MODULES.size());
View Full Code Here

                .setConfig("com.graphaware.module.test1.1", TestModuleBootstrapper.MODULE_ENABLED.getDefaultValue())
                .setConfig("com.graphaware.module.test3.3", TestModuleBootstrapper.MODULE_ENABLED.getDefaultValue())
                .setConfig("com.graphaware.module.test2.2", TestModuleBootstrapper.MODULE_ENABLED.getDefaultValue())
                .newGraphDatabase();

        try (Transaction tx = database.beginTx()) {
            database.createNode();
            tx.success();
        }

        assertEquals(3, TEST_RUNTIME_MODULES.size());
View Full Code Here

  public static void main(String[] args) {
    System.out.println("Hello Neo4j!");
//    GraphDatabaseService graphDb = new EmbeddedGraphDatabase( "target/data/test" );
    GraphDatabaseService graphDb = new EmbeddedGraphDatabase( "/Users/trisberg/neo4j/imdb" );
    Transaction tx = graphDb.beginTx();

    tx = graphDb.beginTx();
    try {
      for (Node n : graphDb.getAllNodes()) {
        System.out.print("=> " + n.getId() + " :: ");
View Full Code Here

    System.out.println("Hello Neo4j!");
//    GraphDatabaseService graphDb = new EmbeddedGraphDatabase( "target/data/test" );
    GraphDatabaseService graphDb = new EmbeddedGraphDatabase( "/Users/trisberg/neo4j/imdb" );
    Transaction tx = graphDb.beginTx();

    tx = graphDb.beginTx();
    try {
      for (Node n : graphDb.getAllNodes()) {
        System.out.print("=> " + n.getId() + " :: ");
        for (String s : n.getPropertyKeys()) {
          System.out.print(" : " + s + " = " + n.getProperty(s));
View Full Code Here

    @Test
    public void testQueryWithinTransaction() throws Exception {
        GraphDatabaseService db = getRestGraphDb();
        RestCypherQueryEngine cypher = new RestCypherQueryEngine(((RestAPIProvider)db).getRestAPI());
        Transaction tx = db.beginTx();
        QueryResult<Map<String,Object>> result = cypher.query("CREATE (person1 { personId: {id}, started: {started} }) return person1",
                map("id", 1, "started", System.currentTimeMillis()));
        try {
            result.to(Node.class).singleOrNull();
        } catch(IllegalStateException ise) { assertEquals(true, ise.getMessage().contains("finish the transaction")); }
View Full Code Here

        ReferenceNodes.obtainReferenceNode(db,"root");
        MappingInfrastructureFactoryBean factoryBean = new MappingInfrastructureFactoryBean(db, null);
        factoryBean.setTypeRepresentationStrategy(TypeRepresentationStrategyFactory.Strategy.SubRef);
        factoryBean.afterPropertiesSet();
        Neo4jTemplate template = new Neo4jTemplate(factoryBean.getObject());
        Transaction tx = db.beginTx();
        Person person = template.save(new Person());
        person.setName("Bar");
        template.save(person);
        tx.failure();
        tx.close();
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.