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 BaseROptionOptionPeer 40 extends BasePeer 41 { 42 43 44 public static final String DATABASE_NAME = "scarab"; 45 46 47 public static final String TABLE_NAME = "SCARAB_R_OPTION_OPTION"; 48 49 54 public static MapBuilder getMapBuilder() 55 throws TorqueException 56 { 57 return getMapBuilder(ROptionOptionMapBuilder.CLASS_NAME); 58 } 59 60 61 public static final String OPTION1_ID; 62 63 public static final String OPTION2_ID; 64 65 public static final String RELATIONSHIP_ID; 66 67 public static final String WEIGHT; 68 69 public static final String PREFERRED_ORDER; 70 71 static 72 { 73 OPTION1_ID = "SCARAB_R_OPTION_OPTION.OPTION1_ID"; 74 OPTION2_ID = "SCARAB_R_OPTION_OPTION.OPTION2_ID"; 75 RELATIONSHIP_ID = "SCARAB_R_OPTION_OPTION.RELATIONSHIP_ID"; 76 WEIGHT = "SCARAB_R_OPTION_OPTION.WEIGHT"; 77 PREFERRED_ORDER = "SCARAB_R_OPTION_OPTION.PREFERRED_ORDER"; 78 if (Torque.isInit()) 79 { 80 try 81 { 82 getMapBuilder(ROptionOptionMapBuilder.CLASS_NAME); 83 } 84 catch (Exception e) 85 { 86 log.error("Could not initialize Peer", e); 87 } 88 } 89 else 90 { 91 Torque.registerMapBuilder(ROptionOptionMapBuilder.CLASS_NAME); 92 } 93 } 94 95 96 public static final int numColumns = 5; 97 98 99 protected static final String CLASSNAME_DEFAULT = 100 "org.tigris.scarab.om.ROptionOption"; 101 102 103 protected static final Class CLASS_DEFAULT = initClass(CLASSNAME_DEFAULT); 104 105 111 private static Class initClass(String className) 112 { 113 Class c = null; 114 try 115 { 116 c = Class.forName(className); 117 } 118 catch (Throwable t) 119 { 120 log.error("A FATAL ERROR has occurred which should not " 121 + "have happened under any circumstance. Please notify " 122 + "the Torque developers <torque-dev@db.apache.org> " 123 + "and give as many details as possible (including the error " 124 + "stack trace).", t); 125 126 if (t instanceof Error ) 128 { 129 throw (Error ) t.fillInStackTrace(); 130 } 131 } 132 return c; 133 } 134 135 145 public static List resultSet2Objects(java.sql.ResultSet results) 146 throws TorqueException 147 { 148 try 149 { 150 QueryDataSet qds = null; 151 List rows = null; 152 try 153 { 154 qds = new QueryDataSet(results); 155 rows = getSelectResults(qds); 156 } 157 finally 158 { 159 if (qds != null) 160 { 161 qds.close(); 162 } 163 } 164 165 return populateObjects(rows); 166 } 167 catch (SQLException e) 168 { 169 throw new TorqueException(e); 170 } 171 catch (DataSetException e) 172 { 173 throw new TorqueException(e); 174 } 175 } 176 177 178 179 186 public static ObjectKey doInsert(Criteria criteria) 187 throws TorqueException 188 { 189 return BaseROptionOptionPeer 190 .doInsert(criteria, (Connection ) null); 191 } 192 193 203 public static ObjectKey doInsert(Criteria criteria, Connection con) 204 throws TorqueException 205 { 206 207 setDbName(criteria); 208 209 if (con == null) 210 { 211 return BasePeer.doInsert(criteria); 212 } 213 else 214 { 215 return BasePeer.doInsert(criteria, con); 216 } 217 } 218 219 226 public static void addSelectColumns(Criteria criteria) 227 throws TorqueException 228 { 229 criteria.addSelectColumn(OPTION1_ID); 230 criteria.addSelectColumn(OPTION2_ID); 231 criteria.addSelectColumn(RELATIONSHIP_ID); 232 criteria.addSelectColumn(WEIGHT); 233 criteria.addSelectColumn(PREFERRED_ORDER); 234 } 235 236 245 public static ROptionOption row2Object(Record row, 246 int offset, 247 Class cls) 248 throws TorqueException 249 { 250 try 251 { 252 ROptionOption obj = (ROptionOption) cls.newInstance(); 253 ROptionOptionPeer.populateObject(row, offset, obj); 254 obj.setModified(false); 255 obj.setNew(false); 256 257 return obj; 258 } 259 catch (InstantiationException e) 260 { 261 throw new TorqueException(e); 262 } 263 catch (IllegalAccessException e) 264 { 265 throw new TorqueException(e); 266 } 267 } 268 269 278 public static void populateObject(Record row, 279 int offset, 280 ROptionOption obj) 281 throws TorqueException 282 { 283 try 284 { 285 obj.setOption1Id(row.getValue(offset + 0).asIntegerObj()); 286 obj.setOption2Id(row.getValue(offset + 1).asIntegerObj()); 287 obj.setRelationshipId(row.getValue(offset + 2).asIntegerObj()); 288 obj.setWeight(row.getValue(offset + 3).asInt()); 289 obj.setPreferredOrder(row.getValue(offset + 4).asInt()); 290 } 291 catch (DataSetException e) 292 { 293 throw new TorqueException(e); 294 } 295 } 296 297 305 public static List doSelect(Criteria criteria) throws TorqueException 306 { 307 return populateObjects(doSelectVillageRecords(criteria)); 308 } 309 310 319 public static List doSelect(Criteria criteria, Connection con) 320 throws TorqueException 321 { 322 return populateObjects(doSelectVillageRecords(criteria, con)); 323 } 324 325 335 public static List doSelectVillageRecords(Criteria criteria) 336 throws TorqueException 337 { 338 return BaseROptionOptionPeer 339 .doSelectVillageRecords(criteria, (Connection ) null); 340 } 341 342 351 public static List doSelectVillageRecords(Criteria criteria, Connection con) 352 throws TorqueException 353 { 354 if (criteria.getSelectColumns().size() == 0) 355 { 356 addSelectColumns(criteria); 357 } 358 359 360 setDbName(criteria); 361 362 if (con == null) 365 { 366 return BasePeer.doSelect(criteria); 367 } 368 else 369 { 370 return BasePeer.doSelect(criteria, con); 371 } 372 } 373 374 381 public static List populateObjects(List records) 382 throws TorqueException 383 { 384 List results = new ArrayList (records.size()); 385 386 for (int i = 0; i < records.size(); i++) 388 { 389 Record row = (Record) records.get(i); 390 results.add(ROptionOptionPeer.row2Object(row, 1, 391 ROptionOptionPeer.getOMClass())); 392 } 393 return results; 394 } 395 396 397 405 public static Class getOMClass() 406 throws TorqueException 407 { 408 return CLASS_DEFAULT; 409 } 410 411 419 public static void doUpdate(Criteria criteria) throws TorqueException 420 { 421 BaseROptionOptionPeer 422 .doUpdate(criteria, (Connection ) null); 423 } 424 425 436 public static void doUpdate(Criteria criteria, Connection con) 437 throws TorqueException 438 { 439 Criteria selectCriteria = new Criteria(DATABASE_NAME, 2); 440 selectCriteria.put(OPTION1_ID, criteria.remove(OPTION1_ID)); 441 selectCriteria.put(OPTION2_ID, criteria.remove(OPTION2_ID)); 442 443 setDbName(criteria); 444 445 if (con == null) 446 { 447 BasePeer.doUpdate(selectCriteria, criteria); 448 } 449 else 450 { 451 BasePeer.doUpdate(selectCriteria, criteria, con); 452 } 453 } 454 455 462 public static void doDelete(Criteria criteria) throws TorqueException 463 { 464 ROptionOptionPeer 465 .doDelete(criteria, (Connection ) null); 466 } 467 468 478 public static void doDelete(Criteria criteria, Connection con) 479 throws TorqueException 480 { 481 482 setDbName(criteria); 483 484 if (con == null) 485 { 486 BasePeer.doDelete(criteria); 487 } 488 else 489 { 490 BasePeer.doDelete(criteria, con); 491 } 492 } 493 494 500 public static List doSelect(ROptionOption obj) throws TorqueException 501 { 502 return doSelect(buildSelectCriteria(obj)); 503 } 504 505 511 public static void doInsert(ROptionOption obj) throws TorqueException 512 { 513 doInsert(buildCriteria(obj)); 514 obj.setNew(false); 515 obj.setModified(false); 516 } 517 518 523 public static void doUpdate(ROptionOption obj) throws TorqueException 524 { 525 doUpdate(buildCriteria(obj)); 526 obj.setModified(false); 527 } 528 529 534 public static void doDelete(ROptionOption obj) throws TorqueException 535 { 536 doDelete(buildSelectCriteria(obj)); 537 } 538 539 549 public static void doInsert(ROptionOption obj, Connection con) 550 throws TorqueException 551 { 552 doInsert(buildCriteria(obj), con); 553 obj.setNew(false); 554 obj.setModified(false); 555 } 556 557 567 public static void doUpdate(ROptionOption obj, Connection con) 568 throws TorqueException 569 { 570 doUpdate(buildCriteria(obj), con); 571 obj.setModified(false); 572 } 573 574 584 public static void doDelete(ROptionOption obj, Connection con) 585 throws TorqueException 586 { 587 doDelete(buildSelectCriteria(obj), con); 588 } 589 590 597 public static void doDelete(ObjectKey pk) throws TorqueException 598 { 599 BaseROptionOptionPeer 600 .doDelete(pk, (Connection ) null); 601 } 602 603 613 public static void doDelete(ObjectKey pk, Connection con) 614 throws TorqueException 615 { 616 doDelete(buildCriteria(pk), con); 617 } 618 619 620 public static Criteria buildCriteria( ObjectKey pk ) 621 { 622 Criteria criteria = new Criteria(); 623 SimpleKey[] keys = (SimpleKey[])pk.getValue(); 624 criteria.add(OPTION1_ID, keys[0]); 625 criteria.add(OPTION2_ID, keys[1]); 626 return criteria; 627 } 628 629 630 public static Criteria buildCriteria( ROptionOption obj ) 631 { 632 Criteria criteria = new Criteria(DATABASE_NAME); 633 criteria.add(OPTION1_ID, obj.getOption1Id()); 634 criteria.add(OPTION2_ID, obj.getOption2Id()); 635 criteria.add(RELATIONSHIP_ID, obj.getRelationshipId()); 636 criteria.add(WEIGHT, obj.getWeight()); 637 criteria.add(PREFERRED_ORDER, obj.getPreferredOrder()); 638 return criteria; 639 } 640 641 642 public static Criteria buildSelectCriteria( ROptionOption obj ) 643 { 644 Criteria criteria = new Criteria(DATABASE_NAME); 645 criteria.add(OPTION1_ID, obj.getOption1Id()); 646 criteria.add(OPTION2_ID, obj.getOption2Id()); 647 criteria.add(RELATIONSHIP_ID, obj.getRelationshipId()); 648 criteria.add(WEIGHT, obj.getWeight()); 649 criteria.add(PREFERRED_ORDER, obj.getPreferredOrder()); 650 return criteria; 651 } 652 653 654 655 664 public static ROptionOption retrieveByPK(ObjectKey pk) 665 throws TorqueException, NoRowsException, TooManyRowsException 666 { 667 Connection db = null; 668 ROptionOption retVal = null; 669 try 670 { 671 db = Torque.getConnection(DATABASE_NAME); 672 retVal = retrieveByPK(pk, db); 673 } 674 finally 675 { 676 Torque.closeConnection(db); 677 } 678 return(retVal); 679 } 680 681 691 public static ROptionOption retrieveByPK(ObjectKey pk, Connection con) 692 throws TorqueException, NoRowsException, TooManyRowsException 693 { 694 Criteria criteria = buildCriteria(pk); 695 List v = doSelect(criteria, con); 696 if (v.size() == 0) 697 { 698 throw new NoRowsException("Failed to select a row."); 699 } 700 else if (v.size() > 1) 701 { 702 throw new TooManyRowsException("Failed to select only one row."); 703 } 704 else 705 { 706 return (ROptionOption)v.get(0); 707 } 708 } 709 710 717 public static List retrieveByPKs(List pks) 718 throws TorqueException 719 { 720 Connection db = null; 721 List retVal = null; 722 try 723 { 724 db = Torque.getConnection(DATABASE_NAME); 725 retVal = retrieveByPKs(pks, db); 726 } 727 finally 728 { 729 Torque.closeConnection(db); 730 } 731 return(retVal); 732 } 733 734 742 public static List retrieveByPKs( List pks, Connection dbcon ) 743 throws TorqueException 744 { 745 List objs = null; 746 if (pks == null || pks.size() == 0) 747 { 748 objs = new LinkedList (); 749 } 750 else 751 { 752 Criteria criteria = new Criteria(); 753 Iterator iter = pks.iterator(); 754 while (iter.hasNext()) 755 { 756 ObjectKey pk = (ObjectKey)iter.next(); 757 SimpleKey[] keys = (SimpleKey[])pk.getValue(); 758 Criteria.Criterion c0 = criteria.getNewCriterion( 759 OPTION1_ID, keys[0], Criteria.EQUAL); 760 Criteria.Criterion c1 = criteria.getNewCriterion( 761 OPTION2_ID, keys[1], Criteria.EQUAL); 762 c0.and(c1); 763 criteria.or(c0); 764 } 765 objs = doSelect(criteria, dbcon); 766 } 767 return objs; 768 } 769 770 771 777 public static ROptionOption retrieveByPK( 778 Integer option1_id 779 , Integer option2_id 780 ) throws TorqueException 781 { 782 Connection db = null; 783 ROptionOption retVal = null; 784 try 785 { 786 db = Torque.getConnection(DATABASE_NAME); 787 retVal = retrieveByPK( 788 option1_id 789 , option2_id 790 , db); 791 } 792 finally 793 { 794 Torque.closeConnection(db); 795 } 796 return(retVal); 797 } 798 799 806 public static ROptionOption retrieveByPK( 807 Integer option1_id 808 , Integer option2_id 809 ,Connection con) throws TorqueException 810 { 811 812 Criteria criteria = new Criteria(5); 813 criteria.add(OPTION1_ID, option1_id); 814 criteria.add(OPTION2_ID, option2_id); 815 List v = doSelect(criteria, con); 816 if (v.size() != 1) 817 { 818 throw new TorqueException("Failed to select one and only one row."); 819 } 820 else 821 { 822 return (ROptionOption) v.get(0); 823 } 824 } 825 826 827 828 829 830 831 832 833 844 protected static List doSelectJoinAttributeOptionRelatedByOption1Id(Criteria criteria) 845 throws TorqueException 846 { 847 setDbName(criteria); 848 849 ROptionOptionPeer.addSelectColumns(criteria); 850 int offset = numColumns + 1; 851 AttributeOptionPeer.addSelectColumns(criteria); 852 853 854 criteria.addJoin(ROptionOptionPeer.OPTION1_ID, 855 AttributeOptionPeer.OPTION_ID); 856 857 858 859 List rows = BasePeer.doSelect(criteria); 860 List results = new ArrayList (); 861 862 for (int i = 0; i < rows.size(); i++) 863 { 864 Record row = (Record) rows.get(i); 865 866 Class omClass = ROptionOptionPeer.getOMClass(); 867 ROptionOption obj1 = (ROptionOption) ROptionOptionPeer 868 .row2Object(row, 1, omClass); 869 omClass = AttributeOptionPeer.getOMClass(); 870 AttributeOption obj2 = (AttributeOption)AttributeOptionPeer 871 .row2Object(row, offset, omClass); 872 873 boolean newObject = true; 874 for (int j = 0; j < results.size(); j++) 875 { 876 ROptionOption temp_obj1 = (ROptionOption)results.get(j); 877 AttributeOption temp_obj2 = (AttributeOption)temp_obj1.getAttributeOptionRelatedByOption1Id(); 878 if (temp_obj2.getPrimaryKey().equals(obj2.getPrimaryKey())) 879 { 880 newObject = false; 881 temp_obj2.addROptionOptionRelatedByOption1Id(obj1); 882 break; 883 } 884 } 885 if (newObject) 886 { 887 obj2.initROptionOptionsRelatedByOption1Id(); 888 obj2.addROptionOptionRelatedByOption1Id(obj1); 889 } 890 results.add(obj1); 891 } 892 return results; 893 } 894 895 896 897 898 909 protected static List doSelectJoinAttributeOptionRelatedByOption2Id(Criteria criteria) 910 throws TorqueException 911 { 912 setDbName(criteria); 913 914 ROptionOptionPeer.addSelectColumns(criteria); 915 int offset = numColumns + 1; 916 AttributeOptionPeer.addSelectColumns(criteria); 917 918 919 criteria.addJoin(ROptionOptionPeer.OPTION2_ID, 920 AttributeOptionPeer.OPTION_ID); 921 922 923 924 List rows = BasePeer.doSelect(criteria); 925 List results = new ArrayList (); 926 927 for (int i = 0; i < rows.size(); i++) 928 { 929 Record row = (Record) rows.get(i); 930 931 Class omClass = ROptionOptionPeer.getOMClass(); 932 ROptionOption obj1 = (ROptionOption) ROptionOptionPeer 933 .row2Object(row, 1, omClass); 934 omClass = AttributeOptionPeer.getOMClass(); 935 AttributeOption obj2 = (AttributeOption)AttributeOptionPeer 936 .row2Object(row, offset, omClass); 937 938 boolean newObject = true; 939 for (int j = 0; j < results.size(); j++) 940 { 941 ROptionOption temp_obj1 = (ROptionOption)results.get(j); 942 AttributeOption temp_obj2 = (AttributeOption)temp_obj1.getAttributeOptionRelatedByOption2Id(); 943 if (temp_obj2.getPrimaryKey().equals(obj2.getPrimaryKey())) 944 { 945 newObject = false; 946 temp_obj2.addROptionOptionRelatedByOption2Id(obj1); 947 break; 948 } 949 } 950 if (newObject) 951 { 952 obj2.initROptionOptionsRelatedByOption2Id(); 953 obj2.addROptionOptionRelatedByOption2Id(obj1); 954 } 955 results.add(obj1); 956 } 957 return results; 958 } 959 960 961 962 963 974 protected static List doSelectJoinOptionRelationship(Criteria criteria) 975 throws TorqueException 976 { 977 setDbName(criteria); 978 979 ROptionOptionPeer.addSelectColumns(criteria); 980 int offset = numColumns + 1; 981 OptionRelationshipPeer.addSelectColumns(criteria); 982 983 984 criteria.addJoin(ROptionOptionPeer.RELATIONSHIP_ID, 985 OptionRelationshipPeer.RELATIONSHIP_ID); 986 987 988 989 List rows = BasePeer.doSelect(criteria); 990 List results = new ArrayList (); 991 992 for (int i = 0; i < rows.size(); i++) 993 { 994 Record row = (Record) rows.get(i); 995 996 Class omClass = ROptionOptionPeer.getOMClass(); 997 ROptionOption obj1 = (ROptionOption) ROptionOptionPeer 998 .row2Object(row, 1, omClass); 999 omClass = OptionRelationshipPeer.getOMClass(); 1000 OptionRelationship obj2 = (OptionRelationship)OptionRelationshipPeer 1001 .row2Object(row, offset, omClass); 1002 1003 boolean newObject = true; 1004 for (int j = 0; j < results.size(); j++) 1005 { 1006 ROptionOption temp_obj1 = (ROptionOption)results.get(j); 1007 OptionRelationship temp_obj2 = (OptionRelationship)temp_obj1.getOptionRelationship(); 1008 if (temp_obj2.getPrimaryKey().equals(obj2.getPrimaryKey())) 1009 { 1010 newObject = false; 1011 temp_obj2.addROptionOption(obj1); 1012 break; 1013 } 1014 } 1015 if (newObject) 1016 { 1017 obj2.initROptionOptions(); 1018 obj2.addROptionOption(obj1); 1019 } 1020 results.add(obj1); 1021 } 1022 return results; 1023 } 1024 1025 1026 1027 1028 1029 1030 1031 1032 1043 protected static List doSelectJoinAllExceptAttributeOptionRelatedByOption1Id(Criteria criteria) 1044 throws TorqueException 1045 { 1046 setDbName(criteria); 1047 1048 addSelectColumns(criteria); 1049 int offset2 = numColumns + 1; 1050 1051 1052 1053 OptionRelationshipPeer.addSelectColumns(criteria); 1054 int offset3 = offset2 + OptionRelationshipPeer.numColumns; 1055 1056 List rows = BasePeer.doSelect(criteria); 1057 List results = new ArrayList (); 1058 1059 for (int i = 0; i < rows.size(); i++) 1060 { 1061 Record row = (Record)rows.get(i); 1062 1063 Class omClass = ROptionOptionPeer.getOMClass(); 1064 ROptionOption obj1 = (ROptionOption)ROptionOptionPeer 1065 .row2Object(row, 1, omClass); 1066 1067 1068 1069 1070 1071 1072 omClass = OptionRelationshipPeer.getOMClass(); 1073 OptionRelationship obj2 = (OptionRelationship)OptionRelationshipPeer 1074 .row2Object( row, offset2, omClass); 1075 1076 boolean newObject = true; 1077 for (int j = 0; j < results.size(); j++) 1078 { 1079 ROptionOption temp_obj1 = (ROptionOption)results.get(j); 1080 OptionRelationship temp_obj2 = (OptionRelationship)temp_obj1.getOptionRelationship(); 1081 if (temp_obj2.getPrimaryKey().equals(obj2.getPrimaryKey())) 1082 { 1083 newObject = false; 1084 temp_obj2.addROptionOption(obj1); 1085 break; 1086 } 1087 } 1088 if (newObject) 1089 { 1090 obj2.initROptionOptions(); 1091 obj2.addROptionOption(obj1); 1092 } 1093 results.add(obj1); 1094 } 1095 return results; 1096 } 1097 1098 1099 1100 1101 1102 1113 protected static List doSelectJoinAllExceptAttributeOptionRelatedByOption2Id(Criteria criteria) 1114 throws TorqueException 1115 { 1116 setDbName(criteria); 1117 1118 addSelectColumns(criteria); 1119 int offset2 = numColumns + 1; 1120 1121 1122 1123 OptionRelationshipPeer.addSelectColumns(criteria); 1124 int offset3 = offset2 + OptionRelationshipPeer.numColumns; 1125 1126 List rows = BasePeer.doSelect(criteria); 1127 List results = new ArrayList (); 1128 1129 for (int i = 0; i < rows.size(); i++) 1130 { 1131 Record row = (Record)rows.get(i); 1132 1133 Class omClass = ROptionOptionPeer.getOMClass(); 1134 ROptionOption obj1 = (ROptionOption)ROptionOptionPeer 1135 .row2Object(row, 1, omClass); 1136 1137 1138 1139 1140 1141 1142 omClass = OptionRelationshipPeer.getOMClass(); 1143 OptionRelationship obj2 = (OptionRelationship)OptionRelationshipPeer 1144 .row2Object( row, offset2, omClass); 1145 1146 boolean newObject = true; 1147 for (int j = 0; j < results.size(); j++) 1148 { 1149 ROptionOption temp_obj1 = (ROptionOption)results.get(j); 1150 OptionRelationship temp_obj2 = (OptionRelationship)temp_obj1.getOptionRelationship(); 1151 if (temp_obj2.getPrimaryKey().equals(obj2.getPrimaryKey())) 1152 { 1153 newObject = false; 1154 temp_obj2.addROptionOption(obj1); 1155 break; 1156 } 1157 } 1158 if (newObject) 1159 { 1160 obj2.initROptionOptions(); 1161 obj2.addROptionOption(obj1); 1162 } 1163 results.add(obj1); 1164 } 1165 return results; 1166 } 1167 1168 1169 1170 1171 1172 1183 protected static List doSelectJoinAllExceptOptionRelationship(Criteria criteria) 1184 throws TorqueException 1185 { 1186 setDbName(criteria); 1187 1188 addSelectColumns(criteria); 1189 int offset2 = numColumns + 1; 1190 1191 AttributeOptionPeer.addSelectColumns(criteria); 1192 int offset3 = offset2 + AttributeOptionPeer.numColumns; 1193 1194 AttributeOptionPeer.addSelectColumns(criteria); 1195 int offset4 = offset3 + AttributeOptionPeer.numColumns; 1196 1197 1198 List rows = BasePeer.doSelect(criteria); 1199 List results = new ArrayList (); 1200 1201 for (int i = 0; i < rows.size(); i++) 1202 { 1203 Record row = (Record)rows.get(i); 1204 1205 Class omClass = ROptionOptionPeer.getOMClass(); 1206 ROptionOption obj1 = (ROptionOption)ROptionOptionPeer 1207 .row2Object(row, 1, omClass); 1208 1209 1210 1211 1212 omClass = AttributeOptionPeer.getOMClass(); 1213 AttributeOption obj2 = (AttributeOption)AttributeOptionPeer 1214 .row2Object( row, offset2, omClass); 1215 1216 boolean newObject = true; 1217 for (int j = 0; j < results.size(); j++) 1218 { 1219 ROptionOption temp_obj1 = (ROptionOption)results.get(j); 1220 AttributeOption temp_obj2 = (AttributeOption)temp_obj1.getAttributeOptionRelatedByOption1Id(); 1221 if (temp_obj2.getPrimaryKey().equals(obj2.getPrimaryKey())) 1222 { 1223 newObject = false; 1224 temp_obj2.addROptionOptionRelatedByOption1Id(obj1); 1225 break; 1226 } 1227 } 1228 if (newObject) 1229 { 1230 obj2.initROptionOptionsRelatedByOption1Id(); 1231 obj2.addROptionOptionRelatedByOption1Id(obj1); 1232 } 1233 1234 1235 1236 1237 omClass = AttributeOptionPeer.getOMClass(); 1238 AttributeOption obj3 = (AttributeOption)AttributeOptionPeer 1239 .row2Object( row, offset3, omClass); 1240 1241 newObject = true; 1242 for (int j = 0; j < results.size(); j++) 1243 { 1244 ROptionOption temp_obj1 = (ROptionOption)results.get(j); 1245 AttributeOption temp_obj3 = (AttributeOption)temp_obj1.getAttributeOptionRelatedByOption2Id(); 1246 if (temp_obj3.getPrimaryKey().equals(obj3.getPrimaryKey())) 1247 { 1248 newObject = false; 1249 temp_obj3.addROptionOptionRelatedByOption2Id(obj1); 1250 break; 1251 } 1252 } 1253 if (newObject) 1254 { 1255 obj3.initROptionOptionsRelatedByOption2Id(); 1256 obj3.addROptionOptionRelatedByOption2Id(obj1); 1257 } 1258 1259 results.add(obj1); 1260 } 1261 return results; 1262 } 1263 1264 1265 1272 protected static TableMap getTableMap() 1273 throws TorqueException 1274 { 1275 return Torque.getDatabaseMap(DATABASE_NAME).getTable(TABLE_NAME); 1276 } 1277 1278 private static void setDbName(Criteria crit) 1279 { 1280 if (crit.getDbName() == Torque.getDefaultDB()) 1284 { 1285 crit.setDbName(DATABASE_NAME); 1286 } 1287 } 1288} 1289 | Popular Tags |