-->
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.  [ 7 posts ] 
Author Message
 Post subject: Criteria, double class in clause
PostPosted: Wed Jul 28, 2004 8:14 am 
Newbie

Joined: Wed Jul 28, 2004 8:03 am
Posts: 8
Location: Porto Alegre - Brazil
Hi friends!
How I can put double class in Criteria?
Well, my hql is:

Code:
String sql = " from br.com.ag2.quatromais.vo.Compromisso as c where " +" c.dthInicioCompromisso >= " + dtInitial
+ " and c.dthFimCompromisso <= " + dtFinal
+" and  c.agenda.campanha.codCampanha = " + cod_campanha
+" order by c.dthInicioCompromisso asc";


I try make this:

Code:
Criteria criteria = session.createCriteria(Compromisso.class);
Date dtInitial = compromisso.getDthInicioCompromisso();
Date dtFinal = compromisso.getDthFimCompromisso();
criteria.add( Expression.ge("dthInicioCompromisso",dtInitial));
criteria.add( Expression.le("dthFimCompromisso",dtFinal));
criteria.add( Expression.eq("agenda.campanha.codCampanha",cod_campanha));
criteria.addOrder(Order.asc("dthInicioCompromisso"));


But in line
Code:
criteria.add( Expression.eq("agenda.campanha.codCampanha",cod_campanha));


Hibernate acuse an error:

Quote:
2004-07-28 09:12:01,140 ERROR opensymphony.xwork.ActionSupport -> Error in findCompromisso: net.sf.hibernate.QueryException: could not resolve property: agenda.campanha.codCampanha of: br.com.ag2.quatromais.vo.Compromisso


But this property exists!
My HQL work correctly.

Well, any help is welcome!

Thanks friends!

Regards

_________________
Dalton Camargo
JEE Software Architect
JavaFree.org Founder
JavaBB.org Owner
Technical Revisor of Spring in Action the Book to Portuguese


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jul 28, 2004 11:33 am 
Beginner
Beginner

Joined: Fri Mar 26, 2004 8:19 am
Posts: 49
Can you post the src of br.com.ag2.quatromais.vo.Compromisso ?


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jul 28, 2004 12:59 pm 
Newbie

Joined: Wed Jul 28, 2004 8:03 am
Posts: 8
Location: Porto Alegre - Brazil
toastchee wrote:
Can you post the src of br.com.ag2.quatromais.vo.Compromisso ?


Sure!

Code:
   /** identifier field */
   private Integer codCompromisso;

   /** persistent field */
   private Date dthInicioCompromisso;

   /** persistent field */
   private String txtLocal;

   /** persistent field */
   private Date dthFimCompromisso;

   /** persistent field */
   private String txtCompromisso;

   /** persistent field */
   private String txtAssunto;

   /** nullable persistent field */
   private String txtObservacoes;

   /** nullable persistent field */
   private Integer indConfirmado;

   /** nullable persistent field */
   private String txtRelatorioReuniao;

   /** persistent field */
   private br.com.ag2.quatromais.vo.Agenda agenda;

   /** persistent field */
   private br.com.ag2.quatromais.vo.AreaGeografica areaGeografica;

   /** persistent field */
   private Set participants;



And your XML:
Code:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
    "-//Hibernate/Hibernate Mapping DTD 2.0//EN"
    "http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd" >
   
<hibernate-mapping>
<class
    name="br.com.ag2.quatromais.vo.Compromisso"
    table="compromisso"
>

    <id
        name="codCompromisso"
        type="java.lang.Integer"
        column="cod_compromisso"
    >
        <generator class="assigned" />
    </id>

    <property
        name="dthInicioCompromisso"
        type="java.sql.Date"
        column="dth_inicio_compromisso"
        not-null="true"
        length="4"
    />
    <property
        name="txtLocal"
        type="java.lang.String"
        column="txt_local"
        not-null="true"
        length="200"
    />
    <property
        name="dthFimCompromisso"
        type="java.sql.Date"
        column="dth_fim_compromisso"
        not-null="true"
        length="4"
    />
    <property
        name="txtCompromisso"
        type="java.lang.String"
        column="txt_compromisso"
        not-null="true"
        length="8000"
    />
    <property
        name="txtAssunto"
        type="java.lang.String"
        column="txt_assunto"
        not-null="true"
        length="100"
    />
    <property
        name="txtObservacoes"
        type="java.lang.String"
        column="txt_observacoes"
        length="8000"
    />
    <property
        name="indConfirmado"
        type="java.lang.Integer"
        column="ind_confirmado"
        length="4"
    />
    <property
        name="txtRelatorioReuniao"
        type="java.lang.String"
        column="txt_relatorio_reuniao"
        length="8000"
    />

    <!-- Associations -->
 
    <!-- bi-directional one-to-many association to Participant -->
    <set
        name="participants"
        lazy="true"
        inverse="true"
    >
        <key>
            <column name="cod_compromisso" />
        </key>
        <one-to-many
            class="br.com.ag2.quatromais.vo.Participant"
        />
    </set>
    <!-- bi-directional many-to-one association to Agenda -->
    <many-to-one
        name="agenda"
        class="br.com.ag2.quatromais.vo.Agenda"
        not-null="true"
    >
        <column name="cod_agenda" />
    </many-to-one>
    <!-- bi-directional many-to-one association to AreaGeografica -->
    <many-to-one
        name="areaGeografica"
        class="br.com.ag2.quatromais.vo.AreaGeografica"
        not-null="true"
    >
        <column name="cod_area" />
    </many-to-one>

</class>
</hibernate-mapping>


Well, in HQL work correctly, but wen I try change the style of my search for Criteria, appear the error!

Thanks!

_________________
Dalton Camargo
JEE Software Architect
JavaFree.org Founder
JavaBB.org Owner
Technical Revisor of Spring in Action the Book to Portuguese


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jul 28, 2004 3:22 pm 
Beginner
Beginner

Joined: Fri Mar 26, 2004 8:19 am
Posts: 49
how about agenda and campanha?

:-)

thx


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jul 29, 2004 8:12 am 
Newbie

Joined: Wed Jul 28, 2004 8:03 am
Posts: 8
Location: Porto Alegre - Brazil
toastchee wrote:
how about agenda and campanha?

:-)

thx


Hhehe
My question is simple.
How I can putt 2 classes in Criteria search?

;)

Regards

_________________
Dalton Camargo
JEE Software Architect
JavaFree.org Founder
JavaBB.org Owner
Technical Revisor of Spring in Action the Book to Portuguese


Top
 Profile  
 
 Post subject:
PostPosted: Tue Aug 17, 2004 4:43 pm 
Beginner
Beginner

Joined: Thu Sep 11, 2003 12:53 pm
Posts: 23
Have you looked at the examples here?

Specifically, section 12.4?

WILL


Top
 Profile  
 
 Post subject:
PostPosted: Thu Sep 02, 2004 2:10 pm 
Newbie

Joined: Thu Sep 02, 2004 1:39 pm
Posts: 1
hi,

try this:

agendaCriteria.createCriteria( "campanha" ).add( ... )

_________________
cya.


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