CSDNRGY 2015-09-09 09:35 采纳率: 88.2%
浏览 2666
已采纳

我用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 + " ]";
    }

}

  • 写回答

5条回答 默认 最新

  • CSDNRGY 2015-09-10 06:21
    关注

    问答模块应该整个自己可以删除问题的按钮

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(4条)

报告相同问题?

悬赏问题

  • ¥15 PointNet++的onnx模型只能使用一次
  • ¥20 西南科技大学数字信号处理
  • ¥15 有两个非常“自以为是”烦人的问题急期待大家解决!
  • ¥30 STM32 INMP441无法读取数据
  • ¥15 R语言绘制密度图,一个密度曲线内fill不同颜色如何实现
  • ¥100 求汇川机器人IRCB300控制器和示教器同版本升级固件文件升级包
  • ¥15 用visualstudio2022创建vue项目后无法启动
  • ¥15 x趋于0时tanx-sinx极限可以拆开算吗
  • ¥500 把面具戴到人脸上,请大家贡献智慧,别用大模型回答,大模型的答案没啥用
  • ¥15 任意一个散点图自己下载其js脚本文件并做成独立的案例页面,不要作在线的,要离线状态。