コード例 #1
0
 /**
  * INTERNAL: Lazy initialization of xmlTypeFactory allows to avoid loading xdb-dependent class
  * XMLTypeFactoryImpl unless xdb is used.
  *
  * @return XMLTypeFactory
  */
 protected XMLTypeFactory getXMLTypeFactory() {
   if (xmlTypeFactory == null) {
     String className = "oracle.toplink.internal.platform.database.oracle.xdb.XMLTypeFactoryImpl";
     try {
       if (PrivilegedAccessHelper.shouldUsePrivilegedAccess()) {
         Class xmlTypeFactoryClass =
             (Class)
                 AccessController.doPrivileged(
                     new PrivilegedClassForName(
                         className, true, this.getClass().getClassLoader()));
         Constructor xmlTypeFactoryConstructor =
             (Constructor)
                 AccessController.doPrivileged(
                     new PrivilegedGetConstructorFor(xmlTypeFactoryClass, new Class[0], true));
         xmlTypeFactory =
             (XMLTypeFactory)
                 AccessController.doPrivileged(
                     new PrivilegedInvokeConstructor(xmlTypeFactoryConstructor, new Object[0]));
       } else {
         Class xmlTypeFactoryClass =
             PrivilegedAccessHelper.getClassForName(
                 className, true, this.getClass().getClassLoader());
         Constructor xmlTypeFactoryConstructor =
             PrivilegedAccessHelper.getConstructorFor(xmlTypeFactoryClass, new Class[0], true);
         xmlTypeFactory =
             (XMLTypeFactory)
                 PrivilegedAccessHelper.invokeConstructor(
                     xmlTypeFactoryConstructor, new Object[0]);
       }
     } catch (Exception e) {
       throw QueryException.reflectiveCallOnTopLinkClassFailed(className, e);
     }
   }
   return xmlTypeFactory;
 }
コード例 #2
0
 /**
  * INTERNAL: Invalid the cache, that is, those objects in the cache that were affected by the
  * query.
  */
 protected void invalidateCache() {
   oracle.toplink.sessions.IdentityMapAccessor identityMapAccessor =
       getSession().getIdentityMapAccessor();
   if (getSelectionCriteria() == null) {
     // Invalidate the whole class since the user did not specify a where clause
     if (getDescriptor().isChildDescriptor()) {
       Vector collectionToInvalidate =
           identityMapAccessor.getAllFromIdentityMap(
               null, getReferenceClass(), getTranslationRow(), null);
       identityMapAccessor.invalidateObjects(collectionToInvalidate);
     } else {
       // if it's either a root class or there is no inheritance just clear the identity map
       identityMapAccessor.invalidateClass(getReferenceClass());
     }
   } else {
     // Invalidate only those objects in the cache that match the selection criteria
     // Bug:4293920, expression parameters were not passed in
     boolean noObjectsModifiedInDb = result != null && result.intValue() == 0;
     try {
       int policy = InMemoryQueryIndirectionPolicy.SHOULD_IGNORE_EXCEPTION_RETURN_CONFORMED;
       if (noObjectsModifiedInDb) {
         policy = InMemoryQueryIndirectionPolicy.SHOULD_IGNORE_EXCEPTION_RETURN_NOT_CONFORMED;
       }
       Vector collectionToInvalidate =
           identityMapAccessor.getAllFromIdentityMap(
               getSelectionCriteria(), getReferenceClass(), getTranslationRow(), policy);
       identityMapAccessor.invalidateObjects(collectionToInvalidate);
     } catch (QueryException ex) {
       if (ex.getErrorCode() == QueryException.CANNOT_CONFORM_EXPRESSION) {
         // If no objects changed in the db - don't invalidate, ignore.
         if (!noObjectsModifiedInDb) {
           // Invalidate the whole class since the expression can't be selected in memory
           identityMapAccessor.invalidateClass(getReferenceClass());
         }
       } else {
         throw ex;
       }
     }
   }
 }
コード例 #3
0
 /**
  * INTERNAL: Execute the query. If there are cached results return those. This must override the
  * super to support result caching.
  *
  * @param aSession - the session in which the receiver will be executed.
  * @return An object or vector, the result of executing the query.
  * @exception DatabaseException - an error has occurred on the database
  */
 public Object execute(AbstractSession session, AbstractRecord row) throws DatabaseException {
   if (shouldCacheQueryResults()) {
     if (getContainerPolicy().overridesRead()) {
       throw QueryException.cannotCacheCursorResultsOnQuery(this);
     }
     if (isPrepared()) { // only prepared queries can have cached results.
       Object results = getQueryResults(session, row, true);
       // Bug6138532 - if results are "cached no results", return null immediately
       if (results == InvalidObject.instance) {
         return null;
       }
       if (results != null) {
         return results;
       }
     }
   }
   return super.execute(session, row);
 }