-->
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.  [ 1 post ] 
Author Message
 Post subject: Date Issues with XML to RDB Mapping
PostPosted: Mon Jul 16, 2007 10:58 am 
Newbie

Joined: Thu Jan 25, 2007 12:49 pm
Posts: 2
Location: Chichester, UK
I am having a problem passing dates from my XML Document to the Database...


Hibernate version: 3.2.4 sp1

Mapping documents:
Code:
<hibernate-mapping package="uk.gov.westsussex.fb.beans">
   <class name="FbCallsBean"
        table="CALLS"
        node="Call">
           <id name="VcsCallId" column="VcsCallId" type="long" />
      <property name="StatDateTime" column="StatDateTime" type="long" />
      <property name="StatDateTimeText" column="StatDateTimeText"
         type="long" />
      <property name="VcsCallSubId" column="VcsCallSubId" type="long" />
      <property name="CallType" column="CallType" type="long" />
      <property name="CallTypeText" column="CallTypeText" type="long" />
      <property name="CallPriority" column="CallPriority" type="long" />
      <property name="SourceType" column="SourceType" type="long" />
      <property name="SourcePrefix" column="SourcePrefix" type="long" />
      <property name="SourceExtension" column="SourceExtension"
         type="long" />
      <property name="SourceLogicalChannel"
         column="SourceLogicalChannel" type="long" />
      <property name="SourceCLIP" column="SourceCLIP" type="long" />
      <property name="SourceDialledNumber"
         column="SourceDialledNumber" type="long" />
      <property name="SourceUserId" column="SourceUserId" type="long" />
      <property name="SourceUserName" column="SourceUserName"
         type="java.lang.String" />
      <property name="SourceRoleId" column="SourceRoleId" type="long" />
      <property name="SourceRoleName" column="SourceRoleName"
         type="java.lang.String" />
      <property name="TargetPrefix" column="TargetPrefix" type="long" />
      <property name="TargetExtension" column="TargetExtension"
         type="java.lang.String" />
      <property name="TargetExternalDialledNumber"
         column="TargetExternalDialledNumber" type="long" />
      <property name="TargetUserId" column="TargetUserId"
         type="java.lang.String" />
      <property name="TargetUserName" column="TargetUserName"
         type="java.lang.String" />
      <property name="TargetRoleId" column="TargetRoleId" type="long" />
      <property name="TargetRoleName" column="TargetRoleName"
         type="java.lang.String" />
      <property name="TargetTypeConnected"
         column="TargetTypeConnected" type="long" />
      <property name="TargetPrefixConnected"
         column="TargetPrefixConnected" type="long" />
      <property name="TargetExtensionConnected"
         column="TargetExtensionConnected" type="long" />
      <property name="TargetLogicalChannelConnected"
         column="TargetLogicalChannelConnected" type="long" />
      <property name="TargetExternalDialledNumberCon"
         column="TargetExternalDialledNumberCon" type="java.lang.String" />
      <property name="TargetUserIdConnected"
         column="TargetUserIdConnected" type="long" />
      <property name="TargetUserNameConnected"
         column="TargetUserNameConnected" type="java.lang.String" />
      <property name="TargetRoleIdConnected"
         column="TargetRoleIdConnected" type="long" />
      <property name="TargetRoleNameConnected"
         column="TargetRoleNameConnected" type="java.lang.String" />
      <property name="RingingTime" column="RingingTime" type="long" />
      <property name="RingingDate" column="RingingDate"
         type="date" />
      <property name="RingingTimeText" column="RingingTimeText"
         type="long" />
      <property name="ReroutingReason" column="" type="long" />
      <property name="ReroutingReasonText"
         column="ReroutingReasonText" type="java.lang.String" />
      <property name="AnswerTime" column="AnswerTime" type="long" />
      <property name="AnswerDate" column="AnswerDate"
         type="date" />
      <property name="AnswerTimeText" column="AnswerTimeText"
         type="long" />
      <property name="ReleaseTime" column="ReleaseTime" type="long" />
      <property name="ReleaseDate" column="ReleaseDate"
         type="date" />
      <property name="ReleaseTimeText" column="ReleaseTimeText"
         type="long" />
      <property name="ReleaseReasonSource"
         column="ReleaseReasonSource" type="java.lang.String" />
      <property name="ReleaseReasonSourceText"
         column="ReleaseReasonSourceText" type="java.lang.String" />
      <property name="ReleaseReasonTarget"
         column="ReleaseReasonTarget" type="long" />
      <property name="ReleaseReasonTextTarget"
         column="ReleaseReasonTextTarget" type="java.lang.String" />
      <property name="ReleaseStateSource" column="ReleaseStateSource"
         type="long" />
      <property name="ReleaseStateSourceText"
         column="ReleaseStateSourceText" type="long" />
      <property name="ReleaseStateTarget" column="ReleaseStateTarget"
         type="long" />
      <property name="ReleaseStateTextTarget"
         column="ReleaseStateTextTarget" type="java.lang.String" />

   </class>
</hibernate-mapping>


Code between sessionFactory.openSession() and session.close():

Code:
Session session = HibernateUtil.getSessionFactory().openSession();

      Transaction transaction = session.beginTransaction();
      Session dom4jSession = session.getSession(EntityMode.DOM4J);

      Iterator iter = calls.iterator();
      while (iter.hasNext()) {

         Object next = iter.next();
         dom4jSession.saveOrUpdate("uk.gov.westsussex.fb.beans.FbCallsBean", next );

      }// end while
      transaction.commit();
      session.close();

Full stack trace of any exception that occurs:
Code:
org.hibernate.HibernateException: could not parse XML
   at org.hibernate.type.DateType.fromStringValue(DateType.java:98)
   at org.hibernate.type.NullableType.fromXMLString(NullableType.java:198)
   at org.hibernate.type.NullableType.fromXMLNode(NullableType.java:222)
   at org.hibernate.property.Dom4jAccessor$ElementGetter.get(Dom4jAccessor.java:194)
   at org.hibernate.property.Dom4jAccessor$Dom4jGetter.getForInsert(Dom4jAccessor.java:94)
   at org.hibernate.tuple.entity.AbstractEntityTuplizer.getPropertyValuesToInsert(AbstractEntityTuplizer.java:271)
   at org.hibernate.persister.entity.AbstractEntityPersister.getPropertyValuesToInsert(AbstractEntityPersister.java:3668)
   at org.hibernate.event.def.AbstractSaveEventListener.performSaveOrReplicate(AbstractSaveEventListener.java:267)
   at org.hibernate.event.def.AbstractSaveEventListener.performSave(AbstractSaveEventListener.java:181)
   at org.hibernate.event.def.AbstractSaveEventListener.saveWithGeneratedId(AbstractSaveEventListener.java:121)
   at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.saveWithGeneratedOrRequestedId(DefaultSaveOrUpdateEventListener.java:187)
   at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.entityIsTransient(DefaultSaveOrUpdateEventListener.java:172)
   at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.performSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:94)
   at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.onSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:70)
   at org.hibernate.impl.SessionImpl.fireSaveOrUpdate(SessionImpl.java:507)
   at org.hibernate.impl.SessionImpl.saveOrUpdate(SessionImpl.java:499)
   at uk.gov.westsussex.hibernate.FbCallsManager.insertCalls(FbCallsManager.java:74)
   at uk.gov.westsussex.fb.swing.Main$1.actionPerformed(Main.java:69)
   at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:1815)
   at javax.swing.AbstractButton$ForwardActionEvents.actionPerformed(AbstractButton.java:1868)
   at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:449)
   at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:287)
   at javax.swing.AbstractButton.doClick(AbstractButton.java:318)
   at javax.swing.plaf.basic.BasicMenuItemUI.doClick(BasicMenuItemUI.java:1146)
   at javax.swing.plaf.basic.BasicMenuItemUI$MouseInputHandler.mouseReleased(BasicMenuItemUI.java:973)
   at java.awt.Component.processMouseEvent(Component.java:5196)
   at java.awt.Component.processEvent(Component.java:4993)
   at java.awt.Container.processEvent(Container.java:1607)
   at java.awt.Component.dispatchEventImpl(Component.java:3712)
   at java.awt.Container.dispatchEventImpl(Container.java:1665)
   at java.awt.Component.dispatchEvent(Component.java:3574)
   at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:3521)
   at java.awt.LightweightDispatcher.processMouseEvent(Container.java:3236)
   at java.awt.LightweightDispatcher.dispatchEvent(Container.java:3166)
   at java.awt.Container.dispatchEventImpl(Container.java:1651)
   at java.awt.Window.dispatchEventImpl(Window.java:1653)
   at java.awt.Component.dispatchEvent(Component.java:3574)
   at java.awt.EventQueue.dispatchEvent(EventQueue.java:536)
   at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:237)
   at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:187)
   at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:181)
   at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:173)
   at java.awt.EventDispatchThread.run(EventDispatchThread.java:136)
Caused by: java.text.ParseException: Unparseable date: "01/04/2006"
   at java.text.DateFormat.parse(DateFormat.java:347)
   at org.hibernate.type.DateType.fromStringValue(DateType.java:95)
   ... 42

Name and version of the database you are using:

The generated SQL (show_sql=true): N/A

Excerpt from the XML Document:
Code:
<StatisticsExport>
  <Call>
    <SqlID>98748    </SqlID>
    <StatDateTime>820806604    </StatDateTime>
    <StatDateTimeText>20060104015004    </StatDateTimeText>
    <VcsCallId>303469612243404    </VcsCallId>
    <VcsCallSubId>0    </VcsCallSubId>
    <CallType>7    </CallType>
    <CallTypeText>999    </CallTypeText>
    <CallPriority>3    </CallPriority>
    <SourceType>0    </SourceType>
    <SourcePrefix>01    </SourcePrefix>
    <SourceExtension>1401    </SourceExtension>
    <SourceLogicalChannel>0    </SourceLogicalChannel>
    <SourceCLIP>091401403263353    </SourceCLIP>
    <SourceDialledNumber>771219    </SourceDialledNumber>
    <SourceUserId>-1    </SourceUserId>
    <SourceUserName>Unknown    </SourceUserName>
    <SourceRoleId>-1    </SourceRoleId>
    <SourceRoleName>Unknown    </SourceRoleName>
    <TargetPrefix>01    </TargetPrefix>
    <TargetExtension>3000    </TargetExtension>
    <TargetExternalDialledNumber>    </TargetExternalDialledNumber>
    <TargetUserId>-1    </TargetUserId>
    <TargetUserName>Unknown    </TargetUserName>
    <TargetRoleId>-1    </TargetRoleId>
    <TargetRoleName>Unknown    </TargetRoleName>
    <TargetTypeConnected>1    </TargetTypeConnected>
    <TargetPrefixConnected>01    </TargetPrefixConnected>
    <TargetExtensionConnected>1002    </TargetExtensionConnected>
    <TargetLogicalChannelConnected>0    </TargetLogicalChannelConnected>
    <TargetExternalDialledNumberCon>    </TargetExternalDialledNumberCon>
    <TargetUserIdConnected>71    </TargetUserIdConnected>
    <TargetUserNameConnected>John Hicks    </TargetUserNameConnected>
    <TargetRoleIdConnected>101    </TargetRoleIdConnected>
    <TargetRoleNameConnected>Fire / Rescue Control Op    </TargetRoleNameConnected>
    <RingingTime>6604    </RingingTime>
    <RingingDate>01/04/2006    </RingingDate>
    <RingingTimeText>20060104015004    </RingingTimeText>
    <ReroutingReason>-1    </ReroutingReason>
    <ReroutingReasonText>    </ReroutingReasonText>
    <AnswerTime>6610    </AnswerTime>
    <AnswerDate>01/04/2006    </AnswerDate>
    <AnswerTimeText>20060104015010    </AnswerTimeText>
    <ReleaseTime>6678    </ReleaseTime>
    <ReleaseDate>01/04/2006    </ReleaseDate>
    <ReleaseTimeText>20060104015118    </ReleaseTimeText>
    <ReleaseReasonSource>15    </ReleaseReasonSource>
    <ReleaseReasonSourceText>Unknown    </ReleaseReasonSourceText>
    <ReleaseReasonTarget>1    </ReleaseReasonTarget>
    <ReleaseReasonTextTarget>VCS hangup    </ReleaseReasonTextTarget>
    <ReleaseStateSource>15    </ReleaseStateSource>
    <ReleaseStateSourceText>Unknown    </ReleaseStateSourceText>
    <ReleaseStateTarget>2    </ReleaseStateTarget>
    <ReleaseStateTextTarget>Active    </ReleaseStateTextTarget>
  </Call>
</StatisticsExport>

_________________
google talk: mraandrews@gmail.com

m/\RK aNDREWS


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

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.