Hibernate version: 1.03
First off, let me say that I'm glad a friend of mine showed me NHibernate, it's a great tool, and I'm glad it's there.
Now, down to business, as it were.
I've read the examples that are available through Google and through this website regarding NHibernate. In particular, I've been paying close attention to mapping relationships in the .hbm.xml files. Here is a screenie of the relationships between my tables (done in Access, due to the nature of the application)
So far, I've mapped the classes to the their tables in the DB, and the other tasks required, except for mapping the relationships.
In my reading of the documentation provided, I get the feeling that I should use the following code in the client.hbm.xml file:
Quote:
<SET name="Child" cascade="all" lazy="true">
<KEY column="ClientID" />
<ONE-TO-MANY class="SocksCDS.Child, SocksCDS" />
<SET name="Spouse" cascade="all" lazy="true">
<KEY column="ClientID" />
<ONE-TO-ONE class="SocksCDS.Spouse, SocksCDS" />
<SET name="Wages" cascade="all" lazy="true">
<KEY column="ClientID" />
<ONE-TO-ONE class="SocksCDS.Wages, SocksCDS" />
<SET name="Employer" cascade="all" lazy="true">
<KEY column="ClientID" />
<ONE-TO-MANY class="SocksCDS.Employer, SocksCDS" />
<SET name="Assistance" cascade="all" lazy="true">
<KEY column="ClientID" />
<ONE-TO-MANY class="SocksCDS.Assistance, SocksCDS" />
For each of the other .hbm.xml files (Employer, Child, Wages, Assistance) in each should be the following:
Quote:
<SET name="Client" cascade="all">
<KEY column="ClientID" />
<MANY-TO-ONE class="SocksCDS.Client, SocksCDS" />
Now, the second snippet of code bothers me, but in searching through the documentation, I'm not sure of what I'm looking for that will help. Every example I've read about on the internet always gives a simple (non realworld) example, or they give a simple realworld example that doesn't answer these questions)
My questions:
Is code Snippet #1 correct? (given the relationships expressed)
Do I need to also map these relationships in the other files, or once it's mapped in the client.hbm.xml, is it complete, since that is what is used to pull all of the other information?
Thanks again, and if there's any other resources you know of that answer these questions, please feel free to point me in that direction.
As a postscript: Does anyone know the correct Key column for the Access 2003 DB? I'm using 'identity' but am still writing code and haven't tested it yet, I wanted to ensure that the groundwork was done.