I'm currently working on a big rewrite of conventions that should drop over
the next few days, once that arrives we'll be able to support the scenario
you speak of.

On Fri, Feb 13, 2009 at 1:28 AM, Brendan Erwin <[email protected]>wrote:

> Wait, wouldn't that cause "circular cascades"? (a problem I think I have
> but have yet to get the opportunity to fix...)
>
>
> On Feb 12, 2009, at 12:47 PM, James Gregory <[email protected]>
> wrote:
>
> You mean an application wide Cascade.All for any relationship? No, not
> currently. Good idea though.
>
> On Thu, Feb 12, 2009 at 4:56 PM, Ramana Kumar < <[email protected]>
> [email protected]> wrote:
>
>> Thanks James.  Now with the cascade.All, the Saves are working fine.
>>
>> I guess there is no way to set up "cascade all" for all the Entities that
>> references another Entity.
>> Ramana
>>
>> On Thu, Feb 12, 2009 at 3:01 AM, James Gregory 
>> <[email protected]>wrote:
>>
>>> Those wiki pages cover how you'd set the cascade.
>>> ForTypesThatDeriveFrom<Golfer>(m =>
>>> {
>>>   m.References(x => Address)
>>>     .Cascade.All();
>>> })
>>>
>>> On Thu, Feb 12, 2009 at 12:09 AM, Ramana Kumar <<[email protected]>
>>> [email protected]> wrote:
>>>
>>>> I will go back home and check the wiki pages.  In the meantime, here is
>>>> what I use to save
>>>>
>>>>         [Transaction]
>>>>         [AcceptVerbs(HttpVerbs.Post)]
>>>>         public ActionResult Create(Golfer golfer) {
>>>>             if (golfer.IsValid()) {
>>>>                 golferRepository.SaveOrUpdate(golfer);
>>>>                 TempData["message"] = "The golfer was successfully
>>>> created.";
>>>>                 return RedirectToAction("Index");
>>>>             }
>>>>             else {
>>>>
>>>> MvcValidationAdapter.TransferValidationMessagesTo(ViewData.ModelState,
>>>> golfer.ValidationResults());
>>>>                 return View();
>>>>             }
>>>>         }
>>>>
>>>> When I put it the thru the debugger, I see that golfer instance has
>>>> correct values (from the form) for FirstName, LastName, Email as well as
>>>> Address.Addr1, Address.City etc populated correctly.
>>>>
>>>>  BTW, SaveOrUpdate if fine and when the "Create" method ends (i.e. the
>>>> transaction is complete) then I get the exception.  Obviously, because the
>>>> flush is thrwoing the exception.
>>>>
>>>> I still suspect that "cascade" on ManyToOne needs to set to "all", I am
>>>> not sure how to do it.
>>>> Thanks
>>>> Ramana
>>>>
>>>>
>>>> On Wed, Feb 11, 2009 at 2:59 PM, James Gregory <[email protected]
>>>> > wrote:
>>>>
>>>>> Can you show us the code that's actually saving the entities?
>>>>> These two wiki pages show the ways you can customise automappings: 
>>>>> altering
>>>>> entities<http://wiki.fluentnhibernate.org/show/AutoMappingAlteringEntities>
>>>>>  and
>>>>> mapping 
>>>>> overrides<http://wiki.fluentnhibernate.org/show/AutoMappingOverrides>.
>>>>>
>>>>>
>>>>>
>>>>> On Wed, Feb 11, 2009 at 8:43 PM, Ramana Kumar <<[email protected]>
>>>>> [email protected]> wrote:
>>>>>
>>>>>> No, I did mean Many to One :-)  The Domain Objects are Golfer and
>>>>>> Address and many Golfers can share the same Address.  Per James
>>>>>> "i-think-you-mean-a-many-to-one-sir" G, this should be mapped as Many to
>>>>>> one. I am just not sure how to do it thru AutoMap conventions.
>>>>>> HTH
>>>>>> Ramana
>>>>>>
>>>>>>
>>>>>>  namespace GolfHandicapManager.Core
>>>>>> {
>>>>>>     public class Golfer : Entity
>>>>>>     {
>>>>>>         public Golfer() { }
>>>>>>         [DomainSignature]
>>>>>>         [NotNullNotEmpty]
>>>>>>         public virtual string FirstName { get; set; }
>>>>>>         [DomainSignature]
>>>>>>         [NotNullNotEmpty]
>>>>>>         public virtual string LastName { get; set; }
>>>>>>         [NotNullNotEmpty]
>>>>>>         public virtual string EmailAddress { get; set; }
>>>>>>   public virtual string EmailAddress2 { get; set; }
>>>>>>   public virtual string HomePhone { get; set; }
>>>>>>   public virtual string CellPhone { get; set; }
>>>>>>         public virtual Address Address { get; set; }
>>>>>>     }
>>>>>>     public class Address : Entity
>>>>>>     {
>>>>>>         public Address() { }
>>>>>>         [DomainSignature]
>>>>>>   public virtual string Addr1 { get; set; }
>>>>>>   public virtual string Addr2 { get; set; }
>>>>>>         [DomainSignature]
>>>>>>   public virtual string City { get; set; }
>>>>>>   public virtual string State { get; set; }
>>>>>>   public virtual string Country { get; set; }
>>>>>>   public virtual string ZipCode { get; set; }
>>>>>>     }
>>>>>> }
>>>>>>
>>>>>>
>>>>>>
>>>>>> On Wed, Feb 11, 2009 at 2:05 PM, Chris Marisic < <[email protected]>
>>>>>> [email protected]> wrote:
>>>>>>
>>>>>>>
>>>>>>> Do you mean One to Many?
>>>>>>>
>>>>>>> convention.OneToManyConvention = m =>
>>>>>>> {
>>>>>>>    m.Cascade.All();
>>>>>>> };
>>>>>>>
>>>>>>> On Feb 11, 1:58 pm, Ramana Kumar <[email protected]> wrote:
>>>>>>> > Hi
>>>>>>> > I am trying to use AutoMap to define behaviour for ManyToOne and I
>>>>>>> get the
>>>>>>> > following exception
>>>>>>> >
>>>>>>> > object references an unsaved transient instance - save the
>>>>>>> transient
>>>>>>> > instance before flushing:
>>>>>>> >
>>>>>>> > The relevant code is
>>>>>>> >
>>>>>>> >  public class AutoPersistenceModelGenerator :
>>>>>>> IAutoPersistenceModelGenerator
>>>>>>> >     {
>>>>>>> >         public AutoPersistenceModel Generate()
>>>>>>> >         {
>>>>>>> >             AutoPersistenceModel mappings = AutoPersistenceModel
>>>>>>> >                 .MapEntitiesFromAssemblyOf<Golfer>()
>>>>>>> >                 .Where(GetAutoMappingFilter)
>>>>>>> >                 .WithConvention(GetConventions);
>>>>>>> >             return mappings;
>>>>>>> >         }
>>>>>>> >
>>>>>>> >         private bool GetAutoMappingFilter(Type t)
>>>>>>> >         {
>>>>>>> >             return t.Namespace == "GolfHandicapManager.Core";
>>>>>>> >         }
>>>>>>> >         private void GetConventions(Conventions c)
>>>>>>> >         {
>>>>>>> >             c.GetPrimaryKeyNameFromType = type => "ROW_ID";  //DB
>>>>>>> has ROW_ID
>>>>>>> > as Primary Key
>>>>>>> >             c.FindIdentity = type => type.Name == "ID"; // S#arp
>>>>>>> currently
>>>>>>> > uses "ID"
>>>>>>> >             // Taken from Ayende Blog
>>>>>>> >             c.GetForeignKeyNameOfParent = (type => type.Name +
>>>>>>> "_ID");
>>>>>>> >             c.GetTableName = type =>
>>>>>>> > Inflector.Net.Inflector.Pluralize(type.Name);
>>>>>>> >             c.IsBaseType = IsBaseTypeConvention;
>>>>>>> >             // Convert PropertyName to Underscore
>>>>>>> >             c.AddPropertyConvention(new
>>>>>>> > PascalToUnderscorePropertyConvention());
>>>>>>> >         }
>>>>>>> >
>>>>>>> > I am assuming I have to do a "cascade=all" somewhere in there but
>>>>>>> do not
>>>>>>> > know how to do it thru a convention.
>>>>>>> >
>>>>>>> > Any pointers?
>>>>>>> > Thanks
>>>>>>> > Ramana
>>>>>>>
>>>>>>>
>>>>>
>>>>>
>>>
>>>
>>>
>>
>>
>>
>
>
>
> >
>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Fluent NHibernate" 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/fluent-nhibernate?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to