1 23 24 37 package com.lutris.dods.builder.generator.dataobject; 38 39 import java.io.ByteArrayInputStream ; 40 import java.io.IOException ; 41 import java.math.BigDecimal ; 42 import java.sql.PreparedStatement ; 43 import java.sql.ResultSet ; 44 import java.sql.SQLException ; 45 import java.sql.Types ; 46 import com.lutris.logging.Logger; 47 import org.enhydra.dods.DODS; 48 import org.enhydra.dods.cache.Condition; 49 import com.lutris.appserver.server.sql.CloneableDO; 50 import com.lutris.appserver.server.sql.CoreDO; 51 import com.lutris.appserver.server.sql.DBConnection; 52 import com.lutris.appserver.server.sql.DBRowUpdateException; 53 import com.lutris.appserver.server.sql.DatabaseManagerException; 54 import com.lutris.appserver.server.sql.ObjectId; 55 import com.lutris.appserver.server.sql.ObjectIdException; 56 import com.lutris.appserver.server.sql.standard.DriverSpecificConstants; 57 import com.lutris.appserver.server.sql.standard.StandardLogicalDatabase; 58 import com.lutris.dods.builder.generator.query.DataObjectException; 59 import com.lutris.dods.builder.generator.query.QueryException; 60 import com.lutris.dods.builder.generator.query.RefAssertionException; 61 62 abstract public class GenericDO extends CloneableDO { 63 static public void printMsg(int level, String s) { 64 try { 65 DODS.getLogChannel().write(level, s); 66 } catch (Exception e) { 67 System.out.println(level + " " + s); 68 } 69 } 70 protected boolean dirty = false; 73 private boolean notUsingOId = false; 75 76 private static Boolean setNullAsVarchar = null; 77 78 private static Boolean setBytesAsLongvarbinary = null; 79 80 private static Boolean setBytesAsBinaryStream = null; 81 82 private static Boolean setBooleanAsString = null; 83 84 85 86 private static boolean isSetNullAsVarchar() { 87 if (setNullAsVarchar==null) { 88 setNullAsVarchar = new Boolean (DriverSpecificConstants.DEFAULT_SET_NULL_AS_VARCHAR); 89 try { 90 String setNullAsVarcharStr = ((StandardLogicalDatabase)DODS.getDatabaseManager() 91 .findLogicalDatabase(DODS.getDatabaseManager().getDefaultDB())) 92 .getDriverProperty(DriverSpecificConstants.PARAMNAME_SET_NULL_AS_VARCHAR); 93 if(setNullAsVarcharStr!=null){ 94 if(setNullAsVarcharStr.equalsIgnoreCase("true")){ 95 setNullAsVarchar=new Boolean (true); 96 }else if(setNullAsVarcharStr.equalsIgnoreCase("false")){ 97 setNullAsVarchar=new Boolean (false); 98 }else{ 99 DODS.getLogChannel().write(Logger.DEBUG,"Illegal value for SetNullAsVarchar parameter. Using default"); 100 } 101 } 102 } catch (DatabaseManagerException e){ 103 DODS.getLogChannel().write(Logger.DEBUG," Unable to read configuration for SetNullAsVarchar. Using default. "); 104 } 105 } 106 return setNullAsVarchar.booleanValue(); 107 } 108 109 private static boolean isSetBooleanAsString() { 110 if (setBooleanAsString == null) { 111 setBooleanAsString = new Boolean (DriverSpecificConstants.DEFAULT_SET_BOOLEAN_AS_STRING); 112 try { 113 String setBooleanAsStringStr = ((StandardLogicalDatabase)DODS.getDatabaseManager() 114 .findLogicalDatabase(DODS.getDatabaseManager().getDefaultDB())) 115 .getDriverProperty(DriverSpecificConstants.PARAMNAME_SET_BOOLEAN_AS_STRING); 116 if(setBooleanAsStringStr!=null){ 117 if(setBooleanAsStringStr.equalsIgnoreCase("true")){ 118 setBooleanAsString=new Boolean (true); 119 }else if(setBooleanAsStringStr.equalsIgnoreCase("false")){ 120 setBooleanAsString=new Boolean (false); 121 }else{ 122 DODS.getLogChannel().write(Logger.DEBUG,"Illegal value for SetBooleanAsString parameter. Using default ('true')."); 123 } 124 } 125 } catch (DatabaseManagerException e){ 126 DODS.getLogChannel().write(Logger.DEBUG," Unable to read configuration for SetBooleanAsString. Using default ('true'). "); 127 } 128 } 129 return setBooleanAsString.booleanValue(); 130 } 131 132 133 private static boolean isSetBytesAsBinaryStream() { 134 if (setBytesAsBinaryStream == null) { 135 setBytesAsBinaryStream = new Boolean (DriverSpecificConstants.DEFAULT_SET_BYTES_AS_BINARY_STREAM); 136 try { 137 String setBytesAsBinaryStreamStr = ((StandardLogicalDatabase)DODS.getDatabaseManager() 138 .findLogicalDatabase(DODS.getDatabaseManager().getDefaultDB())) 139 .getDriverProperty(DriverSpecificConstants.PARAMNAME_SET_BYTES_AS_BINARY_STREAM); 140 if(setBytesAsBinaryStreamStr!=null){ 141 if(setBytesAsBinaryStreamStr.equalsIgnoreCase("true")){ 142 setBytesAsBinaryStream=new Boolean (true); 143 }else if(setBytesAsBinaryStreamStr.equalsIgnoreCase("false")){ 144 setBytesAsBinaryStream=new Boolean (false); 145 }else{ 146 DODS.getLogChannel().write(Logger.DEBUG,"Illegal value for SetBytesAsBinaryStream parameter. Using default"); 147 } 148 } 149 } catch (DatabaseManagerException e){ 150 DODS.getLogChannel().write(Logger.DEBUG," Unable to read configuration for SetBytesAsBinaryStream. Using default. "); 151 } 152 } 153 return setBytesAsBinaryStream.booleanValue(); 154 } 155 156 private static boolean isSetBytesAsLongvarbinary() { 157 if (setBytesAsLongvarbinary == null) { 158 setBytesAsLongvarbinary = new Boolean (DriverSpecificConstants.DEFAULT_SET_BYTES_AS_LONGVARBINARY); 159 try { 160 String setBytesAsLongvarbinaryStr = ((StandardLogicalDatabase)DODS.getDatabaseManager() 161 .findLogicalDatabase(DODS.getDatabaseManager().getDefaultDB())) 162 .getDriverProperty(DriverSpecificConstants.PARAMNAME_SET_BYTES_AS_LONGVARBINARY); 163 if(setBytesAsLongvarbinaryStr!=null){ 164 if(setBytesAsLongvarbinaryStr.equalsIgnoreCase("true")){ 165 setBytesAsLongvarbinary=new Boolean (true); 166 }else if(setBytesAsLongvarbinaryStr.equalsIgnoreCase("false")){ 167 setBytesAsLongvarbinary=new Boolean (false); 168 }else{ 169 DODS.getLogChannel().write(Logger.DEBUG,"Illegal value for SetBytesAsLongvarchar parameter. Using default"); 170 } 171 } 172 } catch (DatabaseManagerException e){ 173 DODS.getLogChannel().write(Logger.DEBUG," Unable to read configuration for SetBytesAsLongvarchar. Using default. "); 174 } 175 } 176 return setBytesAsLongvarbinary.booleanValue(); 177 } 178 179 180 181 184 public GenericDO() 185 throws ObjectIdException, DatabaseManagerException { 186 super(); 187 set_OId(DODS.getDatabaseManager().allocateObjectId()); 188 markNewValue(); 189 } 190 191 194 public GenericDO(String dbName) 195 throws ObjectIdException, DatabaseManagerException { 196 super(); 197 set_OId(DODS.getDatabaseManager().allocateObjectId(dbName)); 198 markNewValue(); 199 } 200 201 204 public GenericDO(boolean notUsingOId) 205 throws ObjectIdException, DatabaseManagerException { 206 super(); 207 this.notUsingOId = notUsingOId; 208 if (!notUsingOId) { 209 set_OId(DODS.getDatabaseManager().allocateObjectId()); 210 } 211 markNewValue(); 212 } 213 214 217 public GenericDO(String dbName, boolean notUsingOId) 218 throws ObjectIdException, DatabaseManagerException { 219 super(); 220 this.notUsingOId = notUsingOId; 221 if (!notUsingOId) { 222 set_OId(DODS.getDatabaseManager().allocateObjectId(dbName)); 223 } 224 markNewValue(); 225 } 226 227 230 public GenericDO(ObjectId id) 231 throws ObjectIdException, DatabaseManagerException { 232 super(); 233 set_OId(id); 234 } 235 236 239 public GenericDO(String dbName, ObjectId id) 240 throws ObjectIdException, DatabaseManagerException { 241 super(); 242 set_OId(id); 243 } 244 245 255 public GenericDO(ResultSet rs) 256 throws SQLException , ObjectIdException, DatabaseManagerException { 257 super(rs); 258 } 260 261 271 public GenericDO(String dbName, ResultSet rs) 272 throws SQLException , ObjectIdException, DatabaseManagerException { 273 super(rs); 274 } 276 277 286 public synchronized Object cloneUnique() 287 throws DatabaseManagerException, ObjectIdException { 288 GenericDO dataObj = (GenericDO) super.cloneUnique(); 289 290 dataObj.set_Version(0); 294 dataObj.markNewValue(); return dataObj; 296 } 297 298 307 protected void makeIdentical(GenericDO obj) {} 308 309 319 public synchronized void executeUpdate(DBConnection conn) 320 throws SQLException , DBRowUpdateException { 321 if (dirty) { 322 if (!notUsingOId) { 323 printMsg(Logger.DEBUG, 324 getClass().getName() + ".executeUpdate:" + persistent 325 + ": " + getClass().getName() + ": " 326 + get_OId().toString() + ": " + get_Version()); 327 } 328 super.executeUpdate(conn); 329 } 330 } 331 332 342 public synchronized void executeInsert(DBConnection conn) 343 throws SQLException , DBRowUpdateException { 344 345 346 if (!notUsingOId) { 347 printMsg(Logger.DEBUG, 348 getClass().getName() + ".executeInsert():" + persistent 349 + ": " + get_OId().toString() + ": " + get_Version() + ": " 350 + get_NewVersion()); 351 } 352 super.executeInsert(conn); 353 354 356 } 357 358 365 public void executeDelete(DBConnection conn) 366 throws SQLException { 367 369 if (isPersistent()) { 370 if (!notUsingOId) { 371 printMsg(Logger.DEBUG, 372 getClass().getName() + ".executeDelete(): " + persistent 373 + ": " + get_OId().toString() + ": " + get_Version()); 374 } 375 super.executeDelete(conn); 376 } 377 } 378 379 384 public void finalizeInsert(boolean success) { 385 if (!notUsingOId) { 386 printMsg(Logger.DEBUG, 387 getClass().getName() + ".finalizeInsert(" + success + ") " 388 + "oid=" + get_OId().toString() + " " + "version=" 389 + get_Version()); 390 } 391 boolean p = persistent; 392 393 super.finalizeInsert(success); 394 if (p == true) { 395 persistent = true; } 397 if (success) { 398 dirty = false; 399 } 400 } 401 402 407 public void finalizeUpdate(boolean success) { 408 if (!notUsingOId) { 409 printMsg(Logger.DEBUG, 410 getClass().getName() + ".finalizeUpdate:" + success + ": " 411 + get_OId().toString() + ": " + get_Version()); 412 } 413 super.finalizeUpdate(success); 414 if (success) { 415 dirty = false; 416 } 417 } 419 420 428 static protected String get_primaryKeyName() { 429 return CoreDO.get_OIdColumnName(); 430 } 431 432 441 static protected String getPrimaryKeyName() { 442 return get_primaryKeyName(); 443 } 444 445 449 protected void setOId(ObjectId oId) { 450 set_OId(oId); 451 } 452 453 457 protected void set_OId(ObjectId oId) { 458 if (!notUsingOId) { 459 super.set_OId(markNewValue(get_OId(), oId)); 460 } 461 } 462 463 467 public boolean isDirty() { 468 return dirty; 469 } 470 471 479 protected void markClean() { 480 dirty = false; 481 } 482 483 493 protected void markNewValue() { 494 dirty = true; 495 } 496 497 522 protected String markNewValue(String current_string, String new_string, 523 int max_length, 524 boolean nullOK) { 525 526 540 return markNewValue(current_string, new_string, 0, max_length, nullOK); 542 } 543 544 575 protected String markNewValue(String current_string, String new_string, 576 int min_length, int max_length, 577 boolean nullOK) { 578 colChanged = false; 579 if (!nullOK && current_string == null) { current_string = ""; 581 } 582 if (new_string == null) { 583 if (!nullOK) { return current_string; 585 } else { 586 if (current_string != null) { 587 colChanged = dirty = true; 588 } 589 return null; 590 } 591 } 592 if (min_length >= 0 && new_string.length() < min_length) { 593 new_string = current_string; 594 } if (max_length > 00 && new_string.length() > max_length) { 596 new_string = new_string.substring(0, max_length); 597 } 598 if (!new_string.equals(current_string)) { 599 colChanged = dirty = true; 600 } 601 return new_string; 602 } 603 protected boolean colChanged = false; 604 622 protected ObjectId markNewValue(ObjectId current_OId, ObjectId new_OId) { 623 colChanged = false; 624 if (current_OId == null) { 625 if (new_OId != null) { 626 colChanged = dirty = true; 627 } 628 } else { 629 if (new_OId == null) { 630 colChanged = dirty = true; 631 } else if (!current_OId.toString().equals(new_OId.toString())) { 632 colChanged = dirty = true; 633 } 634 } 635 return new_OId; 636 } 637 638 656 protected java.util.Date markNewValue( 657 java.util.Date current_date, java.util.Date new_date) { 658 colChanged = false; 659 if (current_date == null) { 660 if (new_date != null) { 661 colChanged = dirty = true; 662 } 663 } else { 664 if (new_date == null) { 665 colChanged = dirty = true; 666 } else if (!current_date.toString().equals(new_date.toString())) { 667 colChanged = dirty = true; 668 } 669 } 670 return new_date; 671 } 672 673 691 protected BigDecimal markNewValue(BigDecimal current_bd, BigDecimal new_bd) { 692 colChanged = false; 693 if (current_bd == null) { 694 if (new_bd != null) { 695 colChanged = dirty = true; 696 } 697 } else { 698 if (new_bd == null) { 699 colChanged = dirty = true; 700 } else if (!current_bd.equals(new_bd)) { 701 colChanged = dirty = true; 702 } 703 } 704 return new_bd; 705 } 706 707 725 protected byte[] markNewValue(byte[] current_val, byte[] new_val) { 726 colChanged = false; 727 if (current_val == null) { 728 if (new_val != null) { 729 colChanged = dirty = true; 730 } 731 } else { 732 if (new_val == null) { 733 colChanged = dirty = true; 734 } else { 735 if (current_val.length != new_val.length) { colChanged = dirty = true; 737 } else { 738 for (int i = 0; i < current_val.length; i++) { 739 if (current_val[i] != new_val[i]) { 740 colChanged = dirty = true; 741 break; 742 } 743 } 744 } 745 } 746 } 747 return new_val; 748 } 749 750 768 protected java.sql.Date markNewValue( 769 java.sql.Date current_val, java.sql.Date new_val) { 770 colChanged = false; 771 if (current_val == null) { 772 if (new_val != null) { 773 colChanged = dirty = true; 774 } 775 } else { 776 if (new_val == null) { 777 colChanged = dirty = true; 778 } else if (!current_val.equals(new_val)) { 779 colChanged = dirty = true; 780 } 781 } 782 return new_val; 783 } 784 785 803 protected java.sql.Time markNewValue( 804 java.sql.Time current_val, java.sql.Time new_val) { 805 colChanged = false; 806 if (current_val == null) { 807 if (new_val != null) { 808 colChanged = dirty = true; 809 } 810 } else { 811 if (new_val == null) { 812 colChanged = dirty = true; 813 } else if (!current_val.equals(new_val)) { 814 colChanged = dirty = true; 815 } 816 } 817 return new_val; 818 } 819 820 838 protected java.sql.Timestamp markNewValue( 839 java.sql.Timestamp current_val, java.sql.Timestamp new_val) { 840 colChanged = false; 841 if (current_val == null) { 842 if (new_val != null) { 843 colChanged = dirty = true; 844 } 845 } else { 846 if (new_val == null) { 847 colChanged = dirty = true; 848 } else if (!current_val.equals(new_val)) { 849 colChanged = dirty = true; 850 } 851 } 852 return new_val; 853 } 854 855 873 protected int markNewValue(int current_int, int new_int) { 874 colChanged = false; 875 if (current_int != new_int) { 876 colChanged = dirty = true; 877 } 878 return new_int; 879 } 880 881 899 protected float markNewValue(float current_float, float new_float) { 900 colChanged = false; 901 if (current_float != new_float) { 902 colChanged = dirty = true; 903 } 904 return new_float; 905 } 906 907 925 protected double markNewValue(double current_double, double new_double) { 926 colChanged = false; 927 if (current_double != new_double) { 928 colChanged = dirty = true; 929 } 930 return new_double; 931 } 932 933 951 protected boolean markNewValue(boolean current_boolean, boolean new_boolean) { 952 colChanged = false; 953 if (current_boolean != new_boolean) { 954 colChanged = dirty = true; 955 } 956 return new_boolean; 957 } 958 959 977 protected char markNewValue(char current_char, char new_char) { 978 colChanged = false; 979 if (current_char != new_char) { 980 colChanged = dirty = true; 981 } 982 return new_char; 983 } 984 985 1003 protected byte markNewValue(byte current_byte, byte new_byte) { 1004 colChanged = false; 1005 if (current_byte != new_byte) { 1006 colChanged = dirty = true; 1007 } 1008 return new_byte; 1009 } 1010 1011 1029 protected short markNewValue(short current_short, short new_short) { 1030 colChanged = false; 1031 if (current_short != new_short) { 1032 colChanged = dirty = true; 1033 } 1034 return new_short; 1035 } 1036 1037 1055 protected long markNewValue(long current_long, long new_long) { 1056 colChanged = false; 1057 if (current_long != new_long) { 1058 colChanged = dirty = true; 1059 } 1060 return new_long; 1061 } 1062 1063 1081 protected GenericDO markNewValue(GenericDO current_DO, GenericDO new_DO) { 1082 colChanged = false; 1083 if (current_DO != new_DO) { 1084 colChanged = dirty = true; 1085 } 1086 return new_DO; 1087 } 1088 1089 1105 1106 1114 protected void setPrepStmtParam_DO( 1115 PreparedStatement stmt, int[] paramIndex, GenericDO value) 1116 throws java.sql.SQLException { 1117 if (null == value) { 1118 if (isSetNullAsVarchar()) { 1119 stmt.setNull(paramIndex[0]++, Types.VARCHAR); 1120 }else { 1121 stmt.setNull(paramIndex[0]++, Types.DECIMAL); 1122 } 1123 } else { 1124 ObjectId oid = value.get_OId(); 1125 1126 if (null == oid) { 1127 if (isSetNullAsVarchar()) { 1128 stmt.setNull(paramIndex[0]++, Types.VARCHAR); 1129 }else { 1130 stmt.setNull(paramIndex[0]++, Types.DECIMAL); 1131 } 1132 } else { 1133 setPrepStmtParam_BigDecimal(stmt, paramIndex, oid.toBigDecimal()); 1134 } 1135 } 1136 } 1137 1138 static protected boolean isNewDataDifferent_DO(GenericDO oldData, GenericDO newData) { 1139 return (null == oldData) 1140 ? (null != newData) 1141 : (null == newData) 1142 ? true 1143 : isNewDataDifferent_BigDecimal(oldData.get_OId().toBigDecimal(), 1144 newData.get_OId().toBigDecimal()); 1145 } 1146 1147 protected void setPrepStmtParam_String( 1148 PreparedStatement stmt, int[] paramIndex, String value) 1149 throws java.sql.SQLException { 1150 if (null == value) { 1151 stmt.setNull(paramIndex[0]++, Types.VARCHAR); 1152 } else { 1153 stmt.setString(paramIndex[0]++, value); 1155 } 1156 } 1158 1159 static protected boolean isNewDataDifferent_String(String oldData, String newData) { 1160 return (null == oldData) ? (null != newData) : !oldData.equals(newData); 1161 } 1162 1163 protected void setPrepStmtParam_float( 1164 PreparedStatement stmt, int[] paramIndex, float value) 1165 throws java.sql.SQLException { 1166 stmt.setFloat(paramIndex[0]++, value); 1167 } 1168 1169 static protected boolean isNewDataDifferent_float(float oldData, float newData) { 1170 return oldData != newData; 1171 } 1172 1173 protected void setPrepStmtParam_int( 1174 PreparedStatement stmt, int[] paramIndex, int value) 1175 throws java.sql.SQLException { 1176 stmt.setInt(paramIndex[0]++, value); 1177 } 1178 1179 static protected boolean isNewDataDifferent_int(int oldData, int newData) { 1180 return oldData != newData; 1181 } 1182 1183 protected void setPrepStmtParam_java_math_BigDecimal( 1184 PreparedStatement stmt, int[] paramIndex, BigDecimal value) 1185 throws java.sql.SQLException { 1186 if (null == value) { 1187 if (isSetNullAsVarchar()) { 1188 stmt.setNull(paramIndex[0]++, Types.VARCHAR); 1189 }else { 1190 stmt.setNull(paramIndex[0]++, Types.DECIMAL); 1191 } 1192 } else { 1193 stmt.setBigDecimal(paramIndex[0]++, value); 1194 } 1195 } 1196 1197 static protected boolean isNewDataDifferent_java_math_BigDecimal(BigDecimal oldData, BigDecimal newData) { 1198 return (null == oldData) 1199 ? (null != newData) 1200 : (null == newData) ? true : !oldData.equals(newData); 1201 } 1202 1203 protected void setPrepStmtParam_BigDecimal( 1204 PreparedStatement stmt, int[] paramIndex, BigDecimal value) 1205 throws java.sql.SQLException { 1206 if (null == value) { 1207 if (isSetNullAsVarchar()) { 1208 stmt.setNull(paramIndex[0]++, Types.VARCHAR); 1209 }else { 1210 stmt.setNull(paramIndex[0]++, Types.DECIMAL); 1211 } 1212 } else { 1213 stmt.setBigDecimal(paramIndex[0]++, value); 1214 } 1215 } 1216 1217 static protected boolean isNewDataDifferent_BigDecimal(BigDecimal oldData, BigDecimal newData) { 1218 return isNewDataDifferent_java_math_BigDecimal(oldData, newData); 1219 } 1220 1221 protected void setPrepStmtParam_java_sql_Date( 1222 PreparedStatement stmt, int[] paramIndex, java.sql.Date value) 1223 throws java.sql.SQLException { 1224 if (null == value) { 1225 if (isSetNullAsVarchar()) { 1226 stmt.setNull(paramIndex[0]++, Types.VARCHAR); 1227 }else { 1228 stmt.setNull(paramIndex[0]++, Types.DATE); 1229 } 1230 } else { 1231 stmt.setDate(paramIndex[0]++, value); 1232 } 1233 } 1234 1235 static protected boolean isNewDataDifferent_java_sql_Date(java.sql.Date oldData, java.sql.Date newData) { 1236 return (null == oldData) ? (null != newData) : !oldData.equals(newData); 1237 } 1238 1239 protected void setPrepStmtParam_java_sql_Time( 1240 PreparedStatement stmt, int[] paramIndex, java.sql.Time value) 1241 throws java.sql.SQLException { 1242 if (null == value) { 1243 if (isSetNullAsVarchar()) { 1244 stmt.setNull(paramIndex[0]++, Types.VARCHAR); 1245 }else { 1246 stmt.setNull(paramIndex[0]++, Types.TIME); 1247 } 1248 } else { 1249 stmt.setTime(paramIndex[0]++, value); 1250 } 1251 } 1252 1253 static protected boolean isNewDataDifferent_java_sql_Time(java.sql.Time oldData, java.sql.Time newData) { 1254 return (null == oldData) ? (null != newData) : !oldData.equals(newData); 1255 } 1256 1257 protected void setPrepStmtParam_java_sql_Timestamp( 1258 PreparedStatement stmt, int[] paramIndex, java.sql.Timestamp value) 1259 throws java.sql.SQLException { 1260 if (null == value) { 1261 if (isSetNullAsVarchar()) { 1262 stmt.setNull(paramIndex[0]++, Types.VARCHAR); 1263 }else { 1264 stmt.setNull(paramIndex[0]++, Types.TIMESTAMP); 1265 } 1266 } else { 1267 stmt.setTimestamp(paramIndex[0]++, value); 1268 } 1269 } 1270 1271 static protected boolean isNewDataDifferent_java_sql_Timestamp(java.sql.Timestamp oldData, java.sql.Timestamp newData) { 1272 return (null == oldData) ? (null != newData) : !oldData.equals(newData); 1273 } 1274 1275 protected void setPrepStmtParam_bytes( 1276 PreparedStatement stmt, int[] paramIndex, byte[] value) 1277 throws java.sql.SQLException { 1278 if (null == value) { 1279 if (isSetNullAsVarchar()) { 1280 stmt.setNull(paramIndex[0]++, Types.VARCHAR); 1281 }else { 1282 stmt.setNull(paramIndex[0]++, Types.VARBINARY); 1283 } 1284 } else { 1285 if(isSetBytesAsBinaryStream()) { 1286 ByteArrayInputStream newBAIS = new ByteArrayInputStream (value); 1287 stmt.setBinaryStream(paramIndex[0]++,newBAIS,value.length); 1288 try { 1289 newBAIS.close(); 1290 } catch (IOException e) { 1291 e.printStackTrace(); 1292 } 1293 }else if(isSetBytesAsLongvarbinary()) { 1294 String psValue = new String (value); 1295 stmt.setObject(paramIndex[0]++, psValue, Types.LONGVARBINARY); 1296 }else { 1297 stmt.setBytes(paramIndex[0]++, value); 1299 } 1301 } 1302 1303 } 1304 1305 static protected boolean isNewDataDifferent_bytes(byte[] oldData, byte[] newData) { 1306 if (null == oldData) { 1307 return null != newData; 1308 } else if (oldData.length == newData.length) { 1309 for (int i = 0; i < oldData.length; ++i) { 1310 if (oldData[i] != newData[i]) { 1311 return true; 1312 } 1313 } 1314 return false; 1315 } 1316 return true; 1317 } 1318 1319 protected void setPrepStmtParam_double( 1320 PreparedStatement stmt, int[] paramIndex, double value) 1321 throws java.sql.SQLException { 1322 stmt.setDouble(paramIndex[0]++, value); 1323 } 1324 1325 static protected boolean isNewDataDifferent_double(double oldData, double newData) { 1326 return oldData != newData; 1327 } 1328 1329 protected void setPrepStmtParam_long( 1330 PreparedStatement stmt, int[] paramIndex, long value) 1331 throws java.sql.SQLException { 1332 stmt.setLong(paramIndex[0]++, value); 1333 } 1334 1335 static protected boolean isNewDataDifferent_long(long oldData, long newData) { 1336 return oldData != newData; 1337 } 1338 1339 protected void setPrepStmtParam_short( 1340 PreparedStatement stmt, int[] paramIndex, short value) 1341 throws java.sql.SQLException { 1342 stmt.setShort(paramIndex[0]++, value); 1343 } 1344 1345 static protected boolean isNewDataDifferent_short(short oldData, short newData) { 1346 return oldData != newData; 1347 } 1348 1349 protected void setPrepStmtParam_byte( 1350 PreparedStatement stmt, int[] paramIndex, byte value) 1351 throws java.sql.SQLException { 1352 stmt.setByte(paramIndex[0]++, value); 1353 } 1354 1355 static protected boolean isNewDataDifferent_byte(byte oldData, byte newData) { 1356 return oldData != newData; 1357 } 1358 1359 protected void setPrepStmtParam_boolean(PreparedStatement stmt, int[] paramIndex, boolean value) 1360 throws java.sql.SQLException { 1361 if(isSetBooleanAsString()) { 1362 stmt.setString(paramIndex[0]++, value ? "1" : "0"); 1363 }else { 1364 stmt.setBoolean(paramIndex[0]++, value); 1365 } 1366 } 1367 1368 static protected boolean isNewDataDifferent_boolean(boolean oldData, boolean newData) { 1369 return oldData != newData; 1370 } 1371 1372 public String toString(int x) { 1373 return super.toString(); 1374 } 1375 1376 public void delete() 1377 throws SQLException , DatabaseManagerException, 1378 DataObjectException, RefAssertionException, 1379 DBRowUpdateException, QueryException { 1380 if (false) { 1381 throw new SQLException (""); 1382 } 1383 if (false) { 1384 throw new DatabaseManagerException(""); 1385 } 1386 if (false) { 1387 throw new DataObjectException(""); 1388 } 1389 if (false) { 1390 throw new RefAssertionException(""); 1391 } 1392 if (false) { 1393 throw new DBRowUpdateException(""); 1394 } 1395 if (false) { 1396 throw new QueryException(""); 1397 } 1398 } 1399 1400 static public byte[] copyByteArray(byte[] source) { 1403 if (null == source) { 1404 return null; 1405 } 1406 byte[] dest = new byte[ source.length ]; 1407 1408 System.arraycopy(source, 0, dest, 0, source.length); 1409 return dest; 1410 } 1411 1412 static public String copyString(String source) { 1413 if (null == source) { 1414 return null; 1415 } 1416 return source + ""; 1417 } 1418 1419 static public BigDecimal copyBigDecimal(BigDecimal source) { 1420 if (null == source) { 1421 return null; 1422 } 1423 return new java.math.BigDecimal (source.toString()); 1424 } 1425 1426 static public java.sql.Date copyDate(java.sql.Date source) { 1427 if (null == source) { 1428 return null; 1429 } 1430 return new java.sql.Date (source.getTime()); 1431 } 1432 1433 static public java.sql.Time copyTime(java.sql.Time source) { 1434 if (null == source) { 1435 return null; 1436 } 1437 return new java.sql.Time (source.getTime()); 1438 } 1439 1440 static public java.sql.Timestamp copyTimestamp(java.sql.Timestamp source) { 1441 if (null == source) { 1442 return null; 1443 } 1444 return new java.sql.Timestamp (source.getTime()); 1445 } 1446 1447 1456 public boolean compareCond(Condition cond) { 1457 return false; 1458 } 1459 1460 1467 public void setData(Object data) {} 1468 1469 1475 public void set_Data(Object data) {} 1476 1477 1481 public void originalData_set(Object data) {} 1482 1483 1487 public Object getData() { 1488 return getData(); 1489 } 1490 1491 1497 public Object get_Data() { 1498 return null; 1499 } 1500 1501 1507 public String get_Handle() throws DatabaseManagerException { 1508 return null; 1509 } 1510 1511 1518 public String getHandle() throws DatabaseManagerException { 1519 return null; 1520 } 1521 1522 1528 public String get_CacheHandle() throws DatabaseManagerException { 1529 return null; 1530 } 1531 1532 1539 public GenericDO createDO(GenericDO obj) { 1540 return null; 1541 } 1542 1543 1550 public static GenericDO createDO(ObjectId oid) throws java.sql.SQLException , com.lutris.appserver.server.sql.ObjectIdException, com.lutris.dods.builder.generator.query.DataObjectException, com.lutris.appserver.server.sql.DatabaseManagerException { 1551 return null; 1552 } 1553 1554 1558 public String getOriginDatabase() { 1559 return null; 1560 } 1561 1562 1568 public String get_OriginDatabase() { 1569 return null; 1570 } 1571 1572 private boolean executePartially; 1573 1574 public void setExecutePartially(boolean _ep) { 1575 executePartially = _ep; 1576 } 1577 1578 public boolean isExecutePartially() { 1579 return executePartially; 1580 } 1581} 1582 | Popular Tags |