What's the difference between the name argument in @Entity and @Table when using JPA?

后端 未结 3 1713
Happy的楠姐
Happy的楠姐 2020-12-24 01:55

I\'m using JPA2 and both @Entity and @Table have a name attribute, e. g.:

@Entity(name=\"Foo\")
@Table (name=\"Bar\")
         


        
3条回答
  •  无人及你
    2020-12-24 02:35

    The name in @Entity is for JPA-QL queries, it defaults to the class name without package (or unqualified class name, in Java lingo), if you change it you have to make sure you use this name when building queries.

    The name in @Table is the table name where this entity is saved.

提交回复
热议问题