簡體   English   中英

生成持久性映射->通過休眠映射不可用Intellij

[英]Generate persistence mappings -> by hibernate mappings not available Intellij

我是Hibernate的新手,正在嘗試創建以下類,現在我想為其生成hibernate映射。

package com.simpleprogrammer;

public class User {

    private int id;
    private String name;
    private int total;
    private int goal;

    public int getId() {
        return id;
    }
    public void setId(int id) {
        this.id = id;
    }
    public int getGoal() {
        return goal;
    }
    public void setGoal(int goal) {
        this.goal = goal;
    }
    public int getTotal() {
        return total;
    }
    public void setTotal(int total) {
        this.total = total;
    }
    public String getName() {
        return name;
    }
    public void setName(String name) {
        this.name = name;
    }
}

當我右鍵單擊Persistence時,我希望看到“ Generate Persistence Mappings”->“ By Hibernate Maps”可用。 但事實並非如此。 我只能看到“按數據庫模式”。 有人知道為什么“無法使用休眠映射嗎?

如果需要或需要的話,將提供更多信息,我將遵循大約2年后使用Eclipse的多元視野課程,以使事情變得更加復雜!

您需要添加:

在課程開始時@Entity

@Entity
public class User {

    @Id
    private int id;
    ...

然后在關閉元素</session-factory>之前,將<mapping class="com.simpleprogrammer.User"/>hibernate.cfg.xml

還請確保將ID批注( @Id )添加到變量id。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM