Skip to main content

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

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();
		}

	}



RogerV wrote:
> 
> Hi
> 
> Finally got my view working in EclipseLink (Thanks) but now when I try to
> update one of the base tables through the view, EclipseLink throws
> java.sql.SQLException: Can not modify more than one base table through a
> join view. I only want to update one of the base tables via the view. The
> underlying database (MySQL) allows this through native SQL. Is the clue in
> the words "more than one table" or does EclipseLink prevent any update
> through views?
> 
> Which brings me to another newbie question. All the CRUD examples I've
> seen, work with single entities in their entirety (i.e all fields are
> retrieved, displayed (some may be hidden fields)  in the web-app and all
> are returned. In a web-app, how do you deal with the situation where you
> may be displaying/updating only a subset of the fields in an entity - so
> when you try to merge() later, when only a subset of the fields are
> populated because some haven't been returned by the webapp . I guess what
> I'm trying to ask, is how to implement UPDATE TABLE SET Field7 = "xxx",
> Field24 = "yyy" using EclipseLink
> 
> Hope that this makes sense
> 
> Regards
> 

-- 
View this message in context: http://www.nabble.com/Updating-Join-Views-tp25448841p25450104.html
Sent from the EclipseLink - Users mailing list archive at Nabble.com.



Back to the top