import org.eclipse.persistence.config.DescriptorCustomizer; import org.eclipse.persistence.descriptors.ClassDescriptor; public class ShapeCustomizer implements DescriptorCustomizer { @Override public void customize(ClassDescriptor descriptor) throws Exception { descriptor.getInheritancePolicy().setClassIndicatorFieldName("@type"); } }
private Type getType(QName entity, boolean isAttribute, boolean isIndividual) { final XPathNodeWrapper currentNodeWrapper = getCurrentNodeWrapper(); final ClassDescriptor classDescriptor = currentNodeWrapper == null ? null : currentNodeWrapper.getClassDescriptor(); if (classDescriptor != null) { if (currentNodeWrapper.name.equals(entity)) { final Type containerType = getContainerType(isIndividual); return containerType != null ? containerType : classDescriptor.getJavaClass(); } else { final EntityType entityType = currentNodeWrapper.getEntitiesTypesMap(isAttribute).get(entity.getLocalPart()); return entityType == null ? null : entityType.type; } } return null; }
import org.eclipse.persistence.config.DescriptorCustomizer; import org.eclipse.persistence.descriptors.ClassDescriptor; import org.eclipse.persistence.mappings.DatabaseMapping; import org.eclipse.persistence.oxm.mappings.XMLDirectMapping; import org.eclipse.persistence.oxm.mappings.nullpolicy.XMLNullRepresentationType; public class AddressCustomizer implements DescriptorCustomizer { @Override public void customize(ClassDescriptor descriptor) throws Exception { for(DatabaseMapping mapping : descriptor.getMappings()) { if(mapping.isAbstractDirectMapping()) { XMLDirectMapping xmlDirectMapping = (XMLDirectMapping) mapping; xmlDirectMapping.getNullPolicy().setMarshalNullRepresentation(XMLNullRepresentationType.EMPTY_NODE); xmlDirectMapping.getNullPolicy().setNullRepresentedByEmptyNode(true); } } } }
/** * PUBLIC: * Return true if this descriptor should using an additional join expresison. */ public boolean shouldUseAdditionalJoinExpression() { // Return true, if the query manager has an additional join expression // and this descriptor is not part of an inheritance hierarchy using a // view (CR#3701077) return ((getQueryManager().getAdditionalJoinExpression() != null) && ! (hasInheritance() && getInheritancePolicy().hasView())); }
final TreeObjectBuilder objectBuilder = (TreeObjectBuilder) descriptor.getObjectBuilder();
/** * INTERNAL: * Return if the query has an non-default fetch group defined for itself. */ protected boolean hasNonDefaultFetchGroup() { return this.descriptor.hasFetchGroupManager() && ((this.fetchGroup != null) || (this.fetchGroupName != null) || (!this.shouldUseDefaultFetchGroup && (this.descriptor.getFetchGroupManager().getDefaultFetchGroup() != null))); } }
/** * PUBLIC: * Set the locking policy an all fields locking policy. * A field locking policy is base on locking on all fields by comparing with their previous values to detect field-level collisions. * Note: the unit of work must be used for all updates when using field locking. * @see AllFieldsLockingPolicy */ public void useAllFieldsLocking() { setOptimisticLockingPolicy(new AllFieldsLockingPolicy()); }
/** * INTERNAL: * Return the class of identity map to be used by this descriptor. * The default is the "SoftCacheWeakIdentityMap". */ public Class getIdentityMapClass() { return getCachePolicy().getIdentityMapClass(); }
/** * INTERNAL: * Return the class of identity map to be used by this descriptor. * The default is the "SoftCacheWeakIdentityMap". */ public Class getRemoteIdentityMapClass() { return getCachePolicy().getRemoteIdentityMapClass(); }
/** * PUBLIC: * Returns true if the descriptor represents an isolated class */ public boolean isProtectedIsolation() { return getCachePolicy().isProtectedIsolation(); }
/** * @param fullyMergeEntity the fullyMergeEntity to set */ public void setFullyMergeEntity(boolean fullyMergeEntity) { getCachePolicy().setFullyMergeEntity(fullyMergeEntity); }
/** * PUBLIC: * Set the class of identity map to be used by this descriptor. * The default is the "FullIdentityMap". */ public void setIdentityMapClass(Class theIdentityMapClass) { getCachePolicy().setIdentityMapClass(theIdentityMapClass); }
/** * PUBLIC: * Set if the remote session cache hits on primary key read object queries is allowed or not. * * @see #disableCacheHitsOnRemote() */ public void setShouldDisableCacheHitsOnRemote(boolean shouldDisableCacheHitsOnRemote) { getCachePolicy().setShouldDisableCacheHitsOnRemote(shouldDisableCacheHitsOnRemote); }
/** * PUBLIC: * This method returns <CODE>true</CODE> if the <CODE>ClassDescriptor</CODE> is configured to always remotely * refresh the cache if data is received from the database by any query in a {@link org.eclipse.persistence.sessions.remote.RemoteSession}. * Otherwise, it returns <CODE>false</CODE>. * * @see #setShouldAlwaysRefreshCacheOnRemote */ public boolean shouldAlwaysRefreshCacheOnRemote() { return getCachePolicy().shouldAlwaysRefreshCacheOnRemote(); }
/** * PUBLIC: * Set the class of identity map to be the soft identity map. * This map uses soft references to only cache all object in-memory, until memory is low. * Note that "low" is interpreted differently by different JVM's. * The default is the "SoftCacheWeakIdentityMap". */ public void useSoftIdentityMap() { getCachePolicy().useSoftIdentityMap(); }
/** * PUBLIC: * Set the class of identity map to be the hard cache weak identity map. * This map uses weak references to only cache object in-memory. * It also includes a secondary fixed sized soft cache to improve caching performance. * This is provided because some Java VM's do not implement soft references correctly. * The default is the "SoftCacheWeakIdentityMap". */ public void useRemoteHardCacheWeakIdentityMap() { getCachePolicy().setRemoteIdentityMapClass(ClassConstants.HardCacheWeakIdentityMap_Class); }
/** * PUBLIC * @return true if this descriptor is configured with a table per tenant policy. */ public boolean hasTablePerMultitenantPolicy() { return hasMultitenantPolicy() && getMultitenantPolicy().isTablePerMultitenantPolicy(); }
/** * INTERNAL: * Select one object of any concrete subclass. */ @Override protected Object selectOneObject(ReadObjectQuery query) throws DescriptorException { if (this.descriptor.isAbstract()) { return null; } return super.selectOneObject(query); } }
import org.eclipse.persistence.descriptors.ClassDescriptor; import org.eclipse.persistence.mappings.DatabaseMapping; import org.eclipse.persistence.oxm.mappings.XMLDirectMapping; import org.eclipse.persistence.oxm.mappings.nullpolicy.XMLNullRepresentationType; import org.eclipse.persistence.sessions.*; public class NullPolicySessionEventListener extends SessionEventAdapter { @Override public void preLogin(SessionEvent event) { Project project = event.getSession().getProject(); for(ClassDescriptor descriptor : project.getOrderedDescriptors()) { for(DatabaseMapping mapping : descriptor.getMappings()) { if(mapping.isAbstractDirectMapping()) { XMLDirectMapping xmlDirectMapping = (XMLDirectMapping) mapping; xmlDirectMapping.getNullPolicy().setMarshalNullRepresentation(XMLNullRepresentationType.EMPTY_NODE); xmlDirectMapping.getNullPolicy().setNullRepresentedByEmptyNode(true); } } } } }
TreeObjectBuilder objectBuilder = (TreeObjectBuilder) descriptor.getObjectBuilder(); final XPathNodeWrapper nodeWrapper = actualNodeWrapper;