Java Code Examples for javax.persistence.GenerationType#TABLE

The following examples show how to use javax.persistence.GenerationType#TABLE . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ChangeRecord.java    From juddi with Apache License 2.0 6 votes vote down vote up
@Id
@GeneratedValue(strategy = GenerationType.TABLE,
     generator = "personGen")
@TableGenerator(name = "personGen",
     table = "JPAGEN_GENERATORS",
     pkColumnName = "NAME",
     pkColumnValue = "JPAGEN_PERSON_GEN",
     valueColumnName = "VALUE")
public Long getId() {
        return id;
}
 
Example 2
Source File: Menu.java    From dpCms with Apache License 2.0 5 votes vote down vote up
@Id
@Column(name = "ID", unique = true, nullable = false, length = 19)
@GeneratedValue(strategy = GenerationType.TABLE, generator = "table")
@GenericGenerator(name = "table", strategy = "org.hibernate.id.MultipleHiLoPerTableGenerator", parameters = {
		@Parameter(name = "max_lo", value = "5") })//增长级别为5,可根据并发级别适当调整
public Long getId() {
	return this.id;
}
 
Example 3
Source File: IdUtils.java    From jdbctemplatetool with Apache License 2.0 5 votes vote down vote up
/**
 * 根据注解获取自增主键字段名
 * 如果没找到就返回空字符串
 * @param po
 * @return increamentIdFieldName
 * @throws NoSuchMethodException 
 * @throws SecurityException 
 */
public static String getAutoGeneratedId(Object po) throws SecurityException, NoSuchMethodException{
	String autoGeneratedId = "";
	//根据注解获取自增主键字段名
	Field[] allFields = po.getClass().getDeclaredFields();
	for(Field f:allFields){
		
		if("serialVersionUID".equals(f.getName())){
			continue;
		}
		
		//获取getter方法
		String getterName = "get" + StringUtils.capitalize(f.getName());
		Method getter = po.getClass().getDeclaredMethod(getterName);
		
		Id idAnno = getter.getAnnotation(Id.class);
		if(idAnno == null){
			continue;
		}
		GeneratedValue generatedValueAnno = getter.getAnnotation(GeneratedValue.class);
		if(generatedValueAnno == null){
			continue;
		}
		
		if(GenerationType.IDENTITY == generatedValueAnno.strategy() || GenerationType.TABLE == generatedValueAnno.strategy()){
			autoGeneratedId = f.getName();
			break;
		}
	}
	return autoGeneratedId;
}
 
Example 4
Source File: Album.java    From aws-photosharing-example with Apache License 2.0 4 votes vote down vote up
@Id
@GeneratedValue(strategy = GenerationType.TABLE)    
public Long getId() {return id;}
 
Example 5
Source File: Share.java    From aws-photosharing-example with Apache License 2.0 4 votes vote down vote up
@Id
@GeneratedValue(strategy = GenerationType.TABLE)    
public Long getId() {return id;}
 
Example 6
Source File: User.java    From aws-photosharing-example with Apache License 2.0 4 votes vote down vote up
@Id
@GeneratedValue(strategy = GenerationType.TABLE)
@Column(name="user_id")
public Long getId() {return id;}
 
Example 7
Source File: Media.java    From aws-photosharing-example with Apache License 2.0 4 votes vote down vote up
@Id
@GeneratedValue(strategy = GenerationType.TABLE)
@Column(name = "media_id", nullable = false, unique = true, length = 11)
public Long getId() {return id;}