ORM 继承支持

发布于 2024-10-12 01:35:48 字数 508 浏览 4 评论 0原文

我正在尝试将两个表映射到一个实体中,因为这些表实际上是一个实体。 我尝试过 llblgen 和 Visual NHibernate,但没有成功,因为这两个设计者

Visual NHibernate 无法看到一对一的关系,但我已经实现了它。 也许我的数据库模式不能满足此类继承实现的所有要求。 然而我认为我所需要的只是具有一对一的关系来进行这种类型的继承。

也许你们中的一些人已经尝试过了?

编辑:添加表格图片 alt text

我想要我的以下课程

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
alt text

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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

徒留西风 2024-10-19 01:35:48

您将需要查看 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文