hibernate 主键为String处理Entity

package lic.grant.entity;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.Table;

import org.hibernate.annotations.GenericGenerator;

@Entity
@Table(name="licUser")
public class LicUser {
    /*
     *   userid character varying(100) NOT NULL, -- 用户ID(账号)
         username character varying(100), -- 姓名
           passwd character varying(100), -- 密码
         permission smallint, -- 权限 0代表管理员 1代表普通用户
         email character varying(100), -- 电子邮箱
     */

private String userid;
private String username;
private String passwd;
private int permission;
private String email;

@Id
@GeneratedValue(generator ="ud")
@GenericGenerator(name="ud", strategy = "assigned")
@Column(name = "userid", nullable = false)
public String getUserid() {
    return userid;
}

public void setUserid(String userid) {
    this.userid = userid;
}
@Column(name = "username", nullable = false, length = 100)
public String getUsername() {
    return username;
}

public void setUsername(String username) {
    this.username = username;
}
@Column(name = "passwd", nullable = false, length = 100)
public String getPasswd() {
    return passwd;
}

public void setPasswd(String passwd) {
    this.passwd = passwd;
}
@Column(name = "permission", nullable = false)
public int getPermission() {
    return permission;
}

public void setPermission(int permission) {
    this.permission = permission;
}
@Column(name = "email", nullable = false, length = 100)
public String getEmail() {
    return email;
}

public void setEmail(String email) {
    this.email = email;
}
}

你可能感兴趣的:(java学习)