1
我們覺得我們終於對neo4j-ogm中看到的奇怪行爲有了解釋。我們最初認爲它與equals/hashcode實現有關,但事實並非如此。Neo4j OGM圖覆蓋交易中的更改
看來ogm保持圖的緩存副本,並且在一個事務中,所有的檢索都指向同一個內存對象。
我們創建了一個單元測試來證明的行爲(以下一些什麼不工作是僞代碼)
//all within the same transactional
//retrieve an object from the database
NodeObject no1 = repository.loadObject();
//update some values on the object
no1.setValue("whatever");
//retrieve the same database object into a new java object
NodeObject no2 = repository.loadObject();
//at this point no2 and no1 are the same java object, and any value changes to no1 have been reverted to no2, as is in the database.
這似乎特殊性是我們的一個問題。
我們之前已經觀察過這種情況,並通過改變檢索對象的深度(以防止它們的圖形在內存中恢復的東西)來消除它,但是當它不使用我們的密碼查詢時,它的可定製性較差。
請讓我們知道如何避免這個問題!
呃設計是指同一個對象。你能分享你的用例嗎? – Luanne