-->
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.  [ 2 posts ] 
Author Message
 Post subject: Tablenamequoting in Query not accepted!
PostPosted: Wed Apr 06, 2005 4:42 am 
Beginner
Beginner

Joined: Sat Jan 01, 2005 12:18 pm
Posts: 23
Hibernate version: 3.0
Database version: Postgres 7.4.7

I have a legacy database with special characters as tablenames that have to be quoted in order to be found:

Code:
        Session session = HibernateUtilImport.getSession();
        List result = null;
        try {
            Query q = session.createQuery("select distinct `Resistances` from `Vectors`");
            result = q.list();
        } catch (HibernateException ex) {
            throw new InfrastructureException(ex);
        }
        return result;


I also tried it with the charaters: \" and '

Hibernate returns following message:

Code:
[java] org.hibernate.QueryException: unexpected char: '`' [select distinct `Resistances` from `Vectors`]
     [java] at org.hibernate.hql.ast.QueryTranslatorImpl.doCompile(QueryTranslatorImpl.java:165)
     [java] at org.hibernate.hql.ast.QueryTranslatorImpl.compile(QueryTranslatorImpl.java:83)
     [java] at org.hibernate.impl.SessionFactoryImpl.getQuery(SessionFactoryImpl.java:414)
     [java] at org.hibernate.impl.SessionImpl.getQueries(SessionImpl.java:821)
     [java] at org.hibernate.impl.SessionImpl.list(SessionImpl.java:779)
     [java] at org.hibernate.impl.QueryImpl.list(QueryImpl.java:74)
     [java] at at.insilico.madmama.mapper.dao.GenericServiceDAOExport.getObjectsByQuery(GenericServiceDAOExport.java:118)
     [java] at at.insilico.madmama.mapper.transformer.CloneTransformer.makeVectorResistance(CloneTransformer.java:330)
     [java] at at.insilico.madmama.mapper.Loader.<init>(Loader.java:32)
     [java] at at.insilico.madmama.mapper.Main.main(Main.java:8)
     [java] Caused by: line 1:17: unexpected char: '`'
     [java] at org.hibernate.hql.antlr.HqlBaseLexer.nextToken(HqlBaseLexer.java:279)
     [java] at antlr.TokenBuffer.fill(TokenBuffer.java:69)
     [java] at antlr.TokenBuffer.LA(TokenBuffer.java:80)
     [java] at antlr.LLkParser.LA(LLkParser.java:52)
     [java] at org.hibernate.hql.antlr.HqlBaseParser.selectClause(HqlBaseParser.java:873)
     [java] at org.hibernate.hql.antlr.HqlBaseParser.selectFrom(HqlBaseParser.java:658)
     [java] at org.hibernate.hql.antlr.HqlBaseParser.queryRule(HqlBaseParser.java:573)
     [java] at org.hibernate.hql.antlr.HqlBaseParser.selectStatement(HqlBaseParser.java:263)
     [java] at org.hibernate.hql.antlr.HqlBaseParser.statement(HqlBaseParser.java:150)
     [java] at org.hibernate.hql.ast.QueryTranslatorImpl.parse(QueryTranslatorImpl.java:209)
     [java] at org.hibernate.hql.ast.QueryTranslatorImpl.doCompile(QueryTranslatorImpl.java:127)


Top
 Profile  
 
 Post subject:
PostPosted: Wed Apr 06, 2005 6:01 am 
CGLIB Developer
CGLIB Developer

Joined: Thu Aug 28, 2003 1:44 pm
Posts: 1217
Location: Vilnius, Lithuania
quote table manes in mapping, queries use application class names.


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