ejb@glassfish.java.net

printing composite/foreign keys in the client

From: Eve Pokua <gorgeous65_at_msn.com>
Date: Mon, 13 Aug 2007 16:20:59 +0100

Hello everyone,I wonder if somebody could provide me with some help.First of all I have two entities relating to each other:public class Iteamdetailsent implements Serializable{.................... @ManyToOne() @JoinColumn(name="DeptID") private Departmentent departmentent;}relating to:public class Departmentent implements java.io.Serializable{..._at_OneToMany(mappedBy="departmentent") private Collection <Iteamdetailsent> iteamdetailsent;...}In the client when I print details as follows:for(Iteamdetailhlp itemlist: iteamdetailhlp){ out.println("<TR>"); out.println("<td>");out.println(itemlist.getitmid());out.println("</td>"); out.println("<td>");out.println(itemlist.getitmname());out.println("</td>"); out.println("<td>");out.println(itemlist.getdescription());out.println("</td>"); out.println("<td>");out.println(itemlist.getitemsize());out.println("</td>"); out.println("<td>");out.println(itemlist.getcolour());out.println("</td>"); out.println("<td>");out.println(itemlist.getprice());out.println("</td>"); out.println("<td>");out.println( itemlist.getDeptID());out.println("</td>"); ...........}The Iteamdetailhlp is a helper classBut this last column gives me a null:out.println("<td>");out.println(itemlist.getprice());out.println("</td>");
                                             
out.println("<td>");out.println(
itemlist.getDeptID());out.println("</td>");Itemcode
Name
Description
Size
Colour
Price




4547887


iris


table


17in


red


1.20


null




5456865


protey


asdf


52in


sdf


5.00


null




5468679


opara


table


16in


pink


12.00


null




5475686


asdf


asdf


12inch


white


1.02


null
Why is this?In the log file I get this:[#|2007-08-13T15:50:10.603+0100|INFO|sun-appserver-pe9.0|javax.enterprise.system.stream.out|_ThreadID=15;_ThreadName=httpWorkerThread-8080-1;|All Items:|#]Secondly, i have 3 entities relating to each other. To resolve many to many relationship and from my understanding of DB, I created and entity for composition, containing all the primary keys of all three entities as follows:public class Iteamdetailsent implements Serializable{ @Id @Column(name="ITMID", nullable=false) private String itmid;................}public class Customerent implements Serializable { @Id @Column(name="CUSID", nullable=false) private String cusid; ..................}public class CollOrdersrement implements java.io.Serializable{ @Id @Column(name="CollORDID", nullable=false) private String collOrdID;............}with the composite keys defined in the following class: public class CollOrdline implements java.io.Serializable{ private String itmid; private String cusid; private String collOrdID; public CollOrdline(){} @Id public String getitmid(){ return itmid;} public void setitmid(String itmid){ this.itmid=itmid;} @Id //_at_Column(name = "CollORDID", nullable = false, insertable = false, updatable = false) public String getcollOrdID(){ return collOrdID;} public void setcollOrdID(String collOrdID){ this.collOrdID=collOrdID;} @Id public String getcusid() {return cusid;} public void setcusid(String cusid){ this.cusid=cusid; }Now when I try to retrieve data from CollOrdline as below:try{ InitialContext ctx=new InitialContext(); //call the interface collOrdlinerem=(CollOrdlinerem)ctx.lookup("CollOrdersrementJNDI"); String sbc="1"; String rest; collOrdline=collOrdlinerem.Collpoinordid(sbc); rest=collOrdline.getcollOrdID(); System.out.print(rest); }catch(Exception ex){ System.err.println("Can not show the collection point order"); }I get a null with the following message in my log file:[#|2007-08-13T16:18:36.993+0100|INFO|sun-appserver-pe9.0|javax.enterprise.system.stream.out|_ThreadID=15;_ThreadName=httpWorkerThread-8080-1;|null|#]I believe, this has something to do with the way I have specified the relationships. How do I resolve this issue?Any suggestion will be greatly appreciated.Thankseve
_________________________________________________________________
Feel like a local wherever you go with BackOfMyHand.com
http://www.backofmyhand.com