A delimited identifier encloses an SQL table or column name in database-specific identifier delimiters. It permits reserved names such as USER and can preserve otherwise significant naming behavior. section 5.3.1
Hibernate and JPA provide several quoting strategies:
- Enable hibernate.auto_quote_keyword=true so the configured dialect automatically quotes recognized reserved keywords. section 5.3.1
- Use Hibernate backticks in a mapping, such as @Table(name = "`USER`"). section 5.3.1
- Use escaped double quotes, such as @Table(name = "\"USER\"")", for the JPA 2.0 delimited-identifier form. section 5.3.1
- Declare <delimited-identifiers/> in orm.xml to enforce quoting for every SQL identifier. section 5.3.1
Mapping a reserved table name
@Entity @Table(name = "\"USER\"") public class User { // ... } Hibernate translates the mapping to the dialect's native delimiter, producing [USER] for Microsoft SQL Server, `USER` for MySQL, or "USER" for H2. section 5.3.1
@Table(name = "\"USER\"")
Inspect the JPA-compliant mapping syntax for quoting a reserved table name. section 5.3.1
