Hello Everyone,
I am trying to call stored procedure using Hibenate and JPA Entity Manager. I am utilizing annotations and the whole application is using Struts+Spring+ Hibernate combination. The database is Informix11.5. In the class mentioned below I created a NamedNativeQuery with query name="packageList". The stored procedure I am trying to call is "get_QQPackages(?,:STATE) RETURNING int, char(200)" If I call the same procedure in informix I get the result set. But when I deploy the war file with the code mentioned below in my app-server(jboss-5.1) during the deployment time itself I am getting the "org.hibernate.cfg.NotYetImplementedException". The stored procedure is supposed to returns me the list with int and corresponding String values.
Here is the code:
import java.math.BigDecimal; import java.sql.Date; import java.sql.Timestamp;
import javax.persistence.Column; import javax.persistence.EmbeddedId; import javax.persistence.Entity; import javax.persistence.NamedNativeQuery; import javax.persistence.QueryHint; import javax.persistence.Table;
/** * The persistent class for the emp database table. * */ @Entity @Table(name = "emp") @NamedNativeQuery(name = "packageList", query = "{call get_QQPackages(?,:STATE) RETURNING int, char(200)}", hints = {@QueryHint(name = "org.hibernate.callable", value = "true"), @QueryHint(name = "org.hibernate.readOnly", value = "true") } ) public class EMP{ private static final long serialVersionUID = 1L; private Date classlimit; private BigDecimal classcollrate; private BigDecimal classotcrate; private String clerkname; private Timestamp clerkdate; private int classdedamt;
@EmbeddedId protected EmpPK pk; public EMP(){ }
@Column(nullable = false) public Date getClasslimit() { return this.classlimit; }
public void setClasslimit(Date classlimit) { this.classlimit = classlimit; }
@Column(nullable = false, precision = 7, scale = 3) public BigDecimal getClasscollrate() { return this.classcollrate; }
public void setClasscollrate(BigDecimal classcollrate) { this.classcollrate = classcollrate; }
@Column(nullable = false, precision = 7, scale = 3) public BigDecimal getClassotcrate() { return this.classotcrate; }
public void setClassotcrate(BigDecimal classotcrate) { this.classotcrate = classotcrate; }
@Column(length = 8) public String getClerkname() { return this.clerkname; }
public void setClerkname(String clerkname) { this.clerkname = clerkname; }
public Timestamp getClerkdate() { return this.clerkdate; }
public void setClerkdate(Timestamp clerkdate) { this.clerkdate = clerkdate; }
public int getClassdedamt() { return classdedamt; }
public void setClassdedamt(int classdedamt) { this.classdedamt = classdedamt; }
public EmpPK getPk() { return pk; }
public void setPk(EmpPK pk) { this.pk = pk; }
}
Here is the code which I am using to call that namednativequery: try { Query query = getEntityManager().createNamedQuery("packageList"); query.setParameter("STATE",state); logger.info("got the package list"); return query.getResultList(); // return result; } catch (RuntimeException re) { logger.error("getting the package list failed", re); throw re; }
Here is the snap shot of the exceptions:
13:44:00,690 ERROR [ContextLoader] Context initialization failed org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in ServletContext resource [/WEB-INF/applicationContext.xml]: Invocation of init method failed; nested exception is org.hibernate.cfg.NotYetImplementedException: Pure native scalar queries are not yet supported at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1338) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:473) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory$1.run(AbstractAutowireCapableBeanFactory.java:409) at java.security.AccessController.doPrivileged(Native Method) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:380) at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:264) at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222) at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:261) at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:185) at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:164) at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:423) at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:728) at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:380) at org.springframework.web.context.ContextLoader.createWebApplicationContext(ContextLoader.java:255) at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:199) at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:45) at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:3910) at org.apache.catalina.core.StandardContext.start(StandardContext.java:4393) at org.jboss.web.tomcat.service.deployers.TomcatDeployment.performDeployInternal(TomcatDeployment.java:367) at org.jboss.web.tomcat.service.deployers.TomcatDeployment.performDeploy(TomcatDeployment.java:146) at org.jboss.web.deployers.AbstractWarDeployment.start(AbstractWarDeployment.java:460) at org.jboss.web.deployers.WebModule.startModule(WebModule.java:118) at org.jboss.web.deployers.WebModule.start(WebModule.java:96) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:597) at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:157) at org.jboss.mx.server.Invocation.dispatch(Invocation.java:96) at org.jboss.mx.server.Invocation.invoke(Invocation.java:88) at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:264) at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:668) at org.jboss.system.microcontainer.ServiceProxy.invoke(ServiceProxy.java:206) at $Proxy36.start(Unknown Source) at org.jboss.system.microcontainer.StartStopLifecycleAction.installAction(StartStopLifecycleAction.java:42) at org.jboss.system.microcontainer.StartStopLifecycleAction.installAction(StartStopLifecycleAction.java:37) at org.jboss.dependency.plugins.action.SimpleControllerContextAction.simpleInstallAction(SimpleControllerContextAction.java:62) at org.jboss.dependency.plugins.action.AccessControllerContextAction.install(AccessControllerContextAction.java:71) at org.jboss.dependency.plugins.AbstractControllerContextActions.install(AbstractControllerContextActions.java:51) at org.jboss.dependency.plugins.AbstractControllerContext.install(AbstractControllerContext.java:348) at org.jboss.system.microcontainer.ServiceControllerContext.install(ServiceControllerContext.java:286) at org.jboss.dependency.plugins.AbstractController.install(AbstractController.java:1598) at org.jboss.dependency.plugins.AbstractController.incrementState(AbstractController.java:934) at org.jboss.dependency.plugins.AbstractController.resolveContexts(AbstractController.java:1062) at org.jboss.dependency.plugins.AbstractController.resolveContexts(AbstractController.java:984) at org.jboss.dependency.plugins.AbstractController.change(AbstractController.java:822) at org.jboss.dependency.plugins.AbstractController.change(AbstractController.java:553) at org.jboss.system.ServiceController.doChange(ServiceController.java:688) at org.jboss.system.ServiceController.start(ServiceController.java:460) at org.jboss.system.deployers.ServiceDeployer.start(ServiceDeployer.java:146) at org.jboss.system.deployers.ServiceDeployer.deploy(ServiceDeployer.java:104) at org.jboss.system.deployers.ServiceDeployer.deploy(ServiceDeployer.java:45) at org.jboss.deployers.spi.deployer.helpers.AbstractSimpleRealDeployer.internalDeploy(AbstractSimpleRealDeployer.java:62) at org.jboss.deployers.spi.deployer.helpers.AbstractRealDeployer.deploy(AbstractRealDeployer.java:50) at org.jboss.deployers.plugins.deployers.DeployerWrapper.deploy(DeployerWrapper.java:171) at org.jboss.deployers.plugins.deployers.DeployersImpl.doDeploy(DeployersImpl.java:1439) at org.jboss.deployers.plugins.deployers.DeployersImpl.doInstallParentFirst(DeployersImpl.java:1157) at org.jboss.deployers.plugins.deployers.DeployersImpl.doInstallParentFirst(DeployersImpl.java:1178) at org.jboss.deployers.plugins.deployers.DeployersImpl.install(DeployersImpl.java:1098) at org.jboss.dependency.plugins.AbstractControllerContext.install(AbstractControllerContext.java:348) at org.jboss.dependency.plugins.AbstractController.install(AbstractController.java:1598) at org.jboss.dependency.plugins.AbstractController.incrementState(AbstractController.java:934) at org.jboss.dependency.plugins.AbstractController.resolveContexts(AbstractController.java:1062) at org.jboss.dependency.plugins.AbstractController.resolveContexts(AbstractController.java:984) at org.jboss.dependency.plugins.AbstractController.change(AbstractController.java:822) at org.jboss.dependency.plugins.AbstractController.change(AbstractController.java:553) at org.jboss.deployers.plugins.deployers.DeployersImpl.process(DeployersImpl.java:781) at org.jboss.deployers.plugins.main.MainDeployerImpl.process(MainDeployerImpl.java:545) at org.jboss.system.server.profileservice.ProfileServiceBootstrap.loadProfile(ProfileServiceBootstrap.java:304) at org.jboss.system.server.profileservice.ProfileServiceBootstrap.start(ProfileServiceBootstrap.java:205) at org.jboss.bootstrap.AbstractServerImpl.start(AbstractServerImpl.java:405) at org.jboss.Main.boot(Main.java:209) at org.jboss.Main$1.run(Main.java:547) at java.lang.Thread.run(Thread.java:619) Caused by: org.hibernate.cfg.NotYetImplementedException: Pure native scalar queries are not yet supported at org.hibernate.cfg.annotations.QueryBinder.bindNativeQuery(QueryBinder.java:118) at org.hibernate.cfg.AnnotationBinder.bindQueries(AnnotationBinder.java:277) at org.hibernate.cfg.AnnotationBinder.bindClass(AnnotationBinder.java:417) at org.hibernate.cfg.AnnotationConfiguration.processArtifactsOfType(AnnotationConfiguration.java:498) at org.hibernate.cfg.AnnotationConfiguration.secondPassCompile(AnnotationConfiguration.java:277) at org.hibernate.cfg.Configuration.buildMappings(Configuration.java:1115) at org.hibernate.ejb.Ejb3Configuration.buildMappings(Ejb3Configuration.java:1269) at org.hibernate.ejb.EventListenerConfigurator.configure(EventListenerConfigurator.java:150) at org.hibernate.ejb.Ejb3Configuration.configure(Ejb3Configuration.java:888) at org.hibernate.ejb.Ejb3Configuration.configure(Ejb3Configuration.java:416) at org.hibernate.ejb.HibernatePersistence.createContainerEntityManagerFactory(HibernatePersistence.java:126)
I am stuck and I dont know what to do. Please help me what should I do. Please do let me know if this is the right approach to call the storedprocedure or not?
|