-->
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.  [ 4 posts ] 
Author Message
 Post subject: Debugging actual sql-statement (JetDialect)?
PostPosted: Wed Dec 14, 2005 2:03 pm 
Beginner
Beginner

Joined: Thu Oct 20, 2005 9:26 am
Posts: 27
Location: Barcelona
Hi,

I get an SQL error trying to create or retrieve data from my MS Access database. I'm using the new JetDialect, but can't find out what's wrong.
And on top of that I have problems finding the actual SQL statement sent to the database.
I have downloaded the source to NHibernate and tried to debug it all the way, but ends with a OleDbCommand that contains the cmdText for example as "INSERT INTO User_s (email, createtime, password, username, imagename) VALUES (?, ?, ?, ?, ?)" and the parameters separated. I have tried to manually execute the resulting statement directly on the database, but that works fine.
Then I tried enabling logging for NHibernate.SQL, but the closest I get to usable information is:
2005-12-14 18:52:30,866 [608] DEBUG NHibernate.Impl.BatcherImpl [(null)] <(null)> - Building an IDbCommand object for the SqlString: INSERT INTO User_s (email, createtime, password, username, imagename) VALUES (:email, :createtime, :password, :username, :imagename)
2005-12-14 18:52:30,866 [608] DEBUG NHibernate.Persister.EntityPersister [(null)] &lt;(null)&gt; - Dehydrating entity: [TheBrightSide.Powerpage.Business.Data.User#<null>]
2005-12-14 18:52:30,876 [608] DEBUG NHibernate.Type.StringType [(null)] &lt;(null)&gt; - binding 'TestEmail' to parameter: 0
2005-12-14 18:52:30,917 [608] DEBUG NHibernate.Type.DateTimeType [(null)] &lt;(null)&gt; - binding '14/12/2005' to parameter: 1
2005-12-14 18:52:30,917 [608] DEBUG NHibernate.Type.StringType [(null)] &lt;(null)&gt; - binding 'TestPassword' to parameter: 2
2005-12-14 18:52:30,917 [608] DEBUG NHibernate.Type.StringType [(null)] &lt;(null)&gt; - binding 'TestName' to parameter: 3
2005-12-14 18:52:30,917 [608] DEBUG NHibernate.Type.StringType [(null)] &lt;(null)&gt; - binding '' to parameter: 4
2005-12-14 18:52:30,927 [608] DEBUG NHibernate.SQL [(null)] &lt;(null)&gt; - INSERT INTO User_s (email, createtime, password, username, imagename) VALUES (?, ?, ?, ?, ?)
2005-12-14 18:52:30,927 [608] DEBUG NHibernate.SQL [(null)] &lt;(null)&gt; - INSERT INTO User_s (email, createtime, password, username, imagename) VALUES (?, ?, ?, ?, ?)
2005-12-14 18:57:20,563 [608] DEBUG NHibernate.Impl.BatcherImpl [(null)] &lt;(null)&gt; - Closed IDbCommand, open IDbCommands :0
2005-12-14 18:57:20,573 [608] DEBUG NHibernate.Util.ADOExceptionReporter [(null)] &lt;(null)&gt; - could not insert: [TheBrightSide.Powerpage.Business.Data.User]
System.Data.OleDb.OleDbException: Syntax error in INSERT INTO statement.
Again, not the actual actual SQL statement sent to the database. Isn't there some way to get that?

Or anyone knows what might be my problem?

Thanks in advance,
David


Top
 Profile  
 
 Post subject:
PostPosted: Wed Dec 14, 2005 2:50 pm 
Beginner
Beginner

Joined: Thu Oct 20, 2005 9:26 am
Posts: 27
Location: Barcelona
Ok, finally found the problem.
I tried taking out all but one of the parameters in the mapping-file and then added them one by one again until I found the problem: "Password".
It's apparently a reserved word in Access. As well as User, which I already had changed. But the list I was looking at: http://support.microsoft.com/default.as ... 5D;Q286335
doesn't contain "password". :(
I think that the dialect should take care of that, if possible, but I haven't got the time now to add that. Anyway changing the mapping to table="[Password]" instead of "Password" solves the problem.

/David


Top
 Profile  
 
 Post subject:
PostPosted: Wed Dec 14, 2005 9:06 pm 
Beginner
Beginner

Joined: Thu Oct 20, 2005 9:26 am
Posts: 27
Location: Barcelona
Using the [] for column names apparently doesn't work with the select statement generated. So I've ended up calling the table User and writing table="[User]" in the mapping file, and the column i've changed to "pwd".


Top
 Profile  
 
 Post subject:
PostPosted: Thu Dec 15, 2005 8:04 am 
Contributor
Contributor

Joined: Wed May 11, 2005 4:59 pm
Posts: 1766
Location: Prague, Czech Republic
Try backticks (``) instead of brackets.


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