use of org.eclipse.persistence.mappings.DirectMapMapping in project eclipselink by eclipse-ee4j.
the class DirectMapMergeTest method getNewProject.
@Override
protected Project getNewProject() {
Project p = new DirectMapMappingsProject();
DirectMapMapping mapping = (DirectMapMapping) p.getDescriptor(DirectMapMappings.class).getMappingForAttributeName("directMap");
mapping.setKeyClass(Integer.class);
return p;
}
use of org.eclipse.persistence.mappings.DirectMapMapping in project eclipselink by eclipse-ee4j.
the class TestUpdateEntityDirectMapMapping method setup.
@Override
public void setup() {
DirectMapMapping mapping = (DirectMapMapping) getSession().getProject().getDescriptor(EntityDirectMapHolder.class).getMappingForAttributeName("entityToDirectMap");
keyMapping = (ForeignReferenceMapping) ((MappedKeyMapContainerPolicy) mapping.getContainerPolicy()).getKeyMapping();
oldKeyPrivateOwnedValue = keyMapping.isPrivateOwned();
keyMapping.setIsPrivateOwned(usePrivateOwned);
super.setup();
}
use of org.eclipse.persistence.mappings.DirectMapMapping in project eclipselink by eclipse-ee4j.
the class DirectMapMappingsProject method buildDescriptors.
public RelationalDescriptor buildDescriptors() {
RelationalDescriptor descriptor = new RelationalDescriptor();
descriptor.setJavaClass(org.eclipse.persistence.testing.models.directmap.DirectMapMappings.class);
descriptor.addTableName("DIRECTMAPMAPPINGS");
descriptor.addPrimaryKeyFieldName("DIRECTMAPMAPPINGS.ID");
// RelationalDescriptor properties.
descriptor.useSoftCacheWeakIdentityMap();
descriptor.setIdentityMapSize(100);
descriptor.setSequenceNumberFieldName("DIRECTMAPMAPPINGS.ID");
descriptor.setSequenceNumberName("dmmappings_seq");
descriptor.setAlias("DirectMapMappings");
// Query manager.
descriptor.getQueryManager().checkCacheForDoesExist();
// Mappings.
DirectToFieldMapping idMapping = new DirectToFieldMapping();
idMapping.setAttributeName("id");
idMapping.setFieldName("DIRECTMAPMAPPINGS.ID");
descriptor.addMapping(idMapping);
DirectMapMapping directMapMapping = new DirectMapMapping();
directMapMapping.setAttributeName("directMap");
directMapMapping.setReferenceTableName("DIRECTMAP1");
directMapMapping.setDirectFieldName("DIRECTMAP1.VAL");
// "KEY" is a reserved keyword for SyBase, it can't be used as a field name
directMapMapping.setDirectKeyFieldName("DIRECTMAP1.KEY_FIELD");
directMapMapping.addReferenceKeyFieldName("DIRECTMAP1.ID", "DIRECTMAPMAPPINGS.ID");
directMapMapping.setReferenceClass(Hashtable.class);
directMapMapping.setUsesIndirection(false);
directMapMapping.useMapClass(Hashtable.class);
directMapMapping.setKeyClass(Integer.class);
directMapMapping.setValueClass(String.class);
descriptor.addMapping(directMapMapping);
// direct map batch reading mapping
DirectMapMapping directMapBatchMapping = new DirectMapMapping();
directMapBatchMapping.setAttributeName("directMapForBatchRead");
directMapBatchMapping.setReferenceTableName("DIRECTMAP2");
directMapBatchMapping.setDirectFieldName("DIRECTMAP2.VAL");
directMapBatchMapping.setDirectKeyFieldName("DIRECTMAP2.KEY_FIELD");
directMapBatchMapping.addReferenceKeyFieldName("DIRECTMAP2.ID", "DIRECTMAPMAPPINGS.ID");
directMapBatchMapping.setReferenceClass(Hashtable.class);
directMapBatchMapping.setUsesIndirection(false);
directMapBatchMapping.useMapClass(Hashtable.class);
directMapBatchMapping.setKeyClass(Integer.class);
directMapBatchMapping.setValueClass(String.class);
directMapBatchMapping.useBatchReading();
descriptor.addMapping(directMapBatchMapping);
DirectMapMapping indirectionDirectMapMapping = new DirectMapMapping();
indirectionDirectMapMapping.setAttributeName("indirectionDirectMap");
indirectionDirectMapMapping.setReferenceTableName("DIRECTMAP3");
indirectionDirectMapMapping.setDirectFieldName("DIRECTMAP3.VAL");
indirectionDirectMapMapping.setDirectKeyFieldName("DIRECTMAP3.KEY_FIELD");
indirectionDirectMapMapping.addReferenceKeyFieldName("DIRECTMAP3.ID", "DIRECTMAPMAPPINGS.ID");
indirectionDirectMapMapping.setReferenceClass(Hashtable.class);
indirectionDirectMapMapping.useTransparentMap();
indirectionDirectMapMapping.useMapClass(IndirectMapSubclass.class);
indirectionDirectMapMapping.setKeyClass(Integer.class);
indirectionDirectMapMapping.setValueClass(String.class);
descriptor.addMapping(indirectionDirectMapMapping);
DirectMapMapping directMapBlobMapping = new DirectMapMapping();
directMapBlobMapping.setAttributeName("blobDirectMap");
directMapBlobMapping.setReferenceTableName("DIRECTMAPBLOB");
directMapBlobMapping.setDirectFieldName("DIRECTMAPBLOB.VAL");
directMapBlobMapping.setDirectKeyFieldName("DIRECTMAPBLOB.KEY_FIELD");
directMapBlobMapping.addReferenceKeyFieldName("DIRECTMAPBLOB.ID", "DIRECTMAPMAPPINGS.ID");
directMapBlobMapping.setReferenceClass(Hashtable.class);
directMapBlobMapping.setUsesIndirection(false);
directMapBlobMapping.useMapClass(Hashtable.class);
directMapBlobMapping.setKeyClass(Integer.class);
directMapBlobMapping.setValueClass(Object.class);
directMapBlobMapping.setValueConverter(new SerializedObjectConverter(directMapBlobMapping));
descriptor.addMapping(directMapBlobMapping);
DirectMapMapping directHashMapMapping = new DirectMapMapping();
directHashMapMapping.setAttributeName("directHashMap");
directHashMapMapping.setReferenceTableName("DIRECTMAP4");
directHashMapMapping.setDirectFieldName("DIRECTMAP4.VAL");
directHashMapMapping.setDirectKeyFieldName("DIRECTMAP4.KEY_FIELD");
directHashMapMapping.addReferenceKeyFieldName("DIRECTMAP4.ID", "DIRECTMAPMAPPINGS.ID");
directHashMapMapping.setReferenceClass(HashMap.class);
directHashMapMapping.setUsesIndirection(false);
directHashMapMapping.useMapClass(HashMap.class);
directHashMapMapping.setKeyClass(Integer.class);
directHashMapMapping.setValueClass(String.class);
descriptor.addMapping(directHashMapMapping);
return descriptor;
}
use of org.eclipse.persistence.mappings.DirectMapMapping in project eclipselink by eclipse-ee4j.
the class TypeResolver method visit.
@Override
public void visit(ValueExpression expression) {
IdentificationVariable identificationVariable = (IdentificationVariable) expression.getExpression();
Declaration declaration = queryContext.findDeclaration(identificationVariable.getVariableName());
DatabaseMapping mapping = declaration.getMapping();
if (mapping.isDirectMapMapping()) {
DirectMapMapping mapMapping = (DirectMapMapping) mapping;
type = mapMapping.getValueClass();
if (type == null) {
type = mapMapping.getDirectField().getType();
}
} else {
type = calculateMappingType(declaration.getMapping());
}
}
use of org.eclipse.persistence.mappings.DirectMapMapping in project eclipselink by eclipse-ee4j.
the class ForeignKeyTestSuite method testElementCollectionForeignKeys.
/**
* Tests an element collection foreign key settings.
*/
public void testElementCollectionForeignKeys() {
ClassDescriptor runnerDescriptor = getPersistenceUnitServerSession().getDescriptor(Runner.class);
DirectMapMapping mapping = (DirectMapMapping) runnerDescriptor.getMappingForAttributeName("endorsements");
OneToOneMapping keyMapping = (OneToOneMapping) ((MappedKeyMapContainerPolicy) mapping.getContainerPolicy()).getKeyMapping();
DatabaseTable table = mapping.getReferenceTable();
assertForeignKeyConstraint("Endorsements_Foreign_Key", "FOREIGN KEY (ATHLETE_ID) REFERENCES JPA21_DDL_RUNNER (ID)", table);
table = keyMapping.getForeignKeyFields().get(0).getTable();
assertForeignKeyConstraint("Endorsements_Key_Foreign_Key", "FOREIGN KEY (ENDORSER_ID) REFERENCES JPA_DDL_ENDORSER (ID)", table);
mapping = (DirectMapMapping) runnerDescriptor.getMappingForAttributeName("accomplishments");
table = mapping.getReferenceTable();
assertForeignKeyConstraint("Accomplistments_Foreign_Key", "FOREIGN KEY (ATHLETE_ID) REFERENCES JPA21_DDL_RUNNER (ID)", table);
}
Aggregations