-->
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: Column is repeated in generated SQL... why?
PostPosted: Fri Nov 17, 2006 9:30 am 
Newbie

Joined: Tue Oct 07, 2003 4:17 pm
Posts: 9
I was experimenting with fetch="subselect" and noticed that the generated SQL repeats the id column (see below). I think I've noticed this in other situations too. Does anyone have an explanation? is it something I am doing wrong?
thanks
Carl


Hibernate version: v3.2

Mapping documents:

<?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
package="com.ncr.cacheTest">

<class name="Parent1" table="Parent1">

<id name="id">
<generator class="assigned"/>
</id>

<property name="parentName"
not-null="true"
column="parentName"/>

<!-- one-to-many bi-directional (set) -->
<set name="myCollection1"
lazy="true"
fetch="join"
inverse="true"
cascade="all-delete-orphan">
<key column="parent"/>
<one-to-many class="Col1"/>
</set>

<!-- one-to-many bi-directional (bag with set semantics) -->
<bag name="myCollection2"
lazy="true"
fetch="select"
inverse="true"
cascade="all-delete-orphan">
<key column="parent"/>
<one-to-many class="Col2"/>
</bag>

<!-- many-to-many, bi-directional with order (list index) -->
<list name="myCollection3"
lazy="true"
fetch="subselect"
inverse="false"
table="Parent_Col3"
cascade="persist, merge, save-update">
<key column="parent_id"/>
<index column="ord"/>
<many-to-many
column="col3_id"
class="Col3"
unique="false" />
</list>

<!-- one-to-many bi-directional (set) -->
<set name="myCollection4"
lazy="false"
fetch="subselect"
inverse="true"
cascade="all-delete-orphan">
<key column="parent"/>
<one-to-many class="Col4"/>
</set>

</class>

</hibernate-mapping>

<?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
package="com.ncr.cacheTest">

<class name="Col4" table="Col4" >

<id name="id">
<generator class="assigned"/>
</id>

<timestamp name="datetime"
column="datetime"/>

<many-to-one name="parent"
not-null="true"/>

</class>

</hibernate-mapping>

... others not included




Code between sessionFactory.openSession() and session.close():

List list = s.createQuery("from Parent1").list();

Full stack trace of any exception that occurs:

Hibernate: select parent1x0_.id as id0_, parent1x0_.parentName as parentName0_ from Parent1 parent1x0_
17:48:32,253 DEBUG org.hibernate.cache.TransactionalCache caching: com.ncr.cacheTest.Parent1#1553
17:48:32,253 DEBUG org.hibernate.cache.TransactionalCache caching: com.ncr.cacheTest.Parent1#481
...
...
...
17:48:32,534 DEBUG org.hibernate.cache.TransactionalCache caching: com.ncr.cacheTest.Parent1#577
17:48:32,534 DEBUG org.hibernate.cache.TransactionalCache caching: com.ncr.cacheTest.Parent1#609
17:48:32,534 DEBUG org.hibernate.cache.TransactionalCache cache lookup: com.ncr.cacheTest.Parent1.myCollection4#609
17:48:32,534 DEBUG org.hibernate.cache.TransactionalCache cache miss
Hibernate: select mycollecti0_.parent as parent1_, mycollecti0_.id as id1_, mycollecti0_.id as id6_0_, mycollecti0_.datetime as datetime6_0_, mycollecti0_.parent as parent6_0_ from Col4 mycollecti0_ where mycollecti0_.parent in (select parent1x0_.id from Parent1 parent1x0_)
17:48:33,565 DEBUG org.hibernate.cache.TransactionalCache caching: com.ncr.cacheTest.Col4#1564
17:48:33,565 DEBUG org.hibernate.cache.TransactionalCache caching: com.ncr.cacheTest.Col4#495
17:48:33,643 DEBUG org.hibernate.cache.TransactionalCache caching: com.ncr.cacheTest.Col4#1022
...
...
...


Name and version of the database you are using: Teradata R2v6

The generated SQL (show_sql=true):

Hibernate: select parent1x0_.id as id0_, parent1x0_.parentName as parentName0_ from Parent1 parent1x0_

Hibernate: select mycollecti0_.parent as parent1_, mycollecti0_.id as id1_, mycollecti0_.id as id6_0_, mycollecti0_.datetime as datetime6_0_, mycollecti0_.parent as parent6_0_ from Col4 mycollecti0_ where mycollecti0_.parent in (select parent1x0_.id from Parent1 parent1x0_)

_________________
Carl
NCR/Teradata Boston


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.