title: Can I use Java 16 record with JPA entity?
body: <p>I am trying to do something similar like below.</p>
  <pre><code>@Entity
  @Table(name=&quot;Sample&quot;)
  public record Sample(Integer id, String name) {
  
      @Id
      @GeneratedValue(strategy = GenerationType.IDENTITY)
      @Column(name=&quot;user_id&quot;)
      private Integer id;
  
      @Column(name=&quot;username&quot;)
      private String name;
  
  }
  </code></pre>
  <p>However, it gives me error &quot;User declared non-static fields id are not permitted in a record&quot;
  and same for name field as well.</p>
  <p>Is there a way to use new java feature &quot;record&quot; with JPA annotation?</p>