简体   繁体   English

JPA查询语法问题还是什么? JPA SELECT NEW语法问题?

[英]JPA query syntax issue or what ?! JPA SELECT NEW syntax issue?

I have a TextHistory entity object and then I have this JPA query. 我有一个TextHistory实体对象,然后有这个JPA查询。

SELECT NEW TextHistory(i.id, i.fileName, i.importDate) FROM TextHistory i")

In the entity object I have provided the corresponding constructor. 在实体对象中,我提供了相应的构造函数。

I am trying to deploy my app under Payara 4.1 but I get this exception at deploy time: 我正在尝试在Payara 4.1下部署我的应用程序,但在部署时遇到此异常:

Error occurred during deployment: Exception while deploying the app    
[app-name] : Exception [EclipseLink-28019] 
(Eclipse Persistence Services - 2.6.2.qualifier):   
org.eclipse.persistence.exceptions.EntityManagerSetupException 
Exception Description:  
Deployment of PersistenceUnit [unit-name] failed. 
Close all factories for this PersistenceUnit. Internal Exception:  
Exception [EclipseLink-0] (Eclipse Persistence Services - 2.6.2.qualifier): 
org.eclipse.persistence.exceptions.JPQLException   
Exception Description: Internal problem encountered while compiling 
[SELECT NEW TextHistory(i.id, i.fileName, i.importDate) FROM TextHistory i].   
Internal Exception: java.lang.NullPointerException. 
Please see server.log for more details.

I think my JPA query syntax is correct. 我认为我的JPA查询语法是正确的。 I've been struggling with this for several hours now. 我已经为此奋斗了几个小时。

What is the problem? 问题是什么? Any ideas? 有任何想法吗?

In the server.log I am seeing this exception. 在server.log中,我看到此异常。

        [2017-08-15T21:32:24.546+0200] [Payara 4.1] [INFO] [] [org.eclipse.persistence.session./file:/D:/Work/TSSB_DEV_ENV_MASTER/domains/tssb_ms_gf4_domain_srm_tsbg/applications/tsbgam-application-2017-T3-SNAPSHOT/tsbgam-business_jar/_tsms_tsbg.connection] [tid: _ThreadID=154 _ThreadName=admin-listener(7)] [timeMillis: 1502825544546] [levelValue: 800] [[
          /file:/D:/Work/TSSB_DEV_ENV_MASTER/domains/tssb_ms_gf4_domain_srm_tsbg/applications/tsbgam-application-2017-T3-SNAPSHOT/tsbgam-business_jar/_tsms_tsbg logout successful]]

        [2017-08-15T21:32:24.546+0200] [Payara 4.1] [SEVERE] [] [org.eclipse.persistence.session./file:/D:/Work/TSSB_DEV_ENV_MASTER/domains/tssb_ms_gf4_domain_srm_tsbg/applications/tsbgam-application-2017-T3-SNAPSHOT/tsbgam-business_jar/_tsms_tsbg.ejb] [tid: _ThreadID=154 _ThreadName=admin-listener(7)] [timeMillis: 1502825544546] [levelValue: 1000] [[

        Local Exception Stack: 
        Exception [EclipseLink-0] (Eclipse Persistence Services - 2.6.2.qualifier): org.eclipse.persistence.exceptions.JPQLException
        Exception Description: Internal problem encountered while compiling [SELECT NEW TextHistory(i.id, i.fileName, i.importDate) FROM TextHistory i].
        Internal Exception: java.lang.NullPointerException
            at org.eclipse.persistence.internal.jpa.jpql.HermesParser.buildUnexpectedException(HermesParser.java:207)
            at org.eclipse.persistence.internal.jpa.jpql.HermesParser.populateQueryImp(HermesParser.java:296)
            at org.eclipse.persistence.internal.jpa.jpql.HermesParser.buildQuery(HermesParser.java:163)
            at org.eclipse.persistence.internal.jpa.EJBQueryImpl.buildEJBQLDatabaseQuery(EJBQueryImpl.java:142)
            at org.eclipse.persistence.internal.jpa.JPAQuery.processJPQLQuery(JPAQuery.java:223)
            at org.eclipse.persistence.internal.jpa.JPAQuery.prepare(JPAQuery.java:184)
            at org.eclipse.persistence.queries.DatabaseQuery.prepareInternal(DatabaseQuery.java:624)
            at org.eclipse.persistence.internal.sessions.AbstractSession.processJPAQuery(AbstractSession.java:4366)
            at org.eclipse.persistence.internal.sessions.AbstractSession.processJPAQueries(AbstractSession.java:4326)
            at org.eclipse.persistence.internal.sessions.DatabaseSessionImpl.initializeDescriptors(DatabaseSessionImpl.java:598)
            at org.eclipse.persistence.internal.sessions.DatabaseSessionImpl.postConnectDatasource(DatabaseSessionImpl.java:818)
            at org.eclipse.persistence.internal.sessions.DatabaseSessionImpl.loginAndDetectDatasource(DatabaseSessionImpl.java:762)
            at org.eclipse.persistence.internal.jpa.EntityManagerFactoryProvider.login(EntityManagerFactoryProvider.java:265)
            at org.eclipse.persistence.internal.jpa.EntityManagerSetupImpl.deploy(EntityManagerSetupImpl.java:731)
            at org.eclipse.persistence.internal.jpa.EntityManagerFactoryDelegate.getAbstractSession(EntityManagerFactoryDelegate.java:205)
            at org.eclipse.persistence.internal.jpa.EntityManagerFactoryDelegate.createEntityManagerImpl(EntityManagerFactoryDelegate.java:305)
            at org.eclipse.persistence.internal.jpa.EntityManagerFactoryImpl.createEntityManagerImpl(EntityManagerFactoryImpl.java:337)
            at org.eclipse.persistence.internal.jpa.EntityManagerFactoryImpl.createEntityManager(EntityManagerFactoryImpl.java:303)
            at org.glassfish.persistence.jpa.JPADeployer$2.visitPUD(JPADeployer.java:451)
            at org.glassfish.persistence.jpa.JPADeployer$PersistenceUnitDescriptorIterator.iteratePUDs(JPADeployer.java:510)
            at org.glassfish.persistence.jpa.JPADeployer.iterateInitializedPUsAtApplicationPrepare(JPADeployer.java:492)
            at org.glassfish.persistence.jpa.JPADeployer.event(JPADeployer.java:395)
            at org.glassfish.kernel.event.EventsImpl.send(EventsImpl.java:131)
            at com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:487)
            at com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:219)
            at org.glassfish.deployment.admin.DeployCommand.execute(DeployCommand.java:487)
            at com.sun.enterprise.v3.admin.CommandRunnerImpl$2$1.run(CommandRunnerImpl.java:539)
            at com.sun.enterprise.v3.admin.CommandRunnerImpl$2$1.run(CommandRunnerImpl.java:535)
            at java.security.AccessController.doPrivileged(Native Method)
            at javax.security.auth.Subject.doAs(Subject.java:360)
            at com.sun.enterprise.v3.admin.CommandRunnerImpl$2.execute(CommandRunnerImpl.java:534)
            at com.sun.enterprise.v3.admin.CommandRunnerImpl$3.run(CommandRunnerImpl.java:565)
            at com.sun.enterprise.v3.admin.CommandRunnerImpl$3.run(CommandRunnerImpl.java:557)
            at java.security.AccessController.doPrivileged(Native Method)
            at javax.security.auth.Subject.doAs(Subject.java:360)
            at com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:556)
            at com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:1464)
            at com.sun.enterprise.v3.admin.CommandRunnerImpl.access$1300(CommandRunnerImpl.java:109)
            at com.sun.enterprise.v3.admin.CommandRunnerImpl$ExecutionContext.execute(CommandRunnerImpl.java:1846)
            at com.sun.enterprise.v3.admin.CommandRunnerImpl$ExecutionContext.execute(CommandRunnerImpl.java:1722)
            at org.glassfish.admin.rest.utils.ResourceUtil.runCommand(ResourceUtil.java:253)
            at org.glassfish.admin.rest.utils.ResourceUtil.runCommand(ResourceUtil.java:231)
            at org.glassfish.admin.rest.utils.ResourceUtil.runCommand(ResourceUtil.java:275)
            at org.glassfish.admin.rest.resources.TemplateListOfResource.createResource(TemplateListOfResource.java:136)
            at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
            at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
            at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
            at java.lang.reflect.Method.invoke(Method.java:498)
            at org.glassfish.jersey.server.model.internal.ResourceMethodInvocationHandlerFactory$1.invoke(ResourceMethodInvocationHandlerFactory.java:81)
            at org.glassfish.jersey.server.model.internal.AbstractJavaResourceMethodDispatcher$1.run(AbstractJavaResourceMethodDispatcher.java:144)
            at org.glassfish.jersey.server.model.internal.AbstractJavaResourceMethodDispatcher.invoke(AbstractJavaResourceMethodDispatcher.java:161)
            at org.glassfish.jersey.server.model.internal.JavaResourceMethodDispatcherProvider$ResponseOutInvoker.doDispatch(JavaResourceMethodDispatcherProvider.java:160)
            at org.glassfish.jersey.server.model.internal.AbstractJavaResourceMethodDispatcher.dispatch(AbstractJavaResourceMethodDispatcher.java:99)
            at org.glassfish.jersey.server.model.ResourceMethodInvoker.invoke(ResourceMethodInvoker.java:389)
            at org.glassfish.jersey.server.model.ResourceMethodInvoker.apply(ResourceMethodInvoker.java:347)
            at org.glassfish.jersey.server.model.ResourceMethodInvoker.apply(ResourceMethodInvoker.java:102)
            at org.glassfish.jersey.server.ServerRuntime$2.run(ServerRuntime.java:326)
            at org.glassfish.jersey.internal.Errors$1.call(Errors.java:271)
            at org.glassfish.jersey.internal.Errors$1.call(Errors.java:267)
            at org.glassfish.jersey.internal.Errors.process(Errors.java:315)
            at org.glassfish.jersey.internal.Errors.process(Errors.java:297)
            at org.glassfish.jersey.internal.Errors.process(Errors.java:267)
            at org.glassfish.jersey.process.internal.RequestScope.runInScope(RequestScope.java:317)
            at org.glassfish.jersey.server.ServerRuntime.process(ServerRuntime.java:305)
            at org.glassfish.jersey.server.ApplicationHandler.handle(ApplicationHandler.java:1154)
            at org.glassfish.jersey.grizzly2.httpserver.GrizzlyHttpContainer.service(GrizzlyHttpContainer.java:384)
            at org.glassfish.admin.rest.adapter.RestAdapter$2.service(RestAdapter.java:316)
            at org.glassfish.admin.rest.adapter.RestAdapter.service(RestAdapter.java:179)
            at com.sun.enterprise.v3.services.impl.ContainerMapper$HttpHandlerCallable.call(ContainerMapper.java:459)
            at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:167)
            at org.glassfish.grizzly.http.server.HttpHandler.runService(HttpHandler.java:206)
            at org.glassfish.grizzly.http.server.HttpHandler.doHandle(HttpHandler.java:180)
            at org.glassfish.grizzly.http.server.HttpServerFilter.handleRead(HttpServerFilter.java:235)
            at org.glassfish.grizzly.filterchain.ExecutorResolver$9.execute(ExecutorResolver.java:119)
            at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeFilter(DefaultFilterChain.java:283)
            at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeChainPart(DefaultFilterChain.java:200)
            at org.glassfish.grizzly.filterchain.DefaultFilterChain.execute(DefaultFilterChain.java:132)
            at org.glassfish.grizzly.filterchain.DefaultFilterChain.process(DefaultFilterChain.java:111)
            at org.glassfish.grizzly.ProcessorExecutor.execute(ProcessorExecutor.java:77)
            at org.glassfish.grizzly.nio.transport.TCPNIOTransport.fireIOEvent(TCPNIOTransport.java:536)
            at org.glassfish.grizzly.strategies.AbstractIOStrategy.fireIOEvent(AbstractIOStrategy.java:112)
            at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.run0(WorkerThreadIOStrategy.java:117)
            at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.access$100(WorkerThreadIOStrategy.java:56)
            at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy$WorkerThreadRunnable.run(WorkerThreadIOStrategy.java:137)
            at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:591)
            at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.run(AbstractThreadPool.java:571)
            at java.lang.Thread.run(Thread.java:745)
        Caused by: java.lang.NullPointerException
            at org.eclipse.persistence.queries.ReportQuery.beginAddingConstructorArguments(ReportQuery.java:558)
            at org.eclipse.persistence.internal.jpa.jpql.ReportItemBuilder.visit(ReportItemBuilder.java:263)
            at org.eclipse.persistence.jpa.jpql.parser.ConstructorExpression.accept(ConstructorExpression.java:84)
            at org.eclipse.persistence.internal.jpa.jpql.ReportItemBuilder.visitAbstractSelectClause(ReportItemBuilder.java:695)
            at org.eclipse.persistence.internal.jpa.jpql.ReportItemBuilder.visit(ReportItemBuilder.java:545)
            at org.eclipse.persistence.jpa.jpql.parser.SelectClause.accept(SelectClause.java:42)
            at org.eclipse.persistence.internal.jpa.jpql.ReportQueryVisitor.visitAbstractSelectClause(ReportQueryVisitor.java:82)
            at org.eclipse.persistence.internal.jpa.jpql.AbstractObjectLevelReadQueryVisitor.visit(AbstractObjectLevelReadQueryVisitor.java:173)
            at org.eclipse.persistence.jpa.jpql.parser.SelectClause.accept(SelectClause.java:42)
            at org.eclipse.persistence.internal.jpa.jpql.AbstractObjectLevelReadQueryVisitor.visitAbstractSelectStatement(AbstractObjectLevelReadQueryVisitor.java:327)
            at org.eclipse.persistence.internal.jpa.jpql.ReportQueryVisitor.visitAbstractSelectStatement(ReportQueryVisitor.java:92)
            at org.eclipse.persistence.internal.jpa.jpql.AbstractObjectLevelReadQueryVisitor.visit(AbstractObjectLevelReadQueryVisitor.java:183)
            at org.eclipse.persistence.jpa.jpql.parser.SelectStatement.accept(SelectStatement.java:101)
            at org.eclipse.persistence.internal.jpa.jpql.HermesParser$DatabaseQueryVisitor.visit(HermesParser.java:438)
            at org.eclipse.persistence.jpa.jpql.parser.SelectStatement.accept(SelectStatement.java:101)
            at org.eclipse.persistence.internal.jpa.jpql.HermesParser$DatabaseQueryVisitor.visit(HermesParser.java:418)
            at org.eclipse.persistence.jpa.jpql.parser.JPQLExpression.accept(JPQLExpression.java:135)
            at org.eclipse.persistence.internal.jpa.jpql.HermesParser.populateQueryImp(HermesParser.java:282)
            ... 85 more
        ]]

        [2017-08-15T21:32:24.548+0200] [Payara 4.1] [SEVERE] [] [javax.enterprise.system.core] [tid: _ThreadID=154 _ThreadName=admin-listener(7)] [timeMillis: 1502825544548] [levelValue: 1000] [[
          Exception while deploying the app [tsbgam-application-2017-T3-SNAPSHOT]]]

        [2017-08-15T21:32:24.548+0200] [Payara 4.1] [SEVERE] [NCLS-CORE-00026] [javax.enterprise.system.core] [tid: _ThreadID=154 _ThreadName=admin-listener(7)] [timeMillis: 1502825544548] [levelValue: 1000] [[
          Exception during lifecycle processing
        org.glassfish.deployment.common.DeploymentException: Exception [EclipseLink-28019] (Eclipse Persistence Services - 2.6.2.qualifier): org.eclipse.persistence.exceptions.EntityManagerSetupException
        Exception Description: Deployment of PersistenceUnit [tsms_tsbg] failed. Close all factories for this PersistenceUnit.
        Internal Exception: Exception [EclipseLink-0] (Eclipse Persistence Services - 2.6.2.qualifier): org.eclipse.persistence.exceptions.JPQLException
        Exception Description: Internal problem encountered while compiling [SELECT NEW TextHistory(i.id, i.fileName, i.importDate) FROM TextHistory i].
        Internal Exception: java.lang.NullPointerException
            at org.eclipse.persistence.internal.jpa.EntityManagerSetupImpl.createDeployFailedPersistenceException(EntityManagerSetupImpl.java:869)
            at org.eclipse.persistence.internal.jpa.EntityManagerSetupImpl.deploy(EntityManagerSetupImpl.java:809)
            at org.eclipse.persistence.internal.jpa.EntityManagerFactoryDelegate.getAbstractSession(EntityManagerFactoryDelegate.java:205)
            at org.eclipse.persistence.internal.jpa.EntityManagerFactoryDelegate.createEntityManagerImpl(EntityManagerFactoryDelegate.java:305)
            at org.eclipse.persistence.internal.jpa.EntityManagerFactoryImpl.createEntityManagerImpl(EntityManagerFactoryImpl.java:337)
            at org.eclipse.persistence.internal.jpa.EntityManagerFactoryImpl.createEntityManager(EntityManagerFactoryImpl.java:303)
            at org.glassfish.persistence.jpa.JPADeployer$2.visitPUD(JPADeployer.java:451)
            at org.glassfish.persistence.jpa.JPADeployer$PersistenceUnitDescriptorIterator.iteratePUDs(JPADeployer.java:510)
            at org.glassfish.persistence.jpa.JPADeployer.iterateInitializedPUsAtApplicationPrepare(JPADeployer.java:492)
            at org.glassfish.persistence.jpa.JPADeployer.event(JPADeployer.java:395)
            at org.glassfish.kernel.event.EventsImpl.send(EventsImpl.java:131)
            at com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:487)
            at com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:219)
            at org.glassfish.deployment.admin.DeployCommand.execute(DeployCommand.java:487)
            at com.sun.enterprise.v3.admin.CommandRunnerImpl$2$1.run(CommandRunnerImpl.java:539)
            at com.sun.enterprise.v3.admin.CommandRunnerImpl$2$1.run(CommandRunnerImpl.java:535)
            at java.security.AccessController.doPrivileged(Native Method)
            at javax.security.auth.Subject.doAs(Subject.java:360)
            at com.sun.enterprise.v3.admin.CommandRunnerImpl$2.execute(CommandRunnerImpl.java:534)
            at com.sun.enterprise.v3.admin.CommandRunnerImpl$3.run(CommandRunnerImpl.java:565)
            at com.sun.enterprise.v3.admin.CommandRunnerImpl$3.run(CommandRunnerImpl.java:557)
            at java.security.AccessController.doPrivileged(Native Method)
            at javax.security.auth.Subject.doAs(Subject.java:360)
            at com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:556)
            at com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:1464)
            at com.sun.enterprise.v3.admin.CommandRunnerImpl.access$1300(CommandRunnerImpl.java:109)
            at com.sun.enterprise.v3.admin.CommandRunnerImpl$ExecutionContext.execute(CommandRunnerImpl.java:1846)
            at com.sun.enterprise.v3.admin.CommandRunnerImpl$ExecutionContext.execute(CommandRunnerImpl.java:1722)
            at org.glassfish.admin.rest.utils.ResourceUtil.runCommand(ResourceUtil.java:253)
            at org.glassfish.admin.rest.utils.ResourceUtil.runCommand(ResourceUtil.java:231)
            at org.glassfish.admin.rest.utils.ResourceUtil.runCommand(ResourceUtil.java:275)
            at org.glassfish.admin.rest.resources.TemplateListOfResource.createResource(TemplateListOfResource.java:136)
            at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
            at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
            at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
            at java.lang.reflect.Method.invoke(Method.java:498)
            at org.glassfish.jersey.server.model.internal.ResourceMethodInvocationHandlerFactory$1.invoke(ResourceMethodInvocationHandlerFactory.java:81)
            at org.glassfish.jersey.server.model.internal.AbstractJavaResourceMethodDispatcher$1.run(AbstractJavaResourceMethodDispatcher.java:144)
            at org.glassfish.jersey.server.model.internal.AbstractJavaResourceMethodDispatcher.invoke(AbstractJavaResourceMethodDispatcher.java:161)
            at org.glassfish.jersey.server.model.internal.JavaResourceMethodDispatcherProvider$ResponseOutInvoker.doDispatch(JavaResourceMethodDispatcherProvider.java:160)
            at org.glassfish.jersey.server.model.internal.AbstractJavaResourceMethodDispatcher.dispatch(AbstractJavaResourceMethodDispatcher.java:99)
            at org.glassfish.jersey.server.model.ResourceMethodInvoker.invoke(ResourceMethodInvoker.java:389)
            at org.glassfish.jersey.server.model.ResourceMethodInvoker.apply(ResourceMethodInvoker.java:347)
            at org.glassfish.jersey.server.model.ResourceMethodInvoker.apply(ResourceMethodInvoker.java:102)
            at org.glassfish.jersey.server.ServerRuntime$2.run(ServerRuntime.java:326)
            at org.glassfish.jersey.internal.Errors$1.call(Errors.java:271)
            at org.glassfish.jersey.internal.Errors$1.call(Errors.java:267)
            at org.glassfish.jersey.internal.Errors.process(Errors.java:315)
            at org.glassfish.jersey.internal.Errors.process(Errors.java:297)
            at org.glassfish.jersey.internal.Errors.process(Errors.java:267)
            at org.glassfish.jersey.process.internal.RequestScope.runInScope(RequestScope.java:317)
            at org.glassfish.jersey.server.ServerRuntime.process(ServerRuntime.java:305)
            at org.glassfish.jersey.server.ApplicationHandler.handle(ApplicationHandler.java:1154)
            at org.glassfish.jersey.grizzly2.httpserver.GrizzlyHttpContainer.service(GrizzlyHttpContainer.java:384)
            at org.glassfish.admin.rest.adapter.RestAdapter$2.service(RestAdapter.java:316)
            at org.glassfish.admin.rest.adapter.RestAdapter.service(RestAdapter.java:179)
            at com.sun.enterprise.v3.services.impl.ContainerMapper$HttpHandlerCallable.call(ContainerMapper.java:459)
            at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:167)
            at org.glassfish.grizzly.http.server.HttpHandler.runService(HttpHandler.java:206)
            at org.glassfish.grizzly.http.server.HttpHandler.doHandle(HttpHandler.java:180)
            at org.glassfish.grizzly.http.server.HttpServerFilter.handleRead(HttpServerFilter.java:235)
            at org.glassfish.grizzly.filterchain.ExecutorResolver$9.execute(ExecutorResolver.java:119)
            at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeFilter(DefaultFilterChain.java:283)
            at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeChainPart(DefaultFilterChain.java:200)
            at org.glassfish.grizzly.filterchain.DefaultFilterChain.execute(DefaultFilterChain.java:132)
            at org.glassfish.grizzly.filterchain.DefaultFilterChain.process(DefaultFilterChain.java:111)
            at org.glassfish.grizzly.ProcessorExecutor.execute(ProcessorExecutor.java:77)
            at org.glassfish.grizzly.nio.transport.TCPNIOTransport.fireIOEvent(TCPNIOTransport.java:536)
            at org.glassfish.grizzly.strategies.AbstractIOStrategy.fireIOEvent(AbstractIOStrategy.java:112)
            at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.run0(WorkerThreadIOStrategy.java:117)
            at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.access$100(WorkerThreadIOStrategy.java:56)
            at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy$WorkerThreadRunnable.run(WorkerThreadIOStrategy.java:137)
            at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:591)
            at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.run(AbstractThreadPool.java:571)
            at java.lang.Thread.run(Thread.java:745)
        ]]

        [2017-08-15T21:32:24.562+0200] [Payara 4.1] [SEVERE] [] [javax.enterprise.system.core] [tid: _ThreadID=154 _ThreadName=admin-listener(7)] [timeMillis: 1502825544562] [levelValue: 1000] [[
          Exception while deploying the app [tsbgam-application-2017-T3-SNAPSHOT] : Exception [EclipseLink-28019] (Eclipse Persistence Services - 2.6.2.qualifier): org.eclipse.persistence.exceptions.EntityManagerSetupException
        Exception Description: Deployment of PersistenceUnit [tsms_tsbg] failed. Close all factories for this PersistenceUnit.
        Internal Exception: Exception [EclipseLink-0] (Eclipse Persistence Services - 2.6.2.qualifier): org.eclipse.persistence.exceptions.JPQLException
        Exception Description: Internal problem encountered while compiling [SELECT NEW TextHistory(i.id, i.fileName, i.importDate) FROM TextHistory i].
        Internal Exception: java.lang.NullPointerException]]

        [2017-08-15T21:32:24.663+0200] [Payara 4.1] [INFO] [] [org.glassfish.admingui] [tid: _ThreadID=47 _ThreadName=admin-listener(5)] [timeMillis: 1502825544663] [levelValue: 800] [[
          Exception Occurred :Error occurred during deployment: Exception while deploying the app [tsbgam-application-2017-T3-SNAPSHOT] : Exception [EclipseLink-28019] (Eclipse Persistence Services - 2.6.2.qualifier): org.eclipse.persistence.exceptions.EntityManagerSetupException
        Exception Description: Deployment of PersistenceUnit [tsms_tsbg] failed. Close all factories for this PersistenceUnit.
        Internal Exception: Exception [EclipseLink-0] (Eclipse Persistence Services - 2.6.2.qualifier): org.eclipse.persistence.exceptions.JPQLException
        Exception Description: Internal problem encountered while compiling [SELECT NEW TextHistory(i.id, i.fileName, i.importDate) FROM TextHistory i].
        Internal Exception: java.lang.NullPointerException. Please see server.log for more details.          ]]

Any hints on why do you actually want to use the SELECT NEW syntax? 关于您实际上为什么要使用SELECT NEW语法的任何提示? This syntax is mostly used in (the rare) case that you want to select fields from one entity and construct a different object using the values of those fields. 这种语法通常用于(罕见的)情况下,您想从一个实体中选择字段并使用这些字段的值构造另一个对象。

In your case you are constructing the very same entity you are selecting from. 在您的情况下,您将构建从中选择的同一实体。 This is usually done as select e from SomeEntity e . 通常这是通过select e from SomeEntity e完成的。 (Actually, in contrast to SQL, in JPQL the select clause is optional as long as you are selecting from a single entity. So from SomeEntity e just selects the whole table, and from SomeEntity e where e <whatever> selects all <whatever> records.) (实际上,与SQL相反,在JPQL中,只要从单个实体中进行选择, select子句是可选的。因此, from SomeEntity e仅选择整个表, from SomeEntity e where e <whatever>选择from SomeEntity e where e <whatever>选择所有<whatever>记录。)

In case the entity has some heavyweight attributes (like @Lob s) or @ManyToOne associations that you don't want to load initially, the proper way to do this is to make them lazily loaded. 如果实体具有一些重量级属性(例如@Lob )或@ManyToOne关联,而您不想一开始就对其进行加载,则执行此操作的正确方法是使它们延迟加载。 For LOBs this is done via @Basic(fetchType = LAZY) and for associations via @ManyToOne(fetchType = LAZY) . 对于LOB,这通过@Basic(fetchType = LAZY) ,对于关联,则通过@ManyToOne(fetchType = LAZY) Note that for @ManyToMany and @OneToMany lazy loading is the default anyway. 请注意,对于@ManyToMany@OneToMany延迟加载始终是默认设置。

My impression is that you are trying to do JPA "the SQL way". 我的印象是您正在尝试以“ SQL方式”进行JPA。 A solid SQL knowledge is a must to properly use JPA, but you need to always do this "paradigm switch" from relational to object-oriented perspective in order to do things the way they are supposed to. 扎实的SQL知识对于正确使用JPA是必不可少的,但是您必须始终从关系到面向对象的角度进行这种“范式转换”,以便按照预期的方式进行操作。

BTW, regarding BTW,关于

I don't even know what Eclipselink is 我什至不知道什么是Eclipselink

This pretty much says it all :-) JPA is a standardized Java API - it defines how things are supposed to work, no more, no less. 这几乎说明了一切:-) JPA是一种标准化的Java API-它定义了事情应该如何工作,没有更多,也不少。 It does not actually do the real work - this is left to the particular JPA implementation, aka persistence provider. 它实际上并没有做真正的工作-这留给了特定的JPA实现,也就是持久性提供程序。 There are a bunch of JPA implementations out there, the most prominent being Hibernate and Eclipselink. 有很多JPA实现,最突出的是Hibernate和Eclipselink。 Every Java EE application server is required to include a JPA persistence provider, and it seems like your server comes with Eclipselink. 每个Java EE应用程序服务器都必须包含JPA持久性提供程序,并且看来您的服务器随附Eclipselink。 Eclipselink came into existence when Oracle donated their proprietary JPA implementation named TopLink to the Eclipse Foundation. 当Oracle将其专有的名为TopLink的JPA实现捐赠给Eclipse Foundation时,Eclipselink便应运而生。

Update: I did a bit more research and it seems like the reason for your error is quite mundane: The SELECT NEW syntax requires you to use the fully quialified name of the constructor, ie including package name. 更新:我做了更多的研究,看来您出错的原因很平凡: SELECT NEW语法要求您使用构造函数的完全合格名称,即包括程序包名称。 This is because you can select new into any POJO class you want, it does not require the class to be a JPA entity. 这是因为您可以在想要的任何POJO类中select new ,而不要求该类是JPA实体。 In contrast, the from clause uses simple names because only @Entity classes are allowed there (which JPA enumerates and parses at deployment time). 相反, from子句使用简单名称,因为那里仅允许@Entity类(JPA在部署时枚举和解析)。

Why not using a fully qualified name leads to a NullPointer in the Eclipselink code, is another story - seems like a bug in Eclipselink. 为什么不使用完全限定的名称会导致Eclipselink代码中出现NullPointer,这是另一个故事-似乎像Eclipselink中的错误。

==> This leads to the question which one is better, select new or lazy loading. ==>这会导致一个问题,那就是哪个更好, select new加载还是延迟加载。 As always, it depends on your usecase. 与往常一样,这取决于您的用例。 Annotating the fields for lazy loading will always be honored, no matter how the objects got into memory. 无论对象如何进入内存,为延迟加载的字段添加注释将始终受到重视。 For example, using EnitytManager.find() always returns a complete instance of the entity, use can't use a custom constructor there. 例如,使用EnitytManager.find()总是返回实体的完整实例,而不能在其中使用自定义构造函数。 But annotations on fields of course apply. 但是,当然可以使用对字段的注释。 The same goes when accessing entities by association - if A contains a reference to B , and you call A.getB() you get an instance of B initialized according to its annotations. 通过关联访问实体时也是如此-如果A包含对B的引用,并且您调用A.getB()则会根据其注释初始化B的实例。

Using select new is a one-off technique in case you deliberately want to divert from the default. 如果您故意要偏离默认值,则使用select new是一项一次性技术。

Not familiar with this SELECT NEW syntax, but can see you are using Eclipselink ( http://wiki.eclipse.org/EclipseLink/Examples/JPA ) 不熟悉这种SELECT NEW语法,但是可以看到您正在使用Eclipselink( http://wiki.eclipse.org/EclipseLink/Examples/JPA

About a year ago I was stuck with one problem and at the end of the day it appeared to be an Eclipselink bug. 大约一年前,我陷入了一个问题,到最后,它似乎是一个Eclipselink错误。 Worth checking on that ( https://bugs.eclipse.org/bugs/query.cgi ), maybe it's known or maybe you just found it. 值得检查一下( https://bugs.eclipse.org/bugs/query.cgi ),也许它是已知的,或者您只是发现了它。

Another guess: org.eclipse.persistence.exceptions.EntityManagerSetupException might lead to incorrect EntityManager's settings. 另一个猜测: org.eclipse.persistence.exceptions.EntityManagerSetupException可能导致EntityManager的设置不正确。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM