Embedded Columns of another Object

A class can be marked with the @SeifeEmbeddable annotation then its fields can be embedded into the sql table of other business objects. This is sometimes called flat mapping of objects. Suppose there is structured data such as an address that is used at several places throughout your project.

@SeifeEmbeddable
public class Address {
   @SeifeField
   private String street;
   @SeifeField
   private String zipcode;
   @SeifeField
   private String city;
   @SeifeField
   private String state;
}

The system supports mapping these fields even with a prefix. The following code will suffice to let the code generator create the remaining data access objects for  SQLite and if required for the Parcelable API;

@SeifeClass
public class Customer {
   @SeifeField
   private Long id;

   @SeifeField
   private String name;

   @SeifeEmbedded(prefix="billing_")
   private Address billingAddress;

   @SeifeEmbedded(prefix="delivery_")
   private Address deliveryAddress;

   public Address getBillingAddress() {
      if (billingAddress == null) {
         billingAddress = new Address();
      }
      return billingAddress;
   }

   public Address getDeliveryAddress() {
      if (deliveryAddress == null) {
         deliveryAddress = new Address();
      }
      return deliveryAddress;
   }
}

This simple code creates an sql table definition containing columns like delivery_street, delivery_zipcode and includes code that delegates to the address instance when reading from the object in memory or loading the data from a cursor to memory. The programmer only needs to ensure that the getter access methods referring to the embedded object cannot be null.
For the complete example see the project with samples on GitHub (or this direct link to a schema peer with @Embedded annotation)

This type of architecture comes in handy when a data copy needs to be kept for a record. Suppose a customer orders a product, during the purchase the important data of the product such as its current price are saved in the order item of the purchase order. If the price of the product changes in the future the purchase order data remains valid. Embedded objects can group the relevant fields and the same instance can be used during in-memory creation of the purchase order item object. When written to the database it is stored in the context of the purchase order.