private javax.persistence.EnumType getEnumType(ParameterType reader) { javax.persistence.EnumType enumType = null; if ( reader.isPrimaryKey() ) { MapKeyEnumerated enumAnn = getAnnotation( reader.getAnnotationsMethod(), MapKeyEnumerated.class ); if ( enumAnn != null ) { enumType = enumAnn.value(); } } else { Enumerated enumAnn = getAnnotation( reader.getAnnotationsMethod(), Enumerated.class ); if ( enumAnn != null ) { enumType = enumAnn.value(); } } return enumType; }
EnumType enumType = enumerated.value(); if (enumType == EnumType.ORDINAL) { converterType = EnumOrdinalConverter.class.getCanonicalName();
@Test public void testEnumerated() throws Exception { reader = getReader( Entity3.class, "field1", "element-collection.orm19.xml" ); assertAnnotationPresent( ElementCollection.class ); assertAnnotationNotPresent( Temporal.class ); assertAnnotationPresent( Enumerated.class ); assertAnnotationNotPresent( Lob.class ); assertEquals( EnumType.STRING, reader.getAnnotation( Enumerated.class ).value() ); }
private javax.persistence.EnumType getEnumType(XProperty property) { javax.persistence.EnumType enumType = null; if (key) { MapKeyEnumerated enumAnn = property.getAnnotation( MapKeyEnumerated.class ); if ( enumAnn != null ) { enumType = enumAnn.value(); } } else { Enumerated enumAnn = property.getAnnotation( Enumerated.class ); if ( enumAnn != null ) { enumType = enumAnn.value(); } } return enumType; }
@SuppressWarnings("unchecked") public void setEnumScalarType(Enumerated enumerated, DeployBeanProperty prop) { Class<?> enumType = prop.getPropertyType(); if (!enumType.isEnum()) { throw new IllegalArgumentException("Class [" + enumType + "] is Not a Enum?"); } try { Class<? extends Enum<?>> enumClass = (Class<? extends Enum<?>>) enumType; EnumType type = enumerated != null ? enumerated.value() : null; ScalarType<?> scalarType = typeManager.createEnumScalarType(enumClass, type); prop.setScalarType(scalarType); prop.setDbType(scalarType.getJdbcType()); } catch (IllegalStateException e) { throw new PersistenceException("Error mapping property " + prop.getFullBeanName() + " - " + e.getMessage()); } }
final EnumType type = (enumerated == null) ? EnumType.STRING : enumerated.value(); if (type == EnumType.STRING) { pstmt.setString(j, value == null ? null : value.toString()); } else if (attr.field.getType() == Ip.class) { final Enumerated enumerated = attr.field.getAnnotation(Enumerated.class); final EnumType type = (enumerated == null) ? EnumType.ORDINAL : enumerated.value(); if (type == EnumType.STRING) { pstmt.setString(j, value == null ? null : value.toString());
private FieldTypeEnum getEnumType(Enumerated enumerated) { if (enumerated == null) { return FieldTypeEnum.ENUMORDINAL; } EnumType type = enumerated.value(); if (type == null || type == EnumType.ORDINAL) { return FieldTypeEnum.ENUMORDINAL; } return FieldTypeEnum.ENUMSTRING; }
public EnumType getEnumType() { if (element.isAnnotationPresent(Enumerated.class)) { if (element.getAnnotation(Enumerated.class).value() == EnumType.STRING) return EnumType.STRING; else return EnumType.ORDINAL; } return null; }
private EnumType getPersistenceEnumType(Class<?> enumFieldType) { for (Field nextField : getClass().getFields()) { nextField.setAccessible(true); if (nextField.getType().equals(enumFieldType)) { Enumerated enumeratedAnnotation = nextField.getAnnotation(Enumerated.class); if (enumeratedAnnotation != null) { return enumeratedAnnotation.value(); } } } return EnumType.STRING; // catch-all }
/** * Return true if there is an existing default mapping for the enum that needs * to be overridden (for example, DayOfWeek defaults to Integer mapping 1 to 7 * and some might want this mapped to 'MONDAY' etc). */ private boolean enumOverrideDefaultMapping(Enumerated enumerated, ScalarType<?> scalarType) { return enumerated != null && scalarType != null && enumerated.value() == EnumType.STRING && scalarType.getJdbcType() != Types.VARCHAR; }
public <I extends BaseNature, A extends Annotation> boolean processAnnotation( final I info, final A annotation, final AnnotatedElement target) throws AnnotationTargetException { if ((info instanceof JPAFieldNature) && (annotation instanceof Enumerated) && target.isAnnotationPresent(Enumerated.class)) { _log.debug("processing field annotation " + annotation.toString()); final JPAFieldNature jpaFieldNature = (JPAFieldNature) info; if (((Enumerated) annotation).value() == EnumType.STRING) { jpaFieldNature.setStringEnumType(true); } return true; } return false; }
/** * Parse @Enumerated. */ private void parseEnumerated(FieldMapping fm, Enumerated anno) { String strat = EnumValueHandler.class.getName() + "(StoreOrdinal=" + String.valueOf(anno.value() == EnumType.ORDINAL) + ")"; fm.getValueInfo().setStrategy(strat); }
/** * INTERNAL: (Overridden in XMLBasicAccessor) */ public String getEnumeratedType() { Enumerated enumerated = getAnnotation(Enumerated.class); if (enumerated == null) { return EnumType.ORDINAL.name(); } else { return enumerated.value().name(); } }
private void normalSupplementalDetails( XProperty navigableXProperty, MetadataBuildingContext buildingContext) { final Enumerated mapKeyEnumeratedAnn = navigableXProperty.getAnnotation( Enumerated.class ); if ( mapKeyEnumeratedAnn != null ) { enumType = mapKeyEnumeratedAnn.value(); } final Temporal mapKeyTemporalAnn = navigableXProperty.getAnnotation( Temporal.class ); if ( mapKeyTemporalAnn != null ) { temporalPrecision = mapKeyTemporalAnn.value(); } }
private String parseEnum(Field field) { Enumerated enumerated = field.getDeclaredAnnotation(Enumerated.class); if (enumerated != null) { EnumType value = enumerated.value(); if (EnumType.STRING.equals(value)) return "org.apache.ibatis.type.EnumTypeHandler"; } if (config.isUseEnumOrdinalTypeHandlerByDefault()) { return "org.apache.ibatis.type.EnumOrdinalTypeHandler"; } else { return null; } }
/** * Parse @Enumerated. */ private void parseEnumerated(FieldMapping fm, Enumerated anno) { String strat = EnumValueHandler.class.getName() + "(StoreOrdinal=" + String.valueOf(anno.value() == EnumType.ORDINAL) + ")"; if (fm.isElementCollection()) fm.getElementMapping().getValueInfo().setStrategy(strat); else fm.getValueInfo().setStrategy(strat); }
/** * Parse @Enumerated. */ private void parseEnumerated(FieldMapping fm, Enumerated anno) { String strat = EnumValueHandler.class.getName() + "(StoreOrdinal=" + String.valueOf(anno.value() == EnumType.ORDINAL) + ")"; if (fm.isElementCollection()) fm.getElementMapping().getValueInfo().setStrategy(strat); else fm.getValueInfo().setStrategy(strat); }
/** * Parse @Enumerated. */ private void parseEnumerated(FieldMapping fm, Enumerated anno) { String strat = EnumValueHandler.class.getName() + "(StoreOrdinal=" + String.valueOf(anno.value() == EnumType.ORDINAL) + ")"; if (fm.isElementCollection()) fm.getElementMapping().getValueInfo().setStrategy(strat); else fm.getValueInfo().setStrategy(strat); }
@SuppressWarnings("unchecked") public void setEnumScalarType(Enumerated enumerated, DeployBeanProperty prop) { Class<?> enumType = prop.getPropertyType(); if (!enumType.isEnum()) { throw new IllegalArgumentException("Class [" + enumType + "] is Not a Enum?"); } try { Class<? extends Enum<?>> enumClass = (Class<? extends Enum<?>>) enumType; EnumType type = enumerated != null ? enumerated.value() : null; ScalarType<?> scalarType = typeManager.createEnumScalarType(enumClass, type); prop.setScalarType(scalarType); prop.setDbType(scalarType.getJdbcType()); } catch (IllegalStateException e) { throw new PersistenceException("Error mapping property " + prop.getFullBeanName() + " - " + e.getMessage()); } }