You are working with a legacy database where the table and column names do not follow your standard naming conventions. How can you map these tables without modifying the existing database schema?

Hibernate lets you map entities to a legacy schema without altering the database by using @Table and @Column annotations to explicitly bind Java class and field names to the existing table and column names, regardless of naming convention mismatches.

Key Points

Example

A legacy EMP_MASTER table with a column EMP_NM can be mapped to a clean Employee.name field just by annotating: @Table(name = "EMP_MASTER") on the class and @Column(name = "EMP_NM") on the field, with no schema changes required.

@Entity
@Table(name = "EMP_MASTER")
public class Employee {
    @Id
    @Column(name = "EMP_ID")
    private Long id;

    @Column(name = "EMP_NM")
    private String name;
}

Interview Tip

A concise interview answer is

I map legacy schemas by explicitly declaring @Table and @Column names on the entity to match whatever the existing database uses, or by registering a custom naming strategy if the mismatch is systematic across the whole schema — either way the database itself stays untouched.

Last updated: 16 July 2026

Previous question: You need to add auditing features to track changes in entity data. What Hibernate feature would you use to achieve this?

More Hibernate (Optional) interview questions

All Hibernate (Optional) questions