title: bad value for type long: - Postgresql, Hibernate, Spring
body: <p>I wanna store an entity(a String + an image) in PostgresQL using Spring MVC and Hibernate
  Here is my table. The image is supposed to be the type of oid.</p>
  
  <pre><code>CREATE TABLE document
  (
    name character varying(200),
    id serial NOT NULL,
    content oid,   // that should be the image
    CONSTRAINT document_pkey PRIMARY KEY (id )
  )
  WITH (
    OIDS=FALSE
  );
  </code></pre>
  
  <p>Here is the entity that I want to store.   </p>
  
  <pre><code>    @Entity
      @Table(name = "document")
      public class Document {
  
          @Id
          @GeneratedValue(strategy = GenerationType.IDENTITY)
          @Column(name = "id")
          private Long id;
  
          @Column(name = "name")
          private String name;
  
          @Column(name="content")
              private Blob content;  //this is the image
  //getters- setters
  </code></pre>
  
  <p>You can see the variable "name" is a String, not Long. Still when I submit the form with a value which is not numeric it throws  <code>org.postgresql.util.PSQLException: Bad value for type long : x</code></p>
  
  <p>here is the form: </p>
  
  <pre><code>&lt;form:form method="post" action="save.html" commandName="document" enctype="multipart/form-data"&gt;
      &lt;form:errors path="*" cssClass="error"/&gt;
      &lt;table&gt;
      &lt;tr&gt;
          &lt;td&gt;&lt;form:label path="name"&gt;Name&lt;/form:label&gt;&lt;/td&gt;
          &lt;td&gt;&lt;form:input path="name" /&gt;&lt;/td&gt; 
      &lt;/tr&gt;
  
       &lt;tr&gt;
          &lt;td&gt;&lt;form:label path="content"&gt;Document&lt;/form:label&gt;&lt;/td&gt;
          &lt;td&gt;&lt;input type="file" name="file" id="file"&gt;&lt;/input&gt;&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td colspan="2"&gt;
              &lt;input type="submit" value="Add Document"/&gt;
          &lt;/td&gt;
      &lt;/tr&gt;
  &lt;/table&gt;  
  &lt;/form:form&gt;
  </code></pre>
  
  <p>If I enter a numeric value and submit it, OK. But any non-numeric value triggers the above mentioned exception...I read that it might be caused by that I do not use OID properly but I do not know what should I do to eliminate this exception. Actually I do not understand the name of the excpetion either. It says "bad value for type <strong>long</strong>" . but who wants type long? <strong>the variable "name" is type String!!!!</strong> </p>
  
  <p>Finally, here is the Controller</p>
  
  <pre><code>@RequestMapping(value = "/save", method = RequestMethod.POST)
  public String save(@ModelAttribute("document") Document document, @RequestParam("file") MultipartFile file) {
  
      try {
          Blob blob = Hibernate.createBlob(file.getInputStream());
          document.setContent(blob);
          documentDao.save(document);
      } catch (Exception e) {
          e.printStackTrace();
      }
  
  
      return "redirect:/index.html";
  }
  </code></pre>
  
  <p>Any advice is appriciated.</p>