Java Code Examples for javax.persistence.GeneratedValue

The following are top voted examples for showing how to use javax.persistence.GeneratedValue. These examples are extracted from open source projects. You can vote up the examples you like and your votes will be used in our system to generate more good examples.
Example 1
Project: Hibernate_Component_Mapping_Using_DAO_Using_Maven   File: person.java   Source Code and License 13 votes vote down vote up
@Id
@Column(name="PID",length=15)
@Type(type="int")
@GenericGenerator(name="gen",strategy="increment")
@GeneratedValue(generator="gen")
	public int getPid() {
		return pid;
	}
 
Example 2
Project: hibernate-ogm-redis   File: Dog.java   Source Code and License 8 votes vote down vote up
@Id @GeneratedValue(strategy = GenerationType.TABLE, generator = "dog")
@TableGenerator(
	name = "dog",
	table = "sequences",
	pkColumnName = "key",
	pkColumnValue = "dog",
	valueColumnName = "seed"
)
public Long getId() { return id; }
 
Example 3
Project: sjk   File: MonChannelApp.java   Source Code and License 8 votes vote down vote up
@Override
@Id
@GeneratedValue(strategy = IDENTITY)
@Column(name = "Id", unique = true, nullable = false)
public Integer getId() {
    return this.id;
}
 
Example 4
Project: jeesupport   File: TabB.java   Source Code and License 7 votes vote down vote up
/** 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;
	}
 
Example 5
Project: wangmarket   File: User.java   Source Code and License 7 votes vote down vote up
/**
 * 用户id
 * @return
 */
@Id
@GeneratedValue(strategy = IDENTITY)
@Column(name = "id", unique = true, nullable = false)
public Integer getId() {
	return this.id;
}
 
Example 6
Project: spring-data   File: Profile.java   Source Code and License 7 votes vote down vote up
@Id
@GeneratedValue(strategy = IDENTITY)

@Column(name = "id", unique = true, nullable = false)
public Integer getId() {
	return this.id;
}
 
Example 7
Project: crnk-framework   File: JpaResourceFieldInformationProvider.java   Source Code and License 7 votes vote down vote up
@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();
}
 
Example 8
Project: crnk-framework   File: JpaResourceFieldInformationProvider.java   Source Code and License 7 votes vote down vote up
@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();
}
 
Example 9
Project: lemon   File: CustomerInfo.java   Source Code and License 7 votes vote down vote up
/** @return null. */
@Id
@GeneratedValue
@Column(name = "ID", unique = true, nullable = false)
public Long getId() {
    return this.id;
}
 
Example 10
Project: sjk   File: App.java   Source Code and License 7 votes vote down vote up
@Override
@Id
@GeneratedValue(strategy = IDENTITY)
@Column(name = "Id", unique = true, nullable = false)
public Integer getId() {
    return this.id;
}
 
Example 11
Project: lams   File: AnnotationBinder.java   Source Code and License 6 votes vote down vote up
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;
	}
 
Example 12
Project: spring-data-jdbc-template   File: EntityUtils.java   Source Code and License 6 votes vote down vote up
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;
    }
 
Example 13
Project: wangmarket   File: Log.java   Source Code and License 5 votes vote down vote up
@Id
@GeneratedValue(strategy = IDENTITY)
@Column(name = "id", unique = true, nullable = false)
public Integer getId() {
	return id;
}
 
Example 14
Project: lemon   File: OrgPosition.java   Source Code and License 5 votes vote down vote up
/** @return null. */
@Id
@GeneratedValue
@Column(name = "ID", unique = true, nullable = false)
public Long getId() {
    return this.id;
}
 
Example 15
Project: Equella   File: LanguageString.java   Source Code and License 5 votes vote down vote up
@Override
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
public long getId()
{
	return id;
}
 
Example 16
Project: lams   File: AnnotationBinder.java   Source Code and License 5 votes vote down vote up
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() );
	}
}
 
Example 17
Project: lams   File: JPAOverriddenAnnotationReader.java   Source Code and License 5 votes vote down vote up
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;
	}
}
 
Example 18
Project: sjk   File: App.java   Source Code and License 5 votes vote down vote up
@Override
@Id
@GeneratedValue(strategy = IDENTITY)
@Column(name = "Id", unique = true, nullable = false)
public Integer getId() {
    return this.id;
}
 
Example 19
Project: tinyshop8   File: GoodsBrand8JPA.java   Source Code and License 5 votes vote down vote up
@Column(name = "brand_id")
@Override
@Id
@GeneratedValue
public Long getId()
{
    return super.getId();
}
 
Example 20
Project: uckefu   File: Fans.java   Source Code and License 5 votes vote down vote up
@Id
@Column(length = 32)
@GeneratedValue(generator = "system-uuid")
@GenericGenerator(name = "system-uuid", strategy = "uuid")	
public String getId() {
	return id;
}
 
Example 21
Project: uckefu   File: Message.java   Source Code and License 5 votes vote down vote up
@Id
@Column(length = 32)
@GeneratedValue(generator = "system-uuid")
@GenericGenerator(name = "system-uuid", strategy = "uuid")	
public String getId() {
	return id;
}
 
Example 22
Project: uckefu   File: TopicComment.java   Source Code and License 5 votes vote down vote up
@Id
@Column(length = 32)
@GeneratedValue(generator = "system-uuid")
@GenericGenerator(name = "system-uuid", strategy = "uuid")	
public String getId() {
	return id;
}
 
Example 23
Project: uckefu   File: User.java   Source Code and License 5 votes vote down vote up
/**
 * @return the id
 */
@Id
@Column(length = 32)
@GeneratedValue(generator = "system-uuid")
@GenericGenerator(name = "system-uuid", strategy = "uuid")	
public String getId() {
	return id;
}
 
Example 24
Project: JavaEE   File: Bid.java   Source Code and License 5 votes vote down vote up
/**
 * Returns the bid id
 * @return bid id
 */
@Id
@GeneratedValue
@Column(name="BID_ID")
public Long getBidId() {
    return bidId;
}
 
Example 25
Project: DWSurvey   File: IdLongEntity.java   Source Code and License 5 votes vote down vote up
@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;
}
 
Example 26
Project: tianti   File: MysqlSequenceIdEntity.java   Source Code and License 5 votes vote down vote up
@Id
@Column(length = 32, nullable = true)
@GenericGenerator(name = "sys_uuid", strategy = "uuid")
@GeneratedValue(generator = "sys_uuid")
public String getId() {
	return id;
}
 
Example 27
Project: hibernateMaster   File: Power.java   Source Code and License 5 votes vote down vote up
@Id
@GenericGenerator(name="generator",strategy="assigned")
@GeneratedValue(generator="generator")
@Column(length=32)
public String getName() {
	return name;
}
 
Example 28
Project: jeesupport   File: TabA.java   Source Code and License 5 votes vote down vote up
@GenericGenerator ( name = "generator" , strategy = "identity" )
@Id
@GeneratedValue ( generator = "generator" )

@Column ( name = "id" , unique = true , nullable = false )

public Integer getId() {
	return this.id;
}
 
Example 29
Project: crud-admin-spring-boot-starter   File: CrudAdminRepository.java   Source Code and License 4 votes vote down vote up
public boolean isGeneratedId() {
	return getId().isAnnotationPresent(GeneratedValue.class);
}
 
Example 30
Project: sjk   File: MoViewTagApps.java   Source Code and License 4 votes vote down vote up
@Id
@GeneratedValue(strategy = IDENTITY)
@Column(name = "Id", unique = true, nullable = false)
public Integer getId() {
    return this.id;
}
 
Example 31
Project: incubator-netbeans   File: Order.java   Source Code and License 4 votes vote down vote up
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
public Long getId() {
    return id;
}
 
Example 32
Project: incubator-netbeans   File: Employee.java   Source Code and License 4 votes vote down vote up
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
public Long getId() {
    return id;
}
 
Example 33
Project: wangmarket   File: PostClass.java   Source Code and License 4 votes vote down vote up
@Id
@GeneratedValue(strategy = IDENTITY)
@Column(name = "id", unique = true, nullable = false)
public Integer getId() {
	return this.id;
}
 
Example 34
Project: Spring-5.0-Cookbook   File: Employee.java   Source Code and License 4 votes vote down vote up
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
public Integer getId() {
	return id;
}
 
Example 35
Project: sjk   File: Keyword.java   Source Code and License 4 votes vote down vote up
@Id
@GeneratedValue(strategy = IDENTITY)
@Column(name = "Id", unique = true, nullable = false)
public Integer getId() {
    return this.id;
}
 
Example 36
Project: sjk   File: CatalogConvertor.java   Source Code and License 4 votes vote down vote up
@Id
@GeneratedValue(strategy = IDENTITY)
@Column(name = "Id", unique = true, nullable = false)
public Integer getId() {
    return this.id;
}
 
Example 37
Project: wangmarket   File: TemplateVar.java   Source Code and License 4 votes vote down vote up
@Id
@GeneratedValue(strategy = IDENTITY)
@Column(name = "id", unique = true, nullable = false)
public Integer getId() {
	return id;
}
 
Example 38
Project: Spring-5.0-Cookbook   File: Employee.java   Source Code and License 4 votes vote down vote up
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
public Integer getId() {
	return id;
}
 
Example 39
Project: Spring-5.0-Cookbook   File: LoginDetails.java   Source Code and License 4 votes vote down vote up
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
public Integer getId() {
	return id;
}
 
Example 40
Project: Spring-5.0-Cookbook   File: UserDetails.java   Source Code and License 4 votes vote down vote up
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
public Integer getId() {
	return id;
}
 
Example 41
Project: Spring-5.0-Cookbook   File: LoginDetails.java   Source Code and License 4 votes vote down vote up
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
public Integer getId() {
	return id;
}
 
Example 42
Project: sjk   File: MonApp.java   Source Code and License 4 votes vote down vote up
@Id
@GeneratedValue(strategy = IDENTITY)
@Column(name = "Id", unique = true, nullable = false)
public Integer getId() {
    return this.id;
}
 
Example 43
Project: Spring-5.0-Cookbook   File: Employee.java   Source Code and License 4 votes vote down vote up
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
public Integer getId() {
	return id;
}
 
Example 44
Project: Spring-5.0-Cookbook   File: Department.java   Source Code and License 4 votes vote down vote up
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
public Integer getId() {
	return id;
}
 
Example 45
Project: sjk   File: Market.java   Source Code and License 4 votes vote down vote up
@Id
@GeneratedValue(strategy = IDENTITY)
@Column(name = "Id", unique = true, nullable = false)
public Integer getId() {
    return this.id;
}
 
Example 46
Project: bootstrap   File: CsvJpaReader.java   Source Code and License 4 votes vote down vote up
/**
 * Indicates this field is using a auto generated key or not.
 */
private boolean isRowNumber(final Field jpaField, final String propertyName) {
	return getField(jpaField.getType(), propertyName).getAnnotation(GeneratedValue.class) != null;
}
 
Example 47
Project: sjk   File: Catalog.java   Source Code and License 4 votes vote down vote up
@Id
@GeneratedValue(strategy = IDENTITY)
@Column(name = "Id", unique = true, nullable = false)
public Integer getId() {
    return this.id;
}
 
Example 48
Project: Spring-5.0-Cookbook   File: UserDetails.java   Source Code and License 4 votes vote down vote up
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
public Integer getId() {
	return id;
}
 
Example 49
Project: Spring-5.0-Cookbook   File: Department.java   Source Code and License 4 votes vote down vote up
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
public Integer getId() {
	return id;
}
 
Example 50
Project: sjk   File: AppHistory4Index.java   Source Code and License 4 votes vote down vote up
@Id
@GeneratedValue(strategy = IDENTITY)
@Column(name = "Id", unique = true, nullable = false)
public Integer getId() {
    return this.id;
}
 
Example 51
Project: Spring-5.0-Cookbook   File: Employee.java   Source Code and License 4 votes vote down vote up
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
public Integer getId() {
	return id;
}
 
Example 52
Project: sjk   File: DownloadOfApp.java   Source Code and License 4 votes vote down vote up
@Id
@GeneratedValue(strategy = IDENTITY)
@Column(name = "Id", unique = true, nullable = false)
public Integer getId() {
    return id;
}
 
Example 53
Project: wangmarket   File: FriendLog.java   Source Code and License 4 votes vote down vote up
@Id
@GeneratedValue(strategy = IDENTITY)
@Column(name = "id", unique = true, nullable = false)
public Integer getId() {
	return this.id;
}
 
Example 54
Project: oasp-tutorial-sources   File: ApplicationPersistenceEntity.java   Source Code and License 4 votes vote down vote up
@Override
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
public Long getId() {

  return this.id;
}
 
Example 55
Project: Spring-5.0-Cookbook   File: LoginDetails.java   Source Code and License 4 votes vote down vote up
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
public Integer getId() {
	return id;
}
 
Example 56
Project: Spring-5.0-Cookbook   File: Employee.java   Source Code and License 4 votes vote down vote up
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
public Integer getId() {
	return id;
}
 
Example 57
Project: DocIT   File: Company.java   Source Code and License 4 votes vote down vote up
@Id
@GeneratedValue(strategy=IDENTITY)
@Column(name="id", unique=true, nullable=false)
public Long getId() {
    return this.id;
}
 
Example 58
Project: photoiff   File: Diretorio.java   Source Code and License 4 votes vote down vote up
@Id
@GeneratedValue
public Long getId() {
	return id;
}
 
Example 59
Project: DocIT   File: Department.java   Source Code and License 4 votes vote down vote up
@Id
@GeneratedValue(strategy=IDENTITY)
@Column(name="id", unique=true, nullable=false)
public Long getId() {
    return this.id;
}
 
Example 60
Project: wangmarket   File: Exchange.java   Source Code and License 4 votes vote down vote up
@Id
@GeneratedValue(strategy = IDENTITY)
@Column(name = "id", unique = true, nullable = false)
public Integer getId() {
	return id;
}