I am new to JPA and have a question concerning naming.
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)
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.
But I'm unsure of how to do this.
My guess was doing something like this:
@Entity(name="MyProtein")
@Table(name="protein")
public Class MyProtein {
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?
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?