KickJava   Java API By Example, From Geeks To Geeks.

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


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 PaymentItem
39  */

40 public abstract class BasePaymentItem extends BaseObject
41     implements org.apache.turbine.om.Retrievable
42 {
43     /** The Peer class */
44     private static final PaymentItemPeer peer =
45         new PaymentItemPeer();
46
47         
48     /** The value for the paymentItemId field */
49     private int paymentItemId;
50                                           
51     /** The value for the paymentId field */
52     private int paymentId = 1000;
53                                           
54     /** The value for the sorderId field */
55     private int sorderId = 1000;
56                                           
57     /** The value for the customerId field */
58     private int customerId = 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 quantity field */
73     private int quantity = 1;
74                                           
75     /** The value for the currencyId field */
76     private int currencyId = 1000;
77                                   
78     /** The value for the itemCurrTotal field */
79     private BigDecimal JavaDoc itemCurrTotal= new BigDecimal JavaDoc(0);
80                                   
81     /** The value for the itemTotal field */
82     private BigDecimal JavaDoc itemTotal= new BigDecimal JavaDoc(0);
83   
84     
85     /**
86      * Get the PaymentItemId
87      *
88      * @return int
89      */

90     public int getPaymentItemId()
91     {
92         return paymentItemId;
93     }
94
95                         
96     /**
97      * Set the value of PaymentItemId
98      *
99      * @param v new value
100      */

101     public void setPaymentItemId(int v)
102     {
103     
104                   if (this.paymentItemId != v)
105               {
106             this.paymentItemId = v;
107             setModified(true);
108         }
109     
110           
111               }
112   
113     /**
114      * Get the PaymentId
115      *
116      * @return int
117      */

118     public int getPaymentId()
119     {
120         return paymentId;
121     }
122
123                               
124     /**
125      * Set the value of PaymentId
126      *
127      * @param v new value
128      */

129     public void setPaymentId(int v) throws TorqueException
130     {
131     
132                   if (this.paymentId != v)
133               {
134             this.paymentId = v;
135             setModified(true);
136         }
137     
138                           
139                 if (aPayment != null && !(aPayment.getPaymentId() == v))
140                 {
141             aPayment = null;
142         }
143       
144               }
145   
146     /**
147      * Get the SorderId
148      *
149      * @return int
150      */

151     public int getSorderId()
152     {
153         return sorderId;
154     }
155
156                               
157     /**
158      * Set the value of SorderId
159      *
160      * @param v new value
161      */

162     public void setSorderId(int v) throws TorqueException
163     {
164     
165                   if (this.sorderId != v)
166               {
167             this.sorderId = v;
168             setModified(true);
169         }
170     
171                           
172                 if (aSorder != null && !(aSorder.getSorderId() == v))
173                 {
174             aSorder = null;
175         }
176       
177               }
178   
179     /**
180      * Get the CustomerId
181      *
182      * @return int
183      */

184     public int getCustomerId()
185     {
186         return customerId;
187     }
188
189                               
190     /**
191      * Set the value of CustomerId
192      *
193      * @param v new value
194      */

195     public void setCustomerId(int v) throws TorqueException
196     {
197     
198                   if (this.customerId != v)
199               {
200             this.customerId = v;
201             setModified(true);
202         }
203     
204                           
205                 if (aCustomer != null && !(aCustomer.getCustomerId() == v))
206                 {
207             aCustomer = null;
208         }
209       
210               }
211   
212     /**
213      * Get the ProjectId
214      *
215      * @return int
216      */

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

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

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

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

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

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

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

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

339     public int getQuantity()
340     {
341         return quantity;
342     }
343
344                         
345     /**
346      * Set the value of Quantity
347      *
348      * @param v new value
349      */

350     public void setQuantity(int v)
351     {
352     
353                   if (this.quantity != v)
354               {
355             this.quantity = v;
356             setModified(true);
357         }
358     
359           
360               }
361   
362     /**
363      * Get the CurrencyId
364      *
365      * @return int
366      */

367     public int getCurrencyId()
368     {
369         return currencyId;
370     }
371
372                               
373     /**
374      * Set the value of CurrencyId
375      *
376      * @param v new value
377      */

378     public void setCurrencyId(int v) throws TorqueException
379     {
380     
381                   if (this.currencyId != v)
382               {
383             this.currencyId = v;
384             setModified(true);
385         }
386     
387                           
388                 if (aCurrency != null && !(aCurrency.getCurrencyId() == v))
389                 {
390             aCurrency = null;
391         }
392       
393               }
394   
395     /**
396      * Get the ItemCurrTotal
397      *
398      * @return BigDecimal
399      */

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

411     public void setItemCurrTotal(BigDecimal JavaDoc v)
412     {
413     
414                   if (!ObjectUtils.equals(this.itemCurrTotal, v))
415               {
416             this.itemCurrTotal = v;
417             setModified(true);
418         }
419     
420           
421               }
422   
423     /**
424      * Get the ItemTotal
425      *
426      * @return BigDecimal
427      */

428     public BigDecimal JavaDoc getItemTotal()
429     {
430         return itemTotal;
431     }
432
433                         
434     /**
435      * Set the value of ItemTotal
436      *
437      * @param v new value
438      */

439     public void setItemTotal(BigDecimal JavaDoc v)
440     {
441     
442                   if (!ObjectUtils.equals(this.itemTotal, v))
443               {
444             this.itemTotal = v;
445             setModified(true);
446         }
447     
448           
449               }
450   
451       
452     
453                   
454     
455         private Payment aPayment;
456
457     /**
458      * Declares an association between this object and a Payment object
459      *
460      * @param v Payment
461      * @throws TorqueException
462      */

463     public void setPayment(Payment v) throws TorqueException
464     {
465             if (v == null)
466         {
467                           setPaymentId( 1000);
468               }
469         else
470         {
471             setPaymentId(v.getPaymentId());
472         }
473             aPayment = v;
474     }
475
476                                             
477     /**
478      * Get the associated Payment object
479      *
480      * @return the associated Payment object
481      * @throws TorqueException
482      */

483     public Payment getPayment() throws TorqueException
484     {
485         if (aPayment == null && (this.paymentId != 0))
486         {
487                           aPayment = PaymentPeer.retrieveByPK(SimpleKey.keyFor(this.paymentId));
488               
489             /* The following can be used instead of the line above to
490                guarantee the related object contains a reference
491                to this object, but this level of coupling
492                may be undesirable in many circumstances.
493                As it can lead to a db query with many results that may
494                never be used.
495                Payment obj = PaymentPeer.retrieveByPK(this.paymentId);
496                obj.addPaymentItems(this);
497             */

498         }
499         return aPayment;
500     }
501
502     /**
503      * Provides convenient way to set a relationship based on a
504      * ObjectKey, for example
505      * <code>bar.setFooKey(foo.getPrimaryKey())</code>
506      *
507          */

508     public void setPaymentKey(ObjectKey key) throws TorqueException
509     {
510       
511                         setPaymentId(((NumberKey) key).intValue());
512                   }
513     
514     
515                   
516     
517         private Sorder aSorder;
518
519     /**
520      * Declares an association between this object and a Sorder object
521      *
522      * @param v Sorder
523      * @throws TorqueException
524      */

525     public void setSorder(Sorder v) throws TorqueException
526     {
527             if (v == null)
528         {
529                           setSorderId( 1000);
530               }
531         else
532         {
533             setSorderId(v.getSorderId());
534         }
535             aSorder = v;
536     }
537
538                                             
539     /**
540      * Get the associated Sorder object
541      *
542      * @return the associated Sorder object
543      * @throws TorqueException
544      */

545     public Sorder getSorder() throws TorqueException
546     {
547         if (aSorder == null && (this.sorderId != 0))
548         {
549                           aSorder = SorderPeer.retrieveByPK(SimpleKey.keyFor(this.sorderId));
550               
551             /* The following can be used instead of the line above to
552                guarantee the related object contains a reference
553                to this object, but this level of coupling
554                may be undesirable in many circumstances.
555                As it can lead to a db query with many results that may
556                never be used.
557                Sorder obj = SorderPeer.retrieveByPK(this.sorderId);
558                obj.addPaymentItems(this);
559             */

560         }
561         return aSorder;
562     }
563
564     /**
565      * Provides convenient way to set a relationship based on a
566      * ObjectKey, for example
567      * <code>bar.setFooKey(foo.getPrimaryKey())</code>
568      *
569          */

570     public void setSorderKey(ObjectKey key) throws TorqueException
571     {
572       
573                         setSorderId(((NumberKey) key).intValue());
574                   }
575     
576     
577                   
578     
579         private Product aProduct;
580
581     /**
582      * Declares an association between this object and a Product object
583      *
584      * @param v Product
585      * @throws TorqueException
586      */

587     public void setProduct(Product v) throws TorqueException
588     {
589             if (v == null)
590         {
591                           setProductId( 1000);
592               }
593         else
594         {
595             setProductId(v.getProductId());
596         }
597             aProduct = v;
598     }
599
600                                             
601     /**
602      * Get the associated Product object
603      *
604      * @return the associated Product object
605      * @throws TorqueException
606      */

607     public Product getProduct() throws TorqueException
608     {
609         if (aProduct == null && (this.productId != 0))
610         {
611                           aProduct = ProductPeer.retrieveByPK(SimpleKey.keyFor(this.productId));
612               
613             /* The following can be used instead of the line above to
614                guarantee the related object contains a reference
615                to this object, but this level of coupling
616                may be undesirable in many circumstances.
617                As it can lead to a db query with many results that may
618                never be used.
619                Product obj = ProductPeer.retrieveByPK(this.productId);
620                obj.addPaymentItems(this);
621             */

622         }
623         return aProduct;
624     }
625
626     /**
627      * Provides convenient way to set a relationship based on a
628      * ObjectKey, for example
629      * <code>bar.setFooKey(foo.getPrimaryKey())</code>
630      *
631          */

632     public void setProductKey(ObjectKey key) throws TorqueException
633     {
634       
635                         setProductId(((NumberKey) key).intValue());
636                   }
637     
638     
639                   
640     
641         private Currency aCurrency;
642
643     /**
644      * Declares an association between this object and a Currency object
645      *
646      * @param v Currency
647      * @throws TorqueException
648      */

649     public void setCurrency(Currency v) throws TorqueException
650     {
651             if (v == null)
652         {
653                           setCurrencyId( 1000);
654               }
655         else
656         {
657             setCurrencyId(v.getCurrencyId());
658         }
659             aCurrency = v;
660     }
661
662                                             
663     /**
664      * Get the associated Currency object
665      *
666      * @return the associated Currency object
667      * @throws TorqueException
668      */

669     public Currency getCurrency() throws TorqueException
670     {
671         if (aCurrency == null && (this.currencyId != 0))
672         {
673                           aCurrency = CurrencyPeer.retrieveByPK(SimpleKey.keyFor(this.currencyId));
674               
675             /* The following can be used instead of the line above to
676                guarantee the related object contains a reference
677                to this object, but this level of coupling
678                may be undesirable in many circumstances.
679                As it can lead to a db query with many results that may
680                never be used.
681                Currency obj = CurrencyPeer.retrieveByPK(this.currencyId);
682                obj.addPaymentItems(this);
683             */

684         }
685         return aCurrency;
686     }
687
688     /**
689      * Provides convenient way to set a relationship based on a
690      * ObjectKey, for example
691      * <code>bar.setFooKey(foo.getPrimaryKey())</code>
692      *
693          */

694     public void setCurrencyKey(ObjectKey key) throws TorqueException
695     {
696       
697                         setCurrencyId(((NumberKey) key).intValue());
698                   }
699     
700     
701                   
702     
703         private Customer aCustomer;
704
705     /**
706      * Declares an association between this object and a Customer object
707      *
708      * @param v Customer
709      * @throws TorqueException
710      */

711     public void setCustomer(Customer v) throws TorqueException
712     {
713             if (v == null)
714         {
715                           setCustomerId( 1000);
716               }
717         else
718         {
719             setCustomerId(v.getCustomerId());
720         }
721             aCustomer = v;
722     }
723
724                                             
725     /**
726      * Get the associated Customer object
727      *
728      * @return the associated Customer object
729      * @throws TorqueException
730      */

731     public Customer getCustomer() throws TorqueException
732     {
733         if (aCustomer == null && (this.customerId != 0))
734         {
735                           aCustomer = CustomerPeer.retrieveByPK(SimpleKey.keyFor(this.customerId));
736               
737             /* The following can be used instead of the line above to
738                guarantee the related object contains a reference
739                to this object, but this level of coupling
740                may be undesirable in many circumstances.
741                As it can lead to a db query with many results that may
742                never be used.
743                Customer obj = CustomerPeer.retrieveByPK(this.customerId);
744                obj.addPaymentItems(this);
745             */

746         }
747         return aCustomer;
748     }
749
750     /**
751      * Provides convenient way to set a relationship based on a
752      * ObjectKey, for example
753      * <code>bar.setFooKey(foo.getPrimaryKey())</code>
754      *
755          */

756     public void setCustomerKey(ObjectKey key) throws TorqueException
757     {
758       
759                         setCustomerId(((NumberKey) key).intValue());
760                   }
761     
762     
763                   
764     
765         private Project aProject;
766
767     /**
768      * Declares an association between this object and a Project object
769      *
770      * @param v Project
771      * @throws TorqueException
772      */

773     public void setProject(Project v) throws TorqueException
774     {
775             if (v == null)
776         {
777                           setProjectId( 1000);
778               }
779         else
780         {
781             setProjectId(v.getProjectId());
782         }
783             aProject = v;
784     }
785
786                                             
787     /**
788      * Get the associated Project object
789      *
790      * @return the associated Project object
791      * @throws TorqueException
792      */

793     public Project getProject() throws TorqueException
794     {
795         if (aProject == null && (this.projectId != 0))
796         {
797                           aProject = ProjectPeer.retrieveByPK(SimpleKey.keyFor(this.projectId));
798               
799             /* The following can be used instead of the line above to
800                guarantee the related object contains a reference
801                to this object, but this level of coupling
802                may be undesirable in many circumstances.
803                As it can lead to a db query with many results that may
804                never be used.
805                Project obj = ProjectPeer.retrieveByPK(this.projectId);
806                obj.addPaymentItems(this);
807             */

808         }
809         return aProject;
810     }
811
812     /**
813      * Provides convenient way to set a relationship based on a
814      * ObjectKey, for example
815      * <code>bar.setFooKey(foo.getPrimaryKey())</code>
816      *
817          */

818     public void setProjectKey(ObjectKey key) throws TorqueException
819     {
820       
821                         setProjectId(((NumberKey) key).intValue());
822                   }
823        
824                 
825     private static List JavaDoc fieldNames = null;
826
827     /**
828      * Generate a list of field names.
829      *
830      * @return a list of field names
831      */

832     public static synchronized List JavaDoc getFieldNames()
833     {
834         if (fieldNames == null)
835         {
836             fieldNames = new ArrayList JavaDoc();
837               fieldNames.add("PaymentItemId");
838               fieldNames.add("PaymentId");
839               fieldNames.add("SorderId");
840               fieldNames.add("CustomerId");
841               fieldNames.add("ProjectId");
842               fieldNames.add("ProductId");
843               fieldNames.add("Description");
844               fieldNames.add("UnitPrice");
845               fieldNames.add("Quantity");
846               fieldNames.add("CurrencyId");
847               fieldNames.add("ItemCurrTotal");
848               fieldNames.add("ItemTotal");
849               fieldNames = Collections.unmodifiableList(fieldNames);
850         }
851         return fieldNames;
852     }
853
854     /**
855      * Retrieves a field from the object by name passed in as a String.
856      *
857      * @param name field name
858      * @return value
859      */

860     public Object JavaDoc getByName(String JavaDoc name)
861     {
862           if (name.equals("PaymentItemId"))
863         {
864                 return new Integer JavaDoc(getPaymentItemId());
865             }
866           if (name.equals("PaymentId"))
867         {
868                 return new Integer JavaDoc(getPaymentId());
869             }
870           if (name.equals("SorderId"))
871         {
872                 return new Integer JavaDoc(getSorderId());
873             }
874           if (name.equals("CustomerId"))
875         {
876                 return new Integer JavaDoc(getCustomerId());
877             }
878           if (name.equals("ProjectId"))
879         {
880                 return new Integer JavaDoc(getProjectId());
881             }
882           if (name.equals("ProductId"))
883         {
884                 return new Integer JavaDoc(getProductId());
885             }
886           if (name.equals("Description"))
887         {
888                 return getDescription();
889             }
890           if (name.equals("UnitPrice"))
891         {
892                 return getUnitPrice();
893             }
894           if (name.equals("Quantity"))
895         {
896                 return new Integer JavaDoc(getQuantity());
897             }
898           if (name.equals("CurrencyId"))
899         {
900                 return new Integer JavaDoc(getCurrencyId());
901             }
902           if (name.equals("ItemCurrTotal"))
903         {
904                 return getItemCurrTotal();
905             }
906           if (name.equals("ItemTotal"))
907         {
908                 return getItemTotal();
909             }
910           return null;
911     }
912     
913     /**
914      * Retrieves a field from the object by name passed in
915      * as a String. The String must be one of the static
916      * Strings defined in this Class' Peer.
917      *
918      * @param name peer name
919      * @return value
920      */

921     public Object JavaDoc getByPeerName(String JavaDoc name)
922     {
923           if (name.equals(PaymentItemPeer.PAYMENT_ITEM_ID))
924         {
925                 return new Integer JavaDoc(getPaymentItemId());
926             }
927           if (name.equals(PaymentItemPeer.PAYMENT_ID))
928         {
929                 return new Integer JavaDoc(getPaymentId());
930             }
931           if (name.equals(PaymentItemPeer.SORDER_ID))
932         {
933                 return new Integer JavaDoc(getSorderId());
934             }
935           if (name.equals(PaymentItemPeer.CUSTOMER_ID))
936         {
937                 return new Integer JavaDoc(getCustomerId());
938             }
939           if (name.equals(PaymentItemPeer.PROJECT_ID))
940         {
941                 return new Integer JavaDoc(getProjectId());
942             }
943           if (name.equals(PaymentItemPeer.PRODUCT_ID))
944         {
945                 return new Integer JavaDoc(getProductId());
946             }
947           if (name.equals(PaymentItemPeer.DESCRIPTION))
948         {
949                 return getDescription();
950             }
951           if (name.equals(PaymentItemPeer.UNIT_PRICE))
952         {
953                 return getUnitPrice();
954             }
955           if (name.equals(PaymentItemPeer.QUANTITY))
956         {
957                 return new Integer JavaDoc(getQuantity());
958             }
959           if (name.equals(PaymentItemPeer.CURRENCY_ID))
960         {
961                 return new Integer JavaDoc(getCurrencyId());
962             }
963           if (name.equals(PaymentItemPeer.ITEM_CURR_TOTAL))
964         {
965                 return getItemCurrTotal();
966             }
967           if (name.equals(PaymentItemPeer.ITEM_TOTAL))
968         {
969                 return getItemTotal();
970             }
971           return null;
972     }
973
974     /**
975      * Retrieves a field from the object by Position as specified
976      * in the xml schema. Zero-based.
977      *
978      * @param pos position in xml schema
979      * @return value
980      */

981     public Object JavaDoc getByPosition(int pos)
982     {
983             if (pos == 0)
984         {
985                 return new Integer JavaDoc(getPaymentItemId());
986             }
987               if (pos == 1)
988         {
989                 return new Integer JavaDoc(getPaymentId());
990             }
991               if (pos == 2)
992         {
993                 return new Integer JavaDoc(getSorderId());
994             }
995               if (pos == 3)
996         {
997                 return new Integer JavaDoc(getCustomerId());
998             }
999               if (pos == 4)
1000        {
1001                return new Integer JavaDoc(getProjectId());
1002            }
1003              if (pos == 5)
1004        {
1005                return new Integer JavaDoc(getProductId());
1006            }
1007              if (pos == 6)
1008        {
1009                return getDescription();
1010            }
1011              if (pos == 7)
1012        {
1013                return getUnitPrice();
1014            }
1015              if (pos == 8)
1016        {
1017                return new Integer JavaDoc(getQuantity());
1018            }
1019              if (pos == 9)
1020        {
1021                return new Integer JavaDoc(getCurrencyId());
1022            }
1023              if (pos == 10)
1024        {
1025                return getItemCurrTotal();
1026            }
1027              if (pos == 11)
1028        {
1029                return getItemTotal();
1030            }
1031              return null;
1032    }
1033     
1034    /**
1035     * Stores the object in the database. If the object is new,
1036     * it inserts it; otherwise an update is performed.
1037     *
1038     * @throws Exception
1039     */

1040    public void save() throws Exception JavaDoc
1041    {
1042          save(PaymentItemPeer.getMapBuilder()
1043                .getDatabaseMap().getName());
1044      }
1045
1046    /**
1047     * Stores the object in the database. If the object is new,
1048     * it inserts it; otherwise an update is performed.
1049       * Note: this code is here because the method body is
1050     * auto-generated conditionally and therefore needs to be
1051     * in this file instead of in the super class, BaseObject.
1052       *
1053     * @param dbName
1054     * @throws TorqueException
1055     */

1056    public void save(String JavaDoc dbName) throws TorqueException
1057    {
1058        Connection JavaDoc con = null;
1059          try
1060        {
1061            con = Transaction.begin(dbName);
1062            save(con);
1063            Transaction.commit(con);
1064        }
1065        catch(TorqueException e)
1066        {
1067            Transaction.safeRollback(con);
1068            throw e;
1069        }
1070      }
1071
1072      /** flag to prevent endless save loop, if this object is referenced
1073        by another object which falls in this transaction. */

1074    private boolean alreadyInSave = false;
1075      /**
1076     * Stores the object in the database. If the object is new,
1077     * it inserts it; otherwise an update is performed. This method
1078     * is meant to be used as part of a transaction, otherwise use
1079     * the save() method and the connection details will be handled
1080     * internally
1081     *
1082     * @param con
1083     * @throws TorqueException
1084     */

1085    public void save(Connection JavaDoc con) throws TorqueException
1086    {
1087          if (!alreadyInSave)
1088        {
1089            alreadyInSave = true;
1090
1091
1092  
1093            // If this object has been modified, then save it to the database.
1094
if (isModified())
1095            {
1096                if (isNew())
1097                {
1098                    PaymentItemPeer.doInsert((PaymentItem) this, con);
1099                    setNew(false);
1100                }
1101                else
1102                {
1103                    PaymentItemPeer.doUpdate((PaymentItem) this, con);
1104                }
1105            }
1106
1107                      alreadyInSave = false;
1108        }
1109      }
1110
1111                  
1112      /**
1113     * Set the PrimaryKey using ObjectKey.
1114     *
1115     * @param key paymentItemId ObjectKey
1116     */

1117    public void setPrimaryKey(ObjectKey key)
1118        
1119    {
1120            setPaymentItemId(((NumberKey) key).intValue());
1121        }
1122
1123    /**
1124     * Set the PrimaryKey using a String.
1125     *
1126     * @param key
1127     */

1128    public void setPrimaryKey(String JavaDoc key)
1129    {
1130            setPaymentItemId(Integer.parseInt(key));
1131        }
1132
1133  
1134    /**
1135     * returns an id that differentiates this object from others
1136     * of its class.
1137     */

1138    public ObjectKey getPrimaryKey()
1139    {
1140          return SimpleKey.keyFor(getPaymentItemId());
1141      }
1142 
1143    /**
1144     * get an id that differentiates this object from others
1145     * of its class.
1146     */

1147    public String JavaDoc getQueryKey()
1148    {
1149        if (getPrimaryKey() == null)
1150        {
1151            return "";
1152        }
1153        else
1154        {
1155            return getPrimaryKey().toString();
1156        }
1157    }
1158
1159    /**
1160     * set an id that differentiates this object from others
1161     * of its class.
1162     */

1163    public void setQueryKey(String JavaDoc key)
1164        throws TorqueException
1165    {
1166        setPrimaryKey(key);
1167    }
1168
1169    /**
1170     * Makes a copy of this object.
1171     * It creates a new object filling in the simple attributes.
1172       * It then fills all the association collections and sets the
1173     * related objects to isNew=true.
1174       */

1175      public PaymentItem copy() throws TorqueException
1176    {
1177        return copyInto(new PaymentItem());
1178    }
1179  
1180    protected PaymentItem copyInto(PaymentItem copyObj) throws TorqueException
1181    {
1182          copyObj.setPaymentItemId(paymentItemId);
1183          copyObj.setPaymentId(paymentId);
1184          copyObj.setSorderId(sorderId);
1185          copyObj.setCustomerId(customerId);
1186          copyObj.setProjectId(projectId);
1187          copyObj.setProductId(productId);
1188          copyObj.setDescription(description);
1189          copyObj.setUnitPrice(unitPrice);
1190          copyObj.setQuantity(quantity);
1191          copyObj.setCurrencyId(currencyId);
1192          copyObj.setItemCurrTotal(itemCurrTotal);
1193          copyObj.setItemTotal(itemTotal);
1194  
1195                            copyObj.setPaymentItemId( 0);
1196                                                                              
1197                return copyObj;
1198    }
1199
1200    /**
1201     * returns a peer instance associated with this om. Since Peer classes
1202     * are not to have any instance attributes, this method returns the
1203     * same instance for all member of this class. The method could therefore
1204     * be static, but this would prevent one from overriding the behavior.
1205     */

1206    public PaymentItemPeer getPeer()
1207    {
1208        return peer;
1209    }
1210
1211    public String JavaDoc toString()
1212    {
1213        StringBuffer JavaDoc str = new StringBuffer JavaDoc();
1214        str.append("PaymentItem:\n");
1215        str.append("PaymentItemId = ")
1216               .append(getPaymentItemId())
1217             .append("\n");
1218        str.append("PaymentId = ")
1219               .append(getPaymentId())
1220             .append("\n");
1221        str.append("SorderId = ")
1222               .append(getSorderId())
1223             .append("\n");
1224        str.append("CustomerId = ")
1225               .append(getCustomerId())
1226             .append("\n");
1227        str.append("ProjectId = ")
1228               .append(getProjectId())
1229             .append("\n");
1230        str.append("ProductId = ")
1231               .append(getProductId())
1232             .append("\n");
1233        str.append("Description = ")
1234               .append(getDescription())
1235             .append("\n");
1236        str.append("UnitPrice = ")
1237               .append(getUnitPrice())
1238             .append("\n");
1239        str.append("Quantity = ")
1240               .append(getQuantity())
1241             .append("\n");
1242        str.append("CurrencyId = ")
1243               .append(getCurrencyId())
1244             .append("\n");
1245        str.append("ItemCurrTotal = ")
1246               .append(getItemCurrTotal())
1247             .append("\n");
1248        str.append("ItemTotal = ")
1249               .append(getItemTotal())
1250             .append("\n");
1251        return(str.toString());
1252    }
1253}
1254
Popular Tags