[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
Re: [eclipselink-users] Updating Join Views
|
RogerV wrote:
>
>
>
> Andreas Schmidt wrote:
>>
>> Hello Roger,
>>
>> if you use faces, you can put a <t:saveState value="#{Bean or entity}"/>
>> tag in you page.
>> This will restore all fields of the entity (or the entire bean).
>> If your framework does not support such a tag and the bean is in request
>> mode, then you can update the fields as shown below:
>>
>>
>> public void save() {
>>
>>
>> ApplicationBean applicationBean = (ApplicationBean)
>> getBean("applicationBean");
>> EntityManager em = applicationBean.getEMF().createEntityManager();
>>
>> try {
>> em.getTransaction().begin();
>>
>> Entity e = em.find(Entity.class, this.entity.getId());
>>
>> e.setField1(this.entity.getField1());
>> e.setSprache(this.entity.getField2());
>>
>> em.getTransaction().commit();
>>
>>
>> } catch (Exception e) {
>> this.error(e.toString());
>>
>> } finally {
>> em.close();
>> }
>>
>> }
>>
>
> Hi Andreas
>
> I've tried your approach which works fine, but has led me to a fresh
> problem. What I'm doing now is reading the data via EclipseLink using the
> view and displaying it to a web page. When the data is posted back I find
> the entity in the base table I want to update and update the fields
> necassary as you describe. Checking in the database shows that the data
> field and the version field (optimistic locking) have been correctly
> updated. However, when I re-load the data from the view I see the
> pre-updated data, EclipseLink is reading from a cache, not the database.
>
> I've tried @Cache(disableHits = true) and @Cache(refreshOnlyIfNewer =
> true) on my view.java but neither seem to make any difference. What do I
> need to do to force EclipseLink to reload the view data from the database.
>
> Regards
>
Hello Roger,
as you said, the view will be cached and not updated with the fresh values
from the database.
I read somewhere, that you have to "invalidate" the cache of the view (can'
remeber how this can be achieved).
I my case I use the following annotation in the "view entity", since my
resultset is small and performance is not an issue:
@Cache(expiry = 1000 * 60)
//force cache refresh every minute (View !)
You can increase this values if required or disbale caching for this entity
in your persistance.xml
--
View this message in context: http://www.nabble.com/Updating-Join-Views-tp25448841p25451447.html
Sent from the EclipseLink - Users mailing list archive at Nabble.com.