title: JPA - Create Transient primary key
body: <p>I have an entity class mapped to an existing table. This table doesn't have a  primary key. Here is the table : </p>
  
  <pre><code>CREATE TABLE [dbo].[testtable](
  [field1] [varchar](50) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
  [field2] [varchar](50) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
  [field3] [varchar](50) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
  [field4] [varchar](50) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
  [field5] [varchar](50) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
  [field6] [varchar](50) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL
  )
  </code></pre>
  
  <p>I can't do any changes to this table and i am trying to find a way to use jpa by setting a primary key only in memory. I know in theory that if i want to have a column only in memory i can use the transient annotation. I would like to set <code>field1, field2, field3</code> as a <strong>transient</strong> primary key that will point to the existing database fields. Something like a pointer inorder to be able to get the values of the existing fields. Is this posible?? </p>
  
  <p>Here is the entity class:</p>
  
  <pre><code>@Entity
  @Table(name = "testtable")
  public class TestJPA implements Serializable
  {
   @Column(name = "field1")
   private String field1;
  
  @Column(name = "field2")
  private String field2;
  
  @Column(name = "field3")
  private String field3;
  
  @Column(name = "field4")
  private String field4;
  
  @Column(name = "field5")
  private String field5;
  
  @Column(name = "field6")
  private String field6; 
  }
  </code></pre>