-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 
Author Message
 Post subject: Problem with session.Load() ans SQLite 3
PostPosted: Wed Oct 03, 2007 6:31 am 
Newbie

Joined: Wed Oct 03, 2007 5:56 am
Posts: 3
Location: Germany
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


Top
 Profile  
 
 Post subject: Found the problem
PostPosted: Wed Oct 10, 2007 2:06 am 
Newbie

Joined: Wed Oct 03, 2007 5:56 am
Posts: 3
Location: Germany
Hi

for all that are interested in the problem, i finally found the problem:

i designed the class in the class designer and just added the "virtual" statement to the properties, but the class was implicitely declared as private. Changing the class to public fixed the problem in the end.

Hope that can help anybody...
Greetings Alex

P.S by the way: is there another way to hide the class inside the assembley which nhibernate is able to work with?


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.