title: org.postgresql.util.PSQLException: ERROR: operator does not exist: character varying = bytea
body: <p>I am trying to save and Excel file to my database. I get this error:</p>
  <pre class="lang-none prettyprint-override"><code>Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed; nested exception is org.springframework.dao.InvalidDataAccessResourceUsageException: could not extract ResultSet; SQL [n/a]; nested exception is org.hibernate.exception.SQLGrammarException: could not extract ResultSet] with root cause
  
  org.postgresql.util.PSQLException: ERROR: operator does not exist: character varying = bytea
  Hint: No operator matches the given name and argument types. You might need to add explicit type casts. 
  </code></pre>
  <p>This is my controller post method:</p>
  <pre class="lang-java prettyprint-override"><code>@PostMapping
  public ResponseEntity&lt;DocumentCreateResponse&gt; addDocument(@RequestParam(&quot;file&quot;) MultipartFile file) throws IOException {
      Path copyLocation = Paths.get(uploadDir, Objects.requireNonNull(file.getOriginalFilename()));
      Files.copy(file.getInputStream(), copyLocation, StandardCopyOption.REPLACE_EXISTING);
  
      Document savedDocument = documentService.save(copyLocation.toAbsolutePath().toFile());
      if (savedDocument == null){
          return new ResponseEntity&lt;&gt;(new DocumentCreateResponse(null), null, HttpStatus.NOT_ACCEPTABLE);
      }
      return new ResponseEntity&lt;&gt;(new DocumentCreateResponse(savedDocument.getId()), null, HttpStatus.ACCEPTED);
  }
  </code></pre>
  <p>This is document class:</p>
  <pre class="lang-java prettyprint-override"><code>@Entity
  public class DocumentEntity {
      @Id
      @GeneratedValue(strategy = GenerationType.IDENTITY)
      @Column(name =&quot;document_id&quot;)
      private Long id;
  
      @Column(name =&quot;document_file&quot;)
      private File file;
  
  
      public DocumentEntity() {
      }
  
      public DocumentEntity(File file) {
          this.file = file;
      }
  }
  </code></pre>
  <p>And this is my schema creation file (I use Flyway and PostgreSQL)</p>
  <pre class="lang-sql prettyprint-override"><code>create table if not exists document_entity
  (
      document_id bigserial
      constraint document_entity_document_id
      not null primary key,
      document_file varchar not null
  );
  </code></pre>
  <p>Where should I add change, to let my files save properly and not cause this error? I have read articles and seen this error, but I do not see what should I change in my code.</p>
  <pre class="lang-java prettyprint-override"><code>public class DocumentService implements DocumentServicePort {
      private final DocumentRepository documentRepository;
  
      public DocumentService(DocumentRepository documentRepository) {
          this.documentRepository = documentRepository;
      }
  
      @Override
      public Document save(File file) {
          Document document = new Document(file);
          if (document.hasValidExtension(document)) {
              documentRepository.saveDocument(document);
              return document;
          }
          return null;
      }
  }
  </code></pre>