-->
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.  [ 31 posts ]  Go to page 1, 2, 3  Next
Author Message
 Post subject: 3.2.0GA breaks query that works on 3.2.0CR2
PostPosted: Tue Oct 17, 2006 6:32 am 
Senior
Senior

Joined: Tue Jul 25, 2006 9:05 am
Posts: 163
Location: Stuttgart/Karlsruhe, Germany
Hibernate version: 3.2.0GA

Mapping documents: none annotations being used

Full stack trace of any exception that occurs:
Code:
Caused by: javax.ejb.EJBException: java.lang.NullPointerException
        at org.jboss.ejb3.tx.Ejb3TxPolicy.handleExceptionInOurTx(Ejb3TxPolicy.java:69)
        at org.jboss.aspects.tx.TxPolicy.invokeInOurTx(TxPolicy.java:83)
        at org.jboss.aspects.tx.TxInterceptor$Required.invoke(TxInterceptor.java:197)
        at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
        at org.jboss.aspects.tx.TxPropagationInterceptor.invoke(TxPropagationInterceptor.java:76)
        at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
        at org.jboss.ejb3.stateless.StatelessInstanceInterceptor.invoke(StatelessInstanceInterceptor.java:62)
        at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
        at org.jboss.aspects.security.AuthenticationInterceptor.invoke(AuthenticationInterceptor.java:78)
        at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
        at org.jboss.ejb3.ENCPropagationInterceptor.invoke(ENCPropagationInterceptor.java:47)
        at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
        at org.jboss.ejb3.asynchronous.AsynchronousInterceptor.invoke(AsynchronousInterceptor.java:106)
        at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
        at org.jboss.ejb3.stateless.StatelessContainer.localInvoke(StatelessContainer.java:181)
        at org.jboss.ejb3.stateless.StatelessLocalProxy.invoke(StatelessLocalProxy.java:79)
        at $Proxy123.queryStructure(Unknown Source)
        at XXX.queryData(MetadataTest.java:43)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:585)
        at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:155)
        ... 29 more
Caused by: java.lang.NullPointerException
        at org.hibernate.hql.ast.tree.FromClause.findIntendedAliasedFromElementBasedOnCrazyJPARequirements(FromClause.java:120)
        at org.hibernate.hql.ast.tree.FromClause.containsClassAlias(FromClause.java:247)
        at org.hibernate.hql.ast.tree.FromClause.isFromElementAlias(FromClause.java:135)
        at org.hibernate.hql.ast.HqlSqlWalker.isNonQualifiedPropertyRef(HqlSqlWalker.java:474)
        at org.hibernate.hql.antlr.HqlSqlBaseWalker.addrExpr(HqlSqlBaseWalker.java:4382)
        at org.hibernate.hql.antlr.HqlSqlBaseWalker.expr(HqlSqlBaseWalker.java:1212)
        at org.hibernate.hql.antlr.HqlSqlBaseWalker.exprOrSubquery(HqlSqlBaseWalker.java:4041)
        at org.hibernate.hql.antlr.HqlSqlBaseWalker.comparisonExpr(HqlSqlBaseWalker.java:3528)
        at org.hibernate.hql.antlr.HqlSqlBaseWalker.logicalExpr(HqlSqlBaseWalker.java:1762)
        at org.hibernate.hql.antlr.HqlSqlBaseWalker.logicalExpr(HqlSqlBaseWalker.java:1690)
        at org.hibernate.hql.antlr.HqlSqlBaseWalker.whereClause(HqlSqlBaseWalker.java:776)
        at org.hibernate.hql.antlr.HqlSqlBaseWalker.query(HqlSqlBaseWalker.java:577)
        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:228)
        at org.hibernate.hql.ast.QueryTranslatorImpl.doCompile(QueryTranslatorImpl.java:160)
        at org.hibernate.hql.ast.QueryTranslatorImpl.compile(QueryTranslatorImpl.java:111)
        at org.hibernate.engine.query.HQLQueryPlan.<init>(HQLQueryPlan.java:77)
        at org.hibernate.engine.query.HQLQueryPlan.<init>(HQLQueryPlan.java:56)
        at org.hibernate.engine.query.QueryPlanCache.getHQLQueryPlan(QueryPlanCache.java:72)
        at org.hibernate.impl.AbstractSessionImpl.getHQLQueryPlan(AbstractSessionImpl.java:133)
        at org.hibernate.impl.AbstractSessionImpl.createQuery(AbstractSessionImpl.java:112)
        at org.hibernate.impl.SessionImpl.createQuery(SessionImpl.java:1623)
        at org.hibernate.ejb.AbstractEntityManagerImpl.createQuery(AbstractEntityManagerImpl.java:92)
        at org.jboss.ejb3.entity.TransactionScopedEntityManager.createQuery(TransactionScopedEntityManager.java:127)
        at XXX.queryStructure(MetaTestBean.java:55)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:585)
        at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:112)
        at org.jboss.ejb3.interceptor.InvocationContextImpl.proceed(InvocationContextImpl.java:166)
        at org.jboss.ejb3.interceptor.EJB3InterceptorsInterceptor.invoke(EJB3InterceptorsInterceptor.java:63)
        at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
        at org.jboss.ejb3.entity.TransactionScopedEntityManagerInterceptor.invoke(TransactionScopedEntityManagerInterceptor.java:54)
        at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
        at org.jboss.ejb3.AllowedOperationsInterceptor.invoke(AllowedOperationsInterceptor.java:47)
        at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
        at org.jboss.aspects.tx.TxPolicy.invokeInOurTx(TxPolicy.java:79)




Name and version of the database you are using: PostgreSQL 8.1.4

The generated SQL (show_sql=true):
With version 3.2.0GA no SQL is printed out as the exception occurs before then.
The same query that works with 3.2.0CR2 is:
Code:
select distinct expression2_.id as id19_0_, restrictio4_.id as id19_1_, expression5_.id as id20_2_, targetenti6_.id as id21_3_, expression2_.type as type19_0_, expression2_.description as descript4_19_0_, expression2_.expr as expr19_0_, expression2_.DISCRIMINATOR as DISCRIMI1_19_0_, restrictio4_.type as type19_1_, restrictio4_.description as descript4_19_1_, restrictio4_.expr as expr19_1_, restrictio3_.expressionhierarchy_id as expressi1_0__, restrictio3_.restrictions_id as restrict2_0__, restrictio3_.rule_index as rule3_0__, expression5_.expression_id as expression3_20_2_, expression5_.role as role20_2_, expression5_.targetEntity_id as targetEn4_20_2_, expression5_.expression_id as expression3_1__, expression5_.id as id1__, targetenti6_.clazz as clazz21_3_, targetenti6_.attrName as attrName21_3_, targetenti6_.pk as pk21_3_ from TargetEntity targetenti0_ inner join ExpressionTarget expression1_ on targetenti0_.id=expression1_.targetEntity_id left outer join expressionhierarchy expression2_ on expression1_.expression_id=expression2_.id left outer join expressionhierarchy_expressionhierarchy restrictio3_ on expression2_.id=restrictio3_.expressionhierarchy_id left outer join expressionhierarchy restrictio4_ on restrictio3_.restrictions_id=restrictio4_.id inner join ExpressionTarget expression5_ on restrictio4_.id=expression5_.expression_id inner join TargetEntity targetenti6_ on expression5_.targetEntity_id=targetenti6_.id where targetenti0_.id=? and expression2_.DISCRIMINATOR='rule

From the following java code
Query tmpQuery = mEntityManager.createQuery("SELECT DISTINCT e.expression FROM TargetEntity " +
                "t INNER JOIN t.expressionTargets e LEFT OUTER JOIN FETCH e.expression.restrictions r " +
                "JOIN FETCH r.expressionTargets f JOIN FETCH f.targetEntity " +
                "WHERE t.id = :pk AND e.expression.class = Rule").setParameter("pk", 1);


I downloaded 3.2.0GA yestrerday but it seems to have a problem with a query that worked perfectly well with 3.2.0CR2. I don't even know what the problem is as the exception raised is cryptic, but could it be something to do with the fact that there is a cylcle in the query ??

Or possibly i have not migrated from 3.2.0CR2 correctly, i just built everything (EntityManager, Annotation, and Core) and replace the hibernate3.jar, hibernate-annotations.jar, and hibernate-entitymanager.jar in the lib directory of the server, and hibernate-annotations.jar and hibernate-client.jar in the client directory. Is this the correct way to migrate, if not can you please point me to a url, as i could not find one.

Is this a bug in 3.2.0GA or is it a bug in 3.2.0CR2 that let this qery work in the first place ??

Thanks in advance,

Andy


Top
 Profile  
 
 Post subject:
PostPosted: Tue Oct 17, 2006 10:34 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
looks like a bug - submit a runnable failing testcase to jira

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Tue Oct 17, 2006 10:45 am 
Senior
Senior

Joined: Tue Jul 25, 2006 9:05 am
Posts: 163
Location: Stuttgart/Karlsruhe, Germany
Ok, i will submit it tomorrow.

Cheers,

Andy


Top
 Profile  
 
 Post subject:
PostPosted: Tue Oct 17, 2006 1:34 pm 
Senior
Senior

Joined: Tue Jul 25, 2006 9:05 am
Posts: 163
Location: Stuttgart/Karlsruhe, Germany
Do you want just the .ear archive which contains a MBean with the save and query routines, the java source, or both ?

Andy


Top
 Profile  
 
 Post subject:
PostPosted: Tue Oct 17, 2006 1:35 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
i just want a minimal test case (with source)

so a whole application is too much....

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Fri Oct 20, 2006 4:50 am 
Senior
Senior

Joined: Tue Jul 25, 2006 9:05 am
Posts: 163
Location: Stuttgart/Karlsruhe, Germany
After experimenting i managed to find the solution to my problem.

The section of the query that was causing the problem was:

Code:
e.expression.class = Rule


After alot of testing and experimentation i have fouind that, this works:

Code:
e.expression.class = 'rule'


where 'rule' is the discriminator value in single quotation marks.


Cheers,

Andy


Top
 Profile  
 
 Post subject:
PostPosted: Fri Oct 20, 2006 4:52 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
but Rule should work!

referring to the specific physical value is not what is intended.

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Fri Oct 20, 2006 4:58 am 
Senior
Senior

Joined: Tue Jul 25, 2006 9:05 am
Posts: 163
Location: Stuttgart/Karlsruhe, Germany
I know Rule should work as that is what is in the documentation, but it does not work for me in 3.2.0GA.

Luckily enough i was curious enough to start experimenting with a few things and then very lucky to stumble on to the solution


Andy


Top
 Profile  
 
 Post subject:
PostPosted: Fri Oct 20, 2006 5:00 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
it is not the solution...its wrong to use the physical name.

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Fri Oct 20, 2006 5:12 am 
Senior
Senior

Joined: Tue Jul 25, 2006 9:05 am
Posts: 163
Location: Stuttgart/Karlsruhe, Germany
I also agree on that you should not have to specify the discriminator value, and you should never have to enclose anything in single quotations. But if i don't a null pointer exception occurs.

This is only a temporary workaround. I do intend to supply you with a simple test case, but i cannot figure out (cannot setup it up correctly) how to use hibernate in standalone mode :-(.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Oct 20, 2006 5:15 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
what are you missing ? running in standalone mode is the simplest of all "modes".

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Fri Oct 20, 2006 5:32 am 
Senior
Senior

Joined: Tue Jul 25, 2006 9:05 am
Posts: 163
Location: Stuttgart/Karlsruhe, Germany
I don't really know !! I have created the classes (rmoved the annotations) and hbm.xml files, and a hibernate.cfg.xml but cannot seem to run it from within Eclipse. I get a NoClassDefFound error on org.hibernate.Session. Which hibernate (and hibernate related) jar's do i need to include in the class/build path ?


Top
 Profile  
 
 Post subject:
PostPosted: Fri Oct 20, 2006 5:33 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
easiest is just to add hibernate3.jar and lib/*

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Fri Oct 20, 2006 6:26 am 
Senior
Senior

Joined: Tue Jul 25, 2006 9:05 am
Posts: 163
Location: Stuttgart/Karlsruhe, Germany
I still get a NoClassDefFound error even when adding the jar files you suggested, this happens when i try and run it via a java main method, is this the correct way ????

When trying to use the Hibernate Console, and specifing mapping files in the cfg.xml it alway "can't" find the mapping files. Removing the mapping file references cause the session factory to opened but nothing can be done in it.

Sorry to be such an amateur when it comes to using Hibernate in standalone mode.

Andy


Top
 Profile  
 
 Post subject:
PostPosted: Fri Oct 20, 2006 6:29 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
how do you reference the mapping files ? (which lines do you have in cfg.xml ?)

are those files actually in the classpath ?

_________________
Max
Don't forget to rate


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 31 posts ]  Go to page 1, 2, 3  Next

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.