-->
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: QuerySyntaxException: entity class name obfuscation
PostPosted: Sat Jul 10, 2010 7:05 am 
Senior
Senior

Joined: Tue Sep 13, 2005 2:01 am
Posts: 137
Hi,
I use JBoss 5.1 that uses Hibernate core 3.3.1 and EntityManager 3.4.0.

I tried to use proguard to obfuscate entity class names. For example,

@Entity(name="Foo")
class Foo --> f

@Entity(name="Bar")
class Bar --> g

NamedQuery:
select a from Foo a, Bar b where ....

org.hibernate.hql.ast.QuerySyntaxException: ??? is not mapped.
From debug, the query string is correctly passed to Hibernate. where the three question marks come from? Thanks for help.

at org.hibernate.hql.ast.util.SessionFactoryHelper.requireClassPersister(SessionFactoryHelper.java:181)
at org.hibernate.hql.ast.tree.FromElementFactory.addFromElement(FromElementFactory.java:110)
at org.hibernate.hql.ast.tree.FromClause.addFromElement(FromClause.java:93)
at org.hibernate.hql.ast.HqlSqlWalker.createFromElement(HqlSqlWalker.java:277)
at org.hibernate.hql.antlr.HqlSqlBaseWalker.fromElement(HqlSqlBaseWalker.java:3056)
at org.hibernate.hql.antlr.HqlSqlBaseWalker.fromElementList(HqlSqlBaseWalker.java:2945)
at org.hibernate.hql.antlr.HqlSqlBaseWalker.fromClause(HqlSqlBaseWalker.java:688)
at org.hibernate.hql.antlr.HqlSqlBaseWalker.query(HqlSqlBaseWalker.java:544)
at org.hibernate.hql.antlr.HqlSqlBaseWalker.selectStatement(HqlSqlBaseWalker.java:281)
at org.hibernate.hql.antlr.HqlSqlBaseWalker.statement(HqlSqlBaseWalker.java:229)
at org.hibernate.hql.ast.QueryTranslatorImpl.analyze(QueryTranslatorImpl.java:251)
at org.hibernate.hql.ast.QueryTranslatorImpl.doCompile(QueryTranslatorImpl.java:183)
at org.hibernate.hql.ast.QueryTranslatorImpl.compile(QueryTranslatorImpl.java:134)
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:94)
at org.hibernate.impl.SessionFactoryImpl.checkNamedQueries(SessionFactoryImpl.java:436)
at org.hibernate.impl.SessionFactoryImpl.<init>(SessionFactoryImpl.java:384)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1327)
at org.hibernate.cfg.AnnotationConfiguration.buildSessionFactory(AnnotationConfiguration.java:867)
at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:669)


Top
 Profile  
 
 Post subject: Re: QuerySyntaxException: entity class name obfuscation
PostPosted: Thu Jul 22, 2010 12:55 am 
Senior
Senior

Joined: Tue Sep 13, 2005 2:01 am
Posts: 137
I tried the following again:

package mypackage;

@Entity(name="Student")
@Table(name="Student")
class Student {
age,
name
}

HQL:
select distinct c from Student c where c.age>=20 order by c.name desc

It works fine.

After obfuscation, the Student class name becomes a;
(From the following error message). The entity name and table name is not changed.

Caused by: java.lang.IllegalArgumentException: org.hibernate.hql.ast.QuerySyntaxException: ??? is not mapped [select distinct c from mypackage.a c where c.age>=20 order by c.name desc]

The mesage should let me know which is not mapped, but it shows question marks.

DetachedCriteria works fine before and after obfuscation.

Thanks for help. any ideas are appreciated.

Dave


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.