In you approach you actually have no DAO layer.
The common approach for Service Layer with DAO will be
@NamedQueries({
@NamedQuery(name="abc", query="test")
})
@Entity
@Table(name = "MY_TABLE")
public class MyTable
@Repository
public class MyTableDAOImpl implements MyTableDAO
@Autowire
protected SessionFactory sessionFactory;
public MyTable myMethod1() {
Query query = session.getNamedQuery("abc")
.setInteger("id",1).setString("name", "testname");
return (MyTable) query.uniqueResult();}
public MyTable myMethod2() { ...}
@Service
public class MyTableServiceImpl implements MyTableService
@Autowire
protected MyTableDAO myTableDAO;
public MyTable myMethodService() {
//Some logic
...
return myTableDAO.myMethod1()
}
The purpose of having the named queries is that they are compiled and validated at app start-up time See Advantages of Named queries in hibernate?
I suggest that you will consider the GenericDAO pattern