use of org.datanucleus.store.rdbms.mapping.MappingManager in project datanucleus-rdbms by datanucleus.
the class DiscriminatorMapping method createDiscriminatorMapping.
/**
* Convenience method to create a discriminator mapping in the specified table, using the provided
* discriminator metadata.
* @param table The table
* @param dismd The discriminator metadata
* @return Discriminator mapping
*/
public static DiscriminatorMapping createDiscriminatorMapping(Table table, DiscriminatorMetaData dismd) {
RDBMSStoreManager storeMgr = table.getStoreManager();
MappingManager mapMgr = storeMgr.getMappingManager();
if (dismd.getStrategy() == DiscriminatorStrategy.CLASS_NAME) {
return new DiscriminatorStringMapping(table, mapMgr.getMapping(String.class), dismd);
} else if (dismd.getStrategy() == DiscriminatorStrategy.VALUE_MAP) {
ColumnMetaData disColmd = dismd.getColumnMetaData();
if (disColmd != null && disColmd.getJdbcType() != null) {
if (MetaDataUtils.isJdbcTypeNumeric(disColmd.getJdbcType())) {
return new DiscriminatorLongMapping(table, mapMgr.getMapping(Long.class), dismd);
}
return new DiscriminatorStringMapping(table, mapMgr.getMapping(String.class), dismd);
}
return new DiscriminatorStringMapping(table, mapMgr.getMapping(String.class), dismd);
} else if (dismd.getStrategy() == DiscriminatorStrategy.VALUE_MAP_ENTITY_NAME) {
ColumnMetaData disColmd = dismd.getColumnMetaData();
if (disColmd != null && disColmd.getJdbcType() != null) {
if (MetaDataUtils.isJdbcTypeNumeric(disColmd.getJdbcType())) {
return new DiscriminatorLongMapping(table, mapMgr.getMapping(Long.class), dismd);
}
return new DiscriminatorStringMapping(table, mapMgr.getMapping(String.class), dismd);
}
return new DiscriminatorStringMapping(table, mapMgr.getMapping(String.class), dismd);
}
return null;
}
use of org.datanucleus.store.rdbms.mapping.MappingManager in project datanucleus-rdbms by datanucleus.
the class SingleFieldMapping method prepareDatastoreMapping.
/**
* Method to prepare a field mapping for use in the datastore.
* This creates the column in the table.
*/
protected void prepareDatastoreMapping() {
MappingManager mmgr = storeMgr.getMappingManager();
Column col = mmgr.createColumn(this, getJavaTypeForDatastoreMapping(0), 0);
mmgr.createDatastoreMapping(this, mmd, 0, col);
}
Aggregations