views:

50

answers:

0

I'd like to program against interfaces when working with NHibernate due to type dependency issues within the solution I am working with.

SO questions such as this indicate it is possible.

I have an ILocation interface and a concrete Location type. Will the following work?

HBM mapping:

<class name="ILocation" abstract="true" table="ILocation">
  <id name="Id" type="System.Guid" unsaved-value="00000000-0000-0000-0000-000000000000">
    <column name="LocationId" />
    <generator class="guid" />
  </id>       
        <union-subclass table="Location" name="Location">
                <property name="Name" type="System.String"/>
        </union-subclass>
</class>

Detached criteria usage using the interface:

var criteria = DetachedCriteria.For<ILocation>().Add(Restrictions.Eq("Name", "blah"));            
var locations = criteria.GetExecutableCriteria(UoW.Session).List<ILocation>();

Are there any issues with not using the hilo ID generator and/or with this approach in general?