ORM 继承支持
我正在尝试将两个表映射到一个实体中,因为这些表实际上是一个实体。 我尝试过 llblgen 和 Visual NHibernate,但没有成功,因为这两个设计者
Visual NHibernate 无法看到一对一的关系,但我已经实现了它。 也许我的数据库模式不能满足此类继承实现的所有要求。 然而我认为我所需要的只是具有一对一的关系来进行这种类型的继承。
也许你们中的一些人已经尝试过了?
编辑:添加表格图片
我想要我的以下课程
public class Expense {
public int Id {get; set;}
public int Type {get; set;}
public decimal Amount {get; set;}
public string SomeAdditionalInfo {get; set;}
}
I'm trying to map two tables in one Entities as these tables is really one entity.
I've tried llblgen and Visual NHibernate without any success as both designers
Visual NHibernate can't see one to one relationship, however I've implemented it.
Maybe my database schema didn't satisfy all requirements for such inheritance implementation.
However I thought that all I need is to have one to one relationship to make this type of inheritance.
Maybe some of you guys have already tried it?
Edit: Adding tables picture
I want my following class
public class Expense {
public int Id {get; set;}
public int Type {get; set;}
public decimal Amount {get; set;}
public string SomeAdditionalInfo {get; set;}
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您将需要查看 Hibernate 文档以了解继承映射,特别是每个层次结构表模型。你说你可以使 Transact 抽象并让 Expense 继承它,所以我认为如果我理解正确的话,这应该可以解决你的问题。
http://docs.jboss.org/hibernate/core /3.5/reference/en/html/inheritance.html
或者,如果您不想使用每个层次结构一个表的方法,还有其他几种方法可以实现该链接中概述的目标。
You're going to want to take a look at the Hibernate documentation for inheritance mapping, specifically the table-per-hierarchy model. You say you can make Transact abstract and have Expense inherit from it, so I think this should solve your problem if I understand it correctly.
http://docs.jboss.org/hibernate/core/3.5/reference/en/html/inheritance.html
Alternatively, if you don't want to use the table-per-hierarchy method, there's a couple other ways you could achieve your goal outlined in that link.