本文整理汇总了Java中javax.persistence.EnumType类的典型用法代码示例。如果您正苦于以下问题:Java EnumType类的具体用法?Java EnumType怎么用?Java EnumType使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
EnumType类属于javax.persistence包,在下文中一共展示了EnumType类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getAuthorities
import javax.persistence.EnumType; //导入依赖的package包/类
/**
*
* @return
*/
@ElementCollection(targetClass=EAuthority.class,fetch=FetchType.EAGER)
@JoinTable(name = "grupo_autorities")
@Enumerated(EnumType.STRING)
@Fetch(FetchMode.SELECT)
public List<EAuthority> getAuthorities() {
return authorities;
}
示例2: getEnumerated
import javax.persistence.EnumType; //导入依赖的package包/类
private void getEnumerated(List<Annotation> annotationList, Element element) {
Element subElement = element != null ? element.element( "enumerated" ) : null;
if ( subElement != null ) {
AnnotationDescriptor ad = new AnnotationDescriptor( Enumerated.class );
String enumerated = subElement.getTextTrim();
if ( "ORDINAL".equalsIgnoreCase( enumerated ) ) {
ad.setValue( "value", EnumType.ORDINAL );
}
else if ( "STRING".equalsIgnoreCase( enumerated ) ) {
ad.setValue( "value", EnumType.STRING );
}
else if ( StringHelper.isNotEmpty( enumerated ) ) {
throw new AnnotationException( "Unknown EnumType: " + enumerated + ". " + SCHEMA_VALIDATION );
}
annotationList.add( AnnotationFactory.create( ad ) );
}
}
示例3: checkEnumMapping
import javax.persistence.EnumType; //导入依赖的package包/类
/**
* Enums must be mapped as String, not ORDINAL.
* @param g
*/
private void checkEnumMapping(Method g) {
if(Enum.class.isAssignableFrom(g.getReturnType())) { // Is type enum?
if(g.getAnnotation(Transient.class) != null)
return;
//-- If the enum has a @Type we will have to assume the type handles mapping correctly (like MappedEnumType)
org.hibernate.annotations.Type ht = g.getAnnotation(Type.class);
if(null == ht) {
//-- No @Type mapping, so this must have proper @Enumerated definition.
Enumerated e = g.getAnnotation(Enumerated.class);
if(null == e) {
problem(Severity.ERROR, "Missing @Enumerated annotation on enum property - this will cause ORDINAL mapping of an enum which is undesirable");
m_enumErrors++;
} else if(e.value() != EnumType.STRING) {
problem(Severity.ERROR, "@Enumerated(ORDINAL) annotation on enum property - this will cause ORDINAL mapping of an enum which is undesirable");
m_enumErrors++;
}
}
}
}
示例4: BasicTypeRegistry
import javax.persistence.EnumType; //导入依赖的package包/类
public BasicTypeRegistry(TypeConfiguration typeConfiguration) {
this.typeConfiguration = typeConfiguration;
this.baseJdbcRecommendedSqlTypeMappingContext = new JdbcRecommendedSqlTypeMappingContext() {
@Override
public boolean isNationalized() {
return false;
}
@Override
public boolean isLob() {
return false;
}
@Override
public EnumType getEnumeratedType() {
return EnumType.STRING;
}
@Override
public TypeConfiguration getTypeConfiguration() {
return typeConfiguration;
}
};
registerBasicTypes();
}
示例5: getMapKeyEnumerated
import javax.persistence.EnumType; //导入依赖的package包/类
/**
* Adds a @MapKeyEnumerated annotation to the specified annotationList if the specified element
* contains a map-key-enumerated sub-element. This should only be the case for
* element-collection, many-to-many, or one-to-many associations.
*/
private void getMapKeyEnumerated(List<Annotation> annotationList, Element element) {
Element subelement = element != null ? element.element( "map-key-enumerated" ) : null;
if ( subelement != null ) {
AnnotationDescriptor ad = new AnnotationDescriptor( MapKeyEnumerated.class );
EnumType value = EnumType.valueOf( subelement.getTextTrim() );
ad.setValue( "value", value );
annotationList.add( AnnotationFactory.create( ad ) );
}
}
示例6: processBeanProperty
import javax.persistence.EnumType; //导入依赖的package包/类
@SuppressWarnings({ "unchecked", "rawtypes" })
@Override
public Builder<?> processBeanProperty(Builder<?> property, Class<?> beanOrNestedClass) {
property.getAnnotation(Enumerated.class).ifPresent(a -> {
final EnumType enumType = a.value();
if (enumType == EnumType.STRING) {
((Builder) property).converter(PropertyValueConverter.enumByName());
} else {
((Builder) property).converter(PropertyValueConverter.enumByOrdinal());
}
LOGGER.debug(() -> "JpaEnumeratedBeanPropertyPostProcessor: setted property [" + property
+ "] value converter to default enumeration converter using [" + enumType.name() + "] mode");
});
return property;
}
开发者ID:holon-platform,项目名称:holon-datastore-jpa,代码行数:16,代码来源:JpaEnumeratedBeanPropertyPostProcessor.java
示例7: valueOf
import javax.persistence.EnumType; //导入依赖的package包/类
public static EnumType valueOf(ENUM_TYPE en) {
switch (en) {
case ORDINAL: return EnumType.ORDINAL;
case STRING: return EnumType.STRING;
default: return null;
}
}
示例8: getEnumType
import javax.persistence.EnumType; //导入依赖的package包/类
public EnumType getEnumType() {
if (enumType == null && classMapper != null) {
enumType = classMapper.enumType;
}
return enumType;
}
示例9: testSerializeBasicDateTypeRaw
import javax.persistence.EnumType; //导入依赖的package包/类
@Test
public void testSerializeBasicDateTypeRaw() {
BascicDateType datetype = new BascicDateType();
datetype.character = 'A';
datetype.pdouble = 123.456;
datetype.pfloat = 3.456f;
datetype.ddouble = 5.34;
datetype.dfloat = 89.345f;
String json = oson.setAppendingFloatingZero(false).setEnumType(EnumType.ORDINAL).setDate2Long(true).serialize(datetype);
Map<String, Object> map = (Map<String, Object>)oson.getListMapObject(json);
Field[] fields = oson.getFields(BascicDateType.class);
for (Field field: fields) {
String name = field.getName();
// System.err.println("\n" + field.getName() + ":");
//System.err.println(field.getType());
Object obj = map.get(name);
// System.err.println(obj);
if (obj != null) {
//System.err.println(obj.getClass());
assertTrue(ObjectUtil.isSameDataType(field.getType(), obj.getClass()));
}
}
}
示例10: testSerializeEnumWithEnumType
import javax.persistence.EnumType; //导入依赖的package包/类
@Test
public void testSerializeEnumWithEnumType() {
Enum value = MODIFIER.Synchronized;
String expected = "10";
oson.setEnumType(EnumType.ORDINAL);
String result = oson.serialize(value);
assertEquals(expected, result);
}
示例11: getType
import javax.persistence.EnumType; //导入依赖的package包/类
/**
* Getter for property type.
*
* @return Value of property type.
*/
@Enumerated(EnumType.STRING)
@Column(nullable = false)
public LogItemType getType() {
return this.type;
}
示例12: createAttribute
import javax.persistence.EnumType; //导入依赖的package包/类
@Enumerated(EnumType.STRING)
private Attribute createAttribute(String[] parts) {
Boolean oneToMany = false;
Boolean oneToOne = false;
Boolean manyToOne = false;
Boolean manyToMany = false;
Boolean required = false;
Boolean enumString = false;
Boolean enumOrdinal = false;
if (parts.length > 2) {
for (int i = 2; i < parts.length; i++) {
if (this.isRequired(parts[i])) {
required = Boolean.valueOf(parts[i]);
} else if (this.isOneToMany(parts[i])) {
oneToMany = true;
} else if (this.isOneToOne(parts[i])) {
oneToOne = true;
} else if (this.isManyToOne(parts[i])) {
manyToOne = true;
} else if (this.isManyToMany(parts[i])) {
manyToMany = true;
} else if (this.isEnumString(parts[i])) {
enumString = true;
} else if (this.isEnumOrdinal(parts[i])) {
enumOrdinal = true;
}
}
}
return new Attribute(parts[0], parts[1], Util.primeiraMaiuscula(parts[0]), oneToMany, oneToOne, manyToOne, manyToMany, required, enumString, enumOrdinal);
}
示例13: getAuthorities
import javax.persistence.EnumType; //导入依赖的package包/类
@ElementCollection(targetClass=EAuthority.class,fetch=FetchType.EAGER)
@JoinTable(name = "pessoa_autorities")
@Enumerated(EnumType.STRING)
@Fetch(FetchMode.SELECT)
public List<EAuthority> getAuthorities() {
return authorities;
}
示例14: getType
import javax.persistence.EnumType; //导入依赖的package包/类
/**
* @return type type of KPI
*/
@Enumerated(EnumType.ORDINAL)
@Column(name = "type", unique = false, nullable = false)
@Field(index=org.hibernate.search.annotations.Index.TOKENIZED, store=Store.NO)
public Type getType() {
return this.type;
}
示例15: getTypes
import javax.persistence.EnumType; //导入依赖的package包/类
/**
*
* @return Return the subjects that this content is about.
*/
@ElementCollection
@Column(name = "type")
@Enumerated(EnumType.STRING)
@Sort(type = SortType.NATURAL)
public SortedSet<DescriptionType> getTypes() {
return types;
}