Reputation: 12207
I have a Card
class, which has an eager ForeignCollection
in it. I have to query for the instances of this class with a Dao.queryRaw()
, because my SELECT
is too complicated to be built with a simple QueryBuilder
(see my other question). This is how i query and build my objects with RawRowMapper
:
GenericRawResults<String[]> rawResults = getCardDao().queryRaw(statement);
List<Card> results = new ArrayList<Card>();
for (String[] row : rawResults) {
results.add(getCardDao().getRawRowMapper().mapRow(rawResults.getColumnNames(), row));
}
rawResults.close();
Unfortunately when i try to get the ForeignCollection
on my objects, it returns null. If i query the objects with a simple Dao.queryForFirst
, the ForeignCollection
is OK.
Upvotes: 0
Views: 288
Reputation: 104
I have had the same problem today. My solution has been to call something as
dao.refresh(<Card object>)
for every object returned by the queryRaw function (and accumulated into "results" list). This do the trick for me, reloading objects from DB with filled foreign collection.
Upvotes: 1