Some changes in DAO.stg and BaseDAO.stg. refs #500, #498