Hello everybody
obviously i'm pretty new, i try to get nhibernate working for the first time and got a problem while trying to access a sqlite database. While inserting new objects works pretty well i always get an error while trying to access an object with a specific id. my config object looks like this:
Code:
NHibernate.Cfg.Configuration cfg = new NHibernate.Cfg.Configuration();
cfg.SetProperty(NHibernate.Cfg.Environment.ConnectionProvider, "NHibernate.Connection.DriverConnectionProvider");
cfg.SetProperty(NHibernate.Cfg.Environment.Dialect, "NHibernate.Dialect.SQLiteDialect");
cfg.SetProperty(NHibernate.Cfg.Environment.ConnectionDriver, "NHibernate.Driver.SQLite20Driver");
cfg.SetProperty(NHibernate.Cfg.Environment.ConnectionString, "Data Source=Demo.bkdb;Version=3");
cfg.AddClass(typeof(BusinessLogic.Account));
I just added one class to be sure no other things disrupt.
My code looks like this:
Code:
NHibernate.ISessionFactory _sessionFactory = cfg.BuildSessionFactory();
using(session = _sessionFactory.OpenSession())
{
using (transaction = session.BeginTransaction())
{
Account b = new BusinessLogic.Account();
b = (Account)session.Load(typeof(Account), 1);
transaction.Commit();
}
}
During the session.Load() i get the following error:
Code:
Creating a proxy instance failed
Inner Exception:
Access is denied: 'Bookeeper.BusinessLogic.Account'.":"
Stachtrace:
at NHibernate.Proxy.CastleProxyFactory.GetProxy(Object id, ISessionImplementor session)
at NHibernate.Persister.Entity.AbstractEntityPersister.CreateProxy(Object id, ISessionImplementor session)
at NHibernate.Impl.SessionImpl.DoLoadByClass(Type clazz, Object id, Boolean checkDeleted, Boolean allowProxyCreation)
at NHibernate.Impl.SessionImpl.Load(Type clazz, Object id)
at Bookeeper.UseCases.UCCDatabase.UCLoadDatabase() in C:\Dokumente und Einstellungen\VMUser\Desktop\Bookeeper\Bookeeper\UseCases\UCCDatabase.cs:line 78
at Bookeeper.GUI.frmMain..ctor() in C:\Dokumente und Einstellungen\VMUser\Desktop\Bookeeper\Bookeeper\GUI\frmMain.cs:line 22
at Bookeeper.UseCases.UCCApplication.RunApplication() in C:\Dokumente und Einstellungen\VMUser\Desktop\Bookeeper\Bookeeper\UseCases\UCCApplication.cs:line 13
at Bookeeper.Program.Main() in C:\Dokumente und Einstellungen\VMUser\Desktop\Bookeeper\Bookeeper\Program.cs:line 15
at System.AppDomain.nExecuteAssembly(Assembly assembly, String[] args)
at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()
(Sorry that some parts are german, but i think its never the less readable)
I also tried other IDs that exist in the db, but that seems not to be the error. For completion here's my mapping file - i comented pretty much to be sure that there is no error (for simplicity there is no connection to other objects)
Code:
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2">
<class name="Bookeeper.BusinessLogic.Account, Bookeeper" table="tabAccounts">
<id name="ID"/>
<generator class="identity" />
</id>
<property name="Name" column="Name" />
<!--
<property name="Description" column="Description" />
<set name="DebitTickets" table="tabTickets">
<key column="SourceAccount"/>
<one-to-many class="Bookeeper.BusinessLogic.Ticket, Bookeeper" />
</set>
<set name="CreditTickets" table="tabTickets">
<key column="DestAccount"/>
<one-to-many class="Bookeeper.BusinessLogic.Ticket, Bookeeper" />
</set>
-->
</class>
</hibernate-mapping>
Any help would be very nice, any search in the docu, the forums and google did not result in anything (at least i found a spanish website that could help me but i sadly don't speak spanish =o/)
Thank you very much for reading
greetings Alex