0

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;}
}
Danil
  • 1,883
  • 1
  • 21
  • 22
  • 2
    Your question is unclear. Visual NH is a designer, which might not necessarily support all of NH's features. If two tables make up one entity, I don't see the inheritance. Why don't you show us the class(es) and tables? – Diego Mijelshon Jan 15 '11 at 17:44
  • Maybe you are right, it is not inheritance, however I need to know if it is possible to map two tables in one entity. I can make Transact abstract and Expense will inherit it. In this way it will work. – Danil Jan 16 '11 at 20:10
  • Visual NHibernate can map two tables to a single entity, if that's what you want. To do this: Right-click the referenced entity (Transact) on the entity view (Expense). On the context-menu click 'Merge into Expense'. The fields from Transact will be merged into Expense, and the Transact entity will be removed from the model. Note that 'Merge into xxxx' will only appear on the context-menu for 1:1 references. Please report problems with Visual NHibernate to http://support.slyce.com – Gareth Hayter Jan 17 '11 at 06:58

1 Answers1

0

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.

Tyler Treat
  • 14,640
  • 15
  • 80
  • 115