本文整理匯總了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;
}