1 package org.tigris.scarab.om; 2 3 import java.math.BigDecimal ; 4 import java.sql.Connection ; 5 import java.sql.SQLException ; 6 import java.util.ArrayList ; 7 import java.util.Date ; 8 import java.util.Iterator ; 9 import java.util.LinkedList ; 10 import java.util.List ; 11 12 import org.apache.torque.NoRowsException; 13 import org.apache.torque.TooManyRowsException; 14 import org.apache.torque.Torque; 15 import org.apache.torque.TorqueException; 16 import org.apache.torque.map.MapBuilder; 17 import org.apache.torque.map.TableMap; 18 import org.apache.torque.om.DateKey; 19 import org.apache.torque.om.NumberKey; 20 import org.apache.torque.om.StringKey; 21 import org.apache.torque.om.ObjectKey; 22 import org.apache.torque.om.SimpleKey; 23 import org.apache.torque.util.BasePeer; 24 import org.apache.torque.util.Criteria; 25 26 import com.workingdogs.village.DataSetException; 27 import com.workingdogs.village.QueryDataSet; 28 import com.workingdogs.village.Record; 29 30 import org.tigris.scarab.om.map.*; 32 33 34 35 36 37 39 public abstract class BaseMITListItemPeer 40 extends BasePeer 41 { 42 43 44 public static final String DATABASE_NAME = "scarab"; 45 46 47 public static final String TABLE_NAME = "SCARAB_MIT_LISTITEM"; 48 49 54 public static MapBuilder getMapBuilder() 55 throws TorqueException 56 { 57 return getMapBuilder(MITListItemMapBuilder.CLASS_NAME); 58 } 59 60 61 public static final String ITEM_ID; 62 63 public static final String MODULE_ID; 64 65 public static final String ISSUE_TYPE_ID; 66 67 public static final String LIST_ID; 68 69 static 70 { 71 ITEM_ID = "SCARAB_MIT_LISTITEM.ITEM_ID"; 72 MODULE_ID = "SCARAB_MIT_LISTITEM.MODULE_ID"; 73 ISSUE_TYPE_ID = "SCARAB_MIT_LISTITEM.ISSUE_TYPE_ID"; 74 LIST_ID = "SCARAB_MIT_LISTITEM.LIST_ID"; 75 if (Torque.isInit()) 76 { 77 try 78 { 79 getMapBuilder(MITListItemMapBuilder.CLASS_NAME); 80 } 81 catch (Exception e) 82 { 83 log.error("Could not initialize Peer", e); 84 } 85 } 86 else 87 { 88 Torque.registerMapBuilder(MITListItemMapBuilder.CLASS_NAME); 89 } 90 } 91 92 93 public static final int numColumns = 4; 94 95 96 protected static final String CLASSNAME_DEFAULT = 97 "org.tigris.scarab.om.MITListItem"; 98 99 100 protected static final Class CLASS_DEFAULT = initClass(CLASSNAME_DEFAULT); 101 102 108 private static Class initClass(String className) 109 { 110 Class c = null; 111 try 112 { 113 c = Class.forName(className); 114 } 115 catch (Throwable t) 116 { 117 log.error("A FATAL ERROR has occurred which should not " 118 + "have happened under any circumstance. Please notify " 119 + "the Torque developers <torque-dev@db.apache.org> " 120 + "and give as many details as possible (including the error " 121 + "stack trace).", t); 122 123 if (t instanceof Error ) 125 { 126 throw (Error ) t.fillInStackTrace(); 127 } 128 } 129 return c; 130 } 131 132 142 public static List resultSet2Objects(java.sql.ResultSet results) 143 throws TorqueException 144 { 145 try 146 { 147 QueryDataSet qds = null; 148 List rows = null; 149 try 150 { 151 qds = new QueryDataSet(results); 152 rows = getSelectResults(qds); 153 } 154 finally 155 { 156 if (qds != null) 157 { 158 qds.close(); 159 } 160 } 161 162 return populateObjects(rows); 163 } 164 catch (SQLException e) 165 { 166 throw new TorqueException(e); 167 } 168 catch (DataSetException e) 169 { 170 throw new TorqueException(e); 171 } 172 } 173 174 175 176 183 public static ObjectKey doInsert(Criteria criteria) 184 throws TorqueException 185 { 186 return BaseMITListItemPeer 187 .doInsert(criteria, (Connection ) null); 188 } 189 190 200 public static ObjectKey doInsert(Criteria criteria, Connection con) 201 throws TorqueException 202 { 203 204 setDbName(criteria); 205 206 if (con == null) 207 { 208 return BasePeer.doInsert(criteria); 209 } 210 else 211 { 212 return BasePeer.doInsert(criteria, con); 213 } 214 } 215 216 223 public static void addSelectColumns(Criteria criteria) 224 throws TorqueException 225 { 226 criteria.addSelectColumn(ITEM_ID); 227 criteria.addSelectColumn(MODULE_ID); 228 criteria.addSelectColumn(ISSUE_TYPE_ID); 229 criteria.addSelectColumn(LIST_ID); 230 } 231 232 241 public static MITListItem row2Object(Record row, 242 int offset, 243 Class cls) 244 throws TorqueException 245 { 246 try 247 { 248 MITListItem obj = (MITListItem) cls.newInstance(); 249 MITListItemPeer.populateObject(row, offset, obj); 250 obj.setModified(false); 251 obj.setNew(false); 252 253 return obj; 254 } 255 catch (InstantiationException e) 256 { 257 throw new TorqueException(e); 258 } 259 catch (IllegalAccessException e) 260 { 261 throw new TorqueException(e); 262 } 263 } 264 265 274 public static void populateObject(Record row, 275 int offset, 276 MITListItem obj) 277 throws TorqueException 278 { 279 try 280 { 281 obj.setItemId(row.getValue(offset + 0).asLongObj()); 282 obj.setModuleId(row.getValue(offset + 1).asIntegerObj()); 283 obj.setIssueTypeId(row.getValue(offset + 2).asIntegerObj()); 284 obj.setListId(row.getValue(offset + 3).asLongObj()); 285 } 286 catch (DataSetException e) 287 { 288 throw new TorqueException(e); 289 } 290 } 291 292 300 public static List doSelect(Criteria criteria) throws TorqueException 301 { 302 return populateObjects(doSelectVillageRecords(criteria)); 303 } 304 305 314 public static List doSelect(Criteria criteria, Connection con) 315 throws TorqueException 316 { 317 return populateObjects(doSelectVillageRecords(criteria, con)); 318 } 319 320 330 public static List doSelectVillageRecords(Criteria criteria) 331 throws TorqueException 332 { 333 return BaseMITListItemPeer 334 .doSelectVillageRecords(criteria, (Connection ) null); 335 } 336 337 346 public static List doSelectVillageRecords(Criteria criteria, Connection con) 347 throws TorqueException 348 { 349 if (criteria.getSelectColumns().size() == 0) 350 { 351 addSelectColumns(criteria); 352 } 353 354 355 setDbName(criteria); 356 357 if (con == null) 360 { 361 return BasePeer.doSelect(criteria); 362 } 363 else 364 { 365 return BasePeer.doSelect(criteria, con); 366 } 367 } 368 369 376 public static List populateObjects(List records) 377 throws TorqueException 378 { 379 List results = new ArrayList (records.size()); 380 381 for (int i = 0; i < records.size(); i++) 383 { 384 Record row = (Record) records.get(i); 385 results.add(MITListItemPeer.row2Object(row, 1, 386 MITListItemPeer.getOMClass())); 387 } 388 return results; 389 } 390 391 392 400 public static Class getOMClass() 401 throws TorqueException 402 { 403 return CLASS_DEFAULT; 404 } 405 406 414 public static void doUpdate(Criteria criteria) throws TorqueException 415 { 416 BaseMITListItemPeer 417 .doUpdate(criteria, (Connection ) null); 418 } 419 420 431 public static void doUpdate(Criteria criteria, Connection con) 432 throws TorqueException 433 { 434 Criteria selectCriteria = new Criteria(DATABASE_NAME, 2); 435 selectCriteria.put(ITEM_ID, criteria.remove(ITEM_ID)); 436 437 setDbName(criteria); 438 439 if (con == null) 440 { 441 BasePeer.doUpdate(selectCriteria, criteria); 442 } 443 else 444 { 445 BasePeer.doUpdate(selectCriteria, criteria, con); 446 } 447 } 448 449 456 public static void doDelete(Criteria criteria) throws TorqueException 457 { 458 MITListItemPeer 459 .doDelete(criteria, (Connection ) null); 460 } 461 462 472 public static void doDelete(Criteria criteria, Connection con) 473 throws TorqueException 474 { 475 476 setDbName(criteria); 477 478 if (con == null) 479 { 480 BasePeer.doDelete(criteria); 481 } 482 else 483 { 484 BasePeer.doDelete(criteria, con); 485 } 486 } 487 488 494 public static List doSelect(MITListItem obj) throws TorqueException 495 { 496 return doSelect(buildSelectCriteria(obj)); 497 } 498 499 505 public static void doInsert(MITListItem obj) throws TorqueException 506 { 507 obj.setPrimaryKey(doInsert(buildCriteria(obj))); 508 obj.setNew(false); 509 obj.setModified(false); 510 } 511 512 517 public static void doUpdate(MITListItem obj) throws TorqueException 518 { 519 doUpdate(buildCriteria(obj)); 520 obj.setModified(false); 521 } 522 523 528 public static void doDelete(MITListItem obj) throws TorqueException 529 { 530 doDelete(buildSelectCriteria(obj)); 531 } 532 533 543 public static void doInsert(MITListItem obj, Connection con) 544 throws TorqueException 545 { 546 obj.setPrimaryKey(doInsert(buildCriteria(obj), con)); 547 obj.setNew(false); 548 obj.setModified(false); 549 } 550 551 561 public static void doUpdate(MITListItem obj, Connection con) 562 throws TorqueException 563 { 564 doUpdate(buildCriteria(obj), con); 565 obj.setModified(false); 566 } 567 568 578 public static void doDelete(MITListItem obj, Connection con) 579 throws TorqueException 580 { 581 doDelete(buildSelectCriteria(obj), con); 582 } 583 584 591 public static void doDelete(ObjectKey pk) throws TorqueException 592 { 593 BaseMITListItemPeer 594 .doDelete(pk, (Connection ) null); 595 } 596 597 607 public static void doDelete(ObjectKey pk, Connection con) 608 throws TorqueException 609 { 610 doDelete(buildCriteria(pk), con); 611 } 612 613 614 public static Criteria buildCriteria( ObjectKey pk ) 615 { 616 Criteria criteria = new Criteria(); 617 criteria.add(ITEM_ID, pk); 618 return criteria; 619 } 620 621 622 public static Criteria buildCriteria( MITListItem obj ) 623 { 624 Criteria criteria = new Criteria(DATABASE_NAME); 625 if (!obj.isNew()) 626 criteria.add(ITEM_ID, obj.getItemId()); 627 criteria.add(MODULE_ID, obj.getModuleId()); 628 criteria.add(ISSUE_TYPE_ID, obj.getIssueTypeId()); 629 criteria.add(LIST_ID, obj.getListId()); 630 return criteria; 631 } 632 633 634 public static Criteria buildSelectCriteria( MITListItem obj ) 635 { 636 Criteria criteria = new Criteria(DATABASE_NAME); 637 if (!obj.isNew()) 638 criteria.add(ITEM_ID, obj.getItemId()); 639 criteria.add(MODULE_ID, obj.getModuleId()); 640 criteria.add(ISSUE_TYPE_ID, obj.getIssueTypeId()); 641 criteria.add(LIST_ID, obj.getListId()); 642 return criteria; 643 } 644 645 646 655 public static MITListItem retrieveByPK(Long pk) 656 throws TorqueException, NoRowsException, TooManyRowsException 657 { 658 return retrieveByPK(SimpleKey.keyFor(pk)); 659 } 660 661 671 public static MITListItem retrieveByPK(Long pk, Connection con) 672 throws TorqueException, NoRowsException, TooManyRowsException 673 { 674 return retrieveByPK(SimpleKey.keyFor(pk), con); 675 } 676 677 686 public static MITListItem retrieveByPK(ObjectKey pk) 687 throws TorqueException, NoRowsException, TooManyRowsException 688 { 689 Connection db = null; 690 MITListItem retVal = null; 691 try 692 { 693 db = Torque.getConnection(DATABASE_NAME); 694 retVal = retrieveByPK(pk, db); 695 } 696 finally 697 { 698 Torque.closeConnection(db); 699 } 700 return(retVal); 701 } 702 703 713 public static MITListItem retrieveByPK(ObjectKey pk, Connection con) 714 throws TorqueException, NoRowsException, TooManyRowsException 715 { 716 Criteria criteria = buildCriteria(pk); 717 List v = doSelect(criteria, con); 718 if (v.size() == 0) 719 { 720 throw new NoRowsException("Failed to select a row."); 721 } 722 else if (v.size() > 1) 723 { 724 throw new TooManyRowsException("Failed to select only one row."); 725 } 726 else 727 { 728 return (MITListItem)v.get(0); 729 } 730 } 731 732 739 public static List retrieveByPKs(List pks) 740 throws TorqueException 741 { 742 Connection db = null; 743 List retVal = null; 744 try 745 { 746 db = Torque.getConnection(DATABASE_NAME); 747 retVal = retrieveByPKs(pks, db); 748 } 749 finally 750 { 751 Torque.closeConnection(db); 752 } 753 return(retVal); 754 } 755 756 764 public static List retrieveByPKs( List pks, Connection dbcon ) 765 throws TorqueException 766 { 767 List objs = null; 768 if (pks == null || pks.size() == 0) 769 { 770 objs = new LinkedList (); 771 } 772 else 773 { 774 Criteria criteria = new Criteria(); 775 criteria.addIn( ITEM_ID, pks ); 776 objs = doSelect(criteria, dbcon); 777 } 778 return objs; 779 } 780 781 782 783 784 785 786 787 788 789 790 801 protected static List doSelectJoinMITList(Criteria criteria) 802 throws TorqueException 803 { 804 setDbName(criteria); 805 806 MITListItemPeer.addSelectColumns(criteria); 807 int offset = numColumns + 1; 808 MITListPeer.addSelectColumns(criteria); 809 810 811 criteria.addJoin(MITListItemPeer.LIST_ID, 812 MITListPeer.LIST_ID); 813 814 815 816 List rows = BasePeer.doSelect(criteria); 817 List results = new ArrayList (); 818 819 for (int i = 0; i < rows.size(); i++) 820 { 821 Record row = (Record) rows.get(i); 822 823 Class omClass = MITListItemPeer.getOMClass(); 824 MITListItem obj1 = (MITListItem) MITListItemPeer 825 .row2Object(row, 1, omClass); 826 omClass = MITListPeer.getOMClass(); 827 MITList obj2 = (MITList)MITListPeer 828 .row2Object(row, offset, omClass); 829 830 boolean newObject = true; 831 for (int j = 0; j < results.size(); j++) 832 { 833 MITListItem temp_obj1 = (MITListItem)results.get(j); 834 MITList temp_obj2 = (MITList)temp_obj1.getMITList(); 835 if (temp_obj2.getPrimaryKey().equals(obj2.getPrimaryKey())) 836 { 837 newObject = false; 838 temp_obj2.addMITListItem(obj1); 839 break; 840 } 841 } 842 if (newObject) 843 { 844 obj2.initMITListItems(); 845 obj2.addMITListItem(obj1); 846 } 847 results.add(obj1); 848 } 849 return results; 850 } 851 852 853 854 855 866 protected static List doSelectJoinScarabModule(Criteria criteria) 867 throws TorqueException 868 { 869 setDbName(criteria); 870 871 MITListItemPeer.addSelectColumns(criteria); 872 int offset = numColumns + 1; 873 ScarabModulePeer.addSelectColumns(criteria); 874 875 876 criteria.addJoin(MITListItemPeer.MODULE_ID, 877 ScarabModulePeer.MODULE_ID); 878 879 880 881 List rows = BasePeer.doSelect(criteria); 882 List results = new ArrayList (); 883 884 for (int i = 0; i < rows.size(); i++) 885 { 886 Record row = (Record) rows.get(i); 887 888 Class omClass = MITListItemPeer.getOMClass(); 889 MITListItem obj1 = (MITListItem) MITListItemPeer 890 .row2Object(row, 1, omClass); 891 omClass = ScarabModulePeer.getOMClass(row, offset); 892 ScarabModule obj2 = (ScarabModule)ScarabModulePeer 893 .row2Object(row, offset, omClass); 894 895 boolean newObject = true; 896 for (int j = 0; j < results.size(); j++) 897 { 898 MITListItem temp_obj1 = (MITListItem)results.get(j); 899 ScarabModule temp_obj2 = (ScarabModule)temp_obj1.getModule(); 900 if (temp_obj2.getPrimaryKey().equals(obj2.getPrimaryKey())) 901 { 902 newObject = false; 903 temp_obj2.addMITListItem(obj1); 904 break; 905 } 906 } 907 if (newObject) 908 { 909 obj2.initMITListItems(); 910 obj2.addMITListItem(obj1); 911 } 912 results.add(obj1); 913 } 914 return results; 915 } 916 917 918 919 920 931 protected static List doSelectJoinIssueType(Criteria criteria) 932 throws TorqueException 933 { 934 setDbName(criteria); 935 936 MITListItemPeer.addSelectColumns(criteria); 937 int offset = numColumns + 1; 938 IssueTypePeer.addSelectColumns(criteria); 939 940 941 criteria.addJoin(MITListItemPeer.ISSUE_TYPE_ID, 942 IssueTypePeer.ISSUE_TYPE_ID); 943 944 945 946 List rows = BasePeer.doSelect(criteria); 947 List results = new ArrayList (); 948 949 for (int i = 0; i < rows.size(); i++) 950 { 951 Record row = (Record) rows.get(i); 952 953 Class omClass = MITListItemPeer.getOMClass(); 954 MITListItem obj1 = (MITListItem) MITListItemPeer 955 .row2Object(row, 1, omClass); 956 omClass = IssueTypePeer.getOMClass(); 957 IssueType obj2 = (IssueType)IssueTypePeer 958 .row2Object(row, offset, omClass); 959 960 boolean newObject = true; 961 for (int j = 0; j < results.size(); j++) 962 { 963 MITListItem temp_obj1 = (MITListItem)results.get(j); 964 IssueType temp_obj2 = (IssueType)temp_obj1.getIssueType(); 965 if (temp_obj2.getPrimaryKey().equals(obj2.getPrimaryKey())) 966 { 967 newObject = false; 968 temp_obj2.addMITListItem(obj1); 969 break; 970 } 971 } 972 if (newObject) 973 { 974 obj2.initMITListItems(); 975 obj2.addMITListItem(obj1); 976 } 977 results.add(obj1); 978 } 979 return results; 980 } 981 982 983 984 985 986 987 988 989 1000 protected static List doSelectJoinAllExceptMITList(Criteria criteria) 1001 throws TorqueException 1002 { 1003 setDbName(criteria); 1004 1005 addSelectColumns(criteria); 1006 int offset2 = numColumns + 1; 1007 1008 1009 ScarabModulePeer.addSelectColumns(criteria); 1010 int offset3 = offset2 + ScarabModulePeer.numColumns; 1011 1012 IssueTypePeer.addSelectColumns(criteria); 1013 int offset4 = offset3 + IssueTypePeer.numColumns; 1014 1015 List rows = BasePeer.doSelect(criteria); 1016 List results = new ArrayList (); 1017 1018 for (int i = 0; i < rows.size(); i++) 1019 { 1020 Record row = (Record)rows.get(i); 1021 1022 Class omClass = MITListItemPeer.getOMClass(); 1023 MITListItem obj1 = (MITListItem)MITListItemPeer 1024 .row2Object(row, 1, omClass); 1025 1026 1027 1028 1029 1030 omClass = ScarabModulePeer.getOMClass(row, offset2); 1031 ScarabModule obj2 = (ScarabModule)ScarabModulePeer 1032 .row2Object( row, offset2, omClass); 1033 1034 boolean newObject = true; 1035 for (int j = 0; j < results.size(); j++) 1036 { 1037 MITListItem temp_obj1 = (MITListItem)results.get(j); 1038 ScarabModule temp_obj2 = (ScarabModule)temp_obj1.getModule(); 1039 if (temp_obj2.getPrimaryKey().equals(obj2.getPrimaryKey())) 1040 { 1041 newObject = false; 1042 temp_obj2.addMITListItem(obj1); 1043 break; 1044 } 1045 } 1046 if (newObject) 1047 { 1048 obj2.initMITListItems(); 1049 obj2.addMITListItem(obj1); 1050 } 1051 1052 1053 1054 1055 omClass = IssueTypePeer.getOMClass(); 1056 IssueType obj3 = (IssueType)IssueTypePeer 1057 .row2Object( row, offset3, omClass); 1058 1059 newObject = true; 1060 for (int j = 0; j < results.size(); j++) 1061 { 1062 MITListItem temp_obj1 = (MITListItem)results.get(j); 1063 IssueType temp_obj3 = (IssueType)temp_obj1.getIssueType(); 1064 if (temp_obj3.getPrimaryKey().equals(obj3.getPrimaryKey())) 1065 { 1066 newObject = false; 1067 temp_obj3.addMITListItem(obj1); 1068 break; 1069 } 1070 } 1071 if (newObject) 1072 { 1073 obj3.initMITListItems(); 1074 obj3.addMITListItem(obj1); 1075 } 1076 results.add(obj1); 1077 } 1078 return results; 1079 } 1080 1081 1082 1083 1084 1085 1096 protected static List doSelectJoinAllExceptScarabModule(Criteria criteria) 1097 throws TorqueException 1098 { 1099 setDbName(criteria); 1100 1101 addSelectColumns(criteria); 1102 int offset2 = numColumns + 1; 1103 1104 MITListPeer.addSelectColumns(criteria); 1105 int offset3 = offset2 + MITListPeer.numColumns; 1106 1107 1108 IssueTypePeer.addSelectColumns(criteria); 1109 int offset4 = offset3 + IssueTypePeer.numColumns; 1110 1111 List rows = BasePeer.doSelect(criteria); 1112 List results = new ArrayList (); 1113 1114 for (int i = 0; i < rows.size(); i++) 1115 { 1116 Record row = (Record)rows.get(i); 1117 1118 Class omClass = MITListItemPeer.getOMClass(); 1119 MITListItem obj1 = (MITListItem)MITListItemPeer 1120 .row2Object(row, 1, omClass); 1121 1122 1123 1124 1125 omClass = MITListPeer.getOMClass(); 1126 MITList obj2 = (MITList)MITListPeer 1127 .row2Object( row, offset2, omClass); 1128 1129 boolean newObject = true; 1130 for (int j = 0; j < results.size(); j++) 1131 { 1132 MITListItem temp_obj1 = (MITListItem)results.get(j); 1133 MITList temp_obj2 = (MITList)temp_obj1.getMITList(); 1134 if (temp_obj2.getPrimaryKey().equals(obj2.getPrimaryKey())) 1135 { 1136 newObject = false; 1137 temp_obj2.addMITListItem(obj1); 1138 break; 1139 } 1140 } 1141 if (newObject) 1142 { 1143 obj2.initMITListItems(); 1144 obj2.addMITListItem(obj1); 1145 } 1146 1147 1148 1149 1150 1151 omClass = IssueTypePeer.getOMClass(); 1152 IssueType obj3 = (IssueType)IssueTypePeer 1153 .row2Object( row, offset3, omClass); 1154 1155 newObject = true; 1156 for (int j = 0; j < results.size(); j++) 1157 { 1158 MITListItem temp_obj1 = (MITListItem)results.get(j); 1159 IssueType temp_obj3 = (IssueType)temp_obj1.getIssueType(); 1160 if (temp_obj3.getPrimaryKey().equals(obj3.getPrimaryKey())) 1161 { 1162 newObject = false; 1163 temp_obj3.addMITListItem(obj1); 1164 break; 1165 } 1166 } 1167 if (newObject) 1168 { 1169 obj3.initMITListItems(); 1170 obj3.addMITListItem(obj1); 1171 } 1172 results.add(obj1); 1173 } 1174 return results; 1175 } 1176 1177 1178 1179 1180 1181 1192 protected static List doSelectJoinAllExceptIssueType(Criteria criteria) 1193 throws TorqueException 1194 { 1195 setDbName(criteria); 1196 1197 addSelectColumns(criteria); 1198 int offset2 = numColumns + 1; 1199 1200 MITListPeer.addSelectColumns(criteria); 1201 int offset3 = offset2 + MITListPeer.numColumns; 1202 1203 ScarabModulePeer.addSelectColumns(criteria); 1204 int offset4 = offset3 + ScarabModulePeer.numColumns; 1205 1206 1207 List rows = BasePeer.doSelect(criteria); 1208 List results = new ArrayList (); 1209 1210 for (int i = 0; i < rows.size(); i++) 1211 { 1212 Record row = (Record)rows.get(i); 1213 1214 Class omClass = MITListItemPeer.getOMClass(); 1215 MITListItem obj1 = (MITListItem)MITListItemPeer 1216 .row2Object(row, 1, omClass); 1217 1218 1219 1220 1221 omClass = MITListPeer.getOMClass(); 1222 MITList obj2 = (MITList)MITListPeer 1223 .row2Object( row, offset2, omClass); 1224 1225 boolean newObject = true; 1226 for (int j = 0; j < results.size(); j++) 1227 { 1228 MITListItem temp_obj1 = (MITListItem)results.get(j); 1229 MITList temp_obj2 = (MITList)temp_obj1.getMITList(); 1230 if (temp_obj2.getPrimaryKey().equals(obj2.getPrimaryKey())) 1231 { 1232 newObject = false; 1233 temp_obj2.addMITListItem(obj1); 1234 break; 1235 } 1236 } 1237 if (newObject) 1238 { 1239 obj2.initMITListItems(); 1240 obj2.addMITListItem(obj1); 1241 } 1242 1243 1244 1245 1246 omClass = ScarabModulePeer.getOMClass(row, offset3); 1247 ScarabModule obj3 = (ScarabModule)ScarabModulePeer 1248 .row2Object( row, offset3, omClass); 1249 1250 newObject = true; 1251 for (int j = 0; j < results.size(); j++) 1252 { 1253 MITListItem temp_obj1 = (MITListItem)results.get(j); 1254 ScarabModule temp_obj3 = (ScarabModule)temp_obj1.getModule(); 1255 if (temp_obj3.getPrimaryKey().equals(obj3.getPrimaryKey())) 1256 { 1257 newObject = false; 1258 temp_obj3.addMITListItem(obj1); 1259 break; 1260 } 1261 } 1262 if (newObject) 1263 { 1264 obj3.initMITListItems(); 1265 obj3.addMITListItem(obj1); 1266 } 1267 1268 results.add(obj1); 1269 } 1270 return results; 1271 } 1272 1273 1274 1281 protected static TableMap getTableMap() 1282 throws TorqueException 1283 { 1284 return Torque.getDatabaseMap(DATABASE_NAME).getTable(TABLE_NAME); 1285 } 1286 1287 private static void setDbName(Criteria crit) 1288 { 1289 if (crit.getDbName() == Torque.getDefaultDB()) 1293 { 1294 crit.setDbName(DATABASE_NAME); 1295 } 1296 } 1297} 1298 | Popular Tags |