Lazy loading and fetch type

The ActionScript persistent framework supports lazy loading although it may not be as intuitive because of the asynchronous connection with the database.

The fetch type EAGER or LAZY determines the fetch type for the relationship that is loaded. An EAGER fetch type loads the relationship and fetches data when the call is first made. A LAZY fetch type loads the relationship and fetches data only when an explicit fetch call is made. The default value for the fetch type is EAGER and the default value for ignoreLazyLoad is false.

When you specify fetchType="EAGER" at the class-definition level, the loadByPk function always loads the related object, irrespective of the value you specify for the ignoreLazyLoad parameter.

When you specify fetchType="LAZY" at the class-definition level, you can have two possibilities:

  • When you specify the ignoreLazyLoad parameter as true, the related object is also loaded. For example, if you have two related objects Address and Customer, and specify loadByPK(Customer,{id:3},true), the Address object is also loaded.

  • When you do not specify any value for the ignoreLazyLoad parameter, it takes the default value that is false, and the related object is not loaded. For example, if you have two related objects Address and Customer, and specify loadByPK(Customer,{id:3}), the Address object is not loaded.