File tree 1 file changed +22
-5
lines changed 1 file changed +22
-5
lines changed Original file line number Diff line number Diff line change @@ -135,15 +135,32 @@ public override bool UseLHSPrimaryKey
135
135
136
136
public override object Disassemble ( object value , ISessionImplementor session , object owner )
137
137
{
138
- return null ;
138
+ if ( value == null )
139
+ {
140
+ return null ;
141
+ }
142
+
143
+ object id = ForeignKeys . GetEntityIdentifierIfNotUnsaved ( GetAssociatedEntityName ( ) , value , session ) ;
144
+
145
+ if ( id == null )
146
+ {
147
+ throw new AssertionFailure ( "cannot cache a reference to an object with a null id: " + GetAssociatedEntityName ( ) ) ;
148
+ }
149
+
150
+ return GetIdentifierType ( session ) . Disassemble ( id , session , owner ) ;
139
151
}
140
152
141
153
public override object Assemble ( object cached , ISessionImplementor session , object owner )
142
154
{
143
- //this should be a call to resolve(), not resolveIdentifier(),
144
- //'cos it might be a property-ref, and we did not cache the
145
- //referenced value
146
- return ResolveIdentifier ( session . GetContextEntityIdentifier ( owner ) , session , owner ) ;
155
+ // the owner of the association is not the owner of the id
156
+ object id = GetIdentifierType ( session ) . Assemble ( cached , session , null ) ;
157
+
158
+ if ( id == null )
159
+ {
160
+ return null ;
161
+ }
162
+
163
+ return ResolveIdentifier ( id , session ) ;
147
164
}
148
165
149
166
/// <summary>
You can’t perform that action at this time.
0 commit comments