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 BaseRQueryUserPeer 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_QUERY_USER"; 48 49 54 public static MapBuilder getMapBuilder() 55 throws TorqueException 56 { 57 return getMapBuilder(RQueryUserMapBuilder.CLASS_NAME); 58 } 59 60 61 public static final String QUERY_ID; 62 63 public static final String USER_ID; 64 65 public static final String IS_SUBSCRIBED; 66 67 public static final String SUBSCRIPTION_FREQUENCY_ID; 68 69 public static final String ISDEFAULT; 70 71 static 72 { 73 QUERY_ID = "SCARAB_R_QUERY_USER.QUERY_ID"; 74 USER_ID = "SCARAB_R_QUERY_USER.USER_ID"; 75 IS_SUBSCRIBED = "SCARAB_R_QUERY_USER.IS_SUBSCRIBED"; 76 SUBSCRIPTION_FREQUENCY_ID = "SCARAB_R_QUERY_USER.SUBSCRIPTION_FREQUENCY_ID"; 77 ISDEFAULT = "SCARAB_R_QUERY_USER.ISDEFAULT"; 78 if (Torque.isInit()) 79 { 80 try 81 { 82 getMapBuilder(RQueryUserMapBuilder.CLASS_NAME); 83 } 84 catch (Exception e) 85 { 86 log.error("Could not initialize Peer", e); 87 } 88 } 89 else 90 { 91 Torque.registerMapBuilder(RQueryUserMapBuilder.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.RQueryUser"; 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 BaseRQueryUserPeer 190 .doInsert(criteria, (Connection ) null); 191 } 192 193 203 public static ObjectKey doInsert(Criteria criteria, Connection con) 204 throws TorqueException 205 { 206 if (criteria.containsKey(IS_SUBSCRIBED)) 208 { 209 Object possibleBoolean = criteria.get(IS_SUBSCRIBED); 210 if (possibleBoolean instanceof Boolean ) 211 { 212 criteria.add(IS_SUBSCRIBED, ((Boolean ) possibleBoolean).booleanValue() ? 1 : 0); 213 } 214 } 215 if (criteria.containsKey(ISDEFAULT)) 217 { 218 Object possibleBoolean = criteria.get(ISDEFAULT); 219 if (possibleBoolean instanceof Boolean ) 220 { 221 criteria.add(ISDEFAULT, ((Boolean ) possibleBoolean).booleanValue() ? 1 : 0); 222 } 223 } 224 225 setDbName(criteria); 226 227 if (con == null) 228 { 229 return BasePeer.doInsert(criteria); 230 } 231 else 232 { 233 return BasePeer.doInsert(criteria, con); 234 } 235 } 236 237 244 public static void addSelectColumns(Criteria criteria) 245 throws TorqueException 246 { 247 criteria.addSelectColumn(QUERY_ID); 248 criteria.addSelectColumn(USER_ID); 249 criteria.addSelectColumn(IS_SUBSCRIBED); 250 criteria.addSelectColumn(SUBSCRIPTION_FREQUENCY_ID); 251 criteria.addSelectColumn(ISDEFAULT); 252 } 253 254 263 public static RQueryUser row2Object(Record row, 264 int offset, 265 Class cls) 266 throws TorqueException 267 { 268 try 269 { 270 RQueryUser obj = (RQueryUser) cls.newInstance(); 271 RQueryUserPeer.populateObject(row, offset, obj); 272 obj.setModified(false); 273 obj.setNew(false); 274 275 return obj; 276 } 277 catch (InstantiationException e) 278 { 279 throw new TorqueException(e); 280 } 281 catch (IllegalAccessException e) 282 { 283 throw new TorqueException(e); 284 } 285 } 286 287 296 public static void populateObject(Record row, 297 int offset, 298 RQueryUser obj) 299 throws TorqueException 300 { 301 try 302 { 303 obj.setQueryId(row.getValue(offset + 0).asLongObj()); 304 obj.setUserId(row.getValue(offset + 1).asIntegerObj()); 305 obj.setIsSubscribed(row.getValue(offset + 2).asBoolean()); 306 obj.setSubscriptionFrequency(row.getValue(offset + 3).asIntegerObj()); 307 obj.setIsdefault(row.getValue(offset + 4).asBoolean()); 308 } 309 catch (DataSetException e) 310 { 311 throw new TorqueException(e); 312 } 313 } 314 315 323 public static List doSelect(Criteria criteria) throws TorqueException 324 { 325 return populateObjects(doSelectVillageRecords(criteria)); 326 } 327 328 337 public static List doSelect(Criteria criteria, Connection con) 338 throws TorqueException 339 { 340 return populateObjects(doSelectVillageRecords(criteria, con)); 341 } 342 343 353 public static List doSelectVillageRecords(Criteria criteria) 354 throws TorqueException 355 { 356 return BaseRQueryUserPeer 357 .doSelectVillageRecords(criteria, (Connection ) null); 358 } 359 360 369 public static List doSelectVillageRecords(Criteria criteria, Connection con) 370 throws TorqueException 371 { 372 if (criteria.getSelectColumns().size() == 0) 373 { 374 addSelectColumns(criteria); 375 } 376 377 if (criteria.containsKey(IS_SUBSCRIBED)) 379 { 380 Object possibleBoolean = criteria.get(IS_SUBSCRIBED); 381 if (possibleBoolean instanceof Boolean ) 382 { 383 criteria.add(IS_SUBSCRIBED, ((Boolean ) possibleBoolean).booleanValue() ? 1 : 0); 384 } 385 } 386 if (criteria.containsKey(ISDEFAULT)) 388 { 389 Object possibleBoolean = criteria.get(ISDEFAULT); 390 if (possibleBoolean instanceof Boolean ) 391 { 392 criteria.add(ISDEFAULT, ((Boolean ) possibleBoolean).booleanValue() ? 1 : 0); 393 } 394 } 395 396 setDbName(criteria); 397 398 if (con == null) 401 { 402 return BasePeer.doSelect(criteria); 403 } 404 else 405 { 406 return BasePeer.doSelect(criteria, con); 407 } 408 } 409 410 417 public static List populateObjects(List records) 418 throws TorqueException 419 { 420 List results = new ArrayList (records.size()); 421 422 for (int i = 0; i < records.size(); i++) 424 { 425 Record row = (Record) records.get(i); 426 results.add(RQueryUserPeer.row2Object(row, 1, 427 RQueryUserPeer.getOMClass())); 428 } 429 return results; 430 } 431 432 433 441 public static Class getOMClass() 442 throws TorqueException 443 { 444 return CLASS_DEFAULT; 445 } 446 447 455 public static void doUpdate(Criteria criteria) throws TorqueException 456 { 457 BaseRQueryUserPeer 458 .doUpdate(criteria, (Connection ) null); 459 } 460 461 472 public static void doUpdate(Criteria criteria, Connection con) 473 throws TorqueException 474 { 475 Criteria selectCriteria = new Criteria(DATABASE_NAME, 2); 476 selectCriteria.put(QUERY_ID, criteria.remove(QUERY_ID)); 477 selectCriteria.put(USER_ID, criteria.remove(USER_ID)); 478 if (criteria.containsKey(IS_SUBSCRIBED)) 480 { 481 Object possibleBoolean = criteria.get(IS_SUBSCRIBED); 482 if (possibleBoolean instanceof Boolean ) 483 { 484 criteria.add(IS_SUBSCRIBED, ((Boolean ) possibleBoolean).booleanValue() ? 1 : 0); 485 } 486 } 487 if (criteria.containsKey(ISDEFAULT)) 489 { 490 Object possibleBoolean = criteria.get(ISDEFAULT); 491 if (possibleBoolean instanceof Boolean ) 492 { 493 criteria.add(ISDEFAULT, ((Boolean ) possibleBoolean).booleanValue() ? 1 : 0); 494 } 495 } 496 497 setDbName(criteria); 498 499 if (con == null) 500 { 501 BasePeer.doUpdate(selectCriteria, criteria); 502 } 503 else 504 { 505 BasePeer.doUpdate(selectCriteria, criteria, con); 506 } 507 } 508 509 516 public static void doDelete(Criteria criteria) throws TorqueException 517 { 518 RQueryUserPeer 519 .doDelete(criteria, (Connection ) null); 520 } 521 522 532 public static void doDelete(Criteria criteria, Connection con) 533 throws TorqueException 534 { 535 if (criteria.containsKey(IS_SUBSCRIBED)) 537 { 538 Object possibleBoolean = criteria.get(IS_SUBSCRIBED); 539 if (possibleBoolean instanceof Boolean ) 540 { 541 criteria.add(IS_SUBSCRIBED, ((Boolean ) possibleBoolean).booleanValue() ? 1 : 0); 542 } 543 } 544 if (criteria.containsKey(ISDEFAULT)) 546 { 547 Object possibleBoolean = criteria.get(ISDEFAULT); 548 if (possibleBoolean instanceof Boolean ) 549 { 550 criteria.add(ISDEFAULT, ((Boolean ) possibleBoolean).booleanValue() ? 1 : 0); 551 } 552 } 553 554 setDbName(criteria); 555 556 if (con == null) 557 { 558 BasePeer.doDelete(criteria); 559 } 560 else 561 { 562 BasePeer.doDelete(criteria, con); 563 } 564 } 565 566 572 public static List doSelect(RQueryUser obj) throws TorqueException 573 { 574 return doSelect(buildSelectCriteria(obj)); 575 } 576 577 583 public static void doInsert(RQueryUser obj) throws TorqueException 584 { 585 doInsert(buildCriteria(obj)); 586 obj.setNew(false); 587 obj.setModified(false); 588 } 589 590 595 public static void doUpdate(RQueryUser obj) throws TorqueException 596 { 597 doUpdate(buildCriteria(obj)); 598 obj.setModified(false); 599 } 600 601 606 public static void doDelete(RQueryUser obj) throws TorqueException 607 { 608 doDelete(buildSelectCriteria(obj)); 609 } 610 611 621 public static void doInsert(RQueryUser obj, Connection con) 622 throws TorqueException 623 { 624 doInsert(buildCriteria(obj), con); 625 obj.setNew(false); 626 obj.setModified(false); 627 } 628 629 639 public static void doUpdate(RQueryUser obj, Connection con) 640 throws TorqueException 641 { 642 doUpdate(buildCriteria(obj), con); 643 obj.setModified(false); 644 } 645 646 656 public static void doDelete(RQueryUser obj, Connection con) 657 throws TorqueException 658 { 659 doDelete(buildSelectCriteria(obj), con); 660 } 661 662 669 public static void doDelete(ObjectKey pk) throws TorqueException 670 { 671 BaseRQueryUserPeer 672 .doDelete(pk, (Connection ) null); 673 } 674 675 685 public static void doDelete(ObjectKey pk, Connection con) 686 throws TorqueException 687 { 688 doDelete(buildCriteria(pk), con); 689 } 690 691 692 public static Criteria buildCriteria( ObjectKey pk ) 693 { 694 Criteria criteria = new Criteria(); 695 SimpleKey[] keys = (SimpleKey[])pk.getValue(); 696 criteria.add(QUERY_ID, keys[0]); 697 criteria.add(USER_ID, keys[1]); 698 return criteria; 699 } 700 701 702 public static Criteria buildCriteria( RQueryUser obj ) 703 { 704 Criteria criteria = new Criteria(DATABASE_NAME); 705 criteria.add(QUERY_ID, obj.getQueryId()); 706 criteria.add(USER_ID, obj.getUserId()); 707 criteria.add(IS_SUBSCRIBED, obj.getIsSubscribed()); 708 criteria.add(SUBSCRIPTION_FREQUENCY_ID, obj.getSubscriptionFrequency()); 709 criteria.add(ISDEFAULT, obj.getIsdefault()); 710 return criteria; 711 } 712 713 714 public static Criteria buildSelectCriteria( RQueryUser obj ) 715 { 716 Criteria criteria = new Criteria(DATABASE_NAME); 717 criteria.add(QUERY_ID, obj.getQueryId()); 718 criteria.add(USER_ID, obj.getUserId()); 719 criteria.add(IS_SUBSCRIBED, obj.getIsSubscribed()); 720 criteria.add(SUBSCRIPTION_FREQUENCY_ID, obj.getSubscriptionFrequency()); 721 criteria.add(ISDEFAULT, obj.getIsdefault()); 722 return criteria; 723 } 724 725 726 727 736 public static RQueryUser retrieveByPK(ObjectKey pk) 737 throws TorqueException, NoRowsException, TooManyRowsException 738 { 739 Connection db = null; 740 RQueryUser retVal = null; 741 try 742 { 743 db = Torque.getConnection(DATABASE_NAME); 744 retVal = retrieveByPK(pk, db); 745 } 746 finally 747 { 748 Torque.closeConnection(db); 749 } 750 return(retVal); 751 } 752 753 763 public static RQueryUser retrieveByPK(ObjectKey pk, Connection con) 764 throws TorqueException, NoRowsException, TooManyRowsException 765 { 766 Criteria criteria = buildCriteria(pk); 767 List v = doSelect(criteria, con); 768 if (v.size() == 0) 769 { 770 throw new NoRowsException("Failed to select a row."); 771 } 772 else if (v.size() > 1) 773 { 774 throw new TooManyRowsException("Failed to select only one row."); 775 } 776 else 777 { 778 return (RQueryUser)v.get(0); 779 } 780 } 781 782 789 public static List retrieveByPKs(List pks) 790 throws TorqueException 791 { 792 Connection db = null; 793 List retVal = null; 794 try 795 { 796 db = Torque.getConnection(DATABASE_NAME); 797 retVal = retrieveByPKs(pks, db); 798 } 799 finally 800 { 801 Torque.closeConnection(db); 802 } 803 return(retVal); 804 } 805 806 814 public static List retrieveByPKs( List pks, Connection dbcon ) 815 throws TorqueException 816 { 817 List objs = null; 818 if (pks == null || pks.size() == 0) 819 { 820 objs = new LinkedList (); 821 } 822 else 823 { 824 Criteria criteria = new Criteria(); 825 Iterator iter = pks.iterator(); 826 while (iter.hasNext()) 827 { 828 ObjectKey pk = (ObjectKey)iter.next(); 829 SimpleKey[] keys = (SimpleKey[])pk.getValue(); 830 Criteria.Criterion c0 = criteria.getNewCriterion( 831 QUERY_ID, keys[0], Criteria.EQUAL); 832 Criteria.Criterion c1 = criteria.getNewCriterion( 833 USER_ID, keys[1], Criteria.EQUAL); 834 c0.and(c1); 835 criteria.or(c0); 836 } 837 objs = doSelect(criteria, dbcon); 838 } 839 return objs; 840 } 841 842 843 849 public static RQueryUser retrieveByPK( 850 Long query_id 851 , Integer user_id 852 ) throws TorqueException 853 { 854 Connection db = null; 855 RQueryUser retVal = null; 856 try 857 { 858 db = Torque.getConnection(DATABASE_NAME); 859 retVal = retrieveByPK( 860 query_id 861 , user_id 862 , db); 863 } 864 finally 865 { 866 Torque.closeConnection(db); 867 } 868 return(retVal); 869 } 870 871 878 public static RQueryUser retrieveByPK( 879 Long query_id 880 , Integer user_id 881 ,Connection con) throws TorqueException 882 { 883 884 Criteria criteria = new Criteria(5); 885 criteria.add(QUERY_ID, query_id); 886 criteria.add(USER_ID, user_id); 887 List v = doSelect(criteria, con); 888 if (v.size() != 1) 889 { 890 throw new TorqueException("Failed to select one and only one row."); 891 } 892 else 893 { 894 return (RQueryUser) v.get(0); 895 } 896 } 897 898 899 900 901 902 903 904 905 916 protected static List doSelectJoinQuery(Criteria criteria) 917 throws TorqueException 918 { 919 setDbName(criteria); 920 921 RQueryUserPeer.addSelectColumns(criteria); 922 int offset = numColumns + 1; 923 QueryPeer.addSelectColumns(criteria); 924 925 926 criteria.addJoin(RQueryUserPeer.QUERY_ID, 927 QueryPeer.QUERY_ID); 928 929 930 if (criteria.containsKey(IS_SUBSCRIBED)) 932 { 933 Object possibleBoolean = criteria.get(IS_SUBSCRIBED); 934 if (possibleBoolean instanceof Boolean ) 935 { 936 criteria.add(IS_SUBSCRIBED, ((Boolean ) possibleBoolean).booleanValue() ? 1 : 0); 937 } 938 } 939 if (criteria.containsKey(ISDEFAULT)) 941 { 942 Object possibleBoolean = criteria.get(ISDEFAULT); 943 if (possibleBoolean instanceof Boolean ) 944 { 945 criteria.add(ISDEFAULT, ((Boolean ) possibleBoolean).booleanValue() ? 1 : 0); 946 } 947 } 948 949 List rows = BasePeer.doSelect(criteria); 950 List results = new ArrayList (); 951 952 for (int i = 0; i < rows.size(); i++) 953 { 954 Record row = (Record) rows.get(i); 955 956 Class omClass = RQueryUserPeer.getOMClass(); 957 RQueryUser obj1 = (RQueryUser) RQueryUserPeer 958 .row2Object(row, 1, omClass); 959 omClass = QueryPeer.getOMClass(); 960 Query obj2 = (Query)QueryPeer 961 .row2Object(row, offset, omClass); 962 963 boolean newObject = true; 964 for (int j = 0; j < results.size(); j++) 965 { 966 RQueryUser temp_obj1 = (RQueryUser)results.get(j); 967 Query temp_obj2 = (Query)temp_obj1.getQuery(); 968 if (temp_obj2.getPrimaryKey().equals(obj2.getPrimaryKey())) 969 { 970 newObject = false; 971 temp_obj2.addRQueryUser(obj1); 972 break; 973 } 974 } 975 if (newObject) 976 { 977 obj2.initRQueryUsers(); 978 obj2.addRQueryUser(obj1); 979 } 980 results.add(obj1); 981 } 982 return results; 983 } 984 985 986 987 988 999 protected static List doSelectJoinScarabUserImpl(Criteria criteria) 1000 throws TorqueException 1001 { 1002 setDbName(criteria); 1003 1004 RQueryUserPeer.addSelectColumns(criteria); 1005 int offset = numColumns + 1; 1006 ScarabUserImplPeer.addSelectColumns(criteria); 1007 1008 1009 criteria.addJoin(RQueryUserPeer.USER_ID, 1010 ScarabUserImplPeer.USER_ID); 1011 1012 1013 if (criteria.containsKey(IS_SUBSCRIBED)) 1015 { 1016 Object possibleBoolean = criteria.get(IS_SUBSCRIBED); 1017 if (possibleBoolean instanceof Boolean ) 1018 { 1019 criteria.add(IS_SUBSCRIBED, ((Boolean ) possibleBoolean).booleanValue() ? 1 : 0); 1020 } 1021 } 1022 if (criteria.containsKey(ISDEFAULT)) 1024 { 1025 Object possibleBoolean = criteria.get(ISDEFAULT); 1026 if (possibleBoolean instanceof Boolean ) 1027 { 1028 criteria.add(ISDEFAULT, ((Boolean ) possibleBoolean).booleanValue() ? 1 : 0); 1029 } 1030 } 1031 1032 List rows = BasePeer.doSelect(criteria); 1033 List results = new ArrayList (); 1034 1035 for (int i = 0; i < rows.size(); i++) 1036 { 1037 Record row = (Record) rows.get(i); 1038 1039 Class omClass = RQueryUserPeer.getOMClass(); 1040 RQueryUser obj1 = (RQueryUser) RQueryUserPeer 1041 .row2Object(row, 1, omClass); 1042 omClass = ScarabUserImplPeer.getOMClass(); 1043 ScarabUserImpl obj2 = (ScarabUserImpl)ScarabUserImplPeer 1044 .row2Object(row, offset, omClass); 1045 1046 boolean newObject = true; 1047 for (int j = 0; j < results.size(); j++) 1048 { 1049 RQueryUser temp_obj1 = (RQueryUser)results.get(j); 1050 ScarabUserImpl temp_obj2 = (ScarabUserImpl)temp_obj1.getScarabUser(); 1051 if (temp_obj2.getPrimaryKey().equals(obj2.getPrimaryKey())) 1052 { 1053 newObject = false; 1054 temp_obj2.addRQueryUser(obj1); 1055 break; 1056 } 1057 } 1058 if (newObject) 1059 { 1060 obj2.initRQueryUsers(); 1061 obj2.addRQueryUser(obj1); 1062 } 1063 results.add(obj1); 1064 } 1065 return results; 1066 } 1067 1068 1069 1070 1071 1082 protected static List doSelectJoinFrequency(Criteria criteria) 1083 throws TorqueException 1084 { 1085 setDbName(criteria); 1086 1087 RQueryUserPeer.addSelectColumns(criteria); 1088 int offset = numColumns + 1; 1089 FrequencyPeer.addSelectColumns(criteria); 1090 1091 1092 criteria.addJoin(RQueryUserPeer.SUBSCRIPTION_FREQUENCY_ID, 1093 FrequencyPeer.FREQUENCY_ID); 1094 1095 1096 if (criteria.containsKey(IS_SUBSCRIBED)) 1098 { 1099 Object possibleBoolean = criteria.get(IS_SUBSCRIBED); 1100 if (possibleBoolean instanceof Boolean ) 1101 { 1102 criteria.add(IS_SUBSCRIBED, ((Boolean ) possibleBoolean).booleanValue() ? 1 : 0); 1103 } 1104 } 1105 if (criteria.containsKey(ISDEFAULT)) 1107 { 1108 Object possibleBoolean = criteria.get(ISDEFAULT); 1109 if (possibleBoolean instanceof Boolean ) 1110 { 1111 criteria.add(ISDEFAULT, ((Boolean ) possibleBoolean).booleanValue() ? 1 : 0); 1112 } 1113 } 1114 1115 List rows = BasePeer.doSelect(criteria); 1116 List results = new ArrayList (); 1117 1118 for (int i = 0; i < rows.size(); i++) 1119 { 1120 Record row = (Record) rows.get(i); 1121 1122 Class omClass = RQueryUserPeer.getOMClass(); 1123 RQueryUser obj1 = (RQueryUser) RQueryUserPeer 1124 .row2Object(row, 1, omClass); 1125 omClass = FrequencyPeer.getOMClass(); 1126 Frequency obj2 = (Frequency)FrequencyPeer 1127 .row2Object(row, offset, omClass); 1128 1129 boolean newObject = true; 1130 for (int j = 0; j < results.size(); j++) 1131 { 1132 RQueryUser temp_obj1 = (RQueryUser)results.get(j); 1133 Frequency temp_obj2 = (Frequency)temp_obj1.getFrequency(); 1134 if (temp_obj2.getPrimaryKey().equals(obj2.getPrimaryKey())) 1135 { 1136 newObject = false; 1137 temp_obj2.addRQueryUser(obj1); 1138 break; 1139 } 1140 } 1141 if (newObject) 1142 { 1143 obj2.initRQueryUsers(); 1144 obj2.addRQueryUser(obj1); 1145 } 1146 results.add(obj1); 1147 } 1148 return results; 1149 } 1150 1151 1152 1153 1154 1155 1156 1157 1158 1169 protected static List doSelectJoinAllExceptQuery(Criteria criteria) 1170 throws TorqueException 1171 { 1172 setDbName(criteria); 1173 1174 addSelectColumns(criteria); 1175 int offset2 = numColumns + 1; 1176 1177 1178 ScarabUserImplPeer.addSelectColumns(criteria); 1179 int offset3 = offset2 + ScarabUserImplPeer.numColumns; 1180 1181 FrequencyPeer.addSelectColumns(criteria); 1182 int offset4 = offset3 + FrequencyPeer.numColumns; 1183 if (criteria.containsKey(IS_SUBSCRIBED)) 1185 { 1186 Object possibleBoolean = criteria.get(IS_SUBSCRIBED); 1187 if (possibleBoolean instanceof Boolean ) 1188 { 1189 criteria.add(IS_SUBSCRIBED, ((Boolean ) possibleBoolean).booleanValue() ? 1 : 0); 1190 } 1191 } 1192 if (criteria.containsKey(ISDEFAULT)) 1194 { 1195 Object possibleBoolean = criteria.get(ISDEFAULT); 1196 if (possibleBoolean instanceof Boolean ) 1197 { 1198 criteria.add(ISDEFAULT, ((Boolean ) possibleBoolean).booleanValue() ? 1 : 0); 1199 } 1200 } 1201 1202 List rows = BasePeer.doSelect(criteria); 1203 List results = new ArrayList (); 1204 1205 for (int i = 0; i < rows.size(); i++) 1206 { 1207 Record row = (Record)rows.get(i); 1208 1209 Class omClass = RQueryUserPeer.getOMClass(); 1210 RQueryUser obj1 = (RQueryUser)RQueryUserPeer 1211 .row2Object(row, 1, omClass); 1212 1213 1214 1215 1216 1217 omClass = ScarabUserImplPeer.getOMClass(); 1218 ScarabUserImpl obj2 = (ScarabUserImpl)ScarabUserImplPeer 1219 .row2Object( row, offset2, omClass); 1220 1221 boolean newObject = true; 1222 for (int j = 0; j < results.size(); j++) 1223 { 1224 RQueryUser temp_obj1 = (RQueryUser)results.get(j); 1225 ScarabUserImpl temp_obj2 = (ScarabUserImpl)temp_obj1.getScarabUser(); 1226 if (temp_obj2.getPrimaryKey().equals(obj2.getPrimaryKey())) 1227 { 1228 newObject = false; 1229 temp_obj2.addRQueryUser(obj1); 1230 break; 1231 } 1232 } 1233 if (newObject) 1234 { 1235 obj2.initRQueryUsers(); 1236 obj2.addRQueryUser(obj1); 1237 } 1238 1239 1240 1241 1242 omClass = FrequencyPeer.getOMClass(); 1243 Frequency obj3 = (Frequency)FrequencyPeer 1244 .row2Object( row, offset3, omClass); 1245 1246 newObject = true; 1247 for (int j = 0; j < results.size(); j++) 1248 { 1249 RQueryUser temp_obj1 = (RQueryUser)results.get(j); 1250 Frequency temp_obj3 = (Frequency)temp_obj1.getFrequency(); 1251 if (temp_obj3.getPrimaryKey().equals(obj3.getPrimaryKey())) 1252 { 1253 newObject = false; 1254 temp_obj3.addRQueryUser(obj1); 1255 break; 1256 } 1257 } 1258 if (newObject) 1259 { 1260 obj3.initRQueryUsers(); 1261 obj3.addRQueryUser(obj1); 1262 } 1263 results.add(obj1); 1264 } 1265 return results; 1266 } 1267 1268 1269 1270 1271 1272 1283 protected static List doSelectJoinAllExceptScarabUserImpl(Criteria criteria) 1284 throws TorqueException 1285 { 1286 setDbName(criteria); 1287 1288 addSelectColumns(criteria); 1289 int offset2 = numColumns + 1; 1290 1291 QueryPeer.addSelectColumns(criteria); 1292 int offset3 = offset2 + QueryPeer.numColumns; 1293 1294 1295 FrequencyPeer.addSelectColumns(criteria); 1296 int offset4 = offset3 + FrequencyPeer.numColumns; 1297 if (criteria.containsKey(IS_SUBSCRIBED)) 1299 { 1300 Object possibleBoolean = criteria.get(IS_SUBSCRIBED); 1301 if (possibleBoolean instanceof Boolean ) 1302 { 1303 criteria.add(IS_SUBSCRIBED, ((Boolean ) possibleBoolean).booleanValue() ? 1 : 0); 1304 } 1305 } 1306 if (criteria.containsKey(ISDEFAULT)) 1308 { 1309 Object possibleBoolean = criteria.get(ISDEFAULT); 1310 if (possibleBoolean instanceof Boolean ) 1311 { 1312 criteria.add(ISDEFAULT, ((Boolean ) possibleBoolean).booleanValue() ? 1 : 0); 1313 } 1314 } 1315 1316 List rows = BasePeer.doSelect(criteria); 1317 List results = new ArrayList (); 1318 1319 for (int i = 0; i < rows.size(); i++) 1320 { 1321 Record row = (Record)rows.get(i); 1322 1323 Class omClass = RQueryUserPeer.getOMClass(); 1324 RQueryUser obj1 = (RQueryUser)RQueryUserPeer 1325 .row2Object(row, 1, omClass); 1326 1327 1328 1329 1330 omClass = QueryPeer.getOMClass(); 1331 Query obj2 = (Query)QueryPeer 1332 .row2Object( row, offset2, omClass); 1333 1334 boolean newObject = true; 1335 for (int j = 0; j < results.size(); j++) 1336 { 1337 RQueryUser temp_obj1 = (RQueryUser)results.get(j); 1338 Query temp_obj2 = (Query)temp_obj1.getQuery(); 1339 if (temp_obj2.getPrimaryKey().equals(obj2.getPrimaryKey())) 1340 { 1341 newObject = false; 1342 temp_obj2.addRQueryUser(obj1); 1343 break; 1344 } 1345 } 1346 if (newObject) 1347 { 1348 obj2.initRQueryUsers(); 1349 obj2.addRQueryUser(obj1); 1350 } 1351 1352 1353 1354 1355 1356 omClass = FrequencyPeer.getOMClass(); 1357 Frequency obj3 = (Frequency)FrequencyPeer 1358 .row2Object( row, offset3, omClass); 1359 1360 newObject = true; 1361 for (int j = 0; j < results.size(); j++) 1362 { 1363 RQueryUser temp_obj1 = (RQueryUser)results.get(j); 1364 Frequency temp_obj3 = (Frequency)temp_obj1.getFrequency(); 1365 if (temp_obj3.getPrimaryKey().equals(obj3.getPrimaryKey())) 1366 { 1367 newObject = false; 1368 temp_obj3.addRQueryUser(obj1); 1369 break; 1370 } 1371 } 1372 if (newObject) 1373 { 1374 obj3.initRQueryUsers(); 1375 obj3.addRQueryUser(obj1); 1376 } 1377 results.add(obj1); 1378 } 1379 return results; 1380 } 1381 1382 1383 1384 1385 1386 1397 protected static List doSelectJoinAllExceptFrequency(Criteria criteria) 1398 throws TorqueException 1399 { 1400 setDbName(criteria); 1401 1402 addSelectColumns(criteria); 1403 int offset2 = numColumns + 1; 1404 1405 QueryPeer.addSelectColumns(criteria); 1406 int offset3 = offset2 + QueryPeer.numColumns; 1407 1408 ScarabUserImplPeer.addSelectColumns(criteria); 1409 int offset4 = offset3 + ScarabUserImplPeer.numColumns; 1410 1411 if (criteria.containsKey(IS_SUBSCRIBED)) 1413 { 1414 Object possibleBoolean = criteria.get(IS_SUBSCRIBED); 1415 if (possibleBoolean instanceof Boolean ) 1416 { 1417 criteria.add(IS_SUBSCRIBED, ((Boolean ) possibleBoolean).booleanValue() ? 1 : 0); 1418 } 1419 } 1420 if (criteria.containsKey(ISDEFAULT)) 1422 { 1423 Object possibleBoolean = criteria.get(ISDEFAULT); 1424 if (possibleBoolean instanceof Boolean ) 1425 { 1426 criteria.add(ISDEFAULT, ((Boolean ) possibleBoolean).booleanValue() ? 1 : 0); 1427 } 1428 } 1429 1430 List rows = BasePeer.doSelect(criteria); 1431 List results = new ArrayList (); 1432 1433 for (int i = 0; i < rows.size(); i++) 1434 { 1435 Record row = (Record)rows.get(i); 1436 1437 Class omClass = RQueryUserPeer.getOMClass(); 1438 RQueryUser obj1 = (RQueryUser)RQueryUserPeer 1439 .row2Object(row, 1, omClass); 1440 1441 1442 1443 1444 omClass = QueryPeer.getOMClass(); 1445 Query obj2 = (Query)QueryPeer 1446 .row2Object( row, offset2, omClass); 1447 1448 boolean newObject = true; 1449 for (int j = 0; j < results.size(); j++) 1450 { 1451 RQueryUser temp_obj1 = (RQueryUser)results.get(j); 1452 Query temp_obj2 = (Query)temp_obj1.getQuery(); 1453 if (temp_obj2.getPrimaryKey().equals(obj2.getPrimaryKey())) 1454 { 1455 newObject = false; 1456 temp_obj2.addRQueryUser(obj1); 1457 break; 1458 } 1459 } 1460 if (newObject) 1461 { 1462 obj2.initRQueryUsers(); 1463 obj2.addRQueryUser(obj1); 1464 } 1465 1466 1467 1468 1469 omClass = ScarabUserImplPeer.getOMClass(); 1470 ScarabUserImpl obj3 = (ScarabUserImpl)ScarabUserImplPeer 1471 .row2Object( row, offset3, omClass); 1472 1473 newObject = true; 1474 for (int j = 0; j < results.size(); j++) 1475 { 1476 RQueryUser temp_obj1 = (RQueryUser)results.get(j); 1477 ScarabUserImpl temp_obj3 = (ScarabUserImpl)temp_obj1.getScarabUser(); 1478 if (temp_obj3.getPrimaryKey().equals(obj3.getPrimaryKey())) 1479 { 1480 newObject = false; 1481 temp_obj3.addRQueryUser(obj1); 1482 break; 1483 } 1484 } 1485 if (newObject) 1486 { 1487 obj3.initRQueryUsers(); 1488 obj3.addRQueryUser(obj1); 1489 } 1490 1491 results.add(obj1); 1492 } 1493 return results; 1494 } 1495 1496 1497 1504 protected static TableMap getTableMap() 1505 throws TorqueException 1506 { 1507 return Torque.getDatabaseMap(DATABASE_NAME).getTable(TABLE_NAME); 1508 } 1509 1510 private static void setDbName(Criteria crit) 1511 { 1512 if (crit.getDbName() == Torque.getDefaultDB()) 1516 { 1517 crit.setDbName(DATABASE_NAME); 1518 } 1519 } 1520} 1521 | Popular Tags |