Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » EclipseLink » Exceptions between MySQL and Eclipse using the clause SELECT in a table named condition(Exceptions between MySQL and Eclipse using the clause SELECT in a table named condition)
Exceptions between MySQL and Eclipse using the clause SELECT in a table named condition [message #869590] Thu, 03 May 2012 16:40 Go to next message
Daniel Petersen is currently offline Daniel PetersenFriend
Messages: 1
Registered: May 2012
Junior Member
I'm working with EclipseIndigo, EclipseLink and MySQL I have a table called condition I need to keep it with that name but when I execute this command "Query qb = em.createQuery("SELECT c FROM Condition c ")" in eclipse it throws this exception:

Caused by: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'condition' at line 1
at sun.reflect.GeneratedConstructorAccessor5.newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
at java.lang.reflect.Constructor.newInstance(Unknown Source)
at com.mysql.jdbc.Util.handleNewInstance(Util.java:411)
at com.mysql.jdbc.Util.getInstance(Util.java:386)
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1052)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:4096)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:4028)
at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:2490)
at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2651)
at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2683)
at com.mysql.jdbc.PreparedStatement.executeInternal(PreparedStatement.java:2144)
at com.mysql.jdbc.PreparedStatement.executeQuery(PreparedStatement.java:2310)
at org.eclipse.persistence.internal.databaseaccess.DatabaseAccessor.executeSelect(DatabaseAccessor.java:931)
at org.eclipse.persistence.internal.databaseaccess.DatabaseAccessor.basicExecuteCall(DatabaseAccessor.java:607)

I know that MySQL has a command called condition and that's why this command throws me an exception. The question is: there is a form to keep my table named as condition and I can execute this command "Query qb = em.createQuery("SELECT c FROM Condition c ")"?






Re: Exceptions between MySQL and Eclipse using the clause SELECT in a table named condition [message #870282 is a reply to message #869590] Mon, 07 May 2012 14:56 Go to previous message
James Sutherland is currently offline James SutherlandFriend
Messages: 1939
Registered: July 2009
Location: Ottawa, Canada
Senior Member

Your query is using JPQL, the JPQL will be translated to SQL to be executed on the database.

You must map your Entity classes to a valid table on the database. If your database does not have a table called CONDITION, then you can use the @Table annotation to set the table. You can use " quotes in a table name to use special characters or reserved words, but it is probably best to call your table something that is not reserved.

See,
http://wiki.eclipse.org/EclipseLink/UserGuide/JPA/Basic_JPA_Development/Entities/Creating_and_Configuring_Entities#Configuring_an_Entity.27s_Table


James : Wiki : Book : Blog : Twitter
Previous Topic:How to trigger pre-update computation on parent?
Next Topic:EclipseLink References another Entity When Joining
Goto Forum:
  


Current Time: Wed Apr 24 23:09:50 GMT 2024

Powered by FUDForum. Page generated in 0.03028 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top