title: Spring Boot JPA Mapping an array from a returned query value
body: <p>I need to run a query on a table which returns an array based of the values of a column.</p>
  
  <p>The table looks like this:
  <a href="https://i.stack.imgur.com/eqdDC.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/eqdDC.png" alt="enter image description here"></a></p>
  
  <p>The result from the query looks like this:<a href="https://i.stack.imgur.com/9vYSt.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/9vYSt.png" alt="enter image description here"></a></p>
  
  <p>I've tried to map that array to a model class but it always throws <code>No Dialect mapping for JDBC type: 2003</code> Are there any ways to do this?</p>
  
  <p>My classes:</p>
  
  <pre><code>@Entity
  public class Option {
  
      @Id
      @GeneratedValue(strategy = GenerationType.AUTO)
      private int id;
      private int option;
  
      @ManyToOne
      @JoinColumn(name = "user_id")
      User user;
  
      public int getId() {
          return id;
      }
  
      public void setId(int id) {
          this.id = id;
      }
  
      public int getOption() {
          return option;
      }
  
      public void setOption(int option) {
          this.option = option;
      }
  
      public User getUser() {
          return user;
      }
  
      public void setUser(User user) {
          this.user = user;
      }
  
  
  
  }
  </code></pre>
  
  <p>Repository:</p>
  
  <pre><code>@Repository
  public interface OptionRepo extends JpaRepository&lt;Option, Integer&gt;{
      @Query(value = "SELECT user_id, array_agg(option) FROM option GROUP BY user_id ORDER BY user_id", nativeQuery = true)
      public List&lt;OptionQuery&gt; getOptions(); 
  
  }
  </code></pre>
  
  <p>OptionQuery Class:</p>
  
  <pre><code>public class OptionQuery {
  
      private int user_id;
      private int[] array_agg;
  
      public int getUser_id() {
          return user_id;
      }
  
      public void setUser_id(int user_id) {
          this.user_id = user_id;
      }
  
      public int[] getArray_agg() {
          return array_agg;
      }
  
      public void setArray_agg(int[] array_agg) {
          this.array_agg = array_agg;
      }
  }
  </code></pre>
  
  <p>How should i deal with this cause i'm kind of stuck at this point:(</p>