0
SDN(spring-data-neo4j 4.1.2.RELEASE)を使用して、Neo4Jコミュニティエディション3.0.3のPersonエンティティを更新しようとしています。私はエンティティを更新する際にある種の動作を見ています。SDNを使用したNeo4Jエンティティのプロパティの更新
- 「person」という名前の「Person」エンティティを作成し、同じ をデータベース(8行目)に保存しました。
- 保存されたエンティティのプロパティ(fullName)が変更されましたが、 はデータベースの行(10行目)を更新しませんでした。
- データベースから同じ人物を取得しましたが、findByメソッドを使用して "person2"という名前の別の変数(12)に置き換えました。
- 変数 "person"(10行目)の変更は失われます。
personとperson2の両方の変数が今すぐ同じプロパティ値を持っています 。
1.Person person = new Person(); 2. person.setUuid(UUID.randomUUID().toString()); 3. person.setFullName("P1"); 4. person.setEmail("[email protected]"); 5. person.setUsername("[email protected]"); 6. person.setPhone("123456789"); 7. person.setDob(new Date()); 8. personService.create(person); 9. System.out.println(person); //Person{id=27, username='[email protected]', fullName='P1', email='[email protected]'} 10. person.setFullName("P2"); 11. System.out.println(person); //Person{id=27, username='[email protected]', fullName='P2', email='[email protected]'} 12.Person person2 = personService.findByEmail("[email protected]"); 13. System.out.println(person2); //Person{id=27, username='[email protected]', fullName='P1', email='[email protected]'} 14. System.out.println(person); //Person{id=27, username='[email protected]', fullName='P1', email='[email protected]'}
これはSDNのNeo4jのデフォルトの動作ですか?リロードした場合、この動作はのNeo4j OGM- 2.0.4 の最新バージョンで修正されているコメント
<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-neo4j</artifactId>
<!-- <version>4.1.2.RELEASE</version> -->
</dependency>
<dependency>
<groupId>org.neo4j</groupId>
<artifactId>neo4j-ogm-core</artifactId>
<version>2.0.4</version>
</dependency>
public class MyNeo4jConfiguration extends Neo4jConfiguration {
@Bean
public org.neo4j.ogm.config.Configuration getConfiguration() {
org.neo4j.ogm.config.Configuration config = new org.neo4j.ogm.config.Configuration();
config
.driverConfiguration()
.setDriverClassName("org.neo4j.ogm.drivers.http.driver.HttpDriver")
.setCredentials("neo4j", "admin")
.setURI("http://localhost:7474");
return config;
}
@Bean
public SessionFactory getSessionFactory() {
return new SessionFactory(getConfiguration(), "au.threeevolutions.bezzur.domain" );
}
}
私はspring-data-neo4j 4.1.2.RELEASEを使用しています。だから私はneo4j-ogmに変更する必要がありますか?私が切り替えていると、コードに多くの変更が加えられますか?その春のブートベースのプロジェクトです。私は日付まで春のデータに取り組んだだけです(以前の投稿からすでに気づいたかもしれません) – Soumya
Neo4j OGMにドロップする必要はありません。 org.neo4j のNeo4j-OGM-コア 2.0.4 とあなたのドライバーのための1つは、http://neo4j.com/docs/ogm-manualを参照してください。ちょうどあなたのポンポンでこの依存関係を含めます/ current /#_ dependencies_for_the_neo4j_ogm –
Luanne
私はそれに応じて変更を加えました。修正は質問自体にも提供されています。これで、変数 "person"と "person2"の両方の "fullName"プロパティの値は "P2"になりました。同じノードがデータベースからフェッチされると、それらのノードのローカル変更がフェッチされたものに反映されるようです。たとえば、変数 "person1"のfullNameの値を "P2"に変更しました。今私はperson1を永続化していないのに、変数 "person2"にfindByEmailメソッドを使って同じ人の詳細を取得したとき、この変数のfullNameも "P2"で "P1"ではありません – Soumya