You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@openjpa.apache.org by PeshoChuka <ma...@abv.bg> on 2007/06/12 16:57:59 UTC

Refresh disconnected entity

Hello I have an e-commerce application. And I am using JSF and stateless
EJB's.

In a session managed bean I am storing the User object who is dosconnected.
At certain point the user wants to change its account. I am updateing the
users Account. At tis point I want to synchronize the disconected User
object to the database.

problems:

1. I cannot use refresh because the entity is disconnected.
2. I cannot use merge because old data will apply upon the new data and the
changes that were made will be rollbacked.
3. If i use entity.find(id) wouldn't it be too expensive operation?

How to refresh the state of a disconnected entity? Thanks in atdvance.


And I have one more question. Lets suppose that I have customer entity and
this entity has relation with Accounts with fetch type set to LAZY. If at
certain moment I need to fetch this records and the User Entity is
disconnected what is the best way to achieve this?    
  
This topic has no replies.  
 
 

-- 
View this message in context: http://www.nabble.com/Refresh-disconnected-entity-tf3908078.html#a11080464
Sent from the OpenJPA Users mailing list archive at Nabble.com.


Re: Refresh disconnected entity

Posted by Markus Fuchs <Ma...@Sun.COM>.
Hi Pesho,

PeshoChuka wrote:
> Hello I have an e-commerce application. And I am using JSF and stateless
> EJB's.
>
> In a session managed bean I am storing the User object who is dosconnected.
> At certain point the user wants to change its account. I am updateing the
> users Account. At tis point I want to synchronize the disconected User
> object to the database.
>
> problems:
>
> 1. I cannot use refresh because the entity is disconnected.
> 2. I cannot use merge because old data will apply upon the new data and the
> changes that were made will be rollbacked.
>   
Merge is the usual way to synchronize disconnected instances. On merge, 
the changes in the disconnected instance will be applied to a managed 
copy, and this copy is saved to the database on transaction commit. 
Isn't that what you want? Only refresh overwrites local changes with the 
state for the database.
> 3. If i use entity.find(id) wouldn't it be too expensive operation?
>
> How to refresh the state of a disconnected entity? Thanks in atdvance.
>
>
> And I have one more question. Lets suppose that I have customer entity and
> this entity has relation with Accounts with fetch type set to LAZY. If at
> certain moment I need to fetch this records and the User Entity is
> disconnected what is the best way to achieve this?    
>   
>   
This relationship should be marked EAGER, if it's going to be used in 
the disconnected instance.

-- markus.
> This topic has no replies.  
>  
>  
>
>