lfaldanam / sharp-architecture

Automatically exported from code.google.com/p/sharp-architecture
Other
0 stars 0 forks source link

SessionFactoryAttribute is not beeing used while having single database initialized with non-default key, #132

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Define entity and mapping
public class SomeEntity : Entity {...}

2. Define repository and decorate it with SessionFactoryAttribute and non-
default key
[SessionFactory( "SomeFactoryKey" )]
public class SomeEntityRepository : Repository<SomeEntity>{...}

3. Initialize _single_ database using the same key
NHibernateSession.Init( new SimpleSessionStorage( "SomeFactoryKey" ), new 
string[] {}, "some.config" );

4. Try to get some data
SomeEntityRepository rep = new SomeEntityRepository();
var entitis = rep.GetAll();

What is the expected output? What do you see instead?
Expexted output is instance of IList<SomeEntity>.
Instead exception has been rised:
SharpArch.Core.PreconditionException: An ISessionStorage does not exist 
with a factory key of nhibernate.current_session.

What version of the product are you using? On what operating system?
1.0 RTM

Please provide any additional information below.
SessionFactoryAttribute.GetKeyFrom check for attribute, when there is more 
than one SessionFactories. 

public static string GetKeyFrom(object anObject)
{
    if (NHibernateSession.IsConfiguredForMultipleDatabases())
    {
...

Original issue reported on code.google.com by Tomasz...@gmail.com on 6 Oct 2009 at 11:07

GoogleCodeExporter commented 9 years ago
Is there a reason you're using a custom session factory key if you're only 
using one 
database?

Original comment by wmccaffe...@gmail.com on 29 Oct 2009 at 9:14

GoogleCodeExporter commented 9 years ago
I expect to reference modules, which will be writen in unified way,  that might 
use 
another db.

Original comment by Tomasz...@gmail.com on 5 Nov 2009 at 12:25

GoogleCodeExporter commented 9 years ago
This is a problem with multiple databases as well.

Original comment by alex.ga...@apptik.com on 4 Dec 2009 at 4:16