-->
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.  [ 1 post ] 
Author Message
 Post subject: MS Access returning no data.
PostPosted: Sat Apr 02, 2011 11:30 am 
Newbie

Joined: Sat Apr 02, 2011 11:16 am
Posts: 1
I'm using the latest version of NHibernate and recompiled the JetDriver with this version in the .Net 3.5 framework. Everything seems to be setup fine, there just isn't any data returned. Here is my code, anyone see any problems? Also, anyone know where to find a working sample of nhibernate using Access, that would be very helpful.

EDIT: My project is using .Net 4.0 and running on Windows 7 32-bit.
EDIT2: I just realized that I can change the name of the class and tablename in the User.hbm.xml file or delete the file completely and the program doesn't give an error, something is not right here.

hibernate.cfg.xml:
Code:
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-configuration  xmlns="urn:nhibernate-configuration-2.2" >
  <session-factory>
    <property name="connection.provider">NHibernate.Connection.DriverConnectionProvider</property>
    <property name="dialect">NHibernate.JetDriver.JetDialect, NHibernate.JetDriver</property>
    <property name="connection.driver_class">NHibernate.JetDriver.JetDriver, NHibernate.JetDriver</property>
    <property name="connection.connection_string">Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\Database11.accdb</property>
    <property name="proxyfactory.factory_class">NHibernate.ByteCode.LinFu.ProxyFactoryFactory, NHibernate.ByteCode.LinFu</property>
  </session-factory>
</hibernate-configuration>


User.cs:
Code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace NhibernateTest
{
    class User
    {
        public int ID { get; set; }
        public string firstName { get; set; }
        public string lastName { get; set; }
    }
}


User.hbm.xml:
Code:
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2"
                   assembly="NhibernateTest"
                   namespace="NhibernateTest">

  <!-- more mapping info here -->
  <class name="User" Table="User">
    <id name="ID" />
    <property name="firstName"/>
    <property name="lastName"/>
  </class>
 
</hibernate-mapping>


Form1.cs (testing a call to the database):
Code:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using NHibernate;
using NHibernate.Linq;
using NHibernate.Cfg;

namespace NhibernateTest
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();

            var cfg = new Configuration();
            cfg.Configure();
            cfg.AddAssembly(typeof(User).Assembly);
            ISession db = cfg.BuildSessionFactory().OpenSession();
            var test = db.Query<User>().ToList();
        }
    }
}


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

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.