-->
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: many-to-one + fetch join
PostPosted: Wed Jun 15, 2005 5:03 pm 
Regular
Regular

Joined: Wed Sep 22, 2004 8:27 am
Posts: 89
Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp

Hibernate version: 3.05

hi everybody...

the question is:

i've a class A with e set o Classes B
in B there is a manytoone Class C.
I define manytoone of class C with fetch="join"

then with this code:

List list = criteria.createCriterial(A.class)

A a = (A)list.get(0)

session.createfilter(a.getListB(),"order by ...");

the sql genereted is:

1- query for all A like select * from a_table;
2- query for all B of A like select * from b_table join A_key
3- query for C of b like select * from c_table where c.key = btable.c

BUT I PUT FETCH="JOIN" in many-to-one of B

why hibernate generete this code??? i think with join C value must retrive by join and not by direct select

thanks.


Top
 Profile  
 
 Post subject: Re: many-to-one + fetch join
PostPosted: Wed Jun 15, 2005 5:49 pm 
Expert
Expert

Joined: Mon Feb 14, 2005 12:32 pm
Posts: 609
Location: Atlanta, GA - USA
foxmarco wrote:
Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp

Hibernate version: 3.05

hi everybody...

the question is:

i've a class A with e set o Classes B
in B there is a manytoone Class C.
I define manytoone of class C with fetch="join"

then with this code:

List list = criteria.createCriterial(A.class)

A a = (A)list.get(0)

session.createfilter(a.getListB(),"order by ...");

the sql genereted is:

1- query for all A like select * from a_table;
2- query for all B of A like select * from b_table join A_key
3- query for C of b like select * from c_table where c.key = btable.c

BUT I PUT FETCH="JOIN" in many-to-one of B

why hibernate generete this code??? i think with join C value must retrive by join and not by direct select

thanks.




Please post your mapping files. i've a class A with e set o Classes B makes no sense to me.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jun 16, 2005 4:11 am 
Regular
Regular

Joined: Wed Sep 22, 2004 8:27 am
Posts: 89
CLASS A

<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping default-lazy="false">

<class name="com.coginfo.kf.bean.Report" table="KFT_REPORT" select-before-update="true">
<meta attribute="class-description">Report</meta>
<id name="codint" type="long" unsaved-value="0">
<generator class="sequence">
<param name="sequence">KF_SEQ_REPORT</param>
</generator>
</id>

<property name="cafrep" type="string">
<column name="cafrep" length="20" sql-type="string" not-null="true"/>
</property>

<property name="dscrep" type="string">
<column name="dscrep" length="1000" sql-type="string" not-null="true"/>
</property>

<property name="caflbl" type="string">
<column name="caflbl" length="1000" sql-type="string" not-null="true"/>
</property>

<property name="cafpth" type="string">
<column name="cafpth" length="1000" sql-type="string" not-null="true"/>
</property>

<property name="stsrep" type="integer">
<column name="stsrep" length="1" sql-type="integer" not-null="true"/>
</property>

<property name="stscri" type="string">
<column name="stscri" length="1" sql-type="string" not-null="true"/>
</property>


<set name="parametri" order-by=" codord ASC" inverse="true" cascade="delete" fetch="subselect">
<key column="codintrep"/>
<one-to-many class="com.coginfo.kf.bean.Parametro"/>
</set>

</class>

</hibernate-mapping>


CLASS B

<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping default-lazy="false">

<class name="com.coginfo.kf.bean.Parametro" table="KFT_PARAMETRO" select-before-update="true">
<meta attribute="class-description">Parametro</meta>
<composite-id name="id" class="com.coginfo.kf.bean.ParametroPk">
<key-property name="codintrep" column="codintrep" type="long"/>
<key-property name="codint" column="codint" type="long"/>
</composite-id>

<many-to-one class="com.coginfo.kf.bean.Dominio" column="codintdmn" name="codintdmn" not-null="true" lazy="true" fetch="join"/>

<property name="caflbl" type="string">
<column name="caflbl" length="1000" sql-type="string" not-null="false"/>
</property>

<property name="cafprtrep" type="string">
<column name="cafprtrep" length="1000" sql-type="string" not-null="true"/>
</property>

<property name="codord" type="integer">
<column name="codord" length="1000" sql-type="integer" not-null="false"/>
</property>

<property name="stsobbl" type="string">
<column name="stsobbl" length="1" sql-type="string" not-null="true"/>
</property>

<property name="stsedit" type="string">
<column name="stsedit" length="1" sql-type="string" not-null="true"/>
</property>

<property name="stsvis" type="string">
<column name="stsvis" length="1" sql-type="string" not-null="true"/>
</property>

<property name="stsmult" type="string">
<column name="stsmult" length="1" sql-type="string" not-null="true"/>
</property>

<property name="stscri" type="string">
<column name="stscri" length="1" sql-type="string" not-null="true"/>
</property>

</class>

<query name="find.parametro"><![CDATA[
from Parametro par ]]>
</query>

</hibernate-mapping>


CLASS C

<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">

<hibernate-mapping default-lazy="false">

<class name="com.coginfo.kf.bean.Dominio" table="KFT_DOMINIO" select-before-update="true">
<meta attribute="class-description">Dominio</meta>
<id name="codint" type="long" unsaved-value="0">
<generator class="sequence">
<param name="sequence">KF_SEQ_DOMINIO</param>
</generator>
</id>

<property name="cafdsc" type="string">
<column name="cafdsc" length="1000" sql-type="string" not-null="true"/>
</property>

<property name="numdmn" type="string">
<column name="numdmn" length="5" sql-type="string" not-null="true"/>
</property>

<property name="caflbl" type="string">
<column name="caflbl" length="500" sql-type="string" not-null="true"/>
</property>

<property name="caftipdto" type="string">
<column name="caftipdto" length="20" sql-type="string" not-null="true"/>
</property>

<property name="caffordto" type="string">
<column name="caffordto" length="20" sql-type="string" not-null="false"/>
</property>

</class>


</hibernate-mapping>


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.