0 Replies Latest reply on Feb 24, 2010 11:06 AM by xzerolin

    Problems of seam entity

    xzerolin

      My work environment is:

      eclipse: eclipse-jee-galileo-sr1
      Application Server: jboss-5.1.0.GA
      Seam: jboss-seam-2.2.0.GA
      DB Server: mysql-5.1.44
      OS: windows 7


      I have created a seam project by selected File-New-Seam Web Project.
      Then I wanted to test whether this project can work properly. I create a seam entity named User,just like here



      package org.domain.bookstore.entity;
      
      import java.io.Serializable;
      import javax.persistence.Entity;
      import javax.persistence.Id;
      import javax.persistence.GeneratedValue;
      import javax.persistence.Version;
      import org.hibernate.validator.Length;
      
      @Entity
      public class User implements Serializable
      {
          // seam-gen attributes (you should probably edit these)
          private Long id;
          private Integer version;
          private String name;
      
          // add additional entity attributes
      
          // seam-gen attribute getters/setters with annotations (you probably should edit)
      
          @Id @GeneratedValue
          public Long getId() {
              return id;
          }
      
          public void setId(Long id) {
              this.id = id;
          }
      
          @Version
          public Integer getVersion() {
              return version;
          }
      
          private void setVersion(Integer version) {
              this.version = version;
          }
      
          @Length(max = 20)
          public String getName() {
              return name;
          }
      
          public void setName(String name) {
              this.name = name;
          }
      
      }       
      




      Then I ran the server,but an error occured.




      15:24:48,454 ERROR [SchemaExport] Unsuccessful: create table User (id bigint generated by default as identity (start with 1), name varchar(20), version integer, primary key (id))
      15:24:48,454 ERROR [SchemaExport] You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'generated by default as identity (start with 1), name varchar(20), version integ' at line 1




      I googled it , from the answers I thought it was caused by the @GeneratedValue annotation so I removed it. Luckly it worked and the table user generated. But I still want use the @GeneratedValue annotation for generating the id.


      I hope to get help from here:).