2
我有2个实体类ParameterGroupBean和GroupLevelBeanHibernate映射异常
import javax.persistence.*;
import java.util.ArrayList;
import java.util.Collection;
@Entity
@Table(name="tbl_ParameterGroups")
public class ParameterGroupBean {
@Id
@GeneratedValue
private int ParameterGroupId;
private String ParameterGroupName;
private Boolean Status;
@ManyToOne
@JoinColumn(name="LevelId")
private GroupLevelBean level = new GroupLevelBean();
public GroupLevelBean getLevel() {
return level;
}
public void setLevel(GroupLevelBean level) {
this.level = level;
}
@Id
@GeneratedValue
public int getParameterGroupId() {
return ParameterGroupId;
}
public void setParameterGroupId(int parameterGroupId) {
ParameterGroupId = parameterGroupId;
}
@Column(length=120)
public String getParameterGroupName() {
return ParameterGroupName;
}
public void setParameterGroupName(String parameterGroupName) {
ParameterGroupName = parameterGroupName;
}
public Boolean getStatus() {
return Status;
}
public void setStatus(Boolean Status) {
this.Status = Status;
}
}
GroupLevelBean:
import javax.persistence.*;
import java.util.ArrayList;
import java.util.Collection;
@Entity
@Table(name="tbl_GroupLevel")
public class GroupLevelBean {
private int LevelId;
private String LevelName;
@OneToMany(mappedBy = "level")
private Collection<ParameterGroupBean> parameterGroups = new ArrayList<ParameterGroupBean>();
public Collection<ParameterGroupBean> getParameterGroups() {
return parameterGroups;
}
public void setParameterGroups(Collection<ParameterGroupBean> parameterGroups) {
this.parameterGroups = parameterGroups;
}
@Id
@GeneratedValue
public int getLevelId() {
return LevelId;
}
public void setLevelId(int levelId) {
LevelId = levelId;
}
@Column(length = 30)
public String getLevelName() {
return LevelName;
}
public void setLevelName(String levelName) {
LevelName = levelName;
}
}
GroupLevelBean和ParameterGroupBean之间的关系是一对多。 我收到一个异常,当我尝试创建会话对象。
org.hibernate.MappingException:无法确定类型:com.vrde.daems.bean.GroupLevelBean,在表:tbl_ParameterGroups,对于列:[org.hibernate.mapping.Column(水平)]
谁能告诉我有什么问题?
注释干将或注释字段,但不是两者。 –
@StevenBenitez这就是我所说的。 :) –
种,是的。我更喜欢注释吸气剂,我只是想开车回家,这是可以接受的。你的回答似乎有利于这些领域。 :) –