当前位置: 首页>>代码示例>>Java>>正文


Java DatabaseMapping.getField方法代码示例

本文整理汇总了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()
                );
            }
        }
    }
}
 
开发者ID:kawasima,项目名称:occupy-pub,代码行数:26,代码来源:SnakeCaseNameMapping.java

示例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" );
}
 
开发者ID:realityforge,项目名称:geolatte-geom-eclipselink,代码行数:17,代码来源:SqlServerConverter.java

示例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");
}
 
开发者ID:organicsmarthome,项目名称:OSHv4,代码行数:16,代码来源:JPAUUIDConverter.java

示例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);
        }
    }
}
 
开发者ID:antoniomaria,项目名称:karaf4-eclipselink-jpa,代码行数:11,代码来源:CamelNamingStrategy.java

示例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.");
					}
				}
			}

		}
	}
}
 
开发者ID:kuali,项目名称:kc-rice,代码行数:45,代码来源:EclipseLinkJpaMetadataProviderImpl.java

示例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" );
    }
  }
}
 
开发者ID:realityforge,项目名称:geolatte-geom-eclipselink,代码行数:58,代码来源:PostgisConverter.java


注:本文中的org.eclipse.persistence.mappings.DatabaseMapping.getField方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。