Java Code Examples for javax.persistence.GenerationType#IDENTITY

The following examples show how to use javax.persistence.GenerationType#IDENTITY . 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: AccessibleProperty.java    From warpdb with Apache License 2.0 5 votes vote down vote up
boolean isIdentityId() {
	if (!isId()) {
		return false;
	}
	GeneratedValue gv = this.accessible.getAnnotation(GeneratedValue.class);
	if (gv == null) {
		return false;
	}
	GenerationType gt = gv.strategy();
	return gt == GenerationType.IDENTITY;
}
 
Example 2
Source File: Contact.java    From resteasy-examples with Apache License 2.0 5 votes vote down vote up
@Id
@Column(name = "id")
@GeneratedValue(strategy = GenerationType.IDENTITY)
@XmlAttribute(name = "contactId")
public Long getId() {
   return id;
}
 
Example 3
Source File: BaseDaoMysqlImpl.java    From Crawer with MIT License 5 votes vote down vote up
protected BaseDaoMysqlImpl(Class<T> persistentClass) {
	this.persistentClass = persistentClass;
	Table table = AnnotationUtils.findAnnotation(persistentClass,
			Table.class);
	if (table == null) {
		throw new RuntimeException(persistentClass + "没有定义@table");
	}
	this.tableName = table.name();
	BeanInfo beanInfo = null;
	try {
		beanInfo = Introspector.getBeanInfo(persistentClass);
	} catch (IntrospectionException e) {
		log.error(e.getMessage(), e);
	}
	PropertyDescriptor[] pds = beanInfo.getPropertyDescriptors();
	for (PropertyDescriptor pd : pds) {
		Id id = AnnotationUtils
				.findAnnotation(pd.getReadMethod(), Id.class);
		if (pk.equals("") && id != null) {
			pk = pd.getName();
			GeneratedValue gv = AnnotationUtils.findAnnotation(
					pd.getReadMethod(), GeneratedValue.class);
			if (gv == null) {
				strategy = GenerationType.IDENTITY;
			} else {
				strategy = gv.strategy();
			}
		}
		Transient transient_ = AnnotationUtils.findAnnotation(
				pd.getReadMethod(), Transient.class);
		if (transient_ != null) {
			transientPropertys.add(pd.getName());
		}
	}
	if ("".equals(this.getPk())) {
		throw new RuntimeException(persistentClass + "类型中没有在get方法上定义@Id");
	}
}
 
Example 4
Source File: User.java    From coditori with Apache License 2.0 4 votes vote down vote up
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "id")
public Long getId() {
	return id;
}
 
Example 5
Source File: SourceDTO.java    From singleton with Eclipse Public License 2.0 4 votes vote down vote up
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
public long getId() {
    return id;
}
 
Example 6
Source File: VersionTable.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 7
Source File: StringDTO.java    From singleton with Eclipse Public License 2.0 4 votes vote down vote up
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
public long getId() {
    return id;
}
 
Example 8
Source File: TestBasicEntity.java    From logging-log4j2 with Apache License 2.0 4 votes vote down vote up
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "id")
public long getId() {
    return this.id;
}
 
Example 9
Source File: AdmTemplateCiType.java    From we-cmdb with Apache License 2.0 4 votes vote down vote up
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "id_adm_template_citype")
public Integer getIdAdmTemplateCitype() {
    return this.idAdmTemplateCitype;
}
 
Example 10
Source File: IdEntity.java    From springside5 with Apache License 2.0 4 votes vote down vote up
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
public Long getId() {
	return id;
}
 
Example 11
Source File: AdmTemplateCiTypeAttr.java    From we-cmdb with Apache License 2.0 4 votes vote down vote up
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "id_adm_template_ci_type_attr")
public Integer getIdAdmTemplateCiTypeAttr() {
    return this.idAdmTemplateCiTypeAttr;
}
 
Example 12
Source File: Service.java    From SeaCloudsPlatform with Apache License 2.0 4 votes vote down vote up
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "id", unique = true, nullable = false)
public Long getId() {
    return id;
}
 
Example 13
Source File: AdmIntegrateTemplateAlias.java    From we-cmdb with Apache License 2.0 4 votes vote down vote up
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "id_alias")
public Integer getIdAlias() {
    return this.idAlias;
}
 
Example 14
Source File: AdmBasekeyCatType.java    From we-cmdb with Apache License 2.0 4 votes vote down vote up
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "id_adm_basekey_cat_type")
public Integer getIdAdmBasekeyCatType() {
    return this.idAdmBasekeyCatType;
}
 
Example 15
Source File: Book.java    From Crawer with MIT License 4 votes vote down vote up
@Id
@GeneratedValue(strategy=GenerationType.IDENTITY)
public Integer getId() {
	return id;
}
 
Example 16
Source File: ServiceProperties.java    From SeaCloudsPlatform with Apache License 2.0 4 votes vote down vote up
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "id", unique = true, nullable = false)
public Long getId() {
    return id;
}
 
Example 17
Source File: MCRDNBTRANSFERRESULTS.java    From mycore with GNU General Public License v3.0 4 votes vote down vote up
/**
 * @return the id
 */
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
public int getId() {
    return id;
}
 
Example 18
Source File: Variable.java    From SeaCloudsPlatform with Apache License 2.0 4 votes vote down vote up
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "name")
public String getName() {
    return name;
}
 
Example 19
Source File: AdmRoleUser.java    From we-cmdb with Apache License 2.0 4 votes vote down vote up
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "id_adm_role_user")
public Integer getIdAdmRoleUser() {
    return this.idAdmRoleUser;
}
 
Example 20
Source File: Variable.java    From SeaCloudsPlatform with Apache License 2.0 4 votes vote down vote up
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "id", unique = true, nullable = false)
public Long getId() {
    return id;
}