KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > ojb > broker > PathTest


1 package org.apache.ojb.broker;
2
3 /**
4  * TestClasses for Per-Criteria-Path-Hints
5  * @author PAW
6  *
7  */

8 import java.util.ArrayList JavaDoc;
9 import java.util.Collection JavaDoc;
10 import java.util.Iterator JavaDoc;
11
12 import junit.framework.TestCase;
13 import org.apache.ojb.broker.query.Criteria;
14 import org.apache.ojb.broker.query.Query;
15 import org.apache.ojb.broker.query.QueryByCriteria;
16 import org.apache.ojb.broker.query.QueryFactory;
17 import org.apache.ojb.broker.query.UserAlias;
18
19 public class PathTest extends TestCase
20 {
21
22     private static Class JavaDoc CLASS = PathTest.class;
23     private int COUNT = 10;
24     private int id_filter = 10000;
25     private PersistenceBroker broker = null;
26
27     public static void main(String JavaDoc[] args)
28     {
29         String JavaDoc[] arr = {CLASS.getName()};
30         junit.textui.TestRunner.main(arr);
31     }
32
33     /**
34      * Insert the method's description here.
35      * Creation date: (06.12.2000 21:58:53)
36      */

37     public void setUp()
38     {
39         try
40         {
41             broker = PersistenceBrokerFactory.defaultPersistenceBroker();
42         }
43         catch (PBFactoryException e)
44         {
45         }
46     }
47
48     /**
49      * Insert the method's description here.
50      * Creation date: (06.12.2000 21:59:14)
51      */

52     public void tearDown()
53     {
54         broker.close();
55     }
56
57     public PathTest(String JavaDoc name)
58     {
59         super(name);
60     }
61
62     public void testDeleteData() throws Exception JavaDoc
63     {
64         broker.beginTransaction();
65         Criteria crit = new Criteria();
66
67         Query query = QueryFactory.newQuery(D.class, crit);
68         Collection JavaDoc Ds = broker.getCollectionByQuery(query);
69         for (Iterator JavaDoc iterator = Ds.iterator(); iterator.hasNext();)
70         {
71             broker.delete(iterator.next());
72         }
73         query = QueryFactory.newQuery(C.class, crit);
74         Collection JavaDoc Cs = broker.getCollectionByQuery(query);
75         for (Iterator JavaDoc iterator = Cs.iterator(); iterator.hasNext();)
76         {
77             broker.delete(iterator.next());
78         }
79         query = QueryFactory.newQuery(B.class, crit);
80         Collection JavaDoc Bs = broker.getCollectionByQuery(query);
81         for (Iterator JavaDoc iterator = Bs.iterator(); iterator.hasNext();)
82         {
83             broker.delete(iterator.next());
84         }
85         query = QueryFactory.newQuery(A.class, crit);
86         Collection JavaDoc As = broker.getCollectionByQuery(query);
87         for (Iterator JavaDoc iterator = As.iterator(); iterator.hasNext();)
88         {
89             broker.delete(iterator.next());
90         }
91         broker.commitTransaction();
92     }
93
94 // private static int NUM_A = 1;
95
// private static int NUM_B_PER_A = 4;
96
// private static int NUM_C_PER_B = 2;
97
// private static int NUM_C1_PER_B = 3;
98
// private static int NUM_D_PER_C = 1;
99

100     private static int NUM_A = 3;
101     private static int NUM_B_PER_A = 4;
102     private static int NUM_C_PER_B = 2;
103     private static int NUM_C1_PER_B = 3;
104     private static int NUM_D_PER_C = 2;
105
106     private static int A_OFFSET = 10000;
107     private static int B_OFFSET = 1000;
108     private static int C_OFFSET = 100;
109     private static int D_OFFSET = 10;
110
111     public void testCreateData() throws Exception JavaDoc
112     {
113         broker.beginTransaction();
114         
115         for (int ia = 0; ia < NUM_A; ia++)
116         {
117             A a = new A(A_OFFSET + A_OFFSET * ia);
118             broker.store(a);
119             System.out.println("A - " + a.getAAttrib());
120             for (int ib = 0; ib < NUM_B_PER_A; ib++)
121             {
122                 B b = new B(A_OFFSET + B_OFFSET * ib);
123                 b.setA(a);
124                 broker.store(b);
125                 System.out.println("\tB - " + b.getBAttrib());
126                 for (int ic = 0; ic < NUM_C_PER_B; ic++)
127                 {
128                     C c = new C(A_OFFSET + B_OFFSET * ib + C_OFFSET * ic);
129                     c.setB(b);
130                     for (int id = 0; id < NUM_D_PER_C; id++)
131                     {
132                         D d = new D(A_OFFSET + B_OFFSET * ib + C_OFFSET * ic + D_OFFSET * id);
133                         c.setD(d);
134                         broker.store(d);
135                         broker.store(c);
136                         System.out.println("\t\tC - " + c.getCAttrib());
137                         System.out.println("\t\t\tD - " + d.getDAttrib());
138                     }
139                 }
140                 for (int ic = 0; ic < NUM_C1_PER_B; ic++)
141                 {
142                     C1 c1 = new C1(A_OFFSET + B_OFFSET * ib + C_OFFSET * ic);
143                     c1.setB(b);
144                     for (int id = 0; id < NUM_D_PER_C; id++)
145                     {
146                         D d = new D(A_OFFSET + B_OFFSET * ib + C_OFFSET * ic + D_OFFSET * id);
147                         c1.setD(d);
148                         c1.setC1Attrib(c1.getCAttrib() + 1);
149                         broker.store(d);
150                         broker.store(c1);
151                         System.out.println("\t\tC1 - " + c1.getC1Attrib());
152                         System.out.println("\t\t\tD - " + d.getDAttrib());
153                     }
154                 }
155             }
156         }
157         
158         broker.commitTransaction();
159
160         broker.clearCache();
161
162         Criteria crit = new Criteria();
163
164         Query query = QueryFactory.newQuery(A.class, crit);
165         Collection JavaDoc As = broker.getCollectionByQuery(query);
166         assertEquals(NUM_A, As.size());
167
168         query = QueryFactory.newQuery(B.class, crit);
169         Collection JavaDoc Bs = broker.getCollectionByQuery(query);
170         int numB = NUM_A * NUM_B_PER_A;
171         assertEquals(numB, Bs.size());
172
173         query = QueryFactory.newQuery(C.class, crit);
174         Collection JavaDoc Cs = broker.getCollectionByQuery(query);
175         int numC = numB * (NUM_C_PER_B + NUM_C1_PER_B);
176         assertEquals(numC, Cs.size());
177
178         query = QueryFactory.newQuery(D.class, crit);
179         Collection JavaDoc Ds = broker.getCollectionByQuery(query);
180         int numD = numC * NUM_D_PER_C;
181         assertEquals(numD, Ds.size());
182
183     }
184
185 // This is the result of the above population for NUM_A = 1
186
//
187
// A - 10000
188
// B - 10000
189
// C - 10000
190
// D - 10010
191
// C - 10100
192
// D - 10110
193
// C1 - 10001
194
// D - 10010
195
// C1 - 10101
196
// D - 10110
197
// C1 - 10201
198
// D - 10210
199
// B - 11000
200
// C - 11000
201
// D - 11010
202
// C - 11100
203
// D - 11110
204
// C1 - 11001
205
// D - 11010
206
// C1 - 11101
207
// D - 11110
208
// C1 - 11201
209
// D - 11210
210
// B - 12000
211
// C - 12000
212
// D - 12010
213
// C - 12100
214
// D - 12110
215
// C1 - 12001
216
// D - 12010
217
// C1 - 12101
218
// D - 12110
219
// C1 - 12201
220
// D - 12210
221
// B - 13000
222
// C - 13000
223
// D - 13010
224
// C - 13100
225
// D - 13110
226
// C1 - 13001
227
// D - 13010
228
// C1 - 13101
229
// D - 13110
230
// C1 - 13201
231
// D - 13210
232

233     /*
234      * Find all Bs having a particular C1 (c1)
235      * Works
236      */

237     public void testPathClassOnSegment1() throws Exception JavaDoc
238     {
239         try
240         {
241             // c1 criteria
242
Criteria crit1 = new Criteria();
243             crit1.addEqualTo("cSet.c1Attrib", new Integer JavaDoc("10001"));
244             crit1.addPathClass("cSet", C1.class);
245             
246             Query query = new QueryByCriteria(B.class, crit1);
247
248             Collection JavaDoc allBs = broker.getCollectionByQuery(query);
249
250             java.util.Iterator JavaDoc itr = allBs.iterator();
251
252             assertEquals(1 * NUM_A, allBs.size());
253             System.out.println("testPathClassOnSegment1() iteration size:" + allBs.size());
254             while (itr.hasNext())
255             {
256                 B b = (B) itr.next();
257                 System.out.println("Found B: " + b.getId() + " " + b.getBAttrib());
258             }
259         }
260         catch (Throwable JavaDoc t)
261         {
262             t.printStackTrace(System.out);
263             fail("testPathClassOnSegment1: " + t.getMessage());
264         }
265     }
266     
267     /*
268      * Find all As having a particular C1 (c1)
269      * Works
270      */

271     public void testPathClassOnSegment2() throws Exception JavaDoc
272     {
273         try
274         {
275             // c1 criteria
276
Criteria crit1 = new Criteria();
277             crit1.addEqualTo("bSet.cSet.c1Attrib", new Integer JavaDoc("10001"));
278             crit1.addPathClass("bSet.cSet", C1.class);
279             
280             Query query = new QueryByCriteria(A.class, crit1);
281
282             Collection JavaDoc allAs = broker.getCollectionByQuery(query);
283
284             java.util.Iterator JavaDoc itr = allAs.iterator();
285
286             assertEquals(allAs.size(), 1 * NUM_A);
287             System.out.println("testPathClassOnSegment2() iteration size:" + allAs.size());
288             while (itr.hasNext())
289             {
290                 A a = (A) itr.next();
291                 System.out.println("Found A: " + a.getId() + " " + a.getAAttrib());
292             }
293         }
294         catch (Throwable JavaDoc t)
295         {
296             t.printStackTrace(System.out);
297             fail("testPathClassOnSegment2: " + t.getMessage());
298         }
299     }
300     
301     /*
302      * Find all Bs having a C with a particular D (d1)
303      * Works
304      */

305     public void testSingleAlias() throws Exception JavaDoc
306     {
307         try
308         {
309             // d1 criteria
310
Criteria crit1 = new Criteria();
311             crit1.setAlias("cToD1", "cSet"); // unnecessary, but its use should not
312
// cause incorrect results
313
crit1.addEqualTo("cSet.d.dAttrib", new Integer JavaDoc("10010"));
314
315             Query query = new QueryByCriteria(B.class, crit1);
316
317             Collection JavaDoc allBs = broker.getCollectionByQuery(query);
318
319             java.util.Iterator JavaDoc itr = allBs.iterator();
320
321             assertEquals(2 * NUM_A, allBs.size());
322             System.out.println("testSingleAlias() iteration size:" + allBs.size());
323             while (itr.hasNext())
324             {
325                 B b = (B) itr.next();
326                 System.out.println("Found B: " + b.getId() + " " + b.getBAttrib());
327             }
328         }
329         catch (Throwable JavaDoc t)
330         {
331             t.printStackTrace(System.out);
332             fail("testSingleAlias: " + t.getMessage());
333         }
334     }
335     
336     /*
337      * Find all Bs having any C with a particular D (d1) and any C with a particular D (d2)
338      * Works
339      */

340     public void testTwoAliasesTwoSegments() throws Exception JavaDoc
341     {
342         try
343         {
344             // d1 criteria
345
Criteria crit1 = new Criteria();
346             crit1.setAlias("cToD1", "cSet.d");
347             crit1.addEqualTo("cSet.d.dAttrib", new Integer JavaDoc("10010"));
348
349             // d2 criteria
350
Criteria crit2 = new Criteria();
351             crit2.setAlias("cToD2", "cSet.d");
352             crit2.addEqualTo("cSet.d.dAttrib", new Integer JavaDoc("10110"));
353
354             crit1.addAndCriteria(crit2);
355
356             Query query = new QueryByCriteria(B.class, crit1);
357
358             Collection JavaDoc allBs = broker.getCollectionByQuery(query);
359
360             java.util.Iterator JavaDoc itr = allBs.iterator();
361
362             assertEquals(4 * NUM_A, allBs.size());
363             System.out.println("testTwoAliasesTwoSegments() iteration size:" + allBs.size());
364             while (itr.hasNext())
365             {
366                 B b = (B) itr.next();
367                 System.out.println("Found B: " + b.getId() + " " + b.getBAttrib());
368             }
369         }
370         catch (Throwable JavaDoc t)
371         {
372             t.printStackTrace(System.out);
373             fail("testTwoAliasesTwoSegments: " + t.getMessage());
374         }
375     }
376     
377     /*
378      * Find all As having any B with any C with a particular D (d1) and any C with a particular D (d2)
379      * Works
380      */

381     public void testTwoAliasesThreeSegments() throws Exception JavaDoc
382     {
383         try
384         {
385             // d1 criteria
386
Criteria crit1 = new Criteria();
387             crit1.addEqualTo("bSet.cSet.d.dAttrib", new Integer JavaDoc("10010"));
388             crit1.setAlias("bToCToD1", "cSet.d");
389
390             // d2 criteria
391
Criteria crit2 = new Criteria();
392             crit2.addEqualTo("bSet.cSet.d.dAttrib", new Integer JavaDoc("10110"));
393             crit2.setAlias("bToCToD2", "cSet.d");
394
395             crit1.addAndCriteria(crit2);
396
397             boolean isDistinct = true;
398             Query query = new QueryByCriteria(A.class, crit1, true);
399
400             Collection JavaDoc allAs = broker.getCollectionByQuery(query);
401
402             java.util.Iterator JavaDoc itr = allAs.iterator();
403
404             assertEquals(1 * NUM_A, allAs.size());
405             System.out.println("testTwoAliasesThreeSegments() iteration size:" + allAs.size());
406             while (itr.hasNext())
407             {
408                 A a = (A) itr.next();
409                 System.out.println("Found A: " + a.getId() + " " + a.getAAttrib());
410             }
411         }
412         catch (Throwable JavaDoc t)
413         {
414             t.printStackTrace(System.out);
415             fail("testTwoAliasesThreeSegments: " + t.getMessage());
416         }
417     }
418     
419     /*
420      * Find all Bs having a particular C (c) and a particular C1 (c1)
421      */

422     public void testPathClassPerCriteria() throws Exception JavaDoc
423     {
424         try
425         {
426             // C criteria
427
Criteria crit1 = new Criteria();
428             crit1.addEqualTo("cSet.cAttrib", new Integer JavaDoc("10200"));
429             crit1.addPathClass("cSet", C.class);
430             crit1.setAlias("alias1");
431
432             // C1 criteria (subclass of C)
433
Criteria crit2 = new Criteria();
434             crit2.addEqualTo("cSet.c1Attrib", new Integer JavaDoc("10001"));
435             crit2.addPathClass("cSet", C1.class);
436             crit2.setAlias("alias2");
437
438             crit1.addAndCriteria(crit2);
439
440             Query query = new QueryByCriteria(B.class, crit1);
441
442             Collection JavaDoc allBs = broker.getCollectionByQuery(query);
443
444             java.util.Iterator JavaDoc itr = allBs.iterator();
445
446             assertEquals(1 * NUM_A, allBs.size());
447             System.out.println("testPathClassPerCriteria() iteration size:" + allBs.size());
448             while (itr.hasNext())
449             {
450                 B b = (B) itr.next();
451                 System.out.println("Found B: " + b.getId() + " " + b.getBAttrib());
452             }
453         }
454         catch (Throwable JavaDoc t)
455         {
456             t.printStackTrace(System.out);
457             fail("testPathClassPerCriteria: " + t.getMessage());
458         }
459     }
460     
461     /*
462      * Find all Bs having a particular C1 (c1_a) and a particular C3 (c1_b)
463      * Works
464      */

465     public void testPathClassPerQuery() throws Exception JavaDoc
466     {
467         try
468         {
469             // c1_a criteria
470
Criteria crit1 = new Criteria();
471             crit1.addEqualTo("cSet.c1Attrib", new Integer JavaDoc("12001"));
472             //crit1.addPathClass("cSet", C1.class); // can use 1 query setting instead
473
crit1.setAlias("alias1");
474
475             // c2_b criteria
476
Criteria crit2 = new Criteria();
477             crit2.addEqualTo("cSet.c1Attrib", new Integer JavaDoc("12101"));
478             //crit2.addPathClass("cSet", C1.class); // can use 1 query setting instead
479
crit2.setAlias("alias2");
480
481             crit1.addAndCriteria(crit2);
482
483             QueryByCriteria query = new QueryByCriteria(B.class, crit1);
484             query.addPathClass("cSet", C1.class);
485
486             Collection JavaDoc allBs = broker.getCollectionByQuery(query);
487
488             java.util.Iterator JavaDoc itr = allBs.iterator();
489
490             assertEquals(1 * NUM_A, allBs.size());
491             System.out.println("testPathClassPerQuery() iteration size:" + allBs.size());
492             while (itr.hasNext())
493             {
494                 B b = (B) itr.next();
495                 System.out.println("Found B: " + b.getId() + " " + b.getBAttrib());
496             }
497         }
498         catch (Throwable JavaDoc t)
499         {
500             t.printStackTrace(System.out);
501             fail("testPathClassPerQuery: " + t.getMessage());
502         }
503     }
504     
505     /*
506      * Find all As having a B with both a particular C-D combination and
507      * another particular C-D combination
508      */

509     public void testThreeSegmentsAliasOnSegment2And3() throws Exception JavaDoc
510     {
511         try
512         {
513             // d1 criteria
514
Criteria crit1 = new Criteria();
515             crit1.addEqualTo("bSet.cSet.d.dAttrib", new Integer JavaDoc("10010"));
516             crit1.setAlias("bToCToD1", "cSet.d");
517
518             // d2 criteria
519
Criteria crit2 = new Criteria();
520             crit2.addEqualTo("bSet.cSet.d.dAttrib", new Integer JavaDoc("10110"));
521             crit2.setAlias("bToCToD2", "cSet.d");
522
523             crit1.addAndCriteria(crit2);
524
525             boolean isDistinct = true;
526             Query query = new QueryByCriteria(A.class, crit1, isDistinct);
527
528             Collection JavaDoc allAs = broker.getCollectionByQuery(query);
529
530             java.util.Iterator JavaDoc itr = allAs.iterator();
531
532             assertEquals(1 * NUM_A, allAs.size());
533             System.out.println("testThreeSegmentsAliasOnSegment2And3() iteration size:" + allAs.size());
534             while (itr.hasNext())
535             {
536                 A a = (A) itr.next();
537                 System.out.println("Found A: " + a.getId() + " " + a.getAAttrib());
538             }
539         }
540         catch (Throwable JavaDoc t)
541         {
542             t.printStackTrace(System.out);
543             fail("testThreeSegmentsAliasOnSegment2And3: " + t.getMessage());
544         }
545     }
546     
547     /*
548      * Same as above using an explicit UserAlias
549      */

550     public void testThreeSegmentsAliasOnSegment2And3UserAlias() throws Exception JavaDoc
551     {
552         try
553         {
554             UserAlias userAlias1 = new UserAlias("alias1");
555             userAlias1.add("bSet.cSet");
556             userAlias1.add("bSet.cSet.d");
557             
558             // d1 criteria
559
Criteria crit1 = new Criteria();
560             crit1.addEqualTo("bSet.cSet.d.dAttrib", new Integer JavaDoc("10010"));
561             crit1.setAlias(userAlias1);
562
563             // d2 criteria
564
UserAlias userAlias2 = new UserAlias("alias2");
565             userAlias2.add("bSet.cSet");
566             userAlias2.add("bSet.cSet.d");
567
568             Criteria crit2 = new Criteria();
569             crit2.addEqualTo("bSet.cSet.d.dAttrib", new Integer JavaDoc("10110"));
570             crit2.setAlias(userAlias2);
571
572             crit1.addAndCriteria(crit2);
573
574             boolean isDistinct = true;
575             Query query = new QueryByCriteria(A.class, crit1, isDistinct);
576
577             Collection JavaDoc allAs = broker.getCollectionByQuery(query);
578
579             java.util.Iterator JavaDoc itr = allAs.iterator();
580
581             assertEquals(1 * NUM_A, allAs.size());
582             System.out.println("testThreeSegmentsAliasOnSegment2And3UserAlias() iteration size:" + allAs.size());
583             while (itr.hasNext())
584             {
585                 A a = (A) itr.next();
586                 System.out.println("Found A: " + a.getId() + " " + a.getAAttrib());
587             }
588         }
589         catch (Throwable JavaDoc t)
590         {
591             t.printStackTrace(System.out);
592             fail("testThreeSegmentsAliasOnSegment2And3UserAlias: " + t.getMessage());
593         }
594     }
595     
596     public void testSubQueryExists()
597     {
598         // subquery
599
Criteria subCrit = new Criteria();
600         subCrit.addEqualTo(Criteria.PARENT_QUERY_PREFIX + "bSet.cSet.d.dAttrib", new Integer JavaDoc("10011"));
601         // subCrit.setAlias("subAlias", "cSet.d");
602
QueryByCriteria subQuery = new QueryByCriteria(A.class, subCrit);
603
604         // parent query
605
Criteria crit = new Criteria();
606         crit.addEqualTo("bSet.cSet.d.dAttrib", new Integer JavaDoc("10010"));
607         // crit.setAlias("alias", "cSet.d");
608
crit.addNotExists(subQuery);
609         QueryByCriteria query = new QueryByCriteria(A.class, crit,true);
610
611         Collection JavaDoc result = broker.getCollectionByQuery(query);
612         assertEquals(1 * NUM_A, result.size());
613         
614         Iterator JavaDoc itr = result.iterator();
615         while (itr.hasNext())
616         {
617             A a = (A) itr.next();
618             System.out.println("Found A: " + a.getId() + " " + a.getAAttrib());
619         }
620     }
621     
622     // Inner Classes
623

624     public static class A
625     {
626         private long id;
627         private int aAttrib;
628         private Collection JavaDoc bSet;
629
630         public A()
631         {
632         }
633
634         public A(int aAttrib)
635         {
636             this.aAttrib = aAttrib;
637             this.bSet = new ArrayList JavaDoc();
638         }
639
640         // make javabeans conform
641
public int getaAttrib()
642         {
643             return aAttrib;
644         }
645         // make javabeans conform
646
public Collection JavaDoc getbSet()
647         {
648             return bSet;
649         }
650         // make javabeans conform
651
public void setbSet(Collection JavaDoc bSet)
652         {
653             this.bSet = bSet;
654         }
655         // make javabeans conform
656
public void setaAttrib(int aAttrib)
657         {
658             this.aAttrib = aAttrib;
659         }
660
661         /**
662          * @return
663          */

664         public int getAAttrib()
665         {
666             return aAttrib;
667         }
668
669         /**
670          * @return
671          */

672         public Collection JavaDoc getBSet()
673         {
674             return bSet;
675         }
676
677         /**
678          * @return
679          */

680         public long getId()
681         {
682             return id;
683         }
684
685         /**
686          * @param i
687          */

688         public void setAAttrib(int i)
689         {
690             aAttrib = i;
691         }
692
693         /**
694          * @param collection
695          */

696         public void setBSet(Collection JavaDoc collection)
697         {
698             bSet = collection;
699         }
700
701         /**
702          * @param l
703          */

704         public void setId(long l)
705         {
706             id = l;
707         }
708
709     }
710
711     public static class B
712     {
713         private long id;
714         private long aId;
715         private int bAttrib;
716         private A a;
717         private Collection JavaDoc cSet;
718
719         public B()
720         {
721         }
722
723         public B(int bAttrib)
724         {
725             this.bAttrib = bAttrib;
726             this.cSet = new ArrayList JavaDoc();
727         }
728
729         /**
730          * @return
731          */

732         public int getBAttrib()
733         {
734             return bAttrib;
735         }
736
737         /**
738          * @return
739          */

740         public Collection JavaDoc getCSet()
741         {
742             return cSet;
743         }
744
745         /**
746          * @return
747          */

748         public long getId()
749         {
750             return id;
751         }
752
753         /**
754          * @param i
755          */

756         public void setBAttrib(int i)
757         {
758             bAttrib = i;
759         }
760
761         /**
762          * @param collection
763          */

764         public void setCSet(Collection JavaDoc collection)
765         {
766             cSet = collection;
767         }
768
769         /**
770          * @param l
771          */

772         public void setId(long l)
773         {
774             id = l;
775         }
776
777         /**
778          * @return
779          */

780         public A getA()
781         {
782             return a;
783         }
784
785         /**
786          * @param a
787          */

788         public void setA(A a)
789         {
790             this.a = a;
791             a.getBSet().add(this);
792         }
793
794     }
795
796     public static class C
797     {
798         private long id;
799         private long bId;
800         private B b;
801         private long dId;
802         private D d;
803         private int cAttrib;
804
805         public C()
806         {
807         }
808
809         public C(int cAttrib)
810         {
811             this.cAttrib = cAttrib;
812         }
813
814         /**
815          * @return
816          */

817         public int getCAttrib()
818         {
819             return cAttrib;
820         }
821
822         /**
823          * @return
824          */

825         public D getD()
826         {
827             return d;
828         }
829
830         /**
831          * @return
832          */

833         public long getId()
834         {
835             return id;
836         }
837
838         /**
839          * @param i
840          */

841         public void setCAttrib(int i)
842         {
843             cAttrib = i;
844         }
845
846         /**
847          * @param collection
848          */

849         public void setD(D d)
850         {
851             this.d = d;
852         }
853
854         /**
855          * @param l
856          */

857         public void setId(long l)
858         {
859             id = l;
860         }
861
862         /**
863          * @return
864          */

865         public B getB()
866         {
867             return b;
868         }
869
870         /**
871          * @param b
872          */

873         public void setB(B b)
874         {
875             this.b = b;
876             b.getCSet().add(this);
877         }
878
879     }
880
881     public static class C1 extends C
882     {
883
884         private int c1Attrib;
885
886         /**
887          * @param cAttrib
888          */

889
890         public C1()
891         {
892         }
893
894         public C1(int cAttrib)
895         {
896             super(cAttrib);
897         }
898
899         /**
900          * @return
901          */

902         public int getC1Attrib()
903         {
904             return c1Attrib;
905         }
906
907         /**
908          * @param i
909          */

910         public void setC1Attrib(int i)
911         {
912             c1Attrib = i;
913         }
914
915     }
916
917     public static class D
918     {
919         private long id;
920         private int dAttrib;
921
922         public D()
923         {
924         }
925
926         public D(int dAttrib)
927         {
928             this.dAttrib = dAttrib;
929         }
930
931         /**
932          * @return
933          */

934         public int getDAttrib()
935         {
936             return dAttrib;
937         }
938
939         /**
940          * @return
941          */

942         public long getId()
943         {
944             return id;
945         }
946
947         /**
948          * @param i
949          */

950         public void setDAttrib(int i)
951         {
952             dAttrib = i;
953         }
954
955         /**
956          * @param l
957          */

958         public void setId(long l)
959         {
960             id = l;
961         }
962
963     }
964
965 }
966
967
Popular Tags