Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>With Hibernate as JPA 1.0 provider, you can escape a reserved keyword by enclosing it within backticks:</p> <pre><code>@Column(name="`open`") </code></pre> <p>This is the syntax inherited from Hiberate Core:</p> <blockquote> <h3><a href="http://docs.jboss.org/hibernate/stable/core/manual/en-US/html/mapping.html#mapping-quotedidentifiers" rel="noreferrer">5.4. SQL quoted identifiers</a></h3> <p>You can force Hibernate to quote an identifier in the generated SQL by enclosing the table or column name in backticks in the mapping document. Hibernate will use the correct quotation style for the SQL Dialect. This is usually double quotes, but the SQL Server uses brackets and MySQL uses backticks.</p> <pre><code>&lt;class name="LineItem" table="`Line Item`"&gt; &lt;id name="id" column="`Item Id`"/&gt;&lt;generator class="assigned"/&gt;&lt;/id&gt; &lt;property name="itemNumber" column="`Item #`"/&gt; ... &lt;/class&gt; </code></pre> </blockquote> <p>In JPA 2.0, the syntax is standardized and becomes:</p> <pre><code>@Column(name="\"open\"") </code></pre> <h3>References</h3> <ul> <li>Hibernate reference guide <ul> <li><a href="http://docs.jboss.org/hibernate/stable/core/manual/en-US/html/mapping.html#mapping-quotedidentifiers" rel="noreferrer">5.4. SQL quoted identifiers</a></li> </ul></li> <li>JPA 2.0 specification <ul> <li>2.13 Naming of Database Objects</li> </ul></li> </ul> <h3>Related questions</h3> <ul> <li><a href="https://stackoverflow.com/questions/3217479/hibernate-mysql-and-table-named-repeat-strange-behaviour">Hibernate, MySQL and table named “Repeat” - strange behaviour</a> </li> <li><a href="https://stackoverflow.com/questions/3364835/automatic-reserved-word-escaping-for-hibernate-tables-and-columns">Automatic reserved word escaping for Hibernate tables and columns</a></li> </ul>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload