Jagadeesh Reddy
Jagadeesh Reddy

Reputation: 31

Is there any disadvantages with using createNativeQuery() method of JPA

I have a big query with so many joins and I have tried for JPQL implementation (using createQuery() method)of the query but I am getting so many syntax problems with usage of entities instead of table names. So I have chosen native query implementation as it is executing my query properly on my Oracle DB. Is native query is DB specific? and If we change the DB from Oracle to other DB like MySql or SQLServer, will it work?. Please help me on this, thanks in advance.

Upvotes: 1

Views: 2476

Answers (1)

Robert Moskal
Robert Moskal

Reputation: 22553

Take a look at this page that shows some differences among mysql, Oracle, and mssql:

http://www.bristle.com/Tips/SQL.htm#differences_in_sql_syntax

You can see that there are differences in the way certain kinds of joins are specified.

So yes, you may have problems with complex queries if you choose to use the native query implementation and the switch databases.

Upvotes: 1

Related Questions