• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Chapter 11 nativequeries example modification for MySQL users

 
Himai Minh
Ranch Hand
Posts: 1360
7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, for all MySQL users,
here is the modification I need to make in Employee.java class:


Since MySQL cannot interpret the Oracle specific SQL, I need to use a simple MySQL SQL.
If we use the Oracle SQL for MySQL, the createNamedQuery method will not work and it outputs an error :

Internal Exception: 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 'manager_id = 1 CONNECT BY PRIOR emp_id = manager_id' at line 1
Error Code: 1064
Call: SELECT emp_id, name, salary FROM emp START WITH manager_id = ? CONNECT BY PRIOR emp_id = manager_id
bind => [1 parameter bound]
Query: ReadAllQuery(referenceClass=Employee sql="SELECT emp_id, name, salary FROM emp START WITH manager_id = ? CONNECT BY PRIOR emp_id = manager_id")
at org.eclipse.persistence.internal.jpa.QueryImpl.getDetailedException(QueryImpl.java:378)...
 
K. Tsang
Bartender
Posts: 3583
16
Android Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There's a "with" clause in standard sql however MySQL somewhat doesn't fully support the "with recursive"

http://stackoverflow.com/questions/959804/simulation-of-connect-by-prior-of-oracle-in-sql-server

http://mysqlserverteam.com/with-recursive-and-mysql/
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic