-->
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.  [ 4 posts ] 
Author Message
 Post subject: Bei Select werden NULL-Werte ausgefiltert!
PostPosted: Tue May 10, 2005 8:05 am 
Beginner
Beginner

Joined: Thu Apr 21, 2005 5:37 am
Posts: 45
Location: Switzerland
Ich führe folgende Query aus (HQL):
Code:
select proc.transportDevice, proc.driver, proc.coDriver from TransportProcess as proc


ich erwarte etwas zu erhalten wie:
Code:
device1, driver1, codriver1
device2, driver2, null
device3, driver3, codriver3

ich erhalte aber:
Code:
device1, driver1, codriver1
device3, driver3, codriver3

Die 2. Reihe wo proc.coDriver null ist wird komplett weg gelassen! Ist das korrekt?

Hibernate version: Hibernate 2.1.8

Mapping documents:
Code:
<?xml version="1.0" encoding="UTF-8"?>

<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 2.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd">

<hibernate-mapping
>
<class
name="com.optitrans.ejb.model.TransportProcess"
table="OT_Transportvorgang"
dynamic-update="false"
dynamic-insert="false"
select-before-update="false"
optimistic-lock="version"
>

<id
name="id"
column="ID"
type="java.lang.Long"
unsaved-value="null"
>
<generator class="seqhilo">
<!--
To add non XDoclet generator parameters, create a file named
hibernate-generator-params-TransportProcess.xml
containing the additional parameters and place it in your merge dir.
-->
</generator>
</id>

<version
name="version"
type="java.util.Date"
column="Version"
access="property"
unsaved-value="undefined"
/>

<many-to-one
name="coDriver"
class="com.optitrans.ejb.model.Employee"
cascade="none"
outer-join="auto"
update="true"
insert="true"
access="property"
column="ID_Mitarbeiter_Beifahrer"
not-null="false"
/>

<many-to-one
name="driver"
class="com.optitrans.ejb.model.Employee"
cascade="none"
outer-join="auto"
update="true"
insert="true"
access="property"
column="ID_Mitarbeiter_Fahrer"
not-null="true"
/>

<property
name="endLastTransport"
type="java.util.Date"
update="true"
insert="true"
access="property"
column="EndeLetzterTransport"
/>

<property
name="startFirstTransport"
type="java.util.Date"
update="true"
insert="true"
access="property"
column="BeginnErsterTransport"
/>

<set
name="transportTasks"
lazy="true"
inverse="false"
cascade="none"
sort="unsorted"
>

<key
column="ID_Transportvorgang"
>
</key>

<one-to-many
class="com.optitrans.ejb.model.TransportTask"
/>

</set>

<many-to-one
name="transportDevice"
class="com.optitrans.ejb.model.TransportDevice"
cascade="none"
outer-join="auto"
update="true"
insert="true"
access="property"
column="ID_Transportmittel"
not-null="false"
/>

<!--
To add non XDoclet property mappings, create a file named
hibernate-properties-TransportProcess.xml
containing the additional properties and place it in your merge dir.
-->

</class>

</hibernate-mapping>


Database: Firebird 1.5.2.4731

The generated SQL (show_sql=true):
maybe not so interesting...
Code:
**************************************
select transportd1_.ID as ID0_, employee2_.ID as ID1_, employee3_.ID as ID2_, transportd1_.Version as Version0_, transportd1_.Beschreibung as Beschrei3_0_, transportd1_.IstBenutzerdefiniert as IstBenut4_0_, transportd1_.Name as Name0_, transportd1_.ID_Transportmitteltyp as ID_Trans6_0_, transportd1_.Ausmustern as Ausmustern0_, transportd1_.Sortierschluessel as Sortiers8_0_, employee2_.Version as Version1_, employee2_.ID_Adresse as ID_Adresse1_, employee2_.Nachname as Nachname1_, employee2_.Geburtsname as Geburtsn5_1_, employee2_.Vorname as Vorname1_, employee2_.Kurzname as Kurzname1_, employee2_.Spitzname as Spitzname1_, employee2_.IstWeiblich as IstWeibl9_1_, employee2_.Geburtsdatum as Geburts10_1_, employee2_.TelFest as TelFest1_, employee2_.TelMobil as TelMobil1_, employee2_.Email as Email1_, employee2_.Bis as Bis1_, employee3_.Version as Version2_, employee3_.ID_Adresse as ID_Adresse2_, employee3_.Nachname as Nachname2_, employee3_.Geburtsname as Geburtsn5_2_, employee3_.Vorname as Vorname2_, employee3_.Kurzname as Kurzname2_, employee3_.Spitzname as Spitzname2_, employee3_.IstWeiblich as IstWeibl9_2_, employee3_.Geburtsdatum as Geburts10_2_, employee3_.TelFest as TelFest2_, employee3_.TelMobil as TelMobil2_, employee3_.Email as Email2_, employee3_.Bis as Bis2_ from OT_Transportvorgang transportp0_, OTT_Transportmittel transportd1_, OTM_Mitarbeiter employee2_, OTM_Mitarbeiter employee3_ where transportp0_.ID_Transportmittel=transportd1_.ID and transportp0_.ID_Mitarbeiter_Fahrer=employee2_.ID and transportp0_.ID_Mitarbeiter_Beifahrer=employee3_.ID
**************************************
[/code]


Top
 Profile  
 
 Post subject:
PostPosted: Tue May 10, 2005 8:08 am 
Hibernate Team
Hibernate Team

Joined: Mon Aug 25, 2003 9:11 pm
Posts: 4592
Location: Switzerland
Bist Du sicher? Schon im DEBUG log geschaut was der SQL query wirklich zurueckgibt ("xxx rows in resultset.")?


Top
 Profile  
 
 Post subject:
PostPosted: Tue May 10, 2005 8:25 am 
Beginner
Beginner

Joined: Thu Apr 21, 2005 5:37 am
Posts: 45
Location: Switzerland
wenn ich stattdessen
Code:
select proc.driver from TransportProcess as proc

eingebe, bekomme ich folgendes Resultat
Code:
driver1
driver2
driver3


Anmerkung: proc.driver und proc.coDriver sind Objekte der Klasse Employee, nicht einfache Properties.

Die SQL-Query gibt natürlich auch 2 rows zurück, wie die HQL-Query. Das ist auch logisch, weil es einen Join gibt bei
Code:
... where ... and transportp0_.ID_Mitarbeiter_Beifahrer=employee3_.ID

Da aber transportp0_.ID_Mitarbeiter_Beifahrer null ist gibt das "=" nicht true zurück und die Zeile wird nicht ins Resultat aufgenommen.
Aus Objekt-Sicht (HQL) sollte aber die Reihe trotzdem im Resultat auftauchen, mit den Objekten auf null gesetzt.

Falls das absichtlich so gelöst ist, sollte es zumindest klar dokumentiert werden.


Top
 Profile  
 
 Post subject:
PostPosted: Wed May 11, 2005 5:52 am 
Expert
Expert

Joined: Tue Oct 05, 2004 9:45 am
Posts: 263
schomal versucht statt 'outer-join="auto"' 'outer-join="true" ' zu verwenden?


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