Let's now revisit the domain layer created in Chapter 3, Reverse Engineering the Domain Layer with JPA. Defining an ancestor class for all entities in this layer is not only the best practice but will also make our domain layer far easier to enhance in the future. Our ancestor class is defined as follows:
package com.gieman.tttracker.domain; import java.io.Serializable; public abstract class AbstractEntity implements Serializable{ }
Although this class has an empty implementation, we will add functionality in subsequent chapters.
We will also define an appropriate interface that has one generic method to return the ID of the entity:
package com.gieman.tttracker.domain; public interface EntityItem<T> { public T getId(); }
Our domain layer can now extend our base AbstractEntity
class and implement the EntityItem
interface. The changes required to our Company
class follows:
public class Company extends AbstractEntity implements EntityItem<Integer...