2. Persistence Marshalling Code

Marshalling service persistence interfaces that are separated into read-only and persistent operations, similar to the service layer.

Example 1. Excerpt from PersistenceFindMarshallingService in Spring by Example REST Module

The find persistence interface has constants for creating request paths and the basic find methods.

[Note]Note

Annotations specific to Spring by Example REST Module have been removed and replaced with '...'.

                
public interface PersistenceFindMarshallingService<R extends EntityResponseResult, FR extends EntityFindResponseResult> {

    ...
    
    /**
     * Find by primary key.
     */
    ...
    public R findById(... Integer id);

    /**
     * Find a paginated record set.
     */
    ...
    public FR find(... int page, ... int pageSize);

    /**
     * Find all records.
     */
    ...
    public FR find();

}

                
            

Example 2. Excerpt from PersistenceMarshallingService in Spring by Example REST Module

Save and delete are both overloaded so they would continue to work with existing backend tests, but also automatically work with Sencha stores.

[Note]Note

Annotations specific to Spring by Example REST Module have been removed and replaced with '...'.

            
                
public interface PersistenceMarshallingService<R extends EntityResponseResult, FR extends EntityFindResponseResult, S extends PkEntityBase> 
        extends PersistenceFindMarshallingService<R, FR> {

    ...
    
    /**
     * Save record.
     */
    ...
    public R create(... S request);
    
    /**
     * Update record.
     */
    ...
    public R update(... S request);

    /**
     * Delete record.
     */
    ...
    public R delete(... S request);
    
}