History | Log In     View a printable version of the current page.  
Issue Details (XML | Word | Printable)

Key: NH-437
Type: Bug Bug
Status: Closed Closed
Resolution: Fixed
Priority: Major Major
Assignee: Sergey Koshcheyev
Reporter: Lukas Krejci
Votes: 1
Watchers: 3
Operations

If you were logged in you would be able to see more operations.
NHibernate

CLONE -MS Access Dialect and Driver

Created: 28/Oct/05 04:43 AM   Updated: 23/Dec/05 02:34 AM
Component/s: Data Providers
Affects Version/s: prealpha
Fix Version/s: 1.0.1

File Attachments: 1. Zip Archive JetDialect.zip (11 kb)



 Description  « Hide
The OleDb command object fails to prepare when the FROM stmt uses multiple JOIN commands.

 All   Comments   Change History      Sort Order: Ascending order - Click to sort in descending order
Lukas Krejci - 28/Oct/05 04:57 AM
I gave it some time and tried to make a decent Access dialect for NHibernate. The solution passes most of the (modified) NHibernate tests.
These are the limitations of Access dialect:
-- no Int64 support (Int64 is silently converted to Int32, possibly throwing an exception).
-- really no way how to force Access to accept "weird" characters ([$@! etc.) in table/column names even if quoted.

The implementation is not completely finished, I've had no time to register all the SQL functions for the dialect for example, but I hope it is complete enough for other people to start playing with and testing.

I had to implement System.Data.IDbCommand, System.Data.IDbConnection and System.Data.IDbTransaction in order to process everything allright, see class comments in JetDbCommand.

Hope someone will find this useful..

Lukas Krejci - 28/Oct/05 04:59 AM
The zipped files contains source for Jet Dialect and Driver.

Sergey Koshcheyev - 04/Nov/05 02:38 PM
Hmm, should I put this into the core source, or into NHibernateContrib?
By the way, Int64's could probably be turned into strings.

Sergey Koshcheyev - 07/Nov/05 08:23 AM
Added to NHibernateContrib.

Chorn Sokun - 17/Nov/05 08:06 PM
How do I use this Dialect?
Any sample?

Lukas Krejci - 18/Nov/05 03:28 AM
Using the dialect should be fairly easy..
Just reference the Nhibernate.JetDriver.dll in your project and set:
hibernate.dialect configuration setting to "NHibernate.JetDriver.JetDialect, NHibernate.JetDriver",
hibernate.connection.driver_class to "NHibernate.JetDriver.JetDriver, NHibernate.JetDriver" and
hibernate.connection.connection_string to standard OLE connection string for MS Access, ie. something like "Provider=Microsoft.Jet.OLEDB.4.0;User ID=xxx;Data Source=path\to\your\db.mdb"

The rest should be standard work with NHibernate, you just have to be aware of limitations of MS Access regarding number of foreign keys in the database, query complexity (a beautiful "Query too complex" error from Access when your query contains more than 99 (or 40? I don't remeber exactly) columns or the WHERE expression is "too complex" or there are too many joins in the statement), etc. You also don't want any special characters in column names, because quoting in MS Access doesn't work as one would expect.

If you want some working examples, you can change the configuration of tests in nhibernate source to use the dialect :) Most of them should work (after you modify the column names in mapping files). The most complex tests don't work because of the reasons mentioned above.

Lukas Krejci - 18/Nov/05 03:40 AM
The comment above applies to the version of the dialect present in NHibernateContrib, not the one attached here, that have different namespaces..

Rafael Agundo - 23/Dec/05 02:34 AM
First of all, thanks for your dialect. Using NHibernate with Access was a real pain until now.

I can't undesrtand why you mix DbType.Time, DbType.Date and DbType.DateTime and format them using the pattern "dd-MMM-yyyy HH:mm:ss". I had to modify JetDbCommand.cs and format DbType.Time with "HH:mm:ss" and DbType.Date with "dd-MMM-yyyy" in order to get correct inserts into my database.

Also, I'm having problems with the Decimal type. I'm Spanish and numbers are expresed 12.345,123 not 12,345.123 like in English culture. But Nhibernate inserts Decimal type in my database in english format. I don't know if this is a problem of this dialect or not.