-->
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: Query (IQuery-Objekt) mit toLower (case-insensitive)?
PostPosted: Tue Jul 22, 2008 3:15 pm 
Newbie

Joined: Tue Jul 22, 2008 3:06 pm
Posts: 1
Hi,

NHibernate-Version: Build 1.2.1
ich möchte eine Query mit dem IQuery-Objekt erstellen, welche die Properties in dieser mit toLower (case-insensitive) abfragt. Ist dies möglich. Ich habe dies bisher nur mit dem Criteria-Objekt durchgeführt.

Hier meine Funktionen:
'todo: query mit tolower
Friend Shared Function GetItem(Of itemType)(ByVal strQuery As String) As itemType
Dim objTx As ITransaction = Nothing
Dim objResult As itemType = Nothing
Try
GetSession()
objTx = m_objSess.BeginTransaction()
With m_objSess.CreateQuery("from :class where :query")
.SetParameter("class", GetType(itemType).Name)
.SetEntity("query", strQuery)
objResult = .UniqueResult(Of itemType)()
End With
Catch ex As Exception
objTx.Rollback()
End Try
Return objResult
End Function
Friend Shared Function GetItem(Of itemType, itemQueryType)(ByVal objQuery As itemQueryType) As itemType
Dim objTx As ITransaction = Nothing
Dim objResult As itemType = Nothing
Try
GetSession()
objTx = m_objSess.BeginTransaction()
With m_objSess.CreateQuery("from :class where :query")
.SetParameter("class", GetType(itemType).Name)
.SetEntity("query", objQuery)
objResult = .UniqueResult(Of itemType)()
End With
Catch ex As Exception
objTx.Rollback()
End Try
Return objResult
End Function

Noch eine Frage: Muss ich wirklich immer eine Transaction machen, auch wenn ich nur Daten abfrage?

Besten Dank

Johannes


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.