Why do I keep getting the 'cannot resolve query' for this native query?

Good day

Here is my DTO class:

package com.comp.model.employee.hierarchy;

import javax.ejb.Stateful;
import javax.persistence.ColumnResult;
import javax.persistence.ConstructorResult;
import javax.persistence.NamedNativeQuery;
import javax.persistence.SqlResultSetMapping;
import java.io.Serializable;
import java.util.Objects;


@NamedNativeQuery(
        name = "PartialHierarchyDisplay",
        query = "SELECT t.emp_aid, t.supervisor_emp_aid, t.level, t.branch, t.pos "
                + "FROM connectby('human_resources.emp_info', 'emp_aid', 'emp_supervisor', 'emp_last_name', :empAid, 0, '~') "
                + "t(emp_aid bigint, supervisor_emp_aid bigint, level integer, branch text, pos integer)", resultSetMapping = "PartialHierarchyDisplay"
)
@SqlResultSetMapping(
        name = "PartialHierarchyDisplay",
        classes = @ConstructorResult(
                targetClass = PartialHierarchyDisplay.class,
                columns = {
                        @ColumnResult(name = "emp_aid"),
                        @ColumnResult(name = "supervisor_emp_aid"),
                        @ColumnResult(name = "level"),
                        @ColumnResult(name = "branch"),
                        @ColumnResult(name = "pos")
                }
        )
)
@Stateful
public class PartialHierarchyDisplay implements Serializable {

    private static final long serialVersionUID = 1L;
    private Long empAid;
    private Long supervisorEmpAid;
    private Integer level;
    private String branch;
    private Integer pos;

    public PartialHierarchyDisplay(Long empAid, Long supervisorEmpAid, Integer level, String branch, Integer pos) {
        this.empAid = empAid;
        this.supervisorEmpAid = supervisorEmpAid;
        this.level = level;
        this.branch = branch;
        this.pos = pos;
    }

    
    public Long getEmpAid() {
        return empAid;
    }

    public void setEmpAid(Long empAid) {
        this.empAid = empAid;
    }

    public Long getSupervisorEmpAid() {
        return supervisorEmpAid;
    }

    public void setSupervisorEmpAid(Long supervisorEmpAid) {
        this.supervisorEmpAid = supervisorEmpAid;
    }

    public Integer getLevel() {
        return level;
    }

    public void setLevel(Integer level) {
        this.level = level;
    }

    public String getBranch() {
        return branch;
    }

    public void setBranch(String branch) {
        this.branch = branch;
    }

    public Integer getPos() {
        return pos;
    }

    public void setPos(Integer pos) {
        this.pos = pos;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        PartialHierarchyDisplay that = (PartialHierarchyDisplay) o;
        return Objects.equals(empAid, that.empAid) &&
                Objects.equals(supervisorEmpAid, that.supervisorEmpAid) &&
                Objects.equals(level, that.level) &&
                Objects.equals(branch, that.branch) &&
                Objects.equals(pos, that.pos);
    }

    @Override
    public int hashCode() {

        return Objects.hash(empAid, supervisorEmpAid, level, branch, pos);
    }

    @Override
    public String toString() {
        return "PartialHierarchyDisplay{" +
                "empAid=" + empAid +
                ", supervisorEmpAid=" + supervisorEmpAid +
                ", level=" + level +
                ", branch='" + branch + '\'' +
                ", pos=" + pos +
                '}';
    }
}

And this is the service class:

package com.comp.controller.employee.hierarchy;

import com.comp.utility.DmlSQL;
import com.comp.model.employee.hierarchy.PartialHierarchyDisplay;

import javax.ejb.EJB;
import javax.ejb.Stateless;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import java.io.Serializable;
import java.util.List;

@SuppressWarnings({"WeakerAccess", "unused"})
@Stateless
public class PartialHierarchyService implements Serializable {

    private static final long serialVersionUID = 1L;

    @PersistenceContext(unitName = "PostgresDS")
    private transient EntityManager em;

    @EJB
    private transient DmlSQL dmlSQL;
    
    public List<PartialHierarchyDisplay> getPartialHierarchy(Long empAid) {
        List<PartialHierarchyDisplay> partialHierarchyList = em
                .createNamedQuery("PartialHierarchyDisplay")
                .setParameter("empAid", empAid)
                .getResultList();

        return partialHierarchyList;

    }
}

I followed Vlad’s tutorial from here:

I am using Wildfly-11 which in turn uses Hibernate 5.1.10.Final

My problem is that this piece of code:

.createNamedQuery("PartialHierarchyDisplay")

Causes IntelliJ 18.1.1 to show an error with detail:

Cannot resolve query ‘PartialHierarchyDisplay’

What am I doing wrong here?

Sincerest thanks in advance for any assistance.

Causes IntelliJ 18.1.1 to show an error with detail.

Maybe it’s just IDEA who can’t figure out the named query. Try to run an integration tests and see if it works. That’s what counts after all.

Good day @vlad

Thanks for your reply, it is much appreciated.

I get a run time error when attempting to access the query saying basically the same:

09:59:31,198 ERROR [org.jboss.as.ejb3.invocation] (default task-10) WFLYEJB0034: EJB Invocation failed on component PartialHierarchyService for method public java.util.List com.megchemsa.controller.employee.hierarchy.PartialHierarchyService.getPartialHierarchy(java.lang.Long,java.lang.Long): javax.ejb.EJBException: java.lang.IllegalArgumentException: No query defined for that name [PartialHierarchyDisplay]

Do this code require Hibernate 5.2.x ? Wildfly-11 only have 5.1.10.Final ‘out-of-the-box’

Below is the stack trace:

09:59:31,257 ERROR [org.jboss.as.ejb3.invocation] (default task-10) WFLYEJB0034: EJB Invocation failed on component PartialHierarchyService for method public java.util.List com.megchemsa.controller.employee.hierarchy.PartialHierarchyService.getPartialHierarchy(java.lang.Long,java.lang.Long): javax.ejb.EJBException: java.lang.IllegalArgumentException: No query defined for that name [PartialHierarchyDisplay]
	at org.jboss.as.ejb3.tx.CMTTxInterceptor.handleExceptionInOurTx(CMTTxInterceptor.java:188)
	at org.jboss.as.ejb3.tx.CMTTxInterceptor.invokeInOurTx(CMTTxInterceptor.java:277)
	at org.jboss.as.ejb3.tx.CMTTxInterceptor.required(CMTTxInterceptor.java:332)
	at org.jboss.as.ejb3.tx.CMTTxInterceptor.processInvocation(CMTTxInterceptor.java:240)
	at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:422)
	at org.jboss.invocation.InterceptorContext$Invocation.proceed(InterceptorContext.java:509)
	at org.jboss.weld.ejb.AbstractEJBRequestScopeActivationInterceptor.aroundInvoke(AbstractEJBRequestScopeActivationInterceptor.java:64)
	at org.jboss.as.weld.ejb.EjbRequestScopeActivationInterceptor.processInvocation(EjbRequestScopeActivationInterceptor.java:89)
	at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:422)
	at org.jboss.as.ejb3.component.interceptors.CurrentInvocationContextInterceptor.processInvocation(CurrentInvocationContextInterceptor.java:41)
	at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:422)
	at org.jboss.as.ejb3.component.invocationmetrics.WaitTimeInterceptor.processInvocation(WaitTimeInterceptor.java:47)
	at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:422)
	at org.jboss.as.ejb3.security.SecurityContextInterceptor.processInvocation(SecurityContextInterceptor.java:100)
	at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:422)
	at org.jboss.as.ejb3.deployment.processors.StartupAwaitInterceptor.processInvocation(StartupAwaitInterceptor.java:22)
	at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:422)
	at org.jboss.as.ejb3.component.interceptors.ShutDownInterceptorFactory$1.processInvocation(ShutDownInterceptorFactory.java:64)
	at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:422)
	at org.jboss.as.ejb3.component.interceptors.LoggingInterceptor.processInvocation(LoggingInterceptor.java:67)
	at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:422)
	at org.jboss.as.ee.component.NamespaceContextInterceptor.processInvocation(NamespaceContextInterceptor.java:50)
	at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:422)
	at org.jboss.as.ejb3.component.interceptors.AdditionalSetupInterceptor.processInvocation(AdditionalSetupInterceptor.java:54)
	at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:422)
	at org.jboss.invocation.ContextClassLoaderInterceptor.processInvocation(ContextClassLoaderInterceptor.java:60)
	at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:422)
	at org.jboss.invocation.InterceptorContext.run(InterceptorContext.java:438)
	at org.wildfly.security.manager.WildFlySecurityManager.doChecked(WildFlySecurityManager.java:609)
	at org.jboss.invocation.AccessCheckingInterceptor.processInvocation(AccessCheckingInterceptor.java:57)
	at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:422)
	at org.jboss.invocation.ChainedInterceptor.processInvocation(ChainedInterceptor.java:53)
	at org.jboss.as.ee.component.ViewService$View.invoke(ViewService.java:198)
	at org.jboss.as.ee.component.ViewDescription$1.processInvocation(ViewDescription.java:185)
	at org.jboss.as.ee.component.ProxyInvocationHandler.invoke(ProxyInvocationHandler.java:81)
	at com.megchemsa.controller.employee.hierarchy.PartialHierarchyService$$$view6.getPartialHierarchy(Unknown Source)
	at com.megchemsa.view.testing.DevTestingView.init(DevTestingView.java:35)
	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.jboss.weld.interceptor.reader.SimpleInterceptorInvocation$SimpleMethodInvocation.invoke(SimpleInterceptorInvocation.java:76)
	at org.jboss.weld.interceptor.proxy.WeldInvocationContext.invokeNext(WeldInvocationContext.java:85)
	at org.jboss.weld.interceptor.proxy.WeldInvocationContext.proceed(WeldInvocationContext.java:115)
	at org.jboss.weld.interceptor.proxy.InterceptorMethodHandler.executeLifecycleInterception(InterceptorMethodHandler.java:78)
	at org.jboss.weld.interceptor.proxy.InterceptorMethodHandler.executeInterception(InterceptorMethodHandler.java:74)
	at org.jboss.weld.interceptor.proxy.InterceptorMethodHandler.invoke(InterceptorMethodHandler.java:48)
	at org.jboss.weld.bean.proxy.CombinedInterceptorAndDecoratorStackMethodHandler.invoke(CombinedInterceptorAndDecoratorStackMethodHandler.java:84)
	at org.jboss.weld.bean.proxy.CombinedInterceptorAndDecoratorStackMethodHandler.invoke(CombinedInterceptorAndDecoratorStackMethodHandler.java:61)
	at com.megchemsa.view.testing.DevTestingView$Proxy$_$$_WeldSubclass.lifecycle_mixin_$$_postConstruct(Unknown Source)
	at org.jboss.weld.interceptor.util.InterceptionUtils.executePostConstruct(InterceptionUtils.java:49)
	at org.jboss.weld.interceptor.util.InterceptionUtils.executePostConstruct(InterceptionUtils.java:61)
	at org.jboss.weld.injection.producer.DefaultLifecycleCallbackInvoker.postConstruct(DefaultLifecycleCallbackInvoker.java:78)
	at org.jboss.weld.injection.producer.BasicInjectionTarget.postConstruct(BasicInjectionTarget.java:122)
	at org.jboss.weld.bean.ManagedBean.create(ManagedBean.java:162)
	at org.jboss.weld.util.bean.IsolatedForwardingBean.create(IsolatedForwardingBean.java:45)
	at org.omnifaces.cdi.BeanStorage.createBean(BeanStorage.java:62)
	at org.omnifaces.cdi.viewscope.ViewScopeManager.createBean(ViewScopeManager.java:115)
	at org.omnifaces.cdi.viewscope.ViewScopeManager$Proxy$_$$_WeldSubclass.createBean$$super(Unknown Source)
	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.jboss.weld.interceptor.proxy.TerminalAroundInvokeInvocationContext.proceedInternal(TerminalAroundInvokeInvocationContext.java:49)
	at org.jboss.weld.interceptor.proxy.AroundInvokeInvocationContext.proceed(AroundInvokeInvocationContext.java:77)
	at org.jboss.weld.probe.InvocationMonitor$InterceptorAction.proceed(InvocationMonitor.java:198)
	at org.jboss.weld.probe.InvocationMonitor$InterceptorAction.proceed(InvocationMonitor.java:194)
	at org.jboss.weld.probe.InvocationMonitor$Action.perform(InvocationMonitor.java:173)
	at org.jboss.weld.probe.InvocationMonitor.monitor(InvocationMonitor.java:139)
	at sun.reflect.GeneratedMethodAccessor35.invoke(Unknown Source)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at org.jboss.weld.interceptor.reader.SimpleInterceptorInvocation$SimpleMethodInvocation.invoke(SimpleInterceptorInvocation.java:73)
	at org.jboss.weld.interceptor.proxy.InterceptorMethodHandler.executeAroundInvoke(InterceptorMethodHandler.java:84)
	at org.jboss.weld.interceptor.proxy.InterceptorMethodHandler.executeInterception(InterceptorMethodHandler.java:72)
	at org.jboss.weld.interceptor.proxy.InterceptorMethodHandler.invoke(InterceptorMethodHandler.java:56)
	at org.jboss.weld.bean.proxy.CombinedInterceptorAndDecoratorStackMethodHandler.invoke(CombinedInterceptorAndDecoratorStackMethodHandler.java:79)
	at org.jboss.weld.bean.proxy.CombinedInterceptorAndDecoratorStackMethodHandler.invoke(CombinedInterceptorAndDecoratorStackMethodHandler.java:68)
	at org.omnifaces.cdi.viewscope.ViewScopeManager$Proxy$_$$_WeldSubclass.createBean(Unknown Source)
	at org.omnifaces.cdi.viewscope.ViewScopeManager$Proxy$_$$_WeldClientProxy.createBean(Unknown Source)
	at org.omnifaces.cdi.viewscope.ViewScopeContext.get(ViewScopeContext.java:73)
	at org.jboss.weld.context.PassivatingContextWrapper$AbstractPassivatingContextWrapper.get(PassivatingContextWrapper.java:76)
	at org.jboss.weld.bean.ContextualInstanceStrategy$DefaultContextualInstanceStrategy.get(ContextualInstanceStrategy.java:100)
	at org.jboss.weld.bean.ContextualInstance.get(ContextualInstance.java:50)
	at org.jboss.weld.manager.BeanManagerImpl.getReference(BeanManagerImpl.java:758)
	at org.jboss.weld.el.AbstractWeldELResolver.lookup(AbstractWeldELResolver.java:107)
	at org.jboss.weld.el.AbstractWeldELResolver.getValue(AbstractWeldELResolver.java:90)
	at org.jboss.as.jsf.injection.weld.ForwardingELResolver.getValue(ForwardingELResolver.java:46)
	at javax.el.CompositeELResolver.getValue(CompositeELResolver.java:188)
	at com.sun.faces.el.DemuxCompositeELResolver._getValue(DemuxCompositeELResolver.java:176)
	at com.sun.faces.el.DemuxCompositeELResolver.getValue(DemuxCompositeELResolver.java:203)
	at com.sun.el.parser.AstIdentifier.getValue(AstIdentifier.java:116)
	at com.sun.el.parser.AstValue.getBase(AstValue.java:150)
	at com.sun.el.parser.AstValue.getValue(AstValue.java:199)
	at com.sun.el.ValueExpressionImpl.getValue(ValueExpressionImpl.java:226)
	at org.jboss.weld.el.WeldValueExpression.getValue(WeldValueExpression.java:50)
	at org.jboss.weld.el.WeldValueExpression.getValue(WeldValueExpression.java:50)
	at com.sun.faces.facelets.el.TagValueExpression.getValue(TagValueExpression.java:109)
	at javax.faces.component.ComponentStateHelper.eval(ComponentStateHelper.java:194)
	at javax.faces.component.ComponentStateHelper.eval(ComponentStateHelper.java:182)
	at javax.faces.component.UIData.getValue(UIData.java:732)
	at org.primefaces.component.api.UIData.getDataModel(UIData.java:764)
	at org.primefaces.component.api.UIData.setRowModel(UIData.java:571)
	at org.primefaces.component.api.UIData.setRowIndexWithoutRowStatePreserved(UIData.java:564)
	at org.primefaces.component.api.UIData.setRowIndex(UIData.java:473)
	at org.primefaces.component.api.UIData.visitTree(UIData.java:821)
	at javax.faces.component.UIComponent.visitTree(UIComponent.java:1700)
	at javax.faces.component.UIComponent.visitTree(UIComponent.java:1700)
	at javax.faces.component.UIComponent.visitTree(UIComponent.java:1700)
	at javax.faces.component.UIForm.visitTree(UIForm.java:371)
	at javax.faces.component.UIComponent.visitTree(UIComponent.java:1700)
	at javax.faces.component.UIComponent.visitTree(UIComponent.java:1700)
	at javax.faces.component.UIComponent.visitTree(UIComponent.java:1700)
	at javax.faces.component.UIComponent.visitTree(UIComponent.java:1700)
	at javax.faces.component.UIComponent.visitTree(UIComponent.java:1700)
	at org.primefaces.application.exceptionhandler.PrimeExceptionHandler.findHandlerComponent(PrimeExceptionHandler.java:277)
	at org.primefaces.application.exceptionhandler.PrimeExceptionHandler.handleAjaxException(PrimeExceptionHandler.java:177)
	at org.primefaces.application.exceptionhandler.PrimeExceptionHandler.handle(PrimeExceptionHandler.java:98)
	at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:119)
	at com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:219)
	at javax.faces.webapp.FacesServlet.service(FacesServlet.java:659)
	at io.undertow.servlet.handlers.ServletHandler.handleRequest(ServletHandler.java:85)
	at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:129)
	at org.omnifaces.filter.CacheControlFilter.doFilter(CacheControlFilter.java:239)
	at org.omnifaces.filter.HttpFilter.doFilter(HttpFilter.java:108)
	at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61)
	at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131)
	at org.apache.shiro.web.servlet.AbstractShiroFilter.executeChain(AbstractShiroFilter.java:449)
	at org.apache.shiro.web.servlet.AbstractShiroFilter$1.call(AbstractShiroFilter.java:365)
	at org.apache.shiro.subject.support.SubjectCallable.doCall(SubjectCallable.java:90)
	at org.apache.shiro.subject.support.SubjectCallable.call(SubjectCallable.java:83)
	at org.apache.shiro.subject.support.DelegatingSubject.execute(DelegatingSubject.java:387)
	at org.apache.shiro.web.servlet.AbstractShiroFilter.doFilterInternal(AbstractShiroFilter.java:362)
	at org.apache.shiro.web.servlet.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:125)
	at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61)
	at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131)
	at org.jboss.weld.probe.ProbeFilter$FilterAction.proceed(ProbeFilter.java:329)
	at org.jboss.weld.probe.ProbeFilter$FilterAction.proceed(ProbeFilter.java:312)
	at org.jboss.weld.probe.InvocationMonitor$Action.perform(InvocationMonitor.java:173)
	at org.jboss.weld.probe.ProbeFilter$FilterAction.doFilter(ProbeFilter.java:338)
	at org.jboss.weld.probe.ProbeFilter.embedInfoSnippet(ProbeFilter.java:188)
	at org.jboss.weld.probe.ProbeFilter.doFilter(ProbeFilter.java:176)
	at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61)
	at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131)
	at org.apache.logging.log4j.web.Log4jServletFilter.doFilter(Log4jServletFilter.java:71)
	at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61)
	at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131)
	at io.undertow.servlet.handlers.FilterHandler.handleRequest(FilterHandler.java:84)
	at io.undertow.servlet.handlers.security.ServletSecurityRoleHandler.handleRequest(ServletSecurityRoleHandler.java:62)
	at io.undertow.servlet.handlers.ServletDispatchingHandler.handleRequest(ServletDispatchingHandler.java:36)
	at org.wildfly.extension.undertow.security.SecurityContextAssociationHandler.handleRequest(SecurityContextAssociationHandler.java:78)
	at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
	at io.undertow.servlet.handlers.security.SSLInformationAssociationHandler.handleRequest(SSLInformationAssociationHandler.java:131)
	at io.undertow.servlet.handlers.security.ServletAuthenticationCallHandler.handleRequest(ServletAuthenticationCallHandler.java:57)
	at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
	at io.undertow.security.handlers.AbstractConfidentialityHandler.handleRequest(AbstractConfidentialityHandler.java:46)
	at io.undertow.servlet.handlers.security.ServletConfidentialityConstraintHandler.handleRequest(ServletConfidentialityConstraintHandler.java:64)
	at io.undertow.security.handlers.AuthenticationMechanismsHandler.handleRequest(AuthenticationMechanismsHandler.java:60)
	at io.undertow.servlet.handlers.security.CachedAuthenticatedSessionHandler.handleRequest(CachedAuthenticatedSessionHandler.java:77)
	at io.undertow.security.handlers.NotificationReceiverHandler.handleRequest(NotificationReceiverHandler.java:50)
	at io.undertow.security.handlers.AbstractSecurityContextAssociationHandler.handleRequest(AbstractSecurityContextAssociationHandler.java:43)
	at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
	at org.wildfly.extension.undertow.security.jacc.JACCContextIdHandler.handleRequest(JACCContextIdHandler.java:61)
	at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
	at org.wildfly.extension.undertow.deployment.GlobalRequestControllerHandler.handleRequest(GlobalRequestControllerHandler.java:68)
	at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
	at io.undertow.servlet.handlers.ServletInitialHandler.handleFirstRequest(ServletInitialHandler.java:292)
	at io.undertow.servlet.handlers.ServletInitialHandler.access$100(ServletInitialHandler.java:81)
	at io.undertow.servlet.handlers.ServletInitialHandler$2.call(ServletInitialHandler.java:138)
	at io.undertow.servlet.handlers.ServletInitialHandler$2.call(ServletInitialHandler.java:135)
	at io.undertow.servlet.core.ServletRequestContextThreadSetupAction$1.call(ServletRequestContextThreadSetupAction.java:48)
	at io.undertow.servlet.core.ContextClassLoaderSetupAction$1.call(ContextClassLoaderSetupAction.java:43)
	at org.wildfly.extension.undertow.security.SecurityContextThreadSetupAction.lambda$create$0(SecurityContextThreadSetupAction.java:105)
	at org.wildfly.extension.undertow.deployment.UndertowDeploymentInfoService$UndertowThreadSetupAction.lambda$create$0(UndertowDeploymentInfoService.java:1508)
	at org.wildfly.extension.undertow.deployment.UndertowDeploymentInfoService$UndertowThreadSetupAction.lambda$create$0(UndertowDeploymentInfoService.java:1508)
	at org.wildfly.extension.undertow.deployment.UndertowDeploymentInfoService$UndertowThreadSetupAction.lambda$create$0(UndertowDeploymentInfoService.java:1508)
	at org.wildfly.extension.undertow.deployment.UndertowDeploymentInfoService$UndertowThreadSetupAction.lambda$create$0(UndertowDeploymentInfoService.java:1508)
	at org.wildfly.extension.undertow.deployment.UndertowDeploymentInfoService$UndertowThreadSetupAction.lambda$create$0(UndertowDeploymentInfoService.java:1508)
	at io.undertow.servlet.handlers.ServletInitialHandler.dispatchRequest(ServletInitialHandler.java:272)
	at io.undertow.servlet.handlers.ServletInitialHandler.access$000(ServletInitialHandler.java:81)
	at io.undertow.servlet.handlers.ServletInitialHandler$1.handleRequest(ServletInitialHandler.java:104)
	at io.undertow.server.Connectors.executeRootHandler(Connectors.java:326)
	at io.undertow.server.HttpServerExchange$1.run(HttpServerExchange.java:812)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
	at java.lang.Thread.run(Thread.java:748)
Caused by: java.lang.IllegalArgumentException: No query defined for that name [PartialHierarchyDisplay]
	at org.hibernate.jpa.spi.AbstractEntityManagerImpl.buildQueryFromName(AbstractEntityManagerImpl.java:753)
	at org.hibernate.jpa.spi.AbstractEntityManagerImpl.createNamedQuery(AbstractEntityManagerImpl.java:730)
	at org.jboss.as.jpa.container.AbstractEntityManager.createNamedQuery(AbstractEntityManager.java:376)
	at com.megchemsa.controller.employee.hierarchy.PartialHierarchyService.getPartialHierarchy(PartialHierarchyService.java:28)
	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.jboss.as.ee.component.ManagedReferenceMethodInterceptor.processInvocation(ManagedReferenceMethodInterceptor.java:52)
	at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:422)
	at org.jboss.invocation.InterceptorContext$Invocation.proceed(InterceptorContext.java:509)
	at org.jboss.as.weld.ejb.DelegatingInterceptorInvocationContext.proceed(DelegatingInterceptorInvocationContext.java:92)
	at org.jboss.weld.interceptor.proxy.WeldInvocationContext.interceptorChainCompleted(WeldInvocationContext.java:98)
	at org.jboss.weld.interceptor.proxy.WeldInvocationContext.proceed(WeldInvocationContext.java:117)
	at org.jboss.weld.probe.InvocationMonitor$InterceptorAction.proceed(InvocationMonitor.java:198)
	at org.jboss.weld.probe.InvocationMonitor$InterceptorAction.proceed(InvocationMonitor.java:194)
	at org.jboss.weld.probe.InvocationMonitor$Action.perform(InvocationMonitor.java:173)
	at org.jboss.weld.probe.InvocationMonitor.monitor(InvocationMonitor.java:139)
	at sun.reflect.GeneratedMethodAccessor35.invoke(Unknown Source)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at org.jboss.weld.interceptor.reader.SimpleInterceptorInvocation$SimpleMethodInvocation.invoke(SimpleInterceptorInvocation.java:73)
	at org.jboss.weld.interceptor.proxy.WeldInvocationContext.invokeNext(WeldInvocationContext.java:83)
	at org.jboss.weld.interceptor.proxy.WeldInvocationContext.proceed(WeldInvocationContext.java:115)
	at org.jboss.weld.bean.InterceptorImpl.intercept(InterceptorImpl.java:108)
	at org.jboss.as.weld.ejb.DelegatingInterceptorInvocationContext.proceed(DelegatingInterceptorInvocationContext.java:82)
	at org.jboss.as.weld.interceptors.EjbComponentInterceptorSupport.delegateInterception(EjbComponentInterceptorSupport.java:60)
	at org.jboss.as.weld.interceptors.Jsr299BindingsInterceptor.delegateInterception(Jsr299BindingsInterceptor.java:76)
	at org.jboss.as.weld.interceptors.Jsr299BindingsInterceptor.doMethodInterception(Jsr299BindingsInterceptor.java:88)
	at org.jboss.as.weld.interceptors.Jsr299BindingsInterceptor.processInvocation(Jsr299BindingsInterceptor.java:101)
	at org.jboss.as.ee.component.interceptors.UserInterceptorFactory$1.processInvocation(UserInterceptorFactory.java:63)
	at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:422)
	at org.jboss.as.ejb3.component.invocationmetrics.ExecutionTimeInterceptor.processInvocation(ExecutionTimeInterceptor.java:43)
	at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:422)
	at org.jboss.as.jpa.interceptor.SBInvocationInterceptor.processInvocation(SBInvocationInterceptor.java:47)
	at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:422)
	at org.jboss.as.ee.concurrent.ConcurrentContextInterceptor.processInvocation(ConcurrentContextInterceptor.java:45)
	at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:422)
	at org.jboss.invocation.InitialInterceptor.processInvocation(InitialInterceptor.java:40)
	at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:422)
	at org.jboss.invocation.ChainedInterceptor.processInvocation(ChainedInterceptor.java:53)
	at org.jboss.as.ee.component.interceptors.ComponentDispatcherInterceptor.processInvocation(ComponentDispatcherInterceptor.java:52)
	at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:422)
	at org.jboss.as.ejb3.component.pool.PooledInstanceInterceptor.processInvocation(PooledInstanceInterceptor.java:51)
	at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:422)
	at org.jboss.as.ejb3.tx.CMTTxInterceptor.invokeInOurTx(CMTTxInterceptor.java:275)
	... 184 more

Good day @vlad

Thanks for the reply.

I also now did all of the bellow with zero success as I now get the Cannot resolve query ‘PartialHierarchyDisplay’ at run time.

  1. Suppressed the warning in IntelliJ.
  2. Updated Hibernate in my Wildfly server to 5.2.16.FINAL as per: https://docs.jboss.org/hibernate/orm/5.2/topical/html_single/wildfly/Wildfly.html
  3. Compiled the app from within IntelliJ.
  4. Compiled the app from the command line using the latest maven release.
  5. Updated my PostgreSQL driver to 42.2.2

Please let me know if you require any other information that may assist you in please assisting me :slight_smile:

You sure it is not a problem of putting @NamedNativeQuery (and @SqlResultSetMapping) on a NOT @Entity class ?

That’s a good observation. The JPA annotations should be located on JPA entities not on EJB classes.

Good day @p3consulting, thanks for the information.

I am semi new to JPA + Hibernate so pardon the ignorance of the following question. Would adding the @Entity annotation not force JPA / Hibernate to want to create / test for the existence of an actual view / table in the DB?

@George_Labuschagne If you don’t want the schema to be generated, just set the hibernate.hbm2ddl.auto Hibernate configuration setting to none.

Yes the table existence will be checked at runtime… the creation can be turned off as Vlad told you.
In fact you should have @Stateful on a “service” not a domain entity…
looks like you are skipping a layer…
(an @Entity should also have @Table, @Id, … an empty constructor…)

1 Like

Thanks @vlad and @p3consulting it is working correctly now.

Your assistance and advise is most appreciated.

Kind regards,

George

1 Like