liveBook · Manning

Keyword

As explained in Java Persistence with Spring Data and Hibernate epub

An SQL keyword that has a predefined syntactic or semantic meaning and therefore may be invalid as an unquoted identifier.

A keyword has predefined SQL syntax or semantics, so using it as an unquoted table or column identifier can make generated SQL invalid. The entity User therefore maps explicitly to USERS instead of USER. section 5.3.1

Handle keyword collisions through explicit naming or identifier quoting:

  • Override the default table name with @Table(name = "USERS"); this is generally the clearest mapping when the schema can be changed. section 5.3.1
  • Enable Hibernate automatic keyword quoting with hibernate.auto_quote_keyword=true when the configured database dialect identifies the reserved name. section 5.3.1
  • Quote names manually when dialect information is incomplete; Hibernate accepts backticks, while JPA 2.0 standardizes delimited identifiers with double quotes. section 5.3.1
Listing 5.5 Overriding the mapped table name with the @Table annotation
Path: Ch05/mapping/src/main/java/com/manning/javapersistence/ch05/model
 /User.java
 
@Entity
 
@Table(name = "USERS")
 
public class User {
    //  . . .
}

See the concrete @Table mapping that changes the problematic USER table name to USERS. section 5.3.1

How Java Persistence with Spring Data and Hibernate epub covers it

How deep it goes
Explains explicit renaming, automatic quoting, manual quoting, and dialect limitations without detailing SQL parser internals.
Examples
Uses User mapped to USERS and contrasts automatic, backtick, and double-quote identifier handling.
What it assumes
Assumes basic entity-to-table mapping and introduces reserved names through the User-to-USERS example.
What you can do after
Operate/configure JPA mappings that avoid or deliberately quote reserved database names.
How it connects
Connects SQL identifiers with JPA mappings, Hibernate, database dialects, and physical naming strategies.

Also explained in

Compare how 3 books explain keyword →

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.