Hi All,
We have a mapping that has a composite-id with a key-many-to-one. Is
it possible to have the object that is referenced in the key-many-to-
one NOT to persist? Basically, what I'm after is to have the object
"Note" be read only - but also have it persist to the
T_IceTreppNoteMap table - which is the composite-id. This is NH
2.1.2.
Here's what I've tried:
this mapping is using the key-many-to-one element. If I make a change
to the "PharosNote" object and save the "NoteMap" object the changes
to "PharosNote" persist: not what I want.
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2"
assembly="Domain.Pharos"
namespace="Domain.Pharos"
default-lazy="true"
schema="Stage" >
<class name="NoteMap" table="T_IceTreppNoteMap">
<composite-id>
<key-property name="LoanId" column="MasterLoanId"
type="System.String" />
<key-property name="NoteNum" column="NoteNum"
type="System.Double" /
>
<key-many-to-one name="PharosNote" column="IceNoteId"
class="Note" /
>
</composite-id>
<property name="DealName" column="DealName"
type="System.String"/>
</class>
</hibernate-mapping>
In this mapping I tried using a property for the "PharosNote" using a
formula - hoping it would be read-only. The "PharosNote" gets
populated correctly when I retrieve a NoteMap from the database but it
also persists changes if I change the "PharosNote". Which is not what
I'm after.
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2"
assembly="Himco.App.Cmbs.Domain.Pharos"
namespace="Himco.App.Cmbs.Domain.Pharos"
default-lazy="true"
schema="Stage" >
<class name="NoteMap" table="T_IceTreppNoteMap">
<composite-id>
<key-property name="TreppLoanId"
column="MasterLoanIdTrepp"
type="System.String" />
<key-property name="NoteNum" column="NoteNum"
type="System.Double" /
>
<key-property name="PharosNoteId" column="IceNoteId"
type="System.Int32" />
</composite-id>
<property name="TreppDealName" column="TreppDealName"
type="System.String"/>
<property name="AllocationPercent" column="AllocationPercent"
type="System.Double"/>
<property name="MatchRuleId" column="MatchRuleId"
type="System.Int32"/>
<many-to-one name="PharosNote" class="Note"
formula="(select n.m_lObjectId from
dbo.tbNote n where
n.m_lObjectId=IceNoteId)"
cascade="none" update="false"
insert="false" />
</class>
</hibernate-mapping>
Any ideas?
Thanks,
Mike
--
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.