The solution

The interface for interacting with your database table breaks down as follows:
Coding the solution involves these steps:

Create an entity interface java file

Create a new java file named after your entity, and declare an interface extending StandardEntity:

Figure 1. Creating an entity interface file
package curam.mypackage;

import curam.util.persistence.StandardEntity;

/**
 * Description of my wonderful new entity.
 */
public interface MyNewEntity extends StandardEntity {
}

The StandardEntity super-interface provides a standard API for all entities, and must be extended by all entity APIs.

As far as callers of your code are concerned, this interface "is" your entity, which is why (by convention) you name the entity interface after your entity. Ensure that the interface is well-commented.

So far your new entity API doesn't do very much, but that'll change during later the scenarios.

Note that not all interfaces need to be public - if the interface does not need to be visible outside of its package then remove the "public" declaration and make the interface "package-private". Typically this can only be done with entities which are not exposed to calling code, e.g. link tables which do not (directly) appear on UI screens. Only make an interface public if it needs to be (which is usually the case).

Only include methods in your interface which must be visible to other classes - implementation-only methods will exist only in your implementation class (see Coding service-layer implementations).

Create an entity DAO interface java file

Create another interface in the same java package, named after your entity but suffixed with "DAO", extending StandardDAO (typed with your entity interface):

Figure 2. Creating an entity DAO interface file
package curam.mypackage;

import curam.util.persistence.StandardDAO;

/**
 * Data access for {@linkplain MyNewEntity}.
 */
public interface MyNewEntityDAO extends StandardDAO<MyNewEntity> {
}
The StandardDAO super-interface must be extended by all entity DAO APIs. It provides two DAO API methods "for free":
  • newInstance() - creates a new instance of MyNewEntity suitable for inserting onto the database; and
  • get(Long id) - retrieves the instance of MyNewEntity with the primary key value specified by id

Your DAO declares that it is responsible for managing MyNewEntity instances by virtue of the type argument to StandardDAO.

In a later scenario you will add additional methods to the DAO interface.