title: JPA entity id - primitive or object type (long or Long)
body: <p><strong>Should the ID of your Entity be <em>long</em> (primitive type) or <em>Long</em> (object type)?</strong></p>
  <ul>
  <li>The ID is the primary key of my table and is never 'null' in the database.</li>
  <li>My co-workers suggest to use an Object Type Long.</li>
  <li>Hibernate Reverse Engineering tool generates a primitive type long for id by default.</li>
  </ul>
  <p><em>What to choose? long or Long?</em></p>
  <pre><code>@Entity
  @Table(name = &quot;COUNTRY&quot;)
  public class CountryEntity implements java.io.Serializable {
      private static final long serialVersionUID = 1L;
  
      @Id
      @Column(name = &quot;ID&quot;)
      private long id;
      @Column(name = &quot;NAME&quot;)
      private String name;
      @Column(name = &quot;CURRENCY&quot;)
      private String currency;
      @Column(name = &quot;PEOPLE&quot;)
      private Long people;
      @Column(name = &quot;SIZE&quot;)
      private Long size;
  
      public CountryEntity() {
      }
  </code></pre>