本文整理汇总了Java中javax.persistence.GenerationType类的典型用法代码示例。如果您正苦于以下问题:Java GenerationType类的具体用法?Java GenerationType怎么用?Java GenerationType使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
GenerationType类属于javax.persistence包,在下文中一共展示了GenerationType类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getId
import javax.persistence.GenerationType; //导入依赖的package包/类
@Id @GeneratedValue(strategy = GenerationType.TABLE, generator = "dog")
@TableGenerator(
name = "dog",
table = "sequences",
pkColumnName = "key",
pkColumnValue = "dog",
valueColumnName = "seed"
)
public Long getId() { return id; }
示例2: generationTypeToGeneratorStrategyName
import javax.persistence.GenerationType; //导入依赖的package包/类
public static String generationTypeToGeneratorStrategyName(GenerationType generatorEnum, boolean useNewGeneratorMappings) {
switch ( generatorEnum ) {
case IDENTITY:
return "identity";
case AUTO:
return useNewGeneratorMappings
? "enhanced-sequence"
: "native";
case TABLE:
return useNewGeneratorMappings
? "enhanced-table"
: MultipleHiLoPerTableGenerator.class.getName();
case SEQUENCE:
return useNewGeneratorMappings
? "enhanced-sequence"
: "seqhilo";
}
throw new AssertionFailure( "Unknown GeneratorType: " + generatorEnum );
}
示例3: getId
import javax.persistence.GenerationType; //导入依赖的package包/类
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
@Column(name = COLUMN_NAME__ID)
public long getId() {
if (idProperty == null) {
return _id;
} else {
return idProperty.get();
}
}
示例4: getId
import javax.persistence.GenerationType; //导入依赖的package包/类
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "srva_event_id", nullable = false)
@Access(value = AccessType.PROPERTY)
@Override
public Long getId() {
return id;
}
示例5: getId
import javax.persistence.GenerationType; //导入依赖的package包/类
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(nullable = false)
@Access(value = AccessType.PROPERTY)
@Override
public Long getId() {
return id;
}
示例6: getId
import javax.persistence.GenerationType; //导入依赖的package包/类
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
@Column(name = ID, columnDefinition = NORMAL_KEY_DEF)
@XmlTransient
@Override
public long getId() {
return id;
}
示例7: getId
import javax.persistence.GenerationType; //导入依赖的package包/类
@Override
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
public long getId()
{
return id;
}
示例8: buildGeneratedValue
import javax.persistence.GenerationType; //导入依赖的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;
}
}
示例9: checkGeneratedValueAnnotation
import javax.persistence.GenerationType; //导入依赖的package包/类
private IdGenerator checkGeneratedValueAnnotation() {
IdGenerator generator = null;
AnnotationInstance generatedValueAnnotation = JandexHelper.getSingleAnnotation(
annotations(),
JPADotNames.GENERATED_VALUE
);
if ( generatedValueAnnotation != null ) {
String name = JandexHelper.getValue( generatedValueAnnotation, "generator", String.class );
if ( StringHelper.isNotEmpty( name ) ) {
generator = getContext().getMetadataImplementor().getIdGenerator( name );
if ( generator == null ) {
throw new MappingException( String.format( "Unable to find named generator %s", name ), null );
}
}
else {
GenerationType genType = JandexHelper.getEnumValue(
generatedValueAnnotation,
"strategy",
GenerationType.class
);
String strategy = EnumConversionHelper.generationTypeToGeneratorStrategyName(
genType,
getContext().getMetadataImplementor().getOptions().useNewIdentifierGenerators()
);
generator = new IdGenerator( null, strategy, null );
}
}
return generator;
}
示例10: getId
import javax.persistence.GenerationType; //导入依赖的package包/类
@Id
@SequenceGenerator(name = "ID_SEQ")
@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "ID_SEQ")
@Column(name = "ID", nullable = false)
public Long getId() {
return id;
}
示例11: getVendorPartNumber
import javax.persistence.GenerationType; //导入依赖的package包/类
@TableGenerator(
name="vendorPartGen",
table="PERSISTENCE_ORDER_SEQUENCE_GENERATOR",
pkColumnName="GEN_KEY",
valueColumnName="GEN_VALUE",
pkColumnValue="VENDOR_PART_ID",
allocationSize=10)
@Id
@GeneratedValue(strategy=GenerationType.TABLE, generator="vendorPartGen")
public Long getVendorPartNumber() {
return vendorPartNumber;
}
示例12: getId
import javax.persistence.GenerationType; //导入依赖的package包/类
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
//@GeneratedValue(strategy = GenerationType.AUTO, generator = "uuid-string")
//@GeneratedValue(generator = "system-uuid")
//@GenericGenerator(name = "system-uuid", strategy = "uuid")
//@Column(length = 32)
public Long getId() {
return id;
}
示例13: getId
import javax.persistence.GenerationType; //导入依赖的package包/类
@Id
@Column(name = "id")
@GeneratedValue(strategy = GenerationType.AUTO)
@Override
public Long getId() {
return id;
}
示例14: getId
import javax.persistence.GenerationType; //导入依赖的package包/类
@Id
@GeneratedValue(strategy = GenerationType.TABLE, generator="gen_camp")
@TableGenerator(name="gen_camp", table="hel_idgen", pkColumnName="taula", valueColumnName="valor")
@Column(name="id")
public Long getId() {
return id;
}
示例15: getId
import javax.persistence.GenerationType; //导入依赖的package包/类
@Id
@GeneratedValue(strategy = GenerationType.TABLE, generator="gen_registre")
@TableGenerator(name="gen_registre", table="hel_idgen", pkColumnName="taula", valueColumnName="valor")
@Column(name="id")
public Long getId() {
return id;
}