In my project I got a table where I register when a user logs on.
When I changed the name of the log table, I had to change the name in all the sql statements.
Is there a better way to do this? I thought about using a constant. Is that a good solution?
Code:
public class UserLogDaoImpl implements UserLogDao {
private static final String TABLE_NAME = "UserLog";
public List getLogsByUsername(String username, int i){
Session session = HibernateUtil.getSessionFactory().getCurrentSession();
session.beginTransaction();
List logs = session.createQuery("select l from TABLE_NAME as l where l.username=:u").setMaxResults(i).setString("u", username).list();
session.getTransaction().commit();
return logs;
}