Re: Exceptions of mysql jdbc with table named condition in java
Posted by: Todd Farmer
Date: May 03, 2012 11:15AM

Hi Daniel,

Try this:

Query qb = em.createQuery("SELECT c FROM `Condition` c ")"

The relevant manual references are listed below:

http://dev.mysql.com/doc/refman/5.5/en/reserved-words.html
http://dev.mysql.com/doc/refman/5.5/en/identifiers.html

The identifier quote character is the backtick (“`”):

mysql> SELECT * FROM `select` WHERE `select`.id > 100;

If the ANSI_QUOTES SQL mode is enabled, it is also permissible to quote identifiers within double quotation marks:

mysql> CREATE TABLE "test" (col INT);
ERROR 1064: You have an error in your SQL syntax...
mysql> SET sql_mode='ANSI_QUOTES';
mysql> CREATE TABLE "test" (col INT);
Query OK, 0 rows affected (0.00 sec)

The ANSI_QUOTES mode causes the server to interpret double-quoted strings as identifiers. Consequently, when this mode is enabled, string literals must be enclosed within single quotation marks. They cannot be enclosed within double quotation marks. The server SQL mode is controlled as described in Section 5.1.6, “Server SQL Modes”.

Hope that helps!

--
Todd Farmer
MySQL @ Oracle
http://www.oracle.com/mysql/

Options: ReplyQuote


Subject
Written By
Posted
Re: Exceptions of mysql jdbc with table named condition in java
May 03, 2012 11:15AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.