persistence@glassfish.java.net

RE: _at_IdClass issues

From: Eve Pokua <gorgeous65_at_msn.com>
Date: Thu, 26 Feb 2009 15:26:51 +0000

Gordon,

 

which class? The Orderlinementkey does contain the cusid:

 

Please be specific. I understand it's may be something small which I

can't see.

 

thanks eve

 

package stockInformation;

public class OrdlinementKey implements java.io.Serializable{
 private static final long serialVersionUID = 1L;

    private Long itmid;
 private Long cusid;
 private Long ordID;
 

 public OrdlinementKey(){}


 
   public Long getItmid(){
  return itmid;}

 public void setItmid(Long itmid){
  this.itmid=itmid;}

 public Long getCusid()
    {return cusid;}

    public void setCusid(Long cusid){
        this.cusid=cusid;
    }

 public Long getOrdID(){
  return ordID;}

 public void setOrdID(Long ordID){
  this.ordID=ordID;}
        
    @Override
      public int hashCode() {
            if (this. getOrdID() == null || this.getItmid() == null) {
                 return 0;
            } else {
                return (this. getOrdID().hashCode() ^ this.getItmid().hashCode());
               }
    }

    @Override
    public boolean equals(Object obj) {
        if (obj == null) {
            return false;
        }
        if (getClass() != obj.getClass()) {
            return false;
        }
        final OrdlinementKey other = (OrdlinementKey) obj;
        if (this.itmid != other.itmid && (this.itmid == null || !this.itmid.equals(other.itmid))) {
            return false;
        }
        if (this.cusid != other.cusid && (this.cusid == null || !this.cusid.equals(other.cusid))) {
            return false;
        }
        if (this.ordID != other.ordID && (this.ordID == null || !this.ordID.equals(other.ordID))) {
            return false;
        }
        return true;
    }
                   
        }


-----------------------------------------------------------

 

 

--------------------------------------------------------------

 

 

@IdClass(stockInformation.OrdlinementKey.class)
@Entity
@Table(name="ORDERLINE")
public class Ordlineent implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @Column(name = "ITEMID", nullable = false, insertable=false, updatable=false)
    private Long itmid;
    @Id
    @Column(name = "CUSID", nullable = false, insertable=false, updatable=false)
 private Long cusid;
    @Id
    @Column(name = "ORDID", nullable = false, insertable=false, updatable=false)
 private Long ordID;
    


    @ManyToOne(cascade = {CascadeType.ALL})
    @JoinColumn(name="ORDID")
    private Orderent orderent;

    @ManyToOne(cascade = {CascadeType.ALL})
    @JoinColumn(name="ITEMID")
    private Iteamdetailsent iteamdetailsent;

    @ManyToOne(cascade = {CascadeType.ALL})
    @JoinColumn(name="CUSID")
    private Customerent customerent;

    @Column(name="QUANTITY", nullable=true)
    private Long quanity;


    public Long getItmid(){
  return itmid;}

 public void setItmid(Long itmid){
  this.itmid=itmid;}


 public Long getCusid()
    {return cusid;}

    public void setCusid(Long cusid){
        this.cusid=cusid;
    }


 public Long getOrdID(){
  return ordID;}

 public void setOrdID(Long ordID){
  this.ordID=ordID;}

 


    public Orderent getOrderent() {
        return orderent;
    }

    public void setOrderent(Orderent orderent) {
        this.orderent = orderent;
    }

    public Iteamdetailsent getIteamdetailsent() {
        return iteamdetailsent;
    }

    public void setIteamdetailsent(Iteamdetailsent iteamdetailsent) {
        this.iteamdetailsent = iteamdetailsent;
    }
    public Customerent getCustomerent() {
        return customerent;
    }

    public void setCustomerent(Customerent customerent) {
        this.customerent = customerent;
    }

    public Long getQuanity() {
        return quanity;
    }

    public void setQuanity(Long quanity) {
        this.quanity = quanity;
    }
                         @Override
    public String toString() {
        return "stockInformation.Ordlineent[id=" + itmid + "]";
    }

}

 

 

-----------------------------

 

Thanks eve
 


Date: Wed, 25 Feb 2009 22:40:25 -0400
From: gordon.yorke_at_oracle.com
To: persistence_at_glassfish.dev.java.net
CC: users_at_glassfish.dev.java.net; ejb_at_glassfish.dev.java.net
Subject: Re: @IdClass issues

Your PKClass is missing the cusID
--Gordon

Eve Pokua wrote:


Hello everyone,
 
I am having problems creating an IdClass. I get the following errors:
 
[#|2009-02-26T00:06:06.435+0000|SEVERE|sun-appserver9.1|javax.enterprise.system.tools.deployment|_ThreadID=38;_ThreadName=Thread-127;_RequestID=01812ccb-53b3-4d7e-bafe-5a688d407eb3;|Exception occured in J2EEC Phase
com.sun.enterprise.deployment.backend.IASDeploymentException: Exception [TOPLINK-28018] (Oracle TopLink Essentials - 2.0 (Build b58g-fcs (09/07/2007))): oracle.toplink.essentials.exceptions.EntityManagerSetupException
Exception Description: predeploy for PersistenceUnit [STOCKINFOR2-ejbPU] failed.
Internal Exception: Exception [TOPLINK-7150] (Oracle TopLink Essentials - 2.0 (Build b58g-fcs (09/07/2007))): oracle.toplink.essentials.exceptions.ValidationException
Exception Description: Invalid composite primary key specification. The names of the primary key fields or properties in the primary key class [stockInformation.OrdlinementKey] and those of the entity bean class [class stockInformation.Ordlineent] must correspond and their types must be the same. Also, ensure that you have specified id elements for the corresponding attributes in XML and/or an @Id on the corresponding fields or properties of the entity class.
 at oracle.toplink.essentials.internal.ejb.cmp3.EntityManagerSetupImpl.predeploy(EntityManagerSetupImpl.java:643)
 at oracle.toplink.essentials.ejb.cmp3.EntityManagerFactoryProvider.createContainerEntityManagerFactory(EntityManagerFactoryProvider.java:244)
 at com.sun.jdo.spi.persistence.support.ejb.ejbc.PersistenceProcessor.loadPersistenceUnitBundle(PersistenceProcessor.java:512)
 at com.sun.jdo.spi.persistence.support.ejb.ejbc.PersistenceProcessor.createTablesInDB(PersistenceProcessor.java:353)
 at com.sun.jdo.spi.persistence.support.ejb.ejbc.PersistenceProcessor.processAppBundle(PersistenceProcessor.java:219)
 at com.sun.jdo.spi.persistence.support.ejb.ejbc.PersistenceProcessor.processApplication(PersistenceProcessor.java:146)
 at com.sun.jdo.spi.persistence.support.ejb.ejbc.DeploymentEventListenerImpl.processApplication(DeploymentEventListenerImpl.java:211)
 at com.sun.jdo.spi.persistence.support.ejb.ejbc.DeploymentEventListenerImpl.processEvent(DeploymentEventListenerImpl.java:172)
 at com.sun.jdo.spi.persistence.support.ejb.ejbc.DeploymentEventListenerImpl.notifyDeploymentEvent(DeploymentEventListenerImpl.java:122)
 at com.sun.enterprise.deployment.backend.DeploymentEventManager.notifyDeploymentEvent(DeploymentEventManager.java:79)
 at com.sun.enterprise.deployment.backend.AppDeployer.postDeploy(AppDeployer.java:392)
 at com.sun.enterprise.deployment.backend.AppDeployer.deploy(AppDeployer.java:251)
 at com.sun.enterprise.deployment.backend.AppDeployer.doRequestFinish(AppDeployer.java:148)
 at com.sun.enterprise.deployment.phasing.J2EECPhase.runPhase(J2EECPhase.java:191)
 at com.sun.enterprise.deployment.phasing.DeploymentPhase.executePhase(DeploymentPhase.java:108)
 at com.sun.enterprise.deployment.phasing.PEDeploymentService.executePhases(PEDeploymentService.java:919)
 at com.sun.enterprise.deployment.phasing.PEDeploymentService.deploy(PEDeploymentService.java:279)
 at com.sun.enterprise.deployment.phasing.PEDeploymentService.deploy(PEDeploymentService.java:788)
 at com.sun.enterprise.management.deploy.DeployThread.deploy(DeployThread.java:187)
 at com.sun.enterprise.management.deploy.DeployThread.run(DeployThread.java:223)
|#]
 
I have attached the files for your convenience. As you may notice, I have been
messing around with it trying to get it right. Orderlineent is the entity of the breakdown of many to many
relationship for Order & Items and Customer. So Orderlineent does not have and Id of it's own that's why
I need the IdClass.
 
Please, help. I can't figure out why this error and can't deploy it.
 
Thanks
 
eve
 



Share your photos with Windows Live Photos - Free Try it Now!
_________________________________________________________________
Windows Live Messenger just got better .Video display pics, contact updates & more.
http://www.download.live.com/messenger