Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [eclipselink-users] Updating Join Views



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
-- 
View this message in context: http://www.nabble.com/Updating-Join-Views-tp25448841p25450951.html
Sent from the EclipseLink - Users mailing list archive at Nabble.com.



Back to the top