creating records with rid #-1:-2 orientdb graph database?

59 views
Skip to first unread message

gopinath....@gofindo.com

unread,
Nov 14, 2016, 4:40:32 AM11/14/16
to OrientDB, Naveen Alapati
Hi , 
I have strange problem, When I am creating a vertex with nontrasactional graph object the record is creating with record id i.e rid is #-1:-2 , and creating an edge with same object is resulting with  rid is #-1:-3  . 

I am creating like this code,

OrientVertex vertexObject = graph.addVertex("class:"+ClassProperties.VERTEXCLASSNAME);

if(vertexObject == null){

error.put(Constants.ERROR_KEY, "Bad request.");

return new ResponseEntity<String>(error.toString(), HttpStatus.BAD_REQUEST);

}

vertexObject.setProperty(ClassProperties.PROPERTY_ID, UUID.randomUUID().toString());

vertexObject.setProperty(ClassProperties.PROPERTY_NAME, request.getString(ClassProperties. PROPERTY_NAME));

vertexObject.setProperty(ClassProperties.PROPERTY_DESCRIPTION, request.getString(ClassProperties. PROPERTY_DESCRIPTION));

vertexObject.setProperty(ClassProperties.PROPERTY_SKU, "SKU-"+UUID.randomUUID().toString().substring(1, 7)); 
                                            graph.commit();

and in finally bock
                                          finally {
                                                if(graph != null)
                                                         graph.shutdown();

                                             }
                      

and result is getting like this



  1. @class : "className"
  2. @fieldTypes:"value=d,created_date=t,updated_date=t,in_HasReward=g"
  3. @rid:"#-1:-2"
  4. @type:"d"
  5. @version:0
  6. created_date:"2016-11-14 01:37:00"
  7. ... properties what i am trying to insert.


  8. I am unable to find the what was the problem. even sometimes creating successfully in mentioned clusters.?
  9. I have specified 8 clusters to this class by my java program (while designing vertexType), is that the problem ?



alessand...@gmail.com

unread,
Nov 14, 2016, 4:50:55 AM11/14/16
to orient-...@googlegroups.com, naveen....@gofindo.com
Hi, 
which version are you using, could you post more code ?

Naveen Alapati

unread,
Nov 15, 2016, 8:42:03 AM11/15/16
to alessand...@gmail.com, OrientDB, Gopinath Chilukuri
Hi,

We are using 2.2.7. thanks.

On Mon, Nov 14, 2016 at 3:20 PM, <alessand...@gmail.com> wrote:
Hi, 
which version are you using ?



--
Cheers,
Naveen Alapati,
Solution Architect | GoFindo
Skype: naveenkumar.alapati

alessand...@gmail.com

unread,
Nov 15, 2016, 8:44:33 AM11/15/16
to OrientDB, naveen....@gofindo.com
Could you post more code ?

Thanks

gopinath....@gofindo.com

unread,
Nov 16, 2016, 2:37:14 AM11/16/16
to OrientDB, naveen....@gofindo.com, Gopinath Chilukuri
That's only the logical code.
Only i missed return statement after the commit() statement. Here I am pasting return statement.

vertexObject.commit();
return new ResponseEntity<String>(vertexObject.getRecord().toJSON(), HttpStatus.OK); 

I have small doubt on creating of GraphFactory , Please suggest is this the right way of creating graphFactory
Here the code I am posting.

and for each controller I am calling factory.getNoTxGraph() method

public class FactoryService {

static Logger logger = Logger.getLogger(FactoryService.class);

public static OrientGraphFactory factory;

static {

logger.info("factory creating");

factory = new OrientGraphFactory(Constants.DATABASE_URL).setupPool(10, 40);

}

public OrientGraphFactory getGraphFactory(){

if(factory == null){

factory = new OrientGraphFactory(Constants.DATABASE_URL).setupPool(10, 40);

}

return factory;

}

public static OrientBaseGraph getNoTxGraph(){

return factory.getNoTx();

}

public  static OrientBaseGraph getTxGraph(){

return factory.getTx();

}


}



Thank you
Gopinath Chilukuri

Luigi Dell'Aquila

unread,
Nov 16, 2016, 3:32:33 AM11/16/16
to orient-...@googlegroups.com, naveen....@gofindo.com, Gopinath Chilukuri
Hi Gopinath,

This is a very basic operation and your code seems to be correct, so I suspect there is a problem somewhere else.
Just a couple of questions: 
- are you always using NoTx? In this case, why are you invoking graph.commit()? there is no need for that.
- how do you create your schema? 
- do you have a self-contained test case that reproduces the problem? It will make it much easier to diagnose 

Thanks

Luigi
 

--

---
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+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

gopinath....@gofindo.com

unread,
Nov 16, 2016, 7:40:37 AM11/16/16
to orient-...@googlegroups.com, naveen....@gofindo.com, gopinath....@gofindo.com
Hi Luigi,

1. Yes I am using for commit() for notTx() and Tx()  methods. Sometimes I am getting error if i did not put this statement. That is why I added this statement.
 
 my Question :   Is there any problem with using this commit() statement ?
2. I am creating schema (Only class name and with clusters) with java program. Generally I will create schema with OrientStudio web console. there I will specify all the properties and property type. Why I am creating Vertex or Edge class from java is , We can specify number of clusters for that vertex or Edge. If I create through  OrientStudio web console it will allocate only two clusters .

my Question : is there any problem with allocating toomany clusters?


3.  I am not writing any test cases in my program. (note : It is Spring boot rest services )

thanks
Gopinath Chilukuri

To unsubscribe from this group and stop receiving emails from it, send an email to orient-databa...@googlegroups.com.

Luigi Dell'Aquila

unread,
Nov 16, 2016, 8:15:48 AM11/16/16
to orient-...@googlegroups.com, naveen....@gofindo.com, Gopinath Chilukuri
HI Gopinath,


2016-11-16 13:40 GMT+01:00 <gopinath....@gofindo.com>:
Hi Luigi,

1. Yes I am using for commit() for notTx() and Tx()  methods. Sometimes I am getting error if i did not put this statement. That is why I added this statement.
 
 my Question :   Is there any problem with using this commit() statement ?

No, no problem in general, a commit() on a noTx() graph has no effect. My question is only because negative RIDs represent records that are just created and not committed yet, so I was wondering if there is a problem there.
 
2. I am creating schema (Only classanem and with clusters) with java program. Generally I will create schema with OrientStudio web console. there I will specify all the properties and property type. Why I am creating Vertex or Edge class from java is , We can specify number of clusters for that vertex of Edge. If I create through  OrientStudio web console it will allocate only two clusters .

my Question : is there any problem with allocating toomany clusters?


There is a limitation to 32k clusters per db, but apart from this there is no problem in using many clusters.
 

3.  I am not writing any test cases in my program. (note : It is Spring boot rest services )


Ok, do you think you can extract the application logic in a simple piece of code that I can run to reproduce the problem?
 
thanks
Gopinath Chilukuri

Thanks

Luigi
 
To unsubscribe from this group and stop receiving emails from it, send an email to orient-database+unsubscribe@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages