But for as per the documentation, Object API not being improved. Is it good
to use it, why can't we have a jackson or gson kind of conversion b/w pojo
to json and vice versa?

On Mon, Jun 15, 2015 at 3:58 PM xvik <[email protected]> wrote:

> Hi,
>
> If you want to work with pojo you need to use object api instead of
> document api.
> Look here for examples
> http://orientdb.com/docs/last/orientdb.wiki/Object-Database.html
>
> понедельник, 15 июня 2015 г., 16:20:50 UTC+6 пользователь Giulia Brignoli
> написал:
>>
>> Hi,
>>
>> Try this:
>>
>> public static void main(String[] args) {
>> ODatabaseDocumentTx db =   new ODatabaseDocumentTx(path);
>> if (db.exists()){
>> db.open("admin","admin");
>> }else {
>> db.create();
>> // create a contact
>> Contact c = new Contact();
>>
> c.setEmail("[email protected]");
>>
> c.setNumber(123456789L);
>> // create list of contact
>> List<Contact> list = new ArrayList<Contact>();
>> list.add(c);
>> //  Insert date into class User
>> User user = new User();
>> user.setFirstName("Chaitanya Reddy");
>> user.setLastName("Tatipart");
>> user.setContacts(list);
>> // create a document
>> ODocument doc_user = new ODocument("User");
>> doc_user.field("FirstName", user.getFirstName());
>> doc_user.field("LastName", user.getLastName());
>> doc_user.field("Contact", user.getContacts().toString());
>> // save document
>> doc_user.save();
>>
>> }
>> // close db
>> db.close();
>>
>> }
>>
>
>> In this way you insert a object in OrientDB, in fact if you look to
>> visual studio you obtain:
>>
>>
>> <https://lh3.googleusercontent.com/-4LiDmcJyXfk/VX6mASfbdvI/AAAAAAAAAE0/65aCPZrBDj0/s1600/Immagine.png>
>>
>> PS: i create a plocal DB, if you have a remote database the class is a
>> little be different.
>>
>> Bye, Giulia.
>>
>  --
>
> ---
> 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.
>

-- 

--- 
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