struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Christoph Nenning <>
Subject Re: Editing a JPA entity
Date Tue, 05 Jan 2016 07:57:01 GMT
> I'm using an action to retrieve a list of entities and render these as a
> list, the user can then select an edit button that calls an action that
> retrieves the individual entity and renders the edit page. Once the user 
> completed editing they hit the save button which calls the action that 
> the entity manager's merge method to update the db. Each of these 
> call methods of the same action class, but the entity ends up in a 
> state so merge will fail. I could just retrieve the entity again and 
> update each data member but this seems like a very messy way to do it. 
> there a better way to do this with struts?
> I'm using struts 2.3.20 with hibernate 4.3.11

Well, that is basic http. When data is SELECTed from DB and the html page 
is rendered the server is done. That means at this point there are no more 
references to attached jpa objects. In terms of http: the handling of GET 
request is completed.

When the user hits save the browser issues another http request, usually a 
POST request. On the server side there is no more state or information 
that there has been a GET request before and entities had been loaded.

So yes, you have to retrieve the entity again and update it.


This Email was scanned by Sophos Anti Virus

  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message