persistence@glassfish.java.net

RE: question on entity relation. - unidirectional

From: Eve Pokua <gorgeous65_at_msn.com>
Date: Thu, 13 Mar 2008 19:48:41 +0000

Hello,
 
Gordon,
 
Here is the tract:
 
 
Copying 1 file to C:\jee\STOCKINFOR2\STOCKINFOR2-app-client\distrun-tool:Can not insert details into DBjava.lang.NullPointerException at stockinfor2.NewItemsclient$enterListener.actionPerformed(NewItemsclient.java:115) at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:1995) at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2318) at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:387) at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:242) at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListener.java:236) at java.awt.Component.processMouseEvent(Component.java:6038) at javax.swing.JComponent.processMouseEvent(JComponent.java:3265) at java.awt.Component.processEvent(Component.java:5803) at java.awt.Container.processEvent(Container.java:2058) at java.awt.Component.dispatchEventImpl(Component.java:4410) at java.awt.Container.dispatchEventImpl(Container.java:2116) at java.awt.Component.dispatchEvent(Component.java:4240) at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4322) at java.awt.LightweightDispatcher.processMouseEvent(Container.java:3986) at java.awt.LightweightDispatcher.dispatchEvent(Container.java:3916) at java.awt.Container.dispatchEventImpl(Container.java:2102) at java.awt.Window.dispatchEventImpl(Window.java:2429) at java.awt.Component.dispatchEvent(Component.java:4240) at java.awt.EventQueue.dispatchEvent(EventQueue.java:599) at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:273) at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:183) at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:173) at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:168) at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:160) at java.awt.EventDispatchThread.run(EventDispatchThread.java:121)
 
I will look into this further.
 
eve


From: gordon.yorke_at_oracle.comTo: persistence_at_glassfish.dev.java.netDate: Thu, 13 Mar 2008 08:56:51 -0400Subject: RE: question on entity relation. - unidirectional



Eve,
   In your catch statement call ex.printStackTrace().
 
  }catch(Exception ex){ System.err.println("Can not insert new item details"); ex.printStackTrace(); }
--Gordon

-----Original Message-----From: Eve Pokua [mailto:gorgeous65_at_msn.com]Sent: Wednesday, March 12, 2008 7:36 PMTo: persistence_at_glassfish.dev.java.netSubject: RE: question on entity relation. - unidirectionalGordon, I didn't see your reply until now. I realy appreciate your help. It's always easy to retrieve datathan to insert data. Anyway, this is what I have:
public void createIteamdetails(String itmid,String itmname, String description, String colour, long price, String itemsize, long discount, String departid, String suppid, String delivid){ try{ Departmentent departmentent =new Departmentent(); departmentent=em.find(Departmentent.class, departid); Suppliercompanyent suppliercompanyent =new Suppliercompanyent(); suppliercompanyent=em.find(Suppliercompanyent.class, suppid); DeliveryCompanyent deliveryCompanyent =new DeliveryCompanyent(); deliveryCompanyent=em.find(DeliveryCompanyent.class, delivid); Stockinforent stockinforent=new Stockinforent();



  String deliverydate="23/02/07"; long stockquanity=56; Iteamdetailsent iteamdetailsent=new Iteamdetailsent();
   iteamdetailsent.setItmid(itmid); iteamdetailsent.setItmname(itmname); iteamdetailsent.setDescription(description); iteamdetailsent.setItmid(colour); iteamdetailsent.setPrice(price); iteamdetailsent.setItemsize(itemsize); iteamdetailsent.setDiscount(discount); iteamdetailsent.setDepartmentent(departmentent); stockinforent.setDeliverydate(deliverydate); stockinforent.setStockquanity(stockquanity); stockinforent.setSuppliercompanyent(suppliercompanyent); stockinforent.setDeliveryCompanyent(deliveryCompanyent); iteamdetailsent.setStockinforent(stockinforent); em.persist(iteamdetailsent); }catch(Exception ex){ System.err.println("Can not insert new item details"); } } No nothing is working. And the error msg I was talking about isn't errors just msgs as I deploy from the log file:[#|2008-03-12T23:17:37.937+0000|WARNING|sun-appserver9.1|javax.enterprise.system.tools.deployment|_ThreadID=14;_ThreadName=httpWorkerThread-4848-0;_RequestID=c8aa7afe-066a-47e6-aad7-d9bd15c373f9;|Error attempting to process extensions from the manifest of JAR file C:\Sun\SDK\domains\domain1\applications\j2ee-modules\STOCKINFOR2-app-client\swing-layout-1.0.3.jar; ignoring it and continuingjava.io.FileNotFoundException: C:\Sun\SDK\domains\domain1\applications\j2ee-modules\STOCKINFOR2-app-client\swing-layout-1.0.3.jar (The system cannot find the file specified) at java.util.zip.ZipFile.open(Native Method) at java.util.zip.ZipFile.<init>(ZipFile.java:114) at java.util.jar.JarFile.<init>(JarFile.java:133) at java.util.jar.JarFile.<init>(JarFile.java:97) at com.sun.enterprise.appclient.jws.ExtensionFileManager.findExtensionTransitiveClosure(ExtensionFileManager.java:240) at com.sun.enterprise.appclient.jws.AppclientJWSSupportInfo.findExtensions(AppclientJWSSupportInfo.java:1543) at com.sun.enterprise.appclient.jws.AppclientJWSSupportInfo.prepareAppclient(AppclientJWSSupportInfo.java:1384) at com.sun.enterprise.appclient.jws.AppclientJWSSupportInfo.prepareTopLevelAppclient(AppclientJWSSupportInfo.java:1323) at com.sun.enterprise.appclient.jws.AppclientJWSSupportInfo.startJWSServicesForAppclient(AppclientJWSSupportInfo.java:408) at com.sun.enterprise.appclient.jws.AppclientJWSSupportManager.handleApplicationClientEvent(AppclientJWSSupportManager.java:207) at com.sun.enterprise.server.event.ApplicationLoaderEventNotifier.notifyListeners(ApplicationLoaderEventNotifier.java:163) at com.sun.enterprise.server.ApplicationClientModuleLoader.notifyAppClientEvent(ApplicationClientModuleLoader.java:252) at com.sun.enterprise.server.ApplicationClientModuleLoader.doLoad(ApplicationClientModuleLoader.java:128) at com.sun.enterprise.server.AbstractLoader.load(AbstractLoader.java:244) at com.sun.enterprise.server.StandAloneAppClientModulesManager.moduleDeployed(StandAloneAppClientModulesManager.java:269) at com.sun.enterprise.server.StandAloneAppClientModulesManager.moduleDeployed(StandAloneAppClientModulesManager.java:127) at com.sun.enterprise.admin.event.AdminEventMulticaster.invokeModuleDeployEventListener(AdminEventMulticaster.java:974) at com.sun.enterprise.admin.event.AdminEventMulticaster.handleModuleDeployEvent(AdminEventMulticaster.java:961) at com.sun.enterprise.admin.event.AdminEventMulticaster.processEvent(AdminEventMulticaster.java:464) at com.sun.enterprise.admin.event.AdminEventMulticaster.multicastEvent(AdminEventMulticaster.java:176) at com.sun.enterprise.admin.server.core.DeploymentNotificationHelper.multicastEvent(DeploymentNotificationHelper.java:308) at com.sun.enterprise.deployment.phasing.DeploymentServiceUtils.multicastEvent(DeploymentServiceUtils.java:226) at com.sun.enterprise.deployment.phasing.ServerDeploymentTarget.sendStartEvent(ServerDeploymentTarget.java:298) at com.sun.enterprise.deployment.phasing.ApplicationStartPhase.runPhase(ApplicationStartPhase.java:132) 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.start(PEDeploymentService.java:591) at com.sun.enterprise.deployment.phasing.PEDeploymentService.start(PEDeploymentService.java:635) at com.sun.enterprise.admin.mbeans.ApplicationsConfigMBean.start(ApplicationsConfigMBean.java:744) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) And also the msg I print for my catch: run-tool:Can not insert details into DBCan not insert details into DBI really can't find any thing regarding this: Because you have mapped stockinforent as embedded within iteamdetailsent you will need to set stockinforent into iteamdetailsent through the @Embedded mapped attribute. Do you mean I need to place @embedded on the setStockinforent? @Embedded @AttributeOverrides({ @AttributeOverride(name="DELIVERYDATE" , column=_at_Column(name="sdeliverydate")), @AttributeOverride(name="STOCKQUAN" , column=_at_Column(name="sstockquanity")), @AttributeOverride(name="SID" , column=_at_Column(name="ssid")), @AttributeOverride(name="DELIVERYID" , column=_at_Column(name="sdelivid")) }) public Stockinforent getStockinforent(){ return stockinforent;} public void setStockinforent(Stockinforent stockinforent){ this.stockinforent=stockinforent;} Sorry about the indentation. SO as you can see there is no error for me to see why this' not working and I have tried using if statements to print results. but nothingexcept the catch msg. Thanking you. eve


From: gordon.yorke_at_oracle.comTo: persistence_at_glassfish.dev.java.netDate: Wed, 12 Mar 2008 15:38:49 -0400Subject: RE: question on entity relation. - unidirectional


Eve,
   What error do you get? Remove the line "em.persist(stockinforent); and see if that works better.
--Gordon

-----Original Message-----From: Eve Pokua [mailto:gorgeous65_at_msn.com]Sent: Wednesday, March 12, 2008 3:28 PMTo: persistence_at_glassfish.dev.java.netCc: ejb_at_glassfish.dev.java.netSubject: RE: question on entity relation. - unidirectionalGordon, No! the query I stated below does not work and I get this error I don't understand. But anywayI'll take your advice and look into this further. Thanks for your help eve


Date: Wed, 12 Mar 2008 08:38:05 -0400From: gordon.yorke_at_oracle.comTo: persistence_at_glassfish.dev.java.netSubject: Re: question on entity relation. - unidirectionalBecause you have mapped stockinforent as embedded within iteamdetailsent you will need to set stockinforent into iteamdetailsent through the @Embedded mapped attribute. I am surprised that you were able to call em.persist() on stockinforent without getting an error.--GordonEve Pokua wrote:


Hello Gordon, This is what I think may work: public void createIteamdetails(String itmid,String itmname, String description, String colour, long price, String itemsize, long discount, String departid, String suppid, String delivid){ Departmentent departmentent =new Departmentent(); departmentent=em.find(Departmentent.class, departid); Suppliercompanyent suppliercompanyent =new Suppliercompanyent(); suppliercompanyent=em.find(Suppliercompanyent.class, suppid); DeliveryCompanyent deliveryCompanyent =new DeliveryCompanyent(); deliveryCompanyent=em.find(DeliveryCompanyent.class, delivid); Stockinforent stockinforent=new Stockinforent(); String deliverydate="23/02/07"; long stockquanity=56; Iteamdetailsent iteamdetailsent=new Iteamdetailsent(); iteamdetailsent.setItmid(itmid); iteamdetailsent.setItmname(itmname); iteamdetailsent.setDescription(description); iteamdetailsent.setItmid(colour); iteamdetailsent.setPrice(price); iteamdetailsent.setItemsize(itemsize); iteamdetailsent.setDiscount(discount); iteamdetailsent.setDepartmentent(departmentent); stockinforent.setDeliverydate(deliverydate); stockinforent.setStockquanity(stockquanity); stockinforent.setSuppliercompanyent(suppliercompanyent); stockinforent.setDeliveryCompanyent(deliveryCompanyent); em.persist(iteamdetailsent); em.persist(stockinforent); } So how do I persist stockinforent in iteamdetailsent so the data ends in the samerecord? Sorry I hope this helps Thanks eve


From: gordon.yorke_at_oracle.comTo: persistence_at_glassfish.dev.java.netCC: ejb_at_glassfish.dev.java.netDate: Tue, 11 Mar 2008 10:15:06 -0400Subject: RE: question on entity relation. - unidirectional


Hello Eve,
   I am not sure what you are asking with this email. What query are you talking about? The code attached is not setting stockinforent into iteamdetailsent and it is not persisting the iteamdetailsent entity either did you leave that part out? Can you explain what you want to have happen and what is happening now?
--Gordon

-----Original Message-----From: Eve Pokua [mailto:gorgeous65_at_msn.com]Sent: Tuesday, March 11, 2008 9:34 AMTo: persistence_at_glassfish.dev.java.netCc: ejb_at_glassfish.dev.java.netSubject: RE: question on entity relation. - unidirectionalHello Gorgdon, everyone, Because Stockinforent is embedded within Iteamdetailsent both classes will be written to the same row in the same query.--GordonYes, I understood that and this is emphasised when I created the table.It is the query I am worried about. This is what I have done so far: Departmentent departmentent =new Departmentent(); departmentent=em.find(Departmentent.class, departid); Suppliercompanyent suppliercompanyent =new Suppliercompanyent(); suppliercompanyent=em.find(Suppliercompanyent.class, suppid); DeliveryCompanyent deliveryCompanyent =new DeliveryCompanyent(); deliveryCompanyent=em.find(DeliveryCompanyent.class, delivid); Stockinforent stockinforent; String deliverydate="23/02/07" long stockquanity=56; Iteamdetailsent iteamdetailsent=new Iteamdetailsent(itmid,itmname, description, colour, price, itemsize, discount, departmentent); stockinforent=new(deliverydate,stockquanity, suppliercompanyent, deliveryCompanyent); Or I may replace the above with the set methods. Sorry, if I didn't make myself clear with my previous email Thanking you eve


Date: Tue, 11 Mar 2008 08:53:49 -0400From: gordon.yorke_at_oracle.comTo: persistence_at_glassfish.dev.java.netCC: ejb_at_glassfish.dev.java.netSubject: Re: question on entity relation. - unidirectionalBecause Stockinforent is embedded within Iteamdetailsent both classes will be written to the same row in the same query.--GordonEve Pokua wrote:


Hello everyone, Regarding this Embeddable class: @Embeddablepublic class Stockinforent implements java.io.Serializable { @Column(name="DELIVERYDATE", nullable=false, length=35) private String deliverydate; @Column(name="STOCKQUAN", nullable=true, length=35) private Long stockquanity; @JoinColumn(name="sid") @ManyToOne private Suppliercompanyent suppliercompanyent; @JoinColumn(name="delivid") @ManyToOne private DeliveryCompanyent deliveryCompanyent;}The Stockinforent is an embeddable class inside Iteamdetailsent and it is also in relation to other entities as detailed above.To record a new record into the Iteamdetailsent table of the DB, I must have all and especially the ID of all relation entities.So how do I make sure both the new data for Iteamdetailsent and Stockinforent is entered into the DB at the same time( the data wouldbe for the same record). Im a little stack in here so any suggestion would be apprecaited. Thanks eve


From: gorgeous65_at_msn.comTo: persistence_at_glassfish.dev.java.netCC: ejb_at_glassfish.dev.java.netDate: Wed, 20 Feb 2008 21:55:57 +0000Subject: RE: question on entity relation. - unidirectional

Hello everyone, James/Gordon, Thank you all so much for your help. So for anybody learning just like me, I used Embeddable for Stockinforent which was embedded within Iteamdetailsent with AttributeOverrides as: @Embedded @AttributeOverrides({ @AttributeOverride(name="sid" , column=_at_Column(name="ssid")), @AttributeOverride(name="delivid" , column=_at_Column(name="sdelivid")) }) And everything is working good. Thanks eve


From: gorgeous65_at_msn.comTo: persistence_at_glassfish.dev.java.netCC: ejb_at_glassfish.dev.java.netDate: Wed, 20 Feb 2008 16:38:14 +0000Subject: RE: question on entity relation. - unidirectional

Hello James/Gordon, First of all, I would like to say thank you so much for your replies. <Could you include your current mapping annotations or XML for the twoclasses.> With regards to Stockinforent, this is how I relate to the other entities: public class Stockinforent implements java.io.Serializable { ...... @Id @Column(name = "ITMID", insertable=false, updatable=false) private String itmid; @OneToOne() @JoinColumn(name="ITMID") private Iteamdetailsent iteamdetailsent; @JoinColumn(name="sid") @ManyToOne private Suppliercompanyent suppliercompanyent; @JoinColumn(name="delivid") @ManyToOne private DeliveryCompanyent deliveryCompanyent;...... public Iteamdetailsent getIteamdetailsent(){ return this.iteamdetailsent;} public void setIteamdetailsent(Iteamdetailsent iteamdetailsent){ this.iteamdetailsent=iteamdetailsent; this.itmid = iteamdetailsent.getItmid();} public Suppliercompanyent getSuppliercompanyent(){ return this.suppliercompanyent;} public void setSuppliercompanyent(Suppliercompanyent suppliercompanyent){ this.suppliercompanyent=suppliercompanyent;} public DeliveryCompanyent getDeliveryCompanyent(){ return this.deliveryCompanyent;} public void setDeliveryCompanyent(DeliveryCompanyent deliveryCompanyent){ this.deliveryCompanyent=deliveryCompanyent;} ..........} How can I override entities as the get and set methods are of entity type If I understand what you mean: @Embedded
 @AttributeOverrides({
              @ManyToOne
       @AttributeOverride(name="sid" , column=_at_JoinColumn("ssid")),
     @AttributeOverride(name="delivid" , column=_at_JoinColumn("sdelivid"))})

:~) Or may be not?Thankseve
   

From: gordon.yorke_at_oracle.comTo: persistence_at_glassfish.dev.java.netDate: Wed, 20 Feb 2008 11:00:28 -0500Subject: RE: question on entity relation. - unidirectional


With regard to the exception, have you added the attribute overrides to the Entities that share the Stockinforent?
--Gordon

-----Original Message-----From: Eve Pokua [mailto:gorgeous65_at_msn.com]Sent: Wednesday, February 20, 2008 10:42 AMTo: persistence_at_glassfish.dev.java.netCc: ejb glassfishSubject: RE: question on entity relation. - unidirectionalHello, You are right and I've thought of that before. But all of my queries have a lot todo with Iteamdetailsent. And I have come so far with this project. Really, Stockinforent is actually part of Iteamdetailsent. I have divided it to give me a better control over the system. But may be I was wrong. eve


Date: Wed, 20 Feb 2008 08:51:21 -0500From: gordon.yorke_at_oracle.comTo: persistence_at_glassfish.dev.java.netCC: ejb_at_glassfish.dev.java.netSubject: Re: question on entity relation. - unidirectionalAre you using Attribute overrides for the other class Suppliercompanyent?To solve your initial problem you could always query on the "Stockinforent" instead of "Iteamdetailsent" and use the OneToOne reference to display the "Iteamdetailsent" details.-- GordonEve Pokua wrote:


Hello everyone, I tried to used embeddable class as below but then got some error: Descriptor Exceptions: ---------------------------------------------------------Exception [TOPLINK-93] (Oracle TopLink Essentials - 2.0 (Build b58g-fcs (09/07/2007))): oracle.toplink.essentials.exceptions.DescriptorExceptionException Description: The table [ITEMS] is not present in this descriptor.Descriptor: RelationalDescriptor(stockInformation.Suppliercompanyent --> [DatabaseTable(SUPPLIERS)])Runtime Exceptions: ---------------------------------------------------------Deployment error:The module has not been deployed.See the server log for details.The embeddable class is also in relation to another class. I'm kind of running outof ideas and would appreciate any suggestions. Unless I have to stick to bidirectional. Thanks eve


From: gorgeous65_at_msn.comTo: ejb_at_glassfish.dev.java.netCC: persistence_at_glassfish.dev.java.netDate: Mon, 18 Feb 2008 15:36:15 +0000Subject: RE: question on entity relation. - unidirectional

Hello everyone, I was doing a research on this and came across the following about embeddable class: http://www.theserverside.com/tt/articles/article.tss?l=MigratingJDBC Check the entity Accounts and ContactInformation: @Entity
@Table(name = "ACT")
public class Account implements java.io.Serializable {

    protected String userId;
    protected ContactInformation info;
   
    public Account () {}
    
    public Account (String userId, ContactInformation info) {
        this.userId = userId;
        this.info = info;
    }

    @Id
    @Column(name="USERID")
    public String getUserId() {
        return userId;
    }
    @Embedded
    public ContactInformation getContactInformation() {
        return info;
    }
   
   
    
   ...
   ...

}_at_Embeddable
@Table(name = "ACT")

public class ContactInformation implements java.io.Serializable {

    protected String telephone;
    protected String email;
    protected String familyName;
    protected String givenName;
    
    public ContactInformation() {}

    public ContactInformation(String familyName,
                String givenName,
                String telephone,
                String email){

        this.givenName = givenName;
        this.familyName = familyName;
        this.email = email;
        this.telephone = telephone;
       }

    @Column(name="FIRSTNAME")
    public String getGivenName(){
        return givenName;
    }

   ...
   ...


}
The above code was copied from: http://www.theserverside.com/tt/articles/article.tss?l=MigratingJDBC Could this be the answer to my problems. Instead, have two entities and then one table. Embeddedone entity in another, so there is no worries of relations. Then in a case liken this, I would display data usinga code as below: acount.contactInformation.telephone;acount.contactInformation.email;acount.contactInformation.familyName;acount.contactInformation.givenName; I'm I on the right track? Thanks eve


From: gorgeous65_at_msn.comTo: ejb_at_glassfish.dev.java.netCC: persistence_at_glassfish.dev.java.netDate: Mon, 18 Feb 2008 13:16:11 +0000Subject: question on entity relation. - unidirectional

hello everyone, I have two entities: public class Iteamdetailsent implements Serializable{ @Id @Column(name="ITMID", nullable=false, length=8) private String itmid; .... And public class Stockinforent implements java.io.Serializable { @Id @Column(name = "ITMID", insertable=false, updatable=false) private String itmid; @OneToOne() @JoinColumn(name="ITMID") private Iteamdetailsent iteamdetailsent; ..... Stockinforent does not required an ID of it's own so it is using Iteamdetailsent foriegn keyas it's id. Now I am also using the MVC to get and display data to client. Moreover, I amalso using displaytag as part of my design. Now, I am using a servlet to retrieve data from the entitiesand then forwarding data to a JSP to display to client. For example, in my display JSP: <display:table name="sessionScope.iteamdetailsent" ..> <display:column property="itmid" title=" Itemcode "/> <display:column property="itmname" sortable="true" headerClass="sortable" title=" Name "/> ...</display:table> Now, how do I display data or retrieve data of Stockinforent in relations to Iteamdetailsent?I am hoping that I won't have to use bi-directional entity relation, as it's so hard to maintain.Please, help. Thanks eve

Messenger on the move. Text MSN to 63463 now!

Think you know your TV, music and film? Try Search Charades!

Think you know your TV, music and film? Try Search Charades!

Messenger on the move. Text MSN to 63463 now!

Think you know your TV, music and film? Try Search Charades!

Think you know your TV, music and film? Try Search Charades!

Sounds like? How many syllables? Guess and win prizes with Search Charades!

Think you know your TV, music and film? Try Search Charades!

Messenger on the move. Text MSN to 63463 now!

Everything in one place. All new Windows Live!

Messenger on the move. Text MSN to 63463 now!
_________________________________________________________________
Who's friends with who and co-starred in what?
http://www.searchgamesbox.com/celebrityseparation.shtml