users@glassfish.java.net

RE: _at_IdClass issues

From: Eve Pokua <gorgeous65_at_msn.com>
Date: Fri, 27 Feb 2009 19:04:18 +0000

 According to this site its this build:

 

http://www.eclipse.org/eclipselink/downloads/

 

Is this the latest build:

 

EclipseLink 1.0.2 Download

 

If not please, send me a link site and I will download and install it. Thanks

 

eve

 

 
> Date: Fri, 27 Feb 2009 13:23:50 -0500
> From: christopher.delahunt_at_oracle.com
> To: persistence_at_glassfish.dev.java.net
> Subject: Re: @IdClass issues
>
> Hello Eve,
>
> My first statement was that you could do that if you were using the
> latest version of EclipseLink. TopLink Essentials from 09/07/2007 will
> not support JPA 2.0 features.
>
> Try EclipseLink if you can. If you cannot, in pure JPA 1.0 you have to
> have 2 mappings in order to use database pk fields in relationships,
> entities must also map them with a basic mapping. So you had to have 2
> mappings to the same database field, and had to mark one of them as
> read-only (insertable+writable=false).
>
> So, what you were attempting:
> @IdClass(stockInformation.OrdlinementKey.class)
> @Entity
> @Table(name="ORDERLINE")
> public class Ordlineent implements Serializable {
> @Id
> @Column(name="ORDID", insertable=false, updatable=false)
> private Long orderent;
> @Id
> @Column(name="CUSID", insertable=false, updatable=false)
> private Long customerent;
> @Id
> @Column(name="ITMID", insertable=false, updatable=false)
> private Long itmId;
>
> // OR, instead of the above basic mappings, you can use your IDClass as
> an embeddible. To do so, remove the above from your Class, and also
> remove the @IdClass annotation
> // mark the pkclass as embeddable, and uncomment the following:
> //_at_EmbeddableId
> //_at_AttributeOverrides({
> // @AttributeOverride(name="itmId" , column=_at_Column(name="ITMID",
> insertable=false, updatable=false)),
> // @AttributeOverride(name="cusId" ,
> column=_at_Column(name="CUSID", insertable=false, updatable=false)),
> // @AttributeOverride(name="ordId" ,
> column=_at_Column(name="ORDID, insertable=false, updatable=false"))
> // })
> //OrdlinementKey idclass;
>
>
> @ManyToOne(cascade = {CascadeType.ALL})
> @JoinColumn(name="ORDID")
> private Orderent orderent;
>
> @ManyToOne(cascade = {CascadeType.ALL})
> @JoinColumn(name="ITMID")
> private Iteamdetailsent iteamdetailsent;
>
> @ManyToOne(cascade = {CascadeType.ALL})
> @JoinColumn(name="CUSID")
> private Customerent customerent;
> }
>
>
>
>
> Eve Pokua wrote:
> > Chris,
> >
> > Thank you for the help and sorry for the trouble. I tried your
> > suggestions and got
> > the following error:
> >
> > private Orderent orderent;
> > private Iteamdetailsent iteamdetailsent;
> > private Customerent customerent;
> >
> >
> > ------------------------------------------------------
> > And
> >
> > ------------------------------------------------------
> >
> > private Long orderent;
> > private Long customerent;
> > private Long iteamdetailsent;
> >
> >
> > ----------------------------------------
> > Verify results:
> >
> >
> > running Test validity of EJB 3.0 persistence unit. This test tests
> > validity using a portable persistence provider. Please refer to EJB
> > 3.0 Persistence API Specification for further information.
> > For [ STOCKINFOR2#STOCKINFOR2-ejb.jar#STOCKINFOR2-ejbPU ]
> > 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.
> >
> > ------------------------------------
> >
> > Delpoyment error:
> >
> > moduleID=STOCKINFOR2
> > deployment started : 0%
> > deployment finished : 100%
> > Deploying application in domain completed successfully
> > Trying to create reference for application in target server completed
> > successfully
> > Trying to start application in target server completed successfully
> > Error occurred during application loading phase. The application will
> > not run properly. Please fix your application and redeploy.
> > WARNING: com.sun.enterprise.deployment.backend.IASDeploymentException:
> > Error while loading application [STOCKINFOR2]. Please refer to the
> > server log for more details.
> > Enable of STOCKINFOR2 in target server completed successfully
> > Enable of application in all targets completed successfully
> > All operations completed successfully
> > post-run-deploy:
> > run-deploy:
> > BUILD SUCCESSFUL (total time: 7 seconds)
> >
> >
> > --
> >
> > Caused by: 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.exceptions.ValidationException.invalidCompositePKSpecification(ValidationException.java:1017)
> > at
> > oracle.toplink.essentials.internal.ejb.cmp3.metadata.MetadataValidator.throwInvalidCompositePKSpecification(MetadataValidator.java:210)
> > at
> > oracle.toplink.essentials.internal.ejb.cmp3.metadata.accessors.ClassAccessor.validatePrimaryKey(ClassAccessor.java:1505)
> > at
> > oracle.toplink.essentials.internal.ejb.cmp3.metadata.accessors.ClassAccessor.process(ClassAccessor.java:501)
> > at
> > oracle.toplink.essentials.internal.ejb.cmp3.metadata.MetadataProcessor.processAnnotations(MetadataProcessor.java:240)
> > at
> > oracle.toplink.essentials.ejb.cmp3.persistence.PersistenceUnitProcessor.processORMetadata(PersistenceUnitProcessor.java:370)
> > at
> > oracle.toplink.essentials.internal.ejb.cmp3.EntityManagerSetupImpl.predeploy(EntityManagerSetupImpl.java:607)
> > ... 71 more
> > |#]
> > [#|2009-02-27T17:58:05.942+0000|WARNING|sun-appserver9.1|javax.enterprise.system.core|_ThreadID=18;_ThreadName=httpWorkerThread-4848-0;STOCKINFOR2;_RequestID=833eb276-4c88-4b9d-b69f-c0b3b93179a8;|CORE5021:
> > Application NOT loaded: [STOCKINFOR2]|#]
> > [#|2009-02-27T17:58:05.944+0000|WARNING|sun-appserver9.1|javax.enterprise.system.tools.admin|_ThreadID=18;_ThreadName=httpWorkerThread-4848-0;Error
> > while loading application [STOCKINFOR2]. Please refer to the server
> > log for more details.
> > ;_RequestID=833eb276-4c88-4b9d-b69f-c0b3b93179a8;|ADM1075:Error on
> > listening event:[Error while loading application [STOCKINFOR2]. Please
> > refer to the server log for more details. ]|#]
> >
> > According to the error this' my build:
> >
> > Internal Exception: Exception [TOPLINK-7150] (Oracle TopLink
> > Essentials - 2.0 (Build b58g-fcs (09/07/2007))):
> > oracle.toplink.essentials.exceptions.ValidationException
> >
> >
> > Im using netbeans 6.5.
> > Thanking you
> >
> > eve
> >
> > > Date: Fri, 27 Feb 2009 10:01:01 -0500
> > > From: christopher.delahunt_at_oracle.com
> > > To: persistence_at_glassfish.dev.java.net
> > > Subject: Re: @IdClass issues
> > >
> > > Hello Eve,
> > >
> > > You should really clean up the code as it is very difficult to see what
> > > you have tried and what is currently causing the problem with so much
> > > code commented out. I can't see what you are trying to accomplish
> > when the
> > > //_at_EmbeddedId
> > > //private OrdlinementKey ordlinementKey;
> > > is commented out, as is the OrdlinementKey's //_at_Embeddable annotation.
> > > You also have a floating @EmbeddedId annotation in OrdlinementKey
> > > complete with attribute overrides that seem to float on the toString
> > > method.
> > >
> > > If you are just trying to use many-to-one relationships in your primary
> > > key, if you are using the latest EclipseLink build you can use the new
> > > Derived Id JPA 2.0 feature. This allows you to mark the @ManyToOne
> > > relations with the @Id tag and just get rid of the extra EmbeddedId or
> > > basic mappings. ie:
> > >
> > > @IdClass(stockInformation.OrdlinementKey.class)
> > > @Entity
> > > @Table(name="ORDERLINE")
> > > public class Ordlineent implements Serializable {
> > > @Id
> > > @ManyToOne(cascade = {CascadeType.ALL})
> > > @JoinColumn(name="ORDID")
> > > private Orderent orderent;
> > >
> > > @ManyToOne(cascade = {CascadeType.ALL})
> > > @JoinColumn(name="ITMID")
> > > private Iteamdetailsent iteamdetailsent;
> > >
> > > @ManyToOne(cascade = {CascadeType.ALL})
> > > @JoinColumn(name="CUSID")
> > > private Customerent customerent;
> > > }
> > >
> > > Your Id class would need to change slightly just to reflect that the
> > > attribute names need to be orderent, iteamdetailsent and customerent
> > > instead of ordID etc. ie:
> > > public class OrdlinementKey implements java.io.Serializable{
> > > private Long orderent;
> > > private Long customerent;
> > > private Long orderent;
> > > }
> > >
> > > Regards,
> > > Chris
> > >
> > > Eve Pokua wrote:
> > > > Thanks Gordon,
> > > >
> > > > I've attached the files. yes, i did get the errors but i corrected
> > > > it before
> > > > delying again. but in the tables, i've multiples.
> > > >
> > > > thanks
> > > >
> > > > eve
> > > >
> > > >
> > ------------------------------------------------------------------------
> > > > Date: Fri, 27 Feb 2009 09:30:16 -0400
> > > > From: gordon.yorke_at_oracle.com
> > > > To: persistence_at_glassfish.dev.java.net
> > > > Subject: Re: @IdClass issues
> > > >
> > > > I would have to see your code. In TopLink I would expect a multiple
> > > > writable mapping exception if you had multiple mappings that wrote to
> > > > the same field.
> > > > --Gordon
> > > >
> > > > Eve Pokua wrote:
> > > >
> > > > Thanks Gordon.
> > > >
> > > > Using Embeddable & embeddedId works. i can deploy this. however,
> > > > attributes are writing twice in the tables of the database. how
> > > > do i resolve this?
> > > > I thought I could resolve it with attributesoverrides but it does
> > > > not work.
> > > >
> > > > Any help on EmbeddId?
> > > >
> > > > Thanks
> > > >
> > > > eve
> > > >
> > > >
> > ------------------------------------------------------------------------
> > > > Date: Thu, 26 Feb 2009 11:29:07 -0400
> > > > From: gordon.yorke_at_oracle.com <mailto:gordon.yorke_at_oracle.com>
> > > > To: persistence_at_glassfish.dev.java.net
> > > > <mailto:persistence_at_glassfish.dev.java.net>
> > > > Subject: Re: @IdClass issues
> > > >
> > > > In the source that was attached to your previous email the cusid
> > > > attribute of the Key was commented out.
> > > > --Gordon
> > > >
> > > > Eve Pokua wrote:
> > > >
> > > > Gordon,
> > > >
> > > > which class? The Orderl/inementkey 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 <mailto:gordon.yorke_at_oracle.com>
> > > > To: persistence_at_glassfish.dev.java.net
> > > > <mailto:persistence_at_glassfish.dev.java.net>
> > > > CC: users_at_glassfish.dev.java.net
> > > > <mailto:users_at_glassfish.dev.java.net>;
> > > > ejb_at_glassfish.dev.java.net <mailto: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!
> > > >
> > <http://www.microsoft.com/uk/windows/windowslive/products/messenger.aspx>
> > > >
> > > >
> > > >
> > ------------------------------------------------------------------------
> > > > Share your photos with Windows Live Photos - Free Try it Now!
> > > >
> > <http://www.microsoft.com/uk/windows/windowslive/products/messenger.aspx>
> > > >
> > > >
> > > >
> > ------------------------------------------------------------------------
> > > > Windows Live Hotmail just got better. Find out more!
> > > >
> > <http://www.microsoft.com/uk/windows/windowslive/products/hotmail.aspx>
> > > >
> > > >
> > > >
> > ------------------------------------------------------------------------
> > > > Share your photos with Windows Live Photos – Free Find out more!
> > > > <http://clk.atdmt.com/UKM/go/132630768/direct/01/>
> >
> >
> > ------------------------------------------------------------------------
> > Share your photos with Windows Live Photos – Free Try it Now!
> > <http://www.microsoft.com/uk/windows/windowslive/products/messenger.aspx>

_________________________________________________________________
Love Hotmail?  Check out the new services from Windows Live!
http://clk.atdmt.com/UKM/go/132630768/direct/01/