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.  [ 3 posts ] 
Author Message
 Post subject: Case When SQL Statement
PostPosted: Thu Jun 26, 2008 5:07 pm 
Newbie

Joined: Tue Apr 01, 2008 4:16 pm
Posts: 6
Hibernate version: 1.2

Name and version of the database you are using: SQL Server 2005

When trying to do any Session.CreateQuery("Select Case When...THEN...ELSE...END AS ReturnValue") type query I get this error:

NHibernate.QueryException : undefined alias or unknown mapping: case [select case when 1 then 1 else 0 end]

Any ideas?


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jun 27, 2008 3:36 am 
Expert
Expert

Joined: Thu Dec 14, 2006 5:57 am
Posts: 1185
Location: Zurich, Switzerland
Afaik, this is not supported in HQL, try a SQL query instead:

session.CreateSQLQuery(...)

Have a look at http://www.hibernate.org/hib_docs/nhibernate/1.2/reference/en/html/querysql.html

_________________
--Wolfgang


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jul 02, 2008 1:55 am 
Beginner
Beginner

Joined: Sun Oct 22, 2006 12:06 pm
Posts: 39
For this scenario you can use unmapped business object

Case Version when 10 then 1 else 0 end

Code:
Class Issue
{
    //this is mapped property in xml
    int virtual Version {get; set;}

//this is not mapped value
    bool virtual IsVersionTen
   {
        return Version==10;
   }

}


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