-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: Hibernate validation problem with MySQL blobs
PostPosted: Fri Oct 17, 2008 6:11 am 
Newbie

Joined: Fri Sep 15, 2006 10:18 am
Posts: 8
Hi,

I'm getting a very strange error after upgrading Hibernate to 3.3.1.GA. I have an entity with a @Lob property which used to validate fine but now throws an error:

Wrong column type in freetextanswer for column answerText. Found: blob, expected: longblob

However the underlying table column is defined as blob. If I yield to the error message and try setting the table type to longblob then I get the reverse error message!

Wrong column type in freetextanswer for column answerText. Found: longblob, expected: blob

I also tried setting the columnDefinition="blob" parameter to the @Log annotation but this had no effect. Finally, I tried setting the length property to a large value to try and coerce Hibernates choice of blob type but again, no change.

Any ideas on what is wrong?

Cheers,

Chris.


Hibernate version:
3.3.1.GA

Mapping documents:
Code:
/**
* Freetextanswer generated by hbm2java
*/
@Entity
@Table(name = "freetextanswer")
public class FreetextAnswerEntity implements java.io.Serializable {

   private static final long serialVersionUID = 1L;
   
   private Integer freetextAnswerId;
   private FreetextQuestionEntity freetextQuestion;
   private RespondentEntity respondent;
   private byte[] answerText;

   public FreetextAnswerEntity() {
   }

   public FreetextAnswerEntity(FreetextQuestionEntity freetextQuestion,
            RespondentEntity respondent) {
      this.freetextQuestion = freetextQuestion;
      this.respondent = respondent;
   }

   public FreetextAnswerEntity(FreetextQuestionEntity freetextQuestion,
            RespondentEntity respondent, byte[] answerText) {
      this.freetextQuestion = freetextQuestion;
      this.respondent = respondent;
      this.answerText = answerText;
   }

   @Id
   @GeneratedValue(strategy = IDENTITY)
   @Column(name = "freetextAnswerId", unique = true, nullable = false)
   public Integer getFreetextAnswerId() {
      return this.freetextAnswerId;
   }

   public void setFreetextAnswerId(Integer freetextAnswerId) {
      this.freetextAnswerId = freetextAnswerId;
   }

   @ManyToOne(cascade = {}, fetch = FetchType.LAZY)
   @JoinColumn(name = "freetextQuestionId", unique = false, nullable = false, insertable = true, updatable = true)
   public FreetextQuestionEntity getFreetextQuestion() {
      return this.freetextQuestion;
   }

   public void setFreetextQuestion(FreetextQuestionEntity freetextQuestion) {
      this.freetextQuestion = freetextQuestion;
   }

   @ManyToOne(cascade = {}, fetch = FetchType.LAZY)
   @JoinColumn(name = "respondentId", unique = false, nullable = false, insertable = true, updatable = true)
   public RespondentEntity getRespondent() {
      return this.respondent;
   }

   public void setRespondent(RespondentEntity respondent) {
      this.respondent = respondent;
   }

   @Lob
   @Column(name = "answerText")
   public byte[] getAnswerText() {
      return this.answerText;
   }

   public void setAnswerText(byte[] answerText) {
      this.answerText = answerText;
   }

}

DDL
Code:
CREATE TABLE `freetextanswer` (
  `freetextAnswerId` int(10) NOT NULL auto_increment,
  `freetextQuestionId` int(10) NOT NULL,
  `respondentId` int(10) NOT NULL,
  `answerText` blob
) ENGINE=InnoDB DEFAULT CHARSET=latin1;


Full stack trace of any exception that occurs:
Code:
Caused by: org.hibernate.HibernateException: Wrong column type in ixia_cgl.freetextanswer for column answerText. Found: blob, expected: longblob
   at org.hibernate.mapping.Table.validateColumns(Table.java:284)
   at org.hibernate.cfg.Configuration.validateSchema(Configuration.java:1116)
   at org.hibernate.tool.hbm2ddl.SchemaValidator.validate(SchemaValidator.java:139)
   at org.hibernate.impl.SessionFactoryImpl.<init>(SessionFactoryImpl.java:349)
   at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1327)
   at org.hibernate.cfg.AnnotationConfiguration.buildSessionFactory(AnnotationConfiguration.java:867)
   at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:669)
   ... 145 more


Name and version of the database you are using:
Code:
10:41:22,867 INFO  [SettingsFactory] RDBMS: MySQL, version: 5.0.51a-community-nt
10:41:22,867 INFO  [SettingsFactory] JDBC driver: MySQL-AB JDBC Driver, version: mysql-connector-java-5.1.6 ( Revision: ${svn.Revision} )
10:41:22,883 INFO  [Dialect] Using dialect: org.hibernate.dialect.MySQL5InnoDBDialect


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.