/** * INTERNAL: * The mapping clones itself to create deep copy. */ @Override public Object clone() { MappedKeyMapContainerPolicy clone = (MappedKeyMapContainerPolicy) super.clone(); clone.keyMapping = (MapKeyMapping) this.keyMapping.clone(); if (this.keyQuery != null) { clone.keyQuery = (DatabaseQuery) this.keyQuery.clone(); } return clone; }
/** * INTERNAL: * A call back to do session specific preparation of a query. * <p> * The call back occurs immediately before we clone the query for execution, * meaning that if this method needs to clone the query then the caller will * determine that it doesn't need to clone the query twice. */ public DatabaseQuery prepareDatabaseQuery(DatabaseQuery query) { DatabaseQuery clonedQuery = (DatabaseQuery)query.clone(); clonedQuery.setIsExecutionClone(true); clonedQuery.setIsPrepared(false); return clonedQuery; }
/** * INTERNAL: * The mapping clones itself to create deep copy. */ @Override public Object clone() { MappedKeyMapContainerPolicy clone = (MappedKeyMapContainerPolicy) super.clone(); clone.keyMapping = (MapKeyMapping) this.keyMapping.clone(); if (this.keyQuery != null) { clone.keyQuery = (DatabaseQuery) this.keyQuery.clone(); } return clone; }
/** * INTERNAL: * A call back to do session specific preparation of a query. * <p> * The call back occurs immediately before we clone the query for execution, * meaning that if this method needs to clone the query then the caller will * determine that it doesn't need to clone the query twice. */ public DatabaseQuery prepareDatabaseQuery(DatabaseQuery query) { DatabaseQuery clonedQuery = (DatabaseQuery)query.clone(); clonedQuery.setIsExecutionClone(true); clonedQuery.setIsPrepared(false); return clonedQuery; }
/** * INTERNAL: * A call back to do session specific preparation of a query. * <p> * The call back occurs immediately before we clone the query for execution, * meaning that if this method needs to clone the query then the caller will * determine that it doesn't need to clone the query twice. */ public DatabaseQuery prepareDatabaseQuery(DatabaseQuery query) { DatabaseQuery clonedQuery = (DatabaseQuery)query.clone(); clonedQuery.setIsExecutionClone(true); clonedQuery.setIsPrepared(false); return clonedQuery; }
/** * If the query was from the jpql parse cache it must be cloned before being * modified. */ protected void cloneSharedQuery() { DatabaseQuery query = getDatabaseQueryInternal(); if (this.isShared) { // Clone to allow setting of hints or other properties without // corrupting original query. query = (DatabaseQuery) databaseQuery.clone(); setDatabaseQuery(query); this.isShared = false; } }
protected Object remoteExecute() { Transporter transporter = ((RemoteSession)getSession()).getRemoteConnection().remoteExecute((DatabaseQuery)this.clone()); return extractRemoteResult(transporter); }
protected Object remoteExecute() { this.session.startOperationProfile(SessionProfiler.Remote, this, SessionProfiler.ALL); Transporter transporter = ((DistributedSession) this.session).getRemoteConnection().remoteExecute((DatabaseQuery) this.clone()); this.session.endOperationProfile(SessionProfiler.Remote, this, SessionProfiler.ALL); return extractRemoteResult(transporter); }
protected Object remoteExecute() { this.session.startOperationProfile(SessionProfiler.Remote, this, SessionProfiler.ALL); Transporter transporter = ((DistributedSession) this.session).getRemoteConnection().remoteExecute((DatabaseQuery) this.clone()); this.session.endOperationProfile(SessionProfiler.Remote, this, SessionProfiler.ALL); return extractRemoteResult(transporter); }
/** * INTERNAL: * Use a EclipseLink redirector to redirect this query to a method. * Added for bug 3241138 * */ public Object redirectQuery(QueryRedirector redirector, DatabaseQuery queryToRedirect, AbstractSession session, AbstractRecord translationRow) { if (redirector == null ) { return null; } DatabaseQuery queryToExecute = (DatabaseQuery)queryToRedirect.clone(); queryToExecute.setRedirector(null); // since we deal with a clone when using a redirector, the descriptor will // get set on the clone, but not on the original object. So before returning // the results, set the descriptor from the clone onto this object (original // query) - GJPP, BUG# 2692956 Object toReturn = redirector.invokeQuery(queryToExecute, translationRow, session); setDescriptor(queryToExecute.getDescriptor()); return toReturn; }
/** * INTERNAL: Use a EclipseLink redirector to redirect this query to a * method. Added for bug 3241138 * */ public Object redirectQuery(QueryRedirector redirector, DatabaseQuery queryToRedirect, AbstractSession session, AbstractRecord translationRow) { if (redirector == null) { return null; } DatabaseQuery queryToExecute = (DatabaseQuery) queryToRedirect.clone(); queryToExecute.setRedirector(null); // since we deal with a clone when using a redirector, the descriptor // will // get set on the clone, but not on the original object. So before // returning // the results, set the descriptor from the clone onto this object // (original // query) - GJPP, BUG# 2692956 Object toReturn = redirector.invokeQuery(queryToExecute, translationRow, session); setDescriptor(queryToExecute.getDescriptor()); return toReturn; }
/** * INTERNAL: Use a EclipseLink redirector to redirect this query to a * method. Added for bug 3241138 * */ public Object redirectQuery(QueryRedirector redirector, DatabaseQuery queryToRedirect, AbstractSession session, AbstractRecord translationRow) { if (redirector == null) { return null; } DatabaseQuery queryToExecute = (DatabaseQuery) queryToRedirect.clone(); queryToExecute.setRedirector(null); // since we deal with a clone when using a redirector, the descriptor // will // get set on the clone, but not on the original object. So before // returning // the results, set the descriptor from the clone onto this object // (original // query) - GJPP, BUG# 2692956 Object toReturn = redirector.invokeQuery(queryToExecute, translationRow, session); setDescriptor(queryToExecute.getDescriptor()); return toReturn; }
/** * PUBLIC: * Return the query from the set of pre-defined queries with the given name and argument types. * This allows for common queries to be pre-defined, reused and executed by name. * This method should be used if the Session has multiple queries with the same name but * different arguments. * If only one query exists, it will be returned regardless of the arguments. * If multiple queries exist, the first query that has corresponding argument types will be returned * * @see #getQuery(String) */ public DatabaseQuery getQuery(String name, Vector arguments) { DatabaseQuery query = getLocalQuery(name, arguments); // CR#3711: Check if a query with the same name exists for this descriptor. // If not, recursively check descriptors of parent classes. If nothing is // found in parents, return null. if (query == null) { DatabaseQuery parentQuery = getQueryFromParent(name, arguments); if ((parentQuery != null) && parentQuery.isReadQuery()) { parentQuery = (DatabaseQuery)parentQuery.clone(); ((ObjectLevelReadQuery)parentQuery).setReferenceClass(this.descriptor.getJavaClass()); addQuery(name, parentQuery); } return parentQuery; } return query; }
/** * PUBLIC: * Return the query from the set of pre-defined queries with the given name and argument types. * This allows for common queries to be pre-defined, reused and executed by name. * This method should be used if the Session has multiple queries with the same name but * different arguments. * If only one query exists, it will be returned regardless of the arguments. * If multiple queries exist, the first query that has corresponding argument types will be returned * * @see #getQuery(String) */ public DatabaseQuery getQuery(String name, Vector arguments) { DatabaseQuery query = getLocalQuery(name, arguments); // CR#3711: Check if a query with the same name exists for this descriptor. // If not, recursively check descriptors of parent classes. If nothing is // found in parents, return null. if (query == null) { DatabaseQuery parentQuery = getQueryFromParent(name, arguments); if ((parentQuery != null) && parentQuery.isReadQuery()) { parentQuery = (DatabaseQuery)parentQuery.clone(); ((ObjectLevelReadQuery)parentQuery).setReferenceClass(this.descriptor.getJavaClass()); addQuery(name, parentQuery); } return parentQuery; } return query; }
while (queriesForKey.hasNext()) { DatabaseQuery initialQuery = (DatabaseQuery)queriesForKey.next(); DatabaseQuery clonedQuery = (DatabaseQuery)initialQuery.clone(); clonedQuery.setDescriptor(manager.getDescriptor()); manager.addQuery(clonedQuery);
/** * PUBLIC: * Return the query from the set of pre-defined queries with the given name and argument types. * This allows for common queries to be pre-defined, reused and executed by name. * This method should be used if the Session has multiple queries with the same name but * different arguments. * If only one query exists, it will be returned regardless of the arguments. * If multiple queries exist, the first query that has corresponding argument types will be returned * * @see #getQuery(String) */ public DatabaseQuery getQuery(String name, Vector arguments) { DatabaseQuery query = getLocalQuery(name, arguments); // CR#3711: Check if a query with the same name exists for this descriptor. // If not, recursively check descriptors of parent classes. If nothing is // found in parents, return null. if (query == null) { DatabaseQuery parentQuery = getQueryFromParent(name, arguments); if ((parentQuery != null) && parentQuery.isReadQuery()) { parentQuery = (DatabaseQuery)parentQuery.clone(); ((ObjectLevelReadQuery)parentQuery).setReferenceClass(this.descriptor.getJavaClass()); addQuery(name, parentQuery); } return parentQuery; } return query; }
while (queriesForKey.hasNext()) { DatabaseQuery initialQuery = (DatabaseQuery)queriesForKey.next(); DatabaseQuery clonedQuery = (DatabaseQuery)initialQuery.clone(); clonedQuery.setDescriptor(manager.getDescriptor()); manager.addQuery(clonedQuery);
while (queriesForKey.hasNext()) { DatabaseQuery initialQuery = (DatabaseQuery)queriesForKey.next(); DatabaseQuery clonedQuery = (DatabaseQuery)initialQuery.clone(); clonedQuery.setDescriptor(manager.getDescriptor()); manager.addQuery(clonedQuery);
public void addNamedQuery(String name, Query query) { DatabaseQuery unwrapped = (DatabaseQuery) query.unwrap(DatabaseQuery.class).clone(); if (((QueryImpl)query).lockMode != null){ ((ObjectLevelReadQuery)unwrapped).setLockModeType(((QueryImpl)query).lockMode.name(), session); } if (unwrapped.isReadQuery()){ ((ReadQuery)unwrapped).setInternalMax((((QueryImpl)query).getMaxResultsInternal())); if (query.getFirstResult() != QueryImpl.UNDEFINED){ ((ReadQuery)unwrapped).setFirstResult(query.getFirstResult()); } } this.getServerSession().addQuery(name, unwrapped, true); }
public void addNamedQuery(String name, Query query) { QueryImpl queryImpl = query.unwrap(QueryImpl.class); DatabaseQuery unwrapped = (DatabaseQuery) queryImpl.getDatabaseQueryInternal().clone(); if (queryImpl.lockMode != null){ ((ObjectLevelReadQuery)unwrapped).setLockModeType(queryImpl.lockMode.name(), getServerSession()); } if (unwrapped.isReadQuery()){ ((ReadQuery)unwrapped).setInternalMax((queryImpl.getMaxResultsInternal())); ((ReadQuery)unwrapped).setFirstResult((queryImpl.getFirstResult())); } this.getServerSession().addQuery(name, unwrapped, true); }