0
問題這是我的DAO類我的方法和它的作品與setMaxResults()在MSSQL
@Override
@SuppressWarnings("unchecked")
public List<Arquivo> listar() {
try {
Query query = entityManager.createQuery("from Arquivo");
return query.getResultList();
} catch (Exception ex) {
ex.printStackTrace();
return null;
}
}
,但是當我把setMaxResults()我得到這個SQL巨大的錯誤,說一些關於在缺少參數聲明
21:44:00,935 WARN [org.hibernate.engine.jdbc.spi.SqlExceptionHelper] (default task-13) SQL Error: 102, SQLState: S0001
21:44:00,935 ERROR [org.hibernate.engine.jdbc.spi.SqlExceptionHelper] (default task-13) Incorrect syntax near '@P0'.
21:44:00,938 ERROR [stderr] (default task-13) javax.persistence.PersistenceException: org.hibernate.exception.SQLGrammarException: could not extract ResultSet
21:44:00,938 ERROR [stderr] (default task-13) at org.hibernate.jpa.spi.AbstractEntityManagerImpl.convert(AbstractEntityManagerImpl.java:1692)
21:44:00,938 ERROR [stderr] (default task-13) at org.hibernate.jpa.spi.AbstractEntityManagerImpl.convert(AbstractEntityManagerImpl.java:1602)
21:44:00,938 ERROR [stderr] (default task-13) at org.hibernate.jpa.internal.QueryImpl.getResultList(QueryImpl.java:492)
21:44:00,938 ERROR [stderr] (default task-13) at org.jboss.as.jpa.container.QueryNonTxInvocationDetacher.getResultList(QueryNonTxInvocationDetacher.java:58)
21:44:00,938 ERROR [stderr] (default task-13) at dao.ArquivoDao.listar(ArquivoDao.java:41)
21:44:00,938 ERROR [stderr] (default task-13) at service.ArquivoService.listar100(ArquivoService.java:19)
21:44:00,939 ERROR [stderr] (default task-13) at facade.ArquivoFacade.listaArquivos(ArquivoFacade.java:27)
21:44:00,939 ERROR [stderr] (default task-13) at facade.ArquivoFacade$Proxy$_$$_WeldClientProxy.listaArquivos(Unknown Source)
21:44:00,939 ERROR [stderr] (default task-13) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
21:44:00,939 ERROR [stderr] (default task-13) at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
21:44:00,939 ERROR [stderr] (default task-13) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
21:44:00,939 ERROR [stderr] (default task-13) at java.lang.reflect.Method.invoke(Unknown Source)
21:44:00,939 ERROR [stderr] (default task-13) at org.jboss.resteasy.core.MethodInjectorImpl.invoke(MethodInjectorImpl.java:139)
21:44:00,940 ERROR [stderr] (default task-13) at org.jboss.resteasy.core.ResourceMethodInvoker.invokeOnTarget(ResourceMethodInvoker.java:295)
21:44:00,940 ERROR [stderr] (default task-13) at org.jboss.resteasy.core.ResourceMethodInvoker.invoke(ResourceMethodInvoker.java:249)
21:44:00,940 ERROR [stderr] (default task-13) at org.jboss.resteasy.core.ResourceMethodInvoker.invoke(ResourceMethodInvoker.java:236)
21:44:00,940 ERROR [stderr] (default task-13) at org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:402)
21:44:00,940 ERROR [stderr] (default task-13) at org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:209)
21:44:00,940 ERROR [stderr] (default task-13) at org.jboss.resteasy.plugins.server.servlet.ServletContainerDispatcher.service(ServletContainerDispatcher.java:221)
21:44:00,940 ERROR [stderr] (default task-13) at org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher.service(HttpServletDispatcher.java:56)
21:44:00,940 ERROR [stderr] (default task-13) at org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher.service(HttpServletDispatcher.java:51)
21:44:00,941 ERROR [stderr] (default task-13) at javax.servlet.http.HttpServlet.service(HttpServlet.java:790)
21:44:00,941 ERROR [stderr] (default task-13) at io.undertow.servlet.handlers.ServletHandler.handleRequest(ServletHandler.java:85)
21:44:00,941 ERROR [stderr] (default task-13) at io.undertow.servlet.handlers.security.ServletSecurityRoleHandler.handleRequest(ServletSecurityRoleHandler.java:62)
21:44:00,941 ERROR [stderr] (default task-13) at io.undertow.servlet.handlers.ServletDispatchingHandler.handleRequest(ServletDispatchingHandler.java:36)
21:44:00,941 ERROR [stderr] (default task-13) at org.wildfly.extension.undertow.security.SecurityContextAssociationHandler.handleRequest(SecurityContextAssociationHandler.java:78)
21:44:00,941 ERROR [stderr] (default task-13) at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
21:44:00,941 ERROR [stderr] (default task-13) at io.undertow.servlet.handlers.security.SSLInformationAssociationHandler.handleRequest(SSLInformationAssociationHandler.java:131)
21:44:00,942 ERROR [stderr] (default task-13) at io.undertow.servlet.handlers.security.ServletAuthenticationCallHandler.handleRequest(ServletAuthenticationCallHandler.java:57)
21:44:00,942 ERROR [stderr] (default task-13) at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
21:44:00,942 ERROR [stderr] (default task-13) at io.undertow.security.handlers.AbstractConfidentialityHandler.handleRequest(AbstractConfidentialityHandler.java:46)
21:44:00,942 ERROR [stderr] (default task-13) at io.undertow.servlet.handlers.security.ServletConfidentialityConstraintHandler.handleRequest(ServletConfidentialityConstraintHandler.java:64)
21:44:00,942 ERROR [stderr] (default task-13) at io.undertow.security.handlers.AuthenticationMechanismsHandler.handleRequest(AuthenticationMechanismsHandler.java:60)
21:44:00,942 ERROR [stderr] (default task-13) at io.undertow.servlet.handlers.security.CachedAuthenticatedSessionHandler.handleRequest(CachedAuthenticatedSessionHandler.java:77)
21:44:00,942 ERROR [stderr] (default task-13) at io.undertow.security.handlers.NotificationReceiverHandler.handleRequest(NotificationReceiverHandler.java:50)
21:44:00,943 ERROR [stderr] (default task-13) at io.undertow.security.handlers.AbstractSecurityContextAssociationHandler.handleRequest(AbstractSecurityContextAssociationHandler.java:43)
21:44:00,943 ERROR [stderr] (default task-13) at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
21:44:00,943 ERROR [stderr] (default task-13) at org.wildfly.extension.undertow.security.jacc.JACCContextIdHandler.handleRequest(JACCContextIdHandler.java:61)
21:44:00,943 ERROR [stderr] (default task-13) at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
21:44:00,943 ERROR [stderr] (default task-13) at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
21:44:00,943 ERROR [stderr] (default task-13) at io.undertow.servlet.handlers.ServletInitialHandler.handleFirstRequest(ServletInitialHandler.java:292)
21:44:00,943 ERROR [stderr] (default task-13) at io.undertow.servlet.handlers.ServletInitialHandler.access$100(ServletInitialHandler.java:81)
21:44:00,944 ERROR [stderr] (default task-13) at io.undertow.servlet.handlers.ServletInitialHandler$2.call(ServletInitialHandler.java:138)
21:44:00,944 ERROR [stderr] (default task-13) at io.undertow.servlet.handlers.ServletInitialHandler$2.call(ServletInitialHandler.java:135)
21:44:00,944 ERROR [stderr] (default task-13) at io.undertow.servlet.core.ServletRequestContextThreadSetupAction$1.call(ServletRequestContextThreadSetupAction.java:48)
21:44:00,944 ERROR [stderr] (default task-13) at io.undertow.servlet.core.ContextClassLoaderSetupAction$1.call(ContextClassLoaderSetupAction.java:43)
21:44:00,944 ERROR [stderr] (default task-13) at io.undertow.servlet.api.LegacyThreadSetupActionWrapper$1.call(LegacyThreadSetupActionWrapper.java:44)
21:44:00,944 ERROR [stderr] (default task-13) at io.undertow.servlet.api.LegacyThreadSetupActionWrapper$1.call(LegacyThreadSetupActionWrapper.java:44)
21:44:00,944 ERROR [stderr] (default task-13) at io.undertow.servlet.api.LegacyThreadSetupActionWrapper$1.call(LegacyThreadSetupActionWrapper.java:44)
21:44:00,944 ERROR [stderr] (default task-13) at io.undertow.servlet.api.LegacyThreadSetupActionWrapper$1.call(LegacyThreadSetupActionWrapper.java:44)
21:44:00,945 ERROR [stderr] (default task-13) at io.undertow.servlet.api.LegacyThreadSetupActionWrapper$1.call(LegacyThreadSetupActionWrapper.java:44)
21:44:00,945 ERROR [stderr] (default task-13) at io.undertow.servlet.api.LegacyThreadSetupActionWrapper$1.call(LegacyThreadSetupActionWrapper.java:44)
21:44:00,945 ERROR [stderr] (default task-13) at io.undertow.servlet.handlers.ServletInitialHandler.dispatchRequest(ServletInitialHandler.java:272)
21:44:00,945 ERROR [stderr] (default task-13) at io.undertow.servlet.handlers.ServletInitialHandler.access$000(ServletInitialHandler.java:81)
21:44:00,945 ERROR [stderr] (default task-13) at io.undertow.servlet.handlers.ServletInitialHandler$1.handleRequest(ServletInitialHandler.java:104)
21:44:00,945 ERROR [stderr] (default task-13) at io.undertow.server.Connectors.executeRootHandler(Connectors.java:202)
21:44:00,945 ERROR [stderr] (default task-13) at io.undertow.server.HttpServerExchange$1.run(HttpServerExchange.java:805)
21:44:00,946 ERROR [stderr] (default task-13) at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
21:44:00,946 ERROR [stderr] (default task-13) at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
21:44:00,946 ERROR [stderr] (default task-13) at java.lang.Thread.run(Unknown Source)
21:44:00,946 ERROR [stderr] (default task-13) Caused by: org.hibernate.exception.SQLGrammarException: could not extract ResultSet
21:44:00,946 ERROR [stderr] (default task-13) at org.hibernate.exception.internal.SQLStateConversionDelegate.convert(SQLStateConversionDelegate.java:106)
21:44:00,947 ERROR [stderr] (default task-13) at org.hibernate.exception.internal.StandardSQLExceptionConverter.convert(StandardSQLExceptionConverter.java:42)
21:44:00,947 ERROR [stderr] (default task-13) at org.hibernate.engine.jdbc.spi.SqlExceptionHelper.convert(SqlExceptionHelper.java:109)
21:44:00,947 ERROR [stderr] (default task-13) at org.hibernate.engine.jdbc.spi.SqlExceptionHelper.convert(SqlExceptionHelper.java:95)
21:44:00,947 ERROR [stderr] (default task-13) at org.hibernate.engine.jdbc.internal.ResultSetReturnImpl.extract(ResultSetReturnImpl.java:79)
21:44:00,947 ERROR [stderr] (default task-13) at org.hibernate.loader.Loader.getResultSet(Loader.java:2117)
21:44:00,947 ERROR [stderr] (default task-13) at org.hibernate.loader.Loader.executeQueryStatement(Loader.java:1900)
21:44:00,947 ERROR [stderr] (default task-13) at org.hibernate.loader.Loader.executeQueryStatement(Loader.java:1876)
21:44:00,947 ERROR [stderr] (default task-13) at org.hibernate.loader.Loader.doQuery(Loader.java:919)
21:44:00,948 ERROR [stderr] (default task-13) at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:336)
21:44:00,948 ERROR [stderr] (default task-13) at org.hibernate.loader.Loader.doList(Loader.java:2617)
21:44:00,948 ERROR [stderr] (default task-13) at org.hibernate.loader.Loader.doList(Loader.java:2600)
21:44:00,948 ERROR [stderr] (default task-13) at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2429)
21:44:00,948 ERROR [stderr] (default task-13) at org.hibernate.loader.Loader.list(Loader.java:2424)
21:44:00,948 ERROR [stderr] (default task-13) at org.hibernate.loader.hql.QueryLoader.list(QueryLoader.java:501)
這是一個錯誤知道錯誤或我搞砸了嗎?
更新 我perssitence
<?xml version="1.0" encoding="UTF-8"?>
<persistence version="2.1" xmlns="http://xmlns.jcp.org/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/persistence http://xmlns.jcp.org/xml/ns/persistence/persistence_2_1.xsd">
<persistence-unit name="monitoriabnbpu">
<provider>org.hibernate.ejb.HibernatePersistence</provider>
<jta-data-source>java:jboss/datasources/MSSQLARQCOM</jta-data-source>
<properties>
<property name="hibernate.dialect" value="org.hibernate.dialect.SQLServerDialect"/>
<property name="hibernate.hbm2ddl.auto" value="update"/>
<property name="hibernate.show_sql" value="false"/>
<property name="hibernate.format_sql" value="false"/>
</properties>
</persistence-unit>
</persistence>
我使用的是SQL Server 2008和我的數據源是在wildfly 10.1
假設您爲'setMaxResults(int maxResults)'添加一個金額' 設置要檢索的最大行數。 –
我知道@RajithPemabandu這太奇怪了,我只放100 – Krismorte
添加您的persistence.xml和jdbc驅動程序版本 – jklee