2

Using hibernate and mysql 5.5, I am trying to persist String value in TEXT type column of database table.

Tired to set String value in the mentioned column and tried to persist the data.But i am getting following exception. I have generated Entity class using Netbeans 8.0.



Exception:-

FATAL:   JSF1073: javax.faces.FacesException caught during processing of INVOKE_APPLICATION 5 : UIComponent-ClientId=, Message=/addNewCategory.xhtml @30,151 actionListener="#{categoryBean.addCategoryAction}": java.lang.AbstractMethodError: com.mysql.jdbc.ServerPreparedStatement.setCharacterStream(ILjava/io/Reader;J)V
FATAL:   /addNewCategory.xhtml @30,151 actionListener="#{categoryBean.addCategoryAction}": java.lang.AbstractMethodError: com.mysql.jdbc.ServerPreparedStatement.setCharacterStream(ILjava/io/Reader;J)V
javax.faces.FacesException: /addNewCategory.xhtml @30,151 actionListener="#{categoryBean.addCategoryAction}": java.lang.AbstractMethodError: com.mysql.jdbc.ServerPreparedStatement.setCharacterStream(ILjava/io/Reader;J)V
    at com.sun.faces.lifecycle.InvokeApplicationPhase.execute(InvokeApplicationPhase.java:89)

CREATE SQL:-

 CREATE TABLE `oc_category_description` (
      `category_id` int(11) NOT NULL,
      `language_id` int(11) NOT NULL,
      `name` varchar(255) NOT NULL,
      `description` text NOT NULL,
      `meta_description` varchar(255) NOT NULL,
      `meta_keyword` varchar(255) NOT NULL,
      PRIMARY KEY (`category_id`,`language_id`),
      KEY `name` (`name`)
    ) ENGINE=MyISAM DEFAULT CHARSET=utf8;

/*!40101 SET character_set_client = @saved_cs_client */;

EntityClass

@Entity
@Table(name = "oc_category_description")
@XmlRootElement
public class OcCategoryDescription implements Serializable {
    private static final long serialVersionUID = 1L;

    @Basic(optional = false)
    @NotNull
    @Lob
    @Size(min = 1, max = 65535)
    @Column(name = "description")
    private String description;

     public String getDescription() {
    return description;
}

public void setDescription(String description) {
    this.description = description;
}
    //Constructors, setters, getters, equals and hashcode
}

Before raising question I went through following links which were of very little help.



  • I also tried to persist data by removing @Lob, it saving data as "org.hibernate.engine.jdbc.BlobProxy@11e84b60"
  • I tried using @Column(columnDefinition = "TEXT") instead of @Lob, again its giving same result. "org.hibernate.engine.jdbc.BlobProxy@11e84b60"
  • I tried @Type(type="text")instead of @Lob, again its giving same result. "org.hibernate.engine.jdbc.BlobProxy@11e84b60"
8
  • Try removing Lob and Basic annotations from the entity class Commented Aug 2, 2014 at 12:03
  • Tried. Its saving like "org.hibernate.engine.jdbc.BlobProxy@11e84b60". Commented Aug 2, 2014 at 12:06
  • What do you mean by "Its saving like "org.hibernate.engine.jdbc.BlobProxy@11e84b60"? Are you unable to get the entity back from the DB? Commented Aug 2, 2014 at 13:14
  • Yes, On Reading OR SELECT query I am getting "org.hibernate.engine.jdbc.BlobProxy@11e84b60". As am saving String, I would I like to persist the same as String rather than Object. Commented Aug 2, 2014 at 13:21
  • try adding length to the Column annotation Column(length="1000"). How do you retrieve the entity from the DB? Commented Aug 2, 2014 at 13:24

1 Answer 1

4

remove the @Lob and @Size annotations, and use @Type(type="text") instead

WORKED. Thanks @Maurice and @Funtik

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.