Patch GWT 1.5 / Hibernate4GWT

by Olivier on Feb 6th in Uncategorized

Pour utiliser Hibernate4GWT et GWT 1.5, il faut patcher Hibernate4GWT la partie "emul" sinon vous pouvez avoir ce genre de message à la compilation

[java] [ERROR] Line 22: The interface Comparable cannot be implemented more than once with different arguments: Comparable and Comparable
[java] [ERROR] Line 86: Name clash: The method compareTo(Object) of type Date has the same erasure as compareTo(T) of type Comparable
but does not override it

En fait, l’émulation JRE de Date et Timestamp ne compile plus avec un JDK 1.5. Voici les patches à passer sur Hibernate4GWT 1.3 :

Index: src/net/sf/hibernate4gwt/emul/java/sql/Timestamp.java
===================================================================
--- src/net/sf/hibernate4gwt/emul/java/sql/Timestamp.java       (revision 133)
+++ src/net/sf/hibernate4gwt/emul/java/sql/Timestamp.java       (working copy)
@@ -22,7 +22,7 @@
  * Emulation of the java.sql.TimeStamp class
  * Based on the source of java.util.Date emulation from GWT
  */
-public class Timestamp extends java.util.Date implements Cloneable, Comparable{
+public class Timestamp extends java.util.Date implements Cloneable {
   /**
    * Used only by toString().
    */
@@ -90,22 +90,6 @@
     return clone;
   }

-  public int compareTo(Timestamp other) {
-    long thisTime = getTime();
-    long otherTime = other.getTime();
-    if (thisTime < otherTime) {
-      return -1;
-    } else if (thisTime > otherTime) {
-      return 1;
-    } else {
-      return getNanos() - other.getNanos();
-    }
-  }
-
-  public int compareTo(Object other) {
-    return compareTo((Timestamp) other);
-  }
-
   /**
    *  Return the names for the days of the week as specified by the Date
    *  specification.
@@ -269,4 +253,4 @@
     this.jsdate = new Date(date);
     this.nanos = 0;
   }-*/;
-}
\ No newline at end of file
+}

Index: src/net/sf/hibernate4gwt/emul/java/sql/Date.java
===================================================================
--- src/net/sf/hibernate4gwt/emul/java/sql/Date.java    (revision 133)
+++ src/net/sf/hibernate4gwt/emul/java/sql/Date.java    (working copy)
@@ -19,7 +19,7 @@
  * Emulation of the java.sql.Date
  * Based on the source of java.util.Date emulation from GWT
  */
-public class Date extends java.util.Date implements Cloneable, Comparable {
+public class Date extends java.util.Date implements Cloneable {
   /**
    * Used only by toString().
    */
@@ -71,22 +71,6 @@
     return new Date(getTime());
   }

-  public int compareTo(Date other) {
-    long thisTime = getTime();
-    long otherTime = other.getTime();
-    if (thisTime < otherTime) {
-      return -1;
-    } else if (thisTime > otherTime) {
-      return 1;
-    } else {
-      return 0;
-    }
-  }
-
-  public int compareTo(Object other) {
-    return compareTo((Date) other);
-  }
-
   /**
    *  Return the names for the days of the week as specified by the Date
    *  specification.

Index: build.xml
===================================================================
--- build.xml   (revision 133)
+++ build.xml   (working copy)
@@ -3,7 +3,7 @@

        

-

+



2 Comments

  1. Daves

    20th September 2008

    Excellent suggestions. However I downloaded the GWT src and I can’t find a way to build it quickly with NetBeans or Eclipse.

    So do you now about a quick tutorial to build GWT?

  2. Olivier

    20th September 2008

    You can build your GWT in command line with ant from gwt svn.

Leave a Reply

Please note: Comment moderation is enabled and may delay your comment.

Powered By Wordpress Designed By Ridgey