On Saturday, February 13, 2016 at 11:30:24 AM UTC-5, mwpowellhtx wrote:
>
>
>
> On Saturday, February 13, 2016 at 11:14:26 AM UTC-5, mwpowellhtx wrote:
>>
>>
>>
>> On Friday, February 12, 2016 at 5:19:04 AM UTC-5, Gleb Chermennov wrote:
>>>
>>> Hello Michael, 
>>> as far as I know, creating a session factory shouldn't instantiate any 
>>> of your domain objects.
>>> May be you can share your code here or in an email?
>>>
>>
> Let's put it another way, when I put a unit test in your Fluent NHibernate 
> that a test model's default ctor should not be invoked, literally call 
> Assert.Fail() in the default ctor, then this should be sufficient to test 
> that hypothesis?
>

Best guess without diving much further, somewhere in the bowels of this 
NHibernate-Core monster:

/// <summary>
/// Instantiate a new <see cref="ISessionFactory" />, using the properties 
and mappings in this
/// configuration. The <see cref="ISessionFactory" /> will be immutable, so 
changes made to the
/// configuration after building the <see cref="ISessionFactory" /> will 
not affect it.
/// </summary>
/// <returns>An <see cref="ISessionFactory" /> instance.</returns>
public ISessionFactory BuildSessionFactory()
{
ConfigureProxyFactoryFactory();
SecondPassCompile();
Validate();
Environment.VerifyProperties(properties);
Settings settings = BuildSettings();

// Ok, don't need schemas anymore, so free them
Schemas = null;

return new SessionFactoryImpl(this, mapping, settings, 
GetInitializedEventListeners());
}

I've got a stack trace that says new instances are being created. If not 
>> Fluent/NHibernate code, then the proxy instance DLL creation?
>>
>> > Football.dll!Football.Models.GameSituation.GameSituation() Line 905 C#
>>   [External Code] 
>>   
>> FluentNHibernate.dll!FluentNHibernate.Cfg.FluentConfiguration.BuildSessionFactory()
>>  
>> Line 230 + 0x18 bytes C#
>>   
>> Football.Data.dll!Football.Data.Repository.Hibernate.NHibernateSessionFactoryManagerBase.CreateFactory()
>>  
>> Line 131 + 0xb bytes C#
>>   
>> Kingdom.Repository.dll!Kingdom.Repository.SessionFactoryManagerBase<NHibernate.ISessionFactory>.Factory.get()
>>  
>> Line 37 + 0x1a bytes C#
>>   
>> Football.Migrator.exe!Football.Migrator.Program.PlanWork(System.Action<Kingdom.Repository.IRepository>
>>  
>> workPlan) Line 39 + 0xe bytes C#
>>   Football.Migrator.exe!Football.Migrator.Program.Main(string[] args) 
>> Line 66 + 0x36 bytes C#
>>   [External Code] 
>>
>>
>> четверг, 11 февраля 2016 г., 17:44:15 UTC+3 пользователь mwpowellhtx 
>>> написал:
>>>>
>>>> Hello, 
>>>>
>>>> I am curious, I have a stack trace that indicates building a session 
>>>> factory is actually creating new instances of my mapped (?) domain 
>>>> model? 
>>>>
>>>> Is that accurate? If so, why? What's wrong with doing a little 
>>>> reflection followed closely by throwing an exception, or even, if 
>>>> possible, using the "new()" generic constraint? 
>>>>
>>>> I kind of expect a handshake of sorts between any data layer and the 
>>>> underlying model, but I'm not sure this is the right time and/or way 
>>>> to find it out. 
>>>>
>>>> > Football.dll!Football.Models.GameSituation.Initialize() Line 927 C# 
>>>>   Football.dll!Football.Models.GameSituation.GameSituation() Line 905 
>>>> + 0x9 bytes C# 
>>>>   [External Code] 
>>>>   
>>>> FluentNHibernate.dll!FluentNHibernate.Cfg.FluentConfiguration.BuildSessionFactory()
>>>>  
>>>>
>>>> Line 230 + 0x18 bytes C# 
>>>>   
>>>> Football.Data.dll!Football.Data.Repository.Hibernate.NHibernateSessionFactoryManagerBase.CreateFactory()
>>>>  
>>>>
>>>> Line 131 + 0xb bytes C# 
>>>>   
>>>> Kingdom.Repository.dll!Kingdom.Repository.SessionFactoryManagerBase<NHibernate.ISessionFactory>.Factory.get()
>>>>  
>>>>
>>>> Line 37 + 0x1a bytes C# 
>>>>   
>>>> Football.Migrator.exe!Football.Migrator.Program.PlanWork(System.Action<Kingdom.Repository.IRepository>
>>>>  
>>>>
>>>> workPlan) Line 39 + 0xe bytes C# 
>>>>   Football.Migrator.exe!Football.Migrator.Program.Main(string[] args) 
>>>> Line 66 + 0x36 bytes C# 
>>>>   [External Code] 
>>>>
>>>> Suggestions? 
>>>>
>>>> Thank you. 
>>>>
>>>> Regards, 
>>>>
>>>> Michael Powell 
>>>>
>>>

-- 
You received this message because you are subscribed to the Google Groups 
"Fluent NHibernate" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to fluent-nhibernate+unsubscr...@googlegroups.com.
To post to this group, send email to fluent-nhibernate@googlegroups.com.
Visit this group at https://groups.google.com/group/fluent-nhibernate.
For more options, visit https://groups.google.com/d/optout.

Reply via email to