Hi Dmitry,
What is your question ?
Will it work if you do  ?

Entity e = new Entity();
....
db.save(entity);

Yes it will, but you should reassign entity after that, I mean you should do

entity =  db.save(entity);

About case

Entity e = new Entity();
e.setId(); --where field id marked as @Id
...
db.save(entity);

It will not work by one of 2 reasons:
1. you will get concurrent modification exception, because you can not
updated not latest version.
2. document with given id does not exist, because ids are generated
automatically during save.




On Mon, Jan 13, 2014 at 10:15 PM, Dmitry <[email protected]> wrote:

> Hi!
>
> I was not talking about the transfer of DTO from repository to WEB layer.
> And in a reverse direction (from WEB to database).
> May be you can provide example?
> All your examples consist of code:
> Entity e = db.newInstance(Entity.class);
> ....
> db.save(e);
>
> But if I do so:
> Entity e = new Entity();
> ....
> db.save(entity);
>
> And if I do so:
> Entity e = new Entity();
> e.setId(); --where field id marked as @Id
> ...
> db.save(entity);
>
> Thanks.
>
> On Monday, January 13, 2014 3:17:13 PM UTC+3, Andrey Lomakin wrote:
>
>> Hi,
>> You can use detach/attach functionality.
>> Call com.orientechnologies.orient.object.db.OObjectDatabaseTx#detach
>> method and you will not have to copy data so you can use it as web layer
>> DTO.
>> Also you do not need to load entity to save it, just save it without
>> load, you asked how to load entity that is why I mentioned load method.
>>
>>
>>
>>
>> On Sat, Jan 11, 2014 at 3:24 PM, Dmitry <[email protected]> wrote:
>>
>>>  Andrey, maybe there are other options?
>>>
>>> I will explain:
>>> We have a typical web applications (that implements MVC pattern)
>>> And for example we use Spring MVC for it.
>>>
>>> Applications consists of:
>>> Controller (where implemented databinding from request parameters to our
>>> POJO model)
>>> Service/DAO layers for operation of the database.
>>>
>>> For your advice, we must perform mechanical work, because we:
>>> 1) load entity
>>> 2) copy field to field from one POJO (from WEB layer) to other POJO
>>> (loaded from OrientDb)
>>> 3) save loaded entity
>>>
>>> I understood you correctly?
>>>
>>>
>>> On Friday, December 27, 2013 7:35:50 PM UTC+3, Andrey Lomakin wrote:
>>>>
>>>> Ok.
>>>> So you want to load Pojo, update fields and save it.
>>>> It can be done by calling the method com.orientechnologies.orient.o
>>>> bject.db.OObjectDatabaseTx#load(java.lang.Object) and Pojo is saved by
>>>> calling method com.orientechnologies.orient.o
>>>> bject.db.OObjectDatabaseTx#save(java.lang.Object).
>>>>
>>>> About annotations @Oid and @OVersion. First is used to map record id to
>>>> pojo field and second is used to map version to pojo field.
>>>>
>>>  --
>>>
>>> ---
>>> 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/groups/opt_out.
>>>
>>
>>
>>
>> --
>> Best regards,
>> Andrey Lomakin.
>>
>> Orient Technologies
>> the Company behind OrientDB
>>
>>   --
>
> ---
> 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/groups/opt_out.
>



-- 
Best regards,
Andrey Lomakin.

Orient Technologies
the Company behind OrientDB

-- 

--- 
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/groups/opt_out.

Reply via email to