On 7/26/07, Allen Gilliland <[EMAIL PROTECTED]> wrote:
Dave wrote: > On 7/26/07, Allen Gilliland <[EMAIL PROTECTED]> wrote: >> Is there a reason why we had to do this as a new method? Wouldn't we >> want folder.getBookmarks() to just return the sorted collection? > > I didn't want to muck with the getBookmarks() method because it is an > ORM managed relationship, i.e. JPA fetches the bookmarks. Think we > should manage that relationship instead so we can have one method? Hmm, I think the best thing is to leave the relationship as managed by the ORM tool, but configure things so that the collection comes out sorted. I think that should be doable, although it's a little more complicated with bookmarks because they are sorted by a separate priority field. If we can't get the ORM tool to properly sort things then I think the next best option is to just have the pojo wrapper method do the sorting. I don't see any reason why folderWrapper.getBookmarks() can't start by getting the collection via the real pojo, then sort the collection, then wrap. Or alternatively the order could be to get the collection via the real pojo, wrap them, then sort.
The folder wrapper's getBookmarks() method now does the sorting, so now there is no new getBookmarksSorted() method. If we figure out how to get a sorted collection back from JPA via that one-to-many relationship, the change will be transparent. - Dave
