Posted at

Ebean - Lazy load to check resource existence

More than 5 years have passed since last update.


[1]: Stack Overflow - Ebean lazy load to see if resource exists

When you delete, check count or check existence of one resource, fetch the "resource body" may cause an extra cost. This cost may potentially influence the performance.

In case of that, when you do some query that does not actually need load all data of resource, you might need concept of lazy load.

In Ebean, you could do:

boolean itemExists 

= (YourModel.find.where().eq("id", id).findRowCount() == 1) ? true : false;