KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > campware > cream > om > BaseSorderItem


1 package org.campware.cream.om;
2
3
4 import java.math.BigDecimal JavaDoc;
5 import java.sql.Connection JavaDoc;
6 import java.util.ArrayList JavaDoc;
7 import java.util.Collections JavaDoc;
8 import java.util.Date JavaDoc;
9 import java.util.List JavaDoc;
10
11 import org.apache.commons.lang.ObjectUtils;
12 import org.apache.turbine.om.Retrievable;
13 import org.apache.torque.TorqueException;
14 import org.apache.torque.om.BaseObject;
15 import org.apache.torque.om.ComboKey;
16 import org.apache.torque.om.DateKey;
17 import org.apache.torque.om.NumberKey;
18 import org.apache.torque.om.ObjectKey;
19 import org.apache.torque.om.SimpleKey;
20 import org.apache.torque.om.StringKey;
21 import org.apache.torque.om.Persistent;
22 import org.apache.torque.util.Criteria;
23 import org.apache.torque.util.Transaction;
24
25   
26     
27     
28     
29     
30     
31   
32 /**
33  * This class was autogenerated by Torque on:
34  *
35  * [Wed May 04 09:10:56 CEST 2005]
36  *
37  * You should not use this class directly. It should not even be
38  * extended all references should be to SorderItem
39  */

40 public abstract class BaseSorderItem extends BaseObject
41     implements org.apache.turbine.om.Retrievable
42 {
43     /** The Peer class */
44     private static final SorderItemPeer peer =
45         new SorderItemPeer();
46
47         
48     /** The value for the sorderItemId field */
49     private int sorderItemId;
50                                           
51     /** The value for the sorderId field */
52     private int sorderId = 1000;
53                                           
54     /** The value for the customerId field */
55     private int customerId = 1000;
56                                           
57     /** The value for the recipientId field */
58     private int recipientId = 1000;
59                                           
60     /** The value for the projectId field */
61     private int projectId = 1000;
62                                           
63     /** The value for the productId field */
64     private int productId = 1000;
65       
66     /** The value for the description field */
67     private String JavaDoc description;
68                                   
69     /** The value for the unitPrice field */
70     private BigDecimal JavaDoc unitPrice= new BigDecimal JavaDoc(0);
71                                           
72     /** The value for the currencyId field */
73     private int currencyId = 1000;
74                                           
75     /** The value for the quantity field */
76     private int quantity = 1;
77                                   
78     /** The value for the itemCurrTotal field */
79     private BigDecimal JavaDoc itemCurrTotal= new BigDecimal JavaDoc(0);
80   
81     
82     /**
83      * Get the SorderItemId
84      *
85      * @return int
86      */

87     public int getSorderItemId()
88     {
89         return sorderItemId;
90     }
91
92                         
93     /**
94      * Set the value of SorderItemId
95      *
96      * @param v new value
97      */

98     public void setSorderItemId(int v)
99     {
100     
101                   if (this.sorderItemId != v)
102               {
103             this.sorderItemId = v;
104             setModified(true);
105         }
106     
107           
108               }
109   
110     /**
111      * Get the SorderId
112      *
113      * @return int
114      */

115     public int getSorderId()
116     {
117         return sorderId;
118     }
119
120                               
121     /**
122      * Set the value of SorderId
123      *
124      * @param v new value
125      */

126     public void setSorderId(int v) throws TorqueException
127     {
128     
129                   if (this.sorderId != v)
130               {
131             this.sorderId = v;
132             setModified(true);
133         }
134     
135                           
136                 if (aSorder != null && !(aSorder.getSorderId() == v))
137                 {
138             aSorder = null;
139         }
140       
141               }
142   
143     /**
144      * Get the CustomerId
145      *
146      * @return int
147      */

148     public int getCustomerId()
149     {
150         return customerId;
151     }
152
153                               
154     /**
155      * Set the value of CustomerId
156      *
157      * @param v new value
158      */

159     public void setCustomerId(int v) throws TorqueException
160     {
161     
162                   if (this.customerId != v)
163               {
164             this.customerId = v;
165             setModified(true);
166         }
167     
168                                                                   
169                 if (aCustomerRelatedByCustomerId != null && !(aCustomerRelatedByCustomerId.getCustomerId() == v))
170                 {
171             aCustomerRelatedByCustomerId = null;
172         }
173       
174               }
175   
176     /**
177      * Get the RecipientId
178      *
179      * @return int
180      */

181     public int getRecipientId()
182     {
183         return recipientId;
184     }
185
186                               
187     /**
188      * Set the value of RecipientId
189      *
190      * @param v new value
191      */

192     public void setRecipientId(int v) throws TorqueException
193     {
194     
195                   if (this.recipientId != v)
196               {
197             this.recipientId = v;
198             setModified(true);
199         }
200     
201                                                                   
202                 if (aCustomerRelatedByRecipientId != null && !(aCustomerRelatedByRecipientId.getCustomerId() == v))
203                 {
204             aCustomerRelatedByRecipientId = null;
205         }
206       
207               }
208   
209     /**
210      * Get the ProjectId
211      *
212      * @return int
213      */

214     public int getProjectId()
215     {
216         return projectId;
217     }
218
219                               
220     /**
221      * Set the value of ProjectId
222      *
223      * @param v new value
224      */

225     public void setProjectId(int v) throws TorqueException
226     {
227     
228                   if (this.projectId != v)
229               {
230             this.projectId = v;
231             setModified(true);
232         }
233     
234                           
235                 if (aProject != null && !(aProject.getProjectId() == v))
236                 {
237             aProject = null;
238         }
239       
240               }
241   
242     /**
243      * Get the ProductId
244      *
245      * @return int
246      */

247     public int getProductId()
248     {
249         return productId;
250     }
251
252                               
253     /**
254      * Set the value of ProductId
255      *
256      * @param v new value
257      */

258     public void setProductId(int v) throws TorqueException
259     {
260     
261                   if (this.productId != v)
262               {
263             this.productId = v;
264             setModified(true);
265         }
266     
267                           
268                 if (aProduct != null && !(aProduct.getProductId() == v))
269                 {
270             aProduct = null;
271         }
272       
273               }
274   
275     /**
276      * Get the Description
277      *
278      * @return String
279      */

280     public String JavaDoc getDescription()
281     {
282         return description;
283     }
284
285                         
286     /**
287      * Set the value of Description
288      *
289      * @param v new value
290      */

291     public void setDescription(String JavaDoc v)
292     {
293     
294                   if (!ObjectUtils.equals(this.description, v))
295               {
296             this.description = v;
297             setModified(true);
298         }
299     
300           
301               }
302   
303     /**
304      * Get the UnitPrice
305      *
306      * @return BigDecimal
307      */

308     public BigDecimal JavaDoc getUnitPrice()
309     {
310         return unitPrice;
311     }
312
313                         
314     /**
315      * Set the value of UnitPrice
316      *
317      * @param v new value
318      */

319     public void setUnitPrice(BigDecimal JavaDoc v)
320     {
321     
322                   if (!ObjectUtils.equals(this.unitPrice, v))
323               {
324             this.unitPrice = v;
325             setModified(true);
326         }
327     
328           
329               }
330   
331     /**
332      * Get the CurrencyId
333      *
334      * @return int
335      */

336     public int getCurrencyId()
337     {
338         return currencyId;
339     }
340
341                               
342     /**
343      * Set the value of CurrencyId
344      *
345      * @param v new value
346      */

347     public void setCurrencyId(int v) throws TorqueException
348     {
349     
350                   if (this.currencyId != v)
351               {
352             this.currencyId = v;
353             setModified(true);
354         }
355     
356                           
357                 if (aCurrency != null && !(aCurrency.getCurrencyId() == v))
358                 {
359             aCurrency = null;
360         }
361       
362               }
363   
364     /**
365      * Get the Quantity
366      *
367      * @return int
368      */

369     public int getQuantity()
370     {
371         return quantity;
372     }
373
374                         
375     /**
376      * Set the value of Quantity
377      *
378      * @param v new value
379      */

380     public void setQuantity(int v)
381     {
382     
383                   if (this.quantity != v)
384               {
385             this.quantity = v;
386             setModified(true);
387         }
388     
389           
390               }
391   
392     /**
393      * Get the ItemCurrTotal
394      *
395      * @return BigDecimal
396      */

397     public BigDecimal JavaDoc getItemCurrTotal()
398     {
399         return itemCurrTotal;
400     }
401
402                         
403     /**
404      * Set the value of ItemCurrTotal
405      *
406      * @param v new value
407      */

408     public void setItemCurrTotal(BigDecimal JavaDoc v)
409     {
410     
411                   if (!ObjectUtils.equals(this.itemCurrTotal, v))
412               {
413             this.itemCurrTotal = v;
414             setModified(true);
415         }
416     
417           
418               }
419   
420       
421     
422                   
423     
424         private Sorder aSorder;
425
426     /**
427      * Declares an association between this object and a Sorder object
428      *
429      * @param v Sorder
430      * @throws TorqueException
431      */

432     public void setSorder(Sorder v) throws TorqueException
433     {
434             if (v == null)
435         {
436                           setSorderId( 1000);
437               }
438         else
439         {
440             setSorderId(v.getSorderId());
441         }
442             aSorder = v;
443     }
444
445                                             
446     /**
447      * Get the associated Sorder object
448      *
449      * @return the associated Sorder object
450      * @throws TorqueException
451      */

452     public Sorder getSorder() throws TorqueException
453     {
454         if (aSorder == null && (this.sorderId != 0))
455         {
456                           aSorder = SorderPeer.retrieveByPK(SimpleKey.keyFor(this.sorderId));
457               
458             /* The following can be used instead of the line above to
459                guarantee the related object contains a reference
460                to this object, but this level of coupling
461                may be undesirable in many circumstances.
462                As it can lead to a db query with many results that may
463                never be used.
464                Sorder obj = SorderPeer.retrieveByPK(this.sorderId);
465                obj.addSorderItems(this);
466             */

467         }
468         return aSorder;
469     }
470
471     /**
472      * Provides convenient way to set a relationship based on a
473      * ObjectKey, for example
474      * <code>bar.setFooKey(foo.getPrimaryKey())</code>
475      *
476          */

477     public void setSorderKey(ObjectKey key) throws TorqueException
478     {
479       
480                         setSorderId(((NumberKey) key).intValue());
481                   }
482     
483     
484                   
485     
486         private Product aProduct;
487
488     /**
489      * Declares an association between this object and a Product object
490      *
491      * @param v Product
492      * @throws TorqueException
493      */

494     public void setProduct(Product v) throws TorqueException
495     {
496             if (v == null)
497         {
498                           setProductId( 1000);
499               }
500         else
501         {
502             setProductId(v.getProductId());
503         }
504             aProduct = v;
505     }
506
507                                             
508     /**
509      * Get the associated Product object
510      *
511      * @return the associated Product object
512      * @throws TorqueException
513      */

514     public Product getProduct() throws TorqueException
515     {
516         if (aProduct == null && (this.productId != 0))
517         {
518                           aProduct = ProductPeer.retrieveByPK(SimpleKey.keyFor(this.productId));
519               
520             /* The following can be used instead of the line above to
521                guarantee the related object contains a reference
522                to this object, but this level of coupling
523                may be undesirable in many circumstances.
524                As it can lead to a db query with many results that may
525                never be used.
526                Product obj = ProductPeer.retrieveByPK(this.productId);
527                obj.addSorderItems(this);
528             */

529         }
530         return aProduct;
531     }
532
533     /**
534      * Provides convenient way to set a relationship based on a
535      * ObjectKey, for example
536      * <code>bar.setFooKey(foo.getPrimaryKey())</code>
537      *
538          */

539     public void setProductKey(ObjectKey key) throws TorqueException
540     {
541       
542                         setProductId(((NumberKey) key).intValue());
543                   }
544     
545     
546                         
547         
548         private Customer aCustomerRelatedByCustomerId;
549
550     /**
551      * Declares an association between this object and a Customer object
552      *
553      * @param v Customer
554      * @throws TorqueException
555      */

556     public void setCustomerRelatedByCustomerId(Customer v) throws TorqueException
557     {
558             if (v == null)
559         {
560                           setCustomerId( 1000);
561               }
562         else
563         {
564             setCustomerId(v.getCustomerId());
565         }
566             aCustomerRelatedByCustomerId = v;
567     }
568
569                                             
570     /**
571      * Get the associated Customer object
572      *
573      * @return the associated Customer object
574      * @throws TorqueException
575      */

576     public Customer getCustomerRelatedByCustomerId() throws TorqueException
577     {
578         if (aCustomerRelatedByCustomerId == null && (this.customerId != 0))
579         {
580                           aCustomerRelatedByCustomerId = CustomerPeer.retrieveByPK(SimpleKey.keyFor(this.customerId));
581               
582             /* The following can be used instead of the line above to
583                guarantee the related object contains a reference
584                to this object, but this level of coupling
585                may be undesirable in many circumstances.
586                As it can lead to a db query with many results that may
587                never be used.
588                Customer obj = CustomerPeer.retrieveByPK(this.customerId);
589                obj.addSorderItemsRelatedByCustomerId(this);
590             */

591         }
592         return aCustomerRelatedByCustomerId;
593     }
594
595     /**
596      * Provides convenient way to set a relationship based on a
597      * ObjectKey, for example
598      * <code>bar.setFooKey(foo.getPrimaryKey())</code>
599      *
600          */

601     public void setCustomerRelatedByCustomerIdKey(ObjectKey key) throws TorqueException
602     {
603       
604                         setCustomerId(((NumberKey) key).intValue());
605                   }
606     
607     
608                         
609         
610         private Customer aCustomerRelatedByRecipientId;
611
612     /**
613      * Declares an association between this object and a Customer object
614      *
615      * @param v Customer
616      * @throws TorqueException
617      */

618     public void setCustomerRelatedByRecipientId(Customer v) throws TorqueException
619     {
620             if (v == null)
621         {
622                           setRecipientId( 1000);
623               }
624         else
625         {
626             setRecipientId(v.getCustomerId());
627         }
628             aCustomerRelatedByRecipientId = v;
629     }
630
631                                             
632     /**
633      * Get the associated Customer object
634      *
635      * @return the associated Customer object
636      * @throws TorqueException
637      */

638     public Customer getCustomerRelatedByRecipientId() throws TorqueException
639     {
640         if (aCustomerRelatedByRecipientId == null && (this.recipientId != 0))
641         {
642                           aCustomerRelatedByRecipientId = CustomerPeer.retrieveByPK(SimpleKey.keyFor(this.recipientId));
643               
644             /* The following can be used instead of the line above to
645                guarantee the related object contains a reference
646                to this object, but this level of coupling
647                may be undesirable in many circumstances.
648                As it can lead to a db query with many results that may
649                never be used.
650                Customer obj = CustomerPeer.retrieveByPK(this.recipientId);
651                obj.addSorderItemsRelatedByRecipientId(this);
652             */

653         }
654         return aCustomerRelatedByRecipientId;
655     }
656
657     /**
658      * Provides convenient way to set a relationship based on a
659      * ObjectKey, for example
660      * <code>bar.setFooKey(foo.getPrimaryKey())</code>
661      *
662          */

663     public void setCustomerRelatedByRecipientIdKey(ObjectKey key) throws TorqueException
664     {
665       
666                         setRecipientId(((NumberKey) key).intValue());
667                   }
668     
669     
670                   
671     
672         private Project aProject;
673
674     /**
675      * Declares an association between this object and a Project object
676      *
677      * @param v Project
678      * @throws TorqueException
679      */

680     public void setProject(Project v) throws TorqueException
681     {
682             if (v == null)
683         {
684                           setProjectId( 1000);
685               }
686         else
687         {
688             setProjectId(v.getProjectId());
689         }
690             aProject = v;
691     }
692
693                                             
694     /**
695      * Get the associated Project object
696      *
697      * @return the associated Project object
698      * @throws TorqueException
699      */

700     public Project getProject() throws TorqueException
701     {
702         if (aProject == null && (this.projectId != 0))
703         {
704                           aProject = ProjectPeer.retrieveByPK(SimpleKey.keyFor(this.projectId));
705               
706             /* The following can be used instead of the line above to
707                guarantee the related object contains a reference
708                to this object, but this level of coupling
709                may be undesirable in many circumstances.
710                As it can lead to a db query with many results that may
711                never be used.
712                Project obj = ProjectPeer.retrieveByPK(this.projectId);
713                obj.addSorderItems(this);
714             */

715         }
716         return aProject;
717     }
718
719     /**
720      * Provides convenient way to set a relationship based on a
721      * ObjectKey, for example
722      * <code>bar.setFooKey(foo.getPrimaryKey())</code>
723      *
724          */

725     public void setProjectKey(ObjectKey key) throws TorqueException
726     {
727       
728                         setProjectId(((NumberKey) key).intValue());
729                   }
730     
731     
732                   
733     
734         private Currency aCurrency;
735
736     /**
737      * Declares an association between this object and a Currency object
738      *
739      * @param v Currency
740      * @throws TorqueException
741      */

742     public void setCurrency(Currency v) throws TorqueException
743     {
744             if (v == null)
745         {
746                           setCurrencyId( 1000);
747               }
748         else
749         {
750             setCurrencyId(v.getCurrencyId());
751         }
752             aCurrency = v;
753     }
754
755                                             
756     /**
757      * Get the associated Currency object
758      *
759      * @return the associated Currency object
760      * @throws TorqueException
761      */

762     public Currency getCurrency() throws TorqueException
763     {
764         if (aCurrency == null && (this.currencyId != 0))
765         {
766                           aCurrency = CurrencyPeer.retrieveByPK(SimpleKey.keyFor(this.currencyId));
767               
768             /* The following can be used instead of the line above to
769                guarantee the related object contains a reference
770                to this object, but this level of coupling
771                may be undesirable in many circumstances.
772                As it can lead to a db query with many results that may
773                never be used.
774                Currency obj = CurrencyPeer.retrieveByPK(this.currencyId);
775                obj.addSorderItems(this);
776             */

777         }
778         return aCurrency;
779     }
780
781     /**
782      * Provides convenient way to set a relationship based on a
783      * ObjectKey, for example
784      * <code>bar.setFooKey(foo.getPrimaryKey())</code>
785      *
786          */

787     public void setCurrencyKey(ObjectKey key) throws TorqueException
788     {
789       
790                         setCurrencyId(((NumberKey) key).intValue());
791                   }
792        
793                 
794     private static List JavaDoc fieldNames = null;
795
796     /**
797      * Generate a list of field names.
798      *
799      * @return a list of field names
800      */

801     public static synchronized List JavaDoc getFieldNames()
802     {
803         if (fieldNames == null)
804         {
805             fieldNames = new ArrayList JavaDoc();
806               fieldNames.add("SorderItemId");
807               fieldNames.add("SorderId");
808               fieldNames.add("CustomerId");
809               fieldNames.add("RecipientId");
810               fieldNames.add("ProjectId");
811               fieldNames.add("ProductId");
812               fieldNames.add("Description");
813               fieldNames.add("UnitPrice");
814               fieldNames.add("CurrencyId");
815               fieldNames.add("Quantity");
816               fieldNames.add("ItemCurrTotal");
817               fieldNames = Collections.unmodifiableList(fieldNames);
818         }
819         return fieldNames;
820     }
821
822     /**
823      * Retrieves a field from the object by name passed in as a String.
824      *
825      * @param name field name
826      * @return value
827      */

828     public Object JavaDoc getByName(String JavaDoc name)
829     {
830           if (name.equals("SorderItemId"))
831         {
832                 return new Integer JavaDoc(getSorderItemId());
833             }
834           if (name.equals("SorderId"))
835         {
836                 return new Integer JavaDoc(getSorderId());
837             }
838           if (name.equals("CustomerId"))
839         {
840                 return new Integer JavaDoc(getCustomerId());
841             }
842           if (name.equals("RecipientId"))
843         {
844                 return new Integer JavaDoc(getRecipientId());
845             }
846           if (name.equals("ProjectId"))
847         {
848                 return new Integer JavaDoc(getProjectId());
849             }
850           if (name.equals("ProductId"))
851         {
852                 return new Integer JavaDoc(getProductId());
853             }
854           if (name.equals("Description"))
855         {
856                 return getDescription();
857             }
858           if (name.equals("UnitPrice"))
859         {
860                 return getUnitPrice();
861             }
862           if (name.equals("CurrencyId"))
863         {
864                 return new Integer JavaDoc(getCurrencyId());
865             }
866           if (name.equals("Quantity"))
867         {
868                 return new Integer JavaDoc(getQuantity());
869             }
870           if (name.equals("ItemCurrTotal"))
871         {
872                 return getItemCurrTotal();
873             }
874           return null;
875     }
876     
877     /**
878      * Retrieves a field from the object by name passed in
879      * as a String. The String must be one of the static
880      * Strings defined in this Class' Peer.
881      *
882      * @param name peer name
883      * @return value
884      */

885     public Object JavaDoc getByPeerName(String JavaDoc name)
886     {
887           if (name.equals(SorderItemPeer.SORDER_ITEM_ID))
888         {
889                 return new Integer JavaDoc(getSorderItemId());
890             }
891           if (name.equals(SorderItemPeer.SORDER_ID))
892         {
893                 return new Integer JavaDoc(getSorderId());
894             }
895           if (name.equals(SorderItemPeer.CUSTOMER_ID))
896         {
897                 return new Integer JavaDoc(getCustomerId());
898             }
899           if (name.equals(SorderItemPeer.RECIPIENT_ID))
900         {
901                 return new Integer JavaDoc(getRecipientId());
902             }
903           if (name.equals(SorderItemPeer.PROJECT_ID))
904         {
905                 return new Integer JavaDoc(getProjectId());
906             }
907           if (name.equals(SorderItemPeer.PRODUCT_ID))
908         {
909                 return new Integer JavaDoc(getProductId());
910             }
911           if (name.equals(SorderItemPeer.DESCRIPTION))
912         {
913                 return getDescription();
914             }
915           if (name.equals(SorderItemPeer.UNIT_PRICE))
916         {
917                 return getUnitPrice();
918             }
919           if (name.equals(SorderItemPeer.CURRENCY_ID))
920         {
921                 return new Integer JavaDoc(getCurrencyId());
922             }
923           if (name.equals(SorderItemPeer.QUANTITY))
924         {
925                 return new Integer JavaDoc(getQuantity());
926             }
927           if (name.equals(SorderItemPeer.ITEM_CURR_TOTAL))
928         {
929                 return getItemCurrTotal();
930             }
931           return null;
932     }
933
934     /**
935      * Retrieves a field from the object by Position as specified
936      * in the xml schema. Zero-based.
937      *
938      * @param pos position in xml schema
939      * @return value
940      */

941     public Object JavaDoc getByPosition(int pos)
942     {
943             if (pos == 0)
944         {
945                 return new Integer JavaDoc(getSorderItemId());
946             }
947               if (pos == 1)
948         {
949                 return new Integer JavaDoc(getSorderId());
950             }
951               if (pos == 2)
952         {
953                 return new Integer JavaDoc(getCustomerId());
954             }
955               if (pos == 3)
956         {
957                 return new Integer JavaDoc(getRecipientId());
958             }
959               if (pos == 4)
960         {
961                 return new Integer JavaDoc(getProjectId());
962             }
963               if (pos == 5)
964         {
965                 return new Integer JavaDoc(getProductId());
966             }
967               if (pos == 6)
968         {
969                 return getDescription();
970             }
971               if (pos == 7)
972         {
973                 return getUnitPrice();
974             }
975               if (pos == 8)
976         {
977                 return new Integer JavaDoc(getCurrencyId());
978             }
979               if (pos == 9)
980         {
981                 return new Integer JavaDoc(getQuantity());
982             }
983               if (pos == 10)
984         {
985                 return getItemCurrTotal();
986             }
987               return null;
988     }
989      
990     /**
991      * Stores the object in the database. If the object is new,
992      * it inserts it; otherwise an update is performed.
993      *
994      * @throws Exception
995      */

996     public void save() throws Exception JavaDoc
997     {
998           save(SorderItemPeer.getMapBuilder()
999                 .getDatabaseMap().getName());
1000      }
1001
1002    /**
1003     * Stores the object in the database. If the object is new,
1004     * it inserts it; otherwise an update is performed.
1005       * Note: this code is here because the method body is
1006     * auto-generated conditionally and therefore needs to be
1007     * in this file instead of in the super class, BaseObject.
1008       *
1009     * @param dbName
1010     * @throws TorqueException
1011     */

1012    public void save(String JavaDoc dbName) throws TorqueException
1013    {
1014        Connection JavaDoc con = null;
1015          try
1016        {
1017            con = Transaction.begin(dbName);
1018            save(con);
1019            Transaction.commit(con);
1020        }
1021        catch(TorqueException e)
1022        {
1023            Transaction.safeRollback(con);
1024            throw e;
1025        }
1026      }
1027
1028      /** flag to prevent endless save loop, if this object is referenced
1029        by another object which falls in this transaction. */

1030    private boolean alreadyInSave = false;
1031      /**
1032     * Stores the object in the database. If the object is new,
1033     * it inserts it; otherwise an update is performed. This method
1034     * is meant to be used as part of a transaction, otherwise use
1035     * the save() method and the connection details will be handled
1036     * internally
1037     *
1038     * @param con
1039     * @throws TorqueException
1040     */

1041    public void save(Connection JavaDoc con) throws TorqueException
1042    {
1043          if (!alreadyInSave)
1044        {
1045            alreadyInSave = true;
1046
1047
1048  
1049            // If this object has been modified, then save it to the database.
1050
if (isModified())
1051            {
1052                if (isNew())
1053                {
1054                    SorderItemPeer.doInsert((SorderItem) this, con);
1055                    setNew(false);
1056                }
1057                else
1058                {
1059                    SorderItemPeer.doUpdate((SorderItem) this, con);
1060                }
1061            }
1062
1063                      alreadyInSave = false;
1064        }
1065      }
1066
1067                  
1068      /**
1069     * Set the PrimaryKey using ObjectKey.
1070     *
1071     * @param key sorderItemId ObjectKey
1072     */

1073    public void setPrimaryKey(ObjectKey key)
1074        
1075    {
1076            setSorderItemId(((NumberKey) key).intValue());
1077        }
1078
1079    /**
1080     * Set the PrimaryKey using a String.
1081     *
1082     * @param key
1083     */

1084    public void setPrimaryKey(String JavaDoc key)
1085    {
1086            setSorderItemId(Integer.parseInt(key));
1087        }
1088
1089  
1090    /**
1091     * returns an id that differentiates this object from others
1092     * of its class.
1093     */

1094    public ObjectKey getPrimaryKey()
1095    {
1096          return SimpleKey.keyFor(getSorderItemId());
1097      }
1098 
1099    /**
1100     * get an id that differentiates this object from others
1101     * of its class.
1102     */

1103    public String JavaDoc getQueryKey()
1104    {
1105        if (getPrimaryKey() == null)
1106        {
1107            return "";
1108        }
1109        else
1110        {
1111            return getPrimaryKey().toString();
1112        }
1113    }
1114
1115    /**
1116     * set an id that differentiates this object from others
1117     * of its class.
1118     */

1119    public void setQueryKey(String JavaDoc key)
1120        throws TorqueException
1121    {
1122        setPrimaryKey(key);
1123    }
1124
1125    /**
1126     * Makes a copy of this object.
1127     * It creates a new object filling in the simple attributes.
1128       * It then fills all the association collections and sets the
1129     * related objects to isNew=true.
1130       */

1131      public SorderItem copy() throws TorqueException
1132    {
1133        return copyInto(new SorderItem());
1134    }
1135  
1136    protected SorderItem copyInto(SorderItem copyObj) throws TorqueException
1137    {
1138          copyObj.setSorderItemId(sorderItemId);
1139          copyObj.setSorderId(sorderId);
1140          copyObj.setCustomerId(customerId);
1141          copyObj.setRecipientId(recipientId);
1142          copyObj.setProjectId(projectId);
1143          copyObj.setProductId(productId);
1144          copyObj.setDescription(description);
1145          copyObj.setUnitPrice(unitPrice);
1146          copyObj.setCurrencyId(currencyId);
1147          copyObj.setQuantity(quantity);
1148          copyObj.setItemCurrTotal(itemCurrTotal);
1149  
1150                            copyObj.setSorderItemId( 0);
1151                                                                        
1152                return copyObj;
1153    }
1154
1155    /**
1156     * returns a peer instance associated with this om. Since Peer classes
1157     * are not to have any instance attributes, this method returns the
1158     * same instance for all member of this class. The method could therefore
1159     * be static, but this would prevent one from overriding the behavior.
1160     */

1161    public SorderItemPeer getPeer()
1162    {
1163        return peer;
1164    }
1165
1166    public String JavaDoc toString()
1167    {
1168        StringBuffer JavaDoc str = new StringBuffer JavaDoc();
1169        str.append("SorderItem:\n");
1170        str.append("SorderItemId = ")
1171               .append(getSorderItemId())
1172             .append("\n");
1173        str.append("SorderId = ")
1174               .append(getSorderId())
1175             .append("\n");
1176        str.append("CustomerId = ")
1177               .append(getCustomerId())
1178             .append("\n");
1179        str.append("RecipientId = ")
1180               .append(getRecipientId())
1181             .append("\n");
1182        str.append("ProjectId = ")
1183               .append(getProjectId())
1184             .append("\n");
1185        str.append("ProductId = ")
1186               .append(getProductId())
1187             .append("\n");
1188        str.append("Description = ")
1189               .append(getDescription())
1190             .append("\n");
1191        str.append("UnitPrice = ")
1192               .append(getUnitPrice())
1193             .append("\n");
1194        str.append("CurrencyId = ")
1195               .append(getCurrencyId())
1196             .append("\n");
1197        str.append("Quantity = ")
1198               .append(getQuantity())
1199             .append("\n");
1200        str.append("ItemCurrTotal = ")
1201               .append(getItemCurrTotal())
1202             .append("\n");
1203        return(str.toString());
1204    }
1205}
1206
Popular Tags