0 Replies Latest reply on Jul 6, 2007 2:55 PM by Chit Ko

    Wrong column type: Temporal(TemporalType.TIMESTAMP)

    Chit Ko Newbie

      I'm having this classic hibernateException.

      data column(last_modified) is datetime type (MySQL5Dialet)
      i declare this with @Temporal(TemporalType.TIMESTAMP) in JPA.
      what did i do wrong? i know java.sql.Timestamp extends java.util.Date. By default, Hibernate interprets a java.util.Date as a timestamp mapping. You need to explicitly specify type="time" or type="date" if you don?t wish to persist both date and time information.

      do i need to build custom Hibernat mapping type explicitly?

      State: FAILED
      Reason: javax.persistence.PersistenceException: org.hibernate.HibernateException: Wrong column type: last_modified, expected: date
      I Depend On:
      jboss.jca:service=DataSourceBinding,name=SeamLovelyDatasource


      this is my entitybean method:

      @Column(name = "last_modified", nullable = false, length = 19)
      @NotNull
      @Temporal(TemporalType.TIMESTAMP)
      public Date getLastModified() {
      return this.lastModified;
      }

      here is SQL structure:
      -- ----------------------------
      -- Table structure for reviews
      -- ----------------------------
      CREATE TABLE `reviews` (
      `reviews_id` int(8) NOT NULL,
      `products_id` int(8) NOT NULL,
      `customers_id` bigint(20) NOT NULL,
      `customers_name` varchar(128) NOT NULL,
      `reviews_rating` int(1) NOT NULL default '3',
      `date_added` datetime NOT NULL,
      `last_modified` datetime NOT NULL,
      `review_read` int(5) NOT NULL,
      PRIMARY KEY (`reviews_id`),
      KEY `products_id` (`products_id`),
      KEY `customers_id` (`customers_id`),
      CONSTRAINT `reviews_ibfk_1` FOREIGN KEY (`products_id`) REFERENCES `products` (`products_id`),
      CONSTRAINT `reviews_ibfk_2` FOREIGN KEY (`customers_id`) REFERENCES `customers` (`customers_id`)
      ) ENGINE=InnoDB DEFAULT CHARSET=latin1