当前位置: 首页>>代码示例>>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;未经允许,请勿转载。