title: MultipartFile / blob problem saving in database
body: <p>Hi
  i want to upload an image and store it the database
  i use spring mvc &amp; hibernate</p>
  
  <p>here is the model</p>
  
  <pre><code>import java.sql.Blob;
  import java.util.Date;
  
  import javax.persistence.Column;
  import javax.persistence.Entity;
  import javax.persistence.GeneratedValue;
  import javax.persistence.Id;
  import javax.persistence.Lob;
  import javax.persistence.Table;
  
  @Entity
  @Table(name = "article")
  public class Article {
  
  @Id
  @GeneratedValue
  @Column(name = "article_id")
  private Long articleId;
  
  @Column(name = "article_name", nullable = false, length=20)
  private String articleName;
  
  @Column(name = "article_desc", nullable = false)
  private String articleDesc;
  
  @Column(name = "date_added")
  private Date addedDate;
  
   @Lob
      private Blob content;
  public Article() {      
  }
  
  public Long getArticleId() {
      return articleId;
  }
  
  public void setArticleId(Long articleId) {
      this.articleId = articleId;
  }
  
  public String getArticleName() {
      return articleName;
  }
  
  public void setArticleName(String articleName) {
      this.articleName = articleName;
  }
  
  public String getArticleDesc() {
      return articleDesc;
  }
  
  public void setArticleDesc(String articleDesc) {
      this.articleDesc = articleDesc;
  }
  
  public Date getAddedDate() {
      return addedDate;
  }
  
  public void setAddedDate(Date addedDate) {
      this.addedDate = addedDate;
  }   
  
  public String toString(){
      return this.articleName;
  }
  
  public void setContent(Blob content) {
      this.content = content;
  }
  
  public Blob getContent() {
      return content;
  }
  </code></pre>
  
  <p>}</p>
  
  <p>here is the controller (methode to save the article)</p>
  
  <pre><code>  @RequestMapping(value = "/save", method = RequestMethod.POST)
  public String save(
          @ModelAttribute("article") Article article,
          @RequestParam("file") MultipartFile file) {
  
  
  
      try {
          Blob blob = Hibernate.createBlob(file.getInputStream());
  
  
          article.setContent(blob);
  
      } catch (IOException e) {
          e.printStackTrace();
      }
  
      try {
           articleService.addArticle( article);
      } catch(Exception e) {
          e.printStackTrace();
      }
  
      return "redirect:/articles.html";
  }
  </code></pre>
  
  <p>when i want to save a new article with my JSP form i have this errors</p>
  
  <p>33266 [http-8080-2] DEBUG org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerExceptionResolver  - Resolving exception from handler [net.roseindia.controller.ArticleController@10e8647]: org.springframework.beans.ConversionNotSupportedException: Failed to convert value of type 'java.lang.String' to required type 'org.springframework.web.multipart.MultipartFile'; nested exception is java.lang.IllegalStateException: <strong>Cannot convert</strong> value of type [<strong>java.lang.String</strong>] to required type [<strong>org.springframework.web.multipart.MultipartFile</strong>]: no matching editors or conversion strategy found
  33270 [http-8080-2] DEBUG org.springframework.web.servlet.mvc.annotation.ResponseStatusExceptionResolver  - Resolving exception from handler [net.roseindia.controller.ArticleController@10e8647]: org.springframework.beans.ConversionNotSupportedException: Failed to convert value of type 'java.lang.String' to required type 'org.springframework.web.multipart.MultipartFile'; nested exception is java.lang.IllegalStateException: Cannot convert value of type [java.lang.String] to required type [org.springframework.web.multipart.MultipartFile]: no matching editors or conversion strategy found
  33270 [http-8080-2] DEBUG org.springframework.web.servlet.mvc.support.DefaultHandlerExceptionResolver  - Resolving exception from handler [net.roseindia.controller.ArticleController@10e8647]: org.springframework.beans.ConversionNotSupportedException: Failed to convert value of type 'java.lang.String' to required type 'org.springframework.web.multipart.MultipartFile'; nested exception is java.lang.IllegalStateException: Cannot convert value of type [java.lang.String] to required type [org.springframework.web.multipart.MultipartFile]: no matching editors or conversion strategy found</p>
  
  <p>can any body help me</p>