Changeset 6717
- Timestamp:
- Feb 4, 2015, 1:30:37 PM (9 years ago)
- Location:
- branches/3.4-stable/src/core/net/sf/basedb/core
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/3.4-stable/src/core/net/sf/basedb/core/AnnotationSet.java
r6716 r6717 204 204 } 205 205 206 private static final int MAX_PARAMETERS_IN_QUERY = 10000;207 206 208 207 /** … … 262 261 // an arbitrary large number of parameters 263 262 int startIndex = 0; 264 int endIndex = Math.min(MAX_PARAMETERS_IN_QUERY, allIds.size()); 263 int maxParameters = HibernateUtil.getDbEngine().getMaxParametersInQuery(); 264 int endIndex = Math.min(maxParameters, allIds.size()); 265 265 while (startIndex < allIds.size()) 266 266 { … … 284 284 285 285 startIndex = endIndex; 286 endIndex = Math.min(startIndex + MAX_PARAMETERS_IN_QUERY, allIds.size());286 endIndex = Math.min(startIndex + maxParameters, allIds.size()); 287 287 } 288 288 … … 326 326 327 327 startIndex = 0; 328 endIndex = Math.min( MAX_PARAMETERS_IN_QUERY, ids.size());328 endIndex = Math.min(maxParameters, ids.size()); 329 329 330 330 while (startIndex < ids.size()) … … 345 345 numDeleted += sublist.size(); 346 346 startIndex = endIndex; 347 endIndex = Math.min(startIndex + MAX_PARAMETERS_IN_QUERY, ids.size());347 endIndex = Math.min(startIndex + maxParameters, ids.size()); 348 348 } 349 349 } -
branches/3.4-stable/src/core/net/sf/basedb/core/AnyToAny.java
r6675 r6717 23 23 package net.sf.basedb.core; 24 24 25 import java.util.ArrayList; 25 26 import java.util.List; 26 27 … … 378 379 int index = 0; 379 380 int numItemTypes = itemTypes.size(); 381 int maxParameters = HibernateUtil.getDbEngine().getMaxParametersInQuery(); 380 382 org.hibernate.Query deleteQuery = 381 383 HibernateUtil.getPredefinedQuery(session, "DELETE_STRAY_ANYTOANY"); … … 403 405 */ 404 406 query.setInteger("type", itemType); 405 List<Integer> stray = HibernateUtil.loadList(Integer.class, query, null); 406 if (stray.size() > 0) 407 408 List<Integer> stray = new ArrayList<Integer>(HibernateUtil.loadList(Integer.class, query, null)); 409 int startIndex = 0; 410 int endIndex = Math.min(maxParameters, stray.size()); 411 while (startIndex < stray.size()) 407 412 { 408 deleteQuery.setParameterList("ids", stray , TypeWrapper.INTEGER.getHibernateType());413 deleteQuery.setParameterList("ids", stray.subList(startIndex, endIndex), TypeWrapper.INTEGER.getHibernateType()); 409 414 numDeleted += HibernateUtil.executeUpdate(deleteQuery); 415 startIndex = endIndex; 416 endIndex = Math.min(startIndex + maxParameters, stray.size()); 410 417 } 411 418 index++; -
branches/3.4-stable/src/core/net/sf/basedb/core/ChangeHistory.java
r6714 r6717 158 158 return query; 159 159 } 160 161 private static final int MAX_PARAMETERS_IN_QUERY = 10000; 162 160 163 161 /** 164 162 Delete all change history entries that are linking to non-existing items. This method … … 195 193 int index = 0; 196 194 int numItemTypes = itemTypes.size(); 195 int maxParameters = HibernateUtil.getDbEngine().getMaxParametersInQuery(); 197 196 org.hibernate.Query deleteQuery = 198 197 HibernateUtil.getPredefinedQuery(session, "DELETE_STRAY_CHANGEHISTORY"); … … 222 221 List<Integer> stray = new ArrayList<Integer>(HibernateUtil.loadList(Integer.class, query, null)); 223 222 int startIndex = 0; 224 int endIndex = Math.min( MAX_PARAMETERS_IN_QUERY, stray.size());223 int endIndex = Math.min(maxParameters, stray.size()); 225 224 while (startIndex < stray.size()) 226 225 { … … 228 227 numDeleted += HibernateUtil.executeUpdate(deleteQuery); 229 228 startIndex = endIndex; 230 endIndex = Math.min(startIndex + MAX_PARAMETERS_IN_QUERY, stray.size());229 endIndex = Math.min(startIndex + maxParameters, stray.size()); 231 230 } 232 231 index++; -
branches/3.4-stable/src/core/net/sf/basedb/core/dbengine/AbstractDbEngine.java
r6630 r6717 146 146 } 147 147 148 /** 149 Returns 10000. 150 */ 151 @Override 152 public int getMaxParametersInQuery() 153 { 154 return 10000; 155 } 156 148 157 /** 149 158 Return <code>LN(<value>)</code>. -
branches/3.4-stable/src/core/net/sf/basedb/core/dbengine/DbEngine.java
r6630 r6717 351 351 352 352 /** 353 Get the maximum number of parameters that can be used in a prepared 354 statement for a query. 355 @return 356 @since 3.4.1 357 */ 358 public int getMaxParametersInQuery(); 359 360 /** 353 361 Get the function call that takes the natural logarithm 354 362 of a value. For example: <code>LN(value)</code>
Note: See TracChangeset
for help on using the changeset viewer.