本文整理汇总了Java中org.eclipse.persistence.mappings.DatabaseMapping.getField方法的典型用法代码示例。如果您正苦于以下问题:Java DatabaseMapping.getField方法的具体用法?Java DatabaseMapping.getField怎么用?Java DatabaseMapping.getField使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.eclipse.persistence.mappings.DatabaseMapping
的用法示例。
在下文中一共展示了DatabaseMapping.getField方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: customize
import org.eclipse.persistence.mappings.DatabaseMapping; //导入方法依赖的package包/类
@Override
public void customize(Session session) throws Exception {
for (ClassDescriptor descriptor : session.getDescriptors().values()) {
if (!descriptor.getTables().isEmpty() && descriptor.getAlias().equalsIgnoreCase(descriptor.getTableName())) {
String tableName = addUnderscores(descriptor.getAlias()).toUpperCase();
System.out.println(descriptor.getAlias() + ":" + tableName);
descriptor.setTableName(tableName);
DatabaseTable databaseTable = descriptor.getTables().get(0);
for (IndexDefinition indexDef : databaseTable.getIndexes()) {
indexDef.setTargetTable(tableName);
}
}
for (DatabaseMapping mapping : descriptor.getMappings()) {
if (mapping.getField() != null
&& !mapping.getAttributeName().isEmpty()
&& mapping.getField().getName().equalsIgnoreCase(mapping.getAttributeName())) {
mapping.getField().setName(
addUnderscores(mapping.getAttributeName()).toUpperCase()
);
}
}
}
}
示例2: initialize
import org.eclipse.persistence.mappings.DatabaseMapping; //导入方法依赖的package包/类
@Override
public void initialize( final DatabaseMapping mapping, final Session session )
{
final DatabaseField field;
if ( mapping instanceof DirectCollectionMapping )
{
field = ( (DirectCollectionMapping) mapping ).getDirectField();
}
else
{
field = mapping.getField();
}
field.setSqlType( java.sql.Types.OTHER );
field.setTypeName( "geometry" );
field.setColumnDefinition( "geometry" );
}
示例3: initialize
import org.eclipse.persistence.mappings.DatabaseMapping; //导入方法依赖的package包/类
@Override
public void initialize(DatabaseMapping mapping, Session session) {
final DatabaseField field;
if (mapping instanceof DirectCollectionMapping) {
// handle @ElementCollection...
field = ((DirectCollectionMapping) mapping).getDirectField();
} else {
field = mapping.getField();
}
field.setSqlType(java.sql.Types.VARCHAR);
field.setLength(40);
//field.setTypeName("uuid");
//field.setColumnDefinition("UUID");
}
示例4: camelCaseToUnderscore
import org.eclipse.persistence.mappings.DatabaseMapping; //导入方法依赖的package包/类
private void camelCaseToUnderscore(Vector<DatabaseMapping> mappings) {
for (DatabaseMapping mapping : mappings) {
DatabaseField field = mapping.getField();
if (mapping.isDirectToFieldMapping() && !mapping.isPrimaryKeyMapping()) {
String attributeName = mapping.getAttributeName();
String underScoredFieldName = camelCaseToUnderscore(attributeName);
field.setName(underScoredFieldName);
}
}
}
示例5: populateImplementationSpecificAttributeLevelMetadata
import org.eclipse.persistence.mappings.DatabaseMapping; //导入方法依赖的package包/类
/**
* {@inheritDoc}
*/
@Override
protected void populateImplementationSpecificAttributeLevelMetadata(DataObjectAttributeImpl attribute,
SingularAttribute<?, ?> attr) {
if (attr instanceof SingularAttributeImpl) {
DatabaseMapping mapping = ((SingularAttributeImpl<?, ?>) attr).getMapping();
if (mapping != null && mapping.getField() != null) {
attribute.setReadOnly(mapping.isReadOnly());
attribute.setBackingObjectName(mapping.getField().getName());
if (mapping.getField().getLength() != 0) {
attribute.setMaxLength((long) mapping.getField().getLength());
}
// Special check on the converters to attempt to default secure attributes from being shown on the UI
// We check for a converter which has "encrypt" in its name and auto-set the attribute security
// to mask the attribute.
if (mapping instanceof DirectToFieldMapping) {
Converter converter = ((DirectToFieldMapping) mapping).getConverter();
// ConverterClass is the internal wrapper EclipseLink uses to wrap the JPA AttributeConverter
// classes
// and make them conform to the EclipseLink internal API
if (converter != null && converter instanceof ConverterClass) {
// Unfortunately, there is no access to the actual converter class, so we have to hack it
try {
Field f = ConverterClass.class.getDeclaredField("attributeConverterClassName");
f.setAccessible(true);
String attributeConverterClassName = (String) f.get(converter);
if (StringUtils.containsIgnoreCase(attributeConverterClassName, "encrypt")) {
attribute.setSensitive(true);
}
} catch (Exception e) {
LOG.warn("Unable to access the converter name for attribute: "
+ attribute.getOwningType().getName() + "." + attribute.getName()
+ " Skipping attempt to detect converter.");
}
}
}
}
}
}
示例6: initialize
import org.eclipse.persistence.mappings.DatabaseMapping; //导入方法依赖的package包/类
@Override
public void initialize( final DatabaseMapping mapping, final Session session )
{
final DatabaseField field;
if ( mapping instanceof DirectCollectionMapping )
{
field = ( (DirectCollectionMapping) mapping ).getDirectField();
}
else
{
field = mapping.getField();
}
field.setSqlType( java.sql.Types.OTHER );
if ( null == field.getTypeName() )
{
field.setTypeName( "geometry" );
}
if ( null == field.getColumnDefinition() )
{
final Field javaField = getJavaField( mapping, field );
final Class<?> javaFieldType = javaField.getType();
//TODO: Dervive the SRS from an annotation
//TODO: Dervive the M from an annotation
if ( Point.class == javaFieldType )
{
field.setColumnDefinition( "geometry(POINT,-1)" );
}
else if ( Polygon.class == javaFieldType )
{
field.setColumnDefinition( "geometry(POLYGON,-1)" );
}
else if ( LineString.class == javaFieldType )
{
field.setColumnDefinition( "geometry(LINESTRING,-1)" );
}
else if ( MultiPoint.class == javaFieldType )
{
field.setColumnDefinition( "geometry(MULTIPOINT,-1)" );
}
else if ( MultiPolygon.class == javaFieldType )
{
field.setColumnDefinition( "geometry(MULTIPOLYGON,-1)" );
}
else if ( MultiLineString.class == javaFieldType )
{
field.setColumnDefinition( "geometry(MULTILINESTRING,-1)" );
}
else if ( LinearRing.class == javaFieldType )
{
field.setColumnDefinition( "geometry(LINEARRING,-1)" );
}
else
{
field.setColumnDefinition( "geometry" );
}
}
}