程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
 程式師世界 >> 編程語言 >> 更多編程語言 >> 編程綜合問答 >> javase-我用netbeans生成了一個實體類,實體類上面的一堆注解都是干什麼的啊?

javase-我用netbeans生成了一個實體類,實體類上面的一堆注解都是干什麼的啊?

編輯:編程綜合問答
我用netbeans生成了一個實體類,實體類上面的一堆注解都是干什麼的啊?

上面那一大坨有實用價值嗎
這個是netbeans自動生成的實體類,不是Hibernate的

import java.io.Serializable;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.xml.bind.annotation.XmlRootElement;


@Entity
@Table(name = "DB_USER")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "DbUser.findAll", query = "SELECT d FROM DbUser d"),
    @NamedQuery(name = "DbUser.findById", query = "SELECT d FROM DbUser d WHERE d.id = :id"),
    @NamedQuery(name = "DbUser.findByName", query = "SELECT d FROM DbUser d WHERE d.name = :name"),
    @NamedQuery(name = "DbUser.findByPassword", query = "SELECT d FROM DbUser d WHERE d.password = :password"),
    @NamedQuery(name = "DbUser.findByLev", query = "SELECT d FROM DbUser d WHERE d.lev = :lev")})
public class DbUser implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @Basic(optional = false)
    @Column(name = "ID")
    private Integer id;
    @Column(name = "NAME")
    private String name;
    @Column(name = "PASSWORD")
    private String password;
    @Column(name = "LEV")
    private Integer lev;

    public DbUser() {
    }

    public DbUser(Integer id) {
        this.id = id;
    }

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    public Integer getLev() {
        return lev;
    }

    public void setLev(Integer lev) {
        this.lev = lev;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (id != null ? id.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof DbUser)) {
            return false;
        }
        DbUser other = (DbUser) object;
        if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "com.bean.DbUser[ id=" + id + " ]";
    }

}

最佳回答:


問答模塊應該整個自己可以刪除問題的按鈕

  1. 上一頁:
  2. 下一頁:
Copyright © 程式師世界 All Rights Reserved