-->
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.  [ 1 post ] 
Author Message
 Post subject: formula property and wrong query generated in firebird db
PostPosted: Wed Jul 21, 2004 6:31 pm 
Beginner
Beginner

Joined: Thu Jul 08, 2004 8:56 am
Posts: 23
I need to have a property in a class that is a sum of another property in a set. I've already seen a post here in the forum and basically copied the solution. But the query that I get is wrong. I am going to post the two hbm files here:

<!DOCTYPE hibernate-mapping PUBLIC '-//Hibernate/Hibernate Mapping DTD 2.0//EN' 'http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd'>
<hibernate-mapping default-cascade="all">
<class name="fundarpe.fontesderecurso.FonteDeRecurso" table="fontesderecurso">
<id name="numero" column="numero" type="int" unsaved-value="null">
<generator class="assigned"/>
</id>
<property name="descricao" column="descricao" type="string" length="65" not-null="true"/>
<property name="saldo" column="saldo" type="double" formula="(select sum(Lancamentos.valor) from Lancamentos where (Lancamentos.fonteDeRecurso = id))" />
<set name="lancamentos" cascade="all" inverse="true" lazy="true">
<key column="id"/>
<one-to-many class="fundarpe.fontesderecurso.Lancamento"/>
</set>
<set name="processos" cascade="all" inverse="true" lazy="true">
<key column="id"/>
<one-to-many class="fundarpe.processos.Processo"/>
</set>
</class>
</hibernate-mapping>

----------------------------

<!DOCTYPE hibernate-mapping PUBLIC '-//Hibernate/Hibernate Mapping DTD 2.0//EN' 'http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd'>
<hibernate-mapping default-cascade="all">
<class name="fundarpe.fontesderecurso.Lancamento" table="lancamentos" discriminator-value="L">
<id name="id" column="id" type="long" unsaved-value="null">
<generator class="native"/>
</id>
<discriminator column="tipolancamento" type="character"/>
<property name="descricao" column="descricao" type="string" length="65" not-null="true"/>
<property name="valor" column="valor" type="double" not-null="true"/>
<property name="data" column="data" type="date" not-null="true"/>
<many-to-one name="fonteDeRecurso" class="fundarpe.fontesderecurso.FonteDeRecurso" column="fontederecurso"/>
<subclass name="fundarpe.fontesderecurso.Debito" discriminator-value="D"/>
<subclass name="fundarpe.fontesderecurso.Credito" discriminator-value="C"/>
<subclass name="fundarpe.fontesderecurso.Empenho" discriminator-value="E">
<many-to-one name="processo" class="fundarpe.processos.Processo" column="processo"/>
</subclass>
</class>
</hibernate-mapping>

--------------------------------------

the generated query:

select this.numero as numero0_, this.descricao as descricao0_, (select sum(Lancamentos.valor) from Lancamentos where (Lancamentos.fonteDeRecurso = this.id)) as f0_0_ from fontesderecurso this where 1=1


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

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.