當前位置: 首頁>>代碼示例>>Java>>正文


Java EnumType類代碼示例

本文整理匯總了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;
}
 
開發者ID:darciopacifico,項目名稱:omr,代碼行數:12,代碼來源:GrupoVO.java

示例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 ) );
	}
}
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:18,代碼來源:JPAOverriddenAnnotationReader.java

示例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++;
			}
		}
	}
}
 
開發者ID:fjalvingh,項目名稱:domui,代碼行數:25,代碼來源:HibernateChecker.java

示例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();
}
 
開發者ID:hibernate,項目名稱:hibernate-semantic-query,代碼行數:26,代碼來源:BasicTypeRegistry.java

示例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 ) );
	}
}
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:15,代碼來源:JPAOverriddenAnnotationReader.java

示例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;
	}
}
 
開發者ID:osonus,項目名稱:oson,代碼行數:8,代碼來源:Oson.java

示例8: getEnumType

import javax.persistence.EnumType; //導入依賴的package包/類
public EnumType getEnumType() {
	if (enumType == null && classMapper != null) {
		enumType = classMapper.enumType;
	}

	return enumType;
}
 
開發者ID:osonus,項目名稱:oson,代碼行數:8,代碼來源:Oson.java

示例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()));
			}
		}
	}
 
開發者ID:osonus,項目名稱:oson,代碼行數:31,代碼來源:BascicDateTypeTest.java

示例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);
}
 
開發者ID:osonus,項目名稱:oson,代碼行數:12,代碼來源:EnumTest.java

示例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;
}
 
開發者ID:salimvanak,項目名稱:myWMS,代碼行數:12,代碼來源:LogItem.java

示例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);
}
 
開發者ID:GUMGA,項目名稱:maven-plugin,代碼行數:33,代碼來源:GeraEntidade.java

示例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;
}
 
開發者ID:darciopacifico,項目名稱:omr,代碼行數:8,代碼來源:PessoaVO.java

示例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;
}
 
開發者ID:MobileManAG,項目名稱:Project-H-Backend,代碼行數:10,代碼來源:KeyPerformanceIndicatorType.java

示例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;
}
 
開發者ID:RBGKew,項目名稱:powop,代碼行數:12,代碼來源:Description.java


注:本文中的javax.persistence.EnumType類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。