-->
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.  [ 7 posts ] 
Author Message
 Post subject: Troubles with getting data from an MS Access database
PostPosted: Fri Jan 27, 2006 4:02 pm 
Newbie

Joined: Fri Jan 27, 2006 3:35 pm
Posts: 4
Location: Netherlands
I'm making use of the NHibernate.JetDriver.dll to connect to a MS Access database.

My hibernate.cfg.xml is set well. I can connect to the database.

When i want to perform a query to get all objects of type 'Productgroep' i get the following error:

Unable to perform find
The microsoft jet-database-engine can't find the table or -query Productgroepen. Make sure this table exists and is spelled well.

This is my mapping file:

Code:
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.0" namespace="Funsales.Website.Business" assembly="Funsales.Website.Business">
   <class name="Productgroep" table="Productgroepen">
      <id name="id" column="p_id" type="System.Int32" unsaved-value="0">
         <generator class="native" />
      </id>
      <property name="code" column="code" not-null="false" />
      <property name="omschrijving" column="omschrijving" not-null="false" />

    <bag name="producten" inverse="false" cascade="save-update" table="Product">
      <key column="productgroep"></key>
      <one-to-many class="Funsales.Website.Business.Product"></one-to-many>
    </bag>
  </class>
</hibernate-mapping>


When i open the database, the table 'Productgroepen' does excist and it's exactly the same name.

This is my C# code:

Code:
              ICriteria criteria = m_session.CreateCriteria(typeof(Productgroep));
                productgroepen = criteria.List();

                if (productgroepen == null || productgroepen.Count < 1)
                    return null;
                else
                    return productgroepen;


What is wrong? (same project works on a sql server 2000 database)


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jan 27, 2006 6:10 pm 
Newbie

Joined: Fri Jan 27, 2006 3:35 pm
Posts: 4
Location: Netherlands
Little update:

I figured out what query nhibernate fires to my access database:

SELECT this.p_id as p_id0_, this.code as code0_, this.omschrijving as omschrij3_0_ FROM Productgroepen this WHERE 1=1

I tested this query inside msaccess and it did return a good recordset.

There might seem to be a fault in my configuration. Do i need to set my initial catalog?


Top
 Profile  
 
 Post subject:
PostPosted: Wed Feb 01, 2006 1:34 pm 
Newbie

Joined: Fri Jan 27, 2006 3:35 pm
Posts: 4
Location: Netherlands
no one? :(


Top
 Profile  
 
 Post subject:
PostPosted: Thu Feb 02, 2006 1:54 pm 
Newbie

Joined: Wed Nov 02, 2005 9:52 am
Posts: 18
Location: Argentina
Hello!

Code:
productgroepen = criteria.List();


productgroepen is an IList ? or is a instance of productgroepen ?

I supose you must use:

Code:
IList ProductgroepenList  = criteria.List();


Top
 Profile  
 
 Post subject:
PostPosted: Sat Feb 04, 2006 7:41 am 
Newbie

Joined: Fri Jan 27, 2006 3:35 pm
Posts: 4
Location: Netherlands
Thx for your reply!

productgroepen is an IList yes. So i dont think that is te problem


Top
 Profile  
 
 Post subject:
PostPosted: Sun Feb 05, 2006 7:57 pm 
Senior
Senior

Joined: Wed Jun 15, 2005 4:17 am
Posts: 156
how does the config file looks like?

cheers,
radu


Top
 Profile  
 
 Post subject: Table=??
PostPosted: Mon Feb 06, 2006 12:01 am 
Regular
Regular

Joined: Tue Jan 03, 2006 7:21 am
Posts: 85
I do not think this is the problem but I do not think you need to define the table="Product" in the bag definition. I think table is needed only in case of many-many relationship.

Try by removing this and see if this helps.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 7 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.