Java exception using GraphDatabaseService

20 views
Skip to first unread message

Darèios89

unread,
May 21, 2013, 4:56:37 AM5/21/13
to bio4j...@googlegroups.com
Hi! I'm trying to create new kinds of relationship between nodes....and i have an exception.....this is the code in which i want to make the relationship:


I have put the enum relationship in the same code:


The exception is:

org.neo4j.graphdb.NotInTransactionException
at org.neo4j.kernel.impl.persistence.PersistenceManager.getResource(PersistenceManager.java:252)
at org.neo4j.kernel.impl.persistence.PersistenceManager.relationshipCreate(PersistenceManager.java:161)
at org.neo4j.kernel.impl.core.NodeManager.createRelationship(NodeManager.java:253)
at org.neo4j.kernel.impl.core.NodeImpl.createRelationshipTo(NodeImpl.java:523)
at org.neo4j.kernel.impl.core.NodeProxy.createRelationshipTo(NodeProxy.java:207)
at src.main.java.com.era7.bioinfo.bio4j.drug.Prova.main(Prova.java:203)


It is thrown at this line:

Relationship rel = a.getNode().createRelationshipTo(b.getNode(), Prova.DrugRelTypes.KNOWS);  //RELAZIONE PERSONALE

I have no idea what's the matter...


Pablo Pareja Tobes

unread,
May 24, 2013, 10:45:08 AM5/24/13
to bio4j...@googlegroups.com
Hi Dareios,

The very same name of the exception gives you the reason. You're trying to modify the contents of the DB outside a transaction.

Cheers,

Pablo




--
Has recibido este mensaje porque estás suscrito al grupo "bio4j-user" de Grupos de Google.
Para anular la suscripción a este grupo y dejar de recibir sus correos electrónicos, envía un correo electrónico a bio4j-user+...@googlegroups.com.
Para obtener más opciones, visita https://groups.google.com/groups/opt_out.
 
 



--
Pablo Pareja Tobes

Darèios89

unread,
May 27, 2013, 5:09:03 PM5/27/13
to bio4j...@googlegroups.com
Thanks Pablo....but i have not understood what i need to do to begin the Transaction, i think my code has got all i need to start and finish a transaction....or not?



if(proteins.get(a1).getFullName().equals(protein))
{
Transaction tx= graphDb.beginTx(); //Inizio transazione
try{
ProteinNode a=proteins.get(a1);      //NODO BIO4j
Node n = graphDb.createNode();        //NODE PER COSTRUTTORE DRUG
DrugNode b=new DrugNode(n, (String)drugIDList.get(i), (String)drugname.get(i));  //NODO DRUG
tx.success();
Relationship rel = a.getNode().createRelationshipTo(b.getNode(), Prova.DrugRelTypes.KNOWS);  //RELAZIONE PERSONALE
DrugRel relationship=new DrugRel(rel);  //RELAZIONE DRUG
}
finally{
tx.finish(); //Fine transazione
}
break;

Pablo Pareja Tobes

unread,
May 28, 2013, 7:17:03 AM5/28/13
to bio4j...@googlegroups.com
Hi Dareios,

Please check Neo4j's documentation/mail-list for this kind of issues since this is directly related with how to use their technology.

Cheers,

Pablo
Reply all
Reply to author
Forward
0 new messages