Hello Mothy,

take a look at this Jira issue ... "http://jira.codehaus.org/browse/CASTOR-1126". It may be the same problem.


Tim.

+++
Tim Telcik
Technical Application Architect
Business Systems Delivery
Information Technology Services, HBF, Inc.
Email: [EMAIL PROTECTED]
Tel: 9214 6744    Fax: 9214 6779




<[EMAIL PROTECTED]>

09/08/2005 11:57 PM

Please respond to
dev@castor.codehaus.org

To
<dev@castor.codehaus.org>
cc
Subject
[castor-dev]  Problem unmarshalling java.sql.Timestamp





 
 Hi,
 
In my project I am using the following in castor mapping xml file
 
  <field name="eventtime" type="java.sql.Timestamp"
  handler="org.exolab.castor.xml.handlers.SQLTimestampFieldHandler">

 
When I try to Marshal (write to xml file) the Timestamp field I have no problem, castor properly writes to xml file as follows
 
<eventtime>2005-08-09T03:22:48.107-04:00</eventtime>
 
But when I try to read this(Unmarshal) I am getting the following exception
 
java.lang.IllegalArgumentException: Type conversion error: could not set value o
f
[EMAIL PROTECTED] with value of type java.util.Date
       at org.exolab.castor.mapping.loader.FieldHandlerImpl.setValue(FieldHandl
erImpl.java:512)
       at org.exolab.castor.xml.handlers.DateFieldHandler.setValue(DateFieldHan
dler.java:242)
       at org.exolab.castor.xml.UnmarshalHandler.endElement(UnmarshalHandler.ja
va:1066)
       at org.exolab.castor.xml.UnmarshalHandler.endElement(UnmarshalHandler.ja
va:1134)
       at org.apache.xerces.parsers.SAXParser.endElement(SAXParser.java:1403)
       at org.apache.xerces.validators.common.XMLValidator.callEndElement(XMLVa
lidator.java:1550)
       at org.apache.xerces.framework.XMLDocumentScanner$ContentDispatcher.disp
atch(XMLDocumentScanner.java:1149)
       at org.apache.xerces.framework.XMLDocumentScanner.parseSome(XMLDocumentS
canner.java:381)
       at org.apache.xerces.framework.XMLParser.parse(XMLParser.java:1098)
       at org.exolab.castor.xml.Unmarshaller.unmarshal(Unmarshaller.java:657)
       at org.exolab.castor.xml.Unmarshaller.unmarshal(Unmarshaller.java:565)
       at main.main(main.java:32)

 
 I extended SQLTimestampFieldHandler and overriden convertUponSet to see how the Timestamp value is prased. The value printed in the console is Date format. While UnMarshalling castor by default marshalls it as Date. Is there any work around for this. I am using castor-0.9.7. As this is very critical for my project if anyone knows the answer please let me know.
 
import org.exolab.castor.xml.handlers.SQLTimestampFieldHandler;
public class ERSQLTimestampFieldHandler extends SQLTimestampFieldHandler{
 public ERSQLTimestampFieldHandler(){
 super();
}

 public java.lang.Object convertUponSet(java.lang.Object value){
 System.out.println("convertUponSet >>" + value);
 return super.convertUponSet(value);

 }
}
 
Thanks
-Mothy
 
 


Confidentiality Notice

The information contained in this electronic message and any attachments to this message are intended
for the exclusive use of the addressee(s) and may contain confidential or privileged information. If
you are not the intended recipient, please notify the sender at Wipro or [EMAIL PROTECTED] immediately
and destroy all copies of this message and any attachments.





===================================================
HBF Health Funds Inc. a registered organisation under the National Health Act
HBF Insurance Pty Ltd ACN  009 268 277
This email is a confidential communication intended only for the named Addressee(s). 
If you are not that person any disclosure, copying, distribution or use of this email
or the information in it is prohibited. Please notify us immediately by 
telephone, (+61) 08 9265 6111 or return email and delete this email.
The views in this email may be personal to the author and not those of HBF.

Reply via email to