Here is a piece of my code. I have a DAO-Class (TerminDAO) where are my methods for reading/saving data from/into the database. Is this allright so?
Code:
class TerminDAO
...
...
public List queryTermin(java.sql.Timestamp from, java.sql.Timestamp to) throws InfrastructureException {
List result;
try {
Session session = HibernateUtil.getSession();
String queryString = "from Termin t "
+ "where t.timestamp >= :from and "
+ "t.timestamp <= :to";
Query q = session.createQuery(queryString)
.setParameter("from", from, Hibernate.TIMESTAMP)
.setParameter("to", to, Hibernate.TIMESTAMP);
result = q.list();
HibernateUtil.commitTransaction();
}
catch (HibernateException ex) {
System.out.println("TerminDAO: queryTermin:Error:" + ex.toString());
throw new InfrastructureException(ex);
}
HibernateUtil.closeSession();
return result;
}