My object contains the following private attribute ForeignCollection :
@ForeignCollectionField private ForeignCollection<Order> orderCollection; private List<Order> orderList;
What is the best way, or the usual way, to avoid using a ForeignCollection ? Is there any tidy way to return Collections data to the caller?
What does the following method look like? It allows the caller to access data through a List . Would you recommend doing this?
public List<Order> getOrders() { if (orderList == null) { orderList = new ArrayList<Order>(); for (Order order : orderCollection) { orderList.add(order); } } return orderList; }
source share