Hi!
i have 3 tables : item, sub_item and bid and 3 classes: Item, SubItem and Bid. And ResultItem class as result bean.
I have this select:
Code:
return getHibernateTemplate().find("select new com.app.model.ResultItem(" +
"item.createDate, item.publishDate, item.finishDate, " +
"size(item.bids), " +
"(select max(bid.bidPrice) as max from item.bids bid) " +
") from Item item where item.owner = ? " +
"group by item.id, item.createDate, item.publishDate, item.finishDate", owner);
}
and in ResultItem class this constructor:
Code:
public ResultItem(Date createDate, Date publishDate, Date finishDate,
Integer numberOfBids, Double maxBid) {
this.createDate = createDate;
this.publishDate = publishDate;
this.finishDate = finishDate;
this.numberOfBids = numberOfBids;
this.maxBid = maxBid;
}
and everything is OK. BUT, i need add next property of Item (collection):
List subItems (connection to sub_item table):
Code:
return getHibernateTemplate().find("select new com.app.model.ResultItem(" +
"item.createDate, item.publishDate, item.finishDate, " +
"item.subItems, " +
"size(item.bids), " +
"(select max(bid.bidPrice) as max from item.bids bid) " +
") from Item item where item.owner = ? " +
"group by item.id, item.createDate, item.publishDate, item.finishDate", owner);
}
and constructor:
Code:
public FreeOfferFreightSearchResultItem(Date createDate, Date publishDate, Date finishDate, List subItems,
Integer numberOfBids, Double maxBid) {
this.createDate = createDate;
this.publishDate = publishDate;
this.finishDate = finishDate;
this.numberOfBids = numberOfBids;
this.maxBid = maxBid;
this.subItems = subItems;
}
but, it is not correct, please how can I select simple properites (Integer, Date, ..), count(*) or size(), MAX (or MIN) and collection in ONE select.
error message:
org.springframework.orm.hibernate3.HibernateQueryException: Unable to locate appropriate constructor on class [com.app.model.ResultItem]
thanks!
Ivan