-->
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: Mssql keyword File?
PostPosted: Sat Dec 24, 2005 2:46 am 
Newbie

Joined: Sat Dec 24, 2005 2:15 am
Posts: 6
Location: Melbourne
I am using Ms Sql Server and I know that when using the keyword file I should put square braces around it within my query so it will be [file].

So how do I get around this when using nhibernate? Or do I even need to worry about it?
What Im trying to achieve is I want to get back a file based on the following query ie:

string query = "from File as f where f.CharacterID.CharacterID = :charID" +" AND f.FileExtension = :fileEx";
file = (File) session.CreateQuery(query).SetInt32("charID", 5).SetString("fileEx", ".txt")

mapping file:

<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.0" default-access="property">
<class name="LicenseManagerDB.BusinessObjects.File, LicenseManagerDB" table="file">
<id name="FileID" column="fileid">
<generator class="identity" />
</id>
<property name="FileName" column="fileName" />
<many-to-one name="CharacterID" class="LicenseManagerDB.BusinessObjects.Character, LicenseManagerDB" column="characterid" not-null="true" />
<property name="FileSize" column="fileSize" />
<property name="ForPublic" column="forPublic" />
<property name="FileLocation" column="fileLocation" />
<property name="FileExtension" column="fileExtension" />
</class>
</hibernate-mapping>

The error message is: Specified cast is not valid.


Top
 Profile  
 
 Post subject:
PostPosted: Sat Dec 24, 2005 4:39 am 
Newbie

Joined: Sat Dec 24, 2005 2:15 am
Posts: 6
Location: Melbourne
I have also tried assigning the result of the query to be of type object. I thought I might beable to interogate the object to get any other information. THis time the error is:

Begin failed with SQL exception NHibernate.TransactionException: Begin failed with SQL exception ---> System.InvalidOperationException: SqlConnection does not support parallel transactions. at System.Data.SqlClient.SqlConnection.BeginTransaction(IsolationLevel iso) ........ and more stack stuff.
I also got the above error when using the Get(typeof(File),1) etc etc.

GB


Top
 Profile  
 
 Post subject:
PostPosted: Sat Dec 24, 2005 6:35 am 
Senior
Senior

Joined: Sat May 14, 2005 8:40 am
Posts: 130
I don't see any types for the properties in the mapping file. Maybe that's the reason for the first error message.

Regarding kewords: you can escape those in the mapping file by using backticks (`). It will translate to [] on SQL Server.

_________________
Cuyahoga


Top
 Profile  
 
 Post subject:
PostPosted: Wed Dec 28, 2005 1:10 am 
Newbie

Joined: Sat Dec 24, 2005 2:15 am
Posts: 6
Location: Melbourne
After I entered the types in my xml file (prob still hanging around) I discovered that I cant use the SetString() method when the string Im trying to set has a dot in it. Im using ver 0.9.1.0. is there a bug here? Have got around the problem by appending the query string and passing it to the CreateQuery() method.
However would be great if someone could help to explain what a parallel transaction is and why does this error occur. Thanks.


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.