• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Devaka Cooray
  • Knute Snortum
  • Paul Clapham
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Bear Bibeault
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Ron McLeod
  • Piet Souris
  • Frits Walraven
Bartenders:
  • Ganesh Patekar
  • Tim Holloway
  • salvin francis

Chapter 11 nativequeries example modification for MySQL users  RSS feed

 
Ranch Hand
Posts: 1733
12
  • 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)...

 
Bartender
Posts: 3648
16
Firefox Browser Java Mac OS X
  • 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/
 
It would give a normal human mental abilities to rival mine. To think it is just a tiny ad:
how do I do my own kindle-like thing - without amazon
https://coderanch.com/t/711421/engineering/kindle-amazon
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!