An entity name is the query-language name used to reference a persistent entity class in JPA queries. JPA imports entity names automatically, so queries can usually use a class’s short name without its package. section 5.3.1
Choose a name that keeps query references unambiguous:
- Use the default short class name when the persistence unit contains no conflicting entity classes. section 5.3.1
- Assign an explicit JPA entity name when classes with the same short name exist in different packages. section 5.3.1
- Use a fully qualified name in queries when retaining the default entity names is preferable. section 5.3.1
Resolving an entity-name collision
Annotate the conflicting class with @Entity(name = "AuctionItem"), then reference it as select i from AuctionItem i rather than Item. section 5.3.1
package my.other.model;
@javax.persistence.Entity(name = "AuctionItem")
public class Item {
// . . .
}
Shows the annotation that assigns AuctionItem as the query-language name for the Item class. section 5.3.1
