So, I moved the code that makes the edits/sanitization to IMergeEventListener, 
ISaveOrUpdateEventListener listener. This doesnt solve my earlier problem 
but rather circumvent it. I now update the child entities fine during those 
events, however I get a NHibernate.TransientObjectException .

Basically what I need is to sanitize the TranslatedProperty class each time 
a parent that includes it is saved/updated. Any ideas how I get around the 
TransientObjectException ? 

I have tried an @event.Session.GetSession(EntityMode.Poco) to save the 
TranslatedProperty 
but that doesn't solve the exception problem.

On Wednesday, February 13, 2013 4:45:34 PM UTC+2, Mike B wrote:
>
> Hello,
>
> This is a weird bug. I have this setup:
>
> SomeClass : SomeBaseClass {
>       TranslatedProperty Text  {get; set;}
>       TranslatedProperty Text2 {get; set;}
>       TranslatedProperty Text3 {get; set;}
>       ....
> }
>
> TranslatedProperty {
>       SomeBaseClass LocalizableParent {get; set;}
>       string Name { get; set; }
>       IDictionary<int, string> Translations {get; set;}
> }
>
> Relationship Mappings are like so:
>
> *TranslatedPropertyMap :*
>
> Id(x => x.TranslatedPropertyID);
>             Map(x => x.Name);
>             HasMany(x => x.Translations)
>                 
> .Access.ReadOnlyPropertyThroughCamelCaseField(Prefix.Underscore)
>                 .AsMap<string>(
>                     index => index.Column("LanguageLCID").Type<int>(),
>                     element => 
> element.Column("Translation").Type<string>().Length(11000)
>                     )
>                 .Cascade.AllDeleteOrphan()
>                 .Fetch.Join();
>
>             ReferencesAny(x => x.LocalizableParent)
>                 .IdentityType<int>()
>                 .MetaType<string>()
>                 .EntityIdentifierColumn("LocalizableID")
>                 .EntityTypeColumn("ClassName")
>                 .Cascade.All();
>
> *SomeClassMap:* 
>
> References(x => x.Text)
>                 .Fetch.Join()
>                 .Cascade.All();
>
> References(x => x.Text2)
>                 .Fetch.Join()
>                 .Cascade.All();
>
> References(x => x.Text3)
>                 .Fetch.Join()
>                 .Cascade.All();
> *
> How I persist the objects:*
>
> CurrentSession.Save(SomeClass) 
> CurrentSession.Merge(SomeClass) // Using either, doesn't affect the 
> problem
> then .Flush() the session.
>
> *The problem:*
>
> Once the property TranslatedProperty.Name is written, there is no way to 
> update it. Theinsert function cascades, but the update function doesn't.  I 
> also 
> can NOT update the association of TranslatedProperty.LocalizableParent.
>
> When I insert a new entity to the database everything goes well. When I 
> change the translation object (add/remove/edit) of a TranslatedProperty 
> everything goes well. 
> Any Ideas how I can automatically cascade the update of SomeClass to 
> TranslatedProperty.Name (etc) and not just to TranslatedProperty's 
> children ?* *

-- 
You received this message because you are subscribed to the Google Groups 
"nhusers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/nhusers?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to