package curam.inheritance;
import java.util.Set;
import com.google.inject.Singleton;
import curam.inheritance.Cat;
import curam.inheritance.CatDAO;
import curam.inheritance.struct.CatDtls;
import curam.util.persistence.StandardDAOImpl;
@Singleton
public class CatDAO extends StandardDAOImpl<Cat, CatDtls> implements
CatDAO {
private static final CatAdapter adapter = new CatAdapter();
/**
* Protected no-arg constructor for use only by Guice
*/
protected CatDAO() {
super(adapter, Cat.class);
}
public Set<Cat> readAllCats() {
return newSet(adapter.readAll());
}
}
package curam.inheritance;
import java.util.Set;
import com.google.inject.Singleton;
import curam.inheritance.Dog;
import curam.inheritance.DogDAO;
import curam.inheritance.struct.DogDtls;
import curam.util.persistence.StandardDAOImpl;
@Singleton
public class DogDAO extends StandardDAOImpl<Dog, DogDtls> implements
DogDAO {
private static final DogAdapter adapter = new DogAdapter();
/**
* Protected no-arg constructor for use only by Guice
*/
protected DogDAO() {
super(adapter, Dog.class);
}
public Set<Dog> readAllDogs() {
return newSet(adapter.readAll());
}
}
The DAO classes for the concrete classes are straightforward DAO implementations.
CatDAOImpl and DogDAOImpl each support the creation of new instances of their respective entities, as well as retrieval of existing instances, by making use of the StandardDAOImpl class.