Reputation: 2023
I have ORMLite db object and it has a field:
@ForeignCollectionField(eager = true)
public ForeignCollection<BlockMod> blocks;
Now when I want to get all collection of blocks for current object I call:
public BlockMod[] getBlocks(){
return blocks.toArray((BlockMod[])java.lang.reflect.Array.newInstance(BlockMod.class, blocks.size()));
}
My question is how to get this collection with custom sorting? I know I could iterate this data and order it as I want, but is that the best solution?
Is ORMLite doing db request when I ask for ForeignCollection, or is it collected when I initialized main Object?
Upvotes: 0
Views: 1012
Reputation: 63
may be, this code
@ForeignCollectionField(eager = false, orderColumnName = "name")
help you to custom sorting for Foreign Collection
Upvotes: 2