Java Code Examples for javax.persistence.Id

The following are top voted examples for showing how to use javax.persistence.Id. 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: wangmarket   File: User.java   View source code 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 2
Project: uckefu   File: TopicView.java   View source code 6 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 3
Project: lams   File: JPAOverriddenAnnotationReader.java   View source code 6 votes vote down vote up
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 );
}
 
Example 4
Project: FastSQL   File: EntityRefelectUtils.java   View source code 6 votes vote down vote up
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);
}
 
Example 5
Project: tinyshop8   File: User8JPA.java   View source code 5 votes vote down vote up
@Id
@GeneratedValue
@Override
public Long getId()
{
    return super.getId();
}
 
Example 6
Project: hibernateMaster   File: Power.java   View source code 5 votes vote down vote up
@Id
@GenericGenerator(name="generator",strategy="assigned")
@GeneratedValue(generator="generator")
@Column(length=32)
public String getName() {
	return name;
}
 
Example 7
Project: lams   File: JPAOverriddenAnnotationReader.java   View source code 5 votes vote down vote up
/**
 * 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 ) );
	}
}
 
Example 8
Project: tinyshop8   File: GoodsBrand8JPA.java   View source code 5 votes vote down vote up
@Column(name = "brand_id")
@Override
@Id
@GeneratedValue
public Long getId()
{
    return super.getId();
}
 
Example 9
Project: wangmarket   File: Log.java   View source code 5 votes vote down vote up
@Id
@GeneratedValue(strategy = IDENTITY)
@Column(name = "id", unique = true, nullable = false)
public Integer getId() {
	return id;
}
 
Example 10
Project: Hotel-Properties-Management-System   File: Payment.java   View source code 5 votes vote down vote up
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;
}
 
Example 11
Project: hibernateMaster   File: DomainUtil.java   View source code 5 votes vote down vote up
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;
}
 
Example 12
Project: Hotel-Properties-Management-System   File: User.java   View source code 5 votes vote down vote up
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;
}
 
Example 13
Project: GitHub   File: Order.java   View source code 4 votes vote down vote up
@Id @GeneratedValue(strategy=IDENTITY)

@Column(name="orderNumber", unique=true, nullable=false)
public Integer getOrderNumber() {
    return this.orderNumber;
}
 
Example 14
Project: sjk   File: Metro.java   View source code 4 votes vote down vote up
@Id
@GeneratedValue(strategy = IDENTITY)
@Column(name = "Id", unique = true, nullable = false)
public Integer getId() {
    return this.id;
}
 
Example 15
Project: lemon   File: PermType.java   View source code 4 votes vote down vote up
/** @return 主键. */
@Id
@Column(name = "ID", unique = true, nullable = false)
public Long getId() {
    return this.id;
}
 
Example 16
Project: lemon   File: AccountOnline.java   View source code 4 votes vote down vote up
/** @return null. */
@Id
@Column(name = "ID", unique = true, nullable = false)
public Long getId() {
    return this.id;
}
 
Example 17
Project: lemon   File: TicketCatalog.java   View source code 4 votes vote down vote up
/** @return null. */
@Id
@Column(name = "ID", unique = true, nullable = false)
public Long getId() {
    return this.id;
}
 
Example 18
Project: lemon   File: SendmailAttachment.java   View source code 4 votes vote down vote up
/** @return null. */
@Id
@Column(name = "ID", unique = true, nullable = false)
public Long getId() {
    return this.id;
}
 
Example 19
Project: incubator-netbeans   File: Employee.java   View source code 4 votes vote down vote up
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
public Long getId() {
    return id;
}
 
Example 20
Project: lemon   File: BpmConfForm.java   View source code 4 votes vote down vote up
/** @return 主键. */
@Id
@Column(name = "ID", unique = true, nullable = false)
public Long getId() {
    return this.id;
}
 
Example 21
Project: Hibernate_HQL_UniqueResult_ExecuteUpdate_CopyData_Delete_Update   File: newMall.java   View source code 4 votes vote down vote up
@Id 
@Column(name="ID")
public int getMallid() {
	return mallid;
}
 
Example 22
Project: lemon   File: OfficesupplyInfo.java   View source code 4 votes vote down vote up
/** @return null. */
@Id
@Column(name = "ID", unique = true, nullable = false)
public Long getId() {
    return this.id;
}
 
Example 23
Project: lemon   File: PlmIssue.java   View source code 4 votes vote down vote up
/** @return null. */
@Id
@Column(name = "ID", unique = true, nullable = false)
public Long getId() {
    return this.id;
}
 
Example 24
Project: tap17-muggl-javaee   File: CustomerOrder.java   View source code 4 votes vote down vote up
@Id
public int getOrderId() {
    return orderId;
}
 
Example 25
Project: lemon   File: PortalRef.java   View source code 4 votes vote down vote up
/** @return null. */
@Id
@Column(name = "ID", unique = true, nullable = false)
public Long getId() {
    return this.id;
}
 
Example 26
Project: sjk   File: MonApp.java   View source code 4 votes vote down vote up
@Id
@GeneratedValue(strategy = IDENTITY)
@Column(name = "Id", unique = true, nullable = false)
public Integer getId() {
    return this.id;
}
 
Example 27
Project: lemon   File: WhitelistInfo.java   View source code 4 votes vote down vote up
/** @return null. */
@Id
@Column(name = "ID", unique = true, nullable = false)
public Long getId() {
    return this.id;
}
 
Example 28
Project: sjk   File: Market.java   View source code 4 votes vote down vote up
@Id
@GeneratedValue(strategy = IDENTITY)
@Column(name = "Id", unique = true, nullable = false)
public Integer getId() {
    return this.id;
}
 
Example 29
Project: lemon   File: PortalWidget.java   View source code 4 votes vote down vote up
/** @return null. */
@Id
@Column(name = "ID", unique = true, nullable = false)
public Long getId() {
    return this.id;
}
 
Example 30
Project: lemon   File: DoorInfo.java   View source code 4 votes vote down vote up
/** @return null. */
@Id
@Column(name = "ID", unique = true, nullable = false)
public Long getId() {
    return this.id;
}
 
Example 31
Project: Spring-5.0-Cookbook   File: Department.java   View source code 4 votes vote down vote up
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
public Integer getId() {
	return id;
}
 
Example 32
Project: sjk   File: AndroidApp.java   View source code 4 votes vote down vote up
@Id
@GeneratedValue(strategy = IDENTITY)
@Column(name = "ID", unique = true, nullable = false)
public Integer getId() {
    return this.id;
}
 
Example 33
Project: lemon   File: AccountLockLog.java   View source code 4 votes vote down vote up
/** @return null. */
@Id
@Column(name = "ID", unique = true, nullable = false)
public Long getId() {
    return this.id;
}
 
Example 34
Project: Spring-5.0-Cookbook   File: Employee.java   View source code 4 votes vote down vote up
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
public Integer getId() {
	return id;
}
 
Example 35
Project: lemon   File: JavamailAttachment.java   View source code 4 votes vote down vote up
/** @return null. */
@Id
@Column(name = "ID", unique = true, nullable = false)
public Long getId() {
    return this.id;
}
 
Example 36
Project: Spring-5.0-Cookbook   File: Department.java   View source code 4 votes vote down vote up
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
public Integer getId() {
	return id;
}
 
Example 37
Project: sjk   File: App.java   View source code 4 votes vote down vote up
@Id
@GeneratedValue(strategy = IDENTITY)
@Column(name = "Id", unique = true, nullable = false)
public int getId() {
    return id;
}
 
Example 38
Project: lemon   File: OrgDepartment.java   View source code 4 votes vote down vote up
/** @return null. */
@Id
@Column(name = "ID", unique = true, nullable = false)
public Long getId() {
    return this.id;
}
 
Example 39
Project: lemon   File: PimPlan.java   View source code 4 votes vote down vote up
/** @return null. */
@Id
@Column(name = "ID", unique = true, nullable = false)
public Long getId() {
    return this.id;
}
 
Example 40
Project: Spring-5.0-Cookbook   File: Employee.java   View source code 4 votes vote down vote up
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
public Integer getId() {
	return id;
}