Ygg01 / hibernate-generic-dao

Automatically exported from code.google.com/p/hibernate-generic-dao
0 stars 0 forks source link

Invalid query when property is of type Class<?> #86

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
NOTE: If you have a question rather than a bug report or feature request,
please post at http://groups.google.com/group/java-generic-dao .

What steps will reproduce the problem?
1. Define a POJO with a Class<?> targetClass attribute
2. Run a search: return search(new Search().addFilterEqual("targetClass", 
targetClass));

What is the expected output? What do you see instead?

The query generated is:
  select _it from com.joss.common.domain.AttributeDefinition _it where _it.targetClass = com.joss.common.domain.LegalEntity

DOT node with no left-hand-side!

java.lang.IllegalStateException: DOT node with no left-hand-side!
    at org.hibernate.hql.ast.tree.DotNode.getLhs(DotNode.java:637)
    at org.hibernate.hql.ast.tree.DotNode.getDataType(DotNode.java:612)
    at org.hibernate.hql.ast.tree.BinaryLogicOperatorNode.extractDataType(BinaryLogicOperatorNode.java:210)
    at org.hibernate.hql.ast.tree.BinaryLogicOperatorNode.initialize(BinaryLogicOperatorNode.java:58)
    at org.hibernate.hql.ast.HqlSqlWalker.prepareLogicOperator(HqlSqlWalker.java:1133)
    at org.hibernate.hql.antlr.HqlSqlBaseWalker.comparisonExpr(HqlSqlBaseWalker.java:4189)
    at org.hibernate.hql.antlr.HqlSqlBaseWalker.logicalExpr(HqlSqlBaseWalker.java:1864)
    at org.hibernate.hql.antlr.HqlSqlBaseWalker.whereClause(HqlSqlBaseWalker.java:818)
    at org.hibernate.hql.antlr.HqlSqlBaseWalker.query(HqlSqlBaseWalker.java:604)
    at org.hibernate.hql.antlr.HqlSqlBaseWalker.selectStatement(HqlSqlBaseWalker.java:288)
    at org.hibernate.hql.antlr.HqlSqlBaseWalker.statement(HqlSqlBaseWalker.java:231)
    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.(HQLQueryPlan.java:101)
    at org.hibernate.engine.query.HQLQueryPlan.(HQLQueryPlan.java:80)
    at org.hibernate.engine.query.QueryPlanCache.getHQLQueryPlan(QueryPlanCache.java:94)
    at org.hibernate.impl.AbstractSessionImpl.getHQLQueryPlan(AbstractSessionImpl.java:156)
    at org.hibernate.impl.AbstractSessionImpl.createQuery(AbstractSessionImpl.java:135)
    at org.hibernate.impl.SessionImpl.createQuery(SessionImpl.java:1651)
    at org.hibernate.ejb.AbstractEntityManagerImpl.createQuery(AbstractEntityManagerImpl.java:93)
    at sun.reflect.GeneratedMethodAccessor82.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at org.springframework.orm.jpa.ExtendedEntityManagerCreator$ExtendedEntityManagerInvocationHandler.invoke(ExtendedEntityManagerCreator.java:365)
    at $Proxy204.createQuery(Unknown Source)
    at sun.reflect.GeneratedMethodAccessor82.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at org.springframework.orm.jpa.SharedEntityManagerCreator$SharedEntityManagerInvocationHandler.invoke(SharedEntityManagerCreator.java:240)
    at $Proxy204.createQuery(Unknown Source)
    at com.trg.search.jpa.JPASearchProcessor.search(JPASearchProcessor.java:89)
    at com.trg.dao.jpa.JPABaseDAO._search(JPABaseDAO.java:322)
    at com.trg.dao.jpa.GenericDAOImpl.search(GenericDAOImpl.java:123)

What version of the product are you using? On what operating system?
0.5.1 / Mac OS X / JPA

Please provide any additional information below.
Commenting lines 765-767 in BaseSearchProcessor seems to fix the issue:

    protected String param(SearchContext ctx, Object value) {
        //if (value instanceof Class) {
        //  return ((Class<?>) value).getName();
        //}

Original issue reported on code.google.com by jserd...@gmail.com on 8 Feb 2011 at 6:55

GoogleCodeExporter commented 9 years ago
Is this relevant anymore?

Is the solution provided tested?

Original comment by pablit...@gmail.com on 14 Jun 2014 at 7:13