-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 
Author Message
 Post subject: Problem with setting value in Date field from JSP Parameter
PostPosted: Wed Dec 21, 2005 3:00 am 
Newbie

Joined: Sun Dec 19, 2004 8:10 pm
Posts: 10
Location: Australia
Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp

Hibernate version: 3.1

Name and version of the database you are using:Informix 9


hello all,

I am trying to set values into a Hibernate object called project from values passed in the request from a JSP page


// Code start
this is my code


/* create a new project with passed parameters */
SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy");

Project theProject = new Project();
theProject.setProjectId(Integer.valueOf(request.getParameter("projectId")== null ? "0" :request.getParameter("projectId")));
theProject.setEditBy(request.getParameter("userid"));
theProject.setEditDt(new java.util.Date());
theProject.setManager(request.getParameter("manager"));
theProject.setProjectDesc(request.getParameter("projectDesc"));
theProject.setSection(request.getParameter("section"));
theProject.setProjectNm(request.getParameter("projectNm"));
theProject.setStartDt(sdf.parse(request.getParameter("startDt")));
java.util.ArrayList myProjects = new ArrayList(0);

//Code End

If I remove the line highlighted above my code runs and all other values are stored in the database. If I leave this line in, the JSP page will not load and no values are stored anywhere. Can anyone see what I am doing wrong. The value is passed as a Parameter from the JSP page and the type in hibernate is a java.util.Date.

All help appreciated

Connie


Top
 Profile  
 
 Post subject:
PostPosted: Fri Dec 23, 2005 7:01 am 
Expert
Expert

Joined: Thu May 26, 2005 9:19 am
Posts: 262
Location: Oak Creek, WI
Hi,

This is noway a problem of hibernate.
See to that you use java.util.Date on both in the mapping and in the java class.
But this is strange!!!!!

The steps you have followed are correct, but Debug it this way
see the output of request.getParameter("startDt");
and the parse it with sdf.parse(request.getParameter("startDt")).


Now set the value in the Project Object
theProject.setStartDt(sdf.parse(request.getParameter("startDt")));
and check also the backend type for this Date field.

_________________
RamnathN
Senior Software Engineer
http://www.linkedin.com/in/ramnathn
Don't forget to rate.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Dec 23, 2005 4:05 pm 
Newbie

Joined: Sun Dec 19, 2004 8:10 pm
Posts: 10
Location: Australia
Thanks Ramnath,

I totally re wrote the page and now it works. I have no idea why and neither do my fellow developers, I shall put it down to a glitch in my IDE I guess.

Thankyou for taking the time to reply.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.