[英]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.