Java Mailing List Archive

http://www.junlu.com/

Google
Google
Mailing List
Home
Forum Home
JBoss - Java Application Server
Tomcat - JSP/Servlet container
Struts - A MVC web framework
iText - An open source PDF Java Library
JDOM - JDOM XML Parser
JSP - A mailing list about Java Server Pages specification and reference
J2EE - A mailing list for Java(tm) 2 Platform, Enterprise Edition
J2EE Pattern - An interest list for Sun Java Center J2EE Pattern Catalog
Servlet - A mailing list for discussion about Sun Microsystem's Java Servlet API Technology
Struts & Hibernate
Subjects
JSP editor plugin for eclipse ?
org apache jasper JasperException: Unable to compile class for JSP
Tomcat: Connection reset by peer: socket write error
Cannot retrieve definition for form bean null
Struts Tiles Tutorial (free Struts training)
Where do I download Tomcat 4 0 6?
Data Access Object (DAO) pattern, example DAO 's
Where to download Tomcat v 4 1 24 from?
Tomcat 5 0 16 Requested resource not available
Servlet : Session invalidate
Oracle Connection Pooling in 3 2 2
Servlet action is currently unavailable
Tomcat/Struts Unicode Encoding/Decoding problems
Running a Simple JMS Example
Tomcat and webapplication specific java library path
Mapping in workers2 properties
org apache jasper JasperException
problem with html:text bean throwing exception
Cannot find message resources under key org apache struts action
   MESSAGE
Cannot find message resources under key org apache struts action MESSAGE
invalid direct reference problem with solution
Tool for jsp debug Try Sysdeo Eclipse Plugin
Tomcat 5 Cannot load JDBC driver class 'null ' SQL state: null
weblogic ejbc
java properties file
Jboss 3 2 3 Coyote Can 't re
Tomcat 5, Apache2 and mod jk2 integration problem
JBoss example problem new to J2EE
Value attribute of <html:checkbox
url string for connecting jboss to oracle
javax servlet ServletException: BeanUtils populate
5 0 18: Windows XP Pro vs Windows 2000
HTTP Status 404 The requested resource is not available
 
-none-

-none-

2007-10-01       - By Jon_French@(protected)

 Back
Thanks Piero:

* don't flush the session and destroy the object

This is exactly what I want to do. However, the Hibernate session
automatically flushes when the EntityManager is closed during the
OpenEntityManagerInView filter exit filter operation. I definitely need
the filter in place to lazy load collections in my view pages.

* instantiate a temporary bean used for the form only:
BeanUtils.copyProperties(tempBean, yourBean);

Yes, but I'm reluctant to use this work-around although I admit that it
would probably work. IMO, the beauty of the ModelDriven pattern is that
you don't have to do this copy but can rather cut out the old Struts 1
ActionForm "middle-man" bean and do direct updates to your business
objects. Everything works great except this one problem with a validation
failure inappropriately triggering a database update.

* manage your entities with JPA's EntityManager, merge them manually.

I do. In fact, if the validation does NOT fail, my ModelDriven action
calls a JPA backed DAO that does update the entity with a
EntityManager.merge(...) call. In the case of failed validation, this DAO
is never invoked, but rather Hibernate automatically "merges" the invalid
Entity changes to the database when the Hibernate Session is closed.

Thanks for you help,

Jon French
Programmer
ASRC Management Services
ECOS Development Team
jon_french@(protected)
970-226-9290

Fort Collins Science Center
US Geological Survey
2150 Centre Ave, Building C
Fort Collins, CO 80526-8116



Piero Sartini <lists@(protected)>
10/01/2007 03:38 PM
Please respond to
"Struts Users Mailing List" <user@(protected)>


To
"Struts Users Mailing List" <user@(protected)>
cc

Subject
Re: ModelDriven CRUD validation failure still causes JPA update






> Since my Model is acquired from the Hibernate session (during the
> "prepare()" Action method), it is a transactional persistent instance.
> Note this from the hibernate documentation:
>
> "Transactional persistent instances (ie. objects loaded, saved, created
or
> queried by the Session) may be manipulated by the application and any
> changes to persistent state will be persisted when the Session  is
flushed
> (discussed later in this chapter). There is no need to call a particular
> method (like update(), which has a different purpose) to make your
> modifications persistent."

I do not know hibernate but you could try the following solutions:

* don't flush the session and destroy the object

* instantiate a temporary bean used for the form only:
BeanUtils.copyProperties(tempBean, yourBean);

* manage your entities with JPA's EntityManager, merge them manually.

Piero

-- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ------
To unsubscribe, e-mail: user-unsubscribe@(protected)
For additional commands, e-mail: user-help@(protected)



©2008 junlu.com - Jax Systems, LLC, U.S.A.