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 Musachy Barroso

 Back
Only difference is that I don't use model driven. Is there any setting
to tell hibernate to flush the session when closed or it does that by
default?

musachy

On 10/1/07, Jon_French@(protected) <Jon_French@(protected)> wrote:
> Yes, musachy. I do something very similar. Here is my prepare() method:
>
>     public void prepare() throws Exception {
>         if( this.id==0 ) {
>             this.entity = new Entity();
>         } else {
>             this.entity = this.entityDao.findById(this.id);
>         }
>     }
>
> Here is the (obvious) getModel():
>
>     public Object getModel() {
>         return this.entity;
>     }
>
> Here is the update, "execute()" method that is called upon form
> submission:
>
>     @(protected)(
>            requiredStrings =
>                     {@(protected)(fieldName = "model.name",
> message = "You must enter a title.")}
>     )
>     public String update() {
>         if( this.id==0 ) {
>             this.entityDao.create(this.entity);
>         } else {
>             this.entity.update(this.entity);
>         }
>         return SUCCESS;
>     }
>
> So when a user enters a blank "model.name" field, this.entity.name
> property gets set to null, the update() method never is called, but
> Hibernate tries to write the update to the database when
> OpenEntityManagerInViewFilter closes the EntityManager:
>
> Here is the relevant code from OpenEntityManagerInViewFilter
>
>       protected void doFilterInternal(
>                         HttpServletRequest request, HttpServletResponse
> response, FilterChain filterChain)
>                         throws ServletException, IOException {
>
>               ...
>
>                 try {
>                         filterChain.doFilter(request, response);
>                 }
>
>                 finally {
>                         if (!participate) {
>                                 EntityManagerHolder emHolder =
> (EntityManagerHolder)
>  TransactionSynchronizationManager.unbindResource(emf);
>                                 emHolder.getEntityManager().close();
>                         }
>                 }
>         }
>
> 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
>
>
>
> "Musachy Barroso" <musachy@(protected)>
> 10/01/2007 05:10 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
>
>
>
>
>
>
> I only use the beanutils.copy solution on a few places, on the other
> cases I always load the object model on the prepare() method if the
> "id" field is set (editing), and then call update or create on the
> entity manager in my action method. I never got that problem so I'm
> wondering what is different. (I use JPA on top of hibernate)
>
> musachy
>
> On 10/1/07, Dave Newton <newton.dave@(protected)> wrote:
> > --- Jon_French@(protected) wrote:
> > > That's an interesting idea Dave. I'm using the
> > > paramsPrepareStack. It'll take some investigation to
> >
> > > see if that would fix the issue.
> >
> > Shouldn't take much; it might be as simple as adding a
> > validate/defaultWorkFlow up towards the top (although
> > I might try just adding new ones rather than removing
> > the existing ones).
> >
> > > Fort Collins Science Center
> > > US Geological Survey
> > > 2150 Centre Ave, Building C
> >
> > I used to live up Poudre River Canyon (Poudre Park); I
> > sure miss the climbing out there :(
> >
> > d.
> >
> >
> > -- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ------
> > To unsubscribe, e-mail: user-unsubscribe@(protected)
> > For additional commands, e-mail: user-help@(protected)
> >
> >
>
>
> --
> "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)
>
>
>


--
"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)


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