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


Java GeneratedValue類代碼示例

本文整理匯總了Java中javax.persistence.GeneratedValue的典型用法代碼示例。如果您正苦於以下問題:Java GeneratedValue類的具體用法?Java GeneratedValue怎麽用?Java GeneratedValue使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


GeneratedValue類屬於javax.persistence包,在下文中一共展示了GeneratedValue類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: getPid

import javax.persistence.GeneratedValue; //導入依賴的package包/類
@Id
@Column(name="PID",length=15)
@Type(type="int")
@GenericGenerator(name="gen",strategy="increment")
@GeneratedValue(generator="gen")
	public int getPid() {
		return pid;
	}
 
開發者ID:pratikdimble,項目名稱:Hibernate_Component_Mapping_Using_DAO_Using_Maven,代碼行數:9,代碼來源:person.java

示例2: getId

import javax.persistence.GeneratedValue; //導入依賴的package包/類
@Id @GeneratedValue(strategy = GenerationType.TABLE, generator = "dog")
@TableGenerator(
	name = "dog",
	table = "sequences",
	pkColumnName = "key",
	pkColumnValue = "dog",
	valueColumnName = "seed"
)
public Long getId() { return id; }
 
開發者ID:hibernate,項目名稱:hibernate-ogm-redis,代碼行數:10,代碼來源:Dog.java

示例3: getId

import javax.persistence.GeneratedValue; //導入依賴的package包/類
@Override
@Id
@GeneratedValue(strategy = IDENTITY)
@Column(name = "Id", unique = true, nullable = false)
public Integer getId() {
    return this.id;
}
 
開發者ID:zhaoxi1988,項目名稱:sjk,代碼行數:8,代碼來源:MonChannelApp.java

示例4: getId

import javax.persistence.GeneratedValue; //導入依賴的package包/類
/** full constructor */

	// Property accessors
	@GenericGenerator( name = "generator" , strategy = "identity" )
	@Id
	@GeneratedValue( generator = "generator" )
	@Column( name = "id" , unique = true , nullable = false )
	public Integer getId() {
		return this.id;
	}
 
開發者ID:aiyoyoyo,項目名稱:jeesupport,代碼行數:11,代碼來源:TabB.java

示例5: getId

import javax.persistence.GeneratedValue; //導入依賴的package包/類
/**
 * 用戶id
 * @return
 */
@Id
@GeneratedValue(strategy = IDENTITY)
@Column(name = "id", unique = true, nullable = false)
public Integer getId() {
	return this.id;
}
 
開發者ID:xnx3,項目名稱:wangmarket,代碼行數:11,代碼來源:User.java

示例6: getId

import javax.persistence.GeneratedValue; //導入依賴的package包/類
@Id
@GeneratedValue(strategy = IDENTITY)

@Column(name = "id", unique = true, nullable = false)
public Integer getId() {
	return this.id;
}
 
開發者ID:sarfarazengglb,項目名稱:spring-data,代碼行數:8,代碼來源:Profile.java

示例7: isPostable

import javax.persistence.GeneratedValue; //導入依賴的package包/類
@Override
public Optional<Boolean> isPostable(BeanAttributeInformation attributeDesc) {
	Optional<Column> column = attributeDesc.getAnnotation(Column.class);
	Optional<Version> version = attributeDesc.getAnnotation(Version.class);
	if (!version.isPresent() && column.isPresent()) {
		return Optional.of(column.get().insertable());
	}
	Optional<GeneratedValue> generatedValue = attributeDesc.getAnnotation(GeneratedValue.class);
	if (generatedValue.isPresent()) {
		return Optional.of(false);
	}
	return Optional.empty();
}
 
開發者ID:crnk-project,項目名稱:crnk-framework,代碼行數:14,代碼來源:JpaResourceFieldInformationProvider.java

示例8: isPatchable

import javax.persistence.GeneratedValue; //導入依賴的package包/類
@Override
public Optional<Boolean> isPatchable(BeanAttributeInformation attributeDesc) {
	Optional<Column> column = attributeDesc.getAnnotation(Column.class);
	Optional<Version> version = attributeDesc.getAnnotation(Version.class);
	if (!version.isPresent() && column.isPresent()) {
		return Optional.of(column.get().updatable());
	}
	Optional<GeneratedValue> generatedValue = attributeDesc.getAnnotation(GeneratedValue.class);
	if (generatedValue.isPresent()) {
		return Optional.of(false);
	}
	return Optional.empty();
}
 
開發者ID:crnk-project,項目名稱:crnk-framework,代碼行數:14,代碼來源:JpaResourceFieldInformationProvider.java

示例9: getId

import javax.persistence.GeneratedValue; //導入依賴的package包/類
/** @return null. */
@Id
@GeneratedValue
@Column(name = "ID", unique = true, nullable = false)
public Long getId() {
    return this.id;
}
 
開發者ID:zhaojunfei,項目名稱:lemon,代碼行數:8,代碼來源:CustomerInfo.java

示例10: hasAnnotationsOnIdClass

import javax.persistence.GeneratedValue; //導入依賴的package包/類
private static boolean hasAnnotationsOnIdClass(XClass idClass) {
//		if(idClass.getAnnotation(Embeddable.class) != null)
//			return true;

		List<XProperty> properties = idClass.getDeclaredProperties( XClass.ACCESS_FIELD );
		for ( XProperty property : properties ) {
			if ( property.isAnnotationPresent( Column.class ) || property.isAnnotationPresent( OneToMany.class ) ||
					property.isAnnotationPresent( ManyToOne.class ) || property.isAnnotationPresent( Id.class ) ||
					property.isAnnotationPresent( GeneratedValue.class ) || property.isAnnotationPresent( OneToOne.class ) ||
					property.isAnnotationPresent( ManyToMany.class )
					) {
				return true;
			}
		}
		List<XMethod> methods = idClass.getDeclaredMethods();
		for ( XMethod method : methods ) {
			if ( method.isAnnotationPresent( Column.class ) || method.isAnnotationPresent( OneToMany.class ) ||
					method.isAnnotationPresent( ManyToOne.class ) || method.isAnnotationPresent( Id.class ) ||
					method.isAnnotationPresent( GeneratedValue.class ) || method.isAnnotationPresent( OneToOne.class ) ||
					method.isAnnotationPresent( ManyToMany.class )
					) {
				return true;
			}
		}
		return false;
	}
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:27,代碼來源:AnnotationBinder.java

示例11: columnMap

import javax.persistence.GeneratedValue; //導入依賴的package包/類
private static Map<String, Accessor> columnMap(Class<?> klass, boolean includesGeneratedValue) {

        List<Accessor> accessors = new ArrayList<>();
        accessors.addAll(getPropertyAccessors(klass));
        accessors.addAll(getFieldAccessors(klass));

        Map<String, Accessor> result = new HashMap<>();

        for (Accessor accessor : accessors) {
            String columnName = columnName(accessor);
            if (!result.containsKey(columnName)
                    && (includesGeneratedValue || accessor.getAnnotation(GeneratedValue.class) == null)) {
                result.put(columnName, accessor);
            }
        }
        return result;
    }
 
開發者ID:cybozu,項目名稱:spring-data-jdbc-template,代碼行數:18,代碼來源:EntityUtils.java

示例12: getId

import javax.persistence.GeneratedValue; //導入依賴的package包/類
@Id
@GeneratedValue(strategy = IDENTITY)
@Column(name = "id", unique = true, nullable = false)
public Integer getId() {
	return id;
}
 
開發者ID:xnx3,項目名稱:wangmarket,代碼行數:7,代碼來源:Log.java

示例13: getId

import javax.persistence.GeneratedValue; //導入依賴的package包/類
@Override
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
public long getId()
{
	return id;
}
 
開發者ID:equella,項目名稱:Equella,代碼行數:8,代碼來源:LanguageString.java

示例14: processId

import javax.persistence.GeneratedValue; //導入依賴的package包/類
private static void processId(
		PropertyHolder propertyHolder,
		PropertyData inferredData,
		SimpleValue idValue,
		HashMap<String, IdGenerator> classGenerators,
		boolean isIdentifierMapper,
		Mappings mappings) {
	if ( isIdentifierMapper ) {
		throw new AnnotationException(
				"@IdClass class should not have @Id nor @EmbeddedId properties: "
						+ BinderHelper.getPath( propertyHolder, inferredData )
		);
	}
	XClass returnedClass = inferredData.getClassOrElement();
	XProperty property = inferredData.getProperty();
	//clone classGenerator and override with local values
	HashMap<String, IdGenerator> localGenerators = ( HashMap<String, IdGenerator> ) classGenerators.clone();
	localGenerators.putAll( buildLocalGenerators( property, mappings ) );

	//manage composite related metadata
	//guess if its a component and find id data access (property, field etc)
	final boolean isComponent = returnedClass.isAnnotationPresent( Embeddable.class )
			|| property.isAnnotationPresent( EmbeddedId.class );

	GeneratedValue generatedValue = property.getAnnotation( GeneratedValue.class );
	String generatorType = generatedValue != null ?
			generatorType( generatedValue.strategy(), mappings ) :
			"assigned";
	String generatorName = generatedValue != null ?
			generatedValue.generator() :
			BinderHelper.ANNOTATION_STRING_DEFAULT;
	if ( isComponent ) {
		generatorType = "assigned";
	} //a component must not have any generator
	BinderHelper.makeIdGenerator( idValue, generatorType, generatorName, mappings, localGenerators );

	if ( LOG.isTraceEnabled() ) {
		LOG.tracev( "Bind {0} on {1}", ( isComponent ? "@EmbeddedId" : "@Id" ), inferredData.getPropertyName() );
	}
}
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:41,代碼來源:AnnotationBinder.java

示例15: buildGeneratedValue

import javax.persistence.GeneratedValue; //導入依賴的package包/類
private GeneratedValue buildGeneratedValue(Element element) {
	Element subElement = element != null ? element.element( "generated-value" ) : null;
	if ( subElement != null ) {
		AnnotationDescriptor ad = new AnnotationDescriptor( GeneratedValue.class );
		String strategy = subElement.attributeValue( "strategy" );
		if ( "TABLE".equalsIgnoreCase( strategy ) ) {
			ad.setValue( "strategy", GenerationType.TABLE );
		}
		else if ( "SEQUENCE".equalsIgnoreCase( strategy ) ) {
			ad.setValue( "strategy", GenerationType.SEQUENCE );
		}
		else if ( "IDENTITY".equalsIgnoreCase( strategy ) ) {
			ad.setValue( "strategy", GenerationType.IDENTITY );
		}
		else if ( "AUTO".equalsIgnoreCase( strategy ) ) {
			ad.setValue( "strategy", GenerationType.AUTO );
		}
		else if ( StringHelper.isNotEmpty( strategy ) ) {
			throw new AnnotationException( "Unknown GenerationType: " + strategy + ". " + SCHEMA_VALIDATION );
		}
		copyStringAttribute( ad, subElement, "generator", false );
		return AnnotationFactory.create( ad );
	}
	else {
		return null;
	}
}
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:28,代碼來源:JPAOverriddenAnnotationReader.java


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