|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
-none- 2007-10-01 - By Musachy Barroso
If there is a validation error the code on your action shouldn't be
executed at all, so you wouldn't have this problem. Are you applying
the "defaultWorkflow" interceptor to your action?
On 10/1/07, Jon_French@(protected) <Jon_French@(protected)> wrote:
> 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:
> (which seems to be the exact same problem except with the
> OpenSessionInView filter instead of my OpenEntityManagerInView filter)
> And this spring post:
> ? 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
> ASRC Management Services
> ECOS Development Team
> Fort Collins Science Center
> US Geological Survey
> 2150 Centre Ave, Building C
> Fort Collins, CO 80526-8116
"Hey you! Would you help me to carry the stone?" Pink Floyd
-- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ------
To unsubscribe, e-mail: user-unsubscribe@(protected)
For additional commands, e-mail: user-help@(protected)