-->
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.  [ 3 posts ] 
Author Message
 Post subject: Question about "left join fetch"
PostPosted: Thu Dec 25, 2003 3:54 pm 
Pro
Pro

Joined: Wed Oct 08, 2003 10:31 am
Posts: 247
It's kind of strange the following situation, I think. When we have a collection that's loaded "lazy", like the documentation says, we use a "left join fetch" to load the "set". The 1) example works but the 2) doesn't by giving me the following error:

Code:
java.lang.ClassCastException


Did I miss something?
Can someone please explain me this point?

Here's the two examples:
1)
Code:
res = session.find(
      "select he " +
      "from vo.Ensaio e " +
      "left join e.historicoEnsaios he where e.tabela = ?",
      tabela,
      Hibernate.STRING
);


2)
Code:
res = session.find(
      "select he " +
      "from vo.Ensaio e " +
      "left join [b]fetch[/b] e.historicoEnsaios he where e.tabela = ?",
      tabela,
      Hibernate.STRING
);


-----------------------------------------------------
Mapping file (generated with Middlegen R3)
-----------------------------------------------------
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 2.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd" >

<hibernate-mapping>
<!--
Created by Middlegen Hibernate plugin

http://boss.bekk.no/boss/middlegen/
http://hibernate.sourceforge.net/
-->

<class
name="vo.Ensaio"
table="ensaio"
>

<id
name="id"
type="long"
column="id"
>
<generator class="increment" />
</id>

<property
name="referencia"
type="java.lang.String"
column="referencia"
not-null="true"
length="-1"
/>

<!-- associations -->
<!-- bi-directional one-to-many association to HistoricoEnsaio -->
<set
name="historicoEnsaios"
lazy="true"
inverse="true"
>
<key>
<column name="ensaio_fk" />
</key>
<one-to-many
class="vo.HistoricoEnsaio"
/>
</set>

</class>
</hibernate-mapping>


Top
 Profile  
 
 Post subject:
PostPosted: Thu Dec 25, 2003 6:11 pm 
Hibernate Team
Hibernate Team

Joined: Tue Sep 09, 2003 2:10 pm
Posts: 3246
Location: Passau, Germany
Please post a complete Stack Trace of the Exception


Top
 Profile  
 
 Post subject:
PostPosted: Mon Dec 29, 2003 6:30 am 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
Actually the fetch is useless : you explicitly asked the return of the collection.

_________________
Emmanuel


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