Hi,
i have an interface like this

public interface IFoo
{
    int ID
    string Identity
}

later in the code i have a Implementation for it

public class Foo : IFoo
{
   virtual public int     ID         {get;set;}
   virtual public string Identity {get;set;}
}

Later on i want to do something like

IRepository<IFoo> pRep = IoC.Resolve<IFoo>();
IFoo pFoo = pRep.getByIdenity("Foo");

So far so good. My question ist, how to map this with NHibernate? My
first try was

  <class name="Definition.IFoo, Definition"  table="Foo">
    <id name="ID" column="FOO_ID" type="Int32" unsaved-value="0">
      <generator class="assigned"></generator>
    </id>
    <property name="Identity"   column="FOO_IDENTITY"
type="string"   length="30" not-null="true"/>
  </class>

This can't work because NH don't know how to instantiate the entity.
As far as I understand the
documentation, i have to use a discriminator-column in conjunction
with the subclass and
discriminator-value attribute. Sounds clear to me, if i want to have
different classes in a table etc.
But in my case I have no discriminator-value and no discriminator
column.

If i do the following configuration, it works as expected

  <class name="Definition.IFoo, Definition"  table="Foo" discriminator-
value="1">
    <id name="ID" column="Foo_ID" type="Int32" unsaved-value="0">
      <generator class="assigned"></generator>
    </id>
    <discriminator column="Class" type="integer"/>
    <property name="Identity"   column="FOO_IDENTITY"
type="string"   length="30" not-null="true"/>
    <subclass name ="Foo" discriminator-value="1"/>
  </class>

My question is, if there is a simpler way to do this, without the (in
this case) useless discriminator column?

Regards,
Volker
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"nhusers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/nhusers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to