をArrayListのインスタンスを渡す。これは、私の場合では、MySQLを介してデータを取得し、ArrayListオブジェクトに保存しています、私は、JUnitテストで私のプログラムを実行しています、サイファー・クエリに同じオブジェクトが必要です`パブリッククラスDummyTest {checkMysqlConnection(上記のコードでのNeo4jのJUnitのためのコンフィギュレーションおよびCYPHERクエリで
@Test
@Rollback(true)
public void checkMysqlConnection() {
Connection connection = null;
ResultSet tableDatasRsult = null;
try {
Class.forName("com.mysql.jdbc.Driver");
Properties properties = new Properties();
properties.setProperty("user", "root");
properties.setProperty("password", "root");
String url = "127.0.0.1:3306/unicity";
connection = DriverManager.getConnection("jdbc:mysql://" + url, properties);
Assert.assertNotNull(connection);
String sqlq = "select DIST_ID,PV_DATE,POST_DATE from odh";
PreparedStatement preparedStatement = connection.prepareStatement(sqlq);
tableDatasRsult = preparedStatement.executeQuery();
ArrayList<OdhDO> odhDOs = new ArrayList<>();
while (tableDatasRsult.next()) {
OdhDO odhDO = new OdhDO();
odhDO.setDistId(tableDatasRsult.getLong("DIST_ID"));
odhDO.setPvDate(tableDatasRsult.getString("PV_DATE"));
odhDO.setPostDate(tableDatasRsult.getString("POST_DATE"));
odhDOs.add(odhDO);
Map<String, Object> params = new HashMap<>();
params.put(odhDO.getDistId().toString(), odhDO);
System.out.println(params);
}
} catch (ClassNotFoundException e) {
System.out.println("MySql Driver Class Not Found Exception");
e.printStackTrace();
} catch (SQLException e) {
System.out.println("Sql Exception");
e.printStackTrace();
} finally {
try {
connection.close();
} catch (SQLException e) {
e.printStackTrace();
}
}
}
@Test
@Rollback(true)
public void checkneo4jConnection(){
String URL= "http://localhost:7474";
Configuration configuration = new Configuration();
configuration.driverConfiguration().setDriverClassName("org.neo4j.ogm.drivers.http.driver.HttpDriver").setURI(URL).setCredentials("neo4j", "admin");
String cypher = "MATCH (Distributor) WHERE Distributor.DISTID IN {odhDOs} RETURN Distributor";
Map<String, Object> params = new HashMap<>();
List<String> odhDOs = new ArrayList<>();
params.put("odhDOs", odhDOs);
//add some names to the names list
//params.put(key, value)
}`
)iはデータを取得し、のArrayList odhDOs =新しいArrayListを<にこのデータを保存している方法>()オブジェクト、iが必要サイファークエリでこのArraylistインスタンスを渡しますが、このクラスとhからneo4jを設定して接続する方法はわかりませんクエリ内にこのarraylistインスタンスを渡すことができます "MATCH(Distributor)WHERE Distributor.DISTID IN {odhDOs} RETURN Distributor" neo4jを使用したjunitの設定と、cypherクエリで配列インスタンスを渡す方法をお手伝いしてください事前に..thanks ...
あなたは 'Distributor'がで注釈さというクラスを持っていますかNeo4j-OGMのドキュメントにある '@ NodeEntity'? https://github.com/neo4j/neo4j-ogm – digx1
はいディストリビュータークラスはOGMごとに –