tags:

views:

17

answers:

1

I have got four tables in NHibernate

Job
{
  DBID { int, primary key }
  Name { string }
  Media { fk_media (int) }
  PublishInfo { fk_publishinfo (int) }
}

Media
{
  DBID { int, primary key }
  TransmissionID { string }
  Series { string }
  Title { string }
  Description { string }
}

PublishInfo
{
  DBID { int, primary key }
  Destination { string }
  AudioTrack_1 { fk_audiolanguage }
  AudioTrack_2 { fk_audiolanguage }
  AudioTrack_3 { fk_audiolanguage }
  AudioTrack_4 { fk_audiolanguage }
}

AudioLanguage
{
  Code { string, primary key }
  Description { string }
}

What I want to achive with NHibernate is that it only stores unique records. So if a Media is used multiple times they all point to the same media entry. Same goes for PublishInfo.

A second issue I ran into is that when using the same audiolanguage for audiotrack_3 and 4 for instance it gives a error that is was already used in the session.

Any tips how I would do this properly?

A: 

This is a partial anwser to my own question. The reason it wasn't working correctly for the languages when using same lanuage on multiple tracks is because they got send back and forth between a client and server application. The way I solved this is by receiving it back to the server I lookup the proper objects stored in a list on the server and replace them.

I do not think this is the proper solution but it works.

Sebastiaan Vreeken
There error in my thinking is that the objects I was trying to store where indepent object. I simple places them in a central list and before storing replaced the independent objects for the central object.Then NHibernate reconizes it as the exsisting item.
Sebastiaan Vreeken