My question is how can I add a specific query to what’s been generated by reverse JPA engineering without having it overwritten if I have to redo the reverse JPA engineering?
Instead of just the reverse engineering generated code findAll() below, I want to return specific records based on the time difference between the current date/time and what’s in a date/time field in my database.
I think I could add the code in a manner consistent with what’s been generated, but I fear it would be wiped out.
IMonitorScheduleDAO.java
/**
* Find all MonitorSchedule entities.
*
* @return List<MonitorSchedule> all MonitorSchedule entities
*/
public List<MonitorSchedule> findAll();
IMonitorScheduleDAO.java
/**
* Find all MonitorSchedule entities.
*
* @return List<MonitorSchedule> all MonitorSchedule entities
*/
@SuppressWarnings(“unchecked”)
public List<MonitorSchedule> findAll() {
logger.info(“finding all MonitorSchedule instances”);
try {
final String queryString = “select model from MonitorSchedule model”;
return getJpaTemplate().executeFind(new JpaCallback() {
public Object doInJpa(EntityManager em)
throws PersistenceException {
Query query = em.createQuery(queryString);
return query.getResultList();
}
});
} catch (RuntimeException re) {
logger.error(“find all failed”, re);
throw re;
}
}