Hibernate version:
Hibernate 2.1.4
Mapping documents:
Note I removed properties not needed for my question!
<hibernate-mapping>
<class name="vo.T780Attivita" table="T780_ATTIVITA">
<id name="id" column="ID_ATTIVITA">
<generator class="sequence">
<param name="sequence">S780_ATTIVITA</param>
</generator>
</id>
<many-to-one
name="struttura"
column="FK_STRUTTURA_DEFAULT"
class="it.regioneveneto.decreti.vo.T300StruttureRegionali"
cascade="none"
outer-join="true"
not-null="false" />
</class>
</hibernate-mapping>
<hibernate-mapping>
<class lazy="true" name="vo.T300StruttureRegionali" table="T300_STRUTTURE_REGIONALI">
<id name="id" column="C_ID_STRUTTURA" type="string">
<generator class="assigned">
</generator>
</id>
<many-to-one
name="tipoStrutture"
column="C_FK_TIPO_STRUTTURA"
class="it.regioneveneto.decreti.vo.T300TipoStrutture"
cascade="none" />
</class>
</hibernate-mapping>
<hibernate-mapping>
<class name="vo.T300TipoStrutture" table="T300_TIPO_STRUTTURE">
<id name="id" column="C_ID_TIPO_STRUTTURA" type="string">
<generator class="assigned">
</generator>
</id>
</class>
</hibernate-mapping>
Code between sessionFactory.openSession() and session.close():
simplyfing.... I create a criteria starting from vo.T780Attivita and adding a like expression with value "%" on a property as shown by sql generated
Full stack trace of any exception that occurs:
No exception
Name and version of the database you are using:
Oracle 9i
The generated SQL (show_sql=true):
select this.ID_ATTIVITA as ID_ATTIV1_2_, this.COD_ATTIVITA as COD_ATTI2_2_, this.CREATED_BY as CREATED_BY2_, this.DE_ATTIVITA as DE_ATTIV4_2_, this.FLG_MODIFICA_DATI as FLG_MODI5_2_, this.FLG_STR_DEF_MODIFICABILE as FLG_STR_6_2_, this.MODIFIED_BY as MODIFIED7_2_, this.TIMEST_CREATED as TIMEST_C8_2_, this.TIMEST_MODIFIED as TIMEST_M9_2_, this.FK_STRUTTURA_DEFAULT as FK_STRU10_2_, x0_.C_ID_STRUTTURA as C_ID_STR1_0_, x0_.C_COD_SEGRETERIA as C_COD_SE2_0_, x0_.C_COD_AREA as C_COD_AREA0_, x0_.C_COD_DIREZIONE as C_COD_DI4_0_, x0_.C_COD_SERVIZIO as C_COD_SE5_0_, x0_.C_COD_UFFICIO as C_COD_UF6_0_, x0_.C_DS_STRUTTURA as C_DS_STR7_0_, x0_.C_DE_STRUTTURA as C_DE_STR8_0_, x0_.C_VL_INIZIO as C_VL_INI9_0_, x0_.C_VL_FINE as C_VL_FINE0_, x0_.C_FK_TIPO_STRUTTURA as C_FK_TI11_0_, t300tipost2_.C_ID_TIPO_STRUTTURA as C_ID_TIP1_1_, t300tipost2_.C_COD_TIPO_STRUTTURA as C_COD_TI2_1_, t300tipost2_.C_DS_TIPO_STRUTTURA as C_DS_TIP3_1_, t300tipost2_.C_DE_TIPO_STRUTTURA as C_DE_TIP4_1_, t300tipost2_.C_VL_INIZIO as C_VL_INI5_1_, t300tipost2_.C_VL_FINE as C_VL_FINE1_ from T780_ATTIVITA this, T300_STRUTTURE_REGIONALI x0_, T300_TIPO_STRUTTURE t300tipost2_ where lower(this.DE_ATTIVITA) like ? and this.FK_STRUTTURA_DEFAULT=x0_.C_ID_STRUTTURA and x0_.C_FK_TIPO_STRUTTURA=t300tipost2_.C_ID_TIPO_STRUTTURA(+)
Debug level Hibernate log excerpt:
Hi all,
when I search by Criteria for object of type vo.T780Attivita not all the outer join are performed.
This is a problem because there are null-able foreign key then the query return no row. I note a strange behavior, the relation (vo.T300StruttureRegionali)->(vo.T300TipoStrutture) is rapresented in sql with an outer join, instead the relation (vo.T780Attivita)->(vo.T300StruttureRegionali) is rapresented with a normal join (fk=id), also if I add outer-join="true" and not-null="false" on the many-to-one relation on vo.T780Attivita (I also added the lazy="true" on class "vo.T300StruttureRegionali" to force no join in this search, but does not work):
<many-to-one
name="struttura"
column="FK_STRUTTURA_DEFAULT"
class="it.regioneveneto.decreti.vo.T300StruttureRegionali"
cascade="none"
outer-join="true"
not-null="false" />
Somebody has an idea of what i'm doing wrong? I have no explanation.
enqnck
|