hi!
I have a many-to-one relationship (Proposal has many ProposalDetail)and it works great.
I would like compute for a given Proposal the sum of certain fields in its ProposalDetail.
I tried reading the hibernate doc but doesnt say much on formula properties... can someone help or give a suggestion?
P.D: My domain objects know nothing of hibernate, DAO's are the only ones that know anything about hibernate
Ive got this mappings
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="com.cce.domain.proposal.Proposal"
table="package_contractor"
dynamic-update="false"
dynamic-insert="false"
>
<id
name="id"
column="id"
type="long"
unsaved-value="0"
>
<generator class="native">
</generator>
</id>
<set
name="proposalItems"
lazy="true"
inverse="true"
cascade="all-delete-orphan"
sort="unsorted"
>
<key
column="package_contractor"
/>
<one-to-many
class="com.cce.domain.proposal.ProposalItem"
/>
</set>
<property formula="????????" >
</class>
</hibernate-mapping>
And this other class
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="com.cce.domain.proposal.ProposalItem"
table="proposaldetail"
dynamic-update="false"
dynamic-insert="false"
>
<id
name="id"
column="id"
type="long"
unsaved-value="0"
>
<generator class="native">
</generator>
</id>
<property
name="unitLabour"
type="double"
update="true"
insert="true"
column="unit_labor"
/>
<property
name="quantity"
type="double"
update="true"
insert="true"
column="quantity"
/>
<property
name="unit_cost"
type="double"
update="true"
insert="true"
column="unit_cost"
/>
<many-to-one
name="proposal"
class="com.cce.domain.proposal.Proposal"
cascade="none"
outer-join="auto"
update="true"
insert="true"
column="package_contractor"
/>
</class>
</hibernate-mapping>
thanks anyone![/b]