[EJB 3.0] - BUG: Composite Primary Key
by lihuoming
I'm running Jboss4.2.0
Composite Primary Key Class:
package com.foshanshop.ejb3.bean;
| import java.io.Serializable;
| import javax.persistence.Column;
| import javax.persistence.Embeddable;
|
| @SuppressWarnings("serial")
| @Embeddable
| public class AirtLinePK implements Serializable {
| private String leavecity;
| private String arrivecity;
|
| public AirtLinePK(){}
|
| public AirtLinePK(String leavecity, String arrivecity) {
| this.leavecity = leavecity;
| this.arrivecity = arrivecity;
| }
|
| @Column(nullable=false,length=3,name="LEAVECITY")
| public String getLeavecity() {
| return leavecity;
| }
| public void setLeavecity(String leavecity) {
| this.leavecity = leavecity;
| }
|
| @Column(nullable=false,length=3,name="ARRIVECITY")
| public String getArrivecity() {
| return arrivecity;
| }
| public void setArrivecity(String arrivecity) {
| this.arrivecity = arrivecity;
| }
|
| public boolean equals(Object o) {
| if (this == o) return true;
| if (!(o instanceof AirtLinePK)) return false;
|
| final AirtLinePK airtLinePK = (AirtLinePK) o;
|
| if (!leavecity.equals(airtLinePK.getLeavecity())) return false;
| if (!arrivecity.equals(airtLinePK.getArrivecity())) return false;
| return true;
|
| }
| public int hashCode() {
| int result;
| result = leavecity.hashCode();
| result = 29 * result + arrivecity.hashCode();
| return result;
| }
| }
package com.foshanshop.ejb3.bean;
| import java.io.Serializable;
| import java.util.HashSet;
| import java.util.Set;
| import javax.persistence.CascadeType;
| import javax.persistence.EmbeddedId;
| import javax.persistence.Entity;
| import javax.persistence.FetchType;
| import javax.persistence.OneToMany;
| import javax.persistence.OrderBy;
| import javax.persistence.Table;
|
| @SuppressWarnings("serial")
| @Entity
| @Table(name = "AirLine")
| public class AirLine implements Serializable {
|
| private AirtLinePK id;
| private Boolean onoff;
|
| public AirLine(){}
|
| public AirLine(AirtLinePK id, Boolean onoff){
| this.id = id;
| this.onoff = onoff;
| }
|
| @EmbeddedId
| public AirtLinePK getId() {
| return id;
| }
| public void setId(AirtLinePK id) {
| this.id = id;
| }
|
| public Boolean getOnoff() {
| return onoff;
| }
|
| public void setOnoff(Boolean onoff) {
| this.onoff = onoff;
| }
| }
Session bean:
package com.foshanshop.ejb3.impl;
| import javax.ejb.Remote;
| import javax.ejb.Stateless;
| import javax.persistence.EntityManager;
| import javax.persistence.PersistenceContext;
| import javax.persistence.Query;
| import com.foshanshop.ejb3.AirLineDAO;
| import com.foshanshop.ejb3.bean.AirLine;
| import com.foshanshop.ejb3.bean.AirtLinePK;
|
| @Stateless
| @Remote ({AirLineDAO.class})
| public class AirLineDAOBean implements AirLineDAO {
| @PersistenceContext
| protected EntityManager em;
|
| public Long getAirLineTotal() {
| Query query = em.createQuery("select count(a) from AirLine a where a.id.leavecity =?1 and a.id.arrivecity=?2");
| query.setParameter(1, "PEK");
| query.setParameter(2, "CAN");
| return query.getSingleResult();
| }
| }
Jboss Log print Error:
anonymous wrote : 2007-04-12 21:03:24,031 DEBUG [org.hibernate.util.JDBCExceptionReporter] could not execute query [select count((airline0_.LEAVECITY, airline0_.ARRIVECITY)) as col_0_0_ from AirLine airline0_ where airline0_.LEAVECITY=? and airline0_.ARRIVECITY=?]
| java.sql.SQLException: Operand should contain 1 column(s)
| at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:2975)
| at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1600)
| at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:1695)
| at com.mysql.jdbc.Connection.execSQL(Connection.java:3004)
| at com.mysql.jdbc.PreparedStatement.executeInternal(PreparedStatement.java:1128)
| at com.mysql.jdbc.PreparedStatement.executeQuery(PreparedStatement.java:1222)
above code run in Toplink, it work fine
I am using following code in jboss,it work fine:
Query query = em.createQuery("select count(a.id.leavecity) from AirLine a where a.id.leavecity =?1 and a.id.arrivecity=?2");
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4036712#4036712
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4036712
19 years
[JBoss Seam] - Re: Jboss 5 Beta2 and JBoss Seam 1.2.1GA
by gressho
Hello,
after following the instructions in the manual and additionally adding the commons-digester-1.6.jar and commons-beanutils-1.7.0.jar to the ear and application.xml
it all reduces to the following error:
| 12:25:29,235 ERROR [[/miami]] Exception sending context initialized event to listener instance of class org.jboss.seam.servlet.SeamListener
| java.lang.NullPointerException
| at org.jboss.seam.init.Initialization.installComponents(Initialization.java:835)
| at org.jboss.seam.init.Initialization.init(Initialization.java:503)
| at org.jboss.seam.servlet.SeamListener.contextInitialized(SeamListener.java:33)
| at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:3854)
| at org.apache.catalina.core.StandardContext.start(StandardContext.java:4361)
| at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:761)
| at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:741)
| at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:553)
| 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:585)
| at org.apache.tomcat.util.modeler.BaseModelMBean.invoke(BaseModelMBean.java:297)
| at org.jboss.mx.server.RawDynamicInvoker.invoke(RawDynamicInvoker.java:164)
| at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:668)
| at org.apache.catalina.core.StandardContext.init(StandardContext.java:5312)
| at org.jboss.web.tomcat.service.deployers.TomcatDeployment.performDeployInternal(TomcatDeployment.java:298)
| at org.jboss.web.tomcat.service.deployers.TomcatDeployment.performDeploy(TomcatDeployment.java:138)
| at org.jboss.web.deployers.AbstractWarDeployment.start(AbstractWarDeployment.java:367)
| at org.jboss.web.deployers.WebModule.startModule(WebModule.java:104)
| at org.jboss.web.deployers.WebModule.start(WebModule.java:80)
| 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:585)
| 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:184)
| at $Proxy0.start(Unknown Source)
| at org.jboss.system.microcontainer.StartStopLifecycleAction.installAction(StartStopLifecycleAction.java:42)
| at org.jboss.system.microcontainer.ServiceControllerContextAction.install(ServiceControllerContextAction.java:46)
| at org.jboss.dependency.plugins.AbstractControllerContextActions.install(AbstractControllerContextActions.java:51)
| at org.jboss.dependency.plugins.AbstractControllerContext.install(AbstractControllerContext.java:233)
| at org.jboss.system.microcontainer.ServiceControllerContext.install(ServiceControllerContext.java:238)
| at org.jboss.dependency.plugins.AbstractController.install(AbstractController.java:724)
| at org.jboss.dependency.plugins.AbstractController.incrementState(AbstractController.java:445)
| at org.jboss.dependency.plugins.AbstractController.resolveContexts(AbstractController.java:555)
| at org.jboss.dependency.plugins.AbstractController.resolveContexts(AbstractController.java:489)
| at org.jboss.dependency.plugins.AbstractController.change(AbstractController.java:335)
| at org.jboss.dependency.plugins.AbstractController.change(AbstractController.java:205)
| at org.jboss.system.ServiceController.doChange(ServiceController.java:656)
| at org.jboss.system.ServiceController.start(ServiceController.java:431)
| at org.jboss.system.deployers.ServiceDeployer.start(ServiceDeployer.java:142)
| at org.jboss.system.deployers.ServiceDeployer.deploy(ServiceDeployer.java:103)
| at org.jboss.system.deployers.ServiceDeployer.deploy(ServiceDeployer.java:46)
| at org.jboss.deployers.plugins.deployers.helpers.AbstractSimpleRealDeployer.deploy(AbstractSimpleRealDeployer.java:56)
| at org.jboss.deployers.plugins.deployer.AbstractSimpleDeployer.commitDeploy(AbstractSimpleDeployer.java:52)
| at org.jboss.deployers.plugins.deployer.DeployerWrapper.commitDeploy(DeployerWrapper.java:170)
| at org.jboss.deployers.plugins.deployment.MainDeployerImpl.commitDeploy(MainDeployerImpl.java:592)
| at org.jboss.deployers.plugins.deployment.MainDeployerImpl.process(MainDeployerImpl.java:476)
| at org.jboss.deployers.plugins.deployment.MainDeployerImpl.process(MainDeployerImpl.java:406)
| 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:585)
| at org.jboss.aop.joinpoint.MethodInvocation.invokeTarget(MethodInvocation.java:121)
| at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:110)
| at org.jboss.profileservice.aop.MainDeployerAspect.process(MainDeployerAspect.java:53)
| at org.jboss.aop.advice.org.jboss.profileservice.aop.MainDeployerAspect_z_process_1791140146.invoke(MainDeployerAspect_z_process_1791140146.java)
| at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
| at AOPContainerProxy$0.process(AOPContainerProxy$0.java)
| at org.jboss.system.server.profileservice.ProfileServiceBootstrap.loadProfile(ProfileServiceBootstrap.java:371)
| at org.jboss.system.server.profileservice.ProfileServiceBootstrap.bootstrap(ProfileServiceBootstrap.java:247)
| at org.jboss.kernel.plugins.bootstrap.AbstractBootstrap.run(AbstractBootstrap.java:89)
| at org.jboss.system.server.profileservice.ServerImpl.doStart(ServerImpl.java:403)
| at org.jboss.system.server.profileservice.ServerImpl.start(ServerImpl.java:342)
| at org.jboss.Main.boot(Main.java:210)
| at org.jboss.Main$1.run(Main.java:522)
| at java.lang.Thread.run(Thread.java:595)
| 12:25:29,239 ERROR [StandardContext] Error listenerStart
| 12:25:29,239 ERROR [StandardContext] Context [/miami] startup failed due to previous errors
| 12:25:29,487 WARN [config] Unable to process deployment descriptor for context 'null'
|
I think, the warnings regarding anonymous wrote : vfsfile problems can be safely ignored,
but how can I deal with the mentioned error?
Thanks
Werner
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4036708#4036708
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4036708
19 years