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?
原文:
最满意答案
在控制器中
@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 ...
-
只有在父母和孩子没有徘徊的情况下,Jquery才有父母做某事(Jquery have parent do something only once parent and child not hovered)[2022-07-12]
如果子节点是父节点流根的一部分(即父元素包含子元素),那么您可以只注意父节点上的鼠标离开。 $(".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 => { ...
-
反应孩子到父母的沟通(React child to parent communication)[2022-05-02]
如果你的应用程序要比这个大得多,那么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" ...
-
RoR:通过孩子创建父母(RoR: Create parent through child)[2023-10-23]
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 ... -
如何将父母与孩子联系起来?(How to link parent with child?)[2023-06-04]
在控制器中 @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) -
在孩子的父母背景(Parent background over child's)[2023-02-05]
您可以使用伪元素执行此操作,一旦加载完成就必须将其删除(但这是另一个问题)。 在这里,我使用悬停来显示它。 JSfiddle演示 HTML 一些内容 CSS .parent { position: relative; } .parent:after { position: absolute; content:""; top:0; left:0; bottom:0; right:0; background: url('http://www.sec ...