I did not see this in new book, doc or forum, so thought that I would post my expereince with Oracle.
Parent child relationship between itinerary and res_core.
The test query with a hardcoded ID is:
select
itinerary_id as ITINERARY,
sum(rc.grand_total) as TOTAL,
max(rc.total_night_stay) as NIGHTS,
min(rc.arrival_date) as ARRIVAL ,
max(rc.departure_date) as DEPARTURE
from res_core RC
where itinerary_id = 14679 and
res_type = 'L' and
reservation_status != 'C'
group by itinerary_id;
The Java is:
List result = session.createSQLQuery(
"select itinerary_id as itinerary, "+
"sum(rc.grand_total) as total, "+
"max(rc.total_night_stay) as nights, "+
"min(rc.arrival_date) as arrival, "+
"max(rc.departure_date) as departure "+
"from res_core rc "+
"where itinerary_id = 14679 and "+
" res_type = 'L' and "+
" reservation_status != 'C' group by itinerary_id" )
.addEntity(IineraryResSummary.class).list();
The Class is unsurprising:
public class IineraryResSummary implements java.io.Serializable{
private BigDecimal itinerary;
private BigDecimal total;
private BigDecimal nights;
private Date arrival;
private Date departure;
plus the standard stuff.
And the mapping file is:
<hibernate-mapping>
<class name="us.cenres.creditcard.model.IineraryResSummary" table="Iinerary_Res_Summary">
<id name="itinerary" type="big_decimal">
<column name="ITINERARY" precision="22" scale="0" />
<generator class="assigned" />
</id>
<property name="total" type="big_decimal">
<column name="TOTAL" precision="5" scale="0" />
</property>
<property name="nights" type="big_decimal">
<column name="NIGHTS" precision="5" scale="0" />
</property>
<property name="arrival" type="date">
<column name="ARRIVAL" length="7" />
</property>
<property name="departure" type="date">
<column name="DEPARTURE" length="7" />
</property>
</class>
</hibernate-mapping>
[code]
Since this is a read only query, I'm assuming that the bogus table in the mapping file will not cause any problems when I move from JUnit-land to production.
Regards[/code]
|