persistence@glassfish.java.net

Re: printing composite/foreign keys in the client

From: Marina Vatkina <Marina.Vatkina_at_Sun.COM>
Date: Mon, 20 Aug 2007 11:58:46 -0700

Hello Eve,

I'm glad that you were able to figure it out. Keep us posted.

Regards,
-marina

Eve Pokua wrote:
> Hello everyone,
>
> Marina,
>
> Don't be confuse anymore. I have made changes to my project and everything
> is working now. I will also tidy up my work. See below for details
> All items:
> Itemcode Name Description Size Colour Price
> 4547887 iris table 17in red 1.20 BC Bargain Corner
> 5456865 protey asdf 52in sdf 5.00 CP Collection Point
> 5468679 opara table 16in pink 12.00 BC Bargain Corner
> 5475686 asdf asdf 12inch white 1.02 CP Collection Point
> 564646 asdf yop 14in red 1.30 SS Self-Serve
> 564798 asdf red 8in grey 14.00 CP Collection Point
>
>
> I still have issues with the other composite one but I think I have to
> take time
> and resolve that one. I will update people on this.
>
> Thanks for your help Marina.
>
> eve
>
> > Date: Fri, 17 Aug 2007 17:25:53 -0700
> > From: Marina.Vatkina_at_Sun.COM
> > To: persistence_at_glassfish.dev.java.net
> > CC: ejb_at_glassfish.dev.java.net
> > Subject: Re: printing composite/foreign keys in the client
> >
> > Eve,
> >
> > I'm still confused about your problem... Iteamdetailhlp's constructor
> doesn't
> > populate the departmentent field, so it's null. What is the exact
> problem that
> > you are facing?
> >
> > Now, what is the purpose of creating the copy of the iteamdetailsent
> instead of
> > just returning the entities from the query? If you do need a copy,
> why can't you
> > store the result of getDepartment() there (or whatever your latest
> method name is)?
> >
> > And one more - in your latest code you have both, the department
> field and the
> > depid. Do you really need both? How do you keep them in sync if you do?
> >
> > thanks,
> > -marina
> >
> > Eve Pokua wrote:
> > > Marina,
> > >
> > > I forgot to paste in my implementation side of this:
> > >
> > > //To retrieve all items
> > > public List<Iteamdetailhlp> AllItems(){
> > > List<Iteamdetailsent> iteamdetailsent=null;
> > >
> > > try{
> > >
> iteamdetailsent=(List<Iteamdetailsent>)em.createNamedQuery("GetAllItems").getResultList();
> > >
> > > return copyToDetails(iteamdetailsent);
> > > }catch (Exception ex) {
> > > throw new EJBException(ex);
> > > }
> > > }//end of AllItems
> > >
> > > And also from the Query from Iteamdetailsent:
> > >
> > > @NamedQuery(name = "GetAllItems",query = "SELECT i FROM
> Iteamdetailsent i"),
> > >
> > >
> > > THanks
> > >
> > > eve
> > >
> > >
> > >
> > >
> > >
> ------------------------------------------------------------------------
> > > From: gorgeous65_at_msn.com
> > > To: persistence_at_glassfish.dev.java.net
> > > CC: ejb_at_glassfish.dev.java.net
> > > Date: Fri, 17 Aug 2007 23:59:21 +0100
> > > Subject: RE: printing composite/foreign keys in the client
> > >
> > >
> > > Marina,
> > >
> > > Thanks for your reply.
> > >
> > > I make still trying to work it out. Below is my helping class to my
> > > Iteamdetailsent
> > > package StockInformation;
> > >
> > > *import java.io.Serializable;*
> > > *public class Iteamdetailhlp implements Serializable{*
> > > *
> > > private String itmid;
> > > private String itmname;
> > > private String description;
> > > private String colour;
> > > private String price;
> > > private String itemsize;
> > > private String depid;
> > > private String Discount;
> > >
> > > private Departmentent departmentent;*
> > >
> > > * public Iteamdetailhlp(){
> > > }
> > > public Iteamdetailhlp(String itmid, String itmname, String
> > > description, String itemsize, String colour, String price){
> > > this.itmid=itmid;
> > > this.itmname=itmname;
> > > this.description=description;
> > > this.itemsize=itemsize;
> > > this.colour=colour;
> > > this.price=price;
> > > //this.departmentent=departmentent;
> > > }*
> > > *
> > >
> > > public String getitmid(){
> > > return itmid;}
> > >
> > > public void setitmid(String itmid){
> > > this.itmid=itmid;}
> > >
> > >
> > > public String getitmname(){
> > > return itmname;}
> > >
> > > public void setitmname(String itmname){
> > > this.itmname=itmname;}
> > > *
> > > * public String getdescription(){
> > > return description;}
> > >
> > > public void setdescription(String description){
> > > this.description=description;}*
> > > * public String getcolour(){
> > > return colour;}
> > >
> > > public void setcolour(String colour){
> > > this.colour=colour;}*
> > >
> > > * public String getprice(){
> > > return price;}
> > >
> > > public void setprice(String price){
> > > this.price=price;}*
> > > * public String getitemsize(){
> > > return itemsize;}
> > >
> > > public void setitemsize(String itemsize){
> > > this.itemsize=itemsize;}*
> > > * public String getDeptID(){
> > > return depid;}
> > >
> > > public Departmentent getDeptID2(){
> > > return departmentent;}
> > >
> > > public void setDeptID(String depid){
> > > this.depid=depid;}
> > >
> > > public String getDiscount(){
> > > return Discount;}
> > >
> > > public void setDiscount(String Discount){
> > > this.Discount=Discount;}
> > >
> > > public String toString() {
> > > String s = itmid + " " + itmname +" " + description + "
> > > "+ itemsize + " " + colour + " " + price + " " + departmentent;*
> > > * return s;
> > > }*
> > > *}*
> > >
> > >
> > > ANd within the client I am using the helper class to retrieve
> > > details to print it up.
> > >
> > > *try{
> > > InitialContext ctx=new InitialContext();
> > > Iteamdetails
> > > iteamdetails=(Iteamdetails)ctx.lookup("IteamdetailsBeanJNDI");
> > > iteamdetailhlp=iteamdetails.AllItems();
> > >
> > > List<Iteamdetailsent>
> > > iteamdetailsent=iteamdetails.DeptItems2();
> > > out.println("<TABLE BORDER='1'
> > > CELLPADDING='3' CELLSPACING='1'>");
> > > out.println("<TR>");
> > > out.println("<td>"
> > > +"Itemcode");out.println("<td>" +"Name"); out.println("<td>"
> > > +"Description"); out.println("<td>" +"Size"); out.println("<td>"
> > > +"Colour");out.println("<td>" +"Price");out.println("</td>");
> > > out.println("</TR>");
> > >
> > >
> > >
> > > 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.getDeptID2());out.println("</td>");
> > > *
> > > **
> > > *}*
> > >
> > > It would have worked if I was using Iteamdetailsent to print the
> > > above details But since
> > > I am using the helper class and the relationship is not established
> > > properly, so is the null
> > > result.
> > >
> > > I hope you understand what I am saying.
> > >
> > > The other issue I will bring it up later.
> > >
> > > Thank you.
> > >
> > > eve
> > >
> > > Below is
> > > > Date: Fri, 17 Aug 2007 13:52:08 -0700
> > > > From: Marina.Vatkina_at_Sun.COM
> > > > To: persistence_at_glassfish.dev.java.net
> > > > CC: ejb_at_glassfish.dev.java.net
> > > > Subject: Re: printing composite/foreign keys in the client
> > > >
> > > > Eve,
> > > >
> > > > Now I'm confused...
> > > >
> > > >
> > >
> out.println("<td>");out.println(itemlist.getDeptID());out.println("</td>")
> > > >
> > > > will print the department (if Department class has toString()
> > > method - otherwise
> > > > it'll print it's hashcode).
> > > >
> > > > So what else is not working?
> > > >
> > > > thanks,
> > > > -marina
> > > >
> > > > Eve Pokua wrote:
> > > > >
> > > > > Hello everyone,
> > > > >
> > > > > I believe I have identitied where this problem lies especailly
> > > between my
> > > > > and
> > > > >
> > > > >
> > > > >
> > > > > In my client, I am using my helper class (Iteamdetailhlp) to print
> > > > > details from the database.
> > > > >
> > > > > try{
> > > > > InitialContext ctx=new InitialContext();
> > > > > Iteamdetails
> > > > > iteamdetails=(Iteamdetails)ctx.lookup("IteamdetailsBeanJNDI");
> > > > >
> > > > > iteamdetailhlp=iteamdetails.BargainCornItems(barconr);
> > > > >
> > > > >
> > > > > out.println("<TABLE BORDER='1' CELLPADDING='3'
> > > > > CELLSPACING='1'>");
> > > > > out.println("<TR>");
> > > > > out.println("<td>"
> > > > > +"Itemcode");out.println("<td>" +"Name"); out.println("<td>"
> > > > > +"Description"); out.println("<td>" +"Size"); out.println("<td>"
> > > > > +"Colour");out.println("<td>" +"Price");out.println("</td>");
> > > > > out.println("</TR>");
> > > > >
> > > > >
> > > > > for(Iteamdetailhlp itemlist: iteamdetailhlp){
> > > > >
> > > > > out.println("<TR>");
> > > > > out.println("<form method='get'
> > > > > action='AllItemsser'>");
> > > > >
> > > > >
> > > > >
> > >
> 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>");
> > > > > out.println("</td>");
> > > > >
> > > > >
> > > > > But I was having issues linking the helper class to the
> > > > > my Departmentent,
> > > > >
> > > > > So this would not work:
> > > > >
> > > > > public String toString() {
> > > > > String s = itmid + " " + itmname +" " + description + " "+
> > > > > itemsize + " " + colour + " " + price + " " + departmentent;
> > > > > return s;
> > > > > }
> > > > >
> > > > > This is why the departmentent above in the toString() does not work
> > > > > because, there is
> > > > > no relationship between this class the related class. However, my
> > > > > entity class (Iteamdetailsent)
> > > > > is mapped and related to the Departmentent entity.
> > > > >
> > > > > How do I go about this? Any ideas?
> > > > >
> > > > > Thanks
> > > > >
> > > > > eve
> > > > >
> > > > >
> > > > >
> > >
> ------------------------------------------------------------------------
> > > > > From: gorgeous65_at_msn.com
> > > > > To: persistence_at_glassfish.dev.java.net
> > > > > CC: ejb_at_glassfish.dev.java.net
> > > > > Date: Thu, 16 Aug 2007 15:52:11 +0100
> > > > > Subject: RE: printing composite/foreign keys in the client
> > > > >
> > > > > Hello everyone,
> > > > >
> > > > > I have made changes to methods of my classes. I understand this
> > > > > mistake was causing some
> > > > > confusion. Please, see attached.
> > > > >
> > > > > Thanks
> > > > >
> > > > > eve
> > > > >
> > > > >
> > > > >
> > >
> ------------------------------------------------------------------------
> > > > > From: gorgeous65_at_msn.com
> > > > > To: persistence_at_glassfish.dev.java.net
> > > > > CC: ejb_at_glassfish.dev.java.net
> > > > > Date: Thu, 16 Aug 2007 12:38:59 +0100
> > > > > Subject: RE: printing composite/foreign keys in the client
> > > > >
> > > > > hi,
> > > > >
> > > > > > Iteamdetailsent.toString()
> > > > >
> > > > > I believe this is what you are talking about:
> > > > >
> > > > > public String toString() {
> > > > > String s = itmid + ' ' + itmname +' ' + description +
> > > > > ' '+ itemsize + ' ' + colour + ' ' + price + ' ' +
> > > > > departmentent;
> > > > >
> > > > > return s;
> > > > > }
> > > > >
> > > > > it is mapped at the being of the class:
> > > > >
> > > > > @ManyToOne()
> > > > > @JoinColumn(name='DeptID')
> > > > > private Departmentent departmentent;
> > > > >
> > > > > although, I am not sure if I should map these as well:
> > > > >
> > > > > public Departmentent getDeptID(){
> > > > > return departmentent;}
> > > > >
> > > > > public void setDeptID(Departmentent departmentent){
> > > > > this.departmentent=departmentent;}
> > > > >
> > > > > This is all in the Iteamdetailsent class
> > > > >
> > > > >
> > > > > I will make more changes and see if it works.
> > > > >
> > > > > Thanks
> > > > >
> > > > > eve
> > > > >
> > > > >
> > > > >
> > > > >
> > > > > > Date: Wed, 15 Aug 2007 19:38:58 -0700
> > > > > > From: Marina.Vatkina_at_Sun.COM
> > > > > > To: persistence_at_glassfish.dev.java.net
> > > > > > CC: ejb_at_glassfish.dev.java.net
> > > > > > Subject: Re: printing composite/foreign keys in the client
> > > > > >
> > > > > > Eve,
> > > > > >
> > > > > > Eve Pokua wrote:
> > > > > > > Thanks Marina,
> > > > > > >
> > > > > > > I will try and clean them up as much as possible. I have
> > > > > commented most
> > > > > > > out for testing. Just a few questions:
> > > > > > >
> > > > > > > b) You current example prints the departmentent object ref.
> > > > > Does it
> > > > > > > print null?
> > > > > > >
> > > > > > > Are you refering this to the client AllItem??
> > > > > >
> > > > > > Iteamdetailsent.toString()
> > > > > >
> > > > > > >
> > > > > > > > d) Your properties are not capitalized in CollOrdline -
> > > > > that's not a
> > > > > > > JavaBean style.
> > > > > > >
> > > > > > > Sorry! Do you mean I have to state the mothods or variable?
> > > > > capital?
> > > > > > > Please, explain yourself. I am still learning or I might
> > > > > have ignore
> > > > > > > certain java styles.
> > > > > > > Bear with me please.
> > > > > >
> > > > > > JavaBean style properties mean having getFoo/setFoo methods
> > > > > to represent
> > > > > > property named 'foo'.
> > > > > >
> > > > > > >
> > > > > > > e) 'iteamdetailsent' is not initialized - are you sure you
> > > > > set it up?
> > > > > > >
> > > > > > > which of the client are you refering to?? AllItem?/
> > > > > >
> > > > > > Departmentent. It's not only that the client will be creating
> > > > > new instances, but
> > > > > > the JPA provider as well.
> > > > > >
> > > > > > HTH,
> > > > > > -marina
> > > > > >
> > > > > >
> > > > > > > Thanks
> > > > > > >
> > > > > > > eve
> > > > > > >
> > > > > > >
> > > > > > >
> > > > > > > > Date: Tue, 14 Aug 2007 12:52:40 -0700
> > > > > > > > From: Marina.Vatkina_at_Sun.COM
> > > > > > > > To: persistence_at_glassfish.dev.java.net
> > > > > > > > CC: ejb_at_glassfish.dev.java.net
> > > > > > > > Subject: Re: printing composite/foreign keys in the client
> > > > > > > >
> > > > > > > > Eve,
> > > > > > > >
> > > > > > > > Can you cleanup your example? This is a quick list of
> > > > > things that can
> > > > > > > or cannot
> > > > > > > > affect the results, but will make the example(s) easier
> > > > > to read:
> > > > > > > >
> > > > > > > > a) There are too many commented out lines so it's not
> > > > > clear if you
> > > > > > > used them for
> > > > > > > > testing or not.
> > > > > > > > b) You current example prints the departmentent object
> > > > > ref. Does it
> > > > > > > print null?
> > > > > > > > c) Your CollOrdlinementKey has other fields besides ids -
> > > > > if they are
> > > > > > > not used,
> > > > > > > > please remove them.
> > > > > > > > d) Your properties are not capitalized in CollOrdline -
> > > > > that's not a
> > > > > > > JavaBean style.
> > > > > > > > e) 'iteamdetailsent' is not initialized - are you sure
> > > > > you set it up?
> > > > > > > TLE caches
> > > > > > > > objects as-is, so if you didn't set that relationship, it
> > > > > will be
> > > > > > > null until you
> > > > > > > > refresh the instance.
> > > > > > > >
> > > > > > > > thanks,
> > > > > > > > -marina
> > > > > > > >
> > > > > > > > Eve Pokua wrote:
> > > > > > > > > Marina,
> > > > > > > > >
> > > > > > > > > I have attached the Iteamdetailsent and Department in a
> > > > > zip file.
> > > > > > > > > And I have also attached CollOrdline with the client.
> > > > > Please, feel free
> > > > > > > > > to edit them. Or maybe I didn't make use of
> > > > > 'bidirectional entity
> > > > > > > > > persistence relations'. How do I specified this type of
> > > > > relation in my
> > > > > > > > > entities? Or maybe I
> > > > > > > > > did not map my getmethods well. Whatever, the reason, I
> > > > > would
> > > > > > > > > appreciate any help.
> > > > > > > > >
> > > > > > > > > There is an IdClass in my composite entity
> > > > > CollOrderline. I have
> > > > > > > > > attached this as well. There was an issue about this
> > > > > some time ago and
> > > > > > > > > I do believe I have done it right but maybe I'm wrong.
> > > > > Please, feel
> > > > > > > > > free to edit this as well.
> > > > > > > > >
> > > > > > > > > here is an example:
> > > > > > > > >
> > > > > > > > >
> > > > > > > > > StUDENT
> > > > > > > > >
> > > > > > > > >
> > > > > > > > > sid
> > > > > > > > >
> > > > > > > > >
> > > > > > > > > fname
> > > > > > > > >
> > > > > > > > >
> > > > > > > > > surname
> > > > > > > > >
> > > > > > > > >
> > > > > > > > > Course
> > > > > > > > >
> > > > > > > > >
> > > > > > > > > cid
> > > > > > > > >
> > > > > > > > > discription
> > > > > > > > >
> > > > > > > > >
> > > > > > > > > ENROLMENT
> > > > > > > > >
> > > > > > > > >
> > > > > > > > > sid
> > > > > > > > >
> > > > > > > > >
> > > > > > > > > cid
> > > > > > > > >
> > > > > > > > >
> > > > > > > > >
> > > > > > > > >
> > > > > > > > > Thanks
> > > > > > > > >
> > > > > > > > > eve
> > > > > > > > >
> > > > > > > > > > Date: Mon, 13 Aug 2007 10:14:46 -0700
> > > > > > > > > > From: Marina.Vatkina_at_Sun.COM
> > > > > > > > > > To: persistence_at_glassfish.dev.java.net
> > > > > > > > > > CC: ejb_at_glassfish.dev.java.net
> > > > > > > > > > Subject: Re: printing composite/foreign keys in the
> > > > > client
> > > > > > > > > >
> > > > > > > > > > Eve,
> > > > > > > > > >
> > > > > > > > > > I do not see getDeptID() method on Iteamdetailsent.
> > > > > Do you map
> > > > > > > the FK
> > > > > > > > > twice,
> > > > > > > > > > once as a relationship and another time as a field?
> > > > > > > > > >
> > > > > > > > > > Also, CollOrdline does not define an @IdClass - is it
> > > > > a typo?
> > > > > > > > > >
> > > > > > > > > > thanks,
> > > > > > > > > > -marina
> > > > > > > > > >
> > > > > > > > > > Eve Pokua wrote:
> > > > > > > > > > > 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{
> > > > > > > > > > > ...
> > > > > > > > > > > @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 class
> > > > > > > > > > >
> > > > > > > > > > > But 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.
> > > > > > > > > > >
> > > > > > > > > > > Thanks
> > > > > > > > > > >
> > > > > > > > > > > eve
> > > > > > > > > > >
> > > > > > >
> > > > > > >
> > > > >
> > >
> ------------------------------------------------------------------------
> > > > > > > Are you the Quizmaster? Play BrainBattle with a friend now!
> > > > > > > <http://specials.uk.msn.com/brainbattle>
> > > > >
> > > > >
> > >
> ------------------------------------------------------------------------
> > > > > The next generation of MSN Hotmail has arrived - Windows Live
> > > > > Hotmail <http://www.newhotmail.co.uk/>
> > > > >
> > > > >
> > > > >
> > >
> ------------------------------------------------------------------------
> > > > > Play Movie Mash-up and win BIG prizes!
> > > <https://www.moviemashup.co.uk/>
> > > > >
> > > > >
> > > > >
> > >
> ------------------------------------------------------------------------
> > > > > Play Movie Mash-up and win BIG prizes!
> > > <https://www.moviemashup.co.uk>
> > >
> > >
> > >
> ------------------------------------------------------------------------
> > > The future of MSN Messenger! Windows Live Messenger
> > > <http://imagine-msn.com/messenger/launch/en-GB/>
> > >
> > >
> > >
> ------------------------------------------------------------------------
> > > The next generation of MSN Hotmail has arrived - Windows Live Hotmail
> > > <http://www.newhotmail.co.uk>
>
> ------------------------------------------------------------------------
> The future of MSN Messenger! Windows Live Messenger
> <http://imagine-msn.com/messenger/launch/en-GB/>