liveBook · Manning

Identifier quoting

As explained in Java Persistence with Spring Data and Hibernate epub

Identifier quoting is the technique of delimiting database identifiers so reserved words, unusual characters, whitespace, or letter case can be preserved.

Identifier quoting delimits table and column names so reserved words, unusual characters, whitespace, or letter case survive ORM-to-SQL mapping. section 5.3.1

Hibernate and Spring Data JPA with Hibernate support several quoting strategies:

  • Enable automatic quoting with hibernate.auto_quote_keyword=true; the configured dialect identifies reserved keywords and selects the database’s native quote character. section 5.3.1
  • Quote a mapped name with backticks for Hibernate-specific behavior, or escape double quotes for JPA-standard delimited identifiers. section 5.3.1
  • Add <delimited-identifiers/> under persistence-unit-defaults in orm.xml to enforce quoting for every SQL identifier. section 5.3.1

Quoting a reserved table name

Map a table named USER with @Table(name = "`USER`") for Hibernate-specific quoting, or @Table(name = "\"USER\"") for JPA-compliant delimited naming. Hibernate converts the mapping to the dialect’s native SQL syntax. section 5.3.1

How Java Persistence with Spring Data and Hibernate epub covers it

How deep it goes
Explains automatic, manual, dialect-specific, JPA-standard, and global quoting, but stops short of broader SQL naming design.
Examples
Demonstrates @Table mappings for USER with Hibernate backticks and JPA double quotes, plus orm.xml global configuration.
What it assumes
Assumes familiarity with JPA mappings and persistence-unit configuration while defining quoting from its database naming problem.
What you can do after
Operate/configure Hibernate or Spring Data JPA to quote selected identifiers automatically, manually, or globally.
How it connects
Connects identifier quoting with reserved keywords, database dialects, JPA mappings, Hibernate, and physical naming strategies.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Java Persistence with Spring Data and Hibernate epub. The section links point to the parts of the book it draws on.