-->
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.  [ 11 posts ] 
Author Message
 Post subject: Named Queries Cause Configuration to Freeze
PostPosted: Tue Mar 01, 2005 10:56 am 
Newbie

Joined: Tue Mar 01, 2005 10:37 am
Posts: 17
If I have any named queries, Hibernate freezes when doing it's configuration. This happend after I upgraded from 3.0 beta 4 to 3.0 RC1.

All that shows in the logs is:

2005-03-01 09:39:29,474 INFO (org.hibernate.impl.SessionFactoryImpl:366) - Checking 1 named queries
2005-03-01 09:39:29,474 DEBUG (org.hibernate.impl.SessionFactoryImpl:373) - Checking named query: troubletickets.getStaffFaqs

After that, nothing. This happens no matter what query I have, but here's a sample query:

<query name="troubletickets.getStaffFaqs">
FROM FAQ AS f
WHERE f.category.id = :categoryId AND f.staffOnly = true
</query>


Top
 Profile  
 
 Post subject: ClassicQueryTranslatorFactory
PostPosted: Tue Mar 01, 2005 11:56 am 
Newbie

Joined: Tue Mar 01, 2005 10:37 am
Posts: 17
Ok, I guess this is the "major bug that affects dialects with theta-style outer
joins"? (Does PostgreSQL use theta-style outer joins? What are theta-style outer joins?)

My problem is fixed by using
<property name="query.factory_class">org.hibernate.hql.classic.ClassicQueryTranslatorFactory</property>


Top
 Profile  
 
 Post subject:
PostPosted: Tue Mar 01, 2005 1:06 pm 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
Please provide a simple non working test case into JIRA, I'll help us.

_________________
Emmanuel


Top
 Profile  
 
 Post subject:
PostPosted: Tue Mar 01, 2005 3:02 pm 
Newbie

Joined: Tue Mar 01, 2005 10:37 am
Posts: 17
Apparently something in my web-app initialization code is masking the fact that an exception actually get thrown (rather than "freezing" as I thought...)

My simple test I'm preparing for entry in JIRA actually shows the following happening:

2005-03-01 13:44:57,421 INFO (org.hibernate.impl.SessionFactoryImpl:366) - Checking 1 named queries
2005-03-01 13:44:57,421 DEBUG (org.hibernate.impl.SessionFactoryImpl:373) - Checking named query: getFAQsByCreated
Exception in thread "main" java.lang.NoClassDefFoundError: antlr/ANTLRException
at org.hibernate.hql.ast.ASTQueryTranslatorFactory.createQueryTranslator(ASTQueryTranslatorFactory.java:27)
at org.hibernate.impl.SessionFactoryImpl.createQueryTranslators(SessionFactoryImpl.java:344)
at org.hibernate.impl.SessionFactoryImpl.getQuery(SessionFactoryImpl.java:410)
at org.hibernate.impl.SessionFactoryImpl.checkNamedQueries(SessionFactoryImpl.java:375)
at org.hibernate.impl.SessionFactoryImpl.<init>(SessionFactoryImpl.java:278)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1043)
at Test.main(Test.java:11)


Top
 Profile  
 
 Post subject:
PostPosted: Tue Mar 01, 2005 3:02 pm 
Newbie

Joined: Tue Mar 01, 2005 10:37 am
Posts: 17
Is there a jar file I'm missing? I didn't notice any new requirements in the release notes...


Top
 Profile  
 
 Post subject:
PostPosted: Tue Mar 01, 2005 3:19 pm 
Newbie

Joined: Tue Mar 01, 2005 10:37 am
Posts: 17
Ok. The antlr jar file fixed this problem.

Using the new query translator still gives me problems:

2005-03-01 14:02:59,917 ERROR (org.hibernate.util.JDBCExceptionReporter:58) - ERROR: for SELECT DISTINCT, ORDER BY expressions must appear in select list

For:

<query name="troubletickets.getSolvedCategories">
SELECT DISTINCT t.category
FROM Ticket t
WHERE t.status = 'closed'
ORDER BY t.category.name
</query>

Obviously, this issue is much more minor. But I'd still be happy if someone had an idea on I should handle this instead, or if the new QueryTranslator should be handling this case better...


Top
 Profile  
 
 Post subject:
PostPosted: Tue Mar 01, 2005 3:51 pm 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
Your query is wrong. As in SQL, all select properties has to be in the group by clause

Code:
SELECT DISTINCT t.category
FROM Ticket t
WHERE t.status = 'closed'
ORDER BY t.category.name

should be

SELECT DISTINCT t.category.name
FROM Ticket t
WHERE t.status = 'closed'
ORDER BY t.category.name

_________________
Emmanuel


Top
 Profile  
 
 Post subject:
PostPosted: Tue Mar 01, 2005 3:58 pm 
Newbie

Joined: Tue Mar 01, 2005 10:37 am
Posts: 17
Well, it worked before, as far as I could tell (I only didn't check closely to make sure the sortinga actually happened...) It certainly didn't complain.

But I need to be able to get all the Category OBJECTS, while have the list of Objects sorted by NAME. Isn't there any way to do that (filters, etc?).


Top
 Profile  
 
 Post subject:
PostPosted: Tue Mar 01, 2005 3:59 pm 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
Man, I read too fast, I thought you were using group by, sorry.

_________________
Emmanuel


Top
 Profile  
 
 Post subject:
PostPosted: Tue Mar 01, 2005 4:12 pm 
Newbie

Joined: Tue Mar 01, 2005 10:37 am
Posts: 17
That's ok. I'm glad to know I'm not being completely non-sensical...


Top
 Profile  
 
 Post subject:
PostPosted: Tue Mar 01, 2005 4:26 pm 
Newbie

Joined: Tue Mar 01, 2005 10:37 am
Posts: 17
Ok. I guess the issue is this -

Here's the sql generated by Hibernate:

select distinct category1_.id as id, category1_.name as name2_, category1_.description as descript3_2_, category1_.disabled as disabled2_, category1_.changed as changed2_, category1_.created as created2_, category1_.changed_usr_id as changed7_2_, category1_.created_usr_id as created8_2_ from troubletickets_faqs faq0_, troubletickets_categories category1_, troubletickets_categories category2_ where (faq0_.trca_id=category1_.id and faq0_.trca_id=category2_.id) order by category2_.name

Whereas, I expected this, which is what the ClassicQueryTranslator produces:

select distinct category1_.id as id, category1_.name as name2_, category1_.description as descript3_2_, category1_.disabled as disabled2_, category1_.changed as changed2_, category1_.created as created2_, category1_.changed_usr_id as changed7_2_, category1_.created_usr_id as created8_2_ from troubletickets_faqs faq0_, troubletickets_categories category1_ where faq0_.trca_id=category1_.id order by category1_.name

Why does the new QueryTranslator produce a second category to look at?


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