Thanks for answering. 

You work only with strings (persist property with toString()). So this is 
not really what I want...

What I would like to achieve is to write an EMBEDDED jobject so that is 
persisted as json object WITHOUT storing "@type": "d", and "@version": 0.

e.g. 

{
            "@type": "d",
            "@rid": "#15:6",
            "@version": 3,
            "@class": "User",
            "name": "Testuser",
            "email": "[email protected]"
    "appRoles" : [{"appName": "testapp1", "rights":["admin", "etc"] },
{"appName": "testapp2", "rights":["user"] }
]
        }

It seems that when you use ODocument you get,  "@type": "d", and 
"@version": X for every object, also for EMBEDDEDLIST. This is not what I 
want because the info is unnecessary 

Of course another approach would be to generate the json string for every 
embedded object before write and recreate the java instance from the 
json-string after read






Am Montag, 15. Juni 2015 11:38:02 UTC+2 schrieb SavioL:
>
> hi,
> you have already tried using java?
> With java the field @version, @type there are not (see the image)
>
>
> <https://lh3.googleusercontent.com/-Q6MlwRmWAjU/VX6b0W4XQWI/AAAAAAAAACc/Ly3M_2V2bnI/s1600/list1.png>
>
>
>
>
> java code:
>
> public class TestObject{
>
>     private String value;
>
>     public TestObject() {
>         super();
>         this.value = "";
>     }
>
>     public String getValue() {
>         return value;
>     }
>
>     public void setValue(String value) {
>         this.value = value;
>     }
>
>     @Override
>     public String toString() {
>         return "TestObject [value=" + value + "]";
>     }
>
> }
>
>
>
>
> public class TestEmbeddedList {
>     
>     private static String remote = "remote:localhost/";
>
>     public static void main(String[] args) {
>
>         String nomeDb = "TestingList";
>         String currentPath = remote + nomeDb;
>
>         OServerAdmin serverAdmin;
>         OrientGraph g; 
>         
>         try {
>             serverAdmin = new OServerAdmin(currentPath).connect("root", 
> "root");
>             
>             if (serverAdmin.existsDatabase()) {
>                 System.out.println("Db already exist");
>             } else {
>                 serverAdmin.createDatabase(nomeDb, "graph", "plocal");
>                 System.out.println("Db created");
>             }    
>             
>             g = new OrientGraph(currentPath);
>
>             //VERTEX 1
>                 TestObject mio1= new TestObject ();
>                 mio1.setValue("my1");            
>                 TestObject mio2= new TestObject ();
>                 mio2.setValue("my2");
>                 List<TestObject> list = new ArrayList<TestObject>();
>                 list.add(mio1);
>                 list.add(mio2);
>                 
>                 
>                 
>                 OClass cl=g.createVertexType("PersonList", "V");
>                 cl.createProperty("name", OType.STRING);
>                 cl.createProperty("listPeople", OType.EMBEDDEDLIST);
>                 
>                 OrientVertex v1=g.addVertex("class:PersonList");
>                 v1.setProperties("name","list1");
>                 v1.setProperties("listPeople",list.toString());
>             
>                 
>                 //VERTEX 2
>                 TestObject mio3= new TestObject ();
>                 mio3.setValue("my3");            
>                 TestObject mio4= new TestObject ();
>                 mio4.setValue("my4");
>                 
>                 List<TestObject> list2 = new ArrayList<TestObject>();
>                 list2.add(mio3);
>                 list2.add(mio4);
>                 
>                 OrientVertex v2=g.addVertex("class:PersonList");
>                 v2.setProperties("name","list2");
>                 v2.setProperties("listPeople",list2.toString());
>                 
>                 g.commit();
>
>            
>                 //get info vertex 1 and 2
>                 for (Vertex v : g.getVertices()) {
>                     System.out.println(v.getProperty("name"));
>                     System.out.println(v.getProperty("listPeople"));
>                 }
>
>             g.shutdown();
>             
>         serverAdmin.close();
>         } catch (IOException e) {
>             e.printStackTrace();
>         }
>
>     }
>
> }
>
>
>
> However there are visibile also in a javascritp function 
>
>
> <https://lh3.googleusercontent.com/-4Ciiipc5Ij4/VX6cOdyu4FI/AAAAAAAAACk/UPRy6DjCiqI/s1600/Schermata%2Bda%2B2015-06-15%2B11%253A25%253A40.png>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
> @Type
> Type is 'd' for documents, 'b' for binaries, 'f' for flat. what you are 
> looking for is the @class that is 'OGraphVertex' for vertices and 
> 'OGraphEdge' for edges.
>
> @version
> The purpose of the @version property is to check if any update have been 
> made between the time you fetched the object and when you updated it.
> For instance if in your code you fetch a product, you update its 
> properties, in the meanwhile the object has changed in the database 
> (another piece of code has updated it), then you save it : you are trying 
> to update the object with the version 2, but it has the version 3 in 
> database.
> This can help you to prevent concurrent access to your database.
>
> regards,
> Savio L.
>
>
>
>
>
>
>
>

-- 

--- 
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 [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to