1 21 package oracle.toplink.essentials.descriptors; 23 24 import java.util.*; 25 import java.io.*; 26 import oracle.toplink.essentials.queryframework.*; 27 import oracle.toplink.essentials.expressions.*; 28 import oracle.toplink.essentials.mappings.*; 29 import oracle.toplink.essentials.sessions.DatabaseRecord; 30 import oracle.toplink.essentials.internal.helper.*; 31 import oracle.toplink.essentials.exceptions.*; 32 import oracle.toplink.essentials.descriptors.InheritancePolicy; 33 import oracle.toplink.essentials.internal.sessions.AbstractSession; 34 35 56 public class DescriptorQueryManager implements Cloneable , Serializable { 57 protected transient InsertObjectQuery insertQuery; 58 protected transient UpdateObjectQuery updateQuery; 59 protected transient ReadObjectQuery readObjectQuery; 60 protected transient ReadAllQuery readAllQuery; 61 protected transient DeleteObjectQuery deleteQuery; 62 protected DoesExistQuery doesExistQuery; 63 protected ClassDescriptor descriptor; 64 protected boolean hasCustomMultipleTableJoinExpression; 65 protected transient Expression additionalJoinExpression; 66 protected transient Expression multipleTableJoinExpression; 67 protected transient Map queries; 68 protected transient Map tablesJoinExpressions; 69 70 74 public DescriptorQueryManager() { 75 this.queries = new HashMap(5); 76 setDoesExistQuery(new DoesExistQuery()); } 78 79 87 public void addQuery(String name, DatabaseQuery query) { 88 query.setName(name); 89 addQuery(query); 90 } 91 92 99 public synchronized void addQuery(DatabaseQuery query) { 100 if (query instanceof ObjectLevelReadQuery && (((ObjectLevelReadQuery)query).getReferenceClassName() == null)) { 101 ((ObjectLevelReadQuery)query).setReferenceClassName(getDescriptor().getJavaClassName()); 102 103 try { 106 ((ObjectLevelReadQuery)query).setReferenceClass(getDescriptor().getJavaClass()); 107 } catch (ConversionException exception) { 108 } 109 110 query.setDescriptor(getDescriptor()); 112 } 113 114 Vector queriesByName = (Vector)getQueries().get(query.getName()); 117 if (queriesByName == null) { 118 queriesByName = oracle.toplink.essentials.internal.helper.NonSynchronizedVector.newInstance(); 120 getQueries().put(query.getName(), queriesByName); 121 } else { 122 int argumentTypesSize = 0; 123 if (query.getArguments() != null) { 124 argumentTypesSize = query.getArguments().size(); 125 } 126 Vector argumentTypes = oracle.toplink.essentials.internal.helper.NonSynchronizedVector.newInstance(argumentTypesSize); 127 for (int i = 0; i < argumentTypesSize; i++) { 128 argumentTypes.addElement(query.getArgumentTypeNames().elementAt(i)); 129 } 130 131 for (int i = 0; i < queriesByName.size(); i++) { 133 DatabaseQuery currentQuery = (DatabaseQuery)queriesByName.elementAt(i); 134 135 if (argumentTypes.equals(currentQuery.getArgumentTypeNames())) { 140 queriesByName.remove(i); 141 queriesByName.add(i, query); 142 return; 143 } 144 } 145 } 146 queriesByName.add(query); 147 } 148 149 154 public void assumeExistenceForDoesExist() { 155 getDoesExistQuery().assumeExistenceForDoesExist(); 156 } 157 158 163 public void assumeNonExistenceForDoesExist() { 164 getDoesExistQuery().assumeNonExistenceForDoesExist(); 165 } 166 167 173 public void checkCacheForDoesExist() { 174 getDoesExistQuery().checkCacheForDoesExist(); 175 } 176 177 181 public void checkDatabaseForDoesExist() { 182 getDoesExistQuery().checkDatabaseForDoesExist(); 183 } 184 185 189 public Object clone() { 190 DescriptorQueryManager manager = null; 191 try { 192 manager = (DescriptorQueryManager)super.clone(); 193 } catch (Exception exception) { 194 ; 195 } 196 197 manager.setQueries(new Hashtable(getQueries().size())); 199 Iterator iterator = queries.values().iterator(); 200 while (iterator.hasNext()) { 201 Iterator queriesForKey = ((Vector)iterator.next()).iterator(); 202 while (queriesForKey.hasNext()) { 203 DatabaseQuery initialQuery = (DatabaseQuery)queriesForKey.next(); 204 DatabaseQuery clonedQuery = (DatabaseQuery)initialQuery.clone(); 205 clonedQuery.setDescriptor(manager.getDescriptor()); 206 manager.addQuery(clonedQuery); 207 } 208 } 209 manager.setDoesExistQuery((DoesExistQuery)getDoesExistQuery().clone()); 210 if (getReadAllQuery() != null) { 211 manager.setReadAllQuery((ReadAllQuery)getReadAllQuery().clone()); 212 } 213 if (getReadObjectQuery() != null) { 214 manager.setReadObjectQuery((ReadObjectQuery)getReadObjectQuery().clone()); 215 } 216 if (getUpdateQuery() != null) { 217 manager.setUpdateQuery((UpdateObjectQuery)getUpdateQuery().clone()); 218 } 219 if (getInsertQuery() != null) { 220 manager.setInsertQuery((InsertObjectQuery)getInsertQuery().clone()); 221 } 222 if (getDeleteQuery() != null) { 223 manager.setDeleteQuery((DeleteObjectQuery)getDeleteQuery().clone()); 224 } 225 226 return manager; 227 } 228 229 233 public boolean containsQuery(String queryName) { 234 return queries.containsKey(queryName); 235 } 236 237 244 public void convertClassNamesToClasses(ClassLoader classLoader){ 245 Iterator queryVectors = getQueries().values().iterator(); 246 while (queryVectors.hasNext()){ 247 Iterator queries = ((Vector)queryVectors.next()).iterator();; 248 while (queries.hasNext()){ 249 ((DatabaseQuery)queries.next()).convertClassNamesToClasses(classLoader); 250 } 251 } 252 }; 253 254 259 public Expression getAdditionalJoinExpression() { 260 return additionalJoinExpression; 261 } 262 263 271 public DeleteObjectQuery getDeleteQuery() { 272 return deleteQuery; 273 } 274 275 284 public String getDeleteSQLString() { 285 if (getDeleteQuery() == null) { 286 return null; 287 } 288 289 return getDeleteQuery().getSQLString(); 290 } 291 292 296 protected ClassDescriptor getDescriptor() { 297 return descriptor; 298 } 299 300 308 public DoesExistQuery getDoesExistQuery() { 309 return doesExistQuery; 310 } 311 312 323 public String getDoesExistSQLString() { 324 if (getDoesExistQuery() == null) { 325 return null; 326 } 327 328 return getDoesExistQuery().getSQLString(); 329 } 330 331 335 public String getExistenceCheck() { 336 if (getDoesExistQuery().shouldAssumeExistenceForDoesExist()) { 337 return "Assume existence"; 338 } else if (getDoesExistQuery().shouldAssumeNonExistenceForDoesExist()) { 339 return "Assume non-existence"; 340 } else if (getDoesExistQuery().shouldCheckCacheForDoesExist()) { 341 return "Check cache"; 342 } else if (getDoesExistQuery().shouldCheckDatabaseForDoesExist()) { 343 return "Check database"; 344 } else { 345 return "Check cache"; 347 } 348 } 349 350 359 public InsertObjectQuery getInsertQuery() { 360 return insertQuery; 361 } 362 363 372 public String getInsertSQLString() { 373 if (getInsertQuery() == null) { 374 return null; 375 } 376 377 return getInsertQuery().getSQLString(); 378 } 379 380 386 public Expression getMultipleTableJoinExpression() { 387 return multipleTableJoinExpression; 388 } 389 390 397 public Map getQueries() { 398 return queries; 399 } 400 401 408 public Vector getAllQueries() { 409 Vector allQueries = new Vector(); 410 for (Iterator vectors = getQueries().values().iterator(); vectors.hasNext();) { 411 allQueries.addAll((Vector)vectors.next()); 412 } 413 return allQueries; 414 } 415 416 420 public void setAllQueries(Vector vector) { 421 for (Enumeration enumtr = vector.elements(); enumtr.hasMoreElements();) { 422 addQuery((DatabaseQuery)enumtr.nextElement()); 423 } 424 } 425 426 430 public void setQueries(Map hashtable) { 431 queries = hashtable; 432 } 433 434 443 public DatabaseQuery getQuery(String queryName) { 444 return getQuery(queryName, null); 445 } 446 447 458 public DatabaseQuery getQuery(String name, Vector arguments) { 459 DatabaseQuery query = getLocalQuery(name, arguments); 460 461 if (query == null) { 465 DatabaseQuery parentQuery = getQueryFromParent(name, arguments); 466 if (parentQuery != null && parentQuery.isReadQuery()) { 467 parentQuery = (DatabaseQuery) parentQuery.clone(); 468 ((ObjectLevelReadQuery)parentQuery).setReferenceClass(getDescriptor().getJavaClass()); 469 addQuery(name, parentQuery); 470 } 471 return parentQuery; 472 } 473 return query; 474 } 475 476 486 public DatabaseQuery getLocalQuery(String name, Vector arguments) { 487 Vector queries = (Vector)getQueries().get(name); 488 489 if (queries == null){ 490 return null; 491 } 492 493 if (queries.size() == 1) { 495 return (DatabaseQuery)queries.firstElement(); 496 } 497 498 int argumentTypesSize = 0; 506 if (arguments != null) { 507 argumentTypesSize = arguments.size(); 508 } 509 Vector argumentTypes = oracle.toplink.essentials.internal.helper.NonSynchronizedVector.newInstance(argumentTypesSize); 510 for (int i = 0; i < argumentTypesSize; i++) { 511 argumentTypes.addElement(arguments.elementAt(i).getClass()); 512 } 513 for (Enumeration queriesEnum = queries.elements(); queriesEnum.hasMoreElements();) { 514 DatabaseQuery query = (DatabaseQuery)queriesEnum.nextElement(); 515 516 if (Helper.areTypesAssignable(query.getArgumentTypes(), argumentTypes)) { 520 return query; 521 } 522 } 523 524 return null; 525 526 } 527 528 536 protected DatabaseQuery getQueryFromParent(String name, Vector arguments) { 537 ClassDescriptor descriptor = getDescriptor(); 538 if (descriptor.hasInheritance()) { 539 InheritancePolicy inheritancePolicy = descriptor.getInheritancePolicy(); 540 ClassDescriptor parent = inheritancePolicy.getParentDescriptor(); 541 542 if (parent != null) { 544 return parent.getQueryManager().getQuery(name, arguments); 545 } 546 } 547 return null; 548 } 549 550 555 public ReadAllQuery getReadAllQuery() { 556 return readAllQuery; 557 } 558 559 569 public String getReadAllSQLString() { 570 if (getReadAllQuery() == null) { 571 return null; 572 } 573 574 return getReadAllQuery().getSQLString(); 575 } 576 577 586 public ReadObjectQuery getReadObjectQuery() { 587 return readObjectQuery; 588 } 589 590 600 public String getReadObjectSQLString() { 601 if (getReadObjectQuery() == null) { 602 return null; 603 } 604 605 return getReadObjectQuery().getSQLString(); 606 } 607 608 617 public UpdateObjectQuery getUpdateQuery() { 618 return updateQuery; 619 } 620 621 631 public String getUpdateSQLString() { 632 if (getUpdateQuery() == null) { 633 return null; 634 } 635 636 return getUpdateQuery().getSQLString(); 637 } 638 639 643 public boolean hasCustomMultipleTableJoinExpression() { 644 return hasCustomMultipleTableJoinExpression; 645 } 646 647 651 public boolean hasDeleteQuery() { 652 return (deleteQuery != null); 653 } 654 655 659 public boolean hasDoesExistQuery() { 660 return (doesExistQuery != null); 661 } 662 663 667 public boolean hasInsertQuery() { 668 return (insertQuery != null); 669 } 670 671 675 public boolean hasReadAllQuery() { 676 return (readAllQuery != null); 677 } 678 679 683 public boolean hasReadObjectQuery() { 684 return (readObjectQuery != null); 685 } 686 687 691 public boolean hasUpdateQuery() { 692 return (updateQuery != null); 693 } 694 695 699 private void populateQueries() { 700 701 707 if (getInsertQuery() != null) { 708 getInsertQuery().setDescriptor(descriptor); 709 } 710 if (getUpdateQuery() != null) { 711 getUpdateQuery().setDescriptor(descriptor); 712 } 713 if (getReadObjectQuery() != null) { 714 getReadObjectQuery().setReferenceClass(getDescriptor().getJavaClass()); 715 getReadObjectQuery().setDescriptor(descriptor); 716 } 717 if (getDeleteQuery() != null) { 718 getDeleteQuery().setDescriptor(descriptor); 719 } 720 if (getReadAllQuery() != null) { 721 getReadAllQuery().setReferenceClass(getDescriptor().getJavaClass()); 722 getReadAllQuery().setDescriptor(descriptor); 723 } 724 for (Iterator it = getAllQueries().iterator(); it.hasNext();) { 725 ((DatabaseQuery)it.next()).setDescriptor(descriptor); 726 } 727 } 728 729 733 public void initialize(AbstractSession session) { 734 735 if (getDescriptor().isAggregateDescriptor()) { 736 return; 737 } 738 739 if (getMultipleTableJoinExpression() != null) { 740 setAdditionalJoinExpression(getMultipleTableJoinExpression().and(getAdditionalJoinExpression())); 742 } 743 744 if (getDescriptor().isAggregateCollectionDescriptor()) { 745 return; 746 } 747 748 if (!hasReadObjectQuery()) { 750 ReadObjectQuery readObjectQuery = new ReadObjectQuery(); 752 readObjectQuery.setSelectionCriteria(getDescriptor().getObjectBuilder().getPrimaryKeyExpression()); 753 setReadObjectQuery(readObjectQuery); 754 } 755 756 if (!hasInsertQuery()) { 757 setInsertQuery(new InsertObjectQuery()); 759 } 760 getInsertQuery().setModifyRow(getDescriptor().getObjectBuilder().buildTemplateInsertRow(session)); 761 762 if (!hasDeleteQuery()) { 763 setDeleteQuery(new DeleteObjectQuery()); 765 } 766 getDeleteQuery().setModifyRow(new DatabaseRecord()); 767 768 if (hasUpdateQuery()) { 769 getUpdateQuery().setModifyRow(getDescriptor().getObjectBuilder().buildTemplateUpdateRow(session)); 771 } 772 } 773 774 782 public DescriptorQueryManager getParentDescriptorQueryManager() { 783 return getDescriptor().getInheritancePolicy().getParentDescriptor().getQueryManager(); 784 } 785 786 790 public void postDelete(DeleteObjectQuery query) { 791 Vector mappings = getDescriptor().getMappings(); 793 for (int index = 0; index < mappings.size(); index++) { 794 ((DatabaseMapping)mappings.get(index)).postDelete(query); 795 } 796 } 797 798 802 public void postInsert(WriteObjectQuery query) { 803 Vector mappings = getDescriptor().getMappings(); 805 for (int index = 0; index < mappings.size(); index++) { 806 ((DatabaseMapping)mappings.get(index)).postInsert(query); 807 } 808 } 809 810 814 public void postUpdate(WriteObjectQuery query) { 815 Vector mappings = getDescriptor().getMappings(); 817 for (int index = 0; index < mappings.size(); index++) { 818 ((DatabaseMapping)mappings.get(index)).postUpdate(query); 819 } 820 } 821 822 826 public void preDelete(DeleteObjectQuery query) { 827 Vector mappings = getDescriptor().getMappings(); 829 for (int index = 0; index < mappings.size(); index++) { 830 ((DatabaseMapping)mappings.get(index)).preDelete(query); 831 } 832 } 833 834 839 public void preInitialize(AbstractSession session) { 840 if (getDescriptor().isAggregateDescriptor()) { 841 return; 842 } 843 844 if (getDescriptor().isChildDescriptor()) { 846 DescriptorQueryManager parentQueryManager = getDescriptor().getInheritancePolicy().getParentDescriptor().getQueryManager(); 847 848 if ((!hasInsertQuery()) && (parentQueryManager.hasInsertQuery())) { 849 setInsertQuery((InsertObjectQuery)parentQueryManager.getInsertQuery().clone()); 850 } 851 if ((!hasUpdateQuery()) && (parentQueryManager.hasUpdateQuery())) { 852 setUpdateQuery((UpdateObjectQuery)parentQueryManager.getUpdateQuery().clone()); 853 } 854 if ((!hasDeleteQuery()) && (parentQueryManager.hasDeleteQuery())) { 855 setDeleteQuery((DeleteObjectQuery)parentQueryManager.getDeleteQuery().clone()); 856 } 857 if ((!hasReadObjectQuery()) && (parentQueryManager.hasReadObjectQuery())) { 858 setReadObjectQuery((ReadObjectQuery)parentQueryManager.getReadObjectQuery().clone()); 859 } 860 if ((!hasReadAllQuery()) && (parentQueryManager.hasReadAllQuery())) { 861 setReadAllQuery((ReadAllQuery)parentQueryManager.getReadAllQuery().clone()); 862 } 863 if ((!getDoesExistQuery().isUserDefined()) && getDoesExistQuery().shouldCheckCacheForDoesExist()) { 864 setDoesExistQuery(((DoesExistQuery)parentQueryManager.getDoesExistQuery().clone())); 865 } 866 } 867 } 868 869 873 public void preInsert(WriteObjectQuery query) { 874 Vector mappings = getDescriptor().getMappings(); 876 for (int index = 0; index < mappings.size(); index++) { 877 ((DatabaseMapping)mappings.get(index)).preInsert(query); 878 } 879 } 880 881 885 public void preUpdate(WriteObjectQuery query) { 886 Vector mappings = getDescriptor().getMappings(); 888 for (int index = 0; index < mappings.size(); index++) { 889 ((DatabaseMapping)mappings.get(index)).preUpdate(query); 890 } 891 } 892 893 899 public void removeQuery(String queryName) { 900 queries.remove(queryName); 901 } 902 903 909 public void removeQuery(String queryName, Vector argumentTypes) { 910 Vector queries = (Vector)getQueries().get(queryName); 911 if (queries == null) { 912 return; 913 } else { 914 DatabaseQuery query = null; 915 for (Enumeration enumtr = queries.elements(); enumtr.hasMoreElements();) { 916 query = (DatabaseQuery)enumtr.nextElement(); 917 if (Helper.areTypesAssignable(argumentTypes, query.getArgumentTypes())) { 918 break; 919 } 920 } 921 if (query != null) { 922 queries.remove(query); 923 } 924 } 925 } 926 927 935 public void setAdditionalJoinExpression(Expression additionalJoinExpression) { 936 this.additionalJoinExpression = additionalJoinExpression; 937 } 938 939 947 public void setDeleteQuery(DeleteObjectQuery query) { 948 this.deleteQuery = query; 949 if (query == null) { 950 return; 951 } 952 this.deleteQuery.setIsUserDefined(true); 953 this.deleteQuery.setDescriptor(getDescriptor()); 954 955 } 956 957 966 public void setDeleteSQLString(String sqlString) { 967 if (sqlString == null) { 968 return; 969 } 970 971 DeleteObjectQuery query = new DeleteObjectQuery(); 972 query.setSQLString(sqlString); 973 setDeleteQuery(query); 974 } 975 976 981 public void setDeleteCall(Call call) { 982 if (call == null) { 983 return; 984 } 985 DeleteObjectQuery query = new DeleteObjectQuery(); 986 query.setCall(call); 987 setDeleteQuery(query); 988 } 989 990 994 public void setDescriptor(ClassDescriptor descriptor) { 995 this.descriptor = descriptor; 996 populateQueries(); 999 1000 } 1001 1002 1010 public void setDoesExistQuery(DoesExistQuery query) { 1011 this.doesExistQuery = query; 1012 if (query == null) { 1013 return; 1014 } 1015 this.doesExistQuery.setIsUserDefined(true); 1016 this.doesExistQuery.setDescriptor(getDescriptor()); 1017 } 1018 1019 1029 public void setDoesExistSQLString(String sqlString) { 1030 if (sqlString == null) { 1031 return; 1032 } 1033 getDoesExistQuery().setSQLString(sqlString); 1034 getDoesExistQuery().checkDatabaseForDoesExist(); 1035 } 1036 1037 1042 public void setDoesExistCall(Call call) { 1043 if (call == null) { 1044 return; 1045 } 1046 getDoesExistQuery().setCall(call); 1047 } 1048 1049 1053 public void setExistenceCheck(String token) throws DescriptorException { 1054 if (token.equals("Check cache")) { 1055 checkCacheForDoesExist(); 1056 } else if (token.equals("Check database")) { 1057 checkDatabaseForDoesExist(); 1058 } else if (token.equals("Assume existence")) { 1059 assumeExistenceForDoesExist(); 1060 } else if (token.equals("Assume non-existence")) { 1061 assumeNonExistenceForDoesExist(); 1062 } else { 1063 throw DescriptorException.setExistenceCheckingNotUnderstood(token, getDescriptor()); 1064 } 1065 } 1066 1067 1071 protected void setHasCustomMultipleTableJoinExpression(boolean hasCustomMultipleTableJoinExpression) { 1072 this.hasCustomMultipleTableJoinExpression = hasCustomMultipleTableJoinExpression; 1073 } 1074 1075 1083 public void setInsertQuery(InsertObjectQuery insertQuery) { 1084 this.insertQuery = insertQuery; 1085 if (insertQuery == null) { 1086 return; 1087 } 1088 this.insertQuery.setIsUserDefined(true); 1089 this.insertQuery.setDescriptor(getDescriptor()); 1090 } 1091 1092 1097 public void setInsertCall(Call call) { 1098 if (call == null) { 1099 return; 1100 } 1101 InsertObjectQuery query = new InsertObjectQuery(); 1102 query.setCall(call); 1103 setInsertQuery(query); 1104 } 1105 1106 1115 public void setInsertSQLString(String sqlString) { 1116 if (sqlString == null) { 1117 return; 1118 } 1119 1120 InsertObjectQuery query = new InsertObjectQuery(); 1121 query.setSQLString(sqlString); 1122 setInsertQuery(query); 1123 } 1124 1125 1130 public Call getInsertCall() { 1131 if (getInsertQuery() == null) { 1132 return null; 1133 } 1134 return getInsertQuery().getDatasourceCall(); 1135 } 1136 1137 1142 public Call getUpdateCall() { 1143 if (getUpdateQuery() == null) { 1144 return null; 1145 } 1146 return getUpdateQuery().getDatasourceCall(); 1147 } 1148 1149 1154 public Call getDeleteCall() { 1155 if (getDeleteQuery() == null) { 1156 return null; 1157 } 1158 return getDeleteQuery().getDatasourceCall(); 1159 } 1160 1161 1166 public Call getReadObjectCall() { 1167 if (getReadObjectQuery() == null) { 1168 return null; 1169 } 1170 return getReadObjectQuery().getDatasourceCall(); 1171 } 1172 1173 1178 public Call getReadAllCall() { 1179 if (getReadAllQuery() == null) { 1180 return null; 1181 } 1182 return getReadAllQuery().getDatasourceCall(); 1183 } 1184 1185 1190 public Call getDoesExistCall() { 1191 if (getDoesExistQuery() == null) { 1192 return null; 1193 } 1194 return getDoesExistQuery().getDatasourceCall(); 1195 } 1196 1197 1202 public Map getTablesJoinExpressions() { 1203 if(tablesJoinExpressions == null) { 1204 tablesJoinExpressions = new HashMap(); 1205 } 1206 return tablesJoinExpressions; 1207 } 1208 1209 1215 public void setInternalMultipleTableJoinExpression(Expression multipleTableJoinExpression) { 1216 this.multipleTableJoinExpression = multipleTableJoinExpression; 1217 } 1218 1219 1225 public void setMultipleTableJoinExpression(Expression multipleTableJoinExpression) { 1226 this.multipleTableJoinExpression = multipleTableJoinExpression; 1227 setHasCustomMultipleTableJoinExpression(true); 1228 } 1229 1230 1239 public void setReadAllQuery(ReadAllQuery query) { 1240 this.readAllQuery = query; 1241 if (query == null) { 1242 return; 1243 } 1244 1245 this.readAllQuery.setIsUserDefined(true); 1246 1247 1255 if (this.getDescriptor() != null) { 1256 this.readAllQuery.setDescriptor(getDescriptor()); 1257 this.readAllQuery.setReferenceClassName(getDescriptor().getJavaClassName()); 1258 try { 1259 readAllQuery.setReferenceClass(getDescriptor().getJavaClass()); 1260 } catch (ConversionException exception) { 1261 } 1262 } 1263 } 1264 1265 1275 public void setReadAllSQLString(String sqlString) { 1276 if (sqlString == null) { 1277 return; 1278 } 1279 1280 ReadAllQuery query = new ReadAllQuery(); 1281 query.setSQLString(sqlString); 1282 setReadAllQuery(query); 1283 } 1284 1285 1291 public void setReadAllCall(Call call) { 1292 if (call == null) { 1293 return; 1294 } 1295 ReadAllQuery query = new ReadAllQuery(); 1296 query.setCall(call); 1297 setReadAllQuery(query); 1298 } 1299 1300 1309 public void setReadObjectQuery(ReadObjectQuery query) { 1310 this.readObjectQuery = query; 1311 if (query == null) { 1312 return; 1313 } 1314 this.readObjectQuery.setIsUserDefined(true); 1315 1316 1324 if (this.getDescriptor() != null) { 1325 this.readObjectQuery.setDescriptor(getDescriptor()); 1326 this.readObjectQuery.setReferenceClassName(getDescriptor().getJavaClassName()); 1327 try { 1328 readObjectQuery.setReferenceClass(getDescriptor().getJavaClass()); 1329 } catch (ConversionException exception) { 1330 } 1331 } 1332 } 1333 1334 1344 public void setReadObjectSQLString(String sqlString) { 1345 if (sqlString == null) { 1346 return; 1347 } 1348 1349 ReadObjectQuery query = new ReadObjectQuery(); 1350 query.setSQLString(sqlString); 1351 setReadObjectQuery(query); 1352 } 1353 1354 1360 public void setReadObjectCall(Call call) { 1361 if (call == null) { 1362 return; 1363 } 1364 ReadObjectQuery query = new ReadObjectQuery(); 1365 query.setCall(call); 1366 setReadObjectQuery(query); 1367 } 1368 1369 1378 public void setUpdateQuery(UpdateObjectQuery updateQuery) { 1379 this.updateQuery = updateQuery; 1380 if (updateQuery == null) { 1381 return; 1382 } 1383 this.updateQuery.setIsUserDefined(true); 1384 this.updateQuery.setDescriptor(getDescriptor()); 1385 } 1386 1387 1397 public void setUpdateSQLString(String sqlString) { 1398 if (sqlString == null) { 1399 return; 1400 } 1401 1402 UpdateObjectQuery query = new UpdateObjectQuery(); 1403 query.setSQLString(sqlString); 1404 setUpdateQuery(query); 1405 } 1406 1407 1412 public void setUpdateCall(Call call) { 1413 if (call == null) { 1414 return; 1415 } 1416 UpdateObjectQuery query = new UpdateObjectQuery(); 1417 query.setCall(call); 1418 setUpdateQuery(query); 1419 } 1420} 1421 | Popular Tags |