-->
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: Generated SQL too complex ?
PostPosted: Sun Jun 05, 2005 11:08 am 
Newbie

Joined: Sun Jun 05, 2005 10:55 am
Posts: 4
Location: Germany
Hibernate Version 3.0.5 with Spring 1.2.1
PostgreSQL 8

I think the sql generated is too complex.

It is really simple. An entity of 'TEILESTAM' is associated with
some entities of 'BESCHREIB' that contains localized descriptions.

If I load an entity of 'TEILESTAM', the sql is ok. But if I access
the 'beschreibungenInternal' field, hibernate creates a sql-statement
for the entities of 'BESCHREIB' which looks too complicated for me.

Generated SQL:
select
beschreibu0_.MA as MA1_,
beschreibu0_.TEILENR as TEILENR1_,
beschreibu0_.KEY as KEY1_,
beschreibu0_.MA as MA0_,
beschreibu0_.TEILENR as TEILENR0_,
beschreibu0_.KEY as KEY0_,
beschreibu0_.TEXT as TEXT0_0_
from
BESCHREIB beschreibu0_
where
beschreibu0_.MA='MMD' and beschreibu0_.TEILENR='000000033'

ResultSet:
ma1_ teilenr1_ key1_ ma0_ teilenr0_ key0_ text0_0_
---- --------- ----- ---- --------- ----- ---------------------------
MMD 000000033 enGB MMD 000000033 enGB First aid box
MMD 000000033 frFR MMD 000000033 frFR Boîte à pansements
MMD 000000033 itIT MMD 000000033 itIT Scatola del pronto soccorso

So my question is, why are the entries 'ma', 'teilenr' and 'key' retrieved twice ?
I don't know the internals, how hibernate does its mapping.
Is it a mistake in my mapping or .... ?????

My mappings:

teilestam.hbm.xml:

<hibernate-mapping auto-import="true" default-lazy="false" package="de.holger.model">
<class name="Teilestamm" table="TEILESTAM">
<composite-id name="id" class="TeilestammId">
<key-property name="ma" column="MA" type="string" length="5"/>
<key-property name="teilenr" column="TEILENR" type="string" length="20"/>
</composite-id>

<property name="beschreibung" column="BESCHREIBUNG" length="254" type="string" />

<set name="beschreibungenInternal" inverse="false">
<key>
<column name="MA" />
<column name="TEILENR" />
</key>
<one-to-many class="Beschreib" />
</set>
</class>
</hibernate-mapping>

beschreib.hbm.xml:

<hibernate-mapping auto-import="true" default-lazy="false" package="de.holger.model">
<class name="Beschreib" table="BESCHREIB">
<composite-id name="id" class="BeschreibId">
<key-property name="ma" column="MA" type="string" length="5"/>
<key-property name="teilenr" column="TEILENR" type="string" length="20"/>
<key-property name="key" column="KEY" type="string" length="5"/>
</composite-id>

<property name="text" column="TEXT" type="string" length="30"/>
</class>

</hibernate-mapping>

Spring:
<bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
<property name="dataSource"><ref local="dataSource"/></property>
<property name="mappingResources">
<list>
<value>/de/holger/hibernate/maps/beschreib.hbm.xml</value>
<value>/de/holger/hibernate/maps/teilestam.hbm.xml</value>
</list>
</property>
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">org.hibernate.dialect.PostgreSQLDialect</prop>
<prop key="hibernate.show_sql">true</prop>
</props>
</property>
<property name="eventListeners">
<map>
<entry key="merge">
<bean class="org.springframework.orm.hibernate3.support.IdTransferringMergeEventListener"/>
</entry>
</map>
</property>
</bean>

Thank you in advance,

Holger


Top
 Profile  
 
 Post subject:
PostPosted: Sun Jun 05, 2005 11:11 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
This is normal and expected, and perfectly ok.


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.