I have a Hibernate mapped class that has a unique business key property.
I realize that session.Load(typeof(MyClass), myClassId) will first look in the first level cache, but I would like to retrieve one of these objects from 1st level cache with the business key? Is this possible?
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2">
<class name="my.class.MyClass, my.namespace" table="mytable" lazy="false">
<cache usage="read-write" region="myregion"/>
<id name="myid" type="long" unsaved-value="null">
<column name="myid" not-null="true" />
<generator class="native" />
</id>
<property name="BusinessKey" unique="true" index="IX_N_BusinessKey_1" type="String">
<column name="BusinessKey" length="50" not-null="true"/>
</property>
.
.
.
.
</class>
</hibernate-mapping>
If this is not possible, any other suggestions? One idea is to maintain a different cache that has business-key to id mappings.
Thoughts?
|