3 Replies Latest reply on Mar 6, 2007 3:39 AM by hispeedsurfer

    @ManyToOne results in tinyblob

    hispeedsurfer

      Hi,

      I'am working on JBoss-4.0.5.GA with EJB3 on MySQL.
      Why a @ManyToOne join result in a tinyblob instead of a foreign-key?

      My entities are a Baseentity and some derived classes with such @ManyToOne connections.

      Here the BaseEntity

      @MappedSuperclass
      public abstract class BaseEntity implements Serializable{
      
       @Column(name="__UUID__", unique=true, nullable=false, updatable=false, length=36)
       protected String internalUUID;
      
      
       protected Long id;
       protected Integer version;
      
       @Id @GeneratedValue
       protected Long getId(){
       return id;
       }
      
       protected void setId(Long id){
       this.id = id;
       }
      
       @Version
       protected Integer getVersion(){
       return version;
       }
       public void setVersion(Integer version) {
       this.version = version;
       }
      
       public BaseEntity(){
       this.internalUUID = java.util.UUID.randomUUID().toString();
       }
      
       @Override
       public boolean equals(Object o) {
       return (o == this || (o instanceof BaseEntity && internalUUID.equals(((BaseEntity)o).internalUUID)));
       }
      
       public String toString() {
       return getClass().getSimpleName() + " Id: " + getId();
       }
      
       @Override
       public int hashCode() {
       return internalUUID.hashCode();
       }
      
      
      }


      a derived class
      @Entity
      @Name("generation")
      @Table(name="generations")
      @SuppressWarnings("unused")
      public class Generation extends BaseEntity {
      
       /**
       *
       */
       private static final long serialVersionUID = 6004105498293729499L;
       private String name;
      
       /**
       *
       */
       public Generation() {
       // TODO Auto-generated constructor stub
       }
       public String getName() {
       return name;
       }
       public void setName(String name) {
       this.name = name;
       }
      }


      and the class with manytoone relation
      @Entity
      @Name("specialrelease")
      @Table(name="specialreleases")
      @SuppressWarnings("unused")
      public class SpecialRelease extends BaseEntity {
      
       /**
       *
       */
       private static final long serialVersionUID = -8813581197028149761L;
       static final int NOTRELEASED = 1;
       static final int NOTPERMITTED = 2;
       static final int ONDEMAND = 3;
       static final int DECLINED = 4;
       static final int EXPIRED = 5;
       static final int NOTVALID = 6;
      
      
       //@NotNull
       private Long requestNumber;
      
      
       private String description;
      
       @ManyToOne
       private Generation generation;
      
      
       /**
       *
       */
       public SpecialRelease() {
       // TODO Auto-generated constructor stub
       status = NOTRELEASED; //Genemhmigungsprozess noch nicht gestartet
       }
      
      
       public Generation getGeneration() {
       return generation;
       }
      
       public void setGeneration(Generation generation) {
       this.generation = generation;
       }
      }
      


      Even I tried to put "@JoinColumn(name="generation_id", referencedColumnName="id")" to the relation the result is the same.


      An idea what I can to to avoid the tinyblob?


      Thanks
      Andreas

        • 1. Re: @ManyToOne results in tinyblob
          hispeedsurfer

          Hi,

          why nobody post a reply?

          This project was build with Seam 1.1.1GA on XAMPP(1.5.4a) MySQL(5.0.24a) database.


          What can I do to create a foreign key build on the referenced primary key instead of the tinyblob? OR Why at all there is created a tinyblob?


          Thanks

          Andreas

          • 2. Re: @ManyToOne results in tinyblob
            andydale

            Hi Andreas,

            from looking at your base entity, i can see that you are mixing the levels of your annotations. In my experience this is a cause of so many problems (and if it causes any exceptions they are not very helpful at all), try moving all you annotations to field level or to method (getter) level. Let me know if this helps.

            Cheers,

            Andy

            • 3. Re: @ManyToOne results in tinyblob
              hispeedsurfer

              Hi Andy,

              thank you for response. I think mixing annotations levels was the cause of my problem. Now it works.

              Thanks


              Bye
              Andi