Hello Tim,
 
1. Since I am expicitly setting the handler to SQLTimestampFieldHandler, the handler is set properly and while marshalling alos no problem.
 
  <field name="eventtime" type="java.sql.Timestamp"
  handler="org.exolab.castor.xml.handlers.SQLTimestampFieldHandler">
 
But when I  try to unmarshal, java.util.Date is being set to SQLTimestampFieldHandler, please see the exception trace below. Is there any workaround for this.
 
2. Also when castor ummarshal java.util.Date it unmarsals in 2005-08-04T 00:00:00.000-00:00 , so when I do schema validation against <xs:element name="tdate" type="xs:date"/> using SAX I am getting a invalid date format error. How to make castor to marshal date in format 2005-08-04.
 
 
Thanks and Regards
-Mothy
001-212-656-4791(W)
001-781-856-9282(C)
001-732-952-3548(H)


From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
Sent: Tue 8/9/2005 9:49 PM
To: [email protected]
Cc: Mothy Sundararajan (WT01 - FINANCE - SECURITIES)
Subject: Re: [castor-dev] Problem unmarshalling java.sql.Timestamp


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
[email protected]

To
<[email protected]>
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.


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.

Reply via email to