i'm fairly new to spring data for neo (though i have experience with neo4j itself). i tried following the 'official' guide on spring data for neo, specifically the chapter on creating relationships.
But it seems i cannot get it to work. Spring is giving me an
java.lang.IllegalStateException: This index (Index[__rel_types__,Relationship]) has been marked as deleted in this transaction
Let me stress, that i am NOT removing any nodes or relationships. These are the relevant classes of my domain model:
@NodeEntity
public class User {
@GraphId
private Long nodeid;
@Indexed(unique = true)
private String uuid;
....
}
@NodeEntity
public class Website {
@GraphId
private Long nodeid;
@Indexed(unique = true)
private String uuid;
....
}
@RelationshipEntity(type = RelTypes.REL_USER_INTERESTED_IN)
public class UserInterest {
@GraphId
private Long nodeid;
@StartNode
private User user;
@EndNode
private Website site;
...
}
And this is my basic test which i can't get to turn green .. (note that i omitted large portions of the code, the basic setup of the spring context etc. is working fine)
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration
@Transactional
public class BaseTest {
@Autowired
protected Neo4jTemplate template;
@Autowired
protected GraphDatabaseService graphDatabaseService;
protected Transaction tx;
@Configuration
@EnableNeo4jRepositories
static class TestConfig extends Neo4jConfiguration {
TestConfig() throws ClassNotFoundException {
setBasePackage("me.bcfh.model");
}
@Bean
GraphDatabaseService graphDatabaseService() {
return new TestGraphDatabaseFactory().newImpermanentDatabase();
}
}
public void before() {
// provide implementation if necessary
}
public void after() {
// provide implementation if necessary
}
@Before
public void setup() throws Exception {
Neo4jHelper.cleanDb(graphDatabaseService, false);
before();
}
@After
public void tearDown() throws Exception {
after();
if (tx != null) {
tx.success();
tx.close();
tx = null;
}
}
}
public class BasicGraphTest extends BaseTest {
User user;
Website website;
UserInterest interest;
@Override
public void before() {
user = new User();
website = new Website();
website = template.save(website);
user = template.save(user);
}
@Test
@Transactional
public void dbShouldContainData() throws Exception {
UserInterest interest = new UserInterest();
interest.setSite(website);
interest.setUser(user);
template.save(interest);
// some assertions
...
}
}
The IllegalStateException is being thrown when I try persisting the UserInterest instance, which I do not understand because I am not removing anything anywhere.
The ways to create a relationship mentioned in the spring guide did not work for me either, here I got the same exception ..
Can anyone spot what I'm doing wrong here?
I am using Spring Version 4.1.4.RELEASE and Spring Data For Neo Version 3.2.1.RELEASE. Neo4j has version 2.1.6
Note: I also tried copying the domain model classes from the cineasts example into my project and borrowed a few lines of the DomainTest class but this too gives me the IllegalStateException, maybe there is something wrong with my setup?