title: com.fasterxml.jackson.databind.exc.MismatchedInputException: Can not deserialize instance of object out of START_ARRAY token
body: <p>Getting the MismatchedInputException. Searched a lot of questions here but found JSONMappingException mostly. I don't understand if they are same or different.</p>
  
  <p>Following is the entity:</p>
  
  <pre><code>@Entity
  @Table
  @NamedQueries({
      @NamedQuery(name="User.findAll", query="SELECT u FROM User u"),
      @NamedQuery(name="User.findByEmail", query="SELECT u FROM User u WHERE u.email=:pEmail")
  })
  public class User {
  
  @Id
  @GenericGenerator(name = "idGenerator", strategy = "uuid2")
  @GeneratedValue(generator = "idGenerator")
  private String id;
  private String firstName;
  private String lastName;
  
  @Column(unique=true)
  private String username;
  
  @Column(unique=true)
  private String email;
  private String password;
  private String role;
  }
  </code></pre>
  
  <p>with all the getters and setters in place.</p>
  
  <p>Following is the controller mapping function:</p>
  
  <pre><code>@RequestMapping(method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE, consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
      public User create(@RequestBody User user) {
          return service.create(user);
      }
  </code></pre>
  
  <p>Following is the service:</p>
  
  <pre><code>@Override
      @Transactional
      public User create(User user) {
          User existing = repository.findByEmail(user.getEmail());
          if(existing == null){
              repository.create(user);
          }
          return user;
      }
  </code></pre>
  
  <p>Following is the repository:</p>
  
  <pre><code>@Override
      public User findByEmail(String email) {
          TypedQuery&lt;User&gt; query = em.createNamedQuery("User.findByEmail", User.class);
          query.setParameter("pEmail", email);
          List&lt;User&gt; users = query.getResultList();
          if(users != null &amp;&amp; users.size()==1){
              return users.get(0);
          }
          return null;
      }
  
      @Override
      public User create(User user) {
          em.persist(user);
          return user;
      }
  </code></pre>
  
  <p>Following are the dependencies I used:</p>
  
  <pre><code>&lt;dependency&gt;
              &lt;groupId&gt;com.fasterxml.jackson.core&lt;/groupId&gt;
              &lt;artifactId&gt;jackson-databind&lt;/artifactId&gt;
              &lt;version&gt;2.9.0.pr2&lt;/version&gt;
          &lt;/dependency&gt;
  &lt;dependency&gt;
              &lt;groupId&gt;org.hibernate&lt;/groupId&gt;
              &lt;artifactId&gt;hibernate-entitymanager&lt;/artifactId&gt;
              &lt;version&gt;5.2.9.Final&lt;/version&gt;
          &lt;/dependency&gt;
  
          &lt;dependency&gt;
              &lt;groupId&gt;mysql&lt;/groupId&gt;
              &lt;artifactId&gt;mysql-connector-java&lt;/artifactId&gt;
              &lt;version&gt;6.0.6&lt;/version&gt;
          &lt;/dependency&gt;
  </code></pre>
  
  <p>I am testing through Postman, I have not yet created the front end. Following is the JSON I am sending:</p>
  
  <pre><code>[{
      "firstName": "hgf",
      "lastName": "frew",
      "username": "erf",
      "email": "bgghjk",
      "password": "bgte",
      "role": "trrere"
    }
  ]
  </code></pre>
  
  <p>Lastly below is the console log:</p>
  
  <pre><code>Thu May 11 13:56:43 CDT 2017 WARN: Establishing SSL connection without server's identity verification is not recommended. According to MySQL 5.5.45+, 5.6.26+ and 5.7.6+ requirements SSL connection must be established by default if explicit option isn't set. For compliance with existing applications not using SSL the verifyServerCertificate property is set to 'false'. You need either to explicitly disable SSL by setting useSSL=false, or set useSSL=true and provide truststore for server certificate verification.
  May 11, 2017 1:57:52 PM org.springframework.web.servlet.mvc.support.DefaultHandlerExceptionResolver handleHttpMessageNotReadable
  WARNING: Failed to read HTTP message: org.springframework.http.converter.HttpMessageNotReadableException: Could not read document: Can not deserialize instance of priyanka.movieflix.entity.User out of START_ARRAY token
   at [Source: (PushbackInputStream); line: 1, column: 1]; nested exception is com.fasterxml.jackson.databind.exc.MismatchedInputException: Can not deserialize instance of priyanka.movieflix.entity.User out of START_ARRAY token
   at [Source: (PushbackInputStream); line: 1, column: 1]
  </code></pre>
  
  <p>I am not sure what is causing this exception. When I start the application, table is being created in the database correctly and I am getting the data correctly in GET request as well.</p>