2 Replies Latest reply on Oct 28, 2005 4:44 PM by Emmanuel Bernard

    Postgres Enum problems

    Matt Johnston Newbie

      I am trying to use a custom Enum with postgres 8 and I am having a problem. My enum is pretty simple

      public enum SubmitType {
       RM("RM","Reader Mail"),
       RE("RE","Reader Email"),
       private String id;
       private String name;
       private SubmitType(String id, String name) {
       this.id = id;
       this.name = name;
       public String getId() {
       return id;
       public String getName() {
       return name;
       public String toString() {
       return id;

      I then use it in an entity bean
       parameters = {@Parameter(name="enumClass", value="com.pga.recipe.entity.SubmitType")}),
      @Column(name="submit_type", columnDefinition="varchar(2)")
       @Type(type = "com.pga.recipe.entity.SubmitType")
       public SubmitType getSubmitType() {
       return submitType;
       public void setSubmitType(SubmitType submitType) {
       this.submitType = submitType;

      The database table is created correctly and my "submit_type" column is a varchar(2). Then when I try to save an object by using

      I get the error message
      "ERROR: column "submit_type" is of type character varying but expression is of type bytea"

      I look at the sql insert statement and it is trying to save the SubmitType enum as binary (<stream of 87 bytes>). Where is the enum object changed to an sql statement? I thought that was in the EnumType.class file, but I added some log statements to EnumType (even some System.out.println) and nothing ever gets fired.