-->
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.  [ 1 post ] 
Author Message
 Post subject: too many sql
PostPosted: Fri Nov 26, 2010 12:08 pm 
Newbie

Joined: Fri Feb 08, 2008 7:14 am
Posts: 4
I have this:

<hibernate-mapping>
<class name="test.A" table="A" >
<id name="a1" type="java.lang.String">
<column name="A1"/>
</id>
<many-to-one name="c" property-ref="c_id"
class="test.C" update="false" insert="false" fetch="join" >

<column name="b1" />
<column name="c1" />
</many-to-one>
</class>
</hibernate-mapping>

<hibernate-mapping>
<class name="test.C" table="C" >
<id name="c" type="java.lang.String">
<column name="C" />
</id>
<properties name="c_id" >
<property name="b1" insert="false" update="false" />
<property name="c1" insert="false" update="false" />
</properties>
</class>
</hibernate-mapping>

And i have a test whit this:

A a = (A) template.load(A.class, "1");

When in table A there is:

A1 | B1 | C1
1 null null

sql generated is:
select ... from A a0_ left outer join C c1_ on a0_.b1=c1_.b1 and a0_.c1=c1_.c1 where a0_.A1=?;

When in table A there is:

A1 | B1 | C1
1 1 1

sql generated is:
select ... from A a0_ left outer join C c1_ on a0_.b1=c1_.b1 and a0_.c1=c1_.c1 where a0_.A1=?;

BUT When I have:

A1 | B1 | C1
1 null 1

OR

A1 | B1 | C1
1 1 null

The sql is:
select ... from A a0_ left outer join C c1_ on a0_.b1=c1_.b1 and a0_.c1=c1_.c1 where a0_.A1=?
select ... from C c0_ where c0_.b1=? and c0_.c1=?

Why reason appears a query on C ?

I am using hibernate 3.2.5


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

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.