Partial Objects

Partial objects are where part of the entity bean is populated. This is an important feature for performance and also design reasons.


Queries - Partial Objects covers how to query partial objects.


A Partial Object will lazy load the rest of the data on demand when you get or set a property it does not have.

// find order 12
// ... fetching the order id, orderDate and version property
// .... nb: the Id and version property are always fetched

Order order = Ebean.find(Order.class)

// shipDate is not in the partially populated order
// ... so it will lazy load all the missing properties
Date shipDate = order.getShipDate();

// similarly if we where to set the shipDate 
// ... that would also trigger a lazy load
order.setShipDate(new Date());

Lazy loading occurs automatically when you set or get a property that the partially populated bean does not have.


You can save or delete a Partial Object.

// find customer 1
// ... just fetch the customer id, name and version property
Customer customer = Ebean.find(Customer.class)


The query generates the following SQL...

<sql summary='[]'>
from or_customer c 
where = ?  

... and in the transaction logs we can find the update dml and bind values.

... update or_customer set name=?, updtime=? where id=? and name=? 
... Binding Update [or_customer]  set[name=CoolName, updtime=2008-11-19 10:58:08.598, ] where[id=1, name=Ford, ] 
... Updated [] [1] 
Introduction User Guide (pdf) Install/Configure Public JavaDoc Whitepapers
General Database Specific Byte Code Deployment Annotations Features
Top Bugs Top Enhancements