1 package allinone; 2 3 import com.lutris.appserver.server.sql.*; 4 import com.lutris.util.*; 5 import org.enhydra.dods.*; 6 import java.sql.SQLException ; 7 8 9 import javax.swing.*; 10 import java.util.*; 11 import java.awt.*; 12 import java.awt.event.*; 13 import java.net.*; 14 import java.io.*; 15 import org.apache.log4j.Logger; 16 import org.apache.log4j.xml.DOMConfigurator; 17 import com.lutris.appserver.server.sql.*; 18 import allinone.data.tableA.*; 19 import allinone.data.tableB.*; 20 import allinone.data.tableC.*; 21 22 public class CircusMultiReference { 23 void showTables(DBTransaction dbTrans){ 24 try{ 25 CRTableAQuery queryA = new CRTableAQuery(dbTrans); 26 CRTableADO[] allADO = queryA.getDOArray(); 27 System.err.println(); 28 System.err.println("-------------TableA-----begin----------"); 29 if(allADO!=null) { 30 if(allADO.length>0)System.err.println("------oid---------someData--------refToB--------"); 31 for(int i=0; i<allADO.length; i++){ 32 System.err.print(" "+allADO[i].getHandle()); 33 System.err.print(" "+allADO[i].getSomedata()); 34 if (null != allADO[i].getReftob()) { 35 System.err.print(" "+allADO[i].getReftob().getOId()); 36 System.err.print(" "+allADO[i].getReftob().getSomedata()); 37 System.err.print(" "+allADO[i].getReftob().getReftoc()); 38 } 39 System.err.println(); 40 } 41 } else { 42 System.err.println("noData"); 43 } 44 System.err.println("-------------TableA-----end------------"); 45 46 CRTableBQuery queryB = new CRTableBQuery(dbTrans); 47 CRTableBDO[] allBDO = queryB.getDOArray(); 48 System.err.println(); 49 System.err.println("-------------TableB-----begin----------"); 50 if(allBDO!=null) { 51 if(allBDO.length>0)System.err.println("------oid---------someData--------refToC-----"); 52 for(int i=0; i<allBDO.length; i++){ 53 System.err.print(" "+allBDO[i].getHandle()); 54 System.err.print(" "+allBDO[i].getSomedata()); 55 if (null != allBDO[i].getReftoc()) { 56 System.err.print(" "+allBDO[i].getReftoc().getOId()); 57 System.err.print(" "+allBDO[i].getReftoc().getSomedata()); 58 } 59 System.err.println(); 60 } 61 } else { 62 System.err.println("noData"); 63 } 64 System.err.println("-------------TableB-----end------------"); 65 66 CRTableCQuery queryC = new CRTableCQuery(dbTrans); 67 CRTableCDO[] allCDO = queryC.getDOArray(); 68 System.err.println(); 69 System.err.println("-------------TableC-----begin----------"); 70 if(allCDO!=null) { 71 if(allCDO.length>0)System.err.println("------oid---------someData--------refToA-----"); 72 for(int i=0; i<allCDO.length; i++){ 73 System.err.print(" "+allCDO[i].getHandle()); 74 System.err.print(" "+allCDO[i].getSomedata()); 75 if (null != allCDO[i].getReftoa()) { 76 System.err.print(" "+allCDO[i].getReftoa().getOId()); 77 System.err.print(" "+allCDO[i].getReftoa().getSomedata()); 78 } 79 System.err.println(); 80 } 81 } else { 82 System.err.println("noData"); 83 } 84 System.err.println("-------------TableC-----end------------"); 85 }catch(Exception e){ 86 e.printStackTrace(); 87 } 88 } 89 90 public void runTest(DBTransaction dbTrans1) { 91 int maxDOs=9; 92 try { 93 System.err.println("___ - + * startin CircMultRef * + - ___"); 94 showTables(dbTrans1); 95 96 CRTableADO[] arrayOfA = new CRTableADO[maxDOs]; 97 CRTableBDO[] arrayOfB = new CRTableBDO[maxDOs]; 98 CRTableCDO[] arrayOfC = new CRTableCDO[maxDOs]; 99 100 for (int i=0; i<maxDOs; i++){ 101 arrayOfA[i] = CRTableADO.createVirgin(dbTrans1); 102 arrayOfB[i] = CRTableBDO.createVirgin(dbTrans1); 103 arrayOfC[i] = CRTableCDO.createVirgin(dbTrans1); 104 105 arrayOfC[i].setSomedata("tableC: "+i); 106 arrayOfC[i].save(); 107 108 if (null != dbTrans1) 109 dbTrans1.write(); 110 111 arrayOfB[i].setSomedata("tableB: "+i); 112 arrayOfB[i].setReftoc(arrayOfC[i]); 113 arrayOfB[i].save(); 114 115 arrayOfA[i].setSomedata("tableA: "+i); 116 arrayOfA[i].setReftob(arrayOfB[i]); 117 arrayOfA[i].save(); 118 119 if (null != dbTrans1) 120 dbTrans1.write(); 121 122 arrayOfC[i].setReftoa(arrayOfA[i]); 123 arrayOfC[i].save(); 124 } 125 if (null != dbTrans1) 126 dbTrans1.commit(); 127 System.err.println("after insert"); 128 showTables(dbTrans1); 129 132 System.err.println("signed, sealed and commited!!!"); 133 showTables(dbTrans1); 134 135 136 for (int i=0; i<maxDOs; i++){ 137 arrayOfC[i].setReftoa(null); 138 arrayOfC[i].save(); 139 } 140 143 144 for (int i=0; i<maxDOs; i++){ 145 arrayOfC[i].delete(); 146 } 147 if (null != dbTrans1) 148 dbTrans1.commit(); 149 150 System.err.println("signed, sealed and commited!!!"); 151 showTables(dbTrans1); 152 }catch (Exception ex){ 153 System.err.println(ex.toString()); 154 ex.printStackTrace(); 155 } 156 } 157 } 158 159 | Popular Tags |