-
Notifications
You must be signed in to change notification settings - Fork 871
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
2 changed files
with
67 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -245,7 +245,7 @@ public boolean equals(Object obj) { | |
|
||
@Override | ||
public int hashCode() { | ||
return map.hashCode(); | ||
return 0; | ||
} | ||
|
||
} |
66 changes: 66 additions & 0 deletions
66
core/src/test/java/com/orientechnologies/orient/core/tx/LinksetInTransactionTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
package com.orientechnologies.orient.core.tx; | ||
|
||
import com.orientechnologies.orient.core.db.document.ODatabaseDocumentTx; | ||
import com.orientechnologies.orient.core.metadata.schema.OType; | ||
import com.orientechnologies.orient.core.record.OElement; | ||
import org.junit.Assert; | ||
import org.junit.Test; | ||
|
||
import java.util.HashSet; | ||
import java.util.Set; | ||
|
||
public class LinksetInTransactionTest { | ||
|
||
@Test | ||
public void test() { | ||
ODatabaseDocumentTx db = new ODatabaseDocumentTx("memory:LinksetInTransactionTest"); | ||
db.create(); | ||
try { | ||
|
||
db.createClass("WithLinks").createProperty("links", OType.LINKSET); | ||
db.createClass("Linked"); | ||
|
||
/* A link must already be there */ | ||
OElement withLinks1 = db.newInstance("WithLinks"); | ||
OElement link1 = db.newInstance("Linked"); | ||
link1.save(); | ||
Set set = new HashSet<>(); | ||
set.add(link1); | ||
withLinks1.setProperty("links", set); | ||
withLinks1.save(); | ||
|
||
/* Only in transaction - without transaction all OK */ | ||
db.begin(); | ||
|
||
/* Add a new linked record */ | ||
OElement link2 = db.newInstance("Linked"); | ||
link2.save(); | ||
Set links = withLinks1.getProperty("links"); | ||
links.add(link2); | ||
withLinks1.save(); | ||
|
||
/* Remove all from ORecordLazySet - if only link2 removed all OK */ | ||
links = withLinks1.getProperty("links"); | ||
links.remove(link1); | ||
links = withLinks1.getProperty("links"); | ||
links.remove(link2); | ||
withLinks1.save(); | ||
|
||
/* All seems OK before commit */ | ||
links = withLinks1.getProperty("links"); | ||
Assert.assertTrue(links.size() == 0); | ||
links = withLinks1.getProperty("links"); | ||
Assert.assertTrue(links.size() == 0); | ||
db.commit(); | ||
|
||
links = withLinks1.getProperty("links"); | ||
/* Initial record was removed */ | ||
Assert.assertFalse(links.contains(link1)); | ||
/* Fails: why is link2 still in the set? */ | ||
Assert.assertFalse(links.contains(link2)); | ||
|
||
} finally { | ||
db.drop(); | ||
} | ||
} | ||
} |