Hello I wanted to ask if I am doing this correctly or am doing something 
wrong, I initialize it like this:
*Class orientDBService*
OrientGraphFactory oFactory = new OrientGraphFactory 
(this.databaseURI).setupPool(1,10);;
this.graph = oFactory.getTx();

Then I have two methods one to create a Vertex and another to recover it
public void insertComposition(EhrId ehrId, CompositionData compositionData) 
{
    System.out.println("Insertando composition en bbdd");
    OrientGraph graph = orientDBService.getGraph();
    
    try{
    String idComposition = 
compositionData.getCompositionId().toString().split(":")[0];
    Vertex compositionVersion = (Vertex) graph.command( new 
OCommandSQL("insert into CompositionVersions set value = " + 
compositionData.asJSON()) ).execute();    
    
    }catch( Exception e ) {
    System.out.println("Error: " + e.getMessage());
    graph.rollback();
    }finally {
    graph.shutdown();
    }
    }

recover function
public CompositionData getComposition(String compositionId) {
OrientGraph graph = orientDBService.getGraph();
Vertex composition = null;
    try{
    //enlazamos al EHR
    Iterable<OrientVertex> resultComposition = graph
    .command( new OCommandSQL("SELECT @this.value.toJson('') FROM ( SELECT 
expand (out('hasVersions')) as this FROM Composition WHERE idComposition = 
'" + compositionId  + "')") ).execute();
    if (resultComposition.iterator().hasNext()){
    composition = (Vertex) resultComposition.iterator().next();
    }
    
    }catch( Exception e ) {
    System.out.println("Error: " + e.getMessage());
    graph.rollback();
    }finally {
//     graph.shutdown();
    }
    
    return 
CompositionData.fromJSON(composition.getProperty("this").toString());
    }


*This gives me the exception: Database is closed, However if I do not use 
graph.shutdown the data is not yet persistent*

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"OrientDB" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to orient-database+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
  • [orientdb] Database is... Academia Learning Centro de inglés y de formación

Reply via email to