-->
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: [solved] Criteria: adding alias to criteria breaks fetchmode
PostPosted: Mon Aug 21, 2006 2:49 am 
Newbie

Joined: Thu May 04, 2006 5:04 am
Posts: 17
Location: Austria
Hello,
we are using Hibernate for about 8 months now, 2 of those even in production, and didn't have any problems with it at all.
But recently I encountered the following issue (I don't know if its my fault or a bug).
I am using the criteria API for a search screen (multiple tables are involved, restrictions may be applied to one or more of them).
We are using FetchMode.JOIN for all of the needed tables (no lazy initialization is wanted).
Basically the search screen works already, data is retrieved and displayed correctly.
However, I had to add an restriction to a table which was previously only fetched but had no restrictions on itself.
Then I added an alias for the path in the criteria object.
After doing this I recompiled and tried the new screen, the result was that I encountered an LazyInitializationException in the already working code.
It seems that adding the alias changed the generated SQL and the FetchMode is being ignored.
I even tried to change the association path in the fetchmode for the entity to the alias name which resulted in a SQLGrammarException.
Because we are using an older version of Hibernate (from december last year) I upgraded Hibernate to 3.1.3 on my workstation but the problem still occurs.
Sorry to bother you with this issue if its a no brainer but I already spent some time on Google and reading in our books on this problem and didnt find a solution for it.

kind regards & thanks in advance, Christian


Last edited by ChristianS on Tue Aug 22, 2006 5:38 am, edited 2 times in total.

Top
 Profile  
 
 Post subject:
PostPosted: Mon Aug 21, 2006 9:39 am 
Newbie

Joined: Thu May 04, 2006 5:04 am
Posts: 17
Location: Austria
Hi,
I could solve the problem by myself.
Instead of using
Code:
createCriteria(String associationPath)

I now use
Code:
createCriteria(String associationPath, int joinType)

whith Join Type
Code:
CriteriaSpecification.LEFT_JOIN

.
kind regards, Chris


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.