0

I did a POC using SDN 3.3.0 sometime back.

Currently, I'm trying to do a POC on SDN 4.0.0.M1. I was able to create a running project in which repositories querying the DB exist on the application side. But it's performance isn't that great.

I'm trying to create a extension which can run as a plugin inside the server. But the problem here is that SDN API is quite changed between 3.3.0 and 4.0.0.M1.

I'm currently stuck at exposing my domain objects in the extension. In 3.3.0, we have SpringPluginInitializer which can be used for the same but couldn't find anything similar in 4.0. Can anyone give any pointers or tutorials on how to configure a plugin using SDN 4.0?

PFB the domain objects and repositories:

package org.neo4j.domain;

import org.neo4j.ogm.annotation.EndNode;
import org.neo4j.ogm.annotation.GraphId;
import org.neo4j.ogm.annotation.RelationshipEntity;
import org.neo4j.ogm.annotation.StartNode;

@RelationshipEntity(type = "HAS_ADDRESS")
public class EmployeeToAddressRelationship {

    @GraphId
    private Long id;

    @StartNode  private Employee employee;
    @EndNode  private Address address;
    //@RelationshipType private relationshipType;

    public EmployeeToAddressRelationship()
    {
        super();
    }

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }
    public Employee getEmployee() {
        return employee;
    }
    public void setEmployee(Employee employee) {
        this.employee = employee;
    }
    public Address getAddresss() {
        return address;
    }
    public void setAddresss(Address address) {
        this.address = address;
    }


}




package org.neo4j.domain;

import org.springframework.data.annotation.TypeAlias;
import org.neo4j.ogm.annotation.GraphId;
import org.neo4j.ogm.annotation.NodeEntity;

@NodeEntity
@TypeAlias("ADDRESS")
public class Address {

@GraphId
private Long id;

public String property1;
public String property2;
public String property3;
public String property4;


Address(){}

//getters and setters for all properties

}







package org.neo4j.repository;

import java.util.Map;
import org.neo4j.domain.Employee2Result;
import org.neo4j.domain.Address;
import org.neo4j.domain.Employee;
import org.neo4j.domain.EmployeeToAddressRelationship;
import org.springframework.data.neo4j.annotation.Query;
import org.springframework.data.repository.CrudRepository;
import org.springframework.stereotype.Repository;

@Repository
public interface EmployeeRepository extends CrudRepository<Employee, String> {

@Query("MATCH p=(node1:NODE1)<-[rel1:REL1]-(node2:NODE2)<-[rel2:REL2]-(node3:NODE3)<-[rel3:REL3]-(node4:NODE4)<-[empRel:REL4]-(emp:EMPLOYEE) WHERE node1.property1={0} AND node2.property2={1} AND node3.property3={2} RETURN emp ORDER BY emp.timestamp DESC")
public Iterable<Employee> method1(String property1, String property2, String property3);

@Query("MATCH p=(node1:NODE1)<-[rel1:REL1]-(node2:NODE2)<-[rel2:REL2]-(node3:NODE3)<-[rel3:REL3]-(node4:NODE4)<-[empRel:REL4]-(emp:EMPLOYEE)-[addressRel:HAS_ADDRESS]->(address:ADDRESS) WHERE node1.property1={0} AND node2.property2={1} AND node3.property3={2} RETURN emp,addressRel,address ORDER BY emp.timestamp DESC")
public Iterable<Employee2Result> method2(String property1, String property2, String property3);

}




package org.neo4j.domain;

import java.util.Set;
import org.springframework.data.annotation.TypeAlias;
import  org.neo4j.ogm.annotation.GraphId;
import  org.neo4j.ogm.annotation.NodeEntity;
import org.neo4j.ogm.annotation.Relationship;
import org.neo4j.ogm.annotation.typeconversion.DateString;
import org.neo4j.ogm.annotation.typeconversion.NumberString;

@NodeEntity(label="EMPLOYEE")
public class Employee {

@GraphId
private Long id;

public String property1;

public String property2;

public String property3;

public String property4;

@Relationship(type = "HAS_ADDRESS", direction = Relationship.UNDIRECTED)
Set<Address> address;


public Searchspace()
{}

//getters and setters for all properties

}






package org.neo4j.domain;

import org.neo4j.ogm.annotation.ResultColumn;
import org.springframework.data.neo4j.annotation.QueryResult;

@QueryResult
public class Employee2Result {

@ResultColumn("emp")
Employee emp;

@ResultColumn("address")
Address address;

@ResultColumn("addressRel")
EmployeeToAddressRelationship addressRel;

//getters and setters for all properties


}

PS - Any idea when SDN 4.0 GA release is?

Thanks in advance,

Rahul

Rahul
  • 637
  • 5
  • 16
  • There is no embedded mode for 4.0.GA – Michael Hunger Jun 27 '15 at 12:58
  • Please share the details of your entities, configuration, repositories, queries etc. to help you figure out why it would be slow. Thanks a lot. – Michael Hunger Jun 27 '15 at 12:58
  • Also try to use 4.0.0.BUILD-SNAPSHOT it has the latest features and improvements and will soon be released as RC1 then GA – Michael Hunger Jun 27 '15 at 12:59
  • @MichaelHunger - Hi Michael, Thanks for the info. I'll share the code details soon. But I'm not trying to run Neo4j in embedded mode. I just want to create an unmanaged extension/plugin using SDN 4.0 and deploy it to the standalone server, is it possible? – Rahul Jun 28 '15 at 09:39
  • No, because that would mean you use Neo4j (within the server) embedded. – Michael Hunger Jun 28 '15 at 22:41
  • @MichaelHunger - ok. Will SDN 4.1 will support embedded mode? When is it scheduled to release? – Rahul Jun 29 '15 at 00:04
  • @MichaelHunger - Also, when I said SDN 4.0 performance isn't that great, I actually compared it with my current implementation. Currently, I'm executing cypher queries by passing them in a rest call to the server and converting the JSON response to custom model object using a custom message converter. I ran both using a simple query to retrieve Employee nodes from a DB(2.2.2 containing 1341 employee nodes). Execution time when executed from SDN 4.0 POC : 1113 ms Execution time when executed using current code : 354 ms – Rahul Jun 29 '15 at 00:11
  • @QueryResult/@ResultColumn isn't working as expected. Getting following exception while executing method2 of EmployeeRepository: WARN o.n.ogm.mapper.SingleUseEntityMapper - Unable to find property: emp on class: org.neo4j.domain.Employee2Result for writing WARN o.n.ogm.mapper.SingleUseEntityMapper - Unable to find property: address on class: org.neo4j.domain.Employee2Result for writing WARN o.n.ogm.mapper.SingleUseEntityMapper - Unable to find property: addressRel on class: org.neo4j.domain.Employee2Result for writing – Rahul Jun 30 '15 at 00:58
  • @ResultColumn isn't supported yet. If there are other issues please post in a new question so we can help, thanks. – Luanne Jun 30 '15 at 04:34

0 Answers0