25 Ocak 2014 Cumartesi

the error: "org.neo4j.graphdb.NotInTransactionException"

The error message is somehing like this:

2014-01-25 16:37:43 ERROR HPAggregateProfile:141 - GRAMY_ERR:
org.neo4j.graphdb.NotInTransactionException
at org.neo4j.kernel.impl.index.IndexConnectionBroker.acquireResourceConnection(IndexConnectionBroker.java:49)
at org.neo4j.index.impl.lucene.LuceneIndex.getConnection(LuceneIndex.java:85)
at org.neo4j.index.impl.lucene.LuceneIndex.add(LuceneIndex.java:138)
at org.springframework.data.neo4j.support.typerepresentation.AbstractIndexingTypeRepresentationStrategy.add(AbstractIndexingTypeRepresentationStrategy.java:124)
at org.springframework.data.neo4j.support.typerepresentation.AbstractIndexingTypeRepresentationStrategy.addToTypesIndex(AbstractIndexingTypeRepresentationStrategy.java:116)
at org.springframework.data.neo4j.support.typerepresentation.AbstractIndexingTypeRepresentationStrategy.writeTypeTo(AbstractIndexingTypeRepresentationStrategy.java:59)
at org.springframework.data.neo4j.support.mapping.TRSTypeAliasAccessor.writeTypeTo(TRSTypeAliasAccessor.java:46)
at org.springframework.data.neo4j.support.mapping.TRSTypeAliasAccessor.writeTypeTo(TRSTypeAliasAccessor.java:26)

The solution is using transactions explicitly..
http://stackoverflow.com/questions/11485090/org-neo4j-graphdb-notintransactionexception

@Autowired
private GraphDatabaseService graphDb;

@Transactional
public void addRelation() {
  Transaction tx = graphDb.beginTx();
  ...
  tx.success(); //or tx.failure();
  tx.finish();
}

Hiç yorum yok:

Yorum Gönder