有 Java 编程相关的问题?

你可以在下面搜索框中键入要查询的问题!

java Hibernate注释。如何注释?

我正在用JavaEE做一个小的库项目。我已经创建了3个表格和类,包括作者、流派和书籍。现在我正在尝试使用hibernate连接它,但我还不知道ide如何确认注释。。。请帮帮我:)

书桌:

|id|book |作者| id |标题|流派| id |描述|照片|

genreTable:

|类型| id |类型|

可编写:

|作者|作者|

结构简单:

书桌。作者id-可授权。作者_id=manytomy

书桌。genre_id-genreTable。类型_id=OneToOne

下面是我的pojo课程:

@Entity
@Table(name = "books")
public class Book implements Serializable{

    private static final long serialVersionUID = -5057364006691079475L;

    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    @Column(name = "user_id")
    private Integer user_id;
    private Author author;
    private String description;
    private BookGenre genre;
    private String title;


    public String getDescription() {
        return description;
    }

    public void setDescription(String description) {
        this.description = description;
    }

    public String getTitle() {
        return title;
    }

    public void setTitle(String title) {
        this.title = title;
    }

    public Integer getUser_id() {
        return user_id;
    }

    public void setUser_id(Integer user_id) {
        this.user_id = user_id;
    }

    public Author getAuthor() {
        return author;
    }

    public void setAuthor(Author author) {
        this.author = author;
    }

    public BookGenre getGenre() {
        return genre;
    }

    public void setGenre(BookGenre genre) {
        this.genre = genre;
    }

}

作者

@Entity
@Table(name = "author")
public class Author implements Serializable{

    private static final long serialVersionUID = 1L;

    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    @Column(name = "author_id")
    private Integer author_id;

    @Column(name = "author")
    private String author;  

    public Integer getAuthor_id() {
        return author_id;
    }

    public void setAuthor_id(Integer author_id) {
        this.author_id = author_id;
    }

    public String getAuthor() {
        return author;
    }

    public void setAuthor(String author) {
        this.author = author;
    }
}

体裁

@Entity
@Table(name = "genre")
public class BookGenre implements Serializable{

    private static final long serialVersionUID = 1L;

    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    @Column(name = "genre_id")
    private Integer genreId;

    @Column(name = "genre")
    private String genre;


    public Integer getGenreId() {
        return genreId;
    }
    public void setGenreId(Integer genreId) {
        this.genreId = genreId;
    }
    public String getGenre() {
        return genre;
    }
    public void setGenre(String genre) {
        this.genre = genre;
    }

}

共 (1) 个答案