I have written an entity bean wrapper to the existing TABLE in PostgreSQL.
create table pr_base{ id varchar(100) no null, -- PK channel varchar(4), airdate date, (...) } CREATE INDEX idx_airdate_channel ON pr_base USING btree (airdate, channel);
public List findByDateChannel(String airdate, String channel){ return em.createQuery("FROM PrRecord pr WHERE airdate = :airdate and channel = :channel") .setParameter("airdate", airdate) .setParameter("channel", channel) .getResultList(); }