-->
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.  [ 2 posts ] 
Author Message
 Post subject: java.sql.Timestamp problem under JDk 1.4 (HQL Editor View)
PostPosted: Wed Apr 13, 2005 10:08 am 
Senior
Senior

Joined: Tue Jan 11, 2005 5:03 pm
Posts: 137
Location: Montreal, Quebec
Hi, I have a strange issue when I am using JDK 1.4 for compilation but not with jdk 1.3.1.

I am using the Spring implemetation RC1.2 for Hibernate 3. I am also using Eclipse 3.1M5 and the Artifact Generator to generate the hbm.xml.

I am using the JDK 1.4 for the Eclipse runtime (for the Spring-IDE pluggin) but I am using the jdk 1.3.1 for my project because it will be deploy on WAS4.0.6. If I run my Hibernate Unit Tests (run some HQL Queries...), they are running correctly under jdk 1.3.1. If I trie to set the JRE to jdk1.4.2_06 and I run the same tests I have this error :

Code:
java.sql.SQLException: Value '0000-00-00' can not be represented as java.sql.Timestamp
   at com.mysql.jdbc.ResultSet.getNativeTimestamp(ResultSet.java:6659)
   at com.mysql.jdbc.ResultSet.getTimestampInternal(ResultSet.java:5314)
   at com.mysql.jdbc.ResultSet.getTimestamp(ResultSet.java:2324)
   at com.mysql.jdbc.ResultSet.getTimestamp(ResultSet.java:2356)
   at org.hibernate.type.TimestampType.get(TimestampType.java:27)
   at org.hibernate.type.NullableType.nullSafeGet(NullableType.java:62)
   at org.hibernate.type.NullableType.nullSafeGet(NullableType.java:53)
   at org.hibernate.type.AbstractType.hydrate(AbstractType.java:70)
   at org.hibernate.persister.BasicEntityPersister.hydrate(BasicEntityPersister.java:1525)
   at org.hibernate.loader.Loader.loadFromResultSet(Loader.java:817)
   at org.hibernate.loader.Loader.instanceNotYetLoaded(Loader.java:775)
   at org.hibernate.loader.Loader.getRow(Loader.java:687)
   at org.hibernate.loader.Loader.getRowFromResultSet(Loader.java:280)
   at org.hibernate.loader.Loader.doQuery(Loader.java:368)
   at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:195)
   at org.hibernate.loader.Loader.doList(Loader.java:1360)
   at org.hibernate.loader.Loader.list(Loader.java:1343)


So I have change the JRE to 1.3.1 to get ride of this error.

But the problem is coming back. Because Eclipse is running under JRE 1.4.2, the HQL Editor View pluggin is also running under JRE 1.4.2. So it cannot execute a simple query... I get the same error about "java.sql.SQLException: Value '0000-00-00' can not be represented as java.sql.Timestamp".

I really don't know where to start to correct this error.

This is my cgf file for testing:

Code:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-configuration PUBLIC
      "-//Hibernate/Hibernate Configuration DTD 3.0//EN"
      "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
<hibernate-configuration>

    <session-factory>
        <property name="hibernate.connection.url">jdbc:mysql://127.0.0.1/etl</property>
        <property name="hibernate.cglib.use_reflection_optimizer">true</property>
        <property name="hibernate.connection.password">***</property>
        <property name="hibernate.connection.username">root</property>
        <property name="hibernate.connection.driver_class">org.gjt.mm.mysql.Driver</property>
        <property name="hibernate.dialect">org.hibernate.dialect.MySQLDialect</property>
      <mapping resource="Control.hbm.xml"/>
      <mapping resource="Load.hbm.xml"/>
      <mapping resource="Job.hbm.xml"/>
      <mapping resource="Part.hbm.xml"/>
    </session-factory>
</hibernate-configuration>



and this is abn exemple of my hbm.xml file :

Code:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
   "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
   "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">

<hibernate-mapping>
   <!--
      Auto-generated mapping file from
      the hibernate.org cfg2hbm engine
   -->
   <class name="com.etl.persistence.model.Job" table="job">
      <id name="Id" type="java.lang.Integer">
         <column name="id" length="10" not-null="true" sql-type="int unsigned" />
         <generator class="assigned" />
      </id>

      <property name="Date" type="java.util.Date">
         <column name="date" length="19" not-null="true" sql-type="datetime" />
      </property>

      <property name="Type" type="java.lang.String">
         <column name="type" not-null="true" sql-type="varchar" />
      </property>

      <set name="SetOfLoad">
         <key>
            <column name="jobId" length="10" not-null="false" unique="true" />
         </key>
         <one-to-many class="com.etl.persistence.model.Load" />
      </set>
   </class>
</hibernate-mapping>


Any idea?

Thanks

Etienne
Montreal


Top
 Profile  
 
 Post subject:
PostPosted: Thu Apr 14, 2005 9:04 am 
Beginner
Beginner

Joined: Tue Mar 15, 2005 1:26 am
Posts: 20
you can use java.util.Date in java file and use java.sql.Timestamp in xml file.

_________________
OR maping? not familar. seems easy select, hard delete/update


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 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.