/** * INTERNAL: * Create an instance of the Key object from the key information extracted from the map. * This key object may be a shallow stub of the actual object if the key is an Entity type. */ public Object createStubbedMapComponentFromSerializableKeyInfo(Object keyInfo, AbstractSession session) { ObjectBuilder builder = this.referenceDescriptor.getObjectBuilder(); ObjectBuildingQuery clonedQuery = (ObjectBuildingQuery) getSelectionQuery().clone(); clonedQuery.setSession(session); Object newObject = referenceDescriptor.getInstantiationPolicy().buildNewInstance(); builder.buildPrimaryKeyAttributesIntoObject(newObject, builder.buildRowFromPrimaryKeyValues(keyInfo, session), clonedQuery, session); return newObject; }
/** * INTERNAL: * Create an instance of the Key object from the key information extracted from the map. * This key object may be a shallow stub of the actual object if the key is an Entity type. */ public Object createStubbedMapComponentFromSerializableKeyInfo(Object keyInfo, AbstractSession session) { ObjectBuilder builder = this.referenceDescriptor.getObjectBuilder(); ObjectBuildingQuery clonedQuery = (ObjectBuildingQuery) getSelectionQuery().clone(); clonedQuery.setSession(session); Object newObject = referenceDescriptor.getInstantiationPolicy().buildNewInstance(); builder.buildPrimaryKeyAttributesIntoObject(newObject, builder.buildRowFromPrimaryKeyValues(keyInfo, session), clonedQuery, session); return newObject; }
if (reference == null) { if ((id instanceof List) || (id instanceof CacheId) || (descriptor.getCMPPolicy() == null)) { AbstractRecord row = descriptor.getObjectBuilder().buildRowFromPrimaryKeyValues(primaryKey, this); reference = descriptor.getObjectBuilder().buildNewInstance(); descriptor.getObjectBuilder().buildPrimaryKeyAttributesIntoObject(reference, row, new ReadObjectQuery(), this);
if (reference == null) { if ((id instanceof List) || (id instanceof CacheId) || (descriptor.getCMPPolicy() == null)) { AbstractRecord row = descriptor.getObjectBuilder().buildRowFromPrimaryKeyValues(primaryKey, this); reference = descriptor.getObjectBuilder().buildNewInstance(); descriptor.getObjectBuilder().buildPrimaryKeyAttributesIntoObject(reference, row, new ReadObjectQuery(), this);
if (reference == null) { if (primaryKey instanceof List) { AbstractRecord row = descriptor.getObjectBuilder().buildRowFromPrimaryKeyValues(primaryKeyValues, this); reference = descriptor.getObjectBuilder().buildNewInstance(); descriptor.getObjectBuilder().buildPrimaryKeyAttributesIntoObject(reference, row, new ReadObjectQuery(), this);
/** * INTERNAL: * Prepare the receiver for execution in a session. */ public void prepareForExecution() throws QueryException { super.prepareForExecution(); // For bug 2989998 the translation row now sometimes set earlier in prepare. if (shouldPrepare()) { if (getSelectionKey() != null) { // Row must come from the key. setTranslationRow(this.descriptor.getObjectBuilder().buildRowFromPrimaryKeyValues(getSelectionKey(), getSession())); } else if (getSelectionObject() != null) { // The expression is set in the prepare as params. setTranslationRow(this.descriptor.getObjectBuilder().buildRowForTranslation(getSelectionObject(), getSession())); } } }
/** * INTERNAL: * Prepare the receiver for execution in a session. */ public void prepareForExecution() throws QueryException { super.prepareForExecution(); // For bug 2989998 the translation row now sometimes set earlier in prepare. if (shouldPrepare()) { if (this.selectionId != null) { // Row must come from the key. this.translationRow = this.descriptor.getObjectBuilder().buildRowFromPrimaryKeyValues(this.selectionId, getSession()); } else if (this.selectionObject != null) { // The expression is set in the prepare as params. this.translationRow = this.descriptor.getObjectBuilder().buildRowForTranslation(this.selectionObject, getSession()); } } // If we have tenant discriminator fields we need to add them to the // database row when doing a primary key query. // Modifying the translation row here will modify it on the original // query which is not good (will append the tenant field to the sql call // for subsequent queries) The translation row must be cloned to isolate // this. if (getDescriptor().hasMultitenantPolicy()) { this.translationRow = this.translationRow.clone(); getDescriptor().getMultitenantPolicy().addFieldsToRow(this.translationRow, getSession()); } }
/** * INTERNAL: * Prepare the receiver for execution in a session. */ public void prepareForExecution() throws QueryException { super.prepareForExecution(); // For bug 2989998 the translation row now sometimes set earlier in prepare. if (shouldPrepare()) { if (this.selectionId != null) { // Row must come from the key. this.translationRow = this.descriptor.getObjectBuilder().buildRowFromPrimaryKeyValues(this.selectionId, getSession()); } else if (this.selectionObject != null) { // The expression is set in the prepare as params. this.translationRow = this.descriptor.getObjectBuilder().buildRowForTranslation(this.selectionObject, getSession()); } } // If we have tenant discriminator fields we need to add them to the // database row when doing a primary key query. // Modifying the translation row here will modify it on the original // query which is not good (will append the tenant field to the sql call // for subsequent queries) The translation row must be cloned to isolate // this. if (getDescriptor().hasMultitenantPolicy()) { this.translationRow = this.translationRow.clone(); getDescriptor().getMultitenantPolicy().addFieldsToRow(this.translationRow, getSession()); } }
@Override public void postMerge(DescriptorEvent event) { if ((event.getChangeSet() != null) && event.getChangeSet().hasChanges()) { Object id = event.getChangeSet().getId(); CacheKey cacheKey = event.getChangeSet().getActiveCacheKey(); if (cacheKey == null) { cacheKey = event.getSession().getParent().getIdentityMapAccessorInstance().getIdentityMapManager().getCacheKeyForObject(id, descriptor.getJavaClass(), descriptor, false); } cacheKey.setTransactionId(event.getSession().getProperty(ORA_TRANSACTION_ID)); if (event.getChangeSet().isNew()) { AbstractRecord row = descriptor.getObjectBuilder().buildRowFromPrimaryKeyValues(id, event.getSession()); Object rowid = event.getSession().executeQuery(rowIdQuery, row); CacheId indexValue = new CacheId(new Object[]{rowid}); event.getSession().getParent().getIdentityMapAccessorInstance().getIdentityMapManager().putCacheKeyByIndex(index, indexValue, cacheKey, descriptor); } } } @Override
@Override public void postMerge(DescriptorEvent event) { if ((event.getChangeSet() != null) && event.getChangeSet().hasChanges()) { Object id = event.getChangeSet().getId(); CacheKey cacheKey = event.getChangeSet().getActiveCacheKey(); if (cacheKey == null) { cacheKey = event.getSession().getParent().getIdentityMapAccessorInstance().getIdentityMapManager().getCacheKeyForObject(id, descriptor.getJavaClass(), descriptor, false); } cacheKey.setTransactionId(event.getSession().getProperty(ORA_TRANSACTION_ID)); if (event.getChangeSet().isNew()) { AbstractRecord row = descriptor.getObjectBuilder().buildRowFromPrimaryKeyValues(id, event.getSession()); Object rowid = event.getSession().executeQuery(rowIdQuery, row); CacheId indexValue = new CacheId(new Object[]{rowid}); event.getSession().getParent().getIdentityMapAccessorInstance().getIdentityMapManager().putCacheKeyByIndex(index, indexValue, cacheKey, descriptor); } } } @Override
if (this.selectionId != null) { setTranslationRow(this.descriptor.getObjectBuilder().buildRowFromPrimaryKeyValues(this.selectionId, this.session)); } else {//(getSelectionObject() != null) setTranslationRow(this.descriptor.getObjectBuilder().buildRowForTranslation(this.selectionObject, this.session));
if (this.selectionId != null) { setTranslationRow(this.descriptor.getObjectBuilder().buildRowFromPrimaryKeyValues(this.selectionId, this.session)); } else {//(getSelectionObject() != null) setTranslationRow(this.descriptor.getObjectBuilder().buildRowForTranslation(this.selectionObject, this.session));
if (getSelectionKey() != null) { setTranslationRow(getDescriptor().getObjectBuilder().buildRowFromPrimaryKeyValues(getSelectionKey(), getSession())); } else {//(getSelectionObject() != null) setTranslationRow(getDescriptor().getObjectBuilder().buildRowForTranslation(getSelectionObject(), getSession()));