-->
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: Registerred function doesn't work in dynamic instantiation
PostPosted: Fri Apr 11, 2014 6:25 am 
Newbie

Joined: Fri Apr 11, 2014 6:11 am
Posts: 3
Hi All,
I'm new of this forum an I want to thanks in advance every one who could help me.

I'm using
    Hibernate 3.6
    jtds 1.2.7
    SQLserver database

I crate my custom dialect, registering the convert function as to_date as follow:

public class MySQLServerDialect extends org.hibernate.dialect.SQLServerDialect{
Code:
    public SQLServerDialect() {
        super();
        registerFunction("TO_DATE", new SQLFunctionTemplate(StandardBasicTypes.DATE, "Convert(DATETIME, ?1 ,112)"));
    }


The function works correctly in HQL when it is in where clause, see example as follow
Code:
from MyObject o
where to_date(o.firstDate) < :date


Otherwise I've aproblem when I use it as follow:

Code:
select new map(to_date(o.firstDate) as myDate)
from MyObject o


here is the stacktrace I get when hibernate try to instantiate the session factory:

Code:
ERROR it.netechgroup.discoveryleasing.ImportLeasing.perform() - java.lang.NullPointerException
java.lang.NullPointerException
   at org.hibernate.hql.NameGenerator.generateColumnNames(NameGenerator.java:46)
   at org.hibernate.hql.ast.util.SessionFactoryHelper.generateColumnNames(SessionFactoryHelper.java:410)
   at org.hibernate.hql.ast.tree.SelectClause.initializeColumnNames(SelectClause.java:257)
   at org.hibernate.hql.ast.tree.SelectClause.finishInitialization(SelectClause.java:247)
   at org.hibernate.hql.ast.tree.SelectClause.initializeExplicitSelectClause(SelectClause.java:242)
   at org.hibernate.hql.ast.HqlSqlWalker.useSelectClause(HqlSqlWalker.java:852)
   at org.hibernate.hql.ast.HqlSqlWalker.processQuery(HqlSqlWalker.java:640)
   at org.hibernate.hql.antlr.HqlSqlBaseWalker.query(HqlSqlBaseWalker.java:685)
   at org.hibernate.hql.antlr.HqlSqlBaseWalker.selectStatement(HqlSqlBaseWalker.java:301)
   at org.hibernate.hql.antlr.HqlSqlBaseWalker.statement(HqlSqlBaseWalker.java:244)
   at org.hibernate.hql.ast.QueryTranslatorImpl.analyze(QueryTranslatorImpl.java:254)
   at org.hibernate.hql.ast.QueryTranslatorImpl.doCompile(QueryTranslatorImpl.java:185)
   at org.hibernate.hql.ast.QueryTranslatorImpl.compile(QueryTranslatorImpl.java:136)
   at org.hibernate.engine.query.HQLQueryPlan.<init>(HQLQueryPlan.java:101)
   at org.hibernate.engine.query.HQLQueryPlan.<init>(HQLQueryPlan.java:80)
   at org.hibernate.engine.query.QueryPlanCache.getHQLQueryPlan(QueryPlanCache.java:124)
   at org.hibernate.impl.SessionFactoryImpl.checkNamedQueries(SessionFactoryImpl.java:547)
   at org.hibernate.impl.SessionFactoryImpl.<init>(SessionFactoryImpl.java:411)
   at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1842)



Any help would be apreciated, many thanks


Top
 Profile  
 
 Post subject: Re: Registerred function doesn't work in dynamic instantiation
PostPosted: Tue Apr 15, 2014 5:39 am 
Newbie

Joined: Fri Apr 11, 2014 6:11 am
Posts: 3
sorry for upping, but anyone have similar problem?

In Addition, debugging hibernate code, I see that querywalker seems to be not able to resolve the type (Date, int or other) of a function used inside dynamic instantiation.


Top
 Profile  
 
 Post subject: Re: Registerred function doesn't work in dynamic instantiation
PostPosted: Wed Jul 02, 2014 12:10 pm 
Newbie

Joined: Fri Apr 11, 2014 6:11 am
Posts: 3
just an other up, may be some one have a work around
thx anyone


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.