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: User defined SQL functions
PostPosted: Mon Apr 14, 2008 10:32 am 
Regular
Regular

Joined: Thu Mar 06, 2008 5:06 am
Posts: 68
I want to use own sql functions in my hql queries. so I defined a subclass for MsSql2005Dialect:



Code:
    public class SqlServerDialect : MsSql2005Dialect
    {
        public SqlServerDialect()
            : base()
        {
            RegisterFunction("bit_not", new SQLFunctionTemplate(NHibernateUtil.Int32, "~?1"));
            RegisterFunction("bit_and", new VarArgsSQLFunction(NHibernateUtil.Int32, "(", "&", ")"));
            RegisterFunction("bit_or", new VarArgsSQLFunction(NHibernateUtil.Int32, "(", "|", ")"));
        }
    }


But in my queries these functions are not replaced. So I get the SqlException, that the function is not recognized...

Any ideas?

bit_and(x, y) in hql should be replaced with (x & y) in sql query.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Apr 15, 2008 2:05 am 
Regular
Regular

Joined: Thu Mar 06, 2008 5:06 am
Posts: 68
Nobody? Please, every little hint is welcome...


Top
 Profile  
 
 Post subject:
PostPosted: Tue Apr 15, 2008 4:32 am 
Regular
Regular

Joined: Thu Mar 06, 2008 5:06 am
Posts: 68
A few tests have shown, that even build-in functions like concat etc. are not replaced with the dialect specific ones.

What could be the reason?

I have inherited the Dialect class from MsSql2005Dialect like shown above. And I have told NHibernate to use this dialect in the config file. I know that NHibernate uses this dialect - a simple Console.Out.Write() in the constructor is executed several times...


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.