use of org.eclipse.persistence.internal.jpa.metadata.accessors.classes.EmbeddableAccessor in project eclipselink by eclipse-ee4j.
the class MappingAccessor method processEmbeddableMapKeyClass.
/**
* INTERNAL:
*/
protected AggregateObjectMapping processEmbeddableMapKeyClass(MappedKeyMapAccessor mappedKeyMapAccessor) {
AggregateObjectMapping keyMapping = new AggregateObjectMapping();
MetadataClass mapKeyClass = mappedKeyMapAccessor.getMapKeyClass();
keyMapping.setReferenceClassName(mapKeyClass.getName());
// The embeddable accessor must be processed by now. If it is not then
// we are in trouble since by the time we get here, we are too late in
// the cycle to process embeddable classes and their accessors. See
// MetadataProject processStage3(), processEmbeddableMappingAccessors.
// At this stage all class accessors (embeddable, entity and mapped
// superclass) have to have been processed to gather all their
// relational and embedded mappings.
EmbeddableAccessor mapKeyAccessor = getProject().getEmbeddableAccessor(mapKeyClass);
// Ensure the reference descriptor is marked as an embeddable collection.
mapKeyAccessor.getDescriptor().setIsEmbeddable();
// Process the attribute overrides for this may key embeddable.
processAttributeOverrides(mappedKeyMapAccessor.getMapKeyAttributeOverrides(), keyMapping, mapKeyAccessor.getDescriptor());
// Process the association overrides for this may key embeddable.
processAssociationOverrides(mappedKeyMapAccessor.getMapKeyAssociationOverrides(), keyMapping, mapKeyAccessor.getDescriptor());
// Process a convert key or jpa converter for the map key if specified.
processConverts(getMapKeyConverts(mappedKeyMapAccessor.getMapKeyConverts()), keyMapping, mappedKeyMapAccessor.getMapKeyClass(), true);
keyMapping.setDescriptor(getDescriptor().getClassDescriptor());
return keyMapping;
}
use of org.eclipse.persistence.internal.jpa.metadata.accessors.classes.EmbeddableAccessor in project eclipselink by eclipse-ee4j.
the class MetadataProject method processStage3.
/**
* INTERNAL:
* Stage 3 processing does all the extra processing that couldn't be
* completed in the first two stages of processing. The biggest thing
* being that all entities will have processed an id by now and we can
* process those accessors that rely on them. NOTE: The order of invocation
* here is very important here, see the comments.
*/
public void processStage3(PersistenceUnitProcessor.Mode mode) {
if (mode == PersistenceUnitProcessor.Mode.ALL || mode == PersistenceUnitProcessor.Mode.COMPOSITE_MEMBER_MIDDLE) {
// 1 - Process accessors with IDs derived from relationships. This will
// finish up any stage2 processing that relied on the PK processing
// being complete as well. Note: some relationships mappings may be
// processed in this stage. This is ok since it is to determine and
// validate the primary key.
processAccessorsWithDerivedIDs();
// 2 - Process all the direct collection accessors we found. This list
// does not include direct collections to an embeddable class.
processDirectCollectionAccessors();
// 3 - Process the sequencing metadata now that every entity has a
// validated primary key.
processSequencingAccessors();
// 4 - Process the owning relationship accessors now that every entity
// has a validated primary key and we can process join columns.
processOwningRelationshipAccessors();
// 5 - Process the embeddable mapping accessors. These are the
// embedded, embedded id and element collection accessors that map
// to an embeddable class. We must hold off on their processing till
// now to ensure their owning relationship accessors have been processed
// and we can therefore process any association overrides correctly.
processEmbeddableMappingAccessors();
// composite persistence unit case
if (getCompositeProcessor() != null) {
for (EmbeddableAccessor accessor : getEmbeddableAccessors()) {
if (!accessor.isProcessed()) {
accessor.process();
}
}
}
}
if (mode == PersistenceUnitProcessor.Mode.ALL || mode == PersistenceUnitProcessor.Mode.COMPOSITE_MEMBER_FINAL) {
// 6 - Process the non owning relationship accessors now that every
// owning relationship should be fully processed.
processNonOwningRelationshipAccessors();
// 7 - Process the interface accessors which will iterate through all
// the entities in the PU and check if we should add them to a variable
// one to one mapping that was either defined (incompletely) or
// defaulted.
processInterfaceAccessors();
processPartitioning();
}
}
use of org.eclipse.persistence.internal.jpa.metadata.accessors.classes.EmbeddableAccessor in project eclipselink by eclipse-ee4j.
the class MetadataProject method getEmbeddableAccessor.
/**
* INTERNAL:
* This method will attempt to look up the embeddable accessor for the
* reference class provided. If no accessor is found, null is returned.
*/
public EmbeddableAccessor getEmbeddableAccessor(MetadataClass cls, boolean checkIsIdClass) {
EmbeddableAccessor accessor = m_embeddableAccessors.get(cls.getName());
if (accessor == null) {
// so desire.
if (cls.isAnnotationPresent(JPA_EMBEDDABLE) || (checkIsIdClass && isIdClass(cls))) {
accessor = new EmbeddableAccessor(cls.getAnnotation(JPA_EMBEDDABLE), cls, this);
addEmbeddableAccessor(accessor);
}
}
return accessor;
}
use of org.eclipse.persistence.internal.jpa.metadata.accessors.classes.EmbeddableAccessor in project eclipselink by eclipse-ee4j.
the class MetadataDescriptor method processMappingAccessors.
/**
* INTERNAL:
* Process this descriptors mapping accessors. Some accessors will not be
* processed right away, instead stored on the project for processing in a
* later stage. This method can not and must not be called beyond
* MetadataProject stage 2 processing.
*/
public void processMappingAccessors() {
for (MappingAccessor accessor : m_mappingAccessors.values()) {
if (!accessor.isProcessed()) {
// key, process that embeddable accessor now.
if (accessor.isMappedKeyMapAccessor()) {
MappedKeyMapAccessor mapAccessor = (MappedKeyMapAccessor) accessor;
EmbeddableAccessor mapKeyEmbeddableAccessor = getProject().getEmbeddableAccessor(mapAccessor.getMapKeyClass());
if (mapKeyEmbeddableAccessor != null && !mapKeyEmbeddableAccessor.isProcessed()) {
mapKeyEmbeddableAccessor.process();
}
}
// Care must be taken in the order of checking here.
if (accessor.isDirectEmbeddableCollection() || accessor.isEmbedded()) {
EmbeddableAccessor embeddableAccessor = getProject().getEmbeddableAccessor(accessor.getReferenceClass());
// not an Embeddable.
if (embeddableAccessor == null) {
throw ValidationException.invalidEmbeddedAttribute(getJavaClass(), accessor.getAttributeName(), accessor.getReferenceClass());
} else {
// Process the embeddable class now (if it's not already processed)
if (!embeddableAccessor.isProcessed()) {
embeddableAccessor.process();
}
// Store this descriptor metadata. It may be needed again
// later on to look up a mappedBy attribute etc.
addEmbeddableDescriptor(embeddableAccessor.getDescriptor());
// accessors have processed.
if (accessor.isEmbeddedId() || accessor.isDerivedIdClass()) {
accessor.process();
} else {
// Otherwise defer it because of association overrides.
// We can't process this mapping till all the
// relationship mappings have been processed.
getProject().addEmbeddableMappingAccessor(accessor);
}
}
} else if (accessor.isDirectCollection()) {
getProject().addDirectCollectionAccessor(accessor);
} else if (accessor.isRelationship()) {
if (accessor.derivesId()) {
m_derivedIdAccessors.add((ObjectAccessor) accessor);
getProject().addAccessorWithDerivedId(m_classAccessor);
} else {
addRelationshipAccessor((RelationshipAccessor) accessor);
}
} else {
accessor.process();
}
}
}
}
use of org.eclipse.persistence.internal.jpa.metadata.accessors.classes.EmbeddableAccessor in project eclipselink by eclipse-ee4j.
the class PersistenceUnit method addEmbeddableAccessor.
/**
* INTERNAL:
* Add an embeddable accessor to the project, preserving any previous
* owning descriptors set if applicable.
*/
protected void addEmbeddableAccessor(EmbeddableAccessor embeddableAccessor) {
// this setting)
if (project.hasEmbeddable(embeddableAccessor.getJavaClass())) {
EmbeddableAccessor existingEmbeddableAccessor = project.getEmbeddableAccessor(embeddableAccessor.getJavaClass());
embeddableAccessor.addEmbeddingAccessors(existingEmbeddableAccessor.getEmbeddingAccessors());
embeddableAccessor.addOwningDescriptors(existingEmbeddableAccessor.getOwningDescriptors());
}
project.addEmbeddableAccessor(embeddableAccessor);
}
Aggregations