/** * Sets the query */ protected void setSelectionQuery(ReadQuery aQuery) { selectionQuery = aQuery; // Make sure the reference class of the selectionQuery is set. if ((selectionQuery != null) && selectionQuery.isObjectLevelReadQuery() && (selectionQuery.getReferenceClassName() == null)) { ((ObjectLevelReadQuery)selectionQuery).setReferenceClass(getReferenceClass()); } }
/** * INTERNAL: * Return the referenceDescriptor. This is a descriptor which is associated with * the reference class. */ public ClassDescriptor getReferenceDescriptor() { if (referenceDescriptor == null) { if (getTempSession() == null) { return null; } else { referenceDescriptor = getTempSession().getDescriptor(getReferenceClass()); } } return referenceDescriptor; }
/** * Initialize and set the descriptor for the referenced class in this mapping. */ protected void initializeReferenceDescriptor(AbstractSession session) throws DescriptorException { if (getReferenceClass() == null) { throw DescriptorException.referenceClassNotSpecified(this); } ClassDescriptor refDescriptor = session.getDescriptor(getReferenceClass()); if (refDescriptor == null) { throw DescriptorException.descriptorIsMissing(getReferenceClass().getName(), this); } if (refDescriptor.isAggregateDescriptor() && (!isAggregateCollectionMapping())) { throw DescriptorException.referenceDescriptorCannotBeAggregate(this); } // can not be isolated if it is null. Seems that only aggregates do not set // the owning descriptor on the mapping. if ((!((this.getDescriptor() != null) && this.getDescriptor().isIsolated())) && refDescriptor.isIsolated()) { throw DescriptorException.isolateDescriptorReferencedBySharedDescriptor(refDescriptor.getJavaClassName(), this.getDescriptor().getJavaClassName(), this); } setReferenceDescriptor(refDescriptor); }
&& WeavedAttributeValueHolderInterface.class.isAssignableFrom(lType) && mapping instanceof ForeignReferenceMapping) { this.type = ForeignReferenceMapping.class.cast(mapping).getReferenceClass(); } else { this.type = lType; ForeignReferenceMapping fMapping = ForeignReferenceMapping.class .cast(mapping); elementType = fMapping.getReferenceClass();
/** * This method will lazily initialize the set method * Lazy initialization occurs to that we are not required to have a handle on * the actual class that we are using until runtime. This helps to satisfy the * weaving requirement that demands that we avoid loading domain classes into * the main class loader until after weaving occurs. * @return */ protected Method getSetMethod(){ if (setMethod == null){ ForeignReferenceMapping sourceMapping = (ForeignReferenceMapping)mapping; // The parameter type for the set method must always be the return type of the get method. Class[] parameterTypes = new Class[1]; parameterTypes[0] = sourceMapping.getReferenceClass(); try { setMethod = Helper.getDeclaredMethod(sourceMapping.getDescriptor().getJavaClass(), setMethodName, parameterTypes); } catch (NoSuchMethodException e){ throw DescriptorException.errorAccessingSetMethodOfEntity(sourceMapping.getDescriptor().getJavaClass(), setMethodName ,sourceMapping.getDescriptor(), e); } } return setMethod; }
ClassDescriptor refDescriptor = ((ForeignReferenceMapping)mapping).getReferenceDescriptor(); if (refDescriptor == null) { refDescriptor = session.getDescriptor(((ForeignReferenceMapping)mapping).getReferenceClass()); ClassDescriptor refDescriptor = ((ForeignReferenceMapping)mapping).getReferenceDescriptor(); if (refDescriptor == null) { refDescriptor = session.getDescriptor(((ForeignReferenceMapping)mapping).getReferenceClass());