How can I set Hibernate to fix the "fetch first ? rows only" in Oracle

2018-04-27 10:27:54.086 |-INFO  [http-nio-8080-exec-2] org.hibernate.hql.internal.QueryTranslatorFactoryInitiator [47] -| HHH000397: Using ASTQueryTranslatorFactory
Hibernate: select soaserver0_.id as id1_1_, soaserver0_.presentation as presentation2_1_, soaserver0_.server_name as server_name3_1_, soaserver0_.server_type as server_type4_1_ from io_soa_ser soaserver0_ where soaserver0_.server_name=? order by soaserver0_.id asc fetch first ? rows only
2018-04-27 10:27:54.190 |-WARN  [http-nio-8080-exec-2] org.hibernate.engine.jdbc.spi.SqlExceptionHelper [129] -| SQL Error: 933, SQLState: 42000
2018-04-27 10:27:54.191 |-ERROR [http-nio-8080-exec-2] org.hibernate.engine.jdbc.spi.SqlExceptionHelper [131] -| ORA-00933: SQL 命令未正确结束

2018-04-27 10:27:54.212 |-ERROR [http-nio-8080-exec-2] org.apache.catalina.core.ContainerBase.[Tomcat].[localhost].[/].[dispatcherServlet] [182] -| Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed; nested exception is org.springframework.dao.InvalidDataAccessResourceUsageException: could not extract ResultSet; SQL [n/a]; nested exception is org.hibernate.exception.SQLGrammarException: could not extract ResultSet] with root cause
oracle.jdbc.OracleDatabaseException: ORA-00933: SQL 命令未正确结束

	at oracle.jdbc.driver.T4CTTIoer11.processError(T4CTTIoer11.java:498)
	at oracle.jdbc.driver.T4CTTIoer11.processError(T4CTTIoer11.java:446)

my database is oracle 11g,it seems my database can’t support the sentence that hibernate generated,
please help me, how can i fix this problem?

select the correct Oracle dialect in your .properties or Java set-up: “fetch first” is Oracle 12c syntax only.

1 Like

This syntax is used by Hibernate when you select the Oracle12cDialect. So, you need to use the Oracle10gDialect instead.

1 Like

thank you !!!

thanks ,it’s useful!!!