- Developing Middleware in Java EE 8
- Abdalla Mahmoud
- 117字
- 2021-07-23 19:24:37
Table mapping
By default, an entity class is mapped to a table with the same name as the class. However, there are cases when you need to modify this default name for one of the following reasons:
- You need to use a custom name for a neater database design.
- You have to map it to an existing table in a legacy database.
- Your entity name is a SQL reserved keyword, for example, User. You are forced to modify the table name, otherwise you will end up with a runtime error.
The @Table annotation is used to customize the table name as in the following example:
@Entity @Table(name = "movies") public class Movie { ... }