title: JPA, relationship between entity, table and class name
body: <p>I am new to JPA and have a question concerning naming.</p>
  
  <p>I recently had some trouble where I got errors saying something like that there where two entities with the same name in my persistence unit. (I was stupid and did not save the error message)</p>
  
  <p>I am making a web application (Java EE 7, Glassfish) which connects to a remote db using an API (UniProt JAPI). The API classes seem to contain an entity named 'Protein'. The thing is I have a local db which I wanted to write some entity classes for, one of which was called 'Protein' because the table in my local db was called 'protein'. This seemed to cause naming conflicts with the externaly derived 'Protein' entity. The easiest way around this I figured was to rename my local protein entity.</p>
  
  <p>But I'm unsure of how to do this.</p>
  
  <p>My guess was doing something like this:</p>
  
  <pre><code>@Entity(name="MyProtein")
  @Table(name="protein")
  public Class MyProtein { 
  </code></pre>
  
  <p>Because I thaught that the name="MyProtein" in the @Entity annotation will set the entity name. Is this so and does this have to be the same as the class name?</p>
  
  <p>And the name="protein" in the @Table annotation I figured set from which table to map the entity. Is this so and does that mean that an entity can only map to one table in the database? Does the table annotation have any relation to the class name?</p>