How to escape a column name with JPA and Hibernate?

How to escape a column name?

You have two choices:

  1. Either you provide the @Column annotation to escape the user property:

    @Entity
    public class Services {
    
         @Id
         private Long id;
    
         private String name;
         
         private String host;
    
         private Short port;           
         
         @Column(name="\"user\"")
         private Sring user;
         
         private String password;
     }
    
  2. Or, you can set the hibernate.globally_quoted_identifiers to true:

      <property name="hibernate.globally_quoted_identifiers" value="true"/>
    

For more details, check out this article.