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
I have a ModelDriven action which controls CRUD operations on JPA managed
Entity E. E has a property called ?name? which maps to a database column
with a NOT NULL constraint. I have added a RequiredStringValidator
annotation to my Action to validate that the ?model.name? property is
non-null. The validation works perfectly.
However, during Struts Interceptor processing of a user entered empty
string for the ?model.name? ServletRequest parameter, entity instance E
has its getName() property set to a null value. Hibernate (my JPA
implementation provider) detects this property state change when the
Hibernate session is flushed at the closing of the JPA EntityManager by
the configured OpenEntityManagerInView ServletFilter. This results in an
attempt by Hibernate to update the ?name? database column to null and
results in a SqlException.
So the problem is that even with appropriate validation on a ModelDriven
action, my Entity moves to an invalid state which Hibernate then tries to
persist to the database at the closing of the session.
Based on what I gleaned from this WebWorkx post:
http://forums.opensymphony.com/thread.jspa?messageID=5315&#5315
(which seems to be the exact same problem except with the
OpenSessionInView filter instead of my OpenEntityManagerInView filter)
And this spring post:
http://forum.springframework.org/showthread.php?t=35740
? I think that what I need to do is set Hibernate?s flush mode to NEVER.
What this means to me is that Hibernate will only flush when I execute a
EntityManager.flush() command and that OpenEntityManagerInView?s closing
of the EntityManager won?t automatically result in a Hibernate session
flush and thus Entity E?s invalid state will not be persisted. This is in
line with what I understand to be the default behavior of Spring?s
OpenSessionInView filter. Unfortunately, I have not yet been able to set
Hibernate's flush mode (nor am I certain that this will solve my issue).
Can anyone shed some light on this problem?
Thanks in advance!

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

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