/** * INTERNAL: * Add child descriptor to the parent descriptor. */ public void addChildDescriptor(ClassDescriptor childDescriptor) { getChildDescriptors().add(childDescriptor); }
/** * INTERNAL: * Add child descriptor to the parent descriptor. */ public void addChildDescriptor(ClassDescriptor childDescriptor) { getChildDescriptors().addElement(childDescriptor); }
/** * INTERNAL: * Add child descriptor to the parent descriptor. */ public void addChildDescriptor(ClassDescriptor childDescriptor) { getChildDescriptors().add(childDescriptor); }
/** * INTERNAL: * Select one object of any concrete subclass. */ public Object selectOneObjectUsingMultipleTableSubclassRead(ReadObjectQuery query) throws DatabaseException, QueryException { Object object = null; for (Enumeration childDescriptors = getChildDescriptors().elements(); childDescriptors.hasMoreElements() && (object == null);) { ClassDescriptor descriptor = (ClassDescriptor)childDescriptors.nextElement(); object = descriptor.getInterfacePolicy().selectOneObject(query); } return object; }
/** * INTERNAL: * Select all objects for an interface descriptor. * This is accomplished by selecting for all of the concrete classes and then merging the objects. * * @return Vector containing all objects. * @exception DatabaseException - an error has occurred on the database. */ public Object selectAllObjectsUsingMultipleTableSubclassRead(ReadAllQuery query) throws DatabaseException { org.eclipse.persistence.internal.queries.ContainerPolicy containerPolicy = query.getContainerPolicy(); Object objects = containerPolicy.containerInstance(1); for (Enumeration childDescriptors = getChildDescriptors().elements(); childDescriptors.hasMoreElements();) { ClassDescriptor descriptor = (ClassDescriptor)childDescriptors.nextElement(); objects = containerPolicy.concatenateContainers(objects, descriptor.getInterfacePolicy().selectAllObjects(query)); } return objects; }
/** * INTERNAL: * Return the value to be stored in the object's attribute. * This will be a proxy object. */ public Object valueFromQuery(ReadQuery query, AbstractRecord row, AbstractSession session) { ClassDescriptor descriptor = null; try { // Need an instance of the implementing class //CR#3838 descriptor = session.getDescriptor(query.getReferenceClass()); if (descriptor.isDescriptorForInterface()) { descriptor = (ClassDescriptor)descriptor.getInterfacePolicy().getChildDescriptors().firstElement(); } } catch (Exception e) { return null; } ValueHolderInterface valueHolder = new QueryBasedValueHolder(query, row, session); return ProxyIndirectionHandler.newProxyInstance(descriptor.getJavaClass(), targetInterfaces, valueHolder); }
/** * INTERNAL: * Return the value to be stored in the object's attribute. * This will be a proxy object. */ public Object valueFromQuery(ReadQuery query, AbstractRecord row, AbstractSession session) { ClassDescriptor descriptor = null; try { // Need an instance of the implementing class //CR#3838 descriptor = session.getDescriptor(query.getReferenceClass()); if (descriptor.isDescriptorForInterface()) { descriptor = descriptor.getInterfacePolicy().getChildDescriptors().get(0); } } catch (Exception e) { return null; } ValueHolderInterface valueHolder = new QueryBasedValueHolder(query, row, session); return ProxyIndirectionHandler.newProxyInstance(descriptor.getJavaClass(), targetInterfaces, valueHolder); }
/** * INTERNAL: * Return the value to be stored in the object's attribute. * This will be a proxy object. */ public Object valueFromQuery(ReadQuery query, AbstractRecord row, AbstractSession session) { ClassDescriptor descriptor = null; try { // Need an instance of the implementing class //CR#3838 descriptor = session.getDescriptor(query.getReferenceClass()); if (descriptor.isDescriptorForInterface()) { descriptor = descriptor.getInterfacePolicy().getChildDescriptors().get(0); } } catch (Exception e) { return null; } ValueHolderInterface valueHolder = new QueryBasedValueHolder(query, row, session); return ProxyIndirectionHandler.newProxyInstance(descriptor.getJavaClass(), targetInterfaces, valueHolder); }
/** * INTERNAL: * Return the value to be stored in the object's attribute. * This value is determined by the batch query. * * NOTE: Currently not supported anyway. */ public Object valueFromBatchQuery(ReadQuery batchQuery, AbstractRecord row, ObjectLevelReadQuery originalQuery) { Object object; try { // Need an instance of the implementing class ClassDescriptor d = originalQuery.getDescriptor(); if (d.isDescriptorForInterface()) { d = (ClassDescriptor)originalQuery.getDescriptor().getInterfacePolicy().getChildDescriptors().firstElement(); } if (PrivilegedAccessHelper.shouldUsePrivilegedAccess()){ object = AccessController.doPrivileged(new PrivilegedNewInstanceFromClass(d.getJavaClass())); }else{ object = PrivilegedAccessHelper.newInstanceFromClass(d.getJavaClass()); } } catch (Exception e) { //org.eclipse.persistence.internal.helper.Helper.toDo("*** Should probably throw some sort of TopLink exception here. ***"); e.printStackTrace(); return null; } ValueHolderInterface valueHolder = new BatchValueHolder(batchQuery, row, this.getForeignReferenceMapping(), originalQuery); return ProxyIndirectionHandler.newProxyInstance(object.getClass(), targetInterfaces, valueHolder); }
/** * INTERNAL: * Return the value to be stored in the object's attribute. * This value is determined by the batch query. * * NOTE: Currently not supported anyway. */ public Object valueFromBatchQuery(ReadQuery batchQuery, AbstractRecord row, ObjectLevelReadQuery originalQuery, CacheKey parentCacheKey) { Object object; try { // Need an instance of the implementing class ClassDescriptor d = originalQuery.getDescriptor(); if (d.isDescriptorForInterface()) { d = originalQuery.getDescriptor().getInterfacePolicy().getChildDescriptors().get(0); } if (PrivilegedAccessHelper.shouldUsePrivilegedAccess()){ object = AccessController.doPrivileged(new PrivilegedNewInstanceFromClass(d.getJavaClass())); }else{ object = PrivilegedAccessHelper.newInstanceFromClass(d.getJavaClass()); } } catch (Exception e) { //org.eclipse.persistence.internal.helper.Helper.toDo("*** Should probably throw some sort of TopLink exception here. ***"); e.printStackTrace(); return null; } ValueHolderInterface valueHolder = new BatchValueHolder(batchQuery, row, this.getForeignReferenceMapping(), originalQuery, parentCacheKey); return ProxyIndirectionHandler.newProxyInstance(object.getClass(), targetInterfaces, valueHolder); }
/** * INTERNAL: * Return the value to be stored in the object's attribute. * This value is determined by the batch query. * * NOTE: Currently not supported anyway. */ public Object valueFromBatchQuery(ReadQuery batchQuery, AbstractRecord row, ObjectLevelReadQuery originalQuery, CacheKey parentCacheKey) { Object object; try { // Need an instance of the implementing class ClassDescriptor d = originalQuery.getDescriptor(); if (d.isDescriptorForInterface()) { d = originalQuery.getDescriptor().getInterfacePolicy().getChildDescriptors().get(0); } if (PrivilegedAccessHelper.shouldUsePrivilegedAccess()){ object = AccessController.doPrivileged(new PrivilegedNewInstanceFromClass(d.getJavaClass())); }else{ object = PrivilegedAccessHelper.newInstanceFromClass(d.getJavaClass()); } } catch (Exception e) { //org.eclipse.persistence.internal.helper.Helper.toDo("*** Should probably throw some sort of TopLink exception here. ***"); e.printStackTrace(); return null; } ValueHolderInterface valueHolder = new BatchValueHolder(batchQuery, row, this.getForeignReferenceMapping(), originalQuery, parentCacheKey); return ProxyIndirectionHandler.newProxyInstance(object.getClass(), targetInterfaces, valueHolder); }
/** * INTERNAL: * Return the classifiction for the field contained in the mapping. * This is used to convert the row value to a consistent java value. */ public Class getFieldClassification(DatabaseField fieldToClassify) { if ((getTypeField() != null) && (fieldToClassify.equals(getTypeField()))) { return getTypeField().getType(); } String queryKey = (String)getSourceToTargetQueryKeyNames().get(fieldToClassify); if (queryKey == null) { return null; } // Search any of the implementor descriptors for a mapping for the query-key. Iterator iterator = getReferenceDescriptor().getInterfacePolicy().getChildDescriptors().iterator(); if (iterator.hasNext()) { ClassDescriptor firstChild = (ClassDescriptor)iterator.next(); DatabaseMapping mapping = firstChild.getObjectBuilder().getMappingForAttributeName(queryKey); if ((mapping != null) && (mapping.isDirectToFieldMapping())) { return ((AbstractDirectMapping)mapping).getAttributeClassification(); } QueryKey targetQueryKey = firstChild.getQueryKeyNamed(queryKey); if ((targetQueryKey != null) && (targetQueryKey.isDirectQueryKey())) { return firstChild.getObjectBuilder().getFieldClassification(((DirectQueryKey)targetQueryKey).getField()); } } return null; }
/** * INTERNAL: * Return the classification for the field contained in the mapping. * This is used to convert the row value to a consistent java value. */ @Override public Class getFieldClassification(DatabaseField fieldToClassify) { if ((getTypeField() != null) && (fieldToClassify.equals(getTypeField()))) { return getTypeField().getType(); } String queryKey = (String)getSourceToTargetQueryKeyNames().get(fieldToClassify); if (queryKey == null) { return null; } // Search any of the implementor descriptors for a mapping for the query-key. Iterator iterator = getReferenceDescriptor().getInterfacePolicy().getChildDescriptors().iterator(); if (iterator.hasNext()) { ClassDescriptor firstChild = (ClassDescriptor)iterator.next(); DatabaseMapping mapping = firstChild.getObjectBuilder().getMappingForAttributeName(queryKey); if ((mapping != null) && (mapping.isDirectToFieldMapping())) { return ((AbstractDirectMapping)mapping).getAttributeClassification(); } QueryKey targetQueryKey = firstChild.getQueryKeyNamed(queryKey); if ((targetQueryKey != null) && (targetQueryKey.isDirectQueryKey())) { return firstChild.getObjectBuilder().getFieldClassification(((DirectQueryKey)targetQueryKey).getField()); } } return null; }
/** * INTERNAL: * Return the classification for the field contained in the mapping. * This is used to convert the row value to a consistent java value. */ @Override public Class getFieldClassification(DatabaseField fieldToClassify) { if ((getTypeField() != null) && (fieldToClassify.equals(getTypeField()))) { return getTypeField().getType(); } String queryKey = (String)getSourceToTargetQueryKeyNames().get(fieldToClassify); if (queryKey == null) { return null; } // Search any of the implementor descriptors for a mapping for the query-key. Iterator iterator = getReferenceDescriptor().getInterfacePolicy().getChildDescriptors().iterator(); if (iterator.hasNext()) { ClassDescriptor firstChild = (ClassDescriptor)iterator.next(); DatabaseMapping mapping = firstChild.getObjectBuilder().getMappingForAttributeName(queryKey); if ((mapping != null) && (mapping.isDirectToFieldMapping())) { return ((AbstractDirectMapping)mapping).getAttributeClassification(); } QueryKey targetQueryKey = firstChild.getQueryKeyNamed(queryKey); if ((targetQueryKey != null) && (targetQueryKey.isDirectQueryKey())) { return firstChild.getObjectBuilder().getFieldClassification(((DirectQueryKey)targetQueryKey).getField()); } } return null; }