當前位置: 首頁>>代碼示例>>Java>>正文


Java Id類代碼示例

本文整理匯總了Java中javax.persistence.Id的典型用法代碼示例。如果您正苦於以下問題:Java Id類的具體用法?Java Id怎麽用?Java Id使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


Id類屬於javax.persistence包,在下文中一共展示了Id類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: getId

import javax.persistence.Id; //導入依賴的package包/類
/**
 * 用戶id
 * @return
 */
@Id
@GeneratedValue(strategy = IDENTITY)
@Column(name = "id", unique = true, nullable = false)
public Integer getId() {
	return this.id;
}
 
開發者ID:xnx3,項目名稱:wangmarket,代碼行數:11,代碼來源:User.java

示例2: getId

import javax.persistence.Id; //導入依賴的package包/類
@Id
@Column(length = 32)
@GeneratedValue(generator = "system-uuid")
@GenericGenerator(name = "system-uuid", strategy = "uuid")	
public String getId() {
	return id;
}
 
開發者ID:uckefu,項目名稱:uckefu,代碼行數:8,代碼來源:TopicView.java

示例3: isProcessingId

import javax.persistence.Id; //導入依賴的package包/類
private boolean isProcessingId(XMLContext.Default defaults) {
	boolean isExplicit = defaults.getAccess() != null;
	boolean correctAccess =
			( PropertyType.PROPERTY.equals( propertyType ) && AccessType.PROPERTY.equals( defaults.getAccess() ) )
					|| ( PropertyType.FIELD.equals( propertyType ) && AccessType.FIELD
					.equals( defaults.getAccess() ) );
	boolean hasId = defaults.canUseJavaAnnotations()
			&& ( isPhysicalAnnotationPresent( Id.class ) || isPhysicalAnnotationPresent( EmbeddedId.class ) );
	//if ( properAccessOnMetadataComplete || properOverridingOnMetadataNonComplete ) {
	boolean mirrorAttributeIsId = defaults.canUseJavaAnnotations() &&
			( mirroredAttribute != null &&
					( mirroredAttribute.isAnnotationPresent( Id.class )
							|| mirroredAttribute.isAnnotationPresent( EmbeddedId.class ) ) );
	boolean propertyIsDefault = PropertyType.PROPERTY.equals( propertyType )
			&& !mirrorAttributeIsId;
	return correctAccess || ( !isExplicit && hasId ) || ( !isExplicit && propertyIsDefault );
}
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:18,代碼來源:JPAOverriddenAnnotationReader.java

示例4: getIdField

import javax.persistence.Id; //導入依賴的package包/類
public static Field getIdField(Object object) {
    List<Field> fieldList = new ArrayList<>();
    Field[] declaredFields = object.getClass().getDeclaredFields();

    for (Field field : declaredFields) {
        if (field.isAnnotationPresent(Id.class)) {
            fieldList.add(field);
        }
    }
    if (fieldList.size() == 0) {
        throw new RuntimeException(object.getClass().getSimpleName() + "實體類必須有一個包含@Id的字段");
    }
    if (fieldList.size() > 1) {
        throw new RuntimeException(object.getClass().getSimpleName() + "實體類必須有一個包含@Id的字段");
    }
    return fieldList.get(0);
}
 
開發者ID:fast-sql,項目名稱:FastSQL,代碼行數:18,代碼來源:EntityRefelectUtils.java

示例5: getId

import javax.persistence.Id; //導入依賴的package包/類
@Id
@GeneratedValue
@Override
public Long getId()
{
    return super.getId();
}
 
開發者ID:SessionFactory,項目名稱:tinyshop8,代碼行數:8,代碼來源:User8JPA.java

示例6: getName

import javax.persistence.Id; //導入依賴的package包/類
@Id
@GenericGenerator(name="generator",strategy="assigned")
@GeneratedValue(generator="generator")
@Column(length=32)
public String getName() {
	return name;
}
 
開發者ID:battlesteed,項目名稱:hibernateMaster,代碼行數:8,代碼來源:Power.java

示例7: getAssociationId

import javax.persistence.Id; //導入依賴的package包/類
/**
 * Adds an @Id annotation to the specified annotationList if the specified element has the id
 * attribute set to true. This should only be the case for many-to-one or one-to-one
 * associations.
 */
private void getAssociationId(List<Annotation> annotationList, Element element) {
	String attrVal = element.attributeValue( "id" );
	if ( "true".equals( attrVal ) ) {
		AnnotationDescriptor ad = new AnnotationDescriptor( Id.class );
		annotationList.add( AnnotationFactory.create( ad ) );
	}
}
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:13,代碼來源:JPAOverriddenAnnotationReader.java

示例8: getId

import javax.persistence.Id; //導入依賴的package包/類
@Column(name = "brand_id")
@Override
@Id
@GeneratedValue
public Long getId()
{
    return super.getId();
}
 
開發者ID:SessionFactory,項目名稱:tinyshop8,代碼行數:9,代碼來源:GoodsBrand8JPA.java

示例9: getId

import javax.persistence.Id; //導入依賴的package包/類
@Id
@GeneratedValue(strategy = IDENTITY)
@Column(name = "id", unique = true, nullable = false)
public Integer getId() {
	return id;
}
 
開發者ID:xnx3,項目名稱:wangmarket,代碼行數:7,代碼來源:Log.java

示例10: Payment

import javax.persistence.Id; //導入依賴的package包/類
public Payment(long Id, String title, String paymentType, String price, String currency, String explanation,
		String theRoomNumber, String dateTime) {
	super();
	this.id = Id;
	this.title = title;
	this.paymentType = paymentType;
	this.price = price;
	this.currency = currency;
	this.explanation = explanation;
	this.roomNumber = theRoomNumber;
	this.dateTime = dateTime;
}
 
開發者ID:Coder-ACJHP,項目名稱:Hotel-Properties-Management-System,代碼行數:13,代碼來源:Payment.java

示例11: createIDNotfoundException

import javax.persistence.Id; //導入依賴的package包/類
private static DomainIdAnnotationNotFoundException createIDNotfoundException(Class<? extends Object> clazz) {
	logger.error("在"+clazz.getName()+"中找不到含有"+Id.class.getName()+"注解的get方法,或字段。");
	DomainIdAnnotationNotFoundException exception = new DomainIdAnnotationNotFoundException("在"+
			clazz.getName()+"中找不到含有"+Id.class.getName()+"注解的get方法,或字段。");
	exception.printStackTrace();
	return exception;
}
 
開發者ID:battlesteed,項目名稱:hibernateMaster,代碼行數:8,代碼來源:DomainUtil.java

示例12: User

import javax.persistence.Id; //導入依賴的package包/類
public User(long id, String firstName, String lastName, String nickName, String password, String email,
		String role) {
	super();
	Id = id;
	FirstName = firstName;
	LastName = lastName;
	NickName = nickName;
	Password = password;
	Email = email;
	Role = role;
}
 
開發者ID:Coder-ACJHP,項目名稱:Hotel-Properties-Management-System,代碼行數:12,代碼來源:User.java

示例13: getOrderNumber

import javax.persistence.Id; //導入依賴的package包/類
@Id @GeneratedValue(strategy=IDENTITY)

@Column(name="orderNumber", unique=true, nullable=false)
public Integer getOrderNumber() {
    return this.orderNumber;
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:7,代碼來源:Order.java

示例14: getId

import javax.persistence.Id; //導入依賴的package包/類
@Id
@GeneratedValue(strategy = IDENTITY)
@Column(name = "Id", unique = true, nullable = false)
public Integer getId() {
    return this.id;
}
 
開發者ID:zhaoxi1988,項目名稱:sjk,代碼行數:7,代碼來源:Metro.java

示例15: getId

import javax.persistence.Id; //導入依賴的package包/類
/** @return 主鍵. */
@Id
@Column(name = "ID", unique = true, nullable = false)
public Long getId() {
    return this.id;
}
 
開發者ID:zhaojunfei,項目名稱:lemon,代碼行數:7,代碼來源:PermType.java


注:本文中的javax.persistence.Id類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。