| I have a mapping of a composite-id with two columns.
 Class 1:
 
 <hibernate-mapping>
 <class
 name="br.gov.mpdft.consultafeitos.negocio.bo.ProcessoBO"
 table="PROC_DADOS"
 dynamic-update="false"
 dynamic-insert="false"
 select-before-update="false"
 optimistic-lock="version">
 
 <composite-id>
 <key-property name="numero" column="nr_proc" type="java.lang.String" length="15" />
 <key-property name="origem" column="origem" type="java.lang.String" length="15" />
 </composite-id>
 
 <property
 name="inquerito"
 type="java.lang.String"
 update="true"
 insert="true"
 access="property"
 >
 <column
 name="nr_inq"
 length="3"
 not-null="true"
 sql-type="char"
 />
 </property>
 
 <property
 name="tombo"
 type="java.lang.String"
 update="true"
 insert="true"
 access="property">
 <column
 name="nr_tombo"
 length="15"
 not-null="true"
 sql-type="char" />
 </property>
 
 </class>
 
 </hibernate-mapping>
 
 Class 2:
 
 <hibernate-mapping
 >
 <class
 name="br.gov.mpdft.consultafeitos.negocio.bo.EnvolvidoBO"
 table="Envolvido"
 dynamic-update="false"
 dynamic-insert="false"
 select-before-update="false"
 optimistic-lock="version"
 >
 
 <composite-id>
 <key-property name="nome" column="nm_envolv" type="java.lang.String" length="50" />
 <key-many-to-one name="processo" class="br.gov.mpdft.consultafeitos.negocio.bo.ProcessoBO">
 <column name="nr_proc" />
 <column name="origem" />
 </key-many-to-one>        </composite-id>
 
 <many-to-one
 name="tipoEnvolvido"
 class="br.gov.mpdft.consultafeitos.negocio.bo.TipoEnvolvidoBO"
 cascade="none"
 outer-join="auto"
 update="true"
 insert="true"
 access="property"
 >
 <column
 name="cd_tp_envolv"
 not-null="true"
 sql-type="char"
 />
 </many-to-one>
 
 <!--
 To add non XDoclet property mappings, create a file named
 hibernate-properties-EnvolvidoBO.xml
 containing the additional properties and place it in your merge dir.
 -->
 
 </class>
 
 </hibernate-mapping>
 
 The problem is: when I try to make a select in class EnvolvidoBO, the generate SQL (for SQL Server) is incorrect:
 
 select count(*) as col_0_0_ from Envolvido envolvidob0_, PROC_DADOS processobo1_ where (envolvidob0_.nr_proc, envolvidob0_.origem)=processobo1_.nr_proc and processobo1_.st_sigiloso='N' and (envolvidob0_.nm_envolv like '%deniz valentim franco%')
 
 Does anybody know the possible cause and how to solve this problem.
 
 Thanks.
 
 
 |