javax.persistence.GenerationType Java Examples

The following examples show how to use javax.persistence.GenerationType. 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: SwedenElectionRegion.java    From cia with Apache License 2.0 5 votes vote down vote up
/**
* Gets the hjid.
*
* @return the hjid
*/
  @Id
  @Column(name = "HJID")
  @GeneratedValue(strategy = GenerationType.AUTO)
  public Long getHjid() {
      return hjid;
  }
 
Example #2
Source File: PersonContainerElement.java    From cia with Apache License 2.0 5 votes vote down vote up
/**
* Gets the hjid.
*
* @return the hjid
*/
  @Id
  @Column(name = "HJID")
  @GeneratedValue(strategy = GenerationType.AUTO)
  public Long getHjid() {
      return hjid;
  }
 
Example #3
Source File: DocumentStatusContainer.java    From cia with Apache License 2.0 5 votes vote down vote up
/**
* Gets the hjid.
*
* @return the hjid
*/
  @Id
  @Column(name = "HJID")
  @GeneratedValue(strategy = GenerationType.AUTO)
  public Long getHjid() {
      return hjid;
  }
 
Example #4
Source File: CommitteeProposalContainer.java    From cia with Apache License 2.0 5 votes vote down vote up
/**
* Gets the hjid.
*
* @return the hjid
*/
  @Id
  @Column(name = "HJID")
  @GeneratedValue(strategy = GenerationType.AUTO)
  public Long getHjid() {
      return hjid;
  }
 
Example #5
Source File: Instructor.java    From sample-java-spring-genericdao with Apache License 2.0 5 votes vote down vote up
@Id
@Column(name = "INSTRUCTOR_ID", unique = true, nullable = false)
@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "SEQ_INSTRUCTOR_ID")
@SequenceGenerator(name = "SEQ_INSTRUCTOR_ID", sequenceName = "SEQ_INSTRUCTOR_ID", allocationSize=1, initialValue=1)
public Integer getId() {
	return this.id;
}
 
Example #6
Source File: Log.java    From ankush with GNU Lesser General Public License v3.0 5 votes vote down vote up
/**
 * Gets the id.
 * 
 * @return the id
 */
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
@JsonIgnore
public Long getId() {
	return id;
}
 
Example #7
Source File: Classes.java    From sample-java-spring-genericdao with Apache License 2.0 5 votes vote down vote up
@Id
@Column(name = "CLASSES_ID", unique = true, nullable = false)
@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "SEQ_CLASSES_ID")
@SequenceGenerator(name = "SEQ_CLASSES_ID", sequenceName = "SEQ_CLASSES_ID", allocationSize=1, initialValue=1)
public Integer getId() {
	return this.id;
}
 
Example #8
Source File: SwedenParliamentElectoralRegionContainer.java    From cia with Apache License 2.0 5 votes vote down vote up
/**
* Gets the hjid.
*
* @return the hjid
*/
  @Id
  @Column(name = "HJID")
  @GeneratedValue(strategy = GenerationType.AUTO)
  public Long getHjid() {
      return hjid;
  }
 
Example #9
Source File: OracleLongEntity.java    From tianti with Apache License 2.0 5 votes vote down vote up
@Id
@SequenceGenerator(name = "ID_SEQ")
@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "ID_SEQ")
@Column(name = "ID", nullable = false)
public Long getId() {
	return id;
}
 
Example #10
Source File: CountryElement.java    From cia with Apache License 2.0 5 votes vote down vote up
/**
* Gets the hjid.
*
* @return the hjid
*/
  @Id
  @Column(name = "HJID")
  @GeneratedValue(strategy = GenerationType.AUTO)
  public Long getHjid() {
      return hjid;
  }
 
Example #11
Source File: DocumentDetailData.java    From cia with Apache License 2.0 5 votes vote down vote up
/**
* Gets the hjid.
*
* @return the hjid
*/
  @Id
  @Column(name = "HJID")
  @GeneratedValue(strategy = GenerationType.AUTO)
  public Long getHjid() {
      return hjid;
  }
 
Example #12
Source File: OrderItemEntity.java    From opensharding-spi-impl-example with Apache License 2.0 5 votes vote down vote up
@Id
@Column(name = "order_item_id")
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Override
public long getOrderItemId() {
    return super.getOrderItemId();
}
 
Example #13
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 #14
Source File: BinderHelper.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
@SuppressWarnings("ConstantConditions")
private static GenerationType interpretGenerationType(GeneratedValue generatedValueAnn) {
	if ( generatedValueAnn.strategy() == null ) {
		return GenerationType.AUTO;
	}

	return generatedValueAnn.strategy();
}
 
Example #15
Source File: OrderEntity.java    From opensharding-spi-impl-example with Apache License 2.0 5 votes vote down vote up
@Id
@Column(name = "order_id")
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Override
public long getOrderId() {
    return super.getOrderId();
}
 
Example #16
Source File: DocumentProposalData.java    From cia with Apache License 2.0 5 votes vote down vote up
/**
* Gets the hjid.
*
* @return the hjid
*/
  @Id
  @Column(name = "HJID")
  @GeneratedValue(strategy = GenerationType.AUTO)
  public Long getHjid() {
      return hjid;
  }
 
Example #17
Source File: Cluster.java    From uyuni with GNU General Public License v2.0 5 votes vote down vote up
/**
 * @return id to get
 */
@Id
@Column(name = "id")
@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "clust_seq")
@SequenceGenerator(name = "clust_seq", sequenceName = "suse_cluster_id_seq",
        allocationSize = 1)
public long getId() {
    return id;
}
 
Example #18
Source File: WorldBankData.java    From cia with Apache License 2.0 5 votes vote down vote up
/**
* Gets the hjid.
*
* @return the hjid
*/
  @Id
  @Column(name = "HJID")
  @GeneratedValue(strategy = GenerationType.AUTO)
  public Long getHjid() {
      return hjid;
  }
 
Example #19
Source File: ImageInfo.java    From uyuni with GNU General Public License v2.0 5 votes vote down vote up
/**
 * @return the id
 */
@Id
@Column(name = "id")
@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "imginfo_seq")
@SequenceGenerator(name = "imginfo_seq", sequenceName = "suse_imginfo_imgid_seq",
                   allocationSize = 1)
public Long getId() {
    return id;
}
 
Example #20
Source File: NotificationMessage.java    From uyuni with GNU General Public License v2.0 5 votes vote down vote up
/**
 * @return Returns the id.
 */
@Id
@Column(name = "id")
@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "nmsg_seq")
@SequenceGenerator(name = "nmsg_seq", sequenceName = "suse_notif_message_id_seq",
        allocationSize = 1)
public Long getId() {
    return id;
}
 
Example #21
Source File: ContentProject.java    From uyuni with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Gets the id.
 *
 * @return id
 */
@Id
@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "content_project_seq")
@SequenceGenerator(name = "content_project_seq", sequenceName = "suse_ct_project_seq", allocationSize = 1)
public Long getId() {
    return id;
}
 
Example #22
Source File: SwedenElectionType.java    From cia with Apache License 2.0 5 votes vote down vote up
/**
* Gets the hjid.
*
* @return the hjid
*/
  @Id
  @Column(name = "HJID")
  @GeneratedValue(strategy = GenerationType.AUTO)
  public Long getHjid() {
      return hjid;
  }
 
Example #23
Source File: Topics.java    From cia with Apache License 2.0 5 votes vote down vote up
/**
* Gets the hjid.
*
* @return the hjid
*/
  @Id
  @Column(name = "HJID")
  @GeneratedValue(strategy = GenerationType.AUTO)
  public Long getHjid() {
      return hjid;
  }
 
Example #24
Source File: EnvironmentTarget.java    From uyuni with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Gets the id.
 *
 * @return id
 */
@Id
@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "content_prj_env_target_seq")
@SequenceGenerator(name = "content_prj_env_target_seq", sequenceName = "suse_ct_env_tgt_seq", allocationSize = 1)
public Long getId() {
    return id;
}
 
Example #25
Source File: WebOfficeEntity.java    From jeewx with Apache License 2.0 5 votes vote down vote up
/**
 *方法: 取得java.lang.Integer
 *@return: java.lang.Integer  id
 */

@Id
@GeneratedValue(strategy = GenerationType.AUTO)
@Column(name ="ID",nullable=false,length=32)
public java.lang.Integer getId(){
	return this.id;
}
 
Example #26
Source File: SwedenElectionTypeContainerElement.java    From cia with Apache License 2.0 5 votes vote down vote up
/**
* Gets the hjid.
*
* @return the hjid
*/
  @Id
  @Column(name = "HJID")
  @GeneratedValue(strategy = GenerationType.AUTO)
  public Long getHjid() {
      return hjid;
  }
 
Example #27
Source File: UserDetails.java    From Spring-5.0-Cookbook with MIT License 4 votes vote down vote up
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
public Integer getId() {
	return id;
}
 
Example #28
Source File: EntityHelper.java    From azeroth with Apache License 2.0 4 votes vote down vote up
/**
 * 由传入的实体的class构建TableMapper对象,构建好的对象存入缓存中,以后使用时直接从缓存中获取
 *
 * @param entityClass
 * @return TableMapper
 */
public static EntityMapper getEntityMapper(Class<?> entityClass) {

    synchronized (entityClass) {
        // 先从map中获取实体映射信息
        EntityMapper entityMapper = tableMapperCache.get(entityClass);

        // 如果存在直接返回
        if (entityMapper != null) {
            return entityMapper;
        }

        TableMapper tableMapper = getTableMapper(entityClass);

        //获取实体ID泛型
        Class<?> idClass = getIdClass(entityClass);

        // 获取实体字段列表
        List<Field> fields = getAllField(entityClass);
        // 全部列
        Set<ColumnMapper> columnMapperSet = new HashSet<ColumnMapper>();
        // 主键
        ColumnMapper idColumn = null;
        GenerationType idStrategy = null;

        for (Field field : fields) {

            // 排除字段
            if (field.isAnnotationPresent(Transient.class)) {
                continue;
            }
            ColumnMapper columnMapper = new ColumnMapper();

            // 数据库字段名
            String columnName = null;
            if (field.isAnnotationPresent(Column.class)) {
                Column column = field.getAnnotation(Column.class);
                columnName = column.name();
                columnMapper.setInsertable(column.insertable());
                columnMapper.setUpdatable(column.updatable());
            }
            // 如果为空,使用属性名并替换为下划线风格
            if (columnName == null || columnName.equals("")) {
                columnName = camelhumpToUnderline(field.getName());
            }

            columnMapper.setProperty(field.getName());
            columnMapper.setColumn(columnName);
            columnMapper.setJavaType(field.getType());

            // 是否主键
            if (field.isAnnotationPresent(Id.class)) {
                columnMapper.setId(true);
                if (field.isAnnotationPresent(GeneratedValue.class)) {
                    idStrategy = field.getAnnotation(GeneratedValue.class).strategy();
                }
                idColumn = columnMapper;
            }
            // 添加到所有字段映射信息
            columnMapperSet.add(columnMapper);

        }
        if (columnMapperSet.size() <= 0) {
            throw new RuntimeException("实体" + entityClass.getName() + "不存在映射字段");
        }
        if (idColumn == null) {
            throw new RuntimeException("实体" + entityClass.getName() + "不存在主键或者");
        }

        // 解析实体映射信息
        entityMapper = new EntityMapper();
        entityMapper.setTableMapper(tableMapper);
        entityMapper.setColumnsMapper(columnMapperSet);
        entityMapper.setIdClass(idClass);
        entityMapper.setIdColumn(idColumn);
        entityMapper.setIdStrategy(idStrategy);

        tableMapperCache.put(entityClass, entityMapper);

        return entityMapper;
    }
}
 
Example #29
Source File: AdmUserAccess.java    From we-cmdb with Apache License 2.0 4 votes vote down vote up
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
public String getId() {
    return this.id;
}
 
Example #30
Source File: BookDetail.java    From Crawer with MIT License 4 votes vote down vote up
@Id
@GeneratedValue(strategy=GenerationType.IDENTITY)
public Integer getId() {
	return id;
}