473,387 Members | 1,561 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

NHibernate Complex Table Mapping

Ram
Hey,

I'm having a trouble mapping a connecting between 2 of my tables.
We have 2 tables - the simplest "dept", "emp" tables which are mapped
to 2 classes.
Class Dept contains 2 properties for emps - 1 for manager and the
second for workers (Collection).
How can I map this?
We can add additional fields in the emp table that indicates the
property in the depts?

Thanks ahead
--Ram

Apr 18 '06 #1
1 2542

Your NHibernate mapping for the department should look like this :

<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.0" schema="dbo">
<class name="Dept, AssemblyName" table="Dept">
<bag name="Workers" inverse="true">
<key column="DepartmentID" />
<one-to-many class="Employee, AssemblyName" />
</bag>
<many-to-one name="Manager" column="ManagerID" class="Employee,
AssmblyName" />
</class>
</hibernate-mapping>

You should have a departmentId field in the emp table (i guess there should
be a one-to-one mapping between employees and departments) and a ManagerID
in the
department table too. AssemblyName should be the fully qualified name of
your assembly.
I hope this helps

"Ram" <St****@gmail.com> wrote in message
news:11**********************@i39g2000cwa.googlegr oups.com...
Hey,

I'm having a trouble mapping a connecting between 2 of my tables.
We have 2 tables - the simplest "dept", "emp" tables which are mapped
to 2 classes.
Class Dept contains 2 properties for emps - 1 for manager and the
second for workers (Collection).
How can I map this?
We can add additional fields in the emp table that indicates the
property in the depts?

Thanks ahead
--Ram

Apr 18 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Fabiano | last post by:
Please, i would like to know if there's a good idea use NHibernate at my programs besides native data tier of .NET. Java mans love it very much, but i don't know if its going to be a nice way...
0
by: sternr | last post by:
Hey, I'm having a trouble mapping a connecting between 2 of my tables. We have 2 tables - the simplest "dept", "emp" tables which are mapped to 2 classes. Class Dept contains 2 properties for...
1
by: sternr | last post by:
Hey, I'm using NHibernate version: 1.0.0.2 My Mapping documents: <class name="DM.Book" table="Books"> <id column="bookId" name="bookId"> <generator class="assigned" /> </id> <property...
5
by: Prem Kumar | last post by:
Hi Can somebody throw some light on what are these tools and which is the best to use? I would like to know, where do these tools fit in ? and how does it help? Thanks Prem
5
by: igotyourdotnet | last post by:
I took over an asp.net C# app from a former developer that left. Ever so ofter I get an error message: Access is denied: 'NHibernate'. Description: An unhandled exception occurred during the...
0
by: Pieter | last post by:
Hi, I'm using NHibernate 1.2 (CR1), and I'm using a custom list (inherited from BindingList(Of T) ) for all my lists. The NHibernate documentation told me that I had to implement...
4
by: IceMan | last post by:
Hi, I am using the configuration object and passing it a Assembly object to load. The assembly object i pass in is from a dll which is in a different folder then the Nhibernate dll. The...
0
by: Jacques Vandensavel | last post by:
I have a legacy table which is composed out three key fields. It is representing a bank. I'm using NHibernate in my ASP.NET application to glue everything together. I'm already searching for an...
14
by: thj | last post by:
Hi, I was wondering what you guys are using and why? LINQ to SQL or NHibernate? Thanks in advance, Tommy
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.