-->
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.  [ 5 posts ] 
Author Message
 Post subject: same result running query
PostPosted: Tue Aug 31, 2004 9:37 pm 
Beginner
Beginner

Joined: Fri Apr 16, 2004 10:25 am
Posts: 44
Location: Brazil
I'm running the following query and it is returning the same value althought I have diferent values in the database.
I executed the SQL generated from hibernate in SQLStudio and It executed OK

Hibernate version: 2.1.6

Mapping documents:
<class name="com.br.resource.csu.lembranca.dao.hibernate.persisted.Documento" table="SSC_documento">
<id name="inxDoc" column="INX_DOC" type="integer">
<generator class="increment"/>
</id>
<set name="regras" inverse="true" lazy="true" cascade="all">
<key column="inx_doc"/>
<one-to-many class="com.br.resource.csu.lembranca.dao.hibernate.persisted.DocumentoRegra"/>
</set>
<many-to-one name="codCli" column="COD_CLI"/>
<property name="codClasse" column="COD_CLASSE"/>
<property name="codInstalacao" column="COD_INSTALACAO"/>
<property name="codLivroLeitura" column="COD_LIVRO_LEITURA"/>
<property name="codLocalidade" column="COD_LOCALIDADE"/>
<property name="codLoteFaturamento" column="COD_LOTE_FATURAMENTO"/>
<property name="codMotivoExc" column="COD_MOTIVO_EXC"/>
<property name="codTipoDoc" column="COD_TIPO_DOC"/>
<property name="codUnidOper" column="COD_UNID_OPER"/>
<property name="datCriacaoFatura" column="DAT_CRIACAO_FATURA"/>
<property name="datEmissaoFatura" column="DAT_EMISSAO_FATURA"/>
<property name="datExc" column="DAT_EXC"/>
<property name="datFimCob" column="DAT_FIM_COB"/>
<property name="datInclusaoReg" column="DAT_INCLUSAO_REG"/>
<property name="datIniCob" column="DAT_INI_COB"/>
<property name="datPrevCorte" column="DAT_PREV_CORTE"/>
<property name="datProcArqOrg" column="DAT_PROC_ARQ_ORG"/>
<property name="datVenctoFatura" column="DAT_VENCTO_FATURA"/>
<property name="flgDebAut" column="FLG_DEB_AUT"/>
<property name="indContencioso" column="IND_CONTENCIOSO"/>
<property name="mesRefFatura" column="MES_REF_FATURA"/>
<property name="numFatura" column="NUM_FATURA"/>
<property name="qtdTentativa" column="QTD_TENTATIVA"/>
<property name="totFaturaAvisoDeb" column="TOT_FATURA_AVISO_DEB"/>
<property name="vlrFatura" column="VLR_FATURA"/>
</class>


Code between sessionFactory.openSession() and session.close():
public String testConnection () {
HibernateDaoFactory hibernateDaoFactory = null;
String retorno;

try {
hibernateDaoFactory = new HibernateDaoFactory();
hibernateDaoFactory.openSession();

Iterator iter = hibernateDaoFactory.session.find("from Documento doc where doc.vlrFatura > 400").iterator();
while ( iter.hasNext() ) {
Documento doc2 = (Documento) iter.next();
System.err.println(doc2.getNumFatura()+" - "+doc2.getVlrFatura());
}
System.err.println("finish");
hibernateDaoFactory.commitSession();
hibernateDaoFactory.closeSession();
retorno = "<BR><B><font face='times new roman' size='3'>Conectado com sucesso</font></B>";
} catch (Exception e) {
System.out.println(e);
retorno = "<BR><B><font face='times new roman' size='3'>Erro ao conectar ao JNDI."+e+"</font></B>";
} finally {
}
return retorno;
}


Name and version of the database you are using: oracle 8i



log :

22:31:55,138 ERROR [STDERR] 000192756833 - 715.1
22:31:55,138 ERROR [STDERR] 000192756833 - 715.1
22:31:55,139 ERROR [STDERR] 000192756833 - 715.1
22:31:55,139 ERROR [STDERR] 000192756833 - 715.1
22:31:55,139 ERROR [STDERR] 000192756833 - 715.1
22:31:55,139 ERROR [STDERR] 000192756833 - 715.1
22:31:55,139 ERROR [STDERR] 000192756833 - 715.1
22:31:55,139 ERROR [STDERR] 000192756833 - 715.1
22:31:55,139 ERROR [STDERR] 000192756833 - 715.1
22:31:55,139 ERROR [STDERR] 000192756833 - 715.1
22:31:55,139 ERROR [STDERR] 000192756833 - 715.1
22:31:55,140 ERROR [STDERR] finish


Top
 Profile  
 
 Post subject:
PostPosted: Wed Sep 01, 2004 2:10 am 
Hibernate Team
Hibernate Team

Joined: Thu Dec 18, 2003 9:55 am
Posts: 1977
Location: France
are you sure of your id?

_________________
Anthony,
Get value thanks to your skills: http://www.redhat.com/certification


Top
 Profile  
 
 Post subject:
PostPosted: Wed Sep 01, 2004 3:02 pm 
Beginner
Beginner

Joined: Fri Apr 16, 2004 10:25 am
Posts: 44
Location: Brazil
in fact I was using just inxDoc as PK, but the primary key is composed of
inxDoc and codCli


Top
 Profile  
 
 Post subject:
PostPosted: Wed Sep 01, 2004 3:15 pm 
Beginner
Beginner

Joined: Fri Apr 16, 2004 10:25 am
Posts: 44
Location: Brazil
Now, I'm having problems setting the relationship

here is a image of the Database
Image

and my mappings

Code:
    <class name="com.br.resource.csu.lembranca.dao.hibernate.persisted.DocumentoRegra" table="SSC_rel_doc_regra">
        <composite-id>
         <key-many-to-one name="inxRegraCampanha" column="inx_regra_campanha"/>
           <key-many-to-one name="docPK" class="com.br.resource.csu.lembranca.dao.hibernate.persisted.DocumentoPK">
              <column name="COD_CLI"/>
              <column name="inx_doc"/>
           </key-many-to-one>
        </composite-id>
        <property    name="datAplicaRegra"   column="dat_aplica_regra"/>
        <property    name="datPrevRegra"     column="dat_prev_regra"/>
        <property    name="indStatusRegra"   column="ind_status_regra"/>
        <property    name="vlrResultRegra"   column="vlr_result_regra"/>
        <property    name="dscObs"           column="dsc_obs"/>
        <property    name="flgRetornoLight"  column="FLG_RETORNO_LIGHT"/>
    </class>

    <class name="com.br.resource.csu.lembranca.dao.hibernate.persisted.Documento" table="SSC_documento">
        <composite-id name="docPK" class="com.br.resource.csu.lembranca.dao.hibernate.persisted.DocumentoPK">
         <key-many-to-one name="codCli" column="COD_CLI"/>
          <key-property name="inxDoc" column="INX_DOC"/>
        </composite-id>
      <set name="regras" inverse="true" lazy="true" cascade="all">
          <key column="inx_doc"/>
          <one-to-many class="com.br.resource.csu.lembranca.dao.hibernate.persisted.DocumentoRegra"/>
      </set>
        <property name="codClasse" column="COD_CLASSE"/>
        <property name="codInstalacao"  column="COD_INSTALACAO"/>
        <property name="codLivroLeitura"        column="COD_LIVRO_LEITURA"/>
        <property name="codLocalidade"  column="COD_LOCALIDADE"/>
        <property name="codLoteFaturamento"     column="COD_LOTE_FATURAMENTO"/>
        <property name="codMotivoExc"   column="COD_MOTIVO_EXC"/>
        <property name="codTipoDoc"     column="COD_TIPO_DOC"/>
        <property name="codUnidOper"    column="COD_UNID_OPER"/>
        <property name="datCriacaoFatura"       column="DAT_CRIACAO_FATURA"/>
        <property name="datEmissaoFatura"       column="DAT_EMISSAO_FATURA"/>
        <property name="datExc" column="DAT_EXC"/>
        <property name="datFimCob"      column="DAT_FIM_COB"/>
        <property name="datInclusaoReg" column="DAT_INCLUSAO_REG"/>
        <property name="datIniCob"      column="DAT_INI_COB"/>
        <property name="datPrevCorte"   column="DAT_PREV_CORTE"/>
        <property name="datProcArqOrg"  column="DAT_PROC_ARQ_ORG"/>
        <property name="datVenctoFatura"        column="DAT_VENCTO_FATURA"/>
        <property name="flgDebAut"      column="FLG_DEB_AUT"/>
        <property name="indContencioso" column="IND_CONTENCIOSO"/>
        <property name="mesRefFatura"   column="MES_REF_FATURA"/>
        <property name="numFatura"      column="NUM_FATURA"/>
        <property name="qtdTentativa"   column="QTD_TENTATIVA"/>
        <property name="totFaturaAvisoDeb"      column="TOT_FATURA_AVISO_DEB"/>
        <property name="vlrFatura"      column="VLR_FATURA"/>
    </class>


Top
 Profile  
 
 Post subject:
PostPosted: Wed Sep 01, 2004 5:55 pm 
Beginner
Beginner

Joined: Fri Apr 16, 2004 10:25 am
Posts: 44
Location: Brazil
solved


Code:
    <class name="com.br.resource.csu.lembranca.dao.hibernate.persisted.Documento" table="SSC_documento">
        <composite-id name="docPK" class="com.br.resource.csu.lembranca.dao.hibernate.persisted.DocumentoPK">
         <key-many-to-one name="codCli" column="COD_CLI"/>
          <key-property name="inxDoc" column="INX_DOC"/>
        </composite-id>
      <set name="regras" inverse="true" lazy="true" cascade="all">
          <key>
             <column name="inx_doc"/>
             <column name="cod_cli"/>
          </key>
          <one-to-many class="com.br.resource.csu.lembranca.dao.hibernate.persisted.DocumentoRegra"/>
      </set>
        <property name="codClasse" column="COD_CLASSE"/>
        <property name="codInstalacao"  column="COD_INSTALACAO"/>
        <property name="codLivroLeitura"        column="COD_LIVRO_LEITURA"/>
        <property name="codLocalidade"  column="COD_LOCALIDADE"/>
        <property name="codLoteFaturamento"     column="COD_LOTE_FATURAMENTO"/>
        <property name="codMotivoExc"   column="COD_MOTIVO_EXC"/>



Code:
    <class name="com.br.resource.csu.lembranca.dao.hibernate.persisted.DocumentoRegra" table="SSC_rel_doc_regra">
        <composite-id>
         <key-many-to-one name="inxRegraCampanha" column="inx_regra_campanha"/>
           <key-many-to-one name="doc" class="com.br.resource.csu.lembranca.dao.hibernate.persisted.Documento">
              <column name="COD_CLI"/>
              <column name="inx_doc"/>
           </key-many-to-one>
        </composite-id>
        <property    name="datAplicaRegra"   column="dat_aplica_regra"/>
        <property    name="datPrevRegra"     column="dat_prev_regra"/>
        <property    name="indStatusRegra"   column="ind_status_regra"/>
        <property    name="vlrResultRegra"   column="vlr_result_regra"/>
        <property    name="dscObs"           column="dsc_obs"/>
        <property    name="flgRetornoLight"  column="FLG_RETORNO_LIGHT"/>
    </class>


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