首页 \ 问答 \ Hibernate映射异常(Hibernate Mapping Exception)

Hibernate映射异常(Hibernate Mapping Exception)

我有2个Entity类ParameterGroupBean和GroupLevelBean

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(level)]

谁能告诉我这是什么问题?


I have 2 Entity classes ParameterGroupBean and GroupLevelBean

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;
}   
}

The relationship between GroupLevelBean and ParameterGroupBean is one to many. I am getting an exception when i try to create a session object.

org.hibernate.MappingException: Could not determine type for: com.vrde.daems.bean.GroupLevelBean, at table: tbl_ParameterGroups, for columns: [org.hibernate.mapping.Column(level)]

Can anyone tell me what is the problem?


原文:
更新时间:2022-02-01 14:02

最满意答案

在控制器中

@order = Order.find(params[:order_id])
@giftcard = @order.build_giftcard(gift_card_params)

In Controller

@order = Order.find(params[:order_id])
@giftcard = @order.build_giftcard(gift_card_params)

相关问答

更多
  • 调用.parents(".box .something1")将返回与选择器.box .something匹配的所有父元素。 换句话说,它将返回.something1父元素,并在.box 。 你需要得到最近的父母的孩子,像这样: $(this).closest('.box').children('.something1') 这个代码调用.closest来获取最内层的父选项符,然后在父元素上调用.closest来找到你要找的叔叔。 Calling .parents(".box .something1") wi ...
  • 如果子节点是父节点流根的一部分(即父元素包含子元素),那么您可以只注意父节点上的鼠标离开。 $(".bannerBottom").parent().on("mouseleave", function(event){ $(this).css({ 'transition': '1s', 'transform': 'rotateY(0deg)' }); }); (此外,没有必要从鼠标离开事件中搜索DOM(带有$(“#”+ var)) ...
  • 使用prepend()函数 例: $( ".parentClass" ).prepend( ".childClass" ); use prepend() function Example: $( ".parentClass" ).prepend( ".childClass" );
  • 也许我对OpenERP的识字能力不足以使这种关联正确发生,或者没有足够的相关文档,或者ORM不是为此用途(或这些的任何组合)设计的,但我需要按照我的要求工作现在确实如此。 如果它以任何方式令人反感,我道歉。 批评和建议总是受欢迎。 def create(self, cr, uid, vals, context=None): """Creates a new dbe.document instance. Called by both internal app and client. do ...
  • 您可以使用React.Children遍历组件的所有子React.Children 。 而且我们可以用React.clone(element,{ additionalProps })克隆每个孩子的附加道具。 在这里,我们检查孩子是否是一个按钮,并添加onClick道具。 render() { const {children} = this.props; var childrenWithProps = React.Children.map(children, child => { ...
  • 如果你的应用程序要比这个大得多,那么redux绝对是你的选择,你应该阅读它。 要做到这一点没有使用redux,你需要定义父组件状态中的所有字段,并将方法传递给子组以更新它们。 所以你可以做这样的事情: 亲 import Child from './Child'; class Parent extends React.Component { constructor(props) { super(props); this.state = { card ...
  • 您是否尝试使用put mapping API ? 为了测试它,我使用了你的映射: PUT /test_index { "mappings": { "parent": {}, "child": { "_parent": { "type": "parent" } }, "child1": { "_parent": { "type": "parent" ...
  • belongs_to :client, class_name: "Company", foreign_key: "id" 应该 belongs_to :client, class_name: "Company", foreign_key: "client_id" 此外,我会更新您的迁移并使该字段不可为空,更好地获得例外而不是保存没有客户端的订单 belongs_to :client, class_name: "Company", foreign_key: "id" Should be belon ...
  • 在控制器中 @order = Order.find(params[:order_id]) @giftcard = @order.build_giftcard(gift_card_params) In Controller @order = Order.find(params[:order_id]) @giftcard = @order.build_giftcard(gift_card_params)
  • 您可以使用伪元素执行此操作,一旦加载完成就必须将其删除(但这是另一个问题)。 在这里,我使用悬停来显示它。 JSfiddle演示 HTML 一些内容 CSS .parent { position: relative; } .parent:after { position: absolute; content:""; top:0; left:0; bottom:0; right:0; background: url('http://www.sec ...

相关文章

更多

最新问答

更多
  • 获取MVC 4使用的DisplayMode后缀(Get the DisplayMode Suffix being used by MVC 4)
  • 如何通过引用返回对象?(How is returning an object by reference possible?)
  • 矩阵如何存储在内存中?(How are matrices stored in memory?)
  • 每个请求的Java新会话?(Java New Session For Each Request?)
  • css:浮动div中重叠的标题h1(css: overlapping headlines h1 in floated divs)
  • 无论图像如何,Caffe预测同一类(Caffe predicts same class regardless of image)
  • xcode语法颜色编码解释?(xcode syntax color coding explained?)
  • 在Access 2010 Runtime中使用Office 2000校对工具(Use Office 2000 proofing tools in Access 2010 Runtime)
  • 从单独的Web主机将图像传输到服务器上(Getting images onto server from separate web host)
  • 从旧版本复制文件并保留它们(旧/新版本)(Copy a file from old revision and keep both of them (old / new revision))
  • 西安哪有PLC可控制编程的培训
  • 在Entity Framework中选择基类(Select base class in Entity Framework)
  • 在Android中出现错误“数据集和渲染器应该不为null,并且应该具有相同数量的系列”(Error “Dataset and renderer should be not null and should have the same number of series” in Android)
  • 电脑二级VF有什么用
  • Datamapper Ruby如何添加Hook方法(Datamapper Ruby How to add Hook Method)
  • 金华英语角.
  • 手机软件如何制作
  • 用于Android webview中图像保存的上下文菜单(Context Menu for Image Saving in an Android webview)
  • 注意:未定义的偏移量:PHP(Notice: Undefined offset: PHP)
  • 如何读R中的大数据集[复制](How to read large dataset in R [duplicate])
  • Unity 5 Heighmap与地形宽度/地形长度的分辨率关系?(Unity 5 Heighmap Resolution relationship to terrain width / terrain length?)
  • 如何通知PipedOutputStream线程写入最后一个字节的PipedInputStream线程?(How to notify PipedInputStream thread that PipedOutputStream thread has written last byte?)
  • python的访问器方法有哪些
  • DeviceNetworkInformation:哪个是哪个?(DeviceNetworkInformation: Which is which?)
  • 在Ruby中对组合进行排序(Sorting a combination in Ruby)
  • 网站开发的流程?
  • 使用Zend Framework 2中的JOIN sql检索数据(Retrieve data using JOIN sql in Zend Framework 2)
  • 条带格式类型格式模式编号无法正常工作(Stripes format type format pattern number not working properly)
  • 透明度错误IE11(Transparency bug IE11)
  • linux的基本操作命令。。。