I am using Hibernate (3.3.x) and I have two objects:
public class FtChargeAcctPkgDtl { private FtChargeAcctPkgDtlId id; private Set<FtChargeAcctPkgRate> ftChargeAcctPkgRates; }
and
public class FtChargeAcctPkgRate { private FtChargeAcctPkgRateId id; }
(other attributes and settings for simplicity).
I have my own request:
<sql-query name="readSymbolsFtPackages"> <return alias="pkgDtl" class="somepackage.FtChargeAcctPkgDtl"/> <return-join alias="pkgRate" property="pkgDtl.ftChargeAcctPkgRates"/> <![CDATA[ SELECT {pkgDtl.*}, {pkgRate.*} FROM ft_charge_acct_pkg_dtl pkgDtl JOIN ft_charge_acct_pkg_rate pkgRate ON pkgRate.master_seq_no = pkgDtl.master_seq_no -- just primary key AND pkgRate.pkg_id = pkgDtl.pkg_id ]]> </sql-query>
The assumption is that the query (I want it) returns one row for each item in pkgDtl, populating FtChargeAcctPkgDtl # ftChargeAcctPkgRates. But actually it returns one line for each element in ft_charge_acct_pkg_rate.
Suppose there are 5 rows in the main (pkgDtl) table and 50 in the combined table (average 10 pkgRates for one pkgDtl). When I call a request with
Query query = session.getNamedQuery("readSymbolsFtPackages"); query.list();
I get 50 lines. However, 45 of them are duplicates. I want to get these 5 pkgDtls and each with filled pkdRates. Is there any way to do this in sleep mode?
source share